summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorTyler Nowicki <tyler.nowicki@gmail.com>2015-08-10 23:01:55 +0000
committerTyler Nowicki <tyler.nowicki@gmail.com>2015-08-10 23:01:55 +0000
commit652b0dabe64577f42fa8af8349687be7f529d183 (patch)
tree26f069a6a420b1b516d2f2cfc668e312ab65eb4e /llvm/lib
parentc0120a3000f32c7721e5bed9d5441724b8b44e01 (diff)
downloadbcm5719-llvm-652b0dabe64577f42fa8af8349687be7f529d183.tar.gz
bcm5719-llvm-652b0dabe64577f42fa8af8349687be7f529d183.zip
Extend late diagnostics to include late test for runtime pointer checks.
This patch moves checking the threshold of runtime pointer checks to the vectorization requirements (late diagnostics) and emits a diagnostic that infroms the user the loop would be vectorized if not for exceeding the pointer-check threshold. Clang will also append the options that can be used to allow vectorization. llvm-svn: 244523
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/DiagnosticInfo.cpp9
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp43
2 files changed, 38 insertions, 14 deletions
diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp
index 07c6714e913..3acef9048cc 100644
--- a/llvm/lib/IR/DiagnosticInfo.cpp
+++ b/llvm/lib/IR/DiagnosticInfo.cpp
@@ -205,6 +205,15 @@ void llvm::emitOptimizationRemarkAnalysisFPCommute(LLVMContext &Ctx,
DLoc, Msg));
}
+void llvm::emitOptimizationRemarkAnalysisAliasing(LLVMContext &Ctx,
+ const char *PassName,
+ const Function &Fn,
+ const DebugLoc &DLoc,
+ const Twine &Msg) {
+ Ctx.diagnose(DiagnosticInfoOptimizationRemarkAnalysisAliasing(PassName, Fn,
+ DLoc, Msg));
+}
+
bool DiagnosticInfoOptimizationFailure::isEnabled() const {
// Only print warnings.
return getSeverity() == DS_Warning;
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 9cfd5feca2d..37d6add20a2 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1435,7 +1435,8 @@ static void emitMissedWarning(Function *F, Loop *L,
/// followed by a non-expert user.
class LoopVectorizationRequirements {
public:
- LoopVectorizationRequirements() : UnsafeAlgebraInst(nullptr) {}
+ LoopVectorizationRequirements()
+ : NumRuntimePointerChecks(0), UnsafeAlgebraInst(nullptr) {}
void addUnsafeAlgebraInst(Instruction *I) {
// First unsafe algebra instruction.
@@ -1443,7 +1444,11 @@ public:
UnsafeAlgebraInst = I;
}
- bool doesNotMeet(Function *F, const LoopVectorizeHints &Hints) {
+ void addRuntimePointerChecks(unsigned Num) { NumRuntimePointerChecks = Num; }
+
+ bool doesNotMeet(Function *F, Loop *L, const LoopVectorizeHints &Hints) {
+ bool failed = false;
+
if (UnsafeAlgebraInst &&
Hints.getForce() == LoopVectorizeHints::FK_Undefined &&
Hints.getWidth() == 0) {
@@ -1453,12 +1458,29 @@ public:
"order of operations, however IEEE 754 "
"floating-point operations are not "
"commutative");
- return true;
+ failed = true;
}
- return false;
+
+ if (NumRuntimePointerChecks >
+ VectorizerParams::RuntimeMemoryCheckThreshold) {
+ emitOptimizationRemarkAnalysisAliasing(
+ F->getContext(), DEBUG_TYPE, *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");
+ DEBUG(dbgs() << "LV: Too many memory checks needed.\n");
+ failed = true;
+ }
+
+ return failed;
}
private:
+ unsigned NumRuntimePointerChecks;
Instruction *UnsafeAlgebraInst;
};
@@ -1714,7 +1736,7 @@ struct LoopVectorize : public FunctionPass {
std::string VecDiagMsg, IntDiagMsg;
bool VectorizeLoop = true, InterleaveLoop = true;
- if (Requirements.doesNotMeet(F, Hints)) {
+ if (Requirements.doesNotMeet(F, L, Hints)) {
DEBUG(dbgs() << "LV: Not vectorizing: loop did not meet vectorization "
"requirements.\n");
emitMissedWarning(F, L, Hints);
@@ -4297,15 +4319,8 @@ bool LoopVectorizationLegality::canVectorizeMemory() {
return false;
}
- if (LAI->getNumRuntimePointerChecks() >
- VectorizerParams::RuntimeMemoryCheckThreshold) {
- emitAnalysis(VectorizationReport()
- << LAI->getNumRuntimePointerChecks() << " exceeds limit of "
- << VectorizerParams::RuntimeMemoryCheckThreshold
- << " dependent memory operations checked at runtime");
- DEBUG(dbgs() << "LV: Too many memory checks needed.\n");
- return false;
- }
+ Requirements->addRuntimePointerChecks(LAI->getNumRuntimePointerChecks());
+
return true;
}
OpenPOWER on IntegriCloud