Skip to content

Commit bc3f5ae

Browse files
committed
Exclude bools from supported FtoI casts
1 parent 9ffc2a4 commit bc3f5ae

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mlir/lib/Conversion/ArithToEmitC/ArithToEmitC.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ class FtoICastOpConversion : public OpConversionPattern<CastOp> {
221221
if (!dstType)
222222
return rewriter.notifyMatchFailure(castOp, "type conversion failed");
223223

224-
if (!emitc::isSupportedIntegerType(dstType))
224+
// Float-to-bool casts are not supported: any non-zero value must be mapped
225+
// to true, which does not hold with rounding for values <= 0.5.
226+
if (!emitc::isSupportedIntegerType(dstType) || dstType.isInteger(1))
225227
return rewriter.notifyMatchFailure(castOp,
226228
"unsupported cast destination type");
227229

0 commit comments

Comments
 (0)