diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-11-11 23:01:20 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-11-11 23:01:20 +0000 |
commit | cb2199b2f33e978b7ad4eaa5bea327162a63478b (patch) | |
tree | 211bc09f82225c030eb0f0e2012d6401ed4f9db8 | |
parent | 3c43737832d0df721a32749c121d06897eed527c (diff) | |
download | bcm5719-llvm-cb2199b2f33e978b7ad4eaa5bea327162a63478b.tar.gz bcm5719-llvm-cb2199b2f33e978b7ad4eaa5bea327162a63478b.zip |
[InstCombine] clean up foldSelectOpOp(); NFC
llvm-svn: 286664
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index 06b769bc05a..9c70f3e6d48 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -162,8 +162,6 @@ Instruction *InstCombiner::foldSelectOpOp(SelectInst &SI, Instruction *TI, TI->getType()); } - // TODO: This function ends awkwardly in unreachable - fix to be more normal. - // Only handle binary operators with one-use here. As with the cast case // above, it may be possible to relax the one-use constraint, but that needs // be examined carefully since it may not reduce the total number of @@ -203,14 +201,10 @@ Instruction *InstCombiner::foldSelectOpOp(SelectInst &SI, Instruction *TI, // If we reach here, they do have operations in common. Value *NewSI = Builder->CreateSelect(SI.getCondition(), OtherOpT, OtherOpF, SI.getName() + ".v", &SI); - - if (BinaryOperator *BO = dyn_cast<BinaryOperator>(TI)) { - if (MatchIsOpZero) - return BinaryOperator::Create(BO->getOpcode(), MatchOp, NewSI); - else - return BinaryOperator::Create(BO->getOpcode(), NewSI, MatchOp); - } - llvm_unreachable("Shouldn't get here"); + BinaryOperator *BO = cast<BinaryOperator>(TI); + Value *Op0 = MatchIsOpZero ? MatchOp : NewSI; + Value *Op1 = MatchIsOpZero ? NewSI : MatchOp; + return BinaryOperator::Create(BO->getOpcode(), Op0, Op1); } static bool isSelect01(Constant *C1, Constant *C2) { |