From: Sanjay Patel Date: Wed, 16 Nov 2016 20:40:02 +0000 (+0000) Subject: [InstCombine] replace unreachable with assert and remove unreachable code; NFCI X-Git-Tag: llvmorg-4.0.0-rc1~4380 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=80baf69cb5177ff3c03a1cf9a817b4f72ebade10;p=platform%2Fupstream%2Fllvm.git [InstCombine] replace unreachable with assert and remove unreachable code; NFCI llvm-svn: 287147 --- diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index a7d4987..028ae14 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -746,6 +746,8 @@ static Value *foldOperationIntoSelectOperand(Instruction &I, Value *SO, if (auto *Cast = dyn_cast(&I)) return IC->Builder->CreateCast(Cast->getOpcode(), SO, I.getType()); + assert(I.isBinaryOp() && "Unexpected opcode for select folding"); + // Figure out if the constant is the left or the right argument. bool ConstIsRHS = isa(I.getOperand(1)); Constant *ConstOperand = cast(I.getOperand(ConstIsRHS)); @@ -760,26 +762,13 @@ static Value *foldOperationIntoSelectOperand(Instruction &I, Value *SO, if (!ConstIsRHS) std::swap(Op0, Op1); - if (auto *BO = dyn_cast(&I)) { - Value *RI = IC->Builder->CreateBinOp(BO->getOpcode(), Op0, Op1, - SO->getName() + ".op"); - Instruction *FPInst = dyn_cast(RI); - if (FPInst && isa(FPInst)) - FPInst->copyFastMathFlags(BO); - return RI; - } - if (ICmpInst *CI = dyn_cast(&I)) - return IC->Builder->CreateICmp(CI->getPredicate(), Op0, Op1, - SO->getName() + ".cmp"); - // FIXME: This must already be unreachable - we would assert trying to create - // an ICmp from an FCmp predicate. It's likely that the ICmp check above this - // is also unreachable. - if (FCmpInst *CI = dyn_cast(&I)) - return IC->Builder->CreateICmp(CI->getPredicate(), Op0, Op1, - SO->getName() + ".cmp"); - - // FIXME: Change this to an assert above. - llvm_unreachable("Unknown binary instruction type!"); + auto *BO = cast(&I); + Value *RI = IC->Builder->CreateBinOp(BO->getOpcode(), Op0, Op1, + SO->getName() + ".op"); + auto *FPInst = dyn_cast(RI); + if (FPInst && isa(FPInst)) + FPInst->copyFastMathFlags(BO); + return RI; } /// Given an instruction with a select as one operand and a constant as the