[Mlir-commits] [mlir] ce47090 - [mlir][math] Properly disable ctlz conversion in MathToFuncs.
Slava Zakharin
llvmlistbot at llvm.org
Sun Apr 16 15:54:32 PDT 2023
Author: Slava Zakharin
Date: 2023-04-16T15:50:07-07:00
New Revision: ce47090d00cb0091902634ce67c90ff8ef3999f3
URL: https://github.com/llvm/llvm-project/commit/ce47090d00cb0091902634ce67c90ff8ef3999f3
DIFF: https://github.com/llvm/llvm-project/commit/ce47090d00cb0091902634ce67c90ff8ef3999f3.diff
LOG: [mlir][math] Properly disable ctlz conversion in MathToFuncs.
This fixes issues caused by D146261.
Differential Revision: https://reviews.llvm.org/D148477
Added:
Modified:
mlir/lib/Conversion/MathToFuncs/MathToFuncs.cpp
mlir/test/Conversion/MathToFuncs/ctlz.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/MathToFuncs/MathToFuncs.cpp b/mlir/lib/Conversion/MathToFuncs/MathToFuncs.cpp
index 6eac3b85e25f0..10832a15f01a8 100644
--- a/mlir/lib/Conversion/MathToFuncs/MathToFuncs.cpp
+++ b/mlir/lib/Conversion/MathToFuncs/MathToFuncs.cpp
@@ -804,6 +804,8 @@ void ConvertMathToFuncsPass::generateOpImplementations() {
module.walk([&](Operation *op) {
TypeSwitch<Operation *>(op)
.Case<math::CountLeadingZerosOp>([&](math::CountLeadingZerosOp op) {
+ if (!convertCtlz)
+ return;
Type resultType = getElementTypeOrSelf(op.getResult().getType());
// Generate the software implementation of this operation,
@@ -872,7 +874,8 @@ void ConvertMathToFuncsPass::runOnOperation() {
vector::VectorDialect>();
target.addIllegalOp<math::IPowIOp>();
- target.addIllegalOp<math::CountLeadingZerosOp>();
+ if (convertCtlz)
+ target.addIllegalOp<math::CountLeadingZerosOp>();
target.addDynamicallyLegalOp<math::FPowIOp>(
[this](math::FPowIOp op) { return !isFPowIConvertible(op); });
if (failed(applyPartialConversion(module, target, std::move(patterns))))
diff --git a/mlir/test/Conversion/MathToFuncs/ctlz.mlir b/mlir/test/Conversion/MathToFuncs/ctlz.mlir
index 8678c22a2b6f3..4e262417d6a95 100644
--- a/mlir/test/Conversion/MathToFuncs/ctlz.mlir
+++ b/mlir/test/Conversion/MathToFuncs/ctlz.mlir
@@ -1,4 +1,5 @@
// RUN: mlir-opt %s -split-input-file -pass-pipeline="builtin.module(convert-math-to-funcs{convert-ctlz})" | FileCheck %s
+// RUN: mlir-opt %s -split-input-file -pass-pipeline="builtin.module(convert-math-to-funcs{convert-ctlz=false})" | FileCheck --check-prefix=NOCVT %s
// Check a golden-path i32 conversion
@@ -38,6 +39,7 @@
// CHECK: }
// CHECK: return %[[OUT]] : i32
// CHECK: }
+// NOCVT-NOT: __mlir_math_ctlz_i32
func.func @main(%arg0: i32) {
%0 = math.ctlz %arg0 : i32
func.return
@@ -83,6 +85,7 @@ func.func @main(%arg0: i32) {
// CHECK: }
// CHECK: return %[[OUT]] : i8
// CHECK: }
+// NOCVT-NOT: __mlir_math_ctlz_i32
func.func @main(%arg0: i8) {
%0 = math.ctlz %arg0 : i8
func.return
More information about the Mlir-commits
mailing list