diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-01-12 15:27:15 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-01-12 15:27:15 +0000 |
commit | 7d65fe5cd55183dfed63a27f0f20e33e4b401e5b (patch) | |
tree | 7df426f87f630d41b316bbe1e3dcb47a3a93cf73 /llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp | |
parent | 1b4a240bfe2f548f29beec177fdc2792290872c5 (diff) | |
download | bcm5719-llvm-7d65fe5cd55183dfed63a27f0f20e33e4b401e5b.tar.gz bcm5719-llvm-7d65fe5cd55183dfed63a27f0f20e33e4b401e5b.zip |
[LoopVectorizer] give more advice in remark about failure to vectorize call
Something like this is requested by:
https://bugs.llvm.org/show_bug.cgi?id=40265
...and it seems like a common enough case that we should acknowledge it.
Differential Revision: https://reviews.llvm.org/D56551
llvm-svn: 351010
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp index ac989dd66f7..b44fe5a52a2 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp @@ -714,10 +714,30 @@ bool LoopVectorizationLegality::canVectorizeInstrs() { !isa<DbgInfoIntrinsic>(CI) && !(CI->getCalledFunction() && TLI && TLI->isFunctionVectorizable(CI->getCalledFunction()->getName()))) { - ORE->emit(createMissedAnalysis("CantVectorizeCall", CI) - << "call instruction cannot be vectorized"); + // If the call is a recognized math libary call, it is likely that + // we can vectorize it given loosened floating-point constraints. + LibFunc Func; + bool IsMathLibCall = + TLI && CI->getCalledFunction() && + CI->getType()->isFloatingPointTy() && + TLI->getLibFunc(CI->getCalledFunction()->getName(), Func) && + TLI->hasOptimizedCodeGen(Func); + + if (IsMathLibCall) { + // TODO: Ideally, we should not use clang-specific language here, + // but it's hard to provide meaningful yet generic advice. + // Also, should this be guarded by allowExtraAnalysis() and/or be part + // of the returned info from isFunctionVectorizable()? + ORE->emit(createMissedAnalysis("CantVectorizeLibcall", CI) + << "library call cannot be vectorized. " + "Try compiling with -fno-math-errno, -ffast-math, " + "or similar flags"); + } else { + ORE->emit(createMissedAnalysis("CantVectorizeCall", CI) + << "call instruction cannot be vectorized"); + } LLVM_DEBUG( - dbgs() << "LV: Found a non-intrinsic, non-libfunc callsite.\n"); + dbgs() << "LV: Found a non-intrinsic callsite.\n"); return false; } |