aboutsummaryrefslogtreecommitdiffstats
path: root/utils/PerfectShuffle
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2009-08-21 12:41:03 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2009-08-21 12:41:03 +0000
commitc9d44f0d9c609f86e13fbf2e27165b663f94efe3 (patch)
tree7da9c948eaa7f553bb4e6b3481081558213a0fd0 /utils/PerfectShuffle
parent62e84f177d4519bf719d188496faf8b6c247e3a7 (diff)
downloadexternal_llvm-c9d44f0d9c609f86e13fbf2e27165b663f94efe3.zip
external_llvm-c9d44f0d9c609f86e13fbf2e27165b663f94efe3.tar.gz
external_llvm-c9d44f0d9c609f86e13fbf2e27165b663f94efe3.tar.bz2
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
Diffstat (limited to 'utils/PerfectShuffle')
-rw-r--r--utils/PerfectShuffle/PerfectShuffle.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/utils/PerfectShuffle/PerfectShuffle.cpp b/utils/PerfectShuffle/PerfectShuffle.cpp
index 5a0c2ba..0ec42f1 100644
--- a/utils/PerfectShuffle/PerfectShuffle.cpp
+++ b/utils/PerfectShuffle/PerfectShuffle.cpp
@@ -104,9 +104,11 @@ struct Operator {
unsigned short ShuffleMask;
unsigned short OpNum;
const char *Name;
-
- Operator(unsigned short shufflemask, const char *name, unsigned opnum)
- : ShuffleMask(shufflemask), OpNum(opnum), Name(name) {
+ unsigned Cost;
+
+ 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,7 +121,8 @@ 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.
unsigned Result = 0;
@@ -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;