Update cost model to include "if" overhead in "if" statement calculation.

This commit is contained in:
Matt Pharr
2011-10-15 13:52:08 -07:00
parent 422b8268a9
commit fc2954419d
2 changed files with 11 additions and 3 deletions

2
ispc.h
View File

@@ -367,6 +367,8 @@ enum {
COST_TASK_LAUNCH = 16,
COST_TYPECAST_COMPLEX = 4,
COST_TYPECAST_SIMPLE = 1,
COST_UNIFORM_IF = 2,
COST_VARYING_IF = 3,
COST_UNIFORM_LOOP = 4,
COST_VARYING_LOOP = 6,
COST_ASSERT = 8,

View File

@@ -541,9 +541,15 @@ Stmt *IfStmt::TypeCheck() {
int
IfStmt::EstimateCost() const {
return ((test ? test->EstimateCost() : 0) +
(trueStmts ? trueStmts->EstimateCost() : 0) +
(falseStmts ? falseStmts->EstimateCost() : 0));
int ifcost = 0;
const Type *type;
if (test && (type = test->GetType()) != NULL)
ifcost = type->IsUniformType() ? COST_UNIFORM_IF : COST_VARYING_IF;
return ifcost +
((test ? test->EstimateCost() : 0) +
(trueStmts ? trueStmts->EstimateCost() : 0) +
(falseStmts ? falseStmts->EstimateCost() : 0));
}