[PATCH] D115329: [LoopVectorize] Pass a vector type to isLegalMaskedGather/Scatter

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 13 06:58:58 PST 2021


lebedev.ri added a comment.

In D115329#3188834 <https://reviews.llvm.org/D115329#3188834>, @sdesmalen wrote:

> @lebedev.ri/@fhahn given that there exists a pass that scalarizes the masked load/store/gather/scatter intrinsics,
> is there a reason why we wouldn't always want to choose the intrinsic representation over scalarizing it in the LV?
> It seems a bit odd to want to trick the LV to think that a masked gather is legal, but then still scalarize it in the end.
> This means it is not using the right cost-model, unless it reimplements the scalarization costs,
> like is done by `X86TargetTransformInfo::getGSScalarCost`.

The fact that something is/isn't legal does not mean that LV will pick *that* particular path.
It merely allows LV to consider this path, among the others,
and out of all the legal paths, pick the most profitable one.

We don't "trick LV to think it's legal and then scalarize anyway", it *is* legal.
But for those particular VF's, it's more costly than the native scalarized path.
So LV won't actually produce gather intrinsics, and naturally, they won't be scalarized.

Furthermore, no, while we could just always prefer the intrinsics (from correctness viewpoint),
that is detrimental to the performance. See e.g. my recent patches, namely D111220 <https://reviews.llvm.org/D111220> / D111363 <https://reviews.llvm.org/D111363> / D111546 <https://reviews.llvm.org/D111546>.

So no, what happens is correct.


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

https://reviews.llvm.org/D115329



More information about the llvm-commits mailing list