[polly] [Polly] Add vectorize metadata to loops identified as vectorizable by polly (PR #113994)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 30 05:33:56 PDT 2024
================
@@ -233,6 +238,26 @@ static bool generateCode(Scop &S, IslAstInfo &AI, LoopInfo &LI,
NodeBuilder.allocateNewArrays(StartExitBlocks);
Annotator.buildAliasScopes(S);
+ // The code below annotates the "llvm.loop.vectorize.enable" to false
+ // for the code flow taken when RTCs fail. Because we don't want the
+ // Loop Vectorizer to come in later and vectorize the original fall back
+ // loop when 'polly-annotate-metadata-vectorize' is passed.
+ if (PollyVectorizeMetadata) {
+ for (Loop *L : LI.getLoopsInPreorder()) {
+ if (S.contains(L)) {
+ Annotator.pushLoop(L, false);
+ SmallVector<BasicBlock *> LoopLatchBlocks;
+ L->getLoopLatches(LoopLatchBlocks);
+ for (BasicBlock *ControlBB : LoopLatchBlocks) {
+ BranchInst *Br = dyn_cast<BranchInst>(ControlBB->getTerminator());
+ if (Br)
+ Annotator.annotateLoopLatch(Br, L, false, true, false);
----------------
Meinersbur wrote:
Why not directly calling `addVectorizeMetadata` here? The ScopAnnotator was design with the assumption to be called on generated code only. Using it outside of it may result in unexpected situations.
https://github.com/llvm/llvm-project/pull/113994
More information about the llvm-commits
mailing list