[PATCH] D115646: [DAG][TLI][X86][ARM][AArch64] Add `isExtractSubvectorFree` / use it in `foldExtractSubvectorFromShuffleVector()`

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 10 09:21:53 PST 2022


lebedev.ri marked 2 inline comments as done.
lebedev.ri added a comment.

In D115646#3231202 <https://reviews.llvm.org/D115646#3231202>, @RKSimon wrote:

> Any luck with finding a x86 test case?



In D115646#3231647 <https://reviews.llvm.org/D115646#3231647>, @greened wrote:

> We do need an X86 test for this.

Sorry, i do not have an x86 test for this..



================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:20795
+              // and that replacing one non-cheap subvector extract
+              // with two cheap ones is a win.
+  };
----------------
greened wrote:
> The values here make it seem like replacing a non-cheap operation with two cheap ones yields the same performance (1+1 = 2). contrary to the comment.  Is this intentional?
Not only does it make seem so, that is exactly what the comment is saying.


================
Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:12899
+  return isExtractSubvectorFree(ResVT, SrcVT, Index);
+}
+
----------------
greened wrote:
> So here, it seems like even if the extract is "free" (cost 0) it'll be counted as "cheap" (cost 1).
> 
> I wonder if it would be better to combine these functions into a single "getExtractSubvectorCost" target hook.
> So here, it seems like even if the extract is "free" (cost 0) it'll be counted as "cheap" (cost 1).

Right. Because even free extractions can be done for cheap, if that makes sense.

> I wonder if it would be better to combine these functions into a single "getExtractSubvectorCost" target hook.

We could do that, there's already `*TTIImpl::getShuffleCost()`, the problem being, what will be the "cheap budget",
i.e. how should the uses of `isExtractSubvectorCheap()` be adjusted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115646



More information about the llvm-commits mailing list