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,
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))))
// 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
// CHECK: }
// CHECK: return %[[OUT]] : i32
// CHECK: }
+// NOCVT-NOT: __mlir_math_ctlz_i32
func.func @main(%arg0: i32) {
%0 = math.ctlz %arg0 : i32
func.return
// CHECK: }
// CHECK: return %[[OUT]] : i8
// CHECK: }
+// NOCVT-NOT: __mlir_math_ctlz_i32
func.func @main(%arg0: i8) {
%0 = math.ctlz %arg0 : i8
func.return