summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-03-24 16:56:51 +0000
committerCraig Topper <craig.topper@gmail.com>2017-03-24 16:56:51 +0000
commitd4521c2fc23b207cca9d45edd2b3a54bdc466193 (patch)
tree39d8f405d6cbcf8dc59dd4d3cc6dba0eb2c2710b /llvm/lib/Transforms
parentf7d1023a730abeeb0aafba939306413ff2935c0e (diff)
downloadbcm5719-llvm-d4521c2fc23b207cca9d45edd2b3a54bdc466193.tar.gz
bcm5719-llvm-d4521c2fc23b207cca9d45edd2b3a54bdc466193.zip
[InstCombine] Provide a way to calculate KnownZero/One for Add/Sub in SimplifyDemandedUseBits without recursing into ComputeKnownBits
SimplifyDemandedUseBits for Add/Sub already recursed down LHS and RHS for simplifying bits. If that didn't provide any simplifications we fall back to calling computeKnownBits which will recurse again. Instead just take the known bits for LHS and RHS we already have and call into a new function in ValueTracking that can calculate the known bits given the LHS/RHS bits. llvm-svn: 298711
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 41d4a4820bf..d10fa06f0c2 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -538,7 +538,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
LHSKnownZero, LHSKnownOne, Depth + 1) ||
ShrinkDemandedConstant(I, 1, DemandedFromOps) ||
SimplifyDemandedBits(I->getOperandUse(1), DemandedFromOps,
- LHSKnownZero, LHSKnownOne, Depth + 1)) {
+ RHSKnownZero, RHSKnownOne, Depth + 1)) {
// Disable the nsw and nuw flags here: We can no longer guarantee that
// we won't wrap after simplification. Removing the nsw/nuw flags is
// legal here because the top bit is not demanded.
@@ -549,9 +549,10 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
}
}
- // Otherwise just hand the add/sub off to computeKnownBits to fill in
- // the known zeros and ones.
- computeKnownBits(V, KnownZero, KnownOne, Depth, CxtI);
+ // Otherwise compute the known bits using the RHS/LHS known bits.
+ bool NSW = cast<OverflowingBinaryOperator>(I)->hasNoSignedWrap();
+ computeKnownBitsForAddSub(V, NSW, KnownZero, KnownOne, LHSKnownZero,
+ LHSKnownOne, RHSKnownZero, RHSKnownOne);
break;
}
case Instruction::Shl:
OpenPOWER on IntegriCloud