This is an archive of the discontinued LLVM Phabricator instance.

[LoopVectorize] Add a flag to prevent reordering of FP operations with hints
AbandonedPublic

Authored by kmclaughlin on May 19 2021, 6:52 AM.

Details

Summary

When loop hints are passed via metadata, the allowReordering() function
in LoopVectorizationLegality will allow the order of floating point
operations to be changed:

bool allowReordering() const {
  // When enabling loop hints are provided we allow the vectorizer to change
  // the order of operations that is given by the scalar loop. This is not
  // enabled by default because can be unsafe or inefficient.

This patch adds a flag to disable this behaviour for testing purposes,
particularly for testing vectorization with in-order reductions, which
requires further changes (D101836) to be enabled without the use of hints.

Diff Detail

Event Timeline

kmclaughlin created this revision.May 19 2021, 6:52 AM
kmclaughlin requested review of this revision.May 19 2021, 6:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2021, 6:52 AM
sdesmalen added inline comments.May 19 2021, 8:11 AM
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
342

Can you add to the description that this has always been the default behaviour for Clang, so it is enabled by default to avoid causing unexpected regressions for code that uses these loop hints.

8008

This looks a bit odd. How about you make this an option to LoopVectorizationLegality, so that you can just call Hints.allowReordering() here without passing the option?

kmclaughlin abandoned this revision.May 24 2021, 6:23 AM
kmclaughlin marked an inline comment as done.

Abandoning as these changes have been combined with D101836