================
@@ -10041,6 +10045,34 @@ static void setLimitsForBinOp(const BinaryOperator
&BO, APInt &Lower,
default:
break;
}
+
+ ConstantRange CR = ConstantRange::getNonEmpty(Lower, Upper);
+ bool IsDisjointOr = BO.getOpcode() == Instruction::Or &&
+ cast<PossiblyDisjointInst>(&BO)->isDisjoint();
+ if (BO.getOpcode() == Instruction::Add ||
+ BO.getOpcode() == Instruction::Sub || IsDisjointOr) {
+ // Limit recursion depth more aggressively for binary operations.
+ unsigned NewDepth = std::max(Depth * 2, 1u);
+ ConstantRange LHS = computeConstantRange(
+ BO.getOperand(0), ForSigned, UseInstrInfo, AC, CtxI, DT, NewDepth);
+ ConstantRange RHS = computeConstantRange(
+ BO.getOperand(1), ForSigned, UseInstrInfo, AC, CtxI, DT, NewDepth);
+ unsigned NoWrapKind = 0;
+ // Only Add and Sub have no-wrap flags, not disjoint Or.
+ if (!IsDisjointOr) {
+ if (IIQ.hasNoUnsignedWrap(&BO))
+ NoWrapKind |= OverflowingBinaryOperator::NoUnsignedWrap;
+ if (IIQ.hasNoSignedWrap(&BO))
+ NoWrapKind |= OverflowingBinaryOperator::NoSignedWrap;
+ }
+ // Disjoint OR is semantically equivalent to Add.
----------------
mgudim wrote:
can "disjoint or" ever have an overflow?
https://github.com/llvm/llvm-project/pull/181110
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits