Don't issue gather/scatter warnigns in the 'extra' bits of foreach loops.

With AOS data, we can often coalesce the accesses into gathers for the main
part of foreach loops but only fail on the last bits where the mask is not
all on (since the coalescing code doesn't handle mixed masks, yet.) Before,
we'd report success with coalescing and then also report that gathers were needed
for the same accesses that were coalesced, which was a) confusing, and b)
didn't accurately represent what was going on for the majority of the loop
iterations.
This commit is contained in:
Matt Pharr
2012-03-19 15:08:35 -07:00
parent d74cc6397b
commit 7e954e4248
4 changed files with 45 additions and 17 deletions

22
ctx.cpp
View File

@@ -245,6 +245,8 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
StoreInst(llvm::Constant::getNullValue(LLVMTypes::VoidPointerType),
launchGroupHandlePtr);
disableGSWarningCount = 0;
const Type *returnType = function->GetReturnType();
if (!returnType || Type::Equal(returnType, AtomicType::Void))
returnValuePtr = NULL;
@@ -1106,6 +1108,19 @@ FunctionEmitContext::InForeachLoop() const {
}
void
FunctionEmitContext::DisableGatherScatterWarnings() {
++disableGSWarningCount;
}
void
FunctionEmitContext::EnableGatherScatterWarnings() {
--disableGSWarningCount;
}
bool
FunctionEmitContext::initLabelBBlocks(ASTNode *node, void *data) {
LabeledStmt *ls = dynamic_cast<LabeledStmt *>(node);
@@ -2492,7 +2507,8 @@ FunctionEmitContext::gather(llvm::Value *ptr, const PointerType *ptrType,
// Add metadata about the source file location so that the
// optimization passes can print useful performance warnings if we
// can't optimize out this gather
addGSMetadata(call, currentPos);
if (disableGSWarningCount == 0)
addGSMetadata(call, currentPos);
return BitCastInst(call, llvmReturnType, "gather_bitcast");
}
@@ -2801,7 +2817,9 @@ FunctionEmitContext::scatter(llvm::Value *value, llvm::Value *ptr,
args.push_back(value);
args.push_back(mask);
llvm::Value *inst = CallInst(scatterFunc, NULL, args);
addGSMetadata(inst, currentPos);
if (disableGSWarningCount == 0)
addGSMetadata(inst, currentPos);
}