This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Hoist forall bounds computation when possible
ClosedPublic

Authored by jeanPerier on May 22 2023, 8:34 AM.

Details

Summary

When inner forall bound computations do not depend on previous
forall indices, they can be hoisted.
This is possible because:

  • bound computation are required to be pure (so evaluating them only once is possible).
  • If the bound computation depends on a value previously assigned, the forall scheduling analysis created different run for it: the assignment impacting the bounds value is not part of the current loop nest.

The reason this optimization is done at that point and not as part of
generic loop hoisting optimization is that having the all the loop
bound computation hoisted will allow allocating simple temporary
storages. The number of iteration can be pre-computed and used as the
extent for the temporary.

Diff Detail

Event Timeline

jeanPerier created this revision.May 22 2023, 8:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2023, 8:34 AM
jeanPerier requested review of this revision.May 22 2023, 8:34 AM
tblah accepted this revision.May 22 2023, 9:04 AM

LGTM, thanks!

This revision is now accepted and ready to land.May 22 2023, 9:04 AM
vzakhari accepted this revision.May 22 2023, 12:05 PM