[llvm] r286671 - [InstCombine] use dyn_cast rather isa+cast; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 11 15:20:01 PST 2016
Author: spatel
Date: Fri Nov 11 17:20:01 2016
New Revision: 286671
URL: http://llvm.org/viewvc/llvm-project?rev=286671&view=rev
Log:
[InstCombine] use dyn_cast rather isa+cast; NFC
Follow-up to r286664 cleanup as suggested by Eli. Thanks!
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=286671&r1=286670&r2=286671&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Fri Nov 11 17:20:01 2016
@@ -166,7 +166,8 @@ Instruction *InstCombiner::foldSelectOpO
// 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
// instructions.
- if (!isa<BinaryOperator>(TI) || !TI->hasOneUse() || !FI->hasOneUse())
+ BinaryOperator *BO = dyn_cast<BinaryOperator>(TI);
+ if (!BO || !TI->hasOneUse() || !FI->hasOneUse())
return nullptr;
// Figure out if the operations have any operands in common.
@@ -201,7 +202,6 @@ Instruction *InstCombiner::foldSelectOpO
// If we reach here, they do have operations in common.
Value *NewSI = Builder->CreateSelect(SI.getCondition(), OtherOpT, OtherOpF,
SI.getName() + ".v", &SI);
- BinaryOperator *BO = cast<BinaryOperator>(TI);
Value *Op0 = MatchIsOpZero ? MatchOp : NewSI;
Value *Op1 = MatchIsOpZero ? NewSI : MatchOp;
return BinaryOperator::Create(BO->getOpcode(), Op0, Op1);
More information about the llvm-commits
mailing list