[llvm-commits] [llvm] r113525 - /llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp
Chris Lattner
clattner at apple.com
Sat Jan 15 23:21:26 PST 2011
On Sep 9, 2010, at 12:07 PM, Owen Anderson wrote:
> Author: resistor
> Date: Thu Sep 9 14:07:31 2010
> New Revision: 113525
>
> URL: http://llvm.org/viewvc/llvm-project?rev=113525&view=rev
> Log:
> Use code-size reduction metrics to estimate the amount of savings we'll get when we unroll a loop.
> Next step is to recalculate the threshold values given this new heuristic.
Hi Owen,
Sorry to bug you about this old patch, but SizeDecrease is completely dead here and it remains the same way in mainline. What are you trying to accomplish? Should the code just be deleted?
-Chris
>
> 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=113525&r1=113524&r2=113525&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp Thu Sep 9 14:07:31 2010
> @@ -90,7 +90,30 @@
> I != E; ++I)
> Metrics.analyzeBasicBlock(*I);
> NumCalls = Metrics.NumCalls;
> - return Metrics.NumInsts;
> +
> + unsigned LoopSize = Metrics.NumInsts;
> +
> + // If we can identify the induction variable, we know that it will become
> + // constant when we unroll the loop, so factor that into our loop size
> + // estimate.
> + // FIXME: We have to divide by InlineConstants::InstrCost because the
> + // measure returned by CountCodeReductionForConstant is not an instruction
> + // count, but rather a weight as defined by InlineConstants. It would
> + // probably be a good idea to standardize on a single weighting scheme by
> + // pushing more of the logic for weighting into CodeMetrics.
> + if (PHINode *IndVar = L->getCanonicalInductionVariable()) {
> + unsigned SizeDecrease = Metrics.CountCodeReductionForConstant(IndVar);
> + // NOTE: Because SizeDecrease is a fuzzy estimate, we don't want to allow
> + // it to totally negate the cost of unrolling a loop.
> + SizeDecrease = SizeDecrease > LoopSize / 2 ? LoopSize : SizeDecrease;
> + }
> +
> + // Don't allow an estimate of size zero. This would allows unrolling of loops
> + // with huge iteration counts, which is a compile time problem even if it's
> + // not a problem for code quality.
> + if (LoopSize == 0) LoopSize = 1;
> +
> + return LoopSize;
> }
>
> bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list