[PATCH] D129636: Fix a LSR debug invariance issue

Markus Lavin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 15 02:35:55 PDT 2022


markus added a comment.

In D129636#3654426 <https://reviews.llvm.org/D129636#3654426>, @eopXD wrote:

> May you explain a bit how the test case shows `SE.forgetValue()` is preserving debug invariance. Thank you.

Right. The test case intends to show that for the given input LSR will give the same output regardless if debug info is stripped before running the LSR pass or after running the LSR pass (i.e .the pass being debug invariant).

Before the addition of `SE.forgetValue()` this was not the case and the test failed.

As I understand it LSR uses `SCEVExpander` to generate code for some of the expressions used by the new loop and the problem lies in that that `SCEVExpander` will search among (and reuse) values that have already been analyzed by SCEV (i.e. `SE.getSCEV()`. Now having debug intrinsics in the input means that we may do `SE.getSCEV()` on values that we would not have done `SE.getSCEV()` on otherwise and this may result in `SCEVExpander` generating different code which is bad.

It is still up for debate if `SE.forgetValue()` is the right solution but the idea was that if we immediately forget about those values that were analyzed just because of the debug intrinsic they will not end up affecting the `SCEVExpander`.


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

https://reviews.llvm.org/D129636



More information about the llvm-commits mailing list