[PATCH] D153145: [LCSSA] Compute SCEV of LCSSA phi if original instruction had SCEV

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 16 08:21:07 PDT 2023


nikic created this revision.
nikic added a reviewer: fhahn.
Herald added subscribers: StephenFan, javed.absar, hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The backstory here is that the LCSSA invalidation we perform here is not really necessary from a SCEV perspective. However, other code may rely on the fact that invalidating only LCSSA phi nodes is sufficient for transforms like loop peeling (see https://reviews.llvm.org/D149331#4398582 for more details).

However, performing invalidation during LCSSA construction also means that SCEV expansion (which may need to construct LCSSA) can invalidate SCEV, which is somewhat unexpected and code may not be prepared to deal with it (see the added test case, reported at https://reviews.llvm.org/D149435#4428219).

Instead of invalidating SCEV, ensure that the LCSSA phi node also has cached SCEV if the original instruction did. This means that later invalidation of LCSSA phi nodes will work as expected. This should avoid both the above issues and be more efficient.


https://reviews.llvm.org/D153145

Files:
  llvm/include/llvm/Analysis/ScalarEvolution.h
  llvm/lib/Transforms/Utils/LCSSA.cpp
  llvm/test/Transforms/IndVarSimplify/lcssa-preservation.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153145.532160.patch
Type: text/x-patch
Size: 5729 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230616/e9ed51f3/attachment.bin>


More information about the llvm-commits mailing list