summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2009-09-20 07:21:39 +0000
committerNick Lewycky <nicholas@mxc.ca>2009-09-20 07:21:39 +0000
commitb0225ba2899acbd8332a5a66731af2f994e61eeb (patch)
treee35c2ffea06df2ac8dd3117e4629b733ffffe038 /llvm/lib
parent44790345377a7cf5a9eb50c382596c9649165896 (diff)
downloadbcm5719-llvm-b0225ba2899acbd8332a5a66731af2f994e61eeb.tar.gz
bcm5719-llvm-b0225ba2899acbd8332a5a66731af2f994e61eeb.zip
Fold 'icmp eq (icmp), true' into an xor(icmp).
llvm-svn: 82386
Diffstat (limited to 'llvm/lib')
-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 e14dd7e9cff..d9ef2c95e76 100644
--- a/llvm/lib/VMCore/ConstantFold.cpp
+++ b/llvm/lib/VMCore/ConstantFold.cpp
@@ -1428,6 +1428,20 @@ Constant *llvm::ConstantFoldCompareInstruction(LLVMContext &Context,
}
}
+ // If the comparison is a comparison between two i1's, simplify it.
+ if (C1->getType() == Type::getInt1Ty(Context)) {
+ switch(pred) {
+ case ICmpInst::ICMP_EQ:
+ if (isa<ConstantInt>(C2))
+ return ConstantExpr::getXor(C1, ConstantExpr::getNot(C2));
+ return ConstantExpr::getXor(ConstantExpr::getNot(C1), C2);
+ case ICmpInst::ICMP_NE:
+ return ConstantExpr::getXor(C1, C2);
+ default:
+ break;
+ }
+ }
+
if (isa<ConstantInt>(C1) && isa<ConstantInt>(C2)) {
APInt V1 = cast<ConstantInt>(C1)->getValue();
APInt V2 = cast<ConstantInt>(C2)->getValue();
OpenPOWER on IntegriCloud