diff options
| author | Reid Spencer <rspencer@reidspencer.com> | 2006-12-23 18:58:04 +0000 |
|---|---|---|
| committer | Reid Spencer <rspencer@reidspencer.com> | 2006-12-23 18:58:04 +0000 |
| commit | 43c77d53ff24af1f7bce7eba21ae859e20ebef1d (patch) | |
| tree | d6e064af495d13e6a5ca8b3ca9a80e4e83af5e70 /llvm/lib/Transforms | |
| parent | ccf78ac1d004d2b769a8b829212a5b744ca3692c (diff) | |
| download | bcm5719-llvm-43c77d53ff24af1f7bce7eba21ae859e20ebef1d.tar.gz bcm5719-llvm-43c77d53ff24af1f7bce7eba21ae859e20ebef1d.zip | |
For PR1065:
Don't allow CmpInst instances to be processed in FoldSelectOpOp because
you can't easily swap their operands.
llvm-svn: 32753
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 205dfef84a8..3397530482f 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -6555,13 +6555,7 @@ Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI, } // Only handle binary, compare and shift operators here. - if (!isa<ShiftInst>(TI) && !isa<BinaryOperator>(TI) && !isa<CmpInst>(TI)) - return 0; - - // If the CmpInst predicates don't match, then the instructions aren't the - // same and we can't continue. - if (isa<CmpInst>(TI) && isa<CmpInst>(FI) && - (cast<CmpInst>(TI)->getPredicate() != cast<CmpInst>(FI)->getPredicate())) + if (!isa<ShiftInst>(TI) && !isa<BinaryOperator>(TI)) return 0; // Figure out if the operations have any operands in common. @@ -6603,12 +6597,13 @@ Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI, return BinaryOperator::create(BO->getOpcode(), MatchOp, NewSI); else return BinaryOperator::create(BO->getOpcode(), NewSI, MatchOp); - } else { - if (MatchIsOpZero) - return new ShiftInst(cast<ShiftInst>(TI)->getOpcode(), MatchOp, NewSI); - else - return new ShiftInst(cast<ShiftInst>(TI)->getOpcode(), NewSI, MatchOp); } + + assert(isa<ShiftInst>(TI) && "Should only have Shift here"); + if (MatchIsOpZero) + return new ShiftInst(cast<ShiftInst>(TI)->getOpcode(), MatchOp, NewSI); + else + return new ShiftInst(cast<ShiftInst>(TI)->getOpcode(), NewSI, MatchOp); } Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { |

