summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2009-09-20 06:24:51 +0000
committerNick Lewycky <nicholas@mxc.ca>2009-09-20 06:24:51 +0000
commit28260409f2621c617052e6338983bde4350e5fb3 (patch)
tree4d5870d49797bb20e5247d31035a2d5ee0a83cdc /llvm/lib/VMCore/ConstantFold.cpp
parent56efff07f5723e5a31e0cabf61d7c97d44a92d13 (diff)
downloadbcm5719-llvm-28260409f2621c617052e6338983bde4350e5fb3.tar.gz
bcm5719-llvm-28260409f2621c617052e6338983bde4350e5fb3.zip
Teach the constant folder how to not a cmpinst.
llvm-svn: 82378
Diffstat (limited to 'llvm/lib/VMCore/ConstantFold.cpp')
-rw-r--r--llvm/lib/VMCore/ConstantFold.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp
index 3f5c7efbb9a..1cf7b290c1e 100644
--- a/llvm/lib/VMCore/ConstantFold.cpp
+++ b/llvm/lib/VMCore/ConstantFold.cpp
@@ -704,6 +704,20 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
break;
case Instruction::Xor:
if (CI2->equalsInt(0)) return C1; // X ^ 0 == X
+
+ if (ConstantExpr *CE1 = dyn_cast<ConstantExpr>(C1)) {
+ switch (CE1->getOpcode()) {
+ default: break;
+ case Instruction::ICmp:
+ case Instruction::FCmp:
+ // icmp pred ^ true -> icmp !pred
+ assert(CI2->equalsInt(1));
+ CmpInst::Predicate pred = (CmpInst::Predicate)CE1->getPredicate();
+ pred = CmpInst::getInversePredicate(pred);
+ return ConstantExpr::getCompare(pred, CE1->getOperand(0),
+ CE1->getOperand(1));
+ }
+ }
break;
case Instruction::AShr:
// ashr (zext C to Ty), C2 -> lshr (zext C, CSA), C2
OpenPOWER on IntegriCloud