Skip to content

Commit f459a27

Browse files
committed
[MLIR][Arith] SelectOp fix invalid folding
The pattern `select %x, true, false => %x` is only valid in case that the return type is identical to the type of `%x` (i.e., i1). Hence, the check `isInteger(1)` was replaced with `isSignlessInteger(1)`.
1 parent b5a11d3 commit f459a27

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mlir/lib/Dialect/Arith/IR/ArithOps.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2314,7 +2314,8 @@ OpFoldResult arith::SelectOp::fold(FoldAdaptor adaptor) {
23142314
return trueVal;
23152315

23162316
// select %x, true, false => %x
2317-
if (getType().isInteger(1) && matchPattern(adaptor.getTrueValue(), m_One()) &&
2317+
if (getType().isSignlessInteger(1) &&
2318+
matchPattern(adaptor.getTrueValue(), m_One()) &&
23182319
matchPattern(adaptor.getFalseValue(), m_Zero()))
23192320
return condition;
23202321

0 commit comments

Comments
 (0)