This code handles (icmp eq/ne (1 << Y), C) if C is a power of 2.
This case is also handled by the more general foldICmpShlConstConst
which is called before we reach foldICmpShlOne.
// Exclude signed min by subtracting 1 and lower the upper bound to 0.
if (Pred == ICmpInst::ICMP_SLT && (C-1).sle(0))
return new ICmpInst(ICmpInst::ICMP_EQ, Y, BitWidthMinusOne);
- } else if (Cmp.isEquality() && CIsPowerOf2) {
- return new ICmpInst(Pred, Y, ConstantInt::get(ShiftType, C.logBase2()));
}
return nullptr;