Skip to content

Commit 0d821b2

Browse files
committed
[InstSimplify] Generalize fold for icmp ugt/ule (pow2 << X), signmask
Alive2: https://alive2.llvm.org/ce/z/wZ41t7
1 parent b05f1d9 commit 0d821b2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3410,10 +3410,10 @@ static Value *simplifyICmpWithBinOp(CmpInst::Predicate Pred, Value *LHS,
34103410
}
34113411
}
34123412

3413-
// TODO: This is overly constrained. LHS can be any power-of-2.
3414-
// (1 << X) >u 0x8000 --> false
3415-
// (1 << X) <=u 0x8000 --> true
3416-
if (match(LHS, m_Shl(m_One(), m_Value())) && match(RHS, m_SignMask())) {
3413+
// If C is a power-of-2:
3414+
// (C << X) >u 0x8000 --> false
3415+
// (C << X) <=u 0x8000 --> true
3416+
if (match(LHS, m_Shl(m_Power2(), m_Value())) && match(RHS, m_SignMask())) {
34173417
if (Pred == ICmpInst::ICMP_UGT)
34183418
return ConstantInt::getFalse(getCompareTy(RHS));
34193419
if (Pred == ICmpInst::ICMP_ULE)

0 commit comments

Comments
 (0)