summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2017-06-30 01:35:31 +0000
committerEric Christopher <echristo@gmail.com>2017-06-30 01:35:31 +0000
commit710c1c8faa67745c8cf59b8fc44326f29601afac (patch)
treed4d5f32f8ba82a8054279a40ce3a96a7c2d82197 /llvm/lib/Transforms
parent837755cf8b859664caa848632087d175f9d67c8d (diff)
downloadbcm5719-llvm-710c1c8faa67745c8cf59b8fc44326f29601afac.tar.gz
bcm5719-llvm-710c1c8faa67745c8cf59b8fc44326f29601afac.zip
Reduce the complexity of the signbit/branch test functions.
llvm-svn: 306779
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index a74c5da5897..aec36f5483a 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -112,10 +112,10 @@ static bool subWithOverflow(Constant *&Result, Constant *In1,
/// Given an icmp instruction, return true if any use of this comparison is a
/// branch on sign bit comparison.
-static bool isBranchOnSignBitCheck(ICmpInst &I, bool isSignBit) {
+static bool hasBranchUse(ICmpInst &I) {
for (auto *U : I.users())
if (isa<BranchInst>(U))
- return isSignBit;
+ return true;
return false;
}
@@ -1448,7 +1448,7 @@ Instruction *InstCombiner::foldICmpWithConstant(ICmpInst &Cmp) {
// of a test and branch. So we avoid canonicalizing in such situations
// because test and branch instruction has better branch displacement
// than compare and branch instruction.
- if (!isBranchOnSignBitCheck(Cmp, IsSignBit) && !Cmp.isEquality()) {
+ if (!(IsSignBit && hasBranchUse(Cmp)) && !Cmp.isEquality()) {
if (auto *AI = Intersection.getSingleElement())
return new ICmpInst(ICmpInst::ICMP_EQ, X, Builder->getInt(*AI));
if (auto *AD = Difference.getSingleElement())
OpenPOWER on IntegriCloud