Fix codegen bug with foreach_tiled.

When the outermost dimension(s) were partially active, but the innermost
dimension was all on, we'd inadvertently use an incorrect "all on"
execution mask.

Fixes issues #177 and #200.
This commit is contained in:
Matt Pharr
2012-06-08 14:56:18 -07:00
parent 6c9bc63a1c
commit 79e0a9f32a

View File

@@ -1649,11 +1649,12 @@ ForeachStmt::EmitCode(FunctionEmitContext *ctx) const {
// width. Set the mask and jump to the masked loop body. // width. Set the mask and jump to the masked loop body.
ctx->SetCurrentBasicBlock(bbAllInnerPartialOuter); { ctx->SetCurrentBasicBlock(bbAllInnerPartialOuter); {
llvm::Value *mask; llvm::Value *mask;
if (extrasMaskPtrs.size() == 0) if (nDims == 1)
// 1D loop; we shouldn't ever get here anyway // 1D loop; we shouldn't ever get here anyway
mask = LLVMMaskAllOff; mask = LLVMMaskAllOff;
else else
mask = ctx->LoadInst(extrasMaskPtrs.back()); mask = ctx->LoadInst(extrasMaskPtrs[nDims-2]);
ctx->SetInternalMask(mask); ctx->SetInternalMask(mask);
ctx->StoreInst(LLVMTrue, stepIndexAfterMaskedBodyPtr); ctx->StoreInst(LLVMTrue, stepIndexAfterMaskedBodyPtr);