mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-17 08:36:52 +00:00
Teach instcombine propagate zeroness through shl instructions, implementing
and.ll:test31 llvm-svn: 21717
This commit is contained in:
parent
d3797164f9
commit
2b4c801d10
@ -1361,14 +1361,10 @@ static bool MaskedValueIsZero(Value *V, ConstantIntegral *Mask) {
|
||||
break;
|
||||
}
|
||||
case Instruction::Shl:
|
||||
// (shl X, C1) & C2 == 0 iff (-1 << C1) & C2 == 0
|
||||
if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1))) {
|
||||
Constant *C1 = ConstantIntegral::getAllOnesValue(I->getType());
|
||||
C1 = ConstantExpr::getShl(C1, SA);
|
||||
C1 = ConstantExpr::getAnd(C1, Mask);
|
||||
if (C1->isNullValue())
|
||||
return true;
|
||||
}
|
||||
// (shl X, C1) & C2 == 0 iff (X & C2 >>u C1) == 0
|
||||
if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1)))
|
||||
return MaskedValueIsZero(I->getOperand(0),
|
||||
cast<ConstantIntegral>(ConstantExpr::getUShr(Mask, SA)));
|
||||
break;
|
||||
case Instruction::Shr:
|
||||
// (ushr X, C1) & C2 == 0 iff (-1 >> C1) & C2 == 0
|
||||
|
Loading…
Reference in New Issue
Block a user