[PATCH] D99204: [LoopRotate] Hoist invariant loads

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 23 12:09:54 PDT 2021


thopre created this revision.
thopre added reviewers: fhahn, jeroen.dobbelaere, lebedev.ri, nikic, sanwou01.
Herald added subscribers: jfb, hiraditya.
thopre requested review of this revision.
Herald added a project: LLVM.

With loop peeling, it is important that unnecessary PHIs be avoided or
it will leads to spurious peeling. One source of such PHIs is loop
rotation which creates PHIs for invariant loads. Those PHIs are
particularly problematic since loop peeling is now run as part of simple
loop unrolling before GVN is run, and are thus a source of spurious
peeling.

Note that while some of the load can be hoisted and eventually
eliminated by instruction combine, this is not always possible due to
alignment issue. In particular, the motivating example [1] was a load
inside a class instance which cannot be hoisted because the `this'
pointer has an alignment of 1.

[1]
http://lists.llvm.org/pipermail/llvm-dev/attachments/20210312/4ce73c47/attachment.cpp

This commit adds logic during loop rotation to prevent PHIs creation for
invariant load, by relying on FindAvailableLoadedValue()'s analysis of
aliasing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99204

Files:
  llvm/include/llvm/Transforms/Utils/LoopRotationUtils.h
  llvm/lib/Transforms/Scalar/LoopRotation.cpp
  llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
  llvm/test/Transforms/LoopRotate/load-hoist.ll
  llvm/test/Transforms/LoopRotate/loopexitinglatch.ll
  llvm/unittests/Transforms/Utils/LoopRotationUtilsTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99204.332751.patch
Type: text/x-patch
Size: 20668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210323/c417e22e/attachment.bin>


More information about the llvm-commits mailing list