[PATCH] D109432: [LoopVectorize] Permit fixed-width epilogue loops for scalable vector bodies

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 13 08:37:43 PDT 2021


david-arm added a comment.

In D109432#2995562 <https://reviews.llvm.org/D109432#2995562>, @bmahjour wrote:

> Different plans may have different recipes, so if we don't find a single plan that supports both the main VF and the epilogue VF, I worry we may get unintended codegen. Furthermore, what guarantees that a vplan with a fixed-width conversion from the scalable VF actually exists? Would it be possible to build scalable plans that include the corresponding fixed width (and some lower powers of 2) VFs?

Hi @bmahjour thanks for taking a look at the patch and leaving some comments!

So in LoopVectorizationPlanner::plan we do try to build vplans with equivalent ranges of VFs, i.e.

  buildVPlansWithVPRecipes(ElementCount::getFixed(1), MaxFactors.FixedVF);
  buildVPlansWithVPRecipes(ElementCount::getScalable(1), MaxFactors.ScalableVF);

Even if for some reason we are missing the fixed-width equivalent from the vplan the worst thing that can happen is we just won't produce an epilogue loop I think? In future we do intend to also add support for using scalable vectors in the epilogue loop as well, but I imagine that this is less likely to be profitable because "VF=vscale x 2" will likely cover more scalar iterations than "VF=2". This means there is a lower chance of us ever entering the epilogue loop.

However, you make a good point about the possibility of having different recipes for the same loop depending upon whether it's scalable or fixed-width. I wasn't sure if this would actually be a problem or not because the vectorised loops are independent. At the moment I can't think of a scenario where the recipes would be different, but perhaps I can add code to bail out if the recipes are different?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109432



More information about the llvm-commits mailing list