[PATCH] D79783: [LV] Fallback strategies if tail-folding fails

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 11:05:01 PDT 2020


dmgreen added a comment.

@SjoerdMeijer I ran into a potential use for this patch in the reduction code I was working on. I think this looks good in general I just had a question about the fallback stratergy.



================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:194-195
+
+static cl::opt<PreferPredicateTy::Option> PreferPredicateOverEpilogue(
+    "prefer-predicate-over-epilog",
+    cl::init(PreferPredicateTy::ScalarEpilogue),
----------------
We should probably pick a single spelling of epilog and stick to it. At least in the same option!
Epilog is nice because it's shorter, but Epilogue seems to be the more common choice?

But feel free to ignore too if you like.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5105
+  if (ScalarEpilogueStatus == CM_ScalarEpilogueNotNeededUsePredicate) {
+    if (PreferPredicateOverEpilogue == PreferPredicateTy::PredicateOrDontVectorize) {
+      LLVM_DEBUG(dbgs() << "LV: Can't fold tail by masking: don't vectorize\n");
----------------
So if I understand this logic properly, the loop hint or the targethook now both mean "try tailpredicate but fall back to vectorize if you can't". The PreferPredicateOverEpilogue option can mean "only tail predicate" or "try tailpredicate, fallback if needed" depending on the choice of the option? (I had not originally realized that was already how this worked for the target hook.)

Do we want the pragma and targethook to always work like that? Or is it worth giving the target hook a choice between the two options. I suspect for MVE we would always want to choose the "with fallback" option, so maybe it's not worth adding?

If we did, we could possibly add another ScalarEpilogueStatus value, to not have to recheck PreferPredicateOverEpilogue or the target hook here.


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

https://reviews.llvm.org/D79783



More information about the llvm-commits mailing list