summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-05-28 10:16:58 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-05-28 10:16:58 +0000
commitfd53a27f991e96b5d3cfd334c61ad41def1c0af7 (patch)
tree565e800890650179258358c9de97e7a44c5a621c /llvm/lib
parent046c47e970369dbe3e74ad4a992e7ab0512939bc (diff)
downloadbcm5719-llvm-fd53a27f991e96b5d3cfd334c61ad41def1c0af7.tar.gz
bcm5719-llvm-fd53a27f991e96b5d3cfd334c61ad41def1c0af7.zip
ConstantFoldInstOperands doesn't like compares, hand it off to instsimplify instead.
Fixes PR10040. llvm-svn: 132254
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 2a451ce5f12..aeb3c3e880f 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -298,6 +298,16 @@ static Value *SimplifyWithOpReplaced(Value *V, Value *Op, Value *RepOp,
return SimplifyBinOp(B->getOpcode(), B->getOperand(0), RepOp, TD);
}
+ // Same for CmpInsts.
+ if (CmpInst *C = dyn_cast<CmpInst>(I)) {
+ if (C->getOperand(0) == Op)
+ return SimplifyCmpInst(C->getPredicate(), RepOp, C->getOperand(1), TD);
+ if (C->getOperand(1) == Op)
+ return SimplifyCmpInst(C->getPredicate(), C->getOperand(0), RepOp, TD);
+ }
+
+ // TODO: We could hand off more cases to instsimplify here.
+
// If all operands are constant after substituting Op for RepOp then we can
// constant fold the instruction.
if (Constant *CRepOp = dyn_cast<Constant>(RepOp)) {
OpenPOWER on IntegriCloud