Skip to content

Commit

Permalink
[LV] Add uses of recurrences in exit blocks in some tests.
Browse files Browse the repository at this point in the history
This preserves the spirit of the tests even if a follow-up changes only
generates exit values for recurrences if they are actually used.
  • Loading branch information
fhahn committed Apr 4, 2023
1 parent 09ab1f3 commit b5925a2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 26 deletions.
61 changes: 37 additions & 24 deletions llvm/test/Transforms/LoopVectorize/first-order-recurrence-chains.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; RUN: opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s | FileCheck %s

define void @test_chained_first_order_recurrences_1(ptr %ptr) {
define i16 @test_chained_first_order_recurrences_1(ptr %ptr) {
; CHECK-LABEL: @test_chained_first_order_recurrences_1
; CHECK: vector.body:
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
Expand Down Expand Up @@ -40,10 +40,11 @@ loop:
br i1 %exitcond.not, label %exit, label %loop

exit:
ret void
%res = add i16 %for.1, %for.2
ret i16 %res
}

define void @test_chained_first_order_recurrences_2(ptr %ptr) {
define i16 @test_chained_first_order_recurrences_2(ptr %ptr) {
; CHECK-LABEL: @test_chained_first_order_recurrences_2
; CHECK: vector.body:
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
Expand Down Expand Up @@ -83,10 +84,11 @@ loop:
br i1 %exitcond.not, label %exit, label %loop

exit:
ret void
%res = add i16 %for.1, %for.2
ret i16 %res
}

define void @test_chained_first_order_recurrences_3(ptr %ptr) {
define i16 @test_chained_first_order_recurrences_3(ptr %ptr) {
; CHECK-LABEL: @test_chained_first_order_recurrences_3
; CHECK: vector.body:
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
Expand Down Expand Up @@ -133,7 +135,9 @@ loop:
br i1 %exitcond.not, label %exit, label %loop

exit:
ret void
%res.1 = add i16 %for.1, %for.2
%res.2 = add i16 %res.1, %for.3
ret i16 %res.2
}

define void @test_cyclic_phis(ptr %ptr) {
Expand Down Expand Up @@ -197,7 +201,7 @@ exit:
ret void
}

define void @test_chained_first_order_recurrences_3_reordered_1(ptr %ptr) {
define i16 @test_chained_first_order_recurrences_3_reordered_1(ptr %ptr) {
; CHECK-LABEL: @test_chained_first_order_recurrences_3_reordered_1
; CHECK: vector.body:
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
Expand Down Expand Up @@ -244,10 +248,12 @@ loop:
br i1 %exitcond.not, label %exit, label %loop

exit:
ret void
%res.1 = add i16 %for.1, %for.2
%res.2 = add i16 %res.1, %for.3
ret i16 %res.2
}

define void @test_chained_first_order_recurrences_3_reordered_2(ptr %ptr) {
define i16 @test_chained_first_order_recurrences_3_reordered_2(ptr %ptr) {
; CHECK-LABEL: @test_chained_first_order_recurrences_3_reordered_2
; CHECK: vector.body:
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
Expand Down Expand Up @@ -294,10 +300,12 @@ loop:
br i1 %exitcond.not, label %exit, label %loop

exit:
ret void
%res.1 = add i16 %for.1, %for.2
%res.2 = add i16 %res.1, %for.3
ret i16 %res.2
}

define void @test_chained_first_order_recurrences_3_for2_no_other_uses(ptr %ptr) {
define i16 @test_chained_first_order_recurrences_3_for2_no_other_uses(ptr %ptr) {
; CHECK-LABEL: @test_chained_first_order_recurrences_3_for2_no_other_uses
; CHECK: vector.body:
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
Expand Down Expand Up @@ -344,10 +352,12 @@ loop:
br i1 %exitcond.not, label %exit, label %loop

exit:
ret void
%res.1 = add i16 %for.1, %for.2
%res.2 = add i16 %res.1, %for.3
ret i16 %res.2
}

define void @test_chained_first_order_recurrences_3_for1_for2_no_other_uses(ptr %ptr) {
define i16 @test_chained_first_order_recurrences_3_for1_for2_no_other_uses(ptr %ptr) {
; CHECK-LABEL: @test_chained_first_order_recurrences_3_for1_for2_no_other_uses
; CHECK: vector.body:
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
Expand Down Expand Up @@ -392,10 +402,12 @@ loop:
br i1 %exitcond.not, label %exit, label %loop

exit:
ret void
%res.1 = add i16 %for.1, %for.2
%res.2 = add i16 %res.1, %for.3
ret i16 %res.2
}

define void @test_chained_first_order_recurrence_sink_users_1(ptr %ptr) {
define double @test_chained_first_order_recurrence_sink_users_1(ptr %ptr) {
; CHECK-LABEL: @test_chained_first_order_recurrence_sink_users_1
; CHECK: vector.body:
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
Expand Down Expand Up @@ -438,7 +450,8 @@ loop:
br i1 %exitcond.not, label %exit, label %loop

exit:
ret void
%res = fadd double %for.1, %for.2
ret double %res
}

define void @test_first_order_recurrences_and_reduction(ptr %ptr) {
Expand Down Expand Up @@ -466,7 +479,7 @@ exit:
ret void
}

define void @test_first_order_recurrences_and_induction(ptr %ptr) {
define i64 @test_first_order_recurrences_and_induction(ptr %ptr) {
; CHECK-LABEL: @test_first_order_recurrences_and_induction(
; CHECK: vector.body:
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
Expand Down Expand Up @@ -502,12 +515,12 @@ loop:
br i1 %exitcond.not, label %exit, label %loop

exit:
ret void
ret i64 %for.1
}

; Same as @test_first_order_recurrences_and_induction but with order of phis
; flipped.
define void @test_first_order_recurrences_and_induction2(ptr %ptr) {
define i64 @test_first_order_recurrences_and_induction2(ptr %ptr) {
; CHECK-LABEL: @test_first_order_recurrences_and_induction2(
; CHECK: vector.body:
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
Expand Down Expand Up @@ -543,10 +556,10 @@ loop:
br i1 %exitcond.not, label %exit, label %loop

exit:
ret void
ret i64 %for.1
}

define void @test_first_order_recurrences_and_pointer_induction1(ptr %ptr) {
define ptr @test_first_order_recurrences_and_pointer_induction1(ptr %ptr) {
; CHECK-LABEL: @test_first_order_recurrences_and_pointer_induction1(
; CHECK: vector.ph:
; CHECK-NEXT: [[IND_END:%.*]] = getelementptr i8, ptr [[PTR:%.*]], i64 4000
Expand Down Expand Up @@ -586,12 +599,12 @@ loop:
br i1 %exitcond.not, label %exit, label %loop

exit:
ret void
ret ptr %for.1
}

; same as @test_first_order_recurrences_and_pointer_induction1 but with order
; of phis flipped.
define void @test_first_order_recurrences_and_pointer_induction2(ptr %ptr) {
define ptr @test_first_order_recurrences_and_pointer_induction2(ptr %ptr) {
; CHECK-LABEL: @test_first_order_recurrences_and_pointer_induction2(
; CHECK: vector.ph:
; CHECK-NEXT: [[IND_END:%.*]] = getelementptr i8, ptr [[PTR:%.*]], i64 4000
Expand Down Expand Up @@ -631,7 +644,7 @@ loop:
br i1 %exitcond.not, label %exit, label %loop

exit:
ret void
ret ptr %for.1
}

; Make sure LLVM doesn't generate wrong data in SinkAfter, and causes crash in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; b[i] = a[i] + a[i - 1]
; }
;
define void @recurrence_1(ptr nocapture readonly %a, ptr nocapture %b, i32 %n) {
define i32 @recurrence_1(ptr nocapture readonly %a, ptr nocapture %b, i32 %n) {
; CHECK-VF4UF1-LABEL: @recurrence_1
; CHECK-VF4UF1: for.preheader
; CHECK-VF4UF1: %[[SUB_1:.*]] = add i32 %n, -1
Expand Down Expand Up @@ -52,7 +52,7 @@ scalar.body:
br i1 %exitcond, label %for.exit, label %scalar.body, !llvm.loop !0

for.exit:
ret void
ret i32 %0
}

; int recurrence_2(int *a, int n) {
Expand Down

0 comments on commit b5925a2

Please sign in to comment.