summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombineSelect.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-01-28 03:28:10 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-01-28 03:28:10 +0000
commitdf3bfae1515c826804754616b989b18630fc4d93 (patch)
tree76656409f00a66862e87a7597f2841da00825355 /lib/Transforms/InstCombine/InstCombineSelect.cpp
parent1ffb5336999b327384752b0f60ad0c4cb4cb8946 (diff)
downloadllvm-df3bfae1515c826804754616b989b18630fc4d93.tar.gz
llvm-df3bfae1515c826804754616b989b18630fc4d93.tar.bz2
llvm-df3bfae1515c826804754616b989b18630fc4d93.tar.xz
Fold select + select where both selects are on the same condition.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124469 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstCombineSelect.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineSelect.cpp b/lib/Transforms/InstCombine/InstCombineSelect.cpp
index ff41ab834b..97abc769ae 100644
--- a/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -792,6 +792,19 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
if (Instruction *NV = FoldOpIntoPhi(SI))
return NV;
+ if (SelectInst *TrueSI = dyn_cast<SelectInst>(TrueVal)) {
+ if (TrueSI->getCondition() == CondVal) {
+ SI.setOperand(1, TrueSI->getTrueValue());
+ return &SI;
+ }
+ }
+ if (SelectInst *FalseSI = dyn_cast<SelectInst>(FalseVal)) {
+ if (FalseSI->getCondition() == CondVal) {
+ SI.setOperand(2, FalseSI->getFalseValue());
+ return &SI;
+ }
+ }
+
if (BinaryOperator::isNot(CondVal)) {
SI.setOperand(0, BinaryOperator::getNotArgument(CondVal));
SI.setOperand(1, FalseVal);