aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
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
commit36b6f7409d9f607317de9815ffc10656b608eab7 (patch)
tree081e67d12a3ba9360c1ae1494a7e57cb912acb8e /lib/Transforms
parentff16df71f50231c79c379a146dc55b4d6867cbd9 (diff)
downloadexternal_llvm-36b6f7409d9f607317de9815ffc10656b608eab7.zip
external_llvm-36b6f7409d9f607317de9815ffc10656b608eab7.tar.gz
external_llvm-36b6f7409d9f607317de9815ffc10656b608eab7.tar.bz2
InstCombine: X & -C != -C -> X <= u ~C
Tests were added in r185910 somehow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185912 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCompares.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp
index fd2b68a..e9f3458 100644
--- a/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/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: {