summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize
diff options
context:
space:
mode:
authorSjoerd Meijer <sjoerd.meijer@arm.com>2019-09-24 08:03:34 +0000
committerSjoerd Meijer <sjoerd.meijer@arm.com>2019-09-24 08:03:34 +0000
commit0fcb3afb401c8c22383a95b515d4213659106d00 (patch)
tree11c3bdd3d269a239a57cfdafa0bb09eea438072c /llvm/lib/Transforms/Vectorize
parent54b78f3bb6789941fec2c5898828803592e97a11 (diff)
downloadbcm5719-llvm-0fcb3afb401c8c22383a95b515d4213659106d00.tar.gz
bcm5719-llvm-0fcb3afb401c8c22383a95b515d4213659106d00.zip
[LV] Forced vectorization with runtime checks and OptForSize
When vectorisation is forced with a pragma, we optimise for min size, and we need to emit runtime memory checks, then allow this code growth and don't run in an assert like we currently do. This is the result of D65197 and D66803, and was a use-case not really considered before. If this now happens, we emit an optimisation remark warning about the code-size expansion, which can be avoided by not forcing vectorisation or possibly source-code modifications. Differential Revision: https://reviews.llvm.org/D67764 llvm-svn: 372694
Diffstat (limited to 'llvm/lib/Transforms/Vectorize')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 9f583cacce2..287a0d498ec 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2730,8 +2730,19 @@ void InnerLoopVectorizer::emitMemRuntimeChecks(Loop *L, BasicBlock *Bypass) {
if (!MemRuntimeCheck)
return;
- assert(!BB->getParent()->hasOptSize() &&
- "Cannot emit memory checks when optimizing for size");
+ if (BB->getParent()->hasOptSize()) {
+ assert(Cost->Hints->getForce() == LoopVectorizeHints::FK_Enabled &&
+ "Cannot emit memory checks when optimizing for size, unless forced "
+ "to vectorize.");
+ ORE->emit([&]() {
+ return OptimizationRemarkAnalysis(DEBUG_TYPE, "VectorizationCodeSize",
+ L->getStartLoc(), L->getHeader())
+ << "Code-size may be reduced by not forcing "
+ "vectorization, or by source-code modifications "
+ "eliminating the need for runtime checks "
+ "(e.g., adding 'restrict').";
+ });
+ }
// Create a new block containing the memory check.
BB->setName("vector.memcheck");
OpenPOWER on IntegriCloud