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: [[X0:%.*]] = extractelement <2 x i8> [[X:%.*]], i32 0
7 ; CHECK-NEXT: [[Y1:%.*]] = extractelement <2 x i8> [[Y:%.*]], i32 1
8 ; CHECK-NEXT: [[X0X0:%.*]] = mul i8 [[X0]], [[X0]]
9 ; CHECK-NEXT: [[Y1Y1:%.*]] = mul i8 [[Y1]], [[Y1]]
10 ; CHECK-NEXT: [[INS1:%.*]] = insertelement <2 x i8> undef, i8 [[X0X0]], i32 0
11 ; CHECK-NEXT: [[INS2:%.*]] = insertelement <2 x i8> [[INS1]], i8 [[Y1Y1]], i32 1
12 ; CHECK-NEXT: ret <2 x i8> [[INS2]]
14 %x0 = extractelement <2 x i8> %x, i32 0
15 %y1 = extractelement <2 x i8> %y, i32 1
16 %x0x0 = mul i8 %x0, %x0
17 %y1y1 = mul i8 %y1, %y1
18 %ins1 = insertelement <2 x i8> undef, i8 %x0x0, i32 0
19 %ins2 = insertelement <2 x i8> %ins1, i8 %y1y1, i32 1
23 define <4 x i8> @h(<4 x i8> %x, <4 x i8> %y) {
25 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i32> <i32 0, i32 3, i32 5, i32 6>
26 ; CHECK-NEXT: [[TMP2:%.*]] = mul <4 x i8> [[TMP1]], [[TMP1]]
27 ; CHECK-NEXT: ret <4 x i8> [[TMP2]]
29 %x0 = extractelement <4 x i8> %x, i32 0
30 %x3 = extractelement <4 x i8> %x, i32 3
31 %y1 = extractelement <4 x i8> %y, i32 1
32 %y2 = extractelement <4 x i8> %y, i32 2
33 %x0x0 = mul i8 %x0, %x0
34 %x3x3 = mul i8 %x3, %x3
35 %y1y1 = mul i8 %y1, %y1
36 %y2y2 = mul i8 %y2, %y2
37 %ins1 = insertelement <4 x i8> undef, i8 %x0x0, i32 0
38 %ins2 = insertelement <4 x i8> %ins1, i8 %x3x3, i32 1
39 %ins3 = insertelement <4 x i8> %ins2, i8 %y1y1, i32 2
40 %ins4 = insertelement <4 x i8> %ins3, i8 %y2y2, i32 3
44 define <4 x i8> @h_undef(<4 x i8> %x, <4 x i8> %y) {
45 ; CHECK-LABEL: @h_undef(
46 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i32> <i32 undef, i32 3, i32 5, i32 6>
47 ; CHECK-NEXT: [[TMP2:%.*]] = mul <4 x i8> [[TMP1]], [[TMP1]]
48 ; CHECK-NEXT: ret <4 x i8> [[TMP2]]
50 %x0 = extractelement <4 x i8> undef, i32 0
51 %x3 = extractelement <4 x i8> %x, i32 3
52 %y1 = extractelement <4 x i8> %y, i32 1
53 %y2 = extractelement <4 x i8> %y, i32 2
54 %x0x0 = mul i8 %x0, %x0
55 %x3x3 = mul i8 %x3, %x3
56 %y1y1 = mul i8 %y1, %y1
57 %y2y2 = mul i8 %y2, %y2
58 %ins1 = insertelement <4 x i8> undef, i8 %x0x0, i32 0
59 %ins2 = insertelement <4 x i8> %ins1, i8 %x3x3, i32 1
60 %ins3 = insertelement <4 x i8> %ins2, i8 %y1y1, i32 2
61 %ins4 = insertelement <4 x i8> %ins3, i8 %y2y2, i32 3
65 define i8 @i(<4 x i8> %x, <4 x i8> %y) {
67 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i32> <i32 0, i32 3, i32 5, i32 6>
68 ; CHECK-NEXT: [[TMP2:%.*]] = mul <4 x i8> [[TMP1]], [[TMP1]]
69 ; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <4 x i8> [[TMP2]], <4 x i8> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
70 ; CHECK-NEXT: [[BIN_RDX:%.*]] = add <4 x i8> [[TMP2]], [[RDX_SHUF]]
71 ; CHECK-NEXT: [[RDX_SHUF1:%.*]] = shufflevector <4 x i8> [[BIN_RDX]], <4 x i8> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
72 ; CHECK-NEXT: [[BIN_RDX2:%.*]] = add <4 x i8> [[BIN_RDX]], [[RDX_SHUF1]]
73 ; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i8> [[BIN_RDX2]], i32 0
74 ; CHECK-NEXT: ret i8 [[TMP3]]
76 %x0 = extractelement <4 x i8> %x, i32 0
77 %x3 = extractelement <4 x i8> %x, i32 3
78 %y1 = extractelement <4 x i8> %y, i32 1
79 %y2 = extractelement <4 x i8> %y, i32 2
80 %x0x0 = mul i8 %x0, %x0
81 %x3x3 = mul i8 %x3, %x3
82 %y1y1 = mul i8 %y1, %y1
83 %y2y2 = mul i8 %y2, %y2
84 %1 = add i8 %x0x0, %x3x3
85 %2 = add i8 %y1y1, %y2y2
90 define i8 @j(<4 x i8> %x, <4 x i8> %y) {
92 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i8> [[X:%.*]], i32 0
93 ; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i8> [[X]], i32 3
94 ; CHECK-NEXT: [[Y1:%.*]] = extractelement <4 x i8> [[Y:%.*]], i32 1
95 ; CHECK-NEXT: [[Y2:%.*]] = extractelement <4 x i8> [[Y]], i32 2
96 ; CHECK-NEXT: [[X0X0:%.*]] = mul i8 [[X0]], [[X0]]
97 ; CHECK-NEXT: [[X3X3:%.*]] = mul i8 [[X3]], [[X3]]
98 ; CHECK-NEXT: [[Y1Y1:%.*]] = mul i8 [[Y1]], [[Y1]]
99 ; CHECK-NEXT: [[Y2Y2:%.*]] = mul i8 [[Y2]], [[Y2]]
100 ; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[X0X0]], [[X3X3]]
101 ; CHECK-NEXT: [[TMP2:%.*]] = add i8 [[Y1Y1]], [[Y2Y2]]
102 ; CHECK-NEXT: [[TMP3:%.*]] = sdiv i8 [[TMP1]], [[TMP2]]
103 ; CHECK-NEXT: ret i8 [[TMP3]]
105 %x0 = extractelement <4 x i8> %x, i32 0
106 %x3 = extractelement <4 x i8> %x, i32 3
107 %y1 = extractelement <4 x i8> %y, i32 1
108 %y2 = extractelement <4 x i8> %y, i32 2
109 %x0x0 = mul i8 %x0, %x0
110 %x3x3 = mul i8 %x3, %x3
111 %y1y1 = mul i8 %y1, %y1
112 %y2y2 = mul i8 %y2, %y2
113 %1 = add i8 %x0x0, %x3x3
114 %2 = add i8 %y1y1, %y2y2
119 define i8 @k(<4 x i8> %x) {
121 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i8> [[X:%.*]], i32 0
122 ; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i8> [[X]], i32 3
123 ; CHECK-NEXT: [[X1:%.*]] = extractelement <4 x i8> [[X]], i32 1
124 ; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i8> [[X]], i32 2
125 ; CHECK-NEXT: [[X0X0:%.*]] = mul i8 [[X0]], [[X0]]
126 ; CHECK-NEXT: [[X3X3:%.*]] = mul i8 [[X3]], [[X3]]
127 ; CHECK-NEXT: [[X1X1:%.*]] = mul i8 [[X1]], [[X1]]
128 ; CHECK-NEXT: [[X2X2:%.*]] = mul i8 [[X2]], [[X2]]
129 ; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[X0X0]], [[X3X3]]
130 ; CHECK-NEXT: [[TMP2:%.*]] = add i8 [[X1X1]], [[X2X2]]
131 ; CHECK-NEXT: [[TMP3:%.*]] = sdiv i8 [[TMP1]], [[TMP2]]
132 ; CHECK-NEXT: ret i8 [[TMP3]]
134 %x0 = extractelement <4 x i8> %x, i32 0
135 %x3 = extractelement <4 x i8> %x, i32 3
136 %x1 = extractelement <4 x i8> %x, i32 1
137 %x2 = extractelement <4 x i8> %x, i32 2
138 %x0x0 = mul i8 %x0, %x0
139 %x3x3 = mul i8 %x3, %x3
140 %x1x1 = mul i8 %x1, %x1
141 %x2x2 = mul i8 %x2, %x2
142 %1 = add i8 %x0x0, %x3x3
143 %2 = add i8 %x1x1, %x2x2
148 define i8 @k_bb(<4 x i8> %x) {
149 ; CHECK-LABEL: @k_bb(
150 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i8> [[X:%.*]], i32 0
151 ; CHECK-NEXT: br label [[BB1:%.*]]
153 ; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i8> [[X]], i32 3
154 ; CHECK-NEXT: [[X1:%.*]] = extractelement <4 x i8> [[X]], i32 1
155 ; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i8> [[X]], i32 2
156 ; CHECK-NEXT: [[X0X0:%.*]] = mul i8 [[X0]], [[X0]]
157 ; CHECK-NEXT: [[X3X3:%.*]] = mul i8 [[X3]], [[X3]]
158 ; CHECK-NEXT: [[X1X1:%.*]] = mul i8 [[X1]], [[X1]]
159 ; CHECK-NEXT: [[X2X2:%.*]] = mul i8 [[X2]], [[X2]]
160 ; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[X0X0]], [[X3X3]]
161 ; CHECK-NEXT: [[TMP2:%.*]] = add i8 [[X1X1]], [[X2X2]]
162 ; CHECK-NEXT: [[TMP3:%.*]] = sdiv i8 [[TMP1]], [[TMP2]]
163 ; CHECK-NEXT: ret i8 [[TMP3]]
165 %x0 = extractelement <4 x i8> %x, i32 0
168 %x3 = extractelement <4 x i8> %x, i32 3
169 %x1 = extractelement <4 x i8> %x, i32 1
170 %x2 = extractelement <4 x i8> %x, i32 2
171 %x0x0 = mul i8 %x0, %x0
172 %x3x3 = mul i8 %x3, %x3
173 %x1x1 = mul i8 %x1, %x1
174 %x2x2 = mul i8 %x2, %x2
175 %1 = add i8 %x0x0, %x3x3
176 %2 = add i8 %x1x1, %x2x2