llvm.org GIT mirror llvm / c9d44f0
Add simple cost model to perfect shuffle. Currently we're doing just greedy search for cost instead of (proper) dynamic programming approach. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79623 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 10 years ago
1 changed file(s) with 9 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
103103 unsigned short ShuffleMask;
104104 unsigned short OpNum;
105105 const char *Name;
106
107 Operator(unsigned short shufflemask, const char *name, unsigned opnum)
108 : ShuffleMask(shufflemask), OpNum(opnum), Name(name) {
106 unsigned Cost;
107
108 Operator(unsigned short shufflemask, const char *name, unsigned opnum,
109 unsigned cost = 1)
110 : ShuffleMask(shufflemask), OpNum(opnum), Name(name), Cost(cost) {
109111 TheOperators.push_back(this);
110112 }
111113 ~Operator() {
118120 }
119121
120122 const char *getName() const { return Name; }
121
123 unsigned getCost() const { return Cost; }
124
122125 unsigned short getTransformedMask(unsigned short LHSMask, unsigned RHSMask) {
123126 // Extract the elements from LHSMask and RHSMask, as appropriate.
124127 unsigned Result = 0;
301304 // Evaluate op(LHS,LHS)
302305 unsigned ResultMask = Op->getTransformedMask(LHS, LHS);
303306
304 unsigned Cost = ShufTab[LHS].Cost + 1;
307 unsigned Cost = ShufTab[LHS].Cost + Op->getCost();
305308 if (Cost < ShufTab[ResultMask].Cost) {
306309 ShufTab[ResultMask].Cost = Cost;
307310 ShufTab[ResultMask].Op = Op;
339342 EvaluateOps(LHS, Vals, NumVals);
340343 EvaluateOps(RHS, Vals, NumVals);
341344
342 unsigned Cost = NumVals + 1;
345 unsigned Cost = NumVals + Op->getCost();
343346 if (Cost < ShufTab[ResultMask].Cost) {
344347 ShufTab[ResultMask].Cost = Cost;
345348 ShufTab[ResultMask].Op = Op;