forked from OSchip/llvm-project
[mlir] do not use llvm.cmpxchg with floats
According to the LLVM Language Reference, 'cmpxchg' accepts integer or pointer types. Several MLIR tests were using it with floats as it appears possible to programmatically construct and print such an instruction, but it cannot be parsed back. Use integers instead. Depends On D85899 Reviewed By: flaub, rriddle Differential Revision: https://reviews.llvm.org/D85900
This commit is contained in:
parent
3b338e53e9
commit
9c4825ce28
|
@ -1216,27 +1216,27 @@ func @atomic_rmw(%I : memref<10xi32>, %ival : i32, %F : memref<10xf32>, %fval :
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
// CHECK-LABEL: func @generic_atomic_rmw
|
// CHECK-LABEL: func @generic_atomic_rmw
|
||||||
func @generic_atomic_rmw(%I : memref<10xf32>, %i : index) -> f32 {
|
func @generic_atomic_rmw(%I : memref<10xi32>, %i : index) -> i32 {
|
||||||
%x = generic_atomic_rmw %I[%i] : memref<10xf32> {
|
%x = generic_atomic_rmw %I[%i] : memref<10xi32> {
|
||||||
^bb0(%old_value : f32):
|
^bb0(%old_value : i32):
|
||||||
%c1 = constant 1.0 : f32
|
%c1 = constant 1 : i32
|
||||||
atomic_yield %c1 : f32
|
atomic_yield %c1 : i32
|
||||||
}
|
}
|
||||||
// CHECK: [[init:%.*]] = llvm.load %{{.*}} : !llvm.ptr<float>
|
// CHECK: [[init:%.*]] = llvm.load %{{.*}} : !llvm.ptr<i32>
|
||||||
// CHECK-NEXT: llvm.br ^bb1([[init]] : !llvm.float)
|
// CHECK-NEXT: llvm.br ^bb1([[init]] : !llvm.i32)
|
||||||
// CHECK-NEXT: ^bb1([[loaded:%.*]]: !llvm.float):
|
// CHECK-NEXT: ^bb1([[loaded:%.*]]: !llvm.i32):
|
||||||
// CHECK-NEXT: [[c1:%.*]] = llvm.mlir.constant(1.000000e+00 : f32)
|
// CHECK-NEXT: [[c1:%.*]] = llvm.mlir.constant(1 : i32)
|
||||||
// CHECK-NEXT: [[pair:%.*]] = llvm.cmpxchg %{{.*}}, [[loaded]], [[c1]]
|
// CHECK-NEXT: [[pair:%.*]] = llvm.cmpxchg %{{.*}}, [[loaded]], [[c1]]
|
||||||
// CHECK-SAME: acq_rel monotonic : !llvm.float
|
// CHECK-SAME: acq_rel monotonic : !llvm.i32
|
||||||
// CHECK-NEXT: [[new:%.*]] = llvm.extractvalue [[pair]][0]
|
// CHECK-NEXT: [[new:%.*]] = llvm.extractvalue [[pair]][0]
|
||||||
// CHECK-NEXT: [[ok:%.*]] = llvm.extractvalue [[pair]][1]
|
// CHECK-NEXT: [[ok:%.*]] = llvm.extractvalue [[pair]][1]
|
||||||
// CHECK-NEXT: llvm.cond_br [[ok]], ^bb2, ^bb1([[new]] : !llvm.float)
|
// CHECK-NEXT: llvm.cond_br [[ok]], ^bb2, ^bb1([[new]] : !llvm.i32)
|
||||||
// CHECK-NEXT: ^bb2:
|
// CHECK-NEXT: ^bb2:
|
||||||
%c2 = constant 2.0 : f32
|
%c2 = constant 2 : i32
|
||||||
%add = addf %c2, %x : f32
|
%add = addi %c2, %x : i32
|
||||||
return %add : f32
|
return %add : i32
|
||||||
// CHECK-NEXT: [[c2:%.*]] = llvm.mlir.constant(2.000000e+00 : f32)
|
// CHECK-NEXT: [[c2:%.*]] = llvm.mlir.constant(2 : i32)
|
||||||
// CHECK-NEXT: [[add:%.*]] = llvm.fadd [[c2]], [[new]] : !llvm.float
|
// CHECK-NEXT: [[add:%.*]] = llvm.add [[c2]], [[new]] : !llvm.i32
|
||||||
// CHECK-NEXT: llvm.return [[add]]
|
// CHECK-NEXT: llvm.return [[add]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -463,9 +463,9 @@ func @cmpxchg_expected_ptr(%f32_ptr : !llvm.ptr<float>, %f32 : !llvm.float) {
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
// CHECK-LABEL: @cmpxchg_mismatched_operands
|
// CHECK-LABEL: @cmpxchg_mismatched_operands
|
||||||
func @cmpxchg_mismatched_operands(%f32_ptr : !llvm.ptr<float>, %i32 : !llvm.i32) {
|
func @cmpxchg_mismatched_operands(%i64_ptr : !llvm.ptr<i64>, %i32 : !llvm.i32) {
|
||||||
// expected-error@+1 {{expected LLVM IR element type for operand #0 to match type for all other operands}}
|
// expected-error@+1 {{expected LLVM IR element type for operand #0 to match type for all other operands}}
|
||||||
%0 = "llvm.cmpxchg"(%f32_ptr, %i32, %i32) {success_ordering=2,failure_ordering=2} : (!llvm.ptr<float>, !llvm.i32, !llvm.i32) -> !llvm.struct<(i32, i1)>
|
%0 = "llvm.cmpxchg"(%i64_ptr, %i32, %i32) {success_ordering=2,failure_ordering=2} : (!llvm.ptr<i64>, !llvm.i32, !llvm.i32) -> !llvm.struct<(i32, i1)>
|
||||||
llvm.return
|
llvm.return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,9 +256,9 @@ func @atomicrmw(%ptr : !llvm.ptr<float>, %val : !llvm.float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECK-LABEL: @cmpxchg
|
// CHECK-LABEL: @cmpxchg
|
||||||
func @cmpxchg(%ptr : !llvm.ptr<float>, %cmp : !llvm.float, %new : !llvm.float) {
|
func @cmpxchg(%ptr : !llvm.ptr<i32>, %cmp : !llvm.i32, %new : !llvm.i32) {
|
||||||
// CHECK: llvm.cmpxchg %{{.*}}, %{{.*}}, %{{.*}} acq_rel monotonic : !llvm.float
|
// CHECK: llvm.cmpxchg %{{.*}}, %{{.*}}, %{{.*}} acq_rel monotonic : !llvm.i32
|
||||||
%0 = llvm.cmpxchg %ptr, %cmp, %new acq_rel monotonic : !llvm.float
|
%0 = llvm.cmpxchg %ptr, %cmp, %new acq_rel monotonic : !llvm.i32
|
||||||
llvm.return
|
llvm.return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1139,13 +1139,13 @@ llvm.func @atomicrmw(
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECK-LABEL: @cmpxchg
|
// CHECK-LABEL: @cmpxchg
|
||||||
llvm.func @cmpxchg(%ptr : !llvm.ptr<float>, %cmp : !llvm.float, %val: !llvm.float) {
|
llvm.func @cmpxchg(%ptr : !llvm.ptr<i32>, %cmp : !llvm.i32, %val: !llvm.i32) {
|
||||||
// CHECK: cmpxchg float* %{{.*}}, float %{{.*}}, float %{{.*}} acq_rel monotonic
|
// CHECK: cmpxchg i32* %{{.*}}, i32 %{{.*}}, i32 %{{.*}} acq_rel monotonic
|
||||||
%0 = llvm.cmpxchg %ptr, %cmp, %val acq_rel monotonic : !llvm.float
|
%0 = llvm.cmpxchg %ptr, %cmp, %val acq_rel monotonic : !llvm.i32
|
||||||
// CHECK: %{{[0-9]+}} = extractvalue { float, i1 } %{{[0-9]+}}, 0
|
// CHECK: %{{[0-9]+}} = extractvalue { i32, i1 } %{{[0-9]+}}, 0
|
||||||
%1 = llvm.extractvalue %0[0] : !llvm.struct<(float, i1)>
|
%1 = llvm.extractvalue %0[0] : !llvm.struct<(i32, i1)>
|
||||||
// CHECK: %{{[0-9]+}} = extractvalue { float, i1 } %{{[0-9]+}}, 1
|
// CHECK: %{{[0-9]+}} = extractvalue { i32, i1 } %{{[0-9]+}}, 1
|
||||||
%2 = llvm.extractvalue %0[1] : !llvm.struct<(float, i1)>
|
%2 = llvm.extractvalue %0[1] : !llvm.struct<(i32, i1)>
|
||||||
llvm.return
|
llvm.return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue