diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-05-28 10:16:58 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-05-28 10:16:58 +0000 |
commit | 2c5cc6887412597518ca4a585625b0af1ea71622 (patch) | |
tree | 49bb70c0d759e22824692f1c43fad96ef2686716 /lib/Transforms | |
parent | d7c10862016939c9850cadfe5e1c35513c0adf28 (diff) | |
download | llvm-2c5cc6887412597518ca4a585625b0af1ea71622.tar.gz llvm-2c5cc6887412597518ca4a585625b0af1ea71622.tar.bz2 llvm-2c5cc6887412597518ca4a585625b0af1ea71622.tar.xz |
ConstantFoldInstOperands doesn't like compares, hand it off to instsimplify instead.
Fixes PR10040.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132254 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineSelect.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineSelect.cpp b/lib/Transforms/InstCombine/InstCombineSelect.cpp index 2a451ce5f1..aeb3c3e880 100644 --- a/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/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)) { |