diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-11-10 07:56:12 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-11-10 07:56:12 +0000 |
commit | 3d75b62ffeb694c70f2745be6da658235076146a (patch) | |
tree | 601955ee3cd469fcd9edbc28672a23ab173d9b4c /llvm/lib/Analysis | |
parent | e30a2814490d1e0f1d338a5eebd871e3defd37e4 (diff) | |
download | bcm5719-llvm-3d75b62ffeb694c70f2745be6da658235076146a.tar.gz bcm5719-llvm-3d75b62ffeb694c70f2745be6da658235076146a.zip |
[SCEVExpander] Hoist unsigned divisons when safe
That is, when the divisor is a constant non-zero.
llvm-svn: 286438
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolutionExpander.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp index d94782ab899..216a95870a8 100644 --- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp @@ -198,7 +198,9 @@ Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode, DebugLoc Loc = Builder.GetInsertPoint()->getDebugLoc(); SCEVInsertPointGuard Guard(Builder, this); - if (Opcode != Instruction::UDiv) { + auto *RHSConst = dyn_cast<ConstantInt>(RHS); + + if (Opcode != Instruction::UDiv || (RHSConst && !RHSConst->isZero())) { // FIXME: There is alredy similar logic in expandCodeFor, we should see if // this is actually needed here. |