Skip to content

Commit 25d539d

Browse files
committed
Fix truncated check lines; exclude bool
1 parent b4e0e1c commit 25d539d

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ class IntegerOpConversion final : public OpConversionPattern<ArithOp> {
6969
return rewriter.notifyMatchFailure(op, "expected integer type");
7070
}
7171

72+
if (type.isInteger(1)) {
73+
// arith expects wrap-around arithmethic, which doesn't happen on `bool`.
74+
return rewriter.notifyMatchFailure(op, "i1 type is not implemented");
75+
}
76+
7277
Value lhs = adaptor.getLhs();
7378
Value rhs = adaptor.getRhs();
7479
Type arithmeticType = type;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: mlir-opt -convert-arith-to-emitc %s -split-input-file -verify-diagnostics
2+
3+
func.func @bool(%arg0: i1, %arg1: i1) {
4+
// expected-error@+1 {{failed to legalize operation 'arith.addi'}}
5+
%0 = arith.addi %arg0, %arg1 : i1
6+
return
7+
}
8+
9+
// -----
10+
11+
func.func @vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) {
12+
// expected-error@+1 {{failed to legalize operation 'arith.addi'}}
13+
%0 = arith.addi %arg0, %arg1 : vector<4xi32>
14+
return
15+
}

mlir/test/Conversion/ArithToEmitC/arith-to-emitc.mlir

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ func.func @arith_ops(%arg0: f32, %arg1: f32) {
3939

4040
// CHECK-LABEL: arith_integer_ops
4141
func.func @arith_integer_ops(%arg0: i32, %arg1: i32) {
42-
// CHECK: %[[C1:[^ ]*]] = emitc.cast %arg0 : i32 to ui3
43-
// CHECK: %[[C2:[^ ]*]] = emitc.cast %arg1 : i32 to ui3
42+
// CHECK: %[[C1:[^ ]*]] = emitc.cast %arg0 : i32 to ui32
43+
// CHECK: %[[C2:[^ ]*]] = emitc.cast %arg1 : i32 to ui32
4444
// CHECK: %[[ADD:[^ ]*]] = emitc.add %[[C1]], %[[C2]] : (ui32, ui32) -> ui32
45-
// CHECK: %[[C3:[^ ]*]] = emitc.cast %[[ADD]] : ui32 to i3
45+
// CHECK: %[[C3:[^ ]*]] = emitc.cast %[[ADD]] : ui32 to i32
4646
%0 = arith.addi %arg0, %arg1 : i32
47-
// CHECK: %[[C1:[^ ]*]] = emitc.cast %arg0 : i32 to ui3
48-
// CHECK: %[[C2:[^ ]*]] = emitc.cast %arg1 : i32 to ui3
47+
// CHECK: %[[C1:[^ ]*]] = emitc.cast %arg0 : i32 to ui32
48+
// CHECK: %[[C2:[^ ]*]] = emitc.cast %arg1 : i32 to ui32
4949
// CHECK: %[[SUB:[^ ]*]] = emitc.sub %[[C1]], %[[C2]] : (ui32, ui32) -> ui32
50-
// CHECK: %[[C3:[^ ]*]] = emitc.cast %[[SUB]] : ui32 to i3
50+
// CHECK: %[[C3:[^ ]*]] = emitc.cast %[[SUB]] : ui32 to i32
5151
%1 = arith.subi %arg0, %arg1 : i32
52-
// CHECK: %[[C1:[^ ]*]] = emitc.cast %arg0 : i32 to ui3
53-
// CHECK: %[[C2:[^ ]*]] = emitc.cast %arg1 : i32 to ui3
52+
// CHECK: %[[C1:[^ ]*]] = emitc.cast %arg0 : i32 to ui32
53+
// CHECK: %[[C2:[^ ]*]] = emitc.cast %arg1 : i32 to ui32
5454
// CHECK: %[[MUL:[^ ]*]] = emitc.mul %[[C1]], %[[C2]] : (ui32, ui32) -> ui32
55-
// CHECK: %[[C3:[^ ]*]] = emitc.cast %[[MUL]] : ui32 to i3
55+
// CHECK: %[[C3:[^ ]*]] = emitc.cast %[[MUL]] : ui32 to i32
5656
%2 = arith.muli %arg0, %arg1 : i32
5757

5858
return

0 commit comments

Comments
 (0)