[PATCH] D21720: Unroll for uncountable loops

Evgeny Stupachenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 14 14:53:15 PDT 2017


evstupac added a comment.

> Okay, so is the general plan here to?
> 
> 1. Generally allow unrolling of uncountable loops

That seems reasonable. I'll enable this at https://reviews.llvm.org/owners/package/3/.

> 2. Adjust the profitability heuristic to account for the cost of the branches for the uncountable case

In most cases we can not remove branches in uncountable (isa<SCEVCouldNotCompute>(SE->getBackedgeTakenCount(L)) is true) loops. And it is hard to detect cases when we can.
To be able to reduce IVs (if there are such) we'll need to count them and do some basic analysis. A lot of uncountable loops don't have IVs at all.
So the heuristic we have for Runtime unrolling (with unknown trip count) is not ok here.

> 3. Include, as necessary, in our general profitability heuristic (if we don't get this naturally), savings from phi-derived values which are cyclic with a small cycle length (like the s = -s case).

Right now this is the only way to see if unroll for uncountable loop is profitable or not.

> I agree that we should start from (1). But I don't understand, why (2) (and (3) ) is considered special for the uncountable case. AFAIU, the current heuristic aims at simulating these savings (removed branches) already - even though we do not try to accurately predict cost of rolled and unrolled version of the loop. Am I missing something?

Current heuristic works for loops with unknown trip count (when we are able to calculate it, but runtime only). It is not applicable for uncountable loops.


Repository:
  rL LLVM

https://reviews.llvm.org/D21720





More information about the llvm-commits mailing list