summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2012-10-24 19:46:44 +0000
committerHal Finkel <hfinkel@anl.gov>2012-10-24 19:46:44 +0000
commit30bd9346a0b5b2f4b2a2032a447239d9aa3c85ef (patch)
tree1d6bb52aade22dc4cccf5fc7985ba0234736b57f /llvm/lib
parent79a97119184dfafe8c6190754d66bc8bcb118a86 (diff)
downloadbcm5719-llvm-30bd9346a0b5b2f4b2a2032a447239d9aa3c85ef.tar.gz
bcm5719-llvm-30bd9346a0b5b2f4b2a2032a447239d9aa3c85ef.zip
getSmallConstantTripMultiple should never return zero.
When the trip count is -1, getSmallConstantTripMultiple could return zero, and this would cause runtime loop unrolling to assert. Instead of returning zero, one is now returned (consistent with the existing overflow cases). Fixes PR14167. llvm-svn: 166612
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 3e062988823..148912b766b 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -3979,8 +3979,11 @@ getSmallConstantTripMultiple(Loop *L, BasicBlock *ExitingBlock) {
ConstantInt *Result = MulC->getValue();
- // Guard against huge trip counts.
- if (!Result || Result->getValue().getActiveBits() > 32)
+ // Guard against huge trip counts (this requires checking
+ // for zero to handle the case where the trip count == -1 and the
+ // addition wraps).
+ if (!Result || Result->getValue().getActiveBits() > 32 ||
+ Result->getValue().getActiveBits() == 0)
return 1;
return (unsigned)Result->getZExtValue();
OpenPOWER on IntegriCloud