summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-06-11 08:01:25 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-06-11 08:01:25 +0000
commit2150145ae49f85cf59ea2ad6a68c626e19514163 (patch)
tree96b61a831bd719752b89da5545ae22742ca4cc62 /llvm/lib/Transforms
parentce8dbaadb6b07be199999ed26dcddb17aeb3e3e3 (diff)
downloadbcm5719-llvm-2150145ae49f85cf59ea2ad6a68c626e19514163.tar.gz
bcm5719-llvm-2150145ae49f85cf59ea2ad6a68c626e19514163.zip
InstCombine: factor code better.
No functionality change. llvm-svn: 158301
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 3fa0aba0129..7076d88554d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -2581,21 +2581,14 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
}
// Transform (zext A) == (B & (1<<X)-1) --> A == (trunc B)
+ // and (B & (1<<X)-1) == (zext A) --> A == (trunc B)
ConstantInt *Cst1;
- if (Op0->hasOneUse() &&
- match(Op0, m_ZExt(m_Value(A))) &&
- match(Op1, m_And(m_Value(B), m_ConstantInt(Cst1)))) {
- APInt Pow2 = Cst1->getValue() + 1;
- if (Pow2.isPowerOf2() && isa<IntegerType>(A->getType()) &&
- Pow2.logBase2() == cast<IntegerType>(A->getType())->getBitWidth())
- return new ICmpInst(I.getPredicate(), A,
- Builder->CreateTrunc(B, A->getType()));
- }
-
- // Transform (B & (1<<X)-1) == (zext A) --> A == (trunc B)
- if (Op1->hasOneUse() &&
- match(Op0, m_And(m_Value(B), m_ConstantInt(Cst1))) &&
- match(Op1, m_ZExt(m_Value(A)))) {
+ if ((Op0->hasOneUse() &&
+ match(Op0, m_ZExt(m_Value(A))) &&
+ match(Op1, m_And(m_Value(B), m_ConstantInt(Cst1)))) ||
+ (Op1->hasOneUse() &&
+ match(Op0, m_And(m_Value(B), m_ConstantInt(Cst1))) &&
+ match(Op1, m_ZExt(m_Value(A))))) {
APInt Pow2 = Cst1->getValue() + 1;
if (Pow2.isPowerOf2() && isa<IntegerType>(A->getType()) &&
Pow2.logBase2() == cast<IntegerType>(A->getType())->getBitWidth())
OpenPOWER on IntegriCloud