[PATCH] D117450: [LoopInterchange] Support loop interchange with floating point reductions

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 28 12:44:33 PST 2022


Meinersbur added a comment.

I applied the patch myself the check.

The other uses of IVDescriptors is LoopVectorizationLegality.

  if (RecurrenceDescriptor::isReductionPHI(Phi, TheLoop, RedDes, DB, AC,
                                           DT)) {
    Requirements->addExactFPMathInst(RedDes.getExactFPMathInst());
    AllowedExit.insert(RedDes.getLoopExitInstr());
    Reductions[Phi] = RedDes;
    continue;
  }

`addExactFPMathInst` as the comments:

  /// This holds vectorization requirements that must be verified late in
  /// the process. The requirements are set by legalize and costmodel. Once
  /// vectorization has been determined to be possible and profitable the
  /// requirements can be verified by looking for metadata or compiler options.
  /// For example, some loops require FP commutativity which is only allowed if
  /// vectorization is explicitly specified or if the fast-math compiler option
  /// has been provided.
  /// Late evaluation of these requirements allows helpful diagnostics to be
  /// composed that tells the user what need to be done to vectorize the loop. For
  /// example, by specifying #pragma clang loop vectorize or -ffast-math. Late
  /// evaluation should be used only when diagnostics can generated that can be
  /// followed by a non-expert user.
  class LoopVectorizationRequirements {
  public:
    /// Track the 1st floating-point instruction that can not be reassociated.
    void addExactFPMathInst(Instruction *I);

I suggest to do the same with LoopInterchange. That is, `RD.getFastMathFlags()` contains requirements that still needs to be checked.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117450/new/

https://reviews.llvm.org/D117450



More information about the llvm-commits mailing list