From f47171a17c381b2368e9e9c764bb477b2dc6f333 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 15 Jun 2012 10:14:39 -0700 Subject: [PATCH] Don't check for "all off" mask at function entry. We should never be running with an all off mask and thus should never enter a function with an all off mask. No performance change from removing this, however. Issue #282. --- func.cpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/func.cpp b/func.cpp index 4e4e8196..30036491 100644 --- a/func.cpp +++ b/func.cpp @@ -304,12 +304,12 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, llvm::Value *mask = ctx->GetFunctionMask(); llvm::Value *allOn = ctx->All(mask); llvm::BasicBlock *bbAllOn = ctx->CreateBasicBlock("all_on"); - llvm::BasicBlock *bbNotAll = ctx->CreateBasicBlock("not_all_on"); + llvm::BasicBlock *bbSomeOn = ctx->CreateBasicBlock("some_on"); // Set up basic blocks for goto targets ctx->InitializeLabelMap(code); - ctx->BranchInst(bbAllOn, bbNotAll, allOn); + ctx->BranchInst(bbAllOn, bbSomeOn, allOn); // all on: we've determined dynamically that the mask is all // on. Set the current mask to "all on" explicitly so that // codegen for this path can be improved with this knowledge in @@ -321,23 +321,11 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, if (ctx->GetCurrentBasicBlock()) ctx->ReturnInst(); - // not all on: figure out if no instances are running, or if - // some of them are - ctx->SetCurrentBasicBlock(bbNotAll); - ctx->SetFunctionMask(mask); - llvm::BasicBlock *bbNoneOn = ctx->CreateBasicBlock("none_on"); - llvm::BasicBlock *bbSomeOn = ctx->CreateBasicBlock("some_on"); - llvm::Value *anyOn = ctx->Any(mask); - ctx->BranchInst(bbSomeOn, bbNoneOn, anyOn); - - // Everyone is off; get out of here. - ctx->SetCurrentBasicBlock(bbNoneOn); - ctx->ReturnInst(); - - // some on: reset the mask to the value it had at function - // entry and emit the code. Resetting the mask here is - // important, due to the "all on" setting of it for the path - // above + // not all on: however, at least one lane must be running, + // since we should never run with all off... some on: reset + // the mask to the value it had at function entry and emit the + // code. Resetting the mask here is important, due to the "all + // on" setting of it for the path above. ctx->SetCurrentBasicBlock(bbSomeOn); ctx->SetFunctionMask(mask);