diff options
author | David Majnemer <david.majnemer@gmail.com> | 2013-07-08 11:53:08 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2013-07-08 11:53:08 +0000 |
commit | 53fc39992df9c485ea45f28998c1ef99caed63f9 (patch) | |
tree | 1b423f8882c8064494312f2df66b31ba3dcf8c8b /lib/Transforms/InstCombine | |
parent | 4010110ccf21be0517034b6ccf9493628afaad77 (diff) | |
download | external_llvm-53fc39992df9c485ea45f28998c1ef99caed63f9.zip external_llvm-53fc39992df9c485ea45f28998c1ef99caed63f9.tar.gz external_llvm-53fc39992df9c485ea45f28998c1ef99caed63f9.tar.bz2 |
InstCombine: Fold X-C1 <u 2 -> (X & -2) == C1
Back in r179493 we determined that two transforms collided with each
other. The fix back then was to reorder the transforms so that the
preferred transform would give it a try and then we would try the
secondary transform. However, it was noted that the best approach would
canonicalize one transform into the other, removing the collision and
allowing us to optimize IR given to us in that form.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185808 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineCompares.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index 0f15760..f473446 100644 --- a/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1539,6 +1539,14 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, Builder->getInt(CR.getLower())); } } + + // X-C1 <u 2 -> (X & -2) == C1 + // iff C1 & 1 == 0 + if (ICI.getPredicate() == ICmpInst::ICMP_ULT && LHSI->hasOneUse() && + LHSV[0] == 0 && RHSV == 2) + return new ICmpInst(ICmpInst::ICMP_EQ, + Builder->CreateAnd(LHSI->getOperand(0), -RHSV), + ConstantExpr::getNeg(LHSC)); } break; } |