[Mlir-commits] [mlir] [MLIR][Transforms] add eliminate-explicit-rounding pass (PR #93443)

Ivy Zhang llvmlistbot at llvm.org
Mon May 27 01:03:58 PDT 2024


================
@@ -57,7 +57,9 @@ void mlir::math::populateLegalizeToF32TypeConverter(
   });
   typeConverter.addTargetMaterialization(
       [](OpBuilder &b, Type target, ValueRange input, Location loc) {
-        return b.create<arith::ExtFOp>(loc, target, input);
+        auto extFOp = b.create<arith::ExtFOp>(loc, target, input);
+        extFOp->setAttr("eliminatable", b.getBoolAttr(true));
----------------
crazydemo wrote:

We would like to do `trunc / extf` pairs elimination after all the type conversion related passes are done, so that the IR will then be simplified. 

However, we may have different use cases, some users may want to keep several `trunc / extf` pairs, some may want to remove all the intermediate op pairs to get more performance improvement. 

Currently, I think `adding` a temp attribute is a direct way to solve this problem. 

Or maybe I can discard this `eliminable` attr in this PR, and let users to determine whether to label some op pairs with `eliminable=false` to keep the desired op pairs?

https://github.com/llvm/llvm-project/pull/93443


More information about the Mlir-commits mailing list