1; RUN: opt < %s -slp-vectorizer -S | FileCheck %s --check-prefix=DEFAULT
2; RUN: opt < %s -slp-schedule-budget=0 -slp-min-tree-size=0 -slp-threshold=-30 -slp-vectorizer -S | FileCheck %s --check-prefix=GATHER
3; RUN: opt < %s -slp-schedule-budget=0 -slp-threshold=-30 -slp-vectorizer -S | FileCheck %s --check-prefix=MAX-COST
4
5target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
6target triple = "aarch64--linux-gnu"
7
8@a = common global [80 x i8] zeroinitializer, align 16
9
10; DEFAULT-LABEL: @PR28330(
11; DEFAULT: %tmp17 = phi i32 [ %tmp34, %for.body ], [ 0, %entry ]
12; DEFAULT: %[[S0:.+]] = select <8 x i1> %1, <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>
13; DEFAULT: %[[R0:.+]] = shufflevector <8 x i32> %[[S0]], <8 x i32> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7, i32 undef, i32 undef, i32 undef, i32 undef>
14; DEFAULT: %[[R1:.+]] = add <8 x i32> %[[S0]], %[[R0]]
15; DEFAULT: %[[R2:.+]] = shufflevector <8 x i32> %[[R1]], <8 x i32> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
16; DEFAULT: %[[R3:.+]] = add <8 x i32> %[[R1]], %[[R2]]
17; DEFAULT: %[[R4:.+]] = shufflevector <8 x i32> %[[R3]], <8 x i32> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
18; DEFAULT: %[[R5:.+]] = add <8 x i32> %[[R3]], %[[R4]]
19; DEFAULT: %[[R6:.+]] = extractelement <8 x i32> %[[R5]], i32 0
20; DEFAULT: %tmp34 = add i32 %[[R6]], %tmp17
21;
22; GATHER-LABEL: @PR28330(
23; GATHER: %tmp17 = phi i32 [ %tmp34, %for.body ], [ 0, %entry ]
24; GATHER: %tmp19 = select i1 %tmp1, i32 -720, i32 -80
25; GATHER: %tmp21 = select i1 %tmp3, i32 -720, i32 -80
26; GATHER: %tmp23 = select i1 %tmp5, i32 -720, i32 -80
27; GATHER: %tmp25 = select i1 %tmp7, i32 -720, i32 -80
28; GATHER: %tmp27 = select i1 %tmp9, i32 -720, i32 -80
29; GATHER: %tmp29 = select i1 %tmp11, i32 -720, i32 -80
30; GATHER: %tmp31 = select i1 %tmp13, i32 -720, i32 -80
31; GATHER: %tmp33 = select i1 %tmp15, i32 -720, i32 -80
32; GATHER: %[[I0:.+]] = insertelement <8 x i32> undef, i32 %tmp19, i32 0
33; GATHER: %[[I1:.+]] = insertelement <8 x i32> %[[I0]], i32 %tmp21, i32 1
34; GATHER: %[[I2:.+]] = insertelement <8 x i32> %[[I1]], i32 %tmp23, i32 2
35; GATHER: %[[I3:.+]] = insertelement <8 x i32> %[[I2]], i32 %tmp25, i32 3
36; GATHER: %[[I4:.+]] = insertelement <8 x i32> %[[I3]], i32 %tmp27, i32 4
37; GATHER: %[[I5:.+]] = insertelement <8 x i32> %[[I4]], i32 %tmp29, i32 5
38; GATHER: %[[I6:.+]] = insertelement <8 x i32> %[[I5]], i32 %tmp31, i32 6
39; GATHER: %[[I7:.+]] = insertelement <8 x i32> %[[I6]], i32 %tmp33, i32 7
40; GATHER: %[[R0:.+]] = shufflevector <8 x i32> %[[I7]], <8 x i32> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7, i32 undef, i32 undef, i32 undef, i32 undef>
41; GATHER: %[[R1:.+]] = add <8 x i32> %[[I7]], %[[R0]]
42; GATHER: %[[R2:.+]] = shufflevector <8 x i32> %[[R1]], <8 x i32> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
43; GATHER: %[[R3:.+]] = add <8 x i32> %[[R1]], %[[R2]]
44; GATHER: %[[R4:.+]] = shufflevector <8 x i32> %[[R3]], <8 x i32> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
45; GATHER: %[[R5:.+]] = add <8 x i32> %[[R3]], %[[R4]]
46; GATHER: %[[R6:.+]] = extractelement <8 x i32> %[[R5]], i32 0
47; GATHER: %tmp34 = add i32 %[[R6]], %tmp17
48;
49; MAX-COST-LABEL: @PR28330(
50; MAX-COST-NOT: shufflevector
51
52define void @PR28330(i32 %n) {
53entry:
54  %tmp0 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 1), align 1
55  %tmp1 = icmp eq i8 %tmp0, 0
56  %tmp2 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 2), align 2
57  %tmp3 = icmp eq i8 %tmp2, 0
58  %tmp4 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 3), align 1
59  %tmp5 = icmp eq i8 %tmp4, 0
60  %tmp6 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 4), align 4
61  %tmp7 = icmp eq i8 %tmp6, 0
62  %tmp8 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 5), align 1
63  %tmp9 = icmp eq i8 %tmp8, 0
64  %tmp10 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 6), align 2
65  %tmp11 = icmp eq i8 %tmp10, 0
66  %tmp12 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 7), align 1
67  %tmp13 = icmp eq i8 %tmp12, 0
68  %tmp14 = load i8, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @a, i64 0, i64 8), align 8
69  %tmp15 = icmp eq i8 %tmp14, 0
70  br label %for.body
71
72for.body:
73  %tmp17 = phi i32 [ %tmp34, %for.body ], [ 0, %entry ]
74  %tmp19 = select i1 %tmp1, i32 -720, i32 -80
75  %tmp20 = add i32 %tmp17, %tmp19
76  %tmp21 = select i1 %tmp3, i32 -720, i32 -80
77  %tmp22 = add i32 %tmp20, %tmp21
78  %tmp23 = select i1 %tmp5, i32 -720, i32 -80
79  %tmp24 = add i32 %tmp22, %tmp23
80  %tmp25 = select i1 %tmp7, i32 -720, i32 -80
81  %tmp26 = add i32 %tmp24, %tmp25
82  %tmp27 = select i1 %tmp9, i32 -720, i32 -80
83  %tmp28 = add i32 %tmp26, %tmp27
84  %tmp29 = select i1 %tmp11, i32 -720, i32 -80
85  %tmp30 = add i32 %tmp28, %tmp29
86  %tmp31 = select i1 %tmp13, i32 -720, i32 -80
87  %tmp32 = add i32 %tmp30, %tmp31
88  %tmp33 = select i1 %tmp15, i32 -720, i32 -80
89  %tmp34 = add i32 %tmp32, %tmp33
90  br label %for.body
91}
92