From 1b0d847874af8690916795b5a1bfe36204738ad6 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sat, 23 Dec 2006 18:58:04 +0000 Subject: [PATCH] For PR1065: Don't allow CmpInst instances to be processed in FoldSelectOpOp because you can't easily swap their operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32753 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Scalar/InstructionCombining.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 205dfef84a8..3397530482f 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/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(TI) && !isa(TI) && !isa(TI)) - return 0; - - // If the CmpInst predicates don't match, then the instructions aren't the - // same and we can't continue. - if (isa(TI) && isa(FI) && - (cast(TI)->getPredicate() != cast(FI)->getPredicate())) + if (!isa(TI) && !isa(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(TI)->getOpcode(), MatchOp, NewSI); - else - return new ShiftInst(cast(TI)->getOpcode(), NewSI, MatchOp); } + + assert(isa(TI) && "Should only have Shift here"); + if (MatchIsOpZero) + return new ShiftInst(cast(TI)->getOpcode(), MatchOp, NewSI); + else + return new ShiftInst(cast(TI)->getOpcode(), NewSI, MatchOp); } Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {