From 1eec27f890366e7640e547b913fdde7349ff4107 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 31 Jan 2012 08:52:11 -0800 Subject: [PATCH] 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. --- llvmutil.cpp | 3 +++ opt.cpp | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/llvmutil.cpp b/llvmutil.cpp index 4ae07b96..92abd392 100644 --- a/llvmutil.cpp +++ b/llvmutil.cpp @@ -597,6 +597,9 @@ LLVMFlattenInsertChain(llvm::InsertElementInst *ie, int vectorWidth, bool LLVMVectorValuesAllEqual(llvm::Value *v, int vectorLength, std::vector &seenPhis) { + if (vectorLength == 1) + return true; + if (llvm::isa(v)) return true; diff --git a/opt.cpp b/opt.cpp index b4570235..c564aa21 100644 --- a/opt.cpp +++ b/opt.cpp @@ -2515,10 +2515,12 @@ GSToLoadStorePass::runOnBasicBlock(llvm::BasicBlock &bb) { } else { // 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. - Warning(pos, "Undefined behavior: all program instances are " - "writing to the same location!"); + if (g->target.vectorWidth > 1) + Warning(pos, "Undefined behavior: all program instances are " + "writing to the same location!"); llvm::Value *first = llvm::ExtractElementInst::Create(storeValue, LLVMInt32(0), "rvalue_first", @@ -2694,10 +2696,12 @@ PseudoGSToGSPass::runOnBasicBlock(llvm::BasicBlock &bb) { Assert(ok); callInst->setCalledFunction(info->actualFunc); - if (info->isGather) - PerformanceWarning(pos, "Gather required to compute value in expression."); - else - PerformanceWarning(pos, "Scatter required for storing value."); + if (g->target.vectorWidth > 1) { + if (info->isGather) + PerformanceWarning(pos, "Gather required to compute value in expression."); + else + PerformanceWarning(pos, "Scatter required for storing value."); + } modifiedAny = true; goto restart; }