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/unittests/Analysis/ScalarEvolutionTest.cpp | |
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/unittests/Analysis/ScalarEvolutionTest.cpp')
-rw-r--r-- | llvm/unittests/Analysis/ScalarEvolutionTest.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp index f9289250419..bc5b12ae892 100644 --- a/llvm/unittests/Analysis/ScalarEvolutionTest.cpp +++ b/llvm/unittests/Analysis/ScalarEvolutionTest.cpp @@ -538,6 +538,19 @@ TEST_F(ScalarEvolutionsTest, BadHoistingSCEVExpander_PR30942) { ASSERT_NE(DivFromScratchExpansionInst, nullptr); EXPECT_EQ(DivInst->getParent(), DivFromScratchExpansionInst->getParent()); } + + { + auto *ArgY = getArgByName(F, "y"); + auto *SafeDivSCEV = + SE.getUDivExpr(SE.getSCEV(ArgY), SE.getConstant(APInt(32, 19))); + + auto *SafeDivExpansion = + Expander.expandCodeFor(SafeDivSCEV, SafeDivSCEV->getType(), + DivInst->getParent()->getTerminator()); + auto *SafeDivExpansionInst = dyn_cast<Instruction>(SafeDivExpansion); + ASSERT_NE(SafeDivExpansionInst, nullptr); + EXPECT_EQ("loop.ph", SafeDivExpansionInst->getParent()->getName()); + } }); } |