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

Congzhe Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 28 13:05:13 PST 2022


congzhe added a comment.

In D117450#3280642 <https://reviews.llvm.org/D117450#3280642>, @Meinersbur wrote:

> 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.

Thanks Michael, this is what I described as well (I updated my previous reply, just in case you did not notice: https://reviews.llvm.org/D117450#3272927).

Are you suggesting me to modify `RedDesc[followLCSSA(&PHI)].getExactFPMathInst() != nullptr` to something like `!RedDesc[followLCSSA(&PHI)].getFastMathFlags().isfast()` in `areOuterLoopExitPHIsSupported()`?


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

https://reviews.llvm.org/D117450



More information about the llvm-commits mailing list