[PATCH] D27811: [CostModel][X86] Add support for broadcast shuffle costs

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 10:09:39 PST 2016


RKSimon added inline comments.


================
Comment at: lib/Analysis/CostModel.cpp:93
 
+static bool isBroadcastVectorMask(SmallVectorImpl<int> &Mask) {
+  for (unsigned i = 0, MaskSize = Mask.size(); i < MaskSize; ++i)
----------------
mkuper wrote:
> We already have this helper in CGP (that version also checks if you're splatting *any* element, not just element 0.)
> Maybe make it common? Not entirely sure what the appropriate place for it yes, though. Would it make sense for CGP to use CostModel?
Adding isSplatMask/isSplat/getSplatIndex support to ShuffleVectorInst (worth adding them to all to match ShuffleVectorSDNode ?) would be trivial, then both CodeGenPrepare and CostModel could use it easily.

It would probably be worth upgrading SK_Broadcast at the same time to support broadcasting any Index value (not just 0) - given that almost nothing uses it so far that shouldn't be a problem.

What other cost model cases did you have in mind? CodeGenPrepare::optimizeShuffleVectorInst seems quite limited.


Repository:
  rL LLVM

https://reviews.llvm.org/D27811





More information about the llvm-commits mailing list