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

Ivy Zhang llvmlistbot at llvm.org
Sun Jun 2 19:51:06 PDT 2024


crazydemo wrote:

Re all the comments above:
Thanks for your comments and suggestions, we now have several opinions on how to implement this `elimination` pass.

All the comments agree that set the default behavior is to eliminate all the `trunc / extf` pairs. 

But we have different opinion on how to filter out the `don't eliminate cases`. We have 
1. `filter function` 
> Does it matter which pass produced the `truncf / extf` pairs? I would start with a pass that eliminates all of them. You can add an optional lambda to rewrite pattern that users can set as a kind of "filter function".
2. `add attributes`
> 1. Add fast-math flags to `arith.truncf` and `arith.extf` if they don't have them already. While they aren't present in LLVM, that's fine, we're allowed extensions 2. Define `contract` for `trunf` and `extf` to allow this fold 3. In the various promotion passes, set "contract" on the truncations and extensions in addition to their existing fastmath (maybe make that a default-on option) 4. Define a folder or canonicalizer on `arith.extf` and `arith.truncf` that collapses

And we also have comments concerned with supporting more data types.

I recommend merging this PR first to facilitate subsequent functionality and accuracy testing. We can then add attribute control in a later PR. @krzysz00 @ZhennanQin @kuhar @joker-eph



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


More information about the Mlir-commits mailing list