1 ; RUN: opt -mtriple=aarch64 -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 < %s -S | FileCheck %s
3 ; The following tests contain loops for which SCEV cannot determine the backedge
4 ; taken count. This is because the backedge taken condition is produced by an
5 ; icmp with one of the sides being a loop varying non-AddRec expression.
6 ; However, there is a possibility to normalize this to an AddRec expression
7 ; using SCEV predicates. This allows us to compute a 'guarded' backedge count.
8 ; The Loop Vectorizer is able to version to loop in order to use this guarded
9 ; backedge count and vectorize more loops.
12 ; CHECK-LABEL: test_sge
13 ; CHECK-LABEL: vector.scevcheck
14 ; CHECK-LABEL: vector.body
15 define void @test_sge(ptr noalias %A,
17 ptr noalias %C, i32 %N) {
19 %cmp13 = icmp eq i32 %N, 0
20 br i1 %cmp13, label %for.end, label %for.body.preheader
26 %indvars.iv = phi i16 [ %indvars.next, %for.body ], [ 0, %for.body.preheader ]
27 %indvars.next = add i16 %indvars.iv, 1
28 %indvars.ext = zext i16 %indvars.iv to i32
30 %arrayidx = getelementptr inbounds i32, ptr %B, i32 %indvars.ext
31 %0 = load i32, ptr %arrayidx, align 4
32 %arrayidx3 = getelementptr inbounds i32, ptr %C, i32 %indvars.ext
33 %1 = load i32, ptr %arrayidx3, align 4
35 %mul4 = mul i32 %1, %0
37 %arrayidx7 = getelementptr inbounds i32, ptr %A, i32 %indvars.ext
38 store i32 %mul4, ptr %arrayidx7, align 4
40 %exitcond = icmp sge i32 %indvars.ext, %N
41 br i1 %exitcond, label %for.end.loopexit, label %for.body
50 ; CHECK-LABEL: test_uge
51 ; CHECK-LABEL: vector.scevcheck
52 ; CHECK-LABEL: vector.body
53 define void @test_uge(ptr noalias %A,
55 ptr noalias %C, i32 %N, i32 %Offset) {
57 %cmp13 = icmp eq i32 %N, 0
58 br i1 %cmp13, label %for.end, label %for.body.preheader
64 %indvars.iv = phi i16 [ %indvars.next, %for.body ], [ 0, %for.body.preheader ]
65 %indvars.next = add i16 %indvars.iv, 1
67 %indvars.ext = sext i16 %indvars.iv to i32
68 %indvars.access = add i32 %Offset, %indvars.ext
70 %arrayidx = getelementptr inbounds i32, ptr %B, i32 %indvars.access
71 %0 = load i32, ptr %arrayidx, align 4
72 %arrayidx3 = getelementptr inbounds i32, ptr %C, i32 %indvars.access
73 %1 = load i32, ptr %arrayidx3, align 4
75 %mul4 = add i32 %1, %0
77 %arrayidx7 = getelementptr inbounds i32, ptr %A, i32 %indvars.access
78 store i32 %mul4, ptr %arrayidx7, align 4
80 %exitcond = icmp uge i32 %indvars.ext, %N
81 br i1 %exitcond, label %for.end.loopexit, label %for.body
90 ; CHECK-LABEL: test_ule
91 ; CHECK-LABEL: vector.scevcheck
92 ; CHECK-LABEL: vector.body
93 define void @test_ule(ptr noalias %A,
95 ptr noalias %C, i32 %N,
98 %cmp13 = icmp eq i32 %N, 0
99 br i1 %cmp13, label %for.end, label %for.body.preheader
105 %indvars.iv = phi i16 [ %indvars.next, %for.body ], [ %M, %for.body.preheader ]
106 %indvars.next = sub i16 %indvars.iv, 1
107 %indvars.ext = zext i16 %indvars.iv to i32
109 %arrayidx = getelementptr inbounds i32, ptr %B, i32 %indvars.ext
110 %0 = load i32, ptr %arrayidx, align 4
111 %arrayidx3 = getelementptr inbounds i32, ptr %C, i32 %indvars.ext
112 %1 = load i32, ptr %arrayidx3, align 4
114 %mul4 = mul i32 %1, %0
116 %arrayidx7 = getelementptr inbounds i32, ptr %A, i32 %indvars.ext
117 store i32 %mul4, ptr %arrayidx7, align 4
119 %exitcond = icmp ule i32 %indvars.ext, %N
120 br i1 %exitcond, label %for.end.loopexit, label %for.body
129 ; CHECK-LABEL: test_sle
130 ; CHECK-LABEL: vector.scevcheck
131 ; CHECK-LABEL: vector.body
132 define void @test_sle(ptr noalias %A,
134 ptr noalias %C, i32 %N,
137 %cmp13 = icmp eq i32 %N, 0
138 br i1 %cmp13, label %for.end, label %for.body.preheader
144 %indvars.iv = phi i16 [ %indvars.next, %for.body ], [ %M, %for.body.preheader ]
145 %indvars.next = sub i16 %indvars.iv, 1
146 %indvars.ext = sext i16 %indvars.iv to i32
148 %arrayidx = getelementptr inbounds i32, ptr %B, i32 %indvars.ext
149 %0 = load i32, ptr %arrayidx, align 4
150 %arrayidx3 = getelementptr inbounds i32, ptr %C, i32 %indvars.ext
151 %1 = load i32, ptr %arrayidx3, align 4
153 %mul4 = mul i32 %1, %0
155 %arrayidx7 = getelementptr inbounds i32, ptr %A, i32 %indvars.ext
156 store i32 %mul4, ptr %arrayidx7, align 4
158 %exitcond = icmp sle i32 %indvars.ext, %N
159 br i1 %exitcond, label %for.end.loopexit, label %for.body