[llvm] r278998 - [LoopUnroll] Move a simple check earlier. NFC.

Haicheng Wu via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 15:42:58 PDT 2016


Author: haicheng
Date: Wed Aug 17 17:42:58 2016
New Revision: 278998

URL: http://llvm.org/viewvc/llvm-project?rev=278998&view=rev
Log:
[LoopUnroll] Move a simple check earlier. NFC.

Move the check of CallInst earlier to skip expensive recursive operations.

Differential Revision: https://reviews.llvm.org/D23611

Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp?rev=278998&r1=278997&r2=278998&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp Wed Aug 17 17:42:58 2016
@@ -431,16 +431,16 @@ analyzeLoopUnrollCost(const Loop *L, uns
         if (IsFree)
           continue;
 
-        // If the instruction might have a side-effect recursively account for
-        // the cost of it and all the instructions leading up to it.
-        if (I.mayHaveSideEffects())
-          AddCostRecursively(I, Iteration);
-
         // Can't properly model a cost of a call.
         // FIXME: With a proper cost model we should be able to do it.
         if(isa<CallInst>(&I))
           return None;
 
+        // If the instruction might have a side-effect recursively account for
+        // the cost of it and all the instructions leading up to it.
+        if (I.mayHaveSideEffects())
+          AddCostRecursively(I, Iteration);
+
         // If unrolled body turns out to be too big, bail out.
         if (UnrolledCost > MaxUnrolledLoopSize) {
           DEBUG(dbgs() << "  Exceeded threshold.. exiting.\n"




More information about the llvm-commits mailing list