[all-commits] [llvm/llvm-project] 8977bd: [IndVars] Invalidate SCEV when IR is changed in re...

Florian Hahn via All-commits all-commits at lists.llvm.org
Wed Oct 20 12:49:01 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8977bd58067d9dcd5e8cebd078c45ff629af9e1d
      https://github.com/llvm/llvm-project/commit/8977bd58067d9dcd5e8cebd078c45ff629af9e1d
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2021-10-20 (Wed, 20 Oct 2021)

  Changed paths:
    M llvm/lib/Transforms/Utils/LoopUtils.cpp
    M llvm/test/Transforms/IndVarSimplify/elim-extend.ll
    M llvm/test/Transforms/IndVarSimplify/invalidate-modified-lcssa-phi.ll

  Log Message:
  -----------
  [IndVars] Invalidate SCEV when IR is changed in rewriteLoopExitValue.

At the moment, rewriteLoopExitValue forgets the current phi node in the
loop that collects phis to rewrite. A few lines after the value is
forgotten, SCEV is used again to analyze incoming values and
potentially expand SCEV expression. This means that another SCEV is
created for PN, before the IR is actually updated in the next loop.

This leads to accessing invalid cached expression in combination with
D71539.

PN should only be changed once the actual incoming exit value is set in
the next loop. Moving invalidation there should ensure that PN is
invalidated in all relevant cases.

Reviewed By: mkazantsev

Differential Revision: https://reviews.llvm.org/D111495




More information about the All-commits mailing list