Skip to content

Commit 7f3420e

Browse files
committed
[MLIR] Fix printing of switch case for negative value
This patch fixes the printer for the llvm.switch operation with negative values in a case.
1 parent a8db1fb commit 7f3420e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ static void printSwitchOpCases(OpAsmPrinter &p, SwitchOp op, Type flagType,
634634
llvm::zip(caseValues, caseDestinations),
635635
[&](auto i) {
636636
p << " ";
637-
p << std::get<0>(i).getLimitedValue();
637+
p << std::get<0>(i);
638638
p << ": ";
639639
p.printSuccessorAndUseList(std::get<1>(i), caseOperands[index++]);
640640
},

mlir/test/Dialect/LLVMIR/roundtrip.mlir

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,14 @@ func.func @ops(%arg0: i32, %arg1: f32,
144144
// CHECK: llvm.switch %0 : i32, ^[[BB3]] [
145145
// CHECK-NEXT: 1: ^[[BB4:.*]],
146146
// CHECK-NEXT: 2: ^[[BB5:.*]],
147-
// CHECK-NEXT: 3: ^[[BB6:.*]]
147+
// CHECK-NEXT: 3: ^[[BB6:.*]],
148+
// CHECK-NEXT: -3: ^[[BB6:.*]]
148149
// CHECK-NEXT: ]
149150
llvm.switch %0 : i32, ^bb3 [
150151
1: ^bb4,
151152
2: ^bb5,
152-
3: ^bb6
153+
3: ^bb6,
154+
-3: ^bb6
153155
]
154156

155157
// CHECK: ^[[BB3]]

0 commit comments

Comments
 (0)