summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-04-20 23:58:27 +0000
committerCraig Topper <craig.topper@gmail.com>2017-04-20 23:58:27 +0000
commit358cd9ae3a9b6f99054ea43af54ec08a39c28265 (patch)
treeee2349ee061e0d9122e3e45ccb8e4b68ef44568e /llvm/lib/Transforms
parent2500d1e35d061fa99de1f79781088599c0c2e35f (diff)
downloadbcm5719-llvm-358cd9ae3a9b6f99054ea43af54ec08a39c28265.tar.gz
bcm5719-llvm-358cd9ae3a9b6f99054ea43af54ec08a39c28265.zip
[InstCombine] Remove the zextOrTrunc from ShrinkDemandedConstant.
The demanded mask and the constant should always be the same width for all callers today. Also stop copying the demanded mask as its passed in. We should avoid allocating memory unless we are going to do something. The final AND to create the new constant will take care of it. llvm-svn: 300927
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index b1bd5593f6f..2f6e411345f 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -26,7 +26,7 @@ using namespace llvm::PatternMatch;
/// constant integer. If so, check to see if there are any bits set in the
/// constant that are not demanded. If so, shrink the constant and return true.
static bool ShrinkDemandedConstant(Instruction *I, unsigned OpNo,
- APInt Demanded) {
+ const APInt &Demanded) {
assert(I && "No instruction?");
assert(OpNo < I->getNumOperands() && "Operand index too large");
@@ -37,13 +37,11 @@ static bool ShrinkDemandedConstant(Instruction *I, unsigned OpNo,
return false;
// If there are no bits set that aren't demanded, nothing to do.
- Demanded = Demanded.zextOrTrunc(C->getBitWidth());
if (C->isSubsetOf(Demanded))
return false;
// This instruction is producing bits that are not demanded. Shrink the RHS.
- Demanded &= *C;
- I->setOperand(OpNo, ConstantInt::get(Op->getType(), Demanded));
+ I->setOperand(OpNo, ConstantInt::get(Op->getType(), *C & Demanded));
return true;
}
OpenPOWER on IntegriCloud