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

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 1 08:12:20 PST 2022


mtrofin added a comment.

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)

@wsmoses, is there a follow-up for mitigating cost estimate implications?


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