From 79e0a9f32aa067850ed21e9744490ccec3cc4dd7 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 8 Jun 2012 14:56:18 -0700 Subject: [PATCH] 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. --- stmt.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stmt.cpp b/stmt.cpp index 974af871..25d1d3d5 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -1649,11 +1649,12 @@ ForeachStmt::EmitCode(FunctionEmitContext *ctx) const { // width. Set the mask and jump to the masked loop body. ctx->SetCurrentBasicBlock(bbAllInnerPartialOuter); { llvm::Value *mask; - if (extrasMaskPtrs.size() == 0) + if (nDims == 1) // 1D loop; we shouldn't ever get here anyway mask = LLVMMaskAllOff; else - mask = ctx->LoadInst(extrasMaskPtrs.back()); + mask = ctx->LoadInst(extrasMaskPtrs[nDims-2]); + ctx->SetInternalMask(mask); ctx->StoreInst(LLVMTrue, stepIndexAfterMaskedBodyPtr);