1 ; __arm_streaming function, no special flags. Should by default not vectorize.
2 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_enabled/ %s | opt -mattr="+sme" -passes=loop-vectorize,slp-vectorizer -S - | FileCheck %s --check-prefix=CHECK
3 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_enabled/ %s | opt -mattr="+sme,+sve" -passes=loop-vectorize,slp-vectorizer -S - | FileCheck %s --check-prefix=CHECK
4 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_body/ %s | opt -mattr="+sme" -passes=loop-vectorize,slp-vectorizer -S - | FileCheck %s --check-prefix=CHECK
5 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_body/ %s | opt -mattr="+sme,+sve" -passes=loop-vectorize,slp-vectorizer -S - | FileCheck %s --check-prefix=CHECK
7 ; __arm_streaming function, force use of scalable autovec. Should vectorize.
8 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_enabled/ %s | opt -mattr="+sme" -passes=loop-vectorize,slp-vectorizer -S -enable-scalable-autovec-in-streaming-mode - | FileCheck %s --check-prefix=CHECK-FORCE-SCALABLE
9 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_enabled/ %s | opt -mattr="+sme,+sve" -passes=loop-vectorize,slp-vectorizer -S -enable-scalable-autovec-in-streaming-mode - | FileCheck %s --check-prefix=CHECK-FORCE-SCALABLE
10 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_body/ %s | opt -mattr="+sme" -passes=loop-vectorize,slp-vectorizer -S -enable-scalable-autovec-in-streaming-mode - | FileCheck %s --check-prefix=CHECK-FORCE-SCALABLE
11 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_body/ %s | opt -mattr="+sme,+sve" -passes=loop-vectorize,slp-vectorizer -S -enable-scalable-autovec-in-streaming-mode - | FileCheck %s --check-prefix=CHECK-FORCE-SCALABLE
13 ; __arm_streaming function, force use of fixed-width autovec. Should vectorize.
14 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_enabled/ %s | opt -mattr="+sme" -passes=loop-vectorize,slp-vectorizer -S -enable-fixedwidth-autovec-in-streaming-mode - | FileCheck %s --check-prefix=CHECK-FORCE-FIXEDWIDTH
15 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_enabled/ %s | opt -mattr="+sme,+sve" -passes=loop-vectorize,slp-vectorizer -S -enable-fixedwidth-autovec-in-streaming-mode - | FileCheck %s --check-prefix=CHECK-FORCE-FIXEDWIDTH
16 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_body/ %s | opt -mattr="+sme" -passes=loop-vectorize,slp-vectorizer -S -enable-fixedwidth-autovec-in-streaming-mode - | FileCheck %s --check-prefix=CHECK-FORCE-FIXEDWIDTH
17 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_body/ %s | opt -mattr="+sme,+sve" -passes=loop-vectorize,slp-vectorizer -S -enable-fixedwidth-autovec-in-streaming-mode - | FileCheck %s --check-prefix=CHECK-FORCE-FIXEDWIDTH
19 ; __arm_streaming_compatible function, no special flags. Should by default not vectorize.
20 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_compatible/ %s | opt -mattr="+sme" -passes=loop-vectorize,slp-vectorizer -S - | FileCheck %s --check-prefix=CHECK
21 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_compatible/ %s | opt -mattr="+sme,+sve" -passes=loop-vectorize,slp-vectorizer -S - | FileCheck %s --check-prefix=CHECK
23 ; __arm_streaming_compatible function, force use of scalable autovec. Can only vectorize if +sve is available.
24 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_compatible/ %s | opt -mattr="+sme" -passes=loop-vectorize,slp-vectorizer -S -enable-scalable-autovec-in-streaming-mode - | FileCheck %s
25 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_compatible/ %s | opt -mattr="+sme,+sve" -passes=loop-vectorize,slp-vectorizer -S -enable-scalable-autovec-in-streaming-mode - | FileCheck %s --check-prefix=CHECK-FORCE-SCALABLE
27 ; __arm_streaming_compatible function, force use of fixed-width autovec. Can only vectorize if +sve is available.
28 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_compatible/ %s | opt -mattr="+sme" -passes=loop-vectorize,slp-vectorizer -S -enable-fixedwidth-autovec-in-streaming-mode - | FileCheck %s
29 ; RUN: sed -e s/REPLACE_PSTATE_MACRO/aarch64_pstate_sm_compatible/ %s | opt -mattr="+sme,+sve" -passes=loop-vectorize,slp-vectorizer -S -enable-fixedwidth-autovec-in-streaming-mode - | FileCheck %s --check-prefix=CHECK-FORCE-FIXEDWIDTH
31 target triple = "aarch64-unknown-linux-gnu"
33 attributes #0 = { vscale_range(1,16) "REPLACE_PSTATE_MACRO" }
35 define void @test_fixedwidth_loopvec(ptr noalias %dst, ptr readonly %src, i32 %N) #0 {
36 ; CHECK-LABEL: @test_fixedwidth_loopvec
37 ; CHECK-NOT: <{{[1-9]+}} x i32>
38 ; CHECK-FORCE-FIXEDWIDTH-LABEL: @test_fixedwidth_loopvec
39 ; CHECK-FORCE-FIXEDWIDTH: <{{[1-9]+}} x i32>
41 %cmp6 = icmp sgt i32 %N, 0
42 br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup
44 for.body.preheader: ; preds = %entry
45 %wide.trip.count = zext i32 %N to i64
48 for.cond.cleanup: ; preds = %for.body, %entry
51 for.body: ; preds = %for.body.preheader, %for.body
52 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
53 %arrayidx = getelementptr inbounds i32, ptr %src, i64 %indvars.iv
54 %0 = load i32, ptr %arrayidx, align 4
55 %add = add nsw i32 %0, 42
56 %arrayidx2 = getelementptr inbounds i32, ptr %dst, i64 %indvars.iv
57 store i32 %add, ptr %arrayidx2, align 4
58 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
59 %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
60 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body, !llvm.loop !0
63 !0 = distinct !{!0, !1, !2, !3}
64 !1 = !{!"llvm.loop.mustprogress"}
65 !2 = !{!"llvm.loop.interleave.count", i32 1}
66 !3 = !{!"llvm.loop.vectorize.scalable.enable", i1 false}
68 define void @test_scalable_loopvec(ptr noalias %dst, ptr readonly %src, i32 %N) #0 {
69 ; CHECK-LABEL: @test_scalable_loopvec
70 ; CHECK-NOT: <vscale x {{[1-9]+}} x i32>
71 ; CHECK-FORCE-SCALABLE-LABEL: @test_fixedwidth_loopvec
72 ; CHECK-FORCE-SCALABLE-LABEL: <vscale x {{[1-9]+}} x i32>
74 %cmp6 = icmp sgt i32 %N, 0
75 br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup
77 for.body.preheader: ; preds = %entry
78 %wide.trip.count = zext i32 %N to i64
81 for.cond.cleanup: ; preds = %for.body, %entry
84 for.body: ; preds = %for.body.preheader, %for.body
85 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
86 %arrayidx = getelementptr inbounds i32, ptr %src, i64 %indvars.iv
87 %0 = load i32, ptr %arrayidx, align 4
88 %add = add nsw i32 %0, 42
89 %arrayidx2 = getelementptr inbounds i32, ptr %dst, i64 %indvars.iv
90 store i32 %add, ptr %arrayidx2, align 4
91 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
92 %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
93 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body, !llvm.loop !4
96 !4 = distinct !{!4, !5, !6, !7}
97 !5 = !{!"llvm.loop.mustprogress"}
98 !6 = !{!"llvm.loop.interleave.count", i32 1}
99 !7 = !{!"llvm.loop.vectorize.scalable.enable", i1 true}
101 define void @test_slp(ptr noalias %dst, ptr readonly %src, i32 %N) #0 {
102 ; CHECK-LABEL: @test_slp
103 ; CHECK-NOT: <{{[1-9]+}} x i32>
104 ; CHECK-FORCE-FIXEDWIDTH-LABEL: @test_slp
105 ; CHECK-FORCE-FIXEDWIDTH: <{{[1-9]+}} x i32>
107 %cmp6 = icmp sgt i32 %N, 0
108 br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup
110 for.body.preheader: ; preds = %entry
111 %wide.trip.count = zext i32 %N to i64
114 for.cond.cleanup: ; preds = %for.body, %entry
117 for.body: ; preds = %for.body.preheader, %for.body
118 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
119 %arrayidx = getelementptr inbounds i32, ptr %src, i64 %indvars.iv
120 %0 = load i32, ptr %arrayidx, align 4
121 %add = add nsw i32 %0, 42
122 %arrayidx2 = getelementptr inbounds i32, ptr %dst, i64 %indvars.iv
123 store i32 %add, ptr %arrayidx2, align 4
124 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
125 %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
126 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body, !llvm.loop !8
129 !8 = distinct !{!8, !9, !10, !11}
130 !9 = !{!"llvm.loop.mustprogress"}
131 !10 = !{!"llvm.loop.interleave.count", i32 4}
132 !11 = !{!"llvm.loop.vectorize.width", i32 1}