This is an archive of the discontinued LLVM Phabricator instance.

LoopUnroll: adjust for new `convergent` semantics
Needs ReviewPublic

Authored by nhaehnle on Aug 9 2020, 7:28 AM.

Details

Summary

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

Diff Detail