[PATCH] D49225: [SLPVectorizer] Move scalar/vector costs to helper functions (NFCI).

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 17 07:02:41 PDT 2018


RKSimon added a comment.

In https://reviews.llvm.org/D49225#1164986, @ABataev wrote:

> In https://reviews.llvm.org/D49225#1164807, @RKSimon wrote:
>
> > I think the use of TTI->getInstructionCost in getScalarCost would be quite straightforward - it is getVectorCost that will need most of the custom handling as we're manipulating scalar Instructions to query equivalent vector costs.
> >
> > IMO we're better off using the getScalarCost/getVectorCost abstractions instead of embedding TTI->getInstructionCost calls directly inside BoUpSLP::getEntryCost - it notably helps simplify the code and improves readability.
>
>
> I tried to do something similar some time ago, but I did not like it. Instead of one switch for opcode we have 2. But we already know the opcode in many cases and, actually, the second switch is required only for the shuffles. Maybe it is worth it to outline several standalone functions for PHIs, CmpInsts, BinOps etc. and use them directly where we know the opcode and use these getScalarCost/getVectorCost only for shuffles? Of course, these 2 functions also should call these outlined cost functions for each particular opcode.


I can investigate ways to return std::pair<int, int> if you think that might be better? That would avoid the scalar/vector switch statement duplication, TTI->getInstructionCost will be doing something very similar.

An alternative would be to handle shufflevector/alternate separately (like we do for gather stages) and split getEntryCost into 2 functions - the special cases (gathers/alternates etc.) and the costs for particular opcodes.


Repository:
  rL LLVM

https://reviews.llvm.org/D49225





More information about the llvm-commits mailing list