1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=slp-vectorizer -S -o - -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 -slp-threshold=50 -slp-recursion-max-depth=6 < %s | FileCheck %s
4 define i32 @bar() local_unnamed_addr {
7 ; CHECK-NEXT: [[ADD78_1:%.*]] = add nsw i32 undef, undef
8 ; CHECK-NEXT: [[SUB86_1:%.*]] = sub nsw i32 undef, undef
9 ; CHECK-NEXT: [[ADD94_1:%.*]] = add nsw i32 undef, undef
10 ; CHECK-NEXT: [[SUB102_1:%.*]] = sub nsw i32 undef, undef
11 ; CHECK-NEXT: [[ADD78_2:%.*]] = add nsw i32 undef, undef
12 ; CHECK-NEXT: [[SUB102_3:%.*]] = sub nsw i32 undef, undef
13 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <16 x i32> <i32 undef, i32 undef, i32 undef, i32 undef, i32 poison, i32 poison, i32 poison, i32 poison, i32 undef, i32 poison, i32 poison, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>, i32 [[SUB102_1]], i32 4
14 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <16 x i32> [[TMP0]], i32 [[ADD94_1]], i32 5
15 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <16 x i32> [[TMP1]], i32 [[ADD78_1]], i32 6
16 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <16 x i32> [[TMP2]], i32 [[SUB86_1]], i32 7
17 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <16 x i32> [[TMP3]], i32 [[ADD78_2]], i32 9
18 ; CHECK-NEXT: [[TMP5:%.*]] = shufflevector <16 x i32> [[TMP4]], <16 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 9, i32 11, i32 12, i32 13, i32 14, i32 15>
19 ; CHECK-NEXT: [[TMP6:%.*]] = shufflevector <16 x i32> [[TMP4]], <16 x i32> poison, <16 x i32> <i32 poison, i32 poison, i32 poison, i32 poison, i32 7, i32 6, i32 5, i32 4, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
20 ; CHECK-NEXT: [[TMP7:%.*]] = insertelement <16 x i32> [[TMP6]], i32 [[SUB102_3]], i32 12
21 ; CHECK-NEXT: [[TMP8:%.*]] = shufflevector <16 x i32> [[TMP7]], <16 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 12>
22 ; CHECK-NEXT: [[TMP9:%.*]] = add nsw <16 x i32> [[TMP5]], [[TMP8]]
23 ; CHECK-NEXT: [[TMP10:%.*]] = sub nsw <16 x i32> [[TMP5]], [[TMP8]]
24 ; CHECK-NEXT: [[TMP11:%.*]] = shufflevector <16 x i32> [[TMP9]], <16 x i32> [[TMP10]], <16 x i32> <i32 0, i32 1, i32 18, i32 19, i32 4, i32 5, i32 22, i32 23, i32 8, i32 9, i32 26, i32 27, i32 12, i32 13, i32 30, i32 31>
25 ; CHECK-NEXT: [[TMP12:%.*]] = lshr <16 x i32> [[TMP11]], <i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15>
26 ; CHECK-NEXT: [[TMP13:%.*]] = and <16 x i32> [[TMP12]], <i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537>
27 ; CHECK-NEXT: [[TMP14:%.*]] = mul nuw <16 x i32> [[TMP13]], <i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535>
28 ; CHECK-NEXT: [[TMP15:%.*]] = add <16 x i32> [[TMP14]], [[TMP11]]
29 ; CHECK-NEXT: [[TMP16:%.*]] = xor <16 x i32> [[TMP15]], [[TMP14]]
30 ; CHECK-NEXT: [[TMP17:%.*]] = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[TMP16]])
31 ; CHECK-NEXT: [[SHR:%.*]] = lshr i32 [[TMP17]], 16
32 ; CHECK-NEXT: [[ADD119:%.*]] = add nuw nsw i32 undef, [[SHR]]
33 ; CHECK-NEXT: [[SHR120:%.*]] = lshr i32 [[ADD119]], 1
34 ; CHECK-NEXT: ret i32 [[SHR120]]
37 %add103 = add nsw i32 undef, undef
38 %sub104 = sub nsw i32 undef, undef
39 %add105 = add nsw i32 undef, undef
40 %sub106 = sub nsw i32 undef, undef
41 %shr.i = lshr i32 %add103, 15
42 %and.i = and i32 %shr.i, 65537
43 %mul.i = mul nuw i32 %and.i, 65535
44 %add.i = add i32 %mul.i, %add103
45 %xor.i = xor i32 %add.i, %mul.i
46 %shr.i64 = lshr i32 %add105, 15
47 %and.i65 = and i32 %shr.i64, 65537
48 %mul.i66 = mul nuw i32 %and.i65, 65535
49 %add.i67 = add i32 %mul.i66, %add105
50 %xor.i68 = xor i32 %add.i67, %mul.i66
51 %shr.i69 = lshr i32 %sub104, 15
52 %and.i70 = and i32 %shr.i69, 65537
53 %mul.i71 = mul nuw i32 %and.i70, 65535
54 %add.i72 = add i32 %mul.i71, %sub104
55 %xor.i73 = xor i32 %add.i72, %mul.i71
56 %shr.i74 = lshr i32 %sub106, 15
57 %and.i75 = and i32 %shr.i74, 65537
58 %mul.i76 = mul nuw i32 %and.i75, 65535
59 %add.i77 = add i32 %mul.i76, %sub106
60 %xor.i78 = xor i32 %add.i77, %mul.i76
61 %add110 = add i32 %xor.i68, %xor.i
62 %add112 = add i32 %add110, %xor.i73
63 %add113 = add i32 %add112, %xor.i78
64 %add78.1 = add nsw i32 undef, undef
65 %sub86.1 = sub nsw i32 undef, undef
66 %add94.1 = add nsw i32 undef, undef
67 %sub102.1 = sub nsw i32 undef, undef
68 %add103.1 = add nsw i32 %add94.1, %add78.1
69 %sub104.1 = sub nsw i32 %add78.1, %add94.1
70 %add105.1 = add nsw i32 %sub102.1, %sub86.1
71 %sub106.1 = sub nsw i32 %sub86.1, %sub102.1
72 %shr.i.1 = lshr i32 %add103.1, 15
73 %and.i.1 = and i32 %shr.i.1, 65537
74 %mul.i.1 = mul nuw i32 %and.i.1, 65535
75 %add.i.1 = add i32 %mul.i.1, %add103.1
76 %xor.i.1 = xor i32 %add.i.1, %mul.i.1
77 %shr.i64.1 = lshr i32 %add105.1, 15
78 %and.i65.1 = and i32 %shr.i64.1, 65537
79 %mul.i66.1 = mul nuw i32 %and.i65.1, 65535
80 %add.i67.1 = add i32 %mul.i66.1, %add105.1
81 %xor.i68.1 = xor i32 %add.i67.1, %mul.i66.1
82 %shr.i69.1 = lshr i32 %sub104.1, 15
83 %and.i70.1 = and i32 %shr.i69.1, 65537
84 %mul.i71.1 = mul nuw i32 %and.i70.1, 65535
85 %add.i72.1 = add i32 %mul.i71.1, %sub104.1
86 %xor.i73.1 = xor i32 %add.i72.1, %mul.i71.1
87 %shr.i74.1 = lshr i32 %sub106.1, 15
88 %and.i75.1 = and i32 %shr.i74.1, 65537
89 %mul.i76.1 = mul nuw i32 %and.i75.1, 65535
90 %add.i77.1 = add i32 %mul.i76.1, %sub106.1
91 %xor.i78.1 = xor i32 %add.i77.1, %mul.i76.1
92 %add108.1 = add i32 %xor.i68.1, %add113
93 %add110.1 = add i32 %add108.1, %xor.i.1
94 %add112.1 = add i32 %add110.1, %xor.i73.1
95 %add113.1 = add i32 %add112.1, %xor.i78.1
96 %add78.2 = add nsw i32 undef, undef
97 %add103.2 = add nsw i32 undef, %add78.2
98 %sub104.2 = sub nsw i32 %add78.2, undef
99 %add105.2 = add nsw i32 undef, undef
100 %sub106.2 = sub nsw i32 undef, undef
101 %shr.i.2 = lshr i32 %add103.2, 15
102 %and.i.2 = and i32 %shr.i.2, 65537
103 %mul.i.2 = mul nuw i32 %and.i.2, 65535
104 %add.i.2 = add i32 %mul.i.2, %add103.2
105 %xor.i.2 = xor i32 %add.i.2, %mul.i.2
106 %shr.i64.2 = lshr i32 %add105.2, 15
107 %and.i65.2 = and i32 %shr.i64.2, 65537
108 %mul.i66.2 = mul nuw i32 %and.i65.2, 65535
109 %add.i67.2 = add i32 %mul.i66.2, %add105.2
110 %xor.i68.2 = xor i32 %add.i67.2, %mul.i66.2
111 %shr.i69.2 = lshr i32 %sub104.2, 15
112 %and.i70.2 = and i32 %shr.i69.2, 65537
113 %mul.i71.2 = mul nuw i32 %and.i70.2, 65535
114 %add.i72.2 = add i32 %mul.i71.2, %sub104.2
115 %xor.i73.2 = xor i32 %add.i72.2, %mul.i71.2
116 %shr.i74.2 = lshr i32 %sub106.2, 15
117 %and.i75.2 = and i32 %shr.i74.2, 65537
118 %mul.i76.2 = mul nuw i32 %and.i75.2, 65535
119 %add.i77.2 = add i32 %mul.i76.2, %sub106.2
120 %xor.i78.2 = xor i32 %add.i77.2, %mul.i76.2
121 %add108.2 = add i32 %xor.i68.2, %add113.1
122 %add110.2 = add i32 %add108.2, %xor.i.2
123 %add112.2 = add i32 %add110.2, %xor.i73.2
124 %add113.2 = add i32 %add112.2, %xor.i78.2
125 %sub102.3 = sub nsw i32 undef, undef
126 %add103.3 = add nsw i32 undef, undef
127 %sub104.3 = sub nsw i32 undef, undef
128 %add105.3 = add nsw i32 %sub102.3, undef
129 %sub106.3 = sub nsw i32 undef, %sub102.3
130 %shr.i.3 = lshr i32 %add103.3, 15
131 %and.i.3 = and i32 %shr.i.3, 65537
132 %mul.i.3 = mul nuw i32 %and.i.3, 65535
133 %add.i.3 = add i32 %mul.i.3, %add103.3
134 %xor.i.3 = xor i32 %add.i.3, %mul.i.3
135 %shr.i64.3 = lshr i32 %add105.3, 15
136 %and.i65.3 = and i32 %shr.i64.3, 65537
137 %mul.i66.3 = mul nuw i32 %and.i65.3, 65535
138 %add.i67.3 = add i32 %mul.i66.3, %add105.3
139 %xor.i68.3 = xor i32 %add.i67.3, %mul.i66.3
140 %shr.i69.3 = lshr i32 %sub104.3, 15
141 %and.i70.3 = and i32 %shr.i69.3, 65537
142 %mul.i71.3 = mul nuw i32 %and.i70.3, 65535
143 %add.i72.3 = add i32 %mul.i71.3, %sub104.3
144 %xor.i73.3 = xor i32 %add.i72.3, %mul.i71.3
145 %shr.i74.3 = lshr i32 %sub106.3, 15
146 %and.i75.3 = and i32 %shr.i74.3, 65537
147 %mul.i76.3 = mul nuw i32 %and.i75.3, 65535
148 %add.i77.3 = add i32 %mul.i76.3, %sub106.3
149 %xor.i78.3 = xor i32 %add.i77.3, %mul.i76.3
150 %add108.3 = add i32 %xor.i68.3, %add113.2
151 %add110.3 = add i32 %add108.3, %xor.i.3
152 %add112.3 = add i32 %add110.3, %xor.i73.3
153 %add113.3 = add i32 %add112.3, %xor.i78.3
154 %shr = lshr i32 %add113.3, 16
155 %add119 = add nuw nsw i32 undef, %shr
156 %shr120 = lshr i32 %add119, 1