ImplicitCastElision: elide casts only on integrals

For comparison operators (==, !=, <, >, <=, >=) the elision is only
sound when both operands are of integral type; otherwise we'd be
changing the kind of comparison being performed.
This commit is contained in:
Alessandro Di Federico
2026-05-27 14:25:50 +02:00
parent 8973f6e55c
commit 1ca8239b65
+6 -7
View File
@@ -44,14 +44,13 @@ public:
BitwiseOrOp,
BitwiseXorOp,
ShiftLeftOp,
ShiftRightOp,
CmpEqOp,
CmpNeOp,
CmpLtOp,
CmpGtOp,
CmpLeOp,
CmpGeOp>(Op))
ShiftRightOp>(Op))
return elideArithmeticCasts(Op);
if (mlir::isa<CmpEqOp, CmpNeOp, CmpLtOp, CmpGtOp, CmpLeOp, CmpGeOp>(Op)) {
if (clift::unwrapped_isa<IntegralType>(Op->getOperand(0).getType()))
elideArithmeticCasts(Op);
}
}
private: