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

Krzysztof Drewniak llvmlistbot at llvm.org
Thu May 30 01:32:02 PDT 2024


================
@@ -117,4 +117,50 @@ def ArithIntNarrowing : Pass<"arith-int-narrowing"> {
   ];
  }
 
+ def EliminateExplicitRounding : Pass<"eliminate-explicit-rounding"> {
+  let summary = "Eliminate the intermidiate truncf/extf pairs";
+  let description = [{
+    `legalize-to-f32` and `arith-emulate-unsupported-floats` pass does f32 promotion
+    for every op belonging to the illegal op list. Once there are some consecutive
+    illegal ops, these passes will insert `arith.truncf` and `arith.extf` pairs
+    between the illegal ops.
+    
+    This pass is to eliminate the intermediate truncf/extf pairs to improve
+    performance.
----------------
krzysz00 wrote:

I'll also note that, within a legalization pass, we have something like https://github.com/llvm/llvm-project/pull/92482#discussion_r1608615204 

I think there's a sensible generalization of `-arith-emulate-unsupported-floats` and `-math-legalize-to-f32` to cover both those dialects that could live in Transforms and avoid introducing intermediate ext/trunc pairs using the matching code I sketched out in that other PR.

Such a general pass could perhaps take a set of dialects to operate on and a set of operations within those dialects to exclude. Or there could be a `UnextendableFloatOp` trait you stick on things that are `Pure` and that take float operations and that should be exempted from promotion (like fma or extf/truncf themselves)

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


More information about the Mlir-commits mailing list