Skip to content

Commit 13d983e

Browse files
[mlir][Transforms][NFC] Dialect Conversion: Resolve insertion point TODO (#95653)
Remove a TODO in the dialect conversion code base when materializing unresolved conversions: ``` // FIXME: Determine a suitable insertion location when there are multiple // inputs. ``` The implementation used to select an insertion point as follows: - If the cast has exactly one operand: right after the definition of the SSA value. - Otherwise: right before the cast op. However, it is not necessary to change the insertion point. Unresolved materializations (`UnrealizedConversionCastOp`) are built during `buildUnresolvedArgumentMaterialization` or `buildUnresolvedTargetMaterialization`. In the former case, the op is inserted at the beginning of the block. In the latter case, only one operand is supported in the dialect conversion, and the op is inserted right after the definition of the SSA value. I.e., the `UnrealizedConversionCastOp` is already inserted at the right place and it is not necessary to change the insertion point for the resolved materialization op. Note: The IR change changes slightly because the `unrealized_conversion_cast` ops at the beginning of a block are no longer doubly-inverted (by setting the insertion to the beginning of the block when inserting the `unrealized_conversion_cast` and again when inserting the resolved conversion op). All affected test cases were fixed by using `CHECK-DAG` instead of `CHECK`. Also improve the quality of multiple test cases that did not check for the correct operands. Note: This commit is in preparation of decoupling the argument/source/target materialization logic of the type converter from the dialect conversion (to reduce its complexity and make that functionality usable from a new dialect conversion driver).
1 parent 21ba91c commit 13d983e

File tree

18 files changed

+122
-116
lines changed

18 files changed

+122
-116
lines changed

mlir/lib/Transforms/Utils/DialectConversion.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,13 +2857,7 @@ static LogicalResult legalizeUnresolvedMaterialization(
28572857

28582858
// Try to materialize the conversion.
28592859
if (const TypeConverter *converter = mat.getConverter()) {
2860-
// FIXME: Determine a suitable insertion location when there are multiple
2861-
// inputs.
2862-
if (inputOperands.size() == 1)
2863-
rewriter.setInsertionPointAfterValue(inputOperands.front());
2864-
else
2865-
rewriter.setInsertionPoint(op);
2866-
2860+
rewriter.setInsertionPoint(op);
28672861
Value newMaterialization;
28682862
switch (mat.getMaterializationKind()) {
28692863
case MaterializationKind::Argument:

mlir/test/Conversion/ArithToLLVM/arith-to-llvm.mlir

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,10 @@ func.func @mului_extended_vector1d(%arg0: vector<3xi64>, %arg1: vector<3xi64>) -
478478
// -----
479479

480480
// CHECK-LABEL: func @cmpf_2dvector(
481+
// CHECK-SAME: %[[OARG0:.*]]: vector<4x3xf32>, %[[OARG1:.*]]: vector<4x3xf32>)
481482
func.func @cmpf_2dvector(%arg0 : vector<4x3xf32>, %arg1 : vector<4x3xf32>) {
482-
// CHECK: %[[ARG0:.*]] = builtin.unrealized_conversion_cast
483-
// CHECK: %[[ARG1:.*]] = builtin.unrealized_conversion_cast
483+
// CHECK-DAG: %[[ARG0:.*]] = builtin.unrealized_conversion_cast %[[OARG0]]
484+
// CHECK-DAG: %[[ARG1:.*]] = builtin.unrealized_conversion_cast %[[OARG1]]
484485
// CHECK: %[[EXTRACT1:.*]] = llvm.extractvalue %[[ARG0]][0] : !llvm.array<4 x vector<3xf32>>
485486
// CHECK: %[[EXTRACT2:.*]] = llvm.extractvalue %[[ARG1]][0] : !llvm.array<4 x vector<3xf32>>
486487
// CHECK: %[[CMP:.*]] = llvm.fcmp "olt" %[[EXTRACT1]], %[[EXTRACT2]] : vector<3xf32>
@@ -492,9 +493,10 @@ func.func @cmpf_2dvector(%arg0 : vector<4x3xf32>, %arg1 : vector<4x3xf32>) {
492493
// -----
493494

494495
// CHECK-LABEL: func @cmpi_0dvector(
496+
// CHECK-SAME: %[[OARG0:.*]]: vector<i32>, %[[OARG1:.*]]: vector<i32>)
495497
func.func @cmpi_0dvector(%arg0 : vector<i32>, %arg1 : vector<i32>) {
496-
// CHECK: %[[ARG0:.*]] = builtin.unrealized_conversion_cast
497-
// CHECK: %[[ARG1:.*]] = builtin.unrealized_conversion_cast
498+
// CHECK-DAG: %[[ARG0:.*]] = builtin.unrealized_conversion_cast %[[OARG0]]
499+
// CHECK-DAG: %[[ARG1:.*]] = builtin.unrealized_conversion_cast %[[OARG1]]
498500
// CHECK: %[[CMP:.*]] = llvm.icmp "ult" %[[ARG0]], %[[ARG1]] : vector<1xi32>
499501
%0 = arith.cmpi ult, %arg0, %arg1 : vector<i32>
500502
func.return
@@ -503,9 +505,10 @@ func.func @cmpi_0dvector(%arg0 : vector<i32>, %arg1 : vector<i32>) {
503505
// -----
504506

505507
// CHECK-LABEL: func @cmpi_2dvector(
508+
// CHECK-SAME: %[[OARG0:.*]]: vector<4x3xi32>, %[[OARG1:.*]]: vector<4x3xi32>)
506509
func.func @cmpi_2dvector(%arg0 : vector<4x3xi32>, %arg1 : vector<4x3xi32>) {
507-
// CHECK: %[[ARG0:.*]] = builtin.unrealized_conversion_cast
508-
// CHECK: %[[ARG1:.*]] = builtin.unrealized_conversion_cast
510+
// CHECK-DAG: %[[ARG0:.*]] = builtin.unrealized_conversion_cast %[[OARG0]]
511+
// CHECK-DAG: %[[ARG1:.*]] = builtin.unrealized_conversion_cast %[[OARG1]]
509512
// CHECK: %[[EXTRACT1:.*]] = llvm.extractvalue %[[ARG0]][0] : !llvm.array<4 x vector<3xi32>>
510513
// CHECK: %[[EXTRACT2:.*]] = llvm.extractvalue %[[ARG1]][0] : !llvm.array<4 x vector<3xi32>>
511514
// CHECK: %[[CMP:.*]] = llvm.icmp "ult" %[[EXTRACT1]], %[[EXTRACT2]] : vector<3xi32>

mlir/test/Conversion/ArithToLLVM/convert-nd-vector-to-llvmir.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ func.func @bitcast_2d(%arg0: vector<2x4xf32>) {
199199

200200
// CHECK-LABEL: func @select_2d(
201201
func.func @select_2d(%arg0 : vector<4x3xi1>, %arg1 : vector<4x3xi32>, %arg2 : vector<4x3xi32>) {
202-
// CHECK: %[[ARG0:.*]] = builtin.unrealized_conversion_cast %arg0
203-
// CHECK: %[[ARG1:.*]] = builtin.unrealized_conversion_cast %arg1
204-
// CHECK: %[[ARG2:.*]] = builtin.unrealized_conversion_cast %arg2
202+
// CHECK-DAG: %[[ARG0:.*]] = builtin.unrealized_conversion_cast %arg0
203+
// CHECK-DAG: %[[ARG1:.*]] = builtin.unrealized_conversion_cast %arg1
204+
// CHECK-DAG: %[[ARG2:.*]] = builtin.unrealized_conversion_cast %arg2
205205
// CHECK: %[[EXTRACT1:.*]] = llvm.extractvalue %[[ARG0]][0] : !llvm.array<4 x vector<3xi1>>
206206
// CHECK: %[[EXTRACT2:.*]] = llvm.extractvalue %[[ARG1]][0] : !llvm.array<4 x vector<3xi32>>
207207
// CHECK: %[[EXTRACT3:.*]] = llvm.extractvalue %[[ARG2]][0] : !llvm.array<4 x vector<3xi32>>

mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ func.func @index_scalar(%lhs: index, %rhs: index) {
6060
// CHECK-LABEL: @index_scalar_srem
6161
// CHECK-SAME: (%[[A:.+]]: index, %[[B:.+]]: index)
6262
func.func @index_scalar_srem(%lhs: index, %rhs: index) {
63-
// CHECK: %[[LHS:.+]] = builtin.unrealized_conversion_cast %[[A]] : index to i32
64-
// CHECK: %[[RHS:.+]] = builtin.unrealized_conversion_cast %[[B]] : index to i32
63+
// CHECK-DAG: %[[LHS:.+]] = builtin.unrealized_conversion_cast %[[A]] : index to i32
64+
// CHECK-DAG: %[[RHS:.+]] = builtin.unrealized_conversion_cast %[[B]] : index to i32
6565
// CHECK: %[[LABS:.+]] = spirv.GL.SAbs %[[LHS]] : i32
6666
// CHECK: %[[RABS:.+]] = spirv.GL.SAbs %[[RHS]] : i32
6767
// CHECK: %[[ABS:.+]] = spirv.UMod %[[LABS]], %[[RABS]] : i32

mlir/test/Conversion/IndexToLLVM/index-to-llvm.mlir

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ func.func @trivial_ops(%a: index, %b: index) {
5050
// CHECK-LABEL: @ceildivs
5151
// CHECK-SAME: %[[NI:.*]]: index, %[[MI:.*]]: index
5252
func.func @ceildivs(%n: index, %m: index) -> index {
53-
// CHECK: %[[N:.*]] = builtin.unrealized_conversion_cast %[[NI]]
54-
// CHECK: %[[M:.*]] = builtin.unrealized_conversion_cast %[[MI]]
53+
// CHECK-DAG: %[[N:.*]] = builtin.unrealized_conversion_cast %[[NI]]
54+
// CHECK-DAG: %[[M:.*]] = builtin.unrealized_conversion_cast %[[MI]]
5555
// CHECK: %[[ZERO:.*]] = llvm.mlir.constant(0 :
5656
// CHECK: %[[POS_ONE:.*]] = llvm.mlir.constant(1 :
5757
// CHECK: %[[NEG_ONE:.*]] = llvm.mlir.constant(-1 :
@@ -82,8 +82,8 @@ func.func @ceildivs(%n: index, %m: index) -> index {
8282
// CHECK-LABEL: @ceildivu
8383
// CHECK-SAME: %[[NI:.*]]: index, %[[MI:.*]]: index
8484
func.func @ceildivu(%n: index, %m: index) -> index {
85-
// CHECK: %[[N:.*]] = builtin.unrealized_conversion_cast %[[NI]]
86-
// CHECK: %[[M:.*]] = builtin.unrealized_conversion_cast %[[MI]]
85+
// CHECK-DAG: %[[N:.*]] = builtin.unrealized_conversion_cast %[[NI]]
86+
// CHECK-DAG: %[[M:.*]] = builtin.unrealized_conversion_cast %[[MI]]
8787
// CHECK: %[[ZERO:.*]] = llvm.mlir.constant(0 :
8888
// CHECK: %[[ONE:.*]] = llvm.mlir.constant(1 :
8989

@@ -103,11 +103,11 @@ func.func @ceildivu(%n: index, %m: index) -> index {
103103
// CHECK-LABEL: @floordivs
104104
// CHECK-SAME: %[[NI:.*]]: index, %[[MI:.*]]: index
105105
func.func @floordivs(%n: index, %m: index) -> index {
106-
// CHECK: %[[N:.*]] = builtin.unrealized_conversion_cast %[[NI]]
107-
// CHECK: %[[M:.*]] = builtin.unrealized_conversion_cast %[[MI]]
108-
// CHECK: %[[ZERO:.*]] = llvm.mlir.constant(0 :
109-
// CHECK: %[[POS_ONE:.*]] = llvm.mlir.constant(1 :
110-
// CHECK: %[[NEG_ONE:.*]] = llvm.mlir.constant(-1 :
106+
// CHECK-DAG: %[[N:.*]] = builtin.unrealized_conversion_cast %[[NI]]
107+
// CHECK-DAG: %[[M:.*]] = builtin.unrealized_conversion_cast %[[MI]]
108+
// CHECK-DAG: %[[ZERO:.*]] = llvm.mlir.constant(0 :
109+
// CHECK-DAG: %[[POS_ONE:.*]] = llvm.mlir.constant(1 :
110+
// CHECK-DAG: %[[NEG_ONE:.*]] = llvm.mlir.constant(-1 :
111111

112112
// CHECK: %[[M_NEG:.*]] = llvm.icmp "slt" %[[M]], %[[ZERO]]
113113
// CHECK: %[[X:.*]] = llvm.select %[[M_NEG]], %[[POS_ONE]], %[[NEG_ONE]]

mlir/test/Conversion/IndexToSPIRV/index-to-spirv.mlir

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ func.func @constant_ops() {
6767
// CHECK-LABEL: @ceildivs
6868
// CHECK-SAME: %[[NI:.*]]: index, %[[MI:.*]]: index
6969
func.func @ceildivs(%n: index, %m: index) -> index {
70-
// CHECK: %[[N:.*]] = builtin.unrealized_conversion_cast %[[NI]]
71-
// CHECK: %[[M:.*]] = builtin.unrealized_conversion_cast %[[MI]]
70+
// CHECK-DAG: %[[N:.*]] = builtin.unrealized_conversion_cast %[[NI]]
71+
// CHECK-DAG: %[[M:.*]] = builtin.unrealized_conversion_cast %[[MI]]
7272
// CHECK: %[[ZERO:.*]] = spirv.Constant 0
7373
// CHECK: %[[POS_ONE:.*]] = spirv.Constant 1
7474
// CHECK: %[[NEG_ONE:.*]] = spirv.Constant -1
@@ -99,8 +99,8 @@ func.func @ceildivs(%n: index, %m: index) -> index {
9999
// CHECK-LABEL: @ceildivu
100100
// CHECK-SAME: %[[NI:.*]]: index, %[[MI:.*]]: index
101101
func.func @ceildivu(%n: index, %m: index) -> index {
102-
// CHECK: %[[N:.*]] = builtin.unrealized_conversion_cast %[[NI]]
103-
// CHECK: %[[M:.*]] = builtin.unrealized_conversion_cast %[[MI]]
102+
// CHECK-DAG: %[[N:.*]] = builtin.unrealized_conversion_cast %[[NI]]
103+
// CHECK-DAG: %[[M:.*]] = builtin.unrealized_conversion_cast %[[MI]]
104104
// CHECK: %[[ZERO:.*]] = spirv.Constant 0
105105
// CHECK: %[[ONE:.*]] = spirv.Constant 1
106106

@@ -120,8 +120,8 @@ func.func @ceildivu(%n: index, %m: index) -> index {
120120
// CHECK-LABEL: @floordivs
121121
// CHECK-SAME: %[[NI:.*]]: index, %[[MI:.*]]: index
122122
func.func @floordivs(%n: index, %m: index) -> index {
123-
// CHECK: %[[N:.*]] = builtin.unrealized_conversion_cast %[[NI]]
124-
// CHECK: %[[M:.*]] = builtin.unrealized_conversion_cast %[[MI]]
123+
// CHECK-DAG: %[[N:.*]] = builtin.unrealized_conversion_cast %[[NI]]
124+
// CHECK-DAG: %[[M:.*]] = builtin.unrealized_conversion_cast %[[MI]]
125125
// CHECK: %[[ZERO:.*]] = spirv.Constant 0
126126
// CHECK: %[[POS_ONE:.*]] = spirv.Constant 1
127127
// CHECK: %[[NEG_ONE:.*]] = spirv.Constant -1

mlir/test/Conversion/MathToSPIRV/math-to-core-spirv.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ func.func @copy_sign_vector_0D(%value: vector<1xf16>, %sign: vector<1xf16>) -> v
7878

7979
// CHECK-LABEL: func @copy_sign_vector_0D
8080
// CHECK-SAME: (%[[VALUE:.+]]: vector<1xf16>, %[[SIGN:.+]]: vector<1xf16>)
81-
// CHECK: %[[CASTVAL:.+]] = builtin.unrealized_conversion_cast %[[VALUE]] : vector<1xf16> to f16
82-
// CHECK: %[[CASTSIGN:.+]] = builtin.unrealized_conversion_cast %[[SIGN]] : vector<1xf16> to f16
81+
// CHECK-DAG: %[[CASTVAL:.+]] = builtin.unrealized_conversion_cast %[[VALUE]] : vector<1xf16> to f16
82+
// CHECK-DAG: %[[CASTSIGN:.+]] = builtin.unrealized_conversion_cast %[[SIGN]] : vector<1xf16> to f16
8383
// CHECK: %[[SMASK:.+]] = spirv.Constant -32768 : i16
8484
// CHECK: %[[VMASK:.+]] = spirv.Constant 32767 : i16
8585
// CHECK: %[[VCAST:.+]] = spirv.Bitcast %[[CASTVAL]] : f16 to i16

mlir/test/Conversion/MemRefToLLVM/convert-dynamic-memref-ops.mlir

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,15 @@ func.func @memref_reinterpret_cast_unranked_to_dynamic_shape(%offset: index,
506506

507507
// -----
508508

509-
// CHECK-LABEL: @memref_reshape
509+
// CHECK-LABEL: @memref_reshape(
510+
// CHECK-SAME: %[[ARG0:.*]]: memref<2x3xf32>, %[[ARG1:.*]]: memref<?xindex>)
510511
func.func @memref_reshape(%input : memref<2x3xf32>, %shape : memref<?xindex>) {
511512
%output = memref.reshape %input(%shape)
512513
: (memref<2x3xf32>, memref<?xindex>) -> memref<*xf32>
513514
return
514515
}
515-
// CHECK: [[INPUT:%.*]] = builtin.unrealized_conversion_cast %{{.*}} to [[INPUT_TY:!.*]]
516-
// CHECK: [[SHAPE:%.*]] = builtin.unrealized_conversion_cast %{{.*}} to [[SHAPE_TY:!.*]]
516+
// CHECK-DAG: [[INPUT:%.*]] = builtin.unrealized_conversion_cast %[[ARG0]] : {{.*}} to [[INPUT_TY:!.*]]
517+
// CHECK-DAG: [[SHAPE:%.*]] = builtin.unrealized_conversion_cast %[[ARG1]] : {{.*}} to [[SHAPE_TY:!.*]]
517518
// CHECK: [[RANK:%.*]] = llvm.extractvalue [[SHAPE]][3, 0] : [[SHAPE_TY]]
518519
// CHECK: [[UNRANKED_OUT_O:%.*]] = llvm.mlir.undef : !llvm.struct<(i64, ptr)>
519520
// CHECK: [[UNRANKED_OUT_1:%.*]] = llvm.insertvalue [[RANK]], [[UNRANKED_OUT_O]][0] : !llvm.struct<(i64, ptr)>

mlir/test/Conversion/MemRefToLLVM/convert-static-memref-ops.mlir

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,11 @@ func.func @zero_d_load(%arg0: memref<f32>) -> f32 {
115115

116116
// -----
117117

118-
// CHECK-LABEL: func @static_load
119-
// CHECK: %[[MEMREF:.*]]: memref<10x42xf32>,
120-
// CHECK: %[[I:.*]]: index,
121-
// CHECK: %[[J:.*]]: index)
118+
// CHECK-LABEL: func @static_load(
119+
// CHECK-SAME: %[[MEMREF:.*]]: memref<10x42xf32>, %[[I:.*]]: index, %[[J:.*]]: index)
122120
func.func @static_load(%static : memref<10x42xf32>, %i : index, %j : index) {
123-
// CHECK: %[[II:.*]] = builtin.unrealized_conversion_cast %[[I]]
124-
// CHECK: %[[JJ:.*]] = builtin.unrealized_conversion_cast %[[J]]
121+
// CHECK-DAG: %[[II:.*]] = builtin.unrealized_conversion_cast %[[I]]
122+
// CHECK-DAG: %[[JJ:.*]] = builtin.unrealized_conversion_cast %[[J]]
125123
// CHECK: %[[ptr:.*]] = llvm.extractvalue %{{.*}}[1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
126124
// CHECK: %[[st0:.*]] = llvm.mlir.constant(42 : index) : i64
127125
// CHECK: %[[offI:.*]] = llvm.mul %[[II]], %[[st0]] : i64
@@ -148,8 +146,8 @@ func.func @zero_d_store(%arg0: memref<f32>, %arg1: f32) {
148146
// CHECK: %[[MEMREF:.*]]: memref<10x42xf32>,
149147
// CHECK-SAME: %[[I:.*]]: index, %[[J:.*]]: index,
150148
func.func @static_store(%static : memref<10x42xf32>, %i : index, %j : index, %val : f32) {
151-
// CHECK: %[[II:.*]] = builtin.unrealized_conversion_cast %[[I]]
152-
// CHECK: %[[JJ:.*]] = builtin.unrealized_conversion_cast %[[J]]
149+
// CHECK-DAG: %[[II:.*]] = builtin.unrealized_conversion_cast %[[I]]
150+
// CHECK-DAG: %[[JJ:.*]] = builtin.unrealized_conversion_cast %[[J]]
153151
// CHECK: %[[ptr:.*]] = llvm.extractvalue %{{.*}}[1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
154152
// CHECK: %[[st0:.*]] = llvm.mlir.constant(42 : index) : i64
155153
// CHECK: %[[offI:.*]] = llvm.mul %[[II]], %[[st0]] : i64
@@ -205,7 +203,7 @@ module attributes { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<index, 32>> } {
205203
func.func @address() {
206204
%c1 = arith.constant 1 : index
207205
%0 = memref.alloc(%c1) : memref<? x vector<2xf32>>
208-
// CHECK: %[[CST_S:.*]] = arith.constant 1 : index
206+
// CHECK-DAG: %[[CST_S:.*]] = arith.constant 1 : index
209207
// CHECK: %[[CST:.*]] = builtin.unrealized_conversion_cast
210208
// CHECK: llvm.mlir.zero
211209
// CHECK: llvm.getelementptr %{{.*}}[[CST]]
@@ -269,8 +267,8 @@ func.func @memref.reshape(%arg0: memref<4x5x6xf32>) -> memref<2x6x20xf32> {
269267
// CHECK-LABEL: func @memref.reshape.dynamic.dim
270268
// CHECK-SAME: %[[arg:.*]]: memref<?x?x?xf32>, %[[shape:.*]]: memref<4xi64>) -> memref<?x?x12x32xf32>
271269
func.func @memref.reshape.dynamic.dim(%arg: memref<?x?x?xf32>, %shape: memref<4xi64>) -> memref<?x?x12x32xf32> {
272-
// CHECK: %[[arg_cast:.*]] = builtin.unrealized_conversion_cast %[[arg]] : memref<?x?x?xf32> to !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
273-
// CHECK: %[[shape_cast:.*]] = builtin.unrealized_conversion_cast %[[shape]] : memref<4xi64> to !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
270+
// CHECK-DAG: %[[arg_cast:.*]] = builtin.unrealized_conversion_cast %[[arg]] : memref<?x?x?xf32> to !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
271+
// CHECK-DAG: %[[shape_cast:.*]] = builtin.unrealized_conversion_cast %[[shape]] : memref<4xi64> to !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
274272
// CHECK: %[[undef:.*]] = llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<4 x i64>, array<4 x i64>)>
275273
// CHECK: %[[alloc_ptr:.*]] = llvm.extractvalue %[[arg_cast]][0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
276274
// CHECK: %[[align_ptr:.*]] = llvm.extractvalue %[[arg_cast]][1] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
@@ -318,8 +316,8 @@ func.func @memref.reshape.dynamic.dim(%arg: memref<?x?x?xf32>, %shape: memref<4x
318316
// CHECK-LABEL: func @memref.reshape_index
319317
// CHECK-SAME: %[[arg:.*]]: memref<?x?xi32>, %[[shape:.*]]: memref<1xindex>
320318
func.func @memref.reshape_index(%arg0: memref<?x?xi32>, %shape: memref<1xindex>) -> memref<?xi32> {
321-
// CHECK: %[[arg_cast:.*]] = builtin.unrealized_conversion_cast %[[arg]] : memref<?x?xi32> to !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
322-
// CHECK: %[[shape_cast:.*]] = builtin.unrealized_conversion_cast %[[shape]] : memref<1xindex> to !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
319+
// CHECK-DAG: %[[arg_cast:.*]] = builtin.unrealized_conversion_cast %[[arg]] : memref<?x?xi32> to !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
320+
// CHECK-DAG: %[[shape_cast:.*]] = builtin.unrealized_conversion_cast %[[shape]] : memref<1xindex> to !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
323321
// CHECK: %[[undef:.*]] = llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
324322
// CHECK: %[[alloc_ptr:.*]] = llvm.extractvalue %[[arg_cast]][0] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>
325323
// CHECK: %[[align_ptr:.*]] = llvm.extractvalue %[[arg_cast]][1] : !llvm.struct<(ptr, ptr, i64, array<2 x i64>, array<2 x i64>)>

mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
// CHECK-LABEL: func @view(
1111
// CHECK: %[[ARG0F:.*]]: index, %[[ARG1F:.*]]: index, %[[ARG2F:.*]]: index
1212
func.func @view(%arg0 : index, %arg1 : index, %arg2 : index) {
13-
// CHECK: %[[ARG2:.*]] = builtin.unrealized_conversion_cast %[[ARG2F:.*]]
14-
// CHECK: %[[ARG0:.*]] = builtin.unrealized_conversion_cast %[[ARG0F:.*]]
15-
// CHECK: %[[ARG1:.*]] = builtin.unrealized_conversion_cast %[[ARG1F:.*]]
13+
// CHECK-DAG: %[[ARG2:.*]] = builtin.unrealized_conversion_cast %[[ARG2F]]
14+
// CHECK-DAG: %[[ARG0:.*]] = builtin.unrealized_conversion_cast %[[ARG0F]]
15+
// CHECK-DAG: %[[ARG1:.*]] = builtin.unrealized_conversion_cast %[[ARG1F]]
1616
// CHECK: llvm.mlir.constant(2048 : index) : i64
1717
// CHECK: llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
1818
%0 = memref.alloc() : memref<2048xi8>
@@ -408,8 +408,8 @@ func.func @atomic_rmw_with_offset(%I : memref<10xi32, strided<[1], offset: 5>>,
408408
// CHECK-SAME: %[[ARG0:.+]]: memref<10xi32, strided<[1], offset: 5>>
409409
// CHECK-SAME: %[[ARG1:.+]]: i32
410410
// CHECK-SAME: %[[ARG2:.+]]: index
411-
// CHECK: %[[MEMREF_STRUCT:.+]] = builtin.unrealized_conversion_cast %[[ARG0]] : memref<10xi32, strided<[1], offset: 5>> to !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
412-
// CHECK: %[[INDEX:.+]] = builtin.unrealized_conversion_cast %[[ARG2]] : index to i64
411+
// CHECK-DAG: %[[MEMREF_STRUCT:.+]] = builtin.unrealized_conversion_cast %[[ARG0]] : memref<10xi32, strided<[1], offset: 5>> to !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
412+
// CHECK-DAG: %[[INDEX:.+]] = builtin.unrealized_conversion_cast %[[ARG2]] : index to i64
413413
// CHECK: %[[BASE_PTR:.+]] = llvm.extractvalue %[[MEMREF_STRUCT]][1] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
414414
// CHECK: %[[OFFSET:.+]] = llvm.mlir.constant(5 : index) : i64
415415
// CHECK: %[[OFFSET_PTR:.+]] = llvm.getelementptr %[[BASE_PTR]][%[[OFFSET]]] : (!llvm.ptr, i64) -> !llvm.ptr, i32

mlir/test/Conversion/MemRefToSPIRV/bitwidth-emulation.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ func.func @load_i4(%arg0: memref<?xi4, #spirv.storage_class<StorageBuffer>>, %i:
196196

197197
// CHECK-LABEL: @store_i4
198198
func.func @store_i4(%arg0: memref<?xi4, #spirv.storage_class<StorageBuffer>>, %value: i4, %i: index) {
199-
// CHECK: %[[VAL:.+]] = builtin.unrealized_conversion_cast %{{.+}} : i4 to i32
200-
// CHECK: %[[INDEX:.+]] = builtin.unrealized_conversion_cast %{{.+}} : index to i32
199+
// CHECK-DAG: %[[VAL:.+]] = builtin.unrealized_conversion_cast %{{.+}} : i4 to i32
200+
// CHECK-DAG: %[[INDEX:.+]] = builtin.unrealized_conversion_cast %{{.+}} : index to i32
201201
// CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32
202202
// CHECK: %[[EIGHT:.+]] = spirv.Constant 8 : i32
203203
// CHECK: %[[FOUR:.+]] = spirv.Constant 4 : i32

0 commit comments

Comments
 (0)