diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-04-12 18:17:46 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-04-12 18:17:46 +0000 |
commit | 9a51c7f343447768bdfeb4f15c4c16c6c98be975 (patch) | |
tree | 7378da52520d3efecb9a5876d47f017dcdc835e9 /llvm/lib/Transforms | |
parent | 99551053bd8321d6be10bed3a92e50318214cf81 (diff) | |
download | bcm5719-llvm-9a51c7f343447768bdfeb4f15c4c16c6c98be975.tar.gz bcm5719-llvm-9a51c7f343447768bdfeb4f15c4c16c6c98be975.zip |
[InstCombine] Teach SimplifyDemandedInstructionBits that even if we reach an instruction that has multiple uses, if we know all the bits for the demanded bits for this context we can go ahead and create a constant.
Currently if we reach an instruction with multiples uses we know we can't do any optimizations to that instruction itself since we only have the demanded bits for one of the users. But if we know all of the bits are zero/one for that one user we can still go ahead and create a constant to give to that user.
This might then reduce the instruction to having a single use and allow additional optimizations on the other path.
This picks up an additional case that r300075 didn't catch.
Differential Revision: https://reviews.llvm.org/D31552
llvm-svn: 300084
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index dd789fad569..279f44c2eae 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -834,6 +834,12 @@ Value *InstCombiner::SimplifyMultipleUseDemandedBits(Instruction *I, // Compute the KnownZero/KnownOne bits to simplify things downstream. computeKnownBits(I, KnownZero, KnownOne, Depth, CxtI); + + // If this user is only demanding bits that we know, return the known + // constant. + if ((DemandedMask & (KnownZero|KnownOne)) == DemandedMask) + return Constant::getIntegerValue(ITy, KnownOne); + return nullptr; } |