[PATCH] D85605: LoopUnroll: adjust for new `convergent` semantics

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 9 07:28:03 PDT 2020


nhaehnle created this revision.
nhaehnle added reviewers: arsenm, foad, sameerds.
Herald added subscribers: zzheng, hiraditya.
Herald added a project: LLVM.
nhaehnle requested review of this revision.
Herald added a subscriber: wdng.

Adjust the unrolling check for the new semantics:

- There is no restriction on loops with convergent operations that are controlled inside the loop -- their behavior with respect to cross-thread communication is (partially) implementation-defined, and the loop unrolling is part of the implementation, so...

- Unrolling loops with the heart in a strange place is entirely forbidden.

  Technically, it would be possible to unroll a loop where the heart dominates all latches, as the heart could be equivalently moved into the header in that case -- but we don't consider this here.

Fix unrolling with loop heart intrinsics: in a typical loop with a
loop heart in the header that uses a token from outside the loop,
duplicating the intrinsic would introduce multiple static uses of a
convergence control token in a cycle that does not contain its definition.

Spell out the setup of UnrollLoopOptions to reduce the potential for
confusion caused by very long struct initializers.

Change-Id: I7e261c95e098a1622313647e89ad79826d7c7c9a


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85605

Files:
  llvm/include/llvm/Analysis/CodeMetrics.h
  llvm/include/llvm/Transforms/Utils/UnrollLoop.h
  llvm/lib/Analysis/CodeMetrics.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/lib/Transforms/Utils/LoopUnroll.cpp
  llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
  llvm/test/Transforms/LoopUnroll/convergent.controlled.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85605.284200.patch
Type: text/x-patch
Size: 34665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200809/10363421/attachment.bin>


More information about the llvm-commits mailing list