Prevent division by 0.
authorMichael Zolotukhin <mzolotukhin@apple.com>
Fri, 13 Feb 2015 00:17:03 +0000 (00:17 +0000)
committerMichael Zolotukhin <mzolotukhin@apple.com>
Fri, 13 Feb 2015 00:17:03 +0000 (00:17 +0000)
When we try to estimate number of potentially removed instructions in
loop unroller, we analyze first N iterations and then scale the
computed number by TripCount/N. We should bail out early if N is 0.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228988 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopUnrollPass.cpp

index 3065b52cef1fec871cffbd7ceb5005a1763ae944..a575c457553f63b0ca6b2202790d01f0a0ad1556 100644 (file)
@@ -548,7 +548,7 @@ static unsigned
 approximateNumberOfOptimizedInstructions(const Loop *L, ScalarEvolution &SE,
                                          unsigned TripCount,
                                          const TargetTransformInfo &TTI) {
-  if (!TripCount)
+  if (!TripCount || !UnrollMaxIterationsCountToAnalyze)
     return 0;
 
   UnrollAnalyzer UA(L, TripCount, SE, TTI);