1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=slp-vectorizer -S | FileCheck %s --check-prefix=DEFAULT
3 ; RUN: opt < %s -slp-schedule-budget=0 -slp-min-tree-size=0 -slp-threshold=-30 -passes=slp-vectorizer -S | FileCheck %s --check-prefix=GATHER
4 ; RUN: opt < %s -slp-schedule-budget=0 -slp-threshold=-30 -passes=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>, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 1), 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_RDX:%.*]], [[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_RDX]] = add i32 [[TMP3]], [[P17]]
22 ; DEFAULT-NEXT: br label [[FOR_BODY]]
24 ; GATHER-LABEL: @PR28330(
26 ; GATHER-NEXT: [[TMP0:%.*]] = load <8 x i8>, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 1), 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_RDX:%.*]], [[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_RDX]] = 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: [[TMP0:%.*]] = load <8 x i8>, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 1), align 1
39 ; MAX-COST-NEXT: [[TMP1:%.*]] = icmp eq <8 x i8> [[TMP0]], zeroinitializer
40 ; MAX-COST-NEXT: br label [[FOR_BODY:%.*]]
42 ; MAX-COST-NEXT: [[P17:%.*]] = phi i32 [ [[OP_RDX:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
43 ; MAX-COST-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>
44 ; MAX-COST-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> [[TMP2]])
45 ; MAX-COST-NEXT: [[OP_RDX]] = add i32 [[TMP3]], [[P17]]
46 ; MAX-COST-NEXT: br label [[FOR_BODY]]
49 %p0 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 1), align 1
50 %p1 = icmp eq i8 %p0, 0
51 %p2 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 2), align 2
52 %p3 = icmp eq i8 %p2, 0
53 %p4 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 3), align 1
54 %p5 = icmp eq i8 %p4, 0
55 %p6 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 4), align 4
56 %p7 = icmp eq i8 %p6, 0
57 %p8 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 5), align 1
58 %p9 = icmp eq i8 %p8, 0
59 %p10 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 6), align 2
60 %p11 = icmp eq i8 %p10, 0
61 %p12 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 7), align 1
62 %p13 = icmp eq i8 %p12, 0
63 %p14 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 8), align 8
64 %p15 = icmp eq i8 %p14, 0
68 %p17 = phi i32 [ %p34, %for.body ], [ 0, %entry ]
69 %p19 = select i1 %p1, i32 -720, i32 -80
70 %p20 = add i32 %p17, %p19
71 %p21 = select i1 %p3, i32 -720, i32 -80
72 %p22 = add i32 %p20, %p21
73 %p23 = select i1 %p5, i32 -720, i32 -80
74 %p24 = add i32 %p22, %p23
75 %p25 = select i1 %p7, i32 -720, i32 -80
76 %p26 = add i32 %p24, %p25
77 %p27 = select i1 %p9, i32 -720, i32 -80
78 %p28 = add i32 %p26, %p27
79 %p29 = select i1 %p11, i32 -720, i32 -80
80 %p30 = add i32 %p28, %p29
81 %p31 = select i1 %p13, i32 -720, i32 -80
82 %p32 = add i32 %p30, %p31
83 %p33 = select i1 %p15, i32 -720, i32 -80
84 %p34 = add i32 %p32, %p33
88 define void @PR32038(i32 %n) {
89 ; DEFAULT-LABEL: @PR32038(
90 ; DEFAULT-NEXT: entry:
91 ; DEFAULT-NEXT: [[TMP0:%.*]] = load <8 x i8>, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 1), align 1
92 ; DEFAULT-NEXT: [[TMP1:%.*]] = icmp eq <8 x i8> [[TMP0]], zeroinitializer
93 ; DEFAULT-NEXT: br label [[FOR_BODY:%.*]]
95 ; DEFAULT-NEXT: [[P17:%.*]] = phi i32 [ [[OP_RDX:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
96 ; 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>
97 ; DEFAULT-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> [[TMP2]])
98 ; DEFAULT-NEXT: [[OP_RDX]] = add i32 [[TMP3]], -5
99 ; DEFAULT-NEXT: br label [[FOR_BODY]]
101 ; GATHER-LABEL: @PR32038(
102 ; GATHER-NEXT: entry:
103 ; GATHER-NEXT: [[TMP0:%.*]] = load <8 x i8>, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 1), align 1
104 ; GATHER-NEXT: [[TMP1:%.*]] = icmp eq <8 x i8> [[TMP0]], zeroinitializer
105 ; GATHER-NEXT: br label [[FOR_BODY:%.*]]
107 ; GATHER-NEXT: [[P17:%.*]] = phi i32 [ [[OP_RDX:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
108 ; 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>
109 ; GATHER-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> [[TMP2]])
110 ; GATHER-NEXT: [[OP_RDX]] = add i32 [[TMP3]], -5
111 ; GATHER-NEXT: br label [[FOR_BODY]]
113 ; MAX-COST-LABEL: @PR32038(
114 ; MAX-COST-NEXT: entry:
115 ; MAX-COST-NEXT: [[TMP0:%.*]] = load <8 x i8>, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 1), align 1
116 ; MAX-COST-NEXT: [[TMP1:%.*]] = icmp eq <8 x i8> [[TMP0]], zeroinitializer
117 ; MAX-COST-NEXT: br label [[FOR_BODY:%.*]]
118 ; MAX-COST: for.body:
119 ; MAX-COST-NEXT: [[P17:%.*]] = phi i32 [ [[OP_RDX:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
120 ; MAX-COST-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>
121 ; MAX-COST-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> [[TMP2]])
122 ; MAX-COST-NEXT: [[OP_RDX]] = add i32 [[TMP3]], -5
123 ; MAX-COST-NEXT: br label [[FOR_BODY]]
126 %p0 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 1), align 1
127 %p1 = icmp eq i8 %p0, 0
128 %p2 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 2), align 2
129 %p3 = icmp eq i8 %p2, 0
130 %p4 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 3), align 1
131 %p5 = icmp eq i8 %p4, 0
132 %p6 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 4), align 4
133 %p7 = icmp eq i8 %p6, 0
134 %p8 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 5), align 1
135 %p9 = icmp eq i8 %p8, 0
136 %p10 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 6), align 2
137 %p11 = icmp eq i8 %p10, 0
138 %p12 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 7), align 1
139 %p13 = icmp eq i8 %p12, 0
140 %p14 = load i8, ptr getelementptr inbounds ([80 x i8], ptr @a, i64 0, i64 8), align 8
141 %p15 = icmp eq i8 %p14, 0
145 %p17 = phi i32 [ %p34, %for.body ], [ 0, %entry ]
146 %p19 = select i1 %p1, i32 -720, i32 -80
147 %p20 = add i32 -5, %p19
148 %p21 = select i1 %p3, i32 -720, i32 -80
149 %p22 = add i32 %p20, %p21
150 %p23 = select i1 %p5, i32 -720, i32 -80
151 %p24 = add i32 %p22, %p23
152 %p25 = select i1 %p7, i32 -720, i32 -80
153 %p26 = add i32 %p24, %p25
154 %p27 = select i1 %p9, i32 -720, i32 -80
155 %p28 = add i32 %p26, %p27
156 %p29 = select i1 %p11, i32 -720, i32 -80
157 %p30 = add i32 %p28, %p29
158 %p31 = select i1 %p13, i32 -720, i32 -80
159 %p32 = add i32 %p30, %p31
160 %p33 = select i1 %p15, i32 -720, i32 -80
161 %p34 = add i32 %p32, %p33