Scalar target fixes.

Don't issue warnings about all instances writing to the same location if
there is only one program instance in the gang.

Be sure to report that all values are equal in one-element vectors in
LLVMVectorValuesAllEqual().

Issue #166.
This commit is contained in:
Matt Pharr
2012-01-31 08:52:11 -08:00
parent 950f86200b
commit 1eec27f890
2 changed files with 14 additions and 7 deletions

View File

@@ -597,6 +597,9 @@ LLVMFlattenInsertChain(llvm::InsertElementInst *ie, int vectorWidth,
bool bool
LLVMVectorValuesAllEqual(llvm::Value *v, int vectorLength, LLVMVectorValuesAllEqual(llvm::Value *v, int vectorLength,
std::vector<llvm::PHINode *> &seenPhis) { std::vector<llvm::PHINode *> &seenPhis) {
if (vectorLength == 1)
return true;
if (llvm::isa<llvm::ConstantAggregateZero>(v)) if (llvm::isa<llvm::ConstantAggregateZero>(v))
return true; return true;

18
opt.cpp
View File

@@ -2515,10 +2515,12 @@ GSToLoadStorePass::runOnBasicBlock(llvm::BasicBlock &bb) {
} }
else { else {
// A scatter with everyone going to the same location is // A scatter with everyone going to the same location is
// undefined. Issue a warning and arbitrarily let the // undefined (if there's more than one program instance in
// the gang). Issue a warning and arbitrarily let the
// first guy win. // first guy win.
Warning(pos, "Undefined behavior: all program instances are " if (g->target.vectorWidth > 1)
"writing to the same location!"); Warning(pos, "Undefined behavior: all program instances are "
"writing to the same location!");
llvm::Value *first = llvm::Value *first =
llvm::ExtractElementInst::Create(storeValue, LLVMInt32(0), "rvalue_first", llvm::ExtractElementInst::Create(storeValue, LLVMInt32(0), "rvalue_first",
@@ -2694,10 +2696,12 @@ PseudoGSToGSPass::runOnBasicBlock(llvm::BasicBlock &bb) {
Assert(ok); Assert(ok);
callInst->setCalledFunction(info->actualFunc); callInst->setCalledFunction(info->actualFunc);
if (info->isGather) if (g->target.vectorWidth > 1) {
PerformanceWarning(pos, "Gather required to compute value in expression."); if (info->isGather)
else PerformanceWarning(pos, "Gather required to compute value in expression.");
PerformanceWarning(pos, "Scatter required for storing value."); else
PerformanceWarning(pos, "Scatter required for storing value.");
}
modifiedAny = true; modifiedAny = true;
goto restart; goto restart;
} }