[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:37:38 PDT 2024
https://github.com/josel-amd created https://github.com/llvm/llvm-project/pull/93450
None
>From 6c3fb599611cab7e1cfe523a034b6cc67ae1ff58 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 3532785c31b93..79776dd46a9aa 100644
--- a/mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp
+++ b/mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp
@@ -94,6 +94,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>,
SelectOpConversion
diff --git a/mlir/test/Conversion/ArithToEmitC/arith-to-emitc.mlir b/mlir/test/Conversion/ArithToEmitC/arith-to-emitc.mlir
index 022530ef4db84..287ebb82c0750 100644
--- a/mlir/test/Conversion/ArithToEmitC/arith-to-emitc.mlir
+++ b/mlir/test/Conversion/ArithToEmitC/arith-to-emitc.mlir
@@ -37,6 +37,22 @@ func.func @arith_ops(%arg0: f32, %arg1: f32) {
// -----
+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