[all-commits] [llvm/llvm-project] ba8fac: [SimpleLoopUnswitch] Fix SCEV invalidation for uns...

Björn Pettersson via All-commits all-commits at lists.llvm.org
Tue Mar 28 00:42:55 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ba8facfff061f54bb6c89640e4c519478a8294a3
      https://github.com/llvm/llvm-project/commit/ba8facfff061f54bb6c89640e4c519478a8294a3
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2023-03-28 (Tue, 28 Mar 2023)

  Changed paths:
    M llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
    A llvm/test/Transforms/SimpleLoopUnswitch/update-scev-2.ll

  Log Message:
  -----------
  [SimpleLoopUnswitch] Fix SCEV invalidation for unswitchTrivialSwitch

When doing a trivial unswitch of a switch statement the code need
to "invalidate SCEVs for the outermost loop reached by any of the
exits", as indicated by code comments.

Depending on if we find such an outermost loop or not we can limit
the invalidation to some sub-loops or the full loop-nest. As shown
in the added test case there seem to have been some bugs in the code
that was finding the "outermost loop", so we could end up invalidating
too few loops.

Seems like commit 1bf8ae17f5e2714c8c87978 introduced the bug by
moving the code that invalidates the loops above some of the code
that computed 'OuterL'. This patch fixes that by also moving that
computation of 'OuterL' so that we compute 'OuterL' properly before
we use it for the SCEV invalidation.

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




More information about the All-commits mailing list