[Mlir-commits] [mlir] [MLIR][ARITH] Adds missing foldings for truncf (PR #128096)
Zahi Moudallal
llvmlistbot at llvm.org
Fri Feb 21 11:06:55 PST 2025
================
@@ -1517,6 +1517,22 @@ LogicalResult arith::TruncIOp::verify() {
/// Perform safe const propagation for truncf, i.e., only propagate if FP value
/// can be represented without precision loss.
OpFoldResult arith::TruncFOp::fold(FoldAdaptor adaptor) {
+ if (auto extOp = getOperand().getDefiningOp<arith::ExtFOp>()) {
----------------
zahimoud wrote:
> I remember needing to go fix a similar folding (that one was for y = trunc(ext(bf16 x to f32) to bf16)) in LLVM because it was causing numerical correctness issues
Can you explain why this one would cause numerical issues ? ext to f32 is just adding 16 zero mantissa bits, then trunc back to bf16 would remove those zero bits, I don't see any rounding error there.
https://github.com/llvm/llvm-project/pull/128096
More information about the Mlir-commits
mailing list