[PATCH] D116688: [SLP]Excluded external uses from the reprdering estimation.

Vasileios Porpodas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 6 12:30:25 PST 2022


vporpo added a comment.

I agree with your second point, it is too pessimistic and should be fixed. 
But I don't fully follow your first point. What do you mean that it will affect the cost in all lanes?

Here is an example where the external uses cost can help:

  %1 = load A[0]
  %2 = load A[1] // %2 has external use
  %3 = load B[0]
  %4 = load A[1]
  %Ln1 = add %1, %3
  %Ln2 = add %2, %4
  ...
  ... = %2 // External use of %2

While doing the operand reordering we can choose to vectorize either {%1, %2} or {%1, %4}. 
Both have the same opcodes etc. so the rest of the cost calculation will give them the exact same score.
But wouldn't we prefer to vectorize {%1, %4} rather than {%1, %2} to avoid the extract instruction? 
How would we do this without taking into account the cost of the external uses?



================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:1143-1144
+    /// \returns The additional cost due to possible broadcasting of the
+    /// elements in the lane. It is more profitable to have power-of-2 unique
+    /// elements in the lane, it will be vectorized with higher probability.
+    int getSplatCost(unsigned Lane, unsigned OpIdx, unsigned Idx) const {
----------------
ABataev wrote:
> vporpo wrote:
> > Please explain in the comments why it is more profitable.
> Do you suggest to ad thу explanation here?
Yes, please add the explanation in the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116688



More information about the llvm-commits mailing list