[PATCH] D132308: [LV] Replace fixed-order cost model with a SK_Splice shuffle

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 22 01:28:45 PDT 2022


dmgreen added a comment.

>> Hm, sounds like your fix improves some targets and at the same time possibly regresses others?

>From looking through the backends that have any tests for "shufflevector", with the codegen from https://godbolt.org/z/r8j69Kz9z - it is Power, SystemZ and X86 that can produce a single instruction but do not have any costmodel for SK_Splice (AArch64 and RISCV have some costs). I've tried to add reviews from each of those architectures. Unfortunately the regressions under MVE were really large, like 250% in some cases.

> For now, please can you add a SK_Splice -> SK_PermuteTwoSrc remapping to targets with getShuffleCost that don't recognise SK_Splice?

I believe that a SK_Splice will currently be costed as a SK_PermuteTwoSrc via https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/CodeGen/BasicTTIImpl.h#L946. This will be high for targets with an Splice/Ext/vpalignr/etc instruction, but will be more accurate on any architecture without it.

Looking again at the cost models, both Power and SystemZ seems to treat all shuffles as cheap as they support cheap arbitrary permutations. That just leaves X86, and whilst I would offer to try and adjust the costmodel I don't think I understand the many variations of the architecture enough to do it well. @RKSimon do you want me to add an `if (Kind == TTI::SK_Splice) Kind = TTI::SK_PermuteTwoSrc;` to X86TTIImpl::getShuffleCost, or are you happier to do it properly yourself?


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

https://reviews.llvm.org/D132308



More information about the llvm-commits mailing list