[PATCH] D149323: [SCEV] Don't invalidate past dependency-breaking instructions

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 28 03:25:20 PDT 2023


nikic added a comment.

In D149323#4304765 <https://reviews.llvm.org/D149323#4304765>, @mkazantsev wrote:

> If we prove that two values are the same, their SCEVs can also be proven the same (and not necessarity SCEVUnknown). If a load is equal to some non-load. then load's SCEV can be non-SCEVUnknown.

I think your example is a bit confusing because it uses `%sum` both in the load address and the comparison. Let's consider this variant where `%v` and `%load1` are only related by the comparison:

  %load1 = load i32, ptr %p
  if (%load1 == %v) {
     %load2 = load i32, ptr %p
  }

If we determined that `getSCEV(%load2) = getSCEV(%v)` based on the comparison and memory dependence reasoning here, then invalidating `%v` would not invalidate `%load2` even with the current implementation, because there is no use-def relationship between them. We would have to invalidate based on potential memory dependences, which is not feasible in practice.

While SCEV could in theory do something like this, it doesn't do this currently, and it's very unlikely that it will do so in the future. If it does do so in the future, we can change this code to reflect the new reality...


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

https://reviews.llvm.org/D149323



More information about the llvm-commits mailing list