Skip to content

Commit d71003c

Browse files
committed
Support conversion of arith.divsi and arith.remsi to EmitC
1 parent b0b3596 commit d71003c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ void mlir::populateArithToEmitCPatterns(TypeConverter &typeConverter,
394394
ArithConstantOpConversionPattern,
395395
ArithOpConversion<arith::AddFOp, emitc::AddOp>,
396396
ArithOpConversion<arith::DivFOp, emitc::DivOp>,
397+
ArithOpConversion<arith::DivSIOp, emitc::DivOp>,
398+
ArithOpConversion<arith::RemSIOp, emitc::RemOp>,
397399
ArithOpConversion<arith::MulFOp, emitc::MulOp>,
398400
ArithOpConversion<arith::SubFOp, emitc::SubOp>,
399401
IntegerOpConversion<arith::AddIOp, emitc::AddOp>,

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,22 @@ func.func @arith_index(%arg0: index, %arg1: index) {
8888

8989
// -----
9090

91+
func.func @arith_signed_integer_div(%arg0: i32, %arg1: i32) {
92+
// CHECK: emitc.div %arg0, %arg1 : (i32, i32) -> i32
93+
%0 = arith.divsi %arg0, %arg1 : i32
94+
return
95+
}
96+
97+
// -----
98+
99+
func.func @arith_signed_integer_rem(%arg0: i32, %arg1: i32) {
100+
// CHECK: emitc.rem %arg0, %arg1 : (i32, i32) -> i32
101+
%0 = arith.remsi %arg0, %arg1 : i32
102+
return
103+
}
104+
105+
// -----
106+
91107
func.func @arith_select(%arg0: i1, %arg1: tensor<8xi32>, %arg2: tensor<8xi32>) -> () {
92108
// CHECK: [[V0:[^ ]*]] = emitc.conditional %arg0, %arg1, %arg2 : tensor<8xi32>
93109
%0 = arith.select %arg0, %arg1, %arg2 : i1, tensor<8xi32>

0 commit comments

Comments
 (0)