[Mlir-commits] [mlir] [MLIR][ARITH] Adds missing foldings for truncf (PR #128096)
Matthias Springer
llvmlistbot at llvm.org
Fri Feb 21 08:04:51 PST 2025
================
@@ -714,6 +714,25 @@ func.func @extFPVectorConstant() -> vector<2xf128> {
return %0 : vector<2xf128>
}
+// CHECK-LABEL: @truncExtf
+// CHECK-NOT: truncf
+// CHECK: return %arg0
+func.func @truncExtf(%arg0: f32) -> f32 {
+ %extf = arith.extf %arg0 : f32 to f64
+ %trunc = arith.truncf %extf : f64 to f32
+ return %trunc : f32
+}
+
+// CHECK-LABEL: @truncExtf2
+// CHECK: %[[ARG0:.+]]: f32
+// CHECK: %[[CST:.*]] = arith.truncf %[[ARG0:.+]] : f32 to f16
----------------
matthias-springer wrote:
I'm wondering if this is producing the exact same bit pattern. If not, maybe this folding is safe only under fast-math assumptions.
https://github.com/llvm/llvm-project/pull/128096
More information about the Mlir-commits
mailing list