1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -slp-vectorizer -S -o - -mtriple=x86_64-unknown-linux -mcpu=bdver2 -instcombine | FileCheck %s
4 define <2 x i8> @g(<2 x i8> %x, <2 x i8> %y) {
6 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]], <2 x i32> <i32 0, i32 3>
7 ; CHECK-NEXT: [[TMP2:%.*]] = mul <2 x i8> [[TMP1]], [[TMP1]]
8 ; CHECK-NEXT: ret <2 x i8> [[TMP2]]
10 %x0 = extractelement <2 x i8> %x, i32 0
11 %y1 = extractelement <2 x i8> %y, i32 1
12 %x0x0 = mul i8 %x0, %x0
13 %y1y1 = mul i8 %y1, %y1
14 %ins1 = insertelement <2 x i8> poison, i8 %x0x0, i32 0
15 %ins2 = insertelement <2 x i8> %ins1, i8 %y1y1, i32 1
19 define <4 x i8> @h(<4 x i8> %x, <4 x i8> %y) {
21 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i32> <i32 0, i32 3, i32 5, i32 6>
22 ; CHECK-NEXT: [[TMP2:%.*]] = mul <4 x i8> [[TMP1]], [[TMP1]]
23 ; CHECK-NEXT: ret <4 x i8> [[TMP2]]
25 %x0 = extractelement <4 x i8> %x, i32 0
26 %x3 = extractelement <4 x i8> %x, i32 3
27 %y1 = extractelement <4 x i8> %y, i32 1
28 %y2 = extractelement <4 x i8> %y, i32 2
29 %x0x0 = mul i8 %x0, %x0
30 %x3x3 = mul i8 %x3, %x3
31 %y1y1 = mul i8 %y1, %y1
32 %y2y2 = mul i8 %y2, %y2
33 %ins1 = insertelement <4 x i8> poison, i8 %x0x0, i32 0
34 %ins2 = insertelement <4 x i8> %ins1, i8 %x3x3, i32 1
35 %ins3 = insertelement <4 x i8> %ins2, i8 %y1y1, i32 2
36 %ins4 = insertelement <4 x i8> %ins3, i8 %y2y2, i32 3
40 define <4 x i8> @h_undef(<4 x i8> %x, <4 x i8> %y) {
41 ; CHECK-LABEL: @h_undef(
42 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i32> <i32 undef, i32 3, i32 5, i32 6>
43 ; CHECK-NEXT: [[TMP2:%.*]] = mul <4 x i8> [[TMP1]], [[TMP1]]
44 ; CHECK-NEXT: ret <4 x i8> [[TMP2]]
46 %x0 = extractelement <4 x i8> undef, i32 0
47 %x3 = extractelement <4 x i8> %x, i32 3
48 %y1 = extractelement <4 x i8> %y, i32 1
49 %y2 = extractelement <4 x i8> %y, i32 2
50 %x0x0 = mul i8 %x0, %x0
51 %x3x3 = mul i8 %x3, %x3
52 %y1y1 = mul i8 %y1, %y1
53 %y2y2 = mul i8 %y2, %y2
54 %ins1 = insertelement <4 x i8> poison, i8 %x0x0, i32 0
55 %ins2 = insertelement <4 x i8> %ins1, i8 %x3x3, i32 1
56 %ins3 = insertelement <4 x i8> %ins2, i8 %y1y1, i32 2
57 %ins4 = insertelement <4 x i8> %ins3, i8 %y2y2, i32 3
61 define i8 @i(<4 x i8> %x, <4 x i8> %y) {
63 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i32> <i32 0, i32 3, i32 5, i32 6>
64 ; CHECK-NEXT: [[TMP2:%.*]] = mul <4 x i8> [[TMP1]], [[TMP1]]
65 ; CHECK-NEXT: [[TMP3:%.*]] = call i8 @llvm.vector.reduce.add.v4i8(<4 x i8> [[TMP2]])
66 ; CHECK-NEXT: ret i8 [[TMP3]]
68 %x0 = extractelement <4 x i8> %x, i32 0
69 %x3 = extractelement <4 x i8> %x, i32 3
70 %y1 = extractelement <4 x i8> %y, i32 1
71 %y2 = extractelement <4 x i8> %y, i32 2
72 %x0x0 = mul i8 %x0, %x0
73 %x3x3 = mul i8 %x3, %x3
74 %y1y1 = mul i8 %y1, %y1
75 %y2y2 = mul i8 %y2, %y2
76 %1 = add i8 %x0x0, %x3x3
77 %2 = add i8 %y1y1, %y2y2
82 define i8 @j(<4 x i8> %x, <4 x i8> %y) {
84 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i8> [[X:%.*]], i32 0
85 ; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i8> [[X]], i32 3
86 ; CHECK-NEXT: [[Y1:%.*]] = extractelement <4 x i8> [[Y:%.*]], i32 1
87 ; CHECK-NEXT: [[Y2:%.*]] = extractelement <4 x i8> [[Y]], i32 2
88 ; CHECK-NEXT: [[X0X0:%.*]] = mul i8 [[X0]], [[X0]]
89 ; CHECK-NEXT: [[X3X3:%.*]] = mul i8 [[X3]], [[X3]]
90 ; CHECK-NEXT: [[Y1Y1:%.*]] = mul i8 [[Y1]], [[Y1]]
91 ; CHECK-NEXT: [[Y2Y2:%.*]] = mul i8 [[Y2]], [[Y2]]
92 ; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[X0X0]], [[X3X3]]
93 ; CHECK-NEXT: [[TMP2:%.*]] = add i8 [[Y1Y1]], [[Y2Y2]]
94 ; CHECK-NEXT: [[TMP3:%.*]] = sdiv i8 [[TMP1]], [[TMP2]]
95 ; CHECK-NEXT: ret i8 [[TMP3]]
97 %x0 = extractelement <4 x i8> %x, i32 0
98 %x3 = extractelement <4 x i8> %x, i32 3
99 %y1 = extractelement <4 x i8> %y, i32 1
100 %y2 = extractelement <4 x i8> %y, i32 2
101 %x0x0 = mul i8 %x0, %x0
102 %x3x3 = mul i8 %x3, %x3
103 %y1y1 = mul i8 %y1, %y1
104 %y2y2 = mul i8 %y2, %y2
105 %1 = add i8 %x0x0, %x3x3
106 %2 = add i8 %y1y1, %y2y2
111 define i8 @k(<4 x i8> %x) {
113 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i8> [[X:%.*]], i32 0
114 ; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i8> [[X]], i32 3
115 ; CHECK-NEXT: [[X1:%.*]] = extractelement <4 x i8> [[X]], i32 1
116 ; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i8> [[X]], i32 2
117 ; CHECK-NEXT: [[X0X0:%.*]] = mul i8 [[X0]], [[X0]]
118 ; CHECK-NEXT: [[X3X3:%.*]] = mul i8 [[X3]], [[X3]]
119 ; CHECK-NEXT: [[X1X1:%.*]] = mul i8 [[X1]], [[X1]]
120 ; CHECK-NEXT: [[X2X2:%.*]] = mul i8 [[X2]], [[X2]]
121 ; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[X0X0]], [[X3X3]]
122 ; CHECK-NEXT: [[TMP2:%.*]] = add i8 [[X1X1]], [[X2X2]]
123 ; CHECK-NEXT: [[TMP3:%.*]] = sdiv i8 [[TMP1]], [[TMP2]]
124 ; CHECK-NEXT: ret i8 [[TMP3]]
126 %x0 = extractelement <4 x i8> %x, i32 0
127 %x3 = extractelement <4 x i8> %x, i32 3
128 %x1 = extractelement <4 x i8> %x, i32 1
129 %x2 = extractelement <4 x i8> %x, i32 2
130 %x0x0 = mul i8 %x0, %x0
131 %x3x3 = mul i8 %x3, %x3
132 %x1x1 = mul i8 %x1, %x1
133 %x2x2 = mul i8 %x2, %x2
134 %1 = add i8 %x0x0, %x3x3
135 %2 = add i8 %x1x1, %x2x2
140 define i8 @k_bb(<4 x i8> %x) {
141 ; CHECK-LABEL: @k_bb(
142 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i8> [[X:%.*]], i32 0
143 ; CHECK-NEXT: br label [[BB1:%.*]]
145 ; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i8> [[X]], i32 3
146 ; CHECK-NEXT: [[X1:%.*]] = extractelement <4 x i8> [[X]], i32 1
147 ; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i8> [[X]], i32 2
148 ; CHECK-NEXT: [[X0X0:%.*]] = mul i8 [[X0]], [[X0]]
149 ; CHECK-NEXT: [[X3X3:%.*]] = mul i8 [[X3]], [[X3]]
150 ; CHECK-NEXT: [[X1X1:%.*]] = mul i8 [[X1]], [[X1]]
151 ; CHECK-NEXT: [[X2X2:%.*]] = mul i8 [[X2]], [[X2]]
152 ; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[X0X0]], [[X3X3]]
153 ; CHECK-NEXT: [[TMP2:%.*]] = add i8 [[X1X1]], [[X2X2]]
154 ; CHECK-NEXT: [[TMP3:%.*]] = sdiv i8 [[TMP1]], [[TMP2]]
155 ; CHECK-NEXT: ret i8 [[TMP3]]
157 %x0 = extractelement <4 x i8> %x, i32 0
160 %x3 = extractelement <4 x i8> %x, i32 3
161 %x1 = extractelement <4 x i8> %x, i32 1
162 %x2 = extractelement <4 x i8> %x, i32 2
163 %x0x0 = mul i8 %x0, %x0
164 %x3x3 = mul i8 %x3, %x3
165 %x1x1 = mul i8 %x1, %x1
166 %x2x2 = mul i8 %x2, %x2
167 %1 = add i8 %x0x0, %x3x3
168 %2 = add i8 %x1x1, %x2x2