[Mlir-commits] [mlir] [mlir][emitc] Support conversion of arith.divsi and arith.remsi to EmitC (PR #93450)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon May 27 02:46:53 PDT 2024
https://github.com/josel-amd updated https://github.com/llvm/llvm-project/pull/93450
>From d71003cc03b32a0394cc831ee1cf3563bd3f3c8f Mon Sep 17 00:00:00 2001
From: Jose Lopes <jose.lopes at amd.com>
Date: Mon, 27 May 2024 08:00:19 +0100
Subject: [PATCH] Support conversion of arith.divsi and arith.remsi to EmitC
---
.../lib/Conversion/ArithToEmitC/ArithToEmitC.cpp | 2 ++
.../Conversion/ArithToEmitC/arith-to-emitc.mlir | 16 ++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp b/mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp
index 0be3d76f556de..75c69cfe7e246 100644
--- a/mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp
+++ b/mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp
@@ -394,6 +394,8 @@ void mlir::populateArithToEmitCPatterns(TypeConverter &typeConverter,
ArithConstantOpConversionPattern,
ArithOpConversion<arith::AddFOp, emitc::AddOp>,
ArithOpConversion<arith::DivFOp, emitc::DivOp>,
+ ArithOpConversion<arith::DivSIOp, emitc::DivOp>,
+ ArithOpConversion<arith::RemSIOp, emitc::RemOp>,
ArithOpConversion<arith::MulFOp, emitc::MulOp>,
ArithOpConversion<arith::SubFOp, emitc::SubOp>,
IntegerOpConversion<arith::AddIOp, emitc::AddOp>,
diff --git a/mlir/test/Conversion/ArithToEmitC/arith-to-emitc.mlir b/mlir/test/Conversion/ArithToEmitC/arith-to-emitc.mlir
index b453b69a214e8..0cbee321b7e7f 100644
--- a/mlir/test/Conversion/ArithToEmitC/arith-to-emitc.mlir
+++ b/mlir/test/Conversion/ArithToEmitC/arith-to-emitc.mlir
@@ -88,6 +88,22 @@ func.func @arith_index(%arg0: index, %arg1: index) {
// -----
+func.func @arith_signed_integer_div(%arg0: i32, %arg1: i32) {
+ // CHECK: emitc.div %arg0, %arg1 : (i32, i32) -> i32
+ %0 = arith.divsi %arg0, %arg1 : i32
+ return
+}
+
+// -----
+
+func.func @arith_signed_integer_rem(%arg0: i32, %arg1: i32) {
+ // CHECK: emitc.rem %arg0, %arg1 : (i32, i32) -> i32
+ %0 = arith.remsi %arg0, %arg1 : i32
+ return
+}
+
+// -----
+
func.func @arith_select(%arg0: i1, %arg1: tensor<8xi32>, %arg2: tensor<8xi32>) -> () {
// CHECK: [[V0:[^ ]*]] = emitc.conditional %arg0, %arg1, %arg2 : tensor<8xi32>
%0 = arith.select %arg0, %arg1, %arg2 : i1, tensor<8xi32>
More information about the Mlir-commits
mailing list