forked from OSchip/llvm-project
[LV] Mark first-order recurrences as allowed exits
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.) Fixes PR45526: AllowedExit set is used by prepareToFoldTailByMasking() to check whether the treatment for live-outs also holds when folding the tail, which is not (yet) the case for first-order recurrences. Differential Revision: https://reviews.llvm.org/D78210
This commit is contained in:
parent
7fde990694
commit
8e0c5f7200
|
@ -668,6 +668,7 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
|
|||
|
||||
if (RecurrenceDescriptor::isFirstOrderRecurrence(Phi, TheLoop,
|
||||
SinkAfter, DT)) {
|
||||
AllowedExit.insert(Phi);
|
||||
FirstOrderRecurrences.insert(Phi);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -121,6 +121,39 @@ for.body29:
|
|||
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-NEXT: entry:
|
||||
; CHECK-NEXT: br label %loop
|
||||
; CHECK-EMPTY:
|
||||
; CHECK-NEXT: loop:
|
||||
; CHECK-NEXT: %piv = phi i32 [ 0, %entry ], [ %pivPlus1, %loop ]
|
||||
; CHECK-NEXT: %for = phi i32 [ 5, %entry ], [ %pivPlus1, %loop ]
|
||||
; CHECK-NEXT: %pivPlus1 = add nuw nsw i32 %piv, 1
|
||||
; CHECK-NEXT: %cond = icmp ult i32 %piv, 510
|
||||
; CHECK-NEXT: br i1 %cond, label %loop, label %exit
|
||||
; CHECK-EMPTY:
|
||||
; CHECK-NEXT: exit:
|
||||
; CHECK-NEXT: %for.lcssa = phi i32 [ %for, %loop ]
|
||||
; CHECK-NEXT: ret i32 %for.lcssa
|
||||
;
|
||||
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}
|
||||
|
|
Loading…
Reference in New Issue