summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-07-09 08:09:32 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-07-09 08:09:32 +0000
commit414d4e58aacdbd809b103ec95ea87b425e529e15 (patch)
treebf1afdb3e07c952353e2387873f9bb64da3906e7 /llvm/lib
parent78a5a116a0ff842a8b960f3e628c45d3e335daa8 (diff)
downloadbcm5719-llvm-414d4e58aacdbd809b103ec95ea87b425e529e15.tar.gz
bcm5719-llvm-414d4e58aacdbd809b103ec95ea87b425e529e15.zip
InstCombine: X & -C != -C -> X <= u ~C
Tests were added in r185910 somehow. llvm-svn: 185912
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index fd2b68a9ecd..e9f3458be98 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1277,6 +1277,15 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
return Res;
}
}
+
+ // X & -C == -C -> X > u ~C
+ // X & -C != -C -> X <= u ~C
+ // iff C is a power of 2
+ if (ICI.isEquality() && RHS == LHSI->getOperand(1) && (-RHSV).isPowerOf2())
+ return new ICmpInst(
+ ICI.getPredicate() == ICmpInst::ICMP_EQ ? ICmpInst::ICMP_UGT
+ : ICmpInst::ICMP_ULE,
+ LHSI->getOperand(0), SubOne(RHS));
break;
case Instruction::Or: {
OpenPOWER on IntegriCloud