Merge pull request #501 from jbrodman/sven
Fix branch tests for breaks and returns.
This commit is contained in:
9
ctx.cpp
9
ctx.cpp
@@ -841,6 +841,9 @@ FunctionEmitContext::jumpIfAllLoopLanesAreDone(llvm::BasicBlock *target) {
|
||||
if (breakLanesPtr == NULL) {
|
||||
llvm::Value *continued = LoadInst(continueLanesPtr,
|
||||
"continue_lanes");
|
||||
continued = BinaryOperator(llvm::Instruction::And,
|
||||
continued, GetFunctionMask(),
|
||||
"continued&func");
|
||||
allDone = MasksAllEqual(continued, blockEntryMask);
|
||||
}
|
||||
else {
|
||||
@@ -860,6 +863,10 @@ FunctionEmitContext::jumpIfAllLoopLanesAreDone(llvm::BasicBlock *target) {
|
||||
finishedLanes = BinaryOperator(llvm::Instruction::Or, finishedLanes,
|
||||
continued, "returned|breaked|continued");
|
||||
}
|
||||
|
||||
finishedLanes = BinaryOperator(llvm::Instruction::And,
|
||||
finishedLanes, GetFunctionMask(),
|
||||
"finished&func");
|
||||
|
||||
// Do we match the mask at loop or switch statement entry?
|
||||
allDone = MasksAllEqual(finishedLanes, blockEntryMask);
|
||||
@@ -1266,7 +1273,7 @@ FunctionEmitContext::CurrentLanesReturned(Expr *expr, bool doCoherenceCheck) {
|
||||
LoadInst(returnedLanesPtr, "old_returned_lanes");
|
||||
llvm::Value *newReturnedLanes =
|
||||
BinaryOperator(llvm::Instruction::Or, oldReturnedLanes,
|
||||
GetInternalMask(), "old_mask|returned_lanes");
|
||||
GetFullMask(), "old_mask|returned_lanes");
|
||||
|
||||
// For 'coherent' return statements, emit code to check if all
|
||||
// lanes have returned
|
||||
|
||||
6
stmt.cpp
6
stmt.cpp
@@ -374,6 +374,7 @@ lEmitIfStatements(FunctionEmitContext *ctx, Stmt *stmts, const char *trueOrFalse
|
||||
|
||||
/** Returns true if the "true" block for the if statement consists of a
|
||||
single 'break' statement, and the "false" block is empty. */
|
||||
/*
|
||||
static bool
|
||||
lCanApplyBreakOptimization(Stmt *trueStmts, Stmt *falseStmts) {
|
||||
if (falseStmts != NULL) {
|
||||
@@ -392,7 +393,7 @@ lCanApplyBreakOptimization(Stmt *trueStmts, Stmt *falseStmts) {
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
void
|
||||
IfStmt::EmitCode(FunctionEmitContext *ctx) const {
|
||||
@@ -447,6 +448,8 @@ IfStmt::EmitCode(FunctionEmitContext *ctx) const {
|
||||
ctx->SetCurrentBasicBlock(bexit);
|
||||
ctx->EndIf();
|
||||
}
|
||||
/*
|
||||
// Disabled for performance reasons. Change to an optional compile-time opt switch.
|
||||
else if (lCanApplyBreakOptimization(trueStmts, falseStmts)) {
|
||||
// If we have a simple break statement inside the 'if' and are
|
||||
// under varying control flow, just update the execution mask
|
||||
@@ -456,6 +459,7 @@ IfStmt::EmitCode(FunctionEmitContext *ctx) const {
|
||||
// benefit in this case.
|
||||
ctx->SetInternalMaskAndNot(ctx->GetInternalMask(), testValue);
|
||||
}
|
||||
*/
|
||||
else
|
||||
emitVaryingIf(ctx, testValue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user