summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-04-28 21:38:51 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-04-28 21:38:51 +0000
commitcf9d1ad62ec690e7cce30a48547431ec4e01e68e (patch)
treefc879e2d8d93aa8803deb817706b9780c47942c6 /llvm/lib/Transforms/InstCombine
parent9f02fd9d8d81f79ea93d2ac7eaff59ba10e29f53 (diff)
downloadbcm5719-llvm-cf9d1ad62ec690e7cce30a48547431ec4e01e68e.tar.gz
bcm5719-llvm-cf9d1ad62ec690e7cce30a48547431ec4e01e68e.zip
We require threse bits to be zero, too.
This shouldn't happen in practice because the icmp would be a constant. Add a check so we don't miscompile code if something goes wrong. llvm-svn: 130446
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 75e93127e7e..a08446e5d51 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -772,7 +772,7 @@ Value *InstCombiner::FoldAndOfICmps(ICmpInst *LHS, ICmpInst *RHS) {
// (trunc x) == C1 & (and x, CA) == C2 -> (and x, CA|CMAX) == C1|C2
// where CMAX is the all ones value for the truncated type,
- // iff the lower bits of CA are zero.
+ // iff the lower bits of C2 and CA are zero.
if (LHSCC == RHSCC && ICmpInst::isEquality(LHSCC) &&
LHS->hasOneUse() && RHS->hasOneUse()) {
Value *V;
@@ -797,7 +797,7 @@ Value *InstCombiner::FoldAndOfICmps(ICmpInst *LHS, ICmpInst *RHS) {
// Check that the low bits are zero.
APInt Low = APInt::getLowBitsSet(BigBitSize, SmallBitSize);
- if ((Low & AndCst->getValue()) == 0) {
+ if ((Low & AndCst->getValue()) == 0 && (Low & BigCst->getValue()) == 0) {
Value *NewAnd = Builder->CreateAnd(V, Low | AndCst->getValue());
APInt N = SmallCst->getValue().zext(BigBitSize) | BigCst->getValue();
Value *NewVal = ConstantInt::get(AndCst->getType()->getContext(), N);
OpenPOWER on IntegriCloud