[Mlir-commits] [mlir] [MLIR][Arith] add fastMathAttr on arith::extf and arith::truncf (PR #93443)
Ivy Zhang
llvmlistbot at llvm.org
Tue Jun 11 19:42:20 PDT 2024
crazydemo wrote:
> I want to discuss adding fast-math attr to `extf`/`truncf` ops more deeply. For `truncf` and `extf` folding, the numerical change is from saving rounding operation of `truncf`, while there's no numerical impact from eliminating `extf`. In my opinion, adding `fastmath<contract>` to `extf` op is meaningless and redundant. We only need to add `fastmath<contract>` to `truncf` op and then we can allow folding below code sequence:
>
> ```mlir
> %2 = arith.truncf %1 fastmath<contract> : f32 to bf16
> %3 = arith.extf %2 : bf16 to f32 // no fast-math attribute
> ```
For fma fastmath optimization: fadd(contract) + fmul(contract) => fma, this case labels both `fadd` and `fmul`. For the `truncf / extf` case, label both of them could be the most safe way, as the `truncf / extf labeled with fastmath::contract` only can be generated from `promotion` passes.
https://github.com/llvm/llvm-project/pull/93443
More information about the Mlir-commits
mailing list