Update cost model to include "if" overhead in "if" statement calculation.
This commit is contained in:
2
ispc.h
2
ispc.h
@@ -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,
|
||||
|
||||
12
stmt.cpp
12
stmt.cpp
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user