forked from OSchip/llvm-project
parent
7b41393497
commit
a8ef4a5737
|
@ -45,29 +45,29 @@ static Value *simplifyValueKnownNonZero(Value *V, InstCombiner &IC,
|
||||||
|
|
||||||
// (PowerOfTwo >>u B) --> isExact since shifting out the result would make it
|
// (PowerOfTwo >>u B) --> isExact since shifting out the result would make it
|
||||||
// inexact. Similarly for <<.
|
// inexact. Similarly for <<.
|
||||||
if (BinaryOperator *I = dyn_cast<BinaryOperator>(V))
|
BinaryOperator *I = dyn_cast<BinaryOperator>(V);
|
||||||
if (I->isLogicalShift() &&
|
if (I && I->isLogicalShift() &&
|
||||||
isKnownToBeAPowerOfTwo(I->getOperand(0), IC.getDataLayout(), false, 0,
|
isKnownToBeAPowerOfTwo(I->getOperand(0), IC.getDataLayout(), false, 0,
|
||||||
IC.getAssumptionCache(), &CxtI,
|
IC.getAssumptionCache(), &CxtI,
|
||||||
IC.getDominatorTree())) {
|
IC.getDominatorTree())) {
|
||||||
// We know that this is an exact/nuw shift and that the input is a
|
// We know that this is an exact/nuw shift and that the input is a
|
||||||
// non-zero context as well.
|
// non-zero context as well.
|
||||||
if (Value *V2 = simplifyValueKnownNonZero(I->getOperand(0), IC, CxtI)) {
|
if (Value *V2 = simplifyValueKnownNonZero(I->getOperand(0), IC, CxtI)) {
|
||||||
I->setOperand(0, V2);
|
I->setOperand(0, V2);
|
||||||
MadeChange = true;
|
MadeChange = true;
|
||||||
}
|
|
||||||
|
|
||||||
if (I->getOpcode() == Instruction::LShr && !I->isExact()) {
|
|
||||||
I->setIsExact();
|
|
||||||
MadeChange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (I->getOpcode() == Instruction::Shl && !I->hasNoUnsignedWrap()) {
|
|
||||||
I->setHasNoUnsignedWrap();
|
|
||||||
MadeChange = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (I->getOpcode() == Instruction::LShr && !I->isExact()) {
|
||||||
|
I->setIsExact();
|
||||||
|
MadeChange = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (I->getOpcode() == Instruction::Shl && !I->hasNoUnsignedWrap()) {
|
||||||
|
I->setHasNoUnsignedWrap();
|
||||||
|
MadeChange = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Lots more we could do here:
|
// TODO: Lots more we could do here:
|
||||||
// If V is a phi node, we can call this on each of its operands.
|
// If V is a phi node, we can call this on each of its operands.
|
||||||
// "select cond, X, 0" can simplify to "X".
|
// "select cond, X, 0" can simplify to "X".
|
||||||
|
|
Loading…
Reference in New Issue