1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -slp-vectorizer -S | FileCheck %s --check-prefix=DEFAULT
3 ; RUN: opt < %s -slp-schedule-budget=0 -slp-min-tree-size=0 -slp-threshold=-30 -slp-vectorizer -S | FileCheck %s --check-prefix=GATHER
4 ; RUN: opt < %s -slp-schedule-budget=0 -slp-threshold=-30 -slp-vectorizer -S | FileCheck %s --check-prefix=MAX-COST
6 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
7 target triple = "aarch64--linux-gnu"
9 @a = common global [80 x i8] zeroinitializer, align 16
11 define void @PR28330(i32 %n) {
12 ; DEFAULT-LABEL: @PR28330(
13 ; DEFAULT-NEXT: entry:
14 ; DEFAULT-NEXT: [[TMP0:%.*]] = load <8 x i8>, <8 x i8>* bitcast (i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1) to <8 x i8>*), align 1
15 ; DEFAULT-NEXT: [[TMP1:%.*]] = icmp eq <8 x i8> [[TMP0]], zeroinitializer
16 ; DEFAULT-NEXT: br label [[FOR_BODY:%.*]]
18 ; DEFAULT-NEXT: [[P17:%.*]] = phi i32 [ [[OP_EXTRA:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
19 ; DEFAULT-NEXT: [[TMP2:%.*]] = select <8 x i1> [[TMP1]], <8 x i32> <i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720>, <8 x i32> <i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80>
20 ; DEFAULT-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> [[TMP2]])
21 ; DEFAULT-NEXT: [[OP_EXTRA]] = add i32 [[TMP3]], [[P17]]
22 ; DEFAULT-NEXT: br label [[FOR_BODY]]
24 ; GATHER-LABEL: @PR28330(
26 ; GATHER-NEXT: [[TMP0:%.*]] = load <8 x i8>, <8 x i8>* bitcast (i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1) to <8 x i8>*), align 1
27 ; GATHER-NEXT: [[TMP1:%.*]] = icmp eq <8 x i8> [[TMP0]], zeroinitializer
28 ; GATHER-NEXT: br label [[FOR_BODY:%.*]]
30 ; GATHER-NEXT: [[P17:%.*]] = phi i32 [ [[OP_EXTRA:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
31 ; GATHER-NEXT: [[TMP2:%.*]] = select <8 x i1> [[TMP1]], <8 x i32> <i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720>, <8 x i32> <i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80>
32 ; GATHER-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> [[TMP2]])
33 ; GATHER-NEXT: [[OP_EXTRA]] = add i32 [[TMP3]], [[P17]]
34 ; GATHER-NEXT: br label [[FOR_BODY]]
36 ; MAX-COST-LABEL: @PR28330(
37 ; MAX-COST-NEXT: entry:
38 ; MAX-COST-NEXT: [[P0:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1), align 1
39 ; MAX-COST-NEXT: [[P1:%.*]] = icmp eq i8 [[P0]], 0
40 ; MAX-COST-NEXT: [[P2:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 2), align 2
41 ; MAX-COST-NEXT: [[P3:%.*]] = icmp eq i8 [[P2]], 0
42 ; MAX-COST-NEXT: [[P4:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 3), align 1
43 ; MAX-COST-NEXT: [[P5:%.*]] = icmp eq i8 [[P4]], 0
44 ; MAX-COST-NEXT: [[P6:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 4), align 4
45 ; MAX-COST-NEXT: [[P7:%.*]] = icmp eq i8 [[P6]], 0
46 ; MAX-COST-NEXT: [[P8:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 5), align 1
47 ; MAX-COST-NEXT: [[P9:%.*]] = icmp eq i8 [[P8]], 0
48 ; MAX-COST-NEXT: [[P10:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 6), align 2
49 ; MAX-COST-NEXT: [[P11:%.*]] = icmp eq i8 [[P10]], 0
50 ; MAX-COST-NEXT: [[P12:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 7), align 1
51 ; MAX-COST-NEXT: [[P13:%.*]] = icmp eq i8 [[P12]], 0
52 ; MAX-COST-NEXT: [[P14:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 8), align 8
53 ; MAX-COST-NEXT: [[P15:%.*]] = icmp eq i8 [[P14]], 0
54 ; MAX-COST-NEXT: br label [[FOR_BODY:%.*]]
56 ; MAX-COST-NEXT: [[P17:%.*]] = phi i32 [ [[P34:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
57 ; MAX-COST-NEXT: [[P19:%.*]] = select i1 [[P1]], i32 -720, i32 -80
58 ; MAX-COST-NEXT: [[P20:%.*]] = add i32 [[P17]], [[P19]]
59 ; MAX-COST-NEXT: [[P21:%.*]] = select i1 [[P3]], i32 -720, i32 -80
60 ; MAX-COST-NEXT: [[P22:%.*]] = add i32 [[P20]], [[P21]]
61 ; MAX-COST-NEXT: [[P23:%.*]] = select i1 [[P5]], i32 -720, i32 -80
62 ; MAX-COST-NEXT: [[P24:%.*]] = add i32 [[P22]], [[P23]]
63 ; MAX-COST-NEXT: [[P25:%.*]] = select i1 [[P7]], i32 -720, i32 -80
64 ; MAX-COST-NEXT: [[P26:%.*]] = add i32 [[P24]], [[P25]]
65 ; MAX-COST-NEXT: [[P27:%.*]] = select i1 [[P9]], i32 -720, i32 -80
66 ; MAX-COST-NEXT: [[P28:%.*]] = add i32 [[P26]], [[P27]]
67 ; MAX-COST-NEXT: [[P29:%.*]] = select i1 [[P11]], i32 -720, i32 -80
68 ; MAX-COST-NEXT: [[P30:%.*]] = add i32 [[P28]], [[P29]]
69 ; MAX-COST-NEXT: [[P31:%.*]] = select i1 [[P13]], i32 -720, i32 -80
70 ; MAX-COST-NEXT: [[P32:%.*]] = add i32 [[P30]], [[P31]]
71 ; MAX-COST-NEXT: [[P33:%.*]] = select i1 [[P15]], i32 -720, i32 -80
72 ; MAX-COST-NEXT: [[P34]] = add i32 [[P32]], [[P33]]
73 ; MAX-COST-NEXT: br label [[FOR_BODY]]
76 %p0 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1), align 1
77 %p1 = icmp eq i8 %p0, 0
78 %p2 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 2), align 2
79 %p3 = icmp eq i8 %p2, 0
80 %p4 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 3), align 1
81 %p5 = icmp eq i8 %p4, 0
82 %p6 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 4), align 4
83 %p7 = icmp eq i8 %p6, 0
84 %p8 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 5), align 1
85 %p9 = icmp eq i8 %p8, 0
86 %p10 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 6), align 2
87 %p11 = icmp eq i8 %p10, 0
88 %p12 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 7), align 1
89 %p13 = icmp eq i8 %p12, 0
90 %p14 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 8), align 8
91 %p15 = icmp eq i8 %p14, 0
95 %p17 = phi i32 [ %p34, %for.body ], [ 0, %entry ]
96 %p19 = select i1 %p1, i32 -720, i32 -80
97 %p20 = add i32 %p17, %p19
98 %p21 = select i1 %p3, i32 -720, i32 -80
99 %p22 = add i32 %p20, %p21
100 %p23 = select i1 %p5, i32 -720, i32 -80
101 %p24 = add i32 %p22, %p23
102 %p25 = select i1 %p7, i32 -720, i32 -80
103 %p26 = add i32 %p24, %p25
104 %p27 = select i1 %p9, i32 -720, i32 -80
105 %p28 = add i32 %p26, %p27
106 %p29 = select i1 %p11, i32 -720, i32 -80
107 %p30 = add i32 %p28, %p29
108 %p31 = select i1 %p13, i32 -720, i32 -80
109 %p32 = add i32 %p30, %p31
110 %p33 = select i1 %p15, i32 -720, i32 -80
111 %p34 = add i32 %p32, %p33
115 define void @PR32038(i32 %n) {
116 ; DEFAULT-LABEL: @PR32038(
117 ; DEFAULT-NEXT: entry:
118 ; DEFAULT-NEXT: [[TMP0:%.*]] = load <8 x i8>, <8 x i8>* bitcast (i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1) to <8 x i8>*), align 1
119 ; DEFAULT-NEXT: [[TMP1:%.*]] = icmp eq <8 x i8> [[TMP0]], zeroinitializer
120 ; DEFAULT-NEXT: br label [[FOR_BODY:%.*]]
122 ; DEFAULT-NEXT: [[P17:%.*]] = phi i32 [ [[OP_EXTRA:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
123 ; DEFAULT-NEXT: [[TMP2:%.*]] = select <8 x i1> [[TMP1]], <8 x i32> <i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720>, <8 x i32> <i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80>
124 ; DEFAULT-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> [[TMP2]])
125 ; DEFAULT-NEXT: [[OP_EXTRA]] = add i32 [[TMP3]], -5
126 ; DEFAULT-NEXT: br label [[FOR_BODY]]
128 ; GATHER-LABEL: @PR32038(
129 ; GATHER-NEXT: entry:
130 ; GATHER-NEXT: [[TMP0:%.*]] = load <8 x i8>, <8 x i8>* bitcast (i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1) to <8 x i8>*), align 1
131 ; GATHER-NEXT: [[TMP1:%.*]] = icmp eq <8 x i8> [[TMP0]], zeroinitializer
132 ; GATHER-NEXT: br label [[FOR_BODY:%.*]]
134 ; GATHER-NEXT: [[P17:%.*]] = phi i32 [ [[OP_EXTRA:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
135 ; GATHER-NEXT: [[TMP2:%.*]] = select <8 x i1> [[TMP1]], <8 x i32> <i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720, i32 -720>, <8 x i32> <i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80, i32 -80>
136 ; GATHER-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> [[TMP2]])
137 ; GATHER-NEXT: [[OP_EXTRA]] = add i32 [[TMP3]], -5
138 ; GATHER-NEXT: br label [[FOR_BODY]]
140 ; MAX-COST-LABEL: @PR32038(
141 ; MAX-COST-NEXT: entry:
142 ; MAX-COST-NEXT: [[TMP0:%.*]] = load <4 x i8>, <4 x i8>* bitcast (i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1) to <4 x i8>*), align 1
143 ; MAX-COST-NEXT: [[TMP1:%.*]] = icmp eq <4 x i8> [[TMP0]], zeroinitializer
144 ; MAX-COST-NEXT: [[P8:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 5), align 1
145 ; MAX-COST-NEXT: [[P9:%.*]] = icmp eq i8 [[P8]], 0
146 ; MAX-COST-NEXT: [[P10:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 6), align 2
147 ; MAX-COST-NEXT: [[P11:%.*]] = icmp eq i8 [[P10]], 0
148 ; MAX-COST-NEXT: [[P12:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 7), align 1
149 ; MAX-COST-NEXT: [[P13:%.*]] = icmp eq i8 [[P12]], 0
150 ; MAX-COST-NEXT: [[P14:%.*]] = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 8), align 8
151 ; MAX-COST-NEXT: [[P15:%.*]] = icmp eq i8 [[P14]], 0
152 ; MAX-COST-NEXT: br label [[FOR_BODY:%.*]]
153 ; MAX-COST: for.body:
154 ; MAX-COST-NEXT: [[P17:%.*]] = phi i32 [ [[P34:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
155 ; MAX-COST-NEXT: [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> <i32 -720, i32 -720, i32 -720, i32 -720>, <4 x i32> <i32 -80, i32 -80, i32 -80, i32 -80>
156 ; MAX-COST-NEXT: [[P27:%.*]] = select i1 [[P9]], i32 -720, i32 -80
157 ; MAX-COST-NEXT: [[P29:%.*]] = select i1 [[P11]], i32 -720, i32 -80
158 ; MAX-COST-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[TMP2]])
159 ; MAX-COST-NEXT: [[TMP4:%.*]] = add i32 [[TMP3]], [[P27]]
160 ; MAX-COST-NEXT: [[TMP5:%.*]] = add i32 [[TMP4]], [[P29]]
161 ; MAX-COST-NEXT: [[OP_EXTRA:%.*]] = add i32 [[TMP5]], -5
162 ; MAX-COST-NEXT: [[P31:%.*]] = select i1 [[P13]], i32 -720, i32 -80
163 ; MAX-COST-NEXT: [[P32:%.*]] = add i32 [[OP_EXTRA]], [[P31]]
164 ; MAX-COST-NEXT: [[P33:%.*]] = select i1 [[P15]], i32 -720, i32 -80
165 ; MAX-COST-NEXT: [[P34]] = add i32 [[P32]], [[P33]]
166 ; MAX-COST-NEXT: br label [[FOR_BODY]]
169 %p0 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1), align 1
170 %p1 = icmp eq i8 %p0, 0
171 %p2 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 2), align 2
172 %p3 = icmp eq i8 %p2, 0
173 %p4 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 3), align 1
174 %p5 = icmp eq i8 %p4, 0
175 %p6 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 4), align 4
176 %p7 = icmp eq i8 %p6, 0
177 %p8 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 5), align 1
178 %p9 = icmp eq i8 %p8, 0
179 %p10 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 6), align 2
180 %p11 = icmp eq i8 %p10, 0
181 %p12 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 7), align 1
182 %p13 = icmp eq i8 %p12, 0
183 %p14 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 8), align 8
184 %p15 = icmp eq i8 %p14, 0
188 %p17 = phi i32 [ %p34, %for.body ], [ 0, %entry ]
189 %p19 = select i1 %p1, i32 -720, i32 -80
190 %p20 = add i32 -5, %p19
191 %p21 = select i1 %p3, i32 -720, i32 -80
192 %p22 = add i32 %p20, %p21
193 %p23 = select i1 %p5, i32 -720, i32 -80
194 %p24 = add i32 %p22, %p23
195 %p25 = select i1 %p7, i32 -720, i32 -80
196 %p26 = add i32 %p24, %p25
197 %p27 = select i1 %p9, i32 -720, i32 -80
198 %p28 = add i32 %p26, %p27
199 %p29 = select i1 %p11, i32 -720, i32 -80
200 %p30 = add i32 %p28, %p29
201 %p31 = select i1 %p13, i32 -720, i32 -80
202 %p32 = add i32 %p30, %p31
203 %p33 = select i1 %p15, i32 -720, i32 -80
204 %p34 = add i32 %p32, %p33