[PATCH] Add #pragma vectorize enable/disable to LLVM
Arnold Schwaighofer
aschwaighofer at apple.com
Wed Dec 4 09:47:51 PST 2013
Reply-all did not work properly. So I’ll replicate my email send to llvm-commits.
> * We're now always adding the vectorizer pass with a flag if it has to check or not for pragmas
> * The default is to not check, since opt can be created with the pass via -loop-vectorize, which doesn't pass through AddOptimizationPasses()
> * Clean-up passes are being passed (and ran), even if the vectorizer doesn't vectorize anything, which increases slightly the compilation time (~2% on some tests I did here at O1), which is not ideal (ideas> welcome!)
> * The main issue is that I DO want to run them if there was a pragma enable, but this is rare, so would be better to have an alternative solution.
Ultimately, I think, we want to call the functionality that the vectorizer requires from those passes from the vectorizer only on the subset of BB’s modified by the vectorizer (instcombine as a library function ...).
It matters for -O1 and -Oz which did not pay this penalty before. In the short term, I don’t have a good answer here.
- if (!LateVectorize && LoopVectorize)
- MPM.add(createLoopVectorizePass(DisableUnrollLoops));
+ if (!LateVectorize)
+ MPM.add(createLoopVectorizePass(DisableUnrollLoops, LoopVectorize));
Let’s fix this whitespace error while we are here.
I think that “vectorizer.enable” flag should enable “aggressive” vectorization at -Os, i.e disable the size heuristic we use.
Something like:
bool OptForSize = F->getAttributes().hasAttribute(FnIndex, SzAttr) && Force != 1;
Thanks,
Arnold
================
Comment at: test/Transforms/LoopVectorize/metadata-enable.ll:174
@@ +173,3 @@
+!1 = metadata !{metadata !"llvm.vectorizer.enable", i1 1}
+!2 = metadata !{metadata !2, metadata !3}
+!3 = metadata !{metadata !"llvm.vectorizer.enable", i1 0}
----------------
Renato Golin wrote:
> Nadav Rotem wrote:
> > The metadata !2 is pointing to itself.
> Yes, that's the list of the metadata applied to a node, with itself as the first node as being itself. I'm not sure why this is like that, Arnold might know why.
“root” metadata does that.
http://llvm.org/docs/LangRef.html#llvm-loop
http://llvm-reviews.chandlerc.com/D2328
More information about the llvm-commits
mailing list