From 8b9c97493f03f14de6d88710a767828dc08d66fb Mon Sep 17 00:00:00 2001 From: Michael Zolotukhin Date: Fri, 13 Feb 2015 00:17:03 +0000 Subject: [PATCH] Prevent division by 0. 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/LoopUnrollPass.cpp b/lib/Transforms/Scalar/LoopUnrollPass.cpp index 3065b52cef1..a575c457553 100644 --- a/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -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); -- 2.40.0