Always check the execution mask after break/continue/return.

When "break", "continue", or "return" is used under varying control flow,
we now always check the execution mask to see if all of the program
instances are executing it.  (Previously, this was only done with "cbreak",
"ccontinue", and "creturn", which are now deprecated.)

An important effect of this change is that it fixes a family of cases
where we could end up running with an "all off" execution mask, which isn't
supposed to happen, as it leads to all sorts of invalid behavior.

This change does cause the volume rendering example to run 9% slower, but
doesn't affect the other examples.

Issue #257.
This commit is contained in:
Matt Pharr
2012-07-06 11:09:11 -07:00
parent 73afab464f
commit 2d8026625b
6 changed files with 38 additions and 81 deletions

37
stmt.h
View File

@@ -195,45 +195,31 @@ public:
};
/** @brief Statement implementation for a break or 'coherent' break
statement in the program. */
/** @brief Statement implementation for a break statement in the
program. */
class BreakStmt : public Stmt {
public:
BreakStmt(bool doCoherenceCheck, SourcePos pos);
BreakStmt(SourcePos pos);
void EmitCode(FunctionEmitContext *ctx) const;
void Print(int indent) const;
Stmt *TypeCheck();
int EstimateCost() const;
private:
/** This indicates whether the generated code will check to see if no
more program instances are currently running after the break, in
which case the code can have a jump to the end of the current
loop. */
const bool doCoherenceCheck;
};
/** @brief Statement implementation for a continue or 'coherent' continue
statement in the program. */
/** @brief Statement implementation for a continue statement in the
program. */
class ContinueStmt : public Stmt {
public:
ContinueStmt(bool doCoherenceCheck, SourcePos pos);
ContinueStmt(SourcePos pos);
void EmitCode(FunctionEmitContext *ctx) const;
void Print(int indent) const;
Stmt *TypeCheck();
int EstimateCost() const;
private:
/** This indicates whether the generated code will check to see if no
more program instances are currently running after the continue, in
which case the code can have a jump to the end of the current
loop. */
const bool doCoherenceCheck;
};
@@ -314,11 +300,11 @@ public:
/** @brief Statement implementation for a 'return' or 'coherent' return
statement in the program. */
/** @brief Statement implementation for a 'return' statement in the
program. */
class ReturnStmt : public Stmt {
public:
ReturnStmt(Expr *e, bool cc, SourcePos p);
ReturnStmt(Expr *e, SourcePos p);
void EmitCode(FunctionEmitContext *ctx) const;
void Print(int indent) const;
@@ -327,11 +313,6 @@ public:
int EstimateCost() const;
Expr *expr;
/** This indicates whether the generated code will check to see if no
more program instances are currently running after the return, in
which case the code can possibly jump to the end of the current
function. */
const bool doCoherenceCheck;
};