diff --git a/stmt.cpp b/stmt.cpp index 7a547149..04807faf 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -830,7 +830,7 @@ void DoStmt::EmitCode(FunctionEmitContext *ctx) const { // And now emit code for the loop body ctx->SetCurrentBasicBlock(bloop); - ctx->SetBlockEntryMask(ctx->GetInternalMask()); + ctx->SetBlockEntryMask(ctx->GetFullMask()); ctx->SetDebugPos(pos); // FIXME: in the StmtList::EmitCode() method takes starts/stops a new // scope around the statements in the list. So if the body is just a @@ -1047,7 +1047,7 @@ ForStmt::EmitCode(FunctionEmitContext *ctx) const { // On to emitting the code for the loop body. ctx->SetCurrentBasicBlock(bloop); - ctx->SetBlockEntryMask(ctx->GetInternalMask()); + ctx->SetBlockEntryMask(ctx->GetFullMask()); ctx->AddInstrumentationPoint("for loop body"); if (!dynamic_cast(stmts)) ctx->StartScope(); @@ -2555,7 +2555,7 @@ SwitchStmt::EmitCode(FunctionEmitContext *ctx) const { bool isUniformCF = (type->IsUniformType() && lHasVaryingBreakOrContinue(stmts) == false); ctx->StartSwitch(isUniformCF, bbDone); - ctx->SetBlockEntryMask(ctx->GetInternalMask()); + ctx->SetBlockEntryMask(ctx->GetFullMask()); ctx->SwitchInst(exprValue, svi.defaultBlock ? svi.defaultBlock : bbDone, svi.caseBlocks, svi.nextBlock); diff --git a/tests/entry-mask-do.ispc b/tests/entry-mask-do.ispc new file mode 100644 index 00000000..dd2254b3 --- /dev/null +++ b/tests/entry-mask-do.ispc @@ -0,0 +1,30 @@ + +export uniform int width() { return programCount; } + +int * uniform ptr = NULL; + +int func(int v) { + int ret; + // print("%\n", v); + do { + if (v == 0) { + ret = 1; + break; + } + *ptr = 1; + } while(true); + return ret; +} + +export void f_f(uniform float RET[], uniform float aFOO[]) { + int count = 10; + if (programIndex & 1) + count = 0x7ffffff; + RET[programIndex] = 0; + if (!(programIndex & 1)) + RET[programIndex] = func(programIndex & 1); +} + +export void result(uniform float RET[]) { + RET[programIndex] = !(programIndex & 1); +} diff --git a/tests/entry-mask-for.ispc b/tests/entry-mask-for.ispc new file mode 100644 index 00000000..a04642c7 --- /dev/null +++ b/tests/entry-mask-for.ispc @@ -0,0 +1,30 @@ + +export uniform int width() { return programCount; } + +int * uniform ptr = NULL; + +int func(int v) { + int ret; + // print("%\n", v); + for (;;) { + if (v == 0) { + ret = 1; + break; + } + *ptr = 1; + } + return ret; +} + +export void f_f(uniform float RET[], uniform float aFOO[]) { + int count = 10; + if (programIndex & 1) + count = 0x7ffffff; + RET[programIndex] = 0; + if (!(programIndex & 1)) + RET[programIndex] = func(programIndex & 1); +} + +export void result(uniform float RET[]) { + RET[programIndex] = !(programIndex & 1); +} diff --git a/tests/entry-mask-switch.ispc b/tests/entry-mask-switch.ispc new file mode 100644 index 00000000..541f1487 --- /dev/null +++ b/tests/entry-mask-switch.ispc @@ -0,0 +1,30 @@ + +export uniform int width() { return programCount; } + +int * uniform ptr = NULL; + +int func(int v) { + int ret; + // print("%\n", v); + switch (v) { + case 0: + ret = 1; + break; + case 1: + *ptr = 1; + } + return ret; +} + +export void f_f(uniform float RET[], uniform float aFOO[]) { + int count = 10; + if (programIndex & 1) + count = 0x7ffffff; + RET[programIndex] = 0; + if (!(programIndex & 1)) + RET[programIndex] = func(programIndex & 1); +} + +export void result(uniform float RET[]) { + RET[programIndex] = !(programIndex & 1); +}