mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-17 18:24:34 +00:00
Don't do: "(X & 4) >> 1 == 2 --> (X & 4) == 4" if there are more than one uses of the shift result.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50118 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -6065,13 +6065,14 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
|
||||
// Otherwise, check to see if the bits shifted out are known to be zero.
|
||||
// If so, we can compare against the unshifted value:
|
||||
// (X & 4) >> 1 == 2 --> (X & 4) == 4.
|
||||
if (MaskedValueIsZero(LHSI->getOperand(0),
|
||||
if (LHSI->hasOneUse() &&
|
||||
MaskedValueIsZero(LHSI->getOperand(0),
|
||||
APInt::getLowBitsSet(Comp.getBitWidth(), ShAmtVal))) {
|
||||
return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0),
|
||||
ConstantExpr::getShl(RHS, ShAmt));
|
||||
}
|
||||
|
||||
if (LHSI->hasOneUse() || RHSV == 0) {
|
||||
if (LHSI->hasOneUse()) {
|
||||
// Otherwise strength reduce the shift into an and.
|
||||
APInt Val(APInt::getHighBitsSet(TypeBits, TypeBits - ShAmtVal));
|
||||
Constant *Mask = ConstantInt::get(Val);
|
||||
|
Reference in New Issue
Block a user