1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-gnu-linux -mcpu=pwr9 < %s | FileCheck %s -check-prefix=CHECK-LE
3 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-gnu-linux -mcpu=pwr9 < %s | FileCheck %s -check-prefix=CHECK-BE
5 define zeroext i8 @test_add1(<16 x i8> %a, i32 signext %index, i8 zeroext %c) {
6 ; CHECK-LE-LABEL: test_add1:
7 ; CHECK-LE: # %bb.0: # %entry
8 ; CHECK-LE-NEXT: vextubrx 3, 5, 2
9 ; CHECK-LE-NEXT: add 3, 3, 6
10 ; CHECK-LE-NEXT: clrldi 3, 3, 56
12 ; CHECK-BE-LABEL: test_add1:
13 ; CHECK-BE: # %bb.0: # %entry
14 ; CHECK-BE-NEXT: vextublx 3, 5, 2
15 ; CHECK-BE-NEXT: add 3, 3, 6
16 ; CHECK-BE-NEXT: clrldi 3, 3, 56
19 %vecext = extractelement <16 x i8> %a, i32 %index
20 %conv = zext i8 %vecext to i32
21 %conv1 = zext i8 %c to i32
22 %add = add nuw nsw i32 %conv, %conv1
23 %conv2 = trunc i32 %add to i8
27 define signext i8 @test_add2(<16 x i8> %a, i32 signext %index, i8 signext %c) {
28 ; CHECK-LE-LABEL: test_add2:
29 ; CHECK-LE: # %bb.0: # %entry
30 ; CHECK-LE-NEXT: vextubrx 3, 5, 2
31 ; CHECK-LE-NEXT: add 3, 3, 6
32 ; CHECK-LE-NEXT: extsb 3, 3
34 ; CHECK-BE-LABEL: test_add2:
35 ; CHECK-BE: # %bb.0: # %entry
36 ; CHECK-BE-NEXT: vextublx 3, 5, 2
37 ; CHECK-BE-NEXT: add 3, 3, 6
38 ; CHECK-BE-NEXT: extsb 3, 3
41 %vecext = extractelement <16 x i8> %a, i32 %index
42 %conv3 = zext i8 %vecext to i32
43 %conv14 = zext i8 %c to i32
44 %add = add nuw nsw i32 %conv3, %conv14
45 %conv2 = trunc i32 %add to i8
49 define zeroext i16 @test_add3(<8 x i16> %a, i32 signext %index, i16 zeroext %c) {
50 ; CHECK-LE-LABEL: test_add3:
51 ; CHECK-LE: # %bb.0: # %entry
52 ; CHECK-LE-NEXT: rlwinm 3, 5, 1, 28, 30
53 ; CHECK-LE-NEXT: vextuhrx 3, 3, 2
54 ; CHECK-LE-NEXT: add 3, 3, 6
55 ; CHECK-LE-NEXT: clrldi 3, 3, 48
57 ; CHECK-BE-LABEL: test_add3:
58 ; CHECK-BE: # %bb.0: # %entry
59 ; CHECK-BE-NEXT: rlwinm 3, 5, 1, 28, 30
60 ; CHECK-BE-NEXT: vextuhlx 3, 3, 2
61 ; CHECK-BE-NEXT: add 3, 3, 6
62 ; CHECK-BE-NEXT: clrldi 3, 3, 48
65 %vecext = extractelement <8 x i16> %a, i32 %index
66 %conv = zext i16 %vecext to i32
67 %conv1 = zext i16 %c to i32
68 %add = add nuw nsw i32 %conv, %conv1
69 %conv2 = trunc i32 %add to i16
73 define signext i16 @test_add4(<8 x i16> %a, i32 signext %index, i16 signext %c) {
74 ; CHECK-LE-LABEL: test_add4:
75 ; CHECK-LE: # %bb.0: # %entry
76 ; CHECK-LE-NEXT: rlwinm 3, 5, 1, 28, 30
77 ; CHECK-LE-NEXT: vextuhrx 3, 3, 2
78 ; CHECK-LE-NEXT: add 3, 3, 6
79 ; CHECK-LE-NEXT: extsh 3, 3
81 ; CHECK-BE-LABEL: test_add4:
82 ; CHECK-BE: # %bb.0: # %entry
83 ; CHECK-BE-NEXT: rlwinm 3, 5, 1, 28, 30
84 ; CHECK-BE-NEXT: vextuhlx 3, 3, 2
85 ; CHECK-BE-NEXT: add 3, 3, 6
86 ; CHECK-BE-NEXT: extsh 3, 3
89 %vecext = extractelement <8 x i16> %a, i32 %index
90 %conv5 = zext i16 %vecext to i32
91 %conv16 = zext i16 %c to i32
92 %add = add nuw nsw i32 %conv5, %conv16
93 %conv2 = trunc i32 %add to i16
97 define zeroext i32 @test_add5(<4 x i32> %a, i32 signext %index, i32 zeroext %c) {
98 ; CHECK-LE-LABEL: test_add5:
99 ; CHECK-LE: # %bb.0: # %entry
100 ; CHECK-LE-NEXT: rlwinm 3, 5, 2, 28, 29
101 ; CHECK-LE-NEXT: vextuwrx 3, 3, 2
102 ; CHECK-LE-NEXT: add 3, 3, 6
103 ; CHECK-LE-NEXT: clrldi 3, 3, 32
105 ; CHECK-BE-LABEL: test_add5:
106 ; CHECK-BE: # %bb.0: # %entry
107 ; CHECK-BE-NEXT: rlwinm 3, 5, 2, 28, 29
108 ; CHECK-BE-NEXT: vextuwlx 3, 3, 2
109 ; CHECK-BE-NEXT: add 3, 3, 6
110 ; CHECK-BE-NEXT: clrldi 3, 3, 32
113 %vecext = extractelement <4 x i32> %a, i32 %index
114 %add = add i32 %vecext, %c
118 define signext i32 @test_add6(<4 x i32> %a, i32 signext %index, i32 signext %c) {
119 ; CHECK-LE-LABEL: test_add6:
120 ; CHECK-LE: # %bb.0: # %entry
121 ; CHECK-LE-NEXT: rlwinm 3, 5, 2, 28, 29
122 ; CHECK-LE-NEXT: vextuwrx 3, 3, 2
123 ; CHECK-LE-NEXT: add 3, 3, 6
124 ; CHECK-LE-NEXT: extsw 3, 3
126 ; CHECK-BE-LABEL: test_add6:
127 ; CHECK-BE: # %bb.0: # %entry
128 ; CHECK-BE-NEXT: rlwinm 3, 5, 2, 28, 29
129 ; CHECK-BE-NEXT: vextuwlx 3, 3, 2
130 ; CHECK-BE-NEXT: add 3, 3, 6
131 ; CHECK-BE-NEXT: extsw 3, 3
134 %vecext = extractelement <4 x i32> %a, i32 %index
135 %add = add nsw i32 %vecext, %c
139 ; When extracting word element 2 on LE, it's better to use mfvsrwz rather than vextuwrx
140 define zeroext i32 @test7(<4 x i32> %a) {
141 ; CHECK-LE-LABEL: test7:
142 ; CHECK-LE: # %bb.0: # %entry
143 ; CHECK-LE-NEXT: mfvsrwz 3, 34
145 ; CHECK-BE-LABEL: test7:
146 ; CHECK-BE: # %bb.0: # %entry
147 ; CHECK-BE-NEXT: li 3, 8
148 ; CHECK-BE-NEXT: vextuwlx 3, 3, 2
151 %vecext = extractelement <4 x i32> %a, i32 2
155 define zeroext i32 @testadd_7(<4 x i32> %a, i32 zeroext %c) {
156 ; CHECK-LE-LABEL: testadd_7:
157 ; CHECK-LE: # %bb.0: # %entry
158 ; CHECK-LE-NEXT: mfvsrwz 3, 34
159 ; CHECK-LE-NEXT: add 3, 3, 5
160 ; CHECK-LE-NEXT: clrldi 3, 3, 32
162 ; CHECK-BE-LABEL: testadd_7:
163 ; CHECK-BE: # %bb.0: # %entry
164 ; CHECK-BE-NEXT: li 3, 8
165 ; CHECK-BE-NEXT: vextuwlx 3, 3, 2
166 ; CHECK-BE-NEXT: add 3, 3, 5
167 ; CHECK-BE-NEXT: clrldi 3, 3, 32
170 %vecext = extractelement <4 x i32> %a, i32 2
171 %add = add i32 %vecext, %c
175 define signext i32 @test8(<4 x i32> %a) {
176 ; CHECK-LE-LABEL: test8:
177 ; CHECK-LE: # %bb.0: # %entry
178 ; CHECK-LE-NEXT: mfvsrwz 3, 34
179 ; CHECK-LE-NEXT: extsw 3, 3
181 ; CHECK-BE-LABEL: test8:
182 ; CHECK-BE: # %bb.0: # %entry
183 ; CHECK-BE-NEXT: li 3, 8
184 ; CHECK-BE-NEXT: vextuwlx 3, 3, 2
185 ; CHECK-BE-NEXT: extsw 3, 3
188 %vecext = extractelement <4 x i32> %a, i32 2
192 define signext i32 @testadd_8(<4 x i32> %a, i32 signext %c) {
193 ; CHECK-LE-LABEL: testadd_8:
194 ; CHECK-LE: # %bb.0: # %entry
195 ; CHECK-LE-NEXT: mfvsrwz 3, 34
196 ; CHECK-LE-NEXT: add 3, 3, 5
197 ; CHECK-LE-NEXT: extsw 3, 3
199 ; CHECK-BE-LABEL: testadd_8:
200 ; CHECK-BE: # %bb.0: # %entry
201 ; CHECK-BE-NEXT: li 3, 8
202 ; CHECK-BE-NEXT: vextuwlx 3, 3, 2
203 ; CHECK-BE-NEXT: add 3, 3, 5
204 ; CHECK-BE-NEXT: extsw 3, 3
207 %vecext = extractelement <4 x i32> %a, i32 2
208 %add = add nsw i32 %vecext, %c
212 ; When extracting word element 1 on BE, it's better to use mfvsrwz rather than vextuwlx
213 define signext i32 @test9(<4 x i32> %a) {
214 ; CHECK-LE-LABEL: test9:
215 ; CHECK-LE: # %bb.0: # %entry
216 ; CHECK-LE-NEXT: li 3, 4
217 ; CHECK-LE-NEXT: vextuwrx 3, 3, 2
218 ; CHECK-LE-NEXT: extsw 3, 3
220 ; CHECK-BE-LABEL: test9:
221 ; CHECK-BE: # %bb.0: # %entry
222 ; CHECK-BE-NEXT: mfvsrwz 3, 34
223 ; CHECK-BE-NEXT: extsw 3, 3
226 %vecext = extractelement <4 x i32> %a, i32 1
230 define signext i32 @testadd_9(<4 x i32> %a, i32 signext %c) {
231 ; CHECK-LE-LABEL: testadd_9:
232 ; CHECK-LE: # %bb.0: # %entry
233 ; CHECK-LE-NEXT: li 3, 4
234 ; CHECK-LE-NEXT: vextuwrx 3, 3, 2
235 ; CHECK-LE-NEXT: add 3, 3, 5
236 ; CHECK-LE-NEXT: extsw 3, 3
238 ; CHECK-BE-LABEL: testadd_9:
239 ; CHECK-BE: # %bb.0: # %entry
240 ; CHECK-BE-NEXT: mfvsrwz 3, 34
241 ; CHECK-BE-NEXT: add 3, 3, 5
242 ; CHECK-BE-NEXT: extsw 3, 3
245 %vecext = extractelement <4 x i32> %a, i32 1
246 %add = add nsw i32 %vecext, %c