Skip to content

Commit 3136b73

Browse files
committed
Use diagnostics to point at tile operand if move is required
1 parent cc7bc3a commit 3136b73

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

mlir/lib/Dialect/ArmSME/Transforms/TileAllocation.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,14 @@ LogicalResult assignTileIdsAndResolveTrivialConflicts(
544544
continue;
545545
auto operandTileOp =
546546
tileOperand->get().getDefiningOp<ArmSMETileOpInterface>();
547-
if (!isTriviallyCloneableTileOp(operandTileOp))
548-
return tileOp.emitOpError("failed to rectify tile operand with tile "
549-
"result (move required)");
547+
if (!isTriviallyCloneableTileOp(operandTileOp)) {
548+
auto error =
549+
tileOp.emitOpError("tile operand allocated to different SME "
550+
"virtial tile (move required)");
551+
error.attachNote(tileOperand->get().getLoc())
552+
<< "tile operand is: " << tileOperand->get();
553+
return error;
554+
}
550555
// Cloning prevents a move/spill (though may require recomputation).
551556
rewriter.setInsertionPoint(tileOp);
552557
auto clonedOp = operandTileOp.clone();
@@ -567,7 +572,7 @@ LogicalResult assignTileIdsAndResolveTrivialConflicts(
567572
return;
568573
if (!isAllocatedToSameTile(predecessorTile)) {
569574
blockArg.getOwner()->getParentOp()->emitOpError(
570-
"block argument not allocated to the same tile as "
575+
"block argument not allocated to the same SME virtial tile as "
571576
"predecessors");
572577
tileMismatch = true;
573578
}

mlir/test/Dialect/ArmSME/tile-allocation-invalid.mlir

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
// Select between tileA and tileB. This is currently unsupported as it would
44
// require inserting (runtime) tile moves.
5+
6+
// expected-note@below {{tile operand is: <block argument> of type 'vector<[4]x[4]xi32>'}}
57
func.func @selecting_between_different_tiles_is_unsupported(%dest : memref<?x?xi32>, %tileA : vector<[4]x[4]xi32>, %tileB : vector<[4]x[4]xi32>, %cond: i1) {
68
%c0 = arith.constant 0 : index
7-
// expected-error@+1 {{op failed to rectify tile operand with tile result (move required)}}
9+
// expected-error@below {{op tile operand allocated to different SME virtial tile (move required)}}
810
%tile = scf.if %cond -> vector<[4]x[4]xi32> {
911
scf.yield %tileA : vector<[4]x[4]xi32>
1012
} else {

mlir/test/Dialect/ArmSME/tile-allocation-liveness.mlir

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ func.func @constant_with_multiple_users(%a: vector<[4]xf32>, %b: vector<[4]xf32>
3737
// CHECK-LIVE-RANGE-NEXT: |E test.some_use
3838
// CHECK-LIVE-RANGE-NEXT: E test.some_use
3939

40+
// expected-note@below {{tile operand is: <block argument> of type 'vector<[4]x[4]xf32>'}}
4041
func.func @value_with_multiple_users(%tile: vector<[4]x[4]xf32>, %a: vector<[4]xf32>, %b: vector<[4]xf32>, %index: index) {
41-
// expected-error@below {{op failed to rectify tile operand with tile result (move required)}}
42+
// expected-error@below {{op tile operand allocated to different SME virtial tile (move required)}}
4243
%tile_a = arm_sme.move_vector_to_tile_slice %a, %tile, %index : vector<[4]xf32> into vector<[4]x[4]xf32>
4344
%tile_b = arm_sme.move_vector_to_tile_slice %b, %tile, %index : vector<[4]xf32> into vector<[4]x[4]xf32>
4445
"test.some_use"(%tile_a) : (vector<[4]x[4]xf32>) -> ()
@@ -143,8 +144,10 @@ func.func @non_overlapping_branches(%cond: i1) {
143144

144145
// Here %vecA and %vecB are not merged into the same live range (as they are unknown values).
145146
// This means that %vecA and %vecB are both allocated to different tiles (which is not legal).
147+
148+
// expected-note@below {{tile operand is: <block argument> of type 'vector<[4]x[4]xf32>'}}
146149
func.func @overlapping_branches(%cond: i1, %vecA: vector<[4]x[4]xf32>, %vecB: vector<[4]x[4]xf32>) {
147-
// expected-error@below {{op failed to rectify tile operand with tile result (move required)}}
150+
// expected-error@below {{op tile operand allocated to different SME virtial tile (move required)}}
148151
%tile = scf.if %cond -> vector<[4]x[4]xf32> {
149152
scf.yield %vecA : vector<[4]x[4]xf32>
150153
} else {

0 commit comments

Comments
 (0)