Fixed the last useless step in foreach_tiled in some cases

This commit is contained in:
Andrey Shishpanov
2016-04-11 01:56:33 +03:00
parent 2fab324924
commit ab4cd1e8a2
2 changed files with 36 additions and 1 deletions

View File

@@ -1988,7 +1988,13 @@ ForeachStmt::EmitCode(FunctionEmitContext *ctx) const {
}
ctx->StoreInst(LLVMFalse, stepIndexAfterMaskedBodyPtr);
ctx->BranchInst(bbMaskedBody);
// check to see if counter != end, otherwise, the next step is not necessary
llvm::Value *counter = ctx->LoadInst(uniformCounterPtrs[nDims-1], "counter");
llvm::Value *atEnd =
ctx->CmpInst(llvm::Instruction::ICmp, llvm::CmpInst::ICMP_NE,
counter, endVals[nDims-1], "at_end");
ctx->BranchInst(bbMaskedBody, bbReset[nDims-1], atEnd);
}
///////////////////////////////////////////////////////////////////////////