[PATCH] D78210: [LV] Mark first-order recurrences as allowed exit
Ayal Zaks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 15 08:12:11 PDT 2020
Ayal created this revision.
Ayal added reviewers: fhahn, gilr, skatkov.
Herald added subscribers: llvm-commits, rkruppe, hiraditya.
Herald added a project: LLVM.
First-order recurrences require special treatment when they are live-out; such treatment is provided by fixFirstOrderRecurrence(), so they should be included in AllowedExit set. (Should probably have been included originally in D16197 <https://reviews.llvm.org/D16197>.)
Fixes PR45526: AllowedExit set is used by prepareToFoldTailByMasking() to check whether the treatment for live-outs also holds when folding the tail, which is currently the case for reductions but not (yet) for first-order recurrences or other values.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78210
Files:
llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
llvm/test/Transforms/LoopVectorize/optsize.ll
Index: llvm/test/Transforms/LoopVectorize/optsize.ll
===================================================================
--- llvm/test/Transforms/LoopVectorize/optsize.ll
+++ llvm/test/Transforms/LoopVectorize/optsize.ll
@@ -121,6 +121,27 @@
br i1 %cmp26, label %for.body29, label %for.cond.cleanup28
}
+; PR45526: don't vectorize with fold-tail if first-order-recurrence is live-out.
+;
+define i32 @pr45526() optsize {
+;
+; CHECK-LABEL: @pr45526
+; CHECK-NOT: <
+;
+entry:
+ br label %loop
+
+loop:
+ %piv = phi i32 [ 0, %entry ], [ %pivPlus1, %loop ]
+ %for = phi i32 [ 5, %entry ], [ %pivPlus1, %loop ]
+ %pivPlus1 = add nuw nsw i32 %piv, 1
+ %cond = icmp ult i32 %piv, 510
+ br i1 %cond, label %loop, label %exit
+
+exit:
+ ret i32 %for
+}
+
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"ProfileSummary", !1}
!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
Index: llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -668,6 +668,7 @@
if (RecurrenceDescriptor::isFirstOrderRecurrence(Phi, TheLoop,
SinkAfter, DT)) {
+ AllowedExit.insert(Phi);
FirstOrderRecurrences.insert(Phi);
continue;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78210.257720.patch
Type: text/x-patch
Size: 1414 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200415/c331541f/attachment-0001.bin>
More information about the llvm-commits
mailing list