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

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));
}