[Mlir-commits] [mlir] [MLIR][ARITH] Adds missing foldings for truncf (PR #128096)

Krzysztof Drewniak llvmlistbot at llvm.org
Thu Feb 20 20:14:23 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>()) {
----------------
krzysz00 wrote:

I don't think this one's correct either

```
%b = arith.exif %a : bf16 to f32
%c = arith.truncf %b : f32 to f16
```
doesn't fold to
```
%c = arith.truncf %a : bf16 to f16
```

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


More information about the Mlir-commits mailing list