[PATCH] D101836: [LoopVectorize] Enable strict reductions when allowReordering() returns false

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 11 00:32:26 PDT 2021


david-arm added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp:884
+  // reduction operations in-loop.
+  bool ExactRdxVars = (any_of(getReductionVars(), [&](auto &Reduction) -> bool {
+    RecurrenceDescriptor RdxDesc = Reduction.second;
----------------
sdesmalen wrote:
> Is it still necessary to iterate through the reduction variables at this point? Given that EnableStrictReductions is true, and that reductions are the only other operations that can have exact FPMath instructions, I think you can just return `true`.
We don't support vectorising all of these reductions, for example we don't suppose strict reductions involving `fmul` and we don't support chains of `fadds` currently either. That's why in the code below we check `!RdxDesc.isOrdered()` because the ordered flag is only set for cases we can support at the moment. I think @kmclaughlin has added a test for this case as well below called `fast_induction_unordered_reduction` which shows how there are both fmul and fadd reductions in the same loop.


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

https://reviews.llvm.org/D101836



More information about the llvm-commits mailing list