From 383c55870eda2ce1664d8e9d199b1ba7bacd32ba Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Mon, 11 May 2015 21:02:34 +0000 Subject: [PATCH] [LoopIdiomRecognize] Transform backedge-taken count check into an assertion. runOnCountable() allowed the caller to call on a loop without a predictable backedge-taken count. Change the code so that only loops with computable backdge-count can call this function, in order to catch abuses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237044 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LoopIdiomRecognize.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp index 7bc291784ab..b57b7c276d7 100644 --- a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -611,7 +611,9 @@ bool NclPopcountRecognize::recognize() { bool LoopIdiomRecognize::runOnCountableLoop() { const SCEV *BECount = SE->getBackedgeTakenCount(CurLoop); - if (isa(BECount)) return false; + assert(!isa(BECount) && + "runOnCountableLoop() called on a loop without a predictable" + "backedge-taken count"); // If this loop executes exactly one time, then it should be peeled, not // optimized by this pass. -- 2.50.1