[PATCH] D75689: [VectorCombine] fold extract-extract-op with different extraction indexes

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 6 04:24:29 PST 2020


lebedev.ri accepted this revision.
lebedev.ri marked an inline comment as done.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Ok, after looking at this more, i think any further improvements (less pessimistic cost computations)
will look really awkward without first abstracting away the splat shuffle cost,
I think it would be okay to add FIXME's for now.

@RKSimon thoughts?



================
Comment at: llvm/lib/Transforms/Vectorize/VectorCombine.cpp:89-90
+  // opcode (extelt V0, Ext0), (ext V1, Ext1) -->
+  // extelt (opcode (splat V0, Ext0), V1), Ext1
+  int CheapExtractCost = std::min(Extract0Cost, Extract1Cost);
 
----------------
// FIXME: evaluate whether that always results in lowest cost


================
Comment at: llvm/lib/Transforms/Vectorize/VectorCombine.cpp:119
+      return true;
+
+    // If we are extracting from 2 different indexes, then 1 operand must be
----------------
lebedev.ri wrote:
> So essentially we are assuming that this is the optimal cost model.
> Can we assert that?
> ```
> int ExpensiveExtractCost = std::max(Extract0Cost, Extract1Cost);
> (void)ExpensiveExtractCost;
> 
> // FIXME: introduce TargetTransformInfo::SK_Splat.
> assert(TTI.getShuffleCost(TargetTransformInfo::SK_PermuteSingleSrc, VecTy) + CheapExtractCost
>        <=
>        TTI.getShuffleCost(TargetTransformInfo::SK_Broadcast, VecTy) + ExpensiveExtractCost
> );
> ```
Err, that won't really do it i guess, so let's not do that.


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

https://reviews.llvm.org/D75689





More information about the llvm-commits mailing list