[PATCH] D118090: [ScalarEvolution] Handle <= and >= in non infinite loops

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 1 08:23:55 PST 2022


nikic added a comment.

In D118090#3351623 <https://reviews.llvm.org/D118090#3351623>, @mtrofin wrote:

> This change has the side-effect of making `SCEVExpander::isHighCostExpansion` return `true` and thus block loop unrolling, which is the root cause of the performance degradation that led to 7e3606f43c63 <https://reviews.llvm.org/rG7e3606f43c63f9622f176a786424c3c92c15f5c0>.
>
> Before, the expression was:
>
> `(1 + ((-2 + %1) /u 2))<nuw>`
>
> with this change, the expression becomes:
>
> `(1 + ((-3 + (4 smax (1 + %1)<nsw>))<nsw> /u 2))<nuw><nsw>`
>
> The `Budget` is always 4, but the second expression trips over it (the `(4 smax (1 + %1)<nsw>)` subexpression raises the cost to 5)

Could you please provide the input IR that is affected? We'd probably want to generate a better BECount than try to adjust cost modelling.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118090



More information about the llvm-commits mailing list