[llvm] b5925a2 - [LV] Add uses of recurrences in exit blocks in some tests.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 4 13:19:44 PDT 2023


Author: Florian Hahn
Date: 2023-04-04T21:19:29+01:00
New Revision: b5925a22c9fb78a87ae7f45066abadef81117e74

URL: https://github.com/llvm/llvm-project/commit/b5925a22c9fb78a87ae7f45066abadef81117e74
DIFF: https://github.com/llvm/llvm-project/commit/b5925a22c9fb78a87ae7f45066abadef81117e74.diff

LOG: [LV] Add uses of recurrences in exit blocks in some tests.

This preserves the spirit of the tests even if a follow-up changes only
generates exit values for recurrences if they are actually used.

Added: 
    

Modified: 
    llvm/test/Transforms/LoopVectorize/first-order-recurrence-chains.ll
    llvm/test/Transforms/LoopVectorize/scalable-first-order-recurrence.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/LoopVectorize/first-order-recurrence-chains.ll b/llvm/test/Transforms/LoopVectorize/first-order-recurrence-chains.ll
index 85972114f8b3..dc7fc9dfe0dc 100644
--- a/llvm/test/Transforms/LoopVectorize/first-order-recurrence-chains.ll
+++ b/llvm/test/Transforms/LoopVectorize/first-order-recurrence-chains.ll
@@ -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 ]
@@ -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 ]
@@ -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 ]
@@ -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) {
@@ -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 ]
@@ -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 ]
@@ -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 ]
@@ -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 ]
@@ -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 ]
@@ -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) {
@@ -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 ]
@@ -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 ]
@@ -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
@@ -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
@@ -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

diff  --git a/llvm/test/Transforms/LoopVectorize/scalable-first-order-recurrence.ll b/llvm/test/Transforms/LoopVectorize/scalable-first-order-recurrence.ll
index 9b843868f6e6..c5bbda6ba8ec 100644
--- a/llvm/test/Transforms/LoopVectorize/scalable-first-order-recurrence.ll
+++ b/llvm/test/Transforms/LoopVectorize/scalable-first-order-recurrence.ll
@@ -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
@@ -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) {


        


More information about the llvm-commits mailing list