[Mlir-commits] [mlir] [mlir][tosa] Fix integer-to-boolean cast folder (PR #150370)

Luke Hutton llvmlistbot at llvm.org
Thu Jul 24 04:57:35 PDT 2025


================
@@ -1302,9 +1302,13 @@ OpFoldResult CastOp::fold(FoldAdaptor adaptor) {
       auto intVal = operand.getSplatValue<APInt>();
       auto bitwidth = outETy.getIntOrFloatBitWidth();
 
+      // i1 types are boolean in TOSA
       if (trunc) {
-        intVal = intVal.trunc(bitwidth);
-        // i1 types are boolean in TOSA
+        if (outETy.isInteger(1)) {
----------------
lhutton1 wrote:

Rather than introduce another level of nesting, could we special case this? i.e.
```
if (trunc && outTy.isInteger(1))
   ...
else if (trunc)
   ...
else if ...
```

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


More information about the Mlir-commits mailing list