[PATCH] D91481: [LoopUnroll] Discount uniform instructions in cost models

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 26 15:56:07 PDT 2021


nikic added a comment.

In D91481#2783449 <https://reviews.llvm.org/D91481#2783449>, @reames wrote:

> In D91481#2783436 <https://reviews.llvm.org/D91481#2783436>, @nikic wrote:
>
>>> The reasoning here is that such an expression (as determined by SCEV) will be CSEd once the loop is unrolled.
>>
>> Is that really the case? I don't think unrolling itself does any CSE, and runtime unrolling is run at the very end of the pipeline, so we don't have any EarlyCSE or GVN passes after it.
>
> If this is a problem in practice, we can add simple CSE to the unroll transform.

Without having a CSE after unrolling, it's not immediately clear to me why this change would make sense from a cost-modelling perspective. It models these instructions as free, but (without CSE) they will not be free.

>> Also, the converse question: Why have invariant instructions not been hoisted by LICM before unrolling is reached?
>
> This uses SCEV's notion of invariant, not Loops.  As an example, LIV udiv LIV2 is invariant, but can't be hoisted unless we can prove LIV2 != 0.

Unfortunately, using SCEVs notion of invariance is rather problematic here, because it requires creating SCEV expressions for every single instruction in the loop. This has predictable impact on compile-time: https://llvm-compile-time-tracker.com/compare.php?from=963495f0d4b5a0707f82b6c6454f42f3aa52da9b&to=39492e37b8285c2ccc8a58136191a011c590470c&stat=instructions


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91481/new/

https://reviews.llvm.org/D91481



More information about the llvm-commits mailing list