diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-01-28 03:28:10 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-01-28 03:28:10 +0000 |
commit | b074e3264176b097bf9e9b9b4359af3394cad58e (patch) | |
tree | 83d3385e854315eb69884578b233fede70333588 /llvm/lib/Transforms | |
parent | 6c17d54891d1166fef669cdefb7885801a884fd7 (diff) | |
download | bcm5719-llvm-b074e3264176b097bf9e9b9b4359af3394cad58e.tar.gz bcm5719-llvm-b074e3264176b097bf9e9b9b4359af3394cad58e.zip |
Fold select + select where both selects are on the same condition.
llvm-svn: 124469
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index ff41ab834b1..97abc769ae5 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/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); |