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_TASK_LAUNCH = 16,
|
||||||
COST_TYPECAST_COMPLEX = 4,
|
COST_TYPECAST_COMPLEX = 4,
|
||||||
COST_TYPECAST_SIMPLE = 1,
|
COST_TYPECAST_SIMPLE = 1,
|
||||||
|
COST_UNIFORM_IF = 2,
|
||||||
|
COST_VARYING_IF = 3,
|
||||||
COST_UNIFORM_LOOP = 4,
|
COST_UNIFORM_LOOP = 4,
|
||||||
COST_VARYING_LOOP = 6,
|
COST_VARYING_LOOP = 6,
|
||||||
COST_ASSERT = 8,
|
COST_ASSERT = 8,
|
||||||
|
|||||||
8
stmt.cpp
8
stmt.cpp
@@ -541,7 +541,13 @@ Stmt *IfStmt::TypeCheck() {
|
|||||||
|
|
||||||
int
|
int
|
||||||
IfStmt::EstimateCost() const {
|
IfStmt::EstimateCost() const {
|
||||||
return ((test ? test->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) +
|
(trueStmts ? trueStmts->EstimateCost() : 0) +
|
||||||
(falseStmts ? falseStmts->EstimateCost() : 0));
|
(falseStmts ? falseStmts->EstimateCost() : 0));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user