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

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 10 09:28:03 PDT 2021


sdesmalen added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp:873-879
+  bool ExactIndVars = (any_of(getInductionVars(), [&](auto &Induction) -> bool {
+    InductionDescriptor IndDesc = Induction.second;
+    return IndDesc.getExactFPMathInst();
+  }));
+
+  if (!getInductionVars().empty() && ExactIndVars)
+    return false;
----------------
is it sufficient to write:

  if (any_of(..... { }))
    return false;

(i.e. if `ExactIndVars` is true, then `!getInductionVars().empty()` must also be true)


================
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;
----------------
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`.


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

https://reviews.llvm.org/D101836



More information about the llvm-commits mailing list