mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-03 14:08:57 +00:00
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
This commit is contained in:
parent
62e84f177d
commit
c9d44f0d9c
@ -104,9 +104,11 @@ struct Operator {
|
||||
unsigned short ShuffleMask;
|
||||
unsigned short OpNum;
|
||||
const char *Name;
|
||||
unsigned Cost;
|
||||
|
||||
Operator(unsigned short shufflemask, const char *name, unsigned opnum)
|
||||
: ShuffleMask(shufflemask), OpNum(opnum), Name(name) {
|
||||
Operator(unsigned short shufflemask, const char *name, unsigned opnum,
|
||||
unsigned cost = 1)
|
||||
: ShuffleMask(shufflemask), OpNum(opnum), Name(name), Cost(cost) {
|
||||
TheOperators.push_back(this);
|
||||
}
|
||||
~Operator() {
|
||||
@ -119,6 +121,7 @@ struct Operator {
|
||||
}
|
||||
|
||||
const char *getName() const { return Name; }
|
||||
unsigned getCost() const { return Cost; }
|
||||
|
||||
unsigned short getTransformedMask(unsigned short LHSMask, unsigned RHSMask) {
|
||||
// Extract the elements from LHSMask and RHSMask, as appropriate.
|
||||
@ -302,7 +305,7 @@ int main() {
|
||||
// Evaluate op(LHS,LHS)
|
||||
unsigned ResultMask = Op->getTransformedMask(LHS, LHS);
|
||||
|
||||
unsigned Cost = ShufTab[LHS].Cost + 1;
|
||||
unsigned Cost = ShufTab[LHS].Cost + Op->getCost();
|
||||
if (Cost < ShufTab[ResultMask].Cost) {
|
||||
ShufTab[ResultMask].Cost = Cost;
|
||||
ShufTab[ResultMask].Op = Op;
|
||||
@ -340,7 +343,7 @@ int main() {
|
||||
EvaluateOps(LHS, Vals, NumVals);
|
||||
EvaluateOps(RHS, Vals, NumVals);
|
||||
|
||||
unsigned Cost = NumVals + 1;
|
||||
unsigned Cost = NumVals + Op->getCost();
|
||||
if (Cost < ShufTab[ResultMask].Cost) {
|
||||
ShufTab[ResultMask].Cost = Cost;
|
||||
ShufTab[ResultMask].Op = Op;
|
||||
|
Loading…
Reference in New Issue
Block a user