[PATCH] D146963: [SimpleLoopUnswitch] Fix SCEV invalidation for unswitchTrivialSwitch

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 27 07:17:33 PDT 2023


bjope created this revision.
bjope added a reviewer: fhahn.
Herald added subscribers: StephenFan, javed.absar, hiraditya.
Herald added a project: All.
bjope requested review of this revision.
Herald added a project: LLVM.

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 <https://reviews.llvm.org/rG1bf8ae17f5e2714c8c87978fd2042896af3cd46d> introduce 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146963

Files:
  llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
  llvm/test/Transforms/SimpleLoopUnswitch/update-scev-2.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146963.508647.patch
Type: text/x-patch
Size: 5892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230327/94ad06a9/attachment.bin>


More information about the llvm-commits mailing list