[PATCH] D95789: [SpeculateAroundPHIs] Avoid speculation on loop back edges

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 1 07:58:48 PST 2021


bjope created this revision.
Herald added subscribers: zzheng, hiraditya.
bjope requested review of this revision.
Herald added a project: LLVM.

In https://bugs.llvm.org/show_bug.cgi?id=48821 there are some
discussions around problems with SpeculateAroundPHIs and back-edges
in loops.

One problem observed is that when splitting a critical edge that
is a loop latch, the pass isn't transferring loop metadata to the
new latch (nor removing the old loop metadata). So if we want to
allow speculation for such scenarios we need to fix that.

There have also been observations that (downstream) backends have
had problems with identifying hwloops when allowing speculation
involving back-edges. That might be a target specific problem
that potentially could be resolved by adding a TTI hook, or possibly
by keeping the loop form by also rotating loops after the pass (need
to decide if opt should canonicalize the loop in such manner or if
a backend need to rotate loops in the codegen pipeline).

This also avoid some differences between LegacyPM and NewPM when
it comes to how we optimize loops. So this could make the transition
to the new pass manager more clean, avoiding to change both pass
manager and potentially introducing new phase ordering issues at the
same time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95789

Files:
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/Scalar/SpeculateAroundPHIs.cpp
  llvm/test/Transforms/PhaseOrdering/loop-rotation-vs-common-code-hoisting.ll
  llvm/test/Transforms/PhaseOrdering/reassociate-after-unroll.ll
  llvm/test/Transforms/SpeculateAroundPHIs/loop-latch.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95789.320469.patch
Type: text/x-patch
Size: 26529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210201/83663f24/attachment.bin>


More information about the llvm-commits mailing list