summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorTyler Nowicki <tyler.nowicki@gmail.com>2015-08-27 18:56:49 +0000
committerTyler Nowicki <tyler.nowicki@gmail.com>2015-08-27 18:56:49 +0000
commit5eaa5a9d2617543322412b12a3c33f18381d29d7 (patch)
tree25d1d2da0d1870e5739ea2ae6fc0e9a5a350f47f /llvm/lib/Transforms
parent05845d31c9a8a3b94d6344845243500d56a7afcf (diff)
downloadbcm5719-llvm-5eaa5a9d2617543322412b12a3c33f18381d29d7.tar.gz
bcm5719-llvm-5eaa5a9d2617543322412b12a3c33f18381d29d7.zip
Improve vectorization diagnostic messages and extend vectorize(enable) pragma.
This patch changes the analysis diagnostics produced when loops with floating-point recurrences or memory operations are identified. The new messages say "cannot prove it is safe to reorder * operations; allow reordering by specifying #pragma clang loop vectorize(enable)". Depending on the type of diagnostic the message will include additional options such as ffast-math or __restrict__. This patch also allows the vectorize(enable) pragma to override the low pointer memory check threshold. When the hint is given a higher threshold is used. See the clang patch for the options produced for each diagnostic. llvm-svn: 246187
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp40
1 files changed, 25 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 6fc1aaab6e1..eaa3ecd48e4 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -214,6 +214,11 @@ static cl::opt<unsigned> MaxNestedScalarReductionIC(
cl::desc("The maximum interleave count to use when interleaving a scalar "
"reduction in a nested loop."));
+static cl::opt<unsigned> PragmaVectorizeMemoryCheckThreshold(
+ "pragma-vectorize-memory-check-threshold", cl::init(128), cl::Hidden,
+ cl::desc("The maximum allowed number of runtime memory checks with a "
+ "vectorize(enable) pragma."));
+
namespace {
// Forward declarations.
@@ -929,6 +934,15 @@ public:
return DiagnosticInfo::AlwaysPrint;
}
+ bool allowReordering() const {
+ // When enabling loop hints are provided we allow the vectorizer to change
+ // the order of operations that is given by the scalar loop. This is not
+ // enabled by default because can be unsafe or inefficient. For example,
+ // reordering floating-point operations will change the way round-off
+ // error accumulates in the loop.
+ return getForce() == LoopVectorizeHints::FK_Enabled || getWidth() > 1;
+ }
+
private:
/// Find hints specified in the loop metadata and update local values.
void getHintsFromMetadata() {
@@ -1427,29 +1441,25 @@ public:
bool doesNotMeet(Function *F, Loop *L, const LoopVectorizeHints &Hints) {
const char *Name = Hints.vectorizeAnalysisPassName();
bool Failed = false;
- if (UnsafeAlgebraInst &&
- Hints.getForce() == LoopVectorizeHints::FK_Undefined &&
- Hints.getWidth() == 0) {
+ if (UnsafeAlgebraInst && !Hints.allowReordering()) {
emitOptimizationRemarkAnalysisFPCommute(
F->getContext(), Name, *F, UnsafeAlgebraInst->getDebugLoc(),
- VectorizationReport() << "vectorization requires changes in the "
- "order of operations, however IEEE 754 "
- "floating-point operations are not "
- "commutative");
+ VectorizationReport() << "cannot prove it is safe to reorder "
+ "floating-point operations");
Failed = true;
}
- if (NumRuntimePointerChecks >
- VectorizerParams::RuntimeMemoryCheckThreshold) {
+ // Test if runtime memcheck thresholds are exceeded.
+ bool PragmaThresholdReached =
+ NumRuntimePointerChecks > PragmaVectorizeMemoryCheckThreshold;
+ bool ThresholdReached =
+ NumRuntimePointerChecks > VectorizerParams::RuntimeMemoryCheckThreshold;
+ if ((ThresholdReached && !Hints.allowReordering()) ||
+ PragmaThresholdReached) {
emitOptimizationRemarkAnalysisAliasing(
F->getContext(), Name, *F, L->getStartLoc(),
VectorizationReport()
- << "cannot prove pointers refer to independent arrays in memory. "
- "The loop requires "
- << NumRuntimePointerChecks
- << " runtime independence checks to vectorize the loop, but that "
- "would exceed the limit of "
- << VectorizerParams::RuntimeMemoryCheckThreshold << " checks");
+ << "cannot prove it is safe to reorder memory operations");
DEBUG(dbgs() << "LV: Too many memory checks needed.\n");
Failed = true;
}
OpenPOWER on IntegriCloud