Debian Codegraph @

gcc/config/s390/vector.md

raw
1 ;;- Instruction patterns for the System z vector facility
2 ;; Copyright (C) 2015-2025 Free Software Foundation, Inc.
3 ;; Contributed by Andreas Krebbel ([email protected])
4
5 ;; This file is part of GCC.
6
7 ;; GCC is free software; you can redistribute it and/or modify it under
8 ;; the terms of the GNU General Public License as published by the Free
9 ;; Software Foundation; either version 3, or (at your option) any later
10 ;; version.
11
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 ;; for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
20
21 ; All vector modes supported in a vector register
22 (define_mode_iterator V
23 [V1QI V2QI V4QI V8QI V16QI V1HI V2HI V4HI V8HI V1SI V2SI V4SI V1DI V2DI V1SF
24 V2SF V4SF V1DF V2DF])
25 (define_mode_iterator VT
26 [V1QI V2QI V4QI V8QI V16QI V1HI V2HI V4HI V8HI V1SI V2SI V4SI V1DI V2DI V1SF
27 V2SF V4SF V1DF V2DF V1TF V1TI TI])
28 (define_mode_iterator VT_VXE3
29 [V1QI V2QI V4QI V8QI V16QI V1HI V2HI V4HI V8HI V1SI V2SI V4SI V1DI V2DI V1SF
30 V2SF V4SF V1DF V2DF V1TF (V1TI "TARGET_VXE3") (TI "TARGET_VXE3")])
31
32 ; All modes directly supported by the hardware having full vector reg size
33 (define_mode_iterator V_HW [V16QI V8HI V4SI V2DI V1TI TI V2DF
34 (V4SF "TARGET_VXE") (V1TF "TARGET_VXE")
35 (TF "TARGET_VXE")])
36 (define_mode_iterator V_HW1 [V16QI V8HI V4SI V2DI V1TI V2DF
37 (V4SF "TARGET_VXE") (V1TF "TARGET_VXE")
38 (TF "TARGET_VXE")])
39 (define_mode_iterator V_HW2 [V16QI V8HI V4SI V2DI V2DF (V4SF "TARGET_VXE")
40 (V1TF "TARGET_VXE") (TF "TARGET_VXE")])
41 (define_mode_iterator V_HW3 [V16QI V8HI V4SI V2DI V1TI TI V4SF V2DF V1TF TF])
42
43 (define_mode_iterator VT_HW_HSDT [V8HI V4SI V4SF V2DI V2DF V1TI V1TF TI TF])
44 (define_mode_iterator V_HW_HSD [V8HI V4SI (V4SF "TARGET_VXE") V2DI V2DF])
45
46 ; Including TI for instructions that support it (va, vn, ...)
47 (define_mode_iterator VT_HW [V16QI V8HI V4SI V2DI V2DF V1TI TI (V4SF "TARGET_VXE") (V1TF "TARGET_VXE")])
48
49 ; All full size integer vector modes supported in a vector register + TImode
50 (define_mode_iterator VIT_HW [V16QI V8HI V4SI V2DI V1TI TI])
51 (define_mode_iterator VIT_HW_VXE3_T [V16QI V8HI V4SI V2DI (V1TI "TARGET_VXE3") (TI "TARGET_VXE3")])
52 (define_mode_iterator VIT_HW_VXE3_DT [V16QI V8HI V4SI (V2DI "TARGET_VXE3") (V1TI "TARGET_VXE3") (TI "TARGET_VXE3")])
53 (define_mode_iterator VI_HW [V16QI V8HI V4SI V2DI])
54 (define_mode_iterator VI_HW_VXE3 [V16QI V8HI V4SI (V2DI "TARGET_VXE3")])
55 (define_mode_iterator VI_HW_QHS [V16QI V8HI V4SI])
56 (define_mode_iterator VI_HW_SDT [V4SI V2DI V1TI TI])
57 (define_mode_iterator VI_HW_HSD [V8HI V4SI V2DI])
58 (define_mode_iterator VI_HW_HSDT [V8HI V4SI V2DI V1TI TI])
59 (define_mode_iterator VI_HW_HS [V8HI V4SI])
60 (define_mode_iterator VI_HW_QH [V16QI V8HI])
61 (define_mode_iterator VI_HW_T [V1TI TI])
62
63 ; Directly supported vector modes with a certain number of elements
64 (define_mode_iterator V_HW_2 [V2DI V2DF])
65 (define_mode_iterator V_HW_4 [V4SI V4SF])
66
67 ; All integer vector modes supported in a vector register + TImode
68 (define_mode_iterator VIT [V1QI V2QI V4QI V8QI V16QI V1HI V2HI V4HI V8HI V1SI V2SI V4SI V1DI V2DI V1TI TI])
69 (define_mode_iterator VIT_VXE3 [V1QI V2QI V4QI V8QI V16QI V1HI V2HI V4HI V8HI V1SI V2SI V4SI V1DI V2DI (V1TI "TARGET_VXE3") (TI "TARGET_VXE3")])
70 (define_mode_iterator VI [V1QI V2QI V4QI V8QI V16QI V1HI V2HI V4HI V8HI V1SI V2SI V4SI V1DI V2DI])
71 (define_mode_iterator VI_VXE3 [V1QI V2QI V4QI V8QI V16QI V1HI V2HI V4HI V8HI V1SI V2SI V4SI V1DI (V2DI "TARGET_VXE3")])
72 (define_mode_iterator VI_QHS [V1QI V2QI V4QI V8QI V16QI V1HI V2HI V4HI V8HI V1SI V2SI V4SI])
73
74 (define_mode_iterator VFT [(V1SF "TARGET_VXE") (V2SF "TARGET_VXE") (V4SF "TARGET_VXE")
75 V1DF V2DF
76 (V1TF "TARGET_VXE") (TF "TARGET_VXE")])
77
78 ; All modes present in V_HW1 and VFT.
79 (define_mode_iterator V_HW1_FT [V16QI V8HI V4SI V2DI V1TI V1DF
80 V2DF (V1SF "TARGET_VXE") (V2SF "TARGET_VXE")
81 (V4SF "TARGET_VXE") (V1TF "TARGET_VXE")
82 (TF "TARGET_VXE")])
83
84 ; FP vector modes directly supported by the HW. This does not include
85 ; vector modes using only part of a vector register and should be used
86 ; for instructions which might trigger IEEE exceptions.
87 (define_mode_iterator VF_HW [(V4SF "TARGET_VXE") V2DF (V1TF "TARGET_VXE")
88 (TF "TARGET_VXE")])
89
90 (define_mode_iterator V_8 [V1QI])
91 (define_mode_iterator V_16 [V2QI V1HI])
92 (define_mode_iterator V_32 [V4QI V2HI V1SI V1SF])
93 (define_mode_iterator V_64 [V8QI V4HI V2SI V2SF V1DI V1DF])
94 (define_mode_iterator V_128 [V16QI V8HI V4SI V4SF V2DI V2DF V1TI V1TF
95 (TF "TARGET_VXE")])
96 (define_mode_iterator V_128_NOSINGLE [V16QI V8HI V4SI V4SF V2DI V2DF])
97
98 ; 32 bit int<->fp vector conversion instructions are available since VXE2 (z15).
99 (define_mode_iterator VX_VEC_CONV_BFP [V2DF (V4SF "TARGET_VXE2")])
100
101 (define_mode_iterator VI_EXTEND [V2QI V2HI V2SI V4QI V4HI])
102
103 ; Empty string for all but TImode. This is used to hide the TImode
104 ; expander name in case it is defined already. See addti3 for an
105 ; example.
106 (define_mode_attr ti* [(V1QI "") (V2QI "") (V4QI "") (V8QI "") (V16QI "")
107 (V1HI "") (V2HI "") (V4HI "") (V8HI "")
108 (V1SI "") (V2SI "") (V4SI "")
109 (V1DI "") (V2DI "")
110 (V1TI "") (TI "*")
111 (V1SF "") (V2SF "") (V4SF "")
112 (V1DF "") (V2DF "")
113 (V1TF "") (TF "")])
114
115 ;; Facilitate dispatching TFmode expanders on z14+.
116 (define_mode_attr tf_vr [(TF "_vr") (V4SF "") (V2DF "") (V1TF "") (V1SF "")
117 (V2SF "") (V1DF "") (V16QI "") (V8HI "") (V4SI "")
118 (V2DI "") (V1TI "")])
119
120 ; The element type of the vector.
121 (define_mode_attr non_vec[(V1QI "QI") (V2QI "QI") (V4QI "QI") (V8QI "QI") (V16QI "QI")
122 (V1HI "HI") (V2HI "HI") (V4HI "HI") (V8HI "HI")
123 (V1SI "SI") (V2SI "SI") (V4SI "SI")
124 (V1DI "DI") (V2DI "DI")
125 (V1TI "TI") (TI "TI")
126 (V1SF "SF") (V2SF "SF") (V4SF "SF")
127 (V1DF "DF") (V2DF "DF")
128 (V1TF "TF") (TF "TF")])
129
130 ; Like above, but in lower case.
131 (define_mode_attr non_vec_l[(V1QI "qi") (V2QI "qi") (V4QI "qi") (V8QI "qi")
132 (V16QI "qi")
133 (V1HI "hi") (V2HI "hi") (V4HI "hi") (V8HI "hi")
134 (V1SI "si") (V2SI "si") (V4SI "si")
135 (V1DI "di") (V2DI "di")
136 (V1TI "ti") (TI "ti")
137 (V1SF "sf") (V2SF "sf") (V4SF "sf")
138 (V1DF "df") (V2DF "df")
139 (V1TF "tf") (TF "tf")])
140
141 ; The instruction suffix for integer instructions and instructions
142 ; which do not care about whether it is floating point or integer.
143 (define_mode_attr bhfgq[(V1QI "b") (V2QI "b") (V4QI "b") (V8QI "b") (V16QI "b")
144 (V1HI "h") (V2HI "h") (V4HI "h") (V8HI "h")
145 (V1SI "f") (V2SI "f") (V4SI "f")
146 (V1DI "g") (V2DI "g")
147 (V1TI "q") (TI "q")
148 (V1SF "f") (V2SF "f") (V4SF "f")
149 (V1DF "g") (V2DF "g")
150 (V1TF "q") (TF "q")])
151
152 ; This is for vmalhw. It gets an 'w' attached to avoid confusion with
153 ; multiply and add logical high vmalh.
154 (define_mode_attr w [(V1QI "") (V2QI "") (V4QI "") (V8QI "") (V16QI "")
155 (V1HI "w") (V2HI "w") (V4HI "w") (V8HI "w")
156 (V1SI "") (V2SI "") (V4SI "")
157 (V1DI "") (V2DI "")
158 (V1TI "") (TI "")])
159
160 ; Resulting mode of a vector comparison. For floating point modes an
161 ; integer vector mode with the same element size is picked.
162 (define_mode_attr TOINTVEC [(V1QI "V1QI") (V2QI "V2QI") (V4QI "V4QI") (V8QI "V8QI") (V16QI "V16QI")
163 (V1HI "V1HI") (V2HI "V2HI") (V4HI "V4HI") (V8HI "V8HI")
164 (V1SI "V1SI") (V2SI "V2SI") (V4SI "V4SI")
165 (V1DI "V1DI") (V2DI "V2DI")
166 (V1TI "V1TI") (TI "TI")
167 (V1SF "V1SI") (V2SF "V2SI") (V4SF "V4SI")
168 (V1DF "V1DI") (V2DF "V2DI")
169 (V1TF "V1TI") (TF "TI")])
170
171 (define_mode_attr tointvec [(V1QI "v1qi") (V2QI "v2qi") (V4QI "v4qi") (V8QI "v8qi") (V16QI "v16qi")
172 (V1HI "v1hi") (V2HI "v2hi") (V4HI "v4hi") (V8HI "v8hi")
173 (V1SI "v1si") (V2SI "v2si") (V4SI "v4si")
174 (V1DI "v1di") (V2DI "v2di")
175 (V1TI "v1ti") (TI "ti")
176 (V1SF "v1si") (V2SF "v2si") (V4SF "v4si")
177 (V1DF "v1di") (V2DF "v2di")
178 (V1TF "v1ti") (TF "ti")])
179
180 (define_mode_attr vw [(SF "w") (V1SF "w") (V2SF "v") (V4SF "v")
181 (DF "w") (V1DF "w") (V2DF "v")
182 (TF "w") (V1TF "w")])
183
184 (define_mode_attr sdx [(SF "s") (V1SF "s") (V2SF "s") (V4SF "s")
185 (DF "d") (V1DF "d") (V2DF "d")
186 (TF "x") (V1TF "x")])
187
188 ; Vector with widened element size but half the number of elements.
189 (define_mode_attr vec_double [(V1QI "V1HI") (V2QI "V1HI") (V4QI "V2HI") (V8QI "V4HI") (V16QI "V8HI")
190 (V1HI "V1SI") (V2HI "V1SI") (V4HI "V2SI") (V8HI "V4SI")
191 (V1SI "V1DI") (V2SI "V1DI") (V4SI "V2DI")
192 (V1DI "V1TI") (V2DI "TI")
193 (V1SF "V1DF") (V2SF "V1DF") (V4SF "V2DF")])
194
195 ; Vector with shrinked element size but twice the number of elements.
196 (define_mode_attr vec_half [(V1HI "V2QI") (V2HI "V4QI") (V4HI "V8QI") (V8HI "V16QI")
197 (V1SI "V2HI") (V2SI "V4HI") (V4SI "V8HI")
198 (V1DI "V2SI") (V2DI "V4SI")
199 (V1TI "V2DI")
200 (V1DF "V2SF") (V2DF "V4SF")
201 (V1TF "V1DF")])
202
203 ; Vector with twice the number of elements but same element size.
204 (define_mode_attr vec_2x_nelts [(V1QI "V2QI") (V2QI "V4QI") (V4QI "V8QI") (V8QI "V16QI") (V16QI "V32QI")
205 (V1HI "V2HI") (V2HI "V4HI") (V4HI "V8HI") (V8HI "V16HI")
206 (V1SI "V2SI") (V2SI "V4SI") (V4SI "V8SI")
207 (V1DI "V2DI") (V2DI "V4DI")
208 (V1SF "V2SF") (V2SF "V4SF") (V4SF "V8SF")
209 (V1DF "V2DF") (V2DF "V4DF")])
210
211 ; Vector with widened element size and the same number of elements.
212 (define_mode_attr VEC_2X_WIDE [(V1QI "V1HI") (V2QI "V2HI") (V4QI "V4HI") (V8QI "V8HI") (V16QI "V16HI")
213 (V1HI "V1SI") (V2HI "V2SI") (V4HI "V4SI") (V8HI "V8SI")
214 (V1SI "V1DI") (V2SI "V2DI") (V4SI "V4DI")
215 (V1DI "V1TI") (V2DI "V2TI")
216 (V1SF "V1DF") (V2SF "V2DF") (V4SF "V4DF")
217 (V1DF "V1TF") (V2DF "V2TF")])
218
219 (define_mode_attr vec_2x_wide [(V1QI "v1hi") (V2QI "v2hi") (V4QI "v4hi") (V8QI "v8hi") (V16QI "v16hi")
220 (V1HI "v1si") (V2HI "v2si") (V4HI "v4si") (V8HI "v8si")
221 (V1SI "v1di") (V2SI "v2di") (V4SI "v4di")
222 (V1DI "v1ti") (V2DI "v2ti")
223 (V1SF "v1df") (V2SF "v2df") (V4SF "v4df")
224 (V1DF "v1tf") (V2DF "v2tf")])
225
226 ; Vector with half the element size AND half the number of elements.
227 (define_mode_attr vec_halfhalf
228 [(V2HI "V2QI") (V4HI "V4QI") (V8HI "V8QI")
229 (V2SI "V2HI") (V4SI "V4HI")
230 (V2DI "V2SI")
231 (V2DF "V2SF")])
232
233 (define_mode_attr vec_halfnumelts
234 [(V4SF "V2SF") (V4SI "V2SI")])
235
236
237
238 ; Comparison operators on int and fp compares which are directly
239 ; supported by the HW.
240 (define_code_iterator VICMP_HW_OP [eq gt gtu])
241 (define_code_iterator VICMP_HW_OP2 [gt gtu])
242 ; For int insn_cmp_op can be used in the insn name as well as in the asm output.
243 (define_code_attr insn_cmp_op [(eq "eq") (gt "h") (gtu "hl") (ge "he")])
244
245 ; Flags for vector string instructions (vfae all 4, vfee only ZS and CS, vstrc all 4)
246 (define_constants
247 [(VSTRING_FLAG_IN 8) ; invert result
248 (VSTRING_FLAG_RT 4) ; result type
249 (VSTRING_FLAG_ZS 2) ; zero search
250 (VSTRING_FLAG_CS 1)]) ; condition code set
251
252 (include "vx-builtins.md")
253
254 ; Full HW vector size moves
255
256 ; We don't use lm/stm for 128 bit moves since these are slower than
257 ; splitting it into separate moves.
258
259 ; FIXME: More constants are possible by enabling jxx, jyy constraints
260 ; for TImode (use double-int for the calculations)
261
262 ; vgmb, vgmh, vgmf, vgmg, vrepib, vrepih, vrepif, vrepig
263 (define_insn "mov<mode><tf_vr>"
264 [(set (match_operand:V_128 0 "nonimmediate_operand" "=v,v,R, v, v, v, v, v,v,*d,*d,?o")
265 (match_operand:V_128 1 "general_operand" " v,R,v,j00,jm1,jyy,jxx,jzz,d, v,dT,*d"))]
266 ""
267 "@
268 vlr\t%v0,%v1
269 vl\t%v0,%1%A1
270 vst\t%v1,%0%A0
271 vzero\t%v0
272 vone\t%v0
273 vgbm\t%v0,%r1
274 vgm\t%v0,%q1
275 vrepi\t%v0,%p1
276 vlvgp\t%v0,%1,%N1
277 #
278 #
279 #"
280 [(set_attr "cpu_facility" "vx,vx,vx,vx,vx,vx,vx,vx,vx,vx,*,*")
281 (set_attr "op_type" "VRR,VRX,VRX,VRI,VRI,VRI,VRI,VRI,VRR,*,*,*")])
282
283 (define_expand "movtf"
284 [(match_operand:TF 0 "nonimmediate_operand" "")
285 (match_operand:TF 1 "general_operand" "")]
286 ""
287 { EXPAND_MOVTF(movtf); })
288
289 ; VR -> GPR, no instruction so split it into 64 element sets.
290 (define_split
291 [(set (match_operand:V_128 0 "register_operand" "")
292 (match_operand:V_128 1 "register_operand" ""))]
293 "TARGET_VX && GENERAL_REG_P (operands[0]) && VECTOR_REG_P (operands[1])"
294 [(set (match_dup 2)
295 (vec_select:DI
296 (subreg:V2DI (match_dup 1) 0)
297 (parallel [(const_int 0)])))
298 (set (match_dup 3)
299 (vec_select:DI
300 (subreg:V2DI (match_dup 1) 0)
301 (parallel [(const_int 1)])))]
302 {
303 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
304 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
305 })
306
307 ; Split the 128 bit GPR move into two word mode moves
308 ; s390_split_ok_p decides which part needs to be moved first.
309
310 (define_split
311 [(set (match_operand:V_128 0 "nonimmediate_operand" "")
312 (match_operand:V_128 1 "general_operand" ""))]
313 "reload_completed
314 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
315 [(set (match_dup 2) (match_dup 4))
316 (set (match_dup 3) (match_dup 5))]
317 {
318 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
319 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
320 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
321 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
322 })
323
324 (define_split
325 [(set (match_operand:V_128 0 "nonimmediate_operand" "")
326 (match_operand:V_128 1 "general_operand" ""))]
327 "reload_completed
328 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
329 [(set (match_dup 2) (match_dup 4))
330 (set (match_dup 3) (match_dup 5))]
331 {
332 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
333 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
334 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
335 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
336 })
337
338 ; This is the vector equivalent to the TImode splitter in s390.md. It
339 ; is required if both target GPRs occur in the source address operand.
340
341 ; For non-s_operands at least one of the target GPRs does not conflict
342 ; with the address operand and one of the splitters above will take
343 ; over.
344 (define_split
345 [(set (match_operand:V_128 0 "register_operand" "")
346 (match_operand:V_128 1 "memory_operand" ""))]
347 "TARGET_ZARCH && reload_completed
348 && !VECTOR_REG_P (operands[0])
349 && !s_operand (operands[1], VOIDmode)"
350 [(set (match_dup 0) (match_dup 1))]
351 {
352 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
353 addr = gen_lowpart (Pmode, addr);
354 s390_load_address (addr, XEXP (operands[1], 0));
355 operands[1] = replace_equiv_address (operands[1], addr);
356 })
357
358 ; Moves for smaller vector modes.
359
360 ; In these patterns only the vlr, vone, and vzero instructions write
361 ; VR bytes outside the mode. This should be ok since we disallow
362 ; formerly bigger modes being accessed with smaller modes via
363 ; subreg. Note: The vone, vzero instructions could easily be replaced
364 ; with vlei which would only access the bytes belonging to the mode.
365 ; However, this would probably be slower.
366
367 (define_insn "mov<mode>"
368 [(set (match_operand:V_8 0 "nonimmediate_operand" "=v,v,d,v,R, v, v, v, v, v,d, Q, S, Q, S, d, d,d,R,T")
369 (match_operand:V_8 1 "general_operand" " v,d,v,R,v,j00,jm1,jyy,jxx,jzz,d,j00,j00,jm1,jm1,j00,jm1,T,d,d"))]
370 "TARGET_VX"
371 "@
372 vlr\t%v0,%v1
373 vlvgb\t%v0,%1,0
374 vlgvb\t%0,%v1,0
375 vleb\t%v0,%1,0
376 vsteb\t%v1,%0,0
377 vzero\t%v0
378 vone\t%v0
379 vgbm\t%v0,%r1
380 vgm\t%v0,%q1
381 vrepi\t%v0,%p1
382 lr\t%0,%1
383 mvi\t%0,0
384 mviy\t%0,0
385 mvi\t%0,255
386 mviy\t%0,255
387 lhi\t%0,0
388 lhi\t%0,-1
389 llc\t%0,%1
390 stc\t%1,%0
391 stcy\t%1,%0"
392 [(set_attr "op_type" "VRR,VRS,VRS,VRX,VRX,VRI,VRI,VRI,VRI,VRI,RR,SI,SIY,SI,SIY,RI,RI,RXY,RX,RXY")])
393
394 (define_insn "mov<mode>"
395 [(set (match_operand:V_16 0 "nonimmediate_operand" "=v,v,d,v,R, v, v, v, v, v,d, Q, Q, d, d,d,d,d,R,T,b")
396 (match_operand:V_16 1 "general_operand" " v,d,v,R,v,j00,jm1,jyy,jxx,jzz,d,j00,jm1,j00,jm1,R,T,b,d,d,d"))]
397 ""
398 "@
399 vlr\t%v0,%v1
400 vlvgh\t%v0,%1,0
401 vlgvh\t%0,%v1,0
402 vleh\t%v0,%1,0
403 vsteh\t%v1,%0,0
404 vzero\t%v0
405 vone\t%v0
406 vgbm\t%v0,%r1
407 vgm\t%v0,%q1
408 vrepi\t%v0,%p1
409 lr\t%0,%1
410 mvhhi\t%0,0
411 mvhhi\t%0,-1
412 lhi\t%0,0
413 lhi\t%0,-1
414 lh\t%0,%1
415 lhy\t%0,%1
416 lhrl\t%0,%1
417 sth\t%1,%0
418 sthy\t%1,%0
419 sthrl\t%1,%0"
420 [(set_attr "op_type" "VRR,VRS,VRS,VRX,VRX,VRI,VRI,VRI,VRI,VRI,RR,SIL,SIL,RI,RI,RX,RXY,RIL,RX,RXY,RIL")])
421
422 (define_insn "mov<mode>"
423 [(set (match_operand:V_32 0 "nonimmediate_operand" "=f,f,f,R,T,v,v,d,v,R, f, v, v, v, v, v, Q, Q, d, d,d,d,d,d,R,T,b")
424 (match_operand:V_32 1 "general_operand" " f,R,T,f,f,v,d,v,R,v,j00,j00,jm1,jyy,jxx,jzz,j00,jm1,j00,jm1,b,d,R,T,d,d,d"))]
425 "TARGET_VX"
426 "@
427 ldr\t%v0,%v1
428 lde\t%0,%1
429 ley\t%0,%1
430 ste\t%1,%0
431 stey\t%1,%0
432 vlr\t%v0,%v1
433 vlvgf\t%v0,%1,0
434 vlgvf\t%0,%v1,0
435 vlef\t%v0,%1,0
436 vstef\t%1,%0,0
437 lzer\t%v0
438 vzero\t%v0
439 vone\t%v0
440 vgbm\t%v0,%r1
441 vgm\t%v0,%q1
442 vrepi\t%v0,%p1
443 mvhi\t%0,0
444 mvhi\t%0,-1
445 lhi\t%0,0
446 lhi\t%0,-1
447 lrl\t%0,%1
448 lr\t%0,%1
449 l\t%0,%1
450 ly\t%0,%1
451 st\t%1,%0
452 sty\t%1,%0
453 strl\t%1,%0"
454 [(set_attr "op_type" "RR,RXE,RXY,RX,RXY,VRR,VRS,VRS,VRX,VRX,RRE,VRI,VRI,VRI,VRI,VRI,SIL,SIL,RI,RI,
455 RIL,RR,RX,RXY,RX,RXY,RIL")])
456
457 (define_insn "mov<mode>"
458 [(set (match_operand:V_64 0 "nonimmediate_operand"
459 "=f,f,f,R,T,v,v,d,v,R, f, v, v, v, v, v, Q, Q, d, d,f,d,d,d,d,T,b")
460 (match_operand:V_64 1 "general_operand"
461 " f,R,T,f,f,v,d,v,R,v,j00,j00,jm1,jyy,jxx,jzz,j00,jm1,j00,jm1,d,f,b,d,T,d,d"))]
462 "TARGET_ZARCH"
463 "@
464 ldr\t%0,%1
465 ld\t%0,%1
466 ldy\t%0,%1
467 std\t%1,%0
468 stdy\t%1,%0
469 vlr\t%v0,%v1
470 vlvgg\t%v0,%1,0
471 vlgvg\t%0,%v1,0
472 vleg\t%v0,%1,0
473 vsteg\t%v1,%0,0
474 lzdr\t%0
475 vzero\t%v0
476 vone\t%v0
477 vgbm\t%v0,%r1
478 vgm\t%v0,%q1
479 vrepi\t%v0,%p1
480 mvghi\t%0,0
481 mvghi\t%0,-1
482 lghi\t%0,0
483 lghi\t%0,-1
484 ldgr\t%0,%1
485 lgdr\t%0,%1
486 lgrl\t%0,%1
487 lgr\t%0,%1
488 lg\t%0,%1
489 stg\t%1,%0
490 stgrl\t%1,%0"
491 [(set_attr "op_type" "RRE,RX,RXY,RX,RXY,VRR,VRS,VRS,VRX,VRX,RRE,VRI,VRI,VRI,VRI,VRI,
492 SIL,SIL,RI,RI,RRE,RRE,RIL,RR,RXY,RXY,RIL")])
493
494
495 ; vec_load_lanes?
496
497 ; vec_store_lanes?
498
499 ; vec_set is supposed to *modify* an existing vector so operand 0 is
500 ; duplicated as input operand.
501 (define_expand "vec_set<mode>"
502 [(set (match_operand:V 0 "register_operand" "")
503 (unspec:V [(match_operand:<non_vec> 1 "general_operand" "")
504 (match_operand:SI 2 "nonmemory_operand" "")
505 (match_dup 0)]
506 UNSPEC_VEC_SET))]
507 "TARGET_VX")
508
509 ; FIXME: Support also vector mode operands for 1
510 ; FIXME: A target memory operand seems to be useful otherwise we end
511 ; up with vl vlvgg vst. Shouldn't the middle-end be able to handle
512 ; that itself?
513 ; vlvgb, vlvgh, vlvgf, vlvgg, vleb, vleh, vlef, vleg, vleib, vleih, vleif, vleig
514 (define_insn "*vec_set<mode>"
515 [(set (match_operand:V 0 "register_operand" "=v,v,v")
516 (unspec:V [(match_operand:<non_vec> 1 "general_operand" "d,R,K")
517 (match_operand:SI 2 "nonmemory_operand" "an,I,I")
518 (match_operand:V 3 "register_operand" "0,0,0")]
519 UNSPEC_VEC_SET))]
520 "TARGET_VX
521 && (!CONST_INT_P (operands[2])
522 || UINTVAL (operands[2]) < GET_MODE_NUNITS (<V:MODE>mode))"
523 "@
524 vlvg<bhfgq>\t%v0,%1,%Y2
525 vle<bhfgq>\t%v0,%1,%2
526 vlei<bhfgq>\t%v0,%1,%2"
527 [(set_attr "op_type" "VRS,VRX,VRI")])
528
529 ; vlvgb, vlvgh, vlvgf, vlvgg
530 (define_insn "*vec_set<mode>_plus"
531 [(set (match_operand:V 0 "register_operand" "=v")
532 (unspec:V [(match_operand:<non_vec> 1 "general_operand" "d")
533 (plus:SI (match_operand:SI 2 "register_operand" "a")
534 (match_operand:SI 4 "const_int_operand" "n"))
535 (match_operand:V 3 "register_operand" "0")]
536 UNSPEC_VEC_SET))]
537 "TARGET_VX"
538 "vlvg<bhfgq>\t%v0,%1,%Y4(%2)"
539 [(set_attr "op_type" "VRS")])
540
541
542 ;; FIXME: Support also vector mode operands for 0
543 ;; This is used via RTL standard name as well as for expanding the builtin
544 (define_expand "vec_extract<mode><non_vec_l>"
545 [(set (match_operand:<non_vec> 0 "nonimmediate_operand" "")
546 (vec_select:<non_vec>
547 (match_operand:V 1 "register_operand" "")
548 (parallel
549 [(match_operand:SI 2 "nonmemory_operand" "")])))]
550 "TARGET_VX"
551 )
552
553 ; vlgvb, vlgvh, vlgvf, vlgvg, vsteb, vsteh, vstef, vsteg
554 (define_insn "*vec_extract<mode>"
555 [(set (match_operand:<non_vec> 0 "nonimmediate_operand" "=d,R")
556 (vec_select:<non_vec>
557 (match_operand:V 1 "nonmemory_operand" "v,v")
558 (parallel
559 [(match_operand:SI 2 "nonmemory_operand" "an,I")])))]
560 "TARGET_VX"
561 {
562 if (CONST_INT_P (operands[2]))
563 operands[2] = GEN_INT (UINTVAL (operands[2]) & (GET_MODE_NUNITS (<V:MODE>mode) - 1));
564 if (which_alternative == 0)
565 return "vlgv<bhfgq>\t%0,%v1,%Y2";
566 return "vste<bhfgq>\t%v1,%0,%2";
567 }
568 [(set_attr "op_type" "VRS,VRX")])
569
570 ; vlgvb, vlgvh, vlgvf, vlgvg
571 (define_insn "*vec_extract<mode>_plus"
572 [(set (match_operand:<non_vec> 0 "nonimmediate_operand" "=d")
573 (vec_select:<non_vec>
574 (match_operand:V 1 "register_operand" "v")
575 (plus:SI (match_operand:SI 2 "nonmemory_operand" "a")
576 (parallel [(match_operand:SI 3 "const_int_operand" "n")]))))]
577 "TARGET_VX"
578 "vlgv<bhfgq>\t%0,%v1,%Y3(%2)"
579 [(set_attr "op_type" "VRS")])
580
581 (define_expand "vec_init<mode><non_vec_l>"
582 [(match_operand:V_128 0 "register_operand" "")
583 (match_operand:V_128 1 "nonmemory_operand" "")]
584 "TARGET_VX"
585 {
586 s390_expand_vec_init (operands[0], operands[1]);
587 DONE;
588 })
589
590 (define_insn "*vec_vllezlf<mode>"
591 [(set (match_operand:V_HW_4 0 "register_operand" "=v")
592 (vec_concat:V_HW_4
593 (vec_concat:<vec_halfnumelts>
594 (match_operand:<non_vec> 1 "memory_operand" "R")
595 (const_int 0))
596 (vec_concat:<vec_halfnumelts>
597 (const_int 0)
598 (const_int 0))))]
599 "TARGET_VXE"
600 "vllezlf\t%v0,%1"
601 [(set_attr "op_type" "VRX")])
602
603 ; Replicate from vector element
604 ; vrepb, vreph, vrepf, vrepg
605 (define_insn "*vec_splat<mode>"
606 [(set (match_operand:V_128_NOSINGLE 0 "register_operand" "=v")
607 (vec_duplicate:V_128_NOSINGLE
608 (vec_select:<non_vec>
609 (match_operand:V_128_NOSINGLE 1 "register_operand" "v")
610 (parallel
611 [(match_operand:QI 2 "const_mask_operand" "C")]))))]
612 "TARGET_VX && UINTVAL (operands[2]) < GET_MODE_NUNITS (<MODE>mode)"
613 "vrep<bhfgq>\t%v0,%v1,%2"
614 [(set_attr "op_type" "VRI")])
615
616 ; vlrepb, vlreph, vlrepf, vlrepg, vrepib, vrepih, vrepif, vrepig, vrepb, vreph, vrepf, vrepg
617 (define_insn "*vec_splats<mode>"
618 [(set (match_operand:V_128_NOSINGLE 0 "register_operand" "=v,v,v,v")
619 (vec_duplicate:V_128_NOSINGLE (match_operand:<non_vec> 1 "general_operand" " R,K,v,d")))]
620 "TARGET_VX"
621 "@
622 vlrep<bhfgq>\t%v0,%1
623 vrepi<bhfgq>\t%v0,%h1
624 vrep<bhfgq>\t%v0,%v1,0
625 #"
626 [(set_attr "op_type" "VRX,VRI,VRI,*")])
627
628 ; vlbrreph, vlbrrepf, vlbrrepg
629 (define_insn "*vec_splats_bswap_vec<mode>"
630 [(set (match_operand:V_HW_HSD 0 "register_operand" "=v")
631 (bswap:V_HW_HSD
632 (vec_duplicate:V_HW_HSD (match_operand:<non_vec> 1 "memory_operand" "R"))))
633 (use (match_operand:V16QI 2 "permute_pattern_operand" "X"))]
634 "TARGET_VXE2"
635 "vlbrrep<bhfgq>\t%v0,%1"
636 [(set_attr "op_type" "VRX")])
637
638 ; Why do we need both? Shouldn't there be a canonical form?
639 ; vlbrreph, vlbrrepf, vlbrrepg
640 (define_insn "*vec_splats_bswap_elem<mode>"
641 [(set (match_operand:V_HW_HSD 0 "register_operand" "=v")
642 (vec_duplicate:V_HW_HSD
643 (bswap:<non_vec> (match_operand:<non_vec> 1 "memory_operand" "R"))))]
644 "TARGET_VXE2"
645 "vlbrrep<bhfgq>\t%v0,%1"
646 [(set_attr "op_type" "VRX")])
647
648 ; A TFmode operand resides in FPR register pairs while V1TF is in a
649 ; single vector register.
650 (define_insn "*vec_tf_to_v1tf_fpr"
651 [(set (match_operand:V1TF 0 "nonimmediate_operand" "=v,v,R,v,v")
652 (vec_duplicate:V1TF (match_operand:TF 1 "general_operand" "f,R,f,G,d")))]
653 "TARGET_VX && !TARGET_VXE"
654 "@
655 vmrhg\t%v0,%1,%N1
656 vl\t%v0,%1%A1
657 vst\t%v1,%0%A0
658 vzero\t%v0
659 vlvgp\t%v0,%1,%N1"
660 [(set_attr "op_type" "VRR,VRX,VRX,VRI,VRR")])
661
662 ; Both TFmode and V1TFmode operands reside in vector registers.
663 (define_insn "*vec_tf_to_v1tf_vr"
664 [(set (match_operand:V1TF 0 "nonimmediate_operand" "=v,v,R,v,v")
665 (vec_duplicate:V1TF (match_operand:TF 1 "general_operand" "v,R,v,G,d")))]
666 "TARGET_VXE"
667 "@
668 vlr\t%v0,%1
669 vl\t%v0,%1%A1
670 vst\t%v1,%0%A0
671 vzero\t%v0
672 vlvgp\t%v0,%1,%N1"
673 [(set_attr "op_type" "VRR,VRX,VRX,VRI,VRR")])
674
675 (define_insn_and_split "fprx2_to_tf"
676 [(set (match_operand:TF 0 "nonimmediate_operand" "=v,AR")
677 (subreg:TF (match_operand:FPRX2 1 "general_operand" "f,f") 0))]
678 "TARGET_VXE"
679 "@
680 vmrhg\t%v0,%1,%N1
681 #"
682 "!(MEM_P (operands[0]) && MEM_VOLATILE_P (operands[0]))"
683 [(set (match_dup 2) (match_dup 3))
684 (set (match_dup 4) (match_dup 5))]
685 {
686 operands[2] = simplify_gen_subreg (DFmode, operands[0], TFmode, 0);
687 operands[3] = simplify_gen_subreg (DFmode, operands[1], FPRX2mode, 0);
688 operands[4] = simplify_gen_subreg (DFmode, operands[0], TFmode, 8);
689 operands[5] = simplify_gen_subreg (DFmode, operands[1], FPRX2mode, 8);
690 }
691 [(set_attr "op_type" "VRR,*")])
692
693 (define_insn "*vec_ti_to_v1ti"
694 [(set (match_operand:V1TI 0 "nonimmediate_operand" "=v,v,R, v, v,v")
695 (vec_duplicate:V1TI (match_operand:TI 1 "general_operand" "v,R,v,j00,jm1,d")))]
696 "TARGET_VX"
697 "@
698 vlr\t%v0,%v1
699 vl\t%v0,%1%A1
700 vst\t%v1,%0%A0
701 vzero\t%v0
702 vone\t%v0
703 vlvgp\t%v0,%1,%N1"
704 [(set_attr "op_type" "VRR,VRX,VRX,VRI,VRI,VRR")])
705
706 ; vec_splats is supposed to replicate op1 into all elements of op0
707 ; This splitter first sets the rightmost element of op0 to op1 and
708 ; then does a vec_splat to replicate that element into all other
709 ; elements.
710 (define_split
711 [(set (match_operand:V_128_NOSINGLE 0 "register_operand" "")
712 (vec_duplicate:V_128_NOSINGLE (match_operand:<non_vec> 1 "register_operand" "")))]
713 "TARGET_VX && GENERAL_REG_P (operands[1])"
714 [(set (match_dup 0)
715 (unspec:V_128_NOSINGLE [(match_dup 1) (match_dup 2) (match_dup 0)] UNSPEC_VEC_SET))
716 (set (match_dup 0)
717 (vec_duplicate:V_128_NOSINGLE
718 (vec_select:<non_vec>
719 (match_dup 0) (parallel [(match_dup 2)]))))]
720 {
721 operands[2] = GEN_INT (GET_MODE_NUNITS (<MODE>mode) - 1);
722 })
723
724 (define_predicate "vcond_comparison_operator"
725 (match_operand 0 "comparison_operator")
726 {
727 if (!HONOR_NANS (GET_MODE (XEXP (op, 0)))
728 && !HONOR_NANS (GET_MODE (XEXP (op, 1))))
729 return true;
730 switch (GET_CODE (op))
731 {
732 case LE:
733 case LT:
734 case GE:
735 case GT:
736 case LTGT:
737 /* Signaling vector comparisons are supported only on z14+. */
738 return TARGET_VXE || TARGET_NONSIGNALING_VECTOR_COMPARE_OK;
739 default:
740 return true;
741 }
742 })
743
744 (define_expand "vcond_mask_<mode><tointvec>"
745 [(set (match_operand:VT 0 "register_operand" "")
746 (if_then_else:VT
747 (eq (match_operand:<TOINTVEC> 3 "register_operand" "")
748 (match_dup 4))
749 (match_operand:VT 2 "register_operand" "")
750 (match_operand:VT 1 "register_operand" "")))]
751 "TARGET_VX"
752 "operands[4] = CONST0_RTX (<TOINTVEC>mode);")
753
754
755 ; We only have HW support for byte vectors. The middle-end is
756 ; supposed to lower the mode if required.
757 (define_insn "vec_permv16qi"
758 [(set (match_operand:V16QI 0 "register_operand" "=v")
759 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
760 (match_operand:V16QI 2 "register_operand" "v")
761 (match_operand:V16QI 3 "register_operand" "v")]
762 UNSPEC_VEC_PERM))]
763 "TARGET_VX"
764 "vperm\t%v0,%v1,%v2,%v3"
765 [(set_attr "op_type" "VRR")])
766
767 (define_insn "*vec_perm<mode>"
768 [(set (match_operand:VT_HW 0 "register_operand" "=v")
769 (subreg:VT_HW (unspec:V16QI [(subreg:V16QI (match_operand:VT_HW 1 "register_operand" "v") 0)
770 (subreg:V16QI (match_operand:VT_HW 2 "register_operand" "v") 0)
771 (match_operand:V16QI 3 "register_operand" "v")]
772 UNSPEC_VEC_PERM) 0))]
773 "TARGET_VX"
774 "vperm\t%v0,%v1,%v2,%v3"
775 [(set_attr "op_type" "VRR")])
776
777
778 ; First DW of op1 and second DW of op2
779 (define_insn "@vpdi1<mode>"
780 [(set (match_operand:V_HW_2 0 "register_operand" "=v")
781 (vec_select:V_HW_2
782 (vec_concat:<vec_2x_nelts>
783 (match_operand:V_HW_2 1 "register_operand" "v")
784 (match_operand:V_HW_2 2 "register_operand" "v"))
785 (parallel [(const_int 0) (const_int 3)])))]
786 "TARGET_VX"
787 "vpdi\t%v0,%v1,%v2,1"
788 [(set_attr "op_type" "VRR")])
789
790 ; Second DW of op1 and first of op2
791 (define_insn "@vpdi4<mode>"
792 [(set (match_operand:V_HW_2 0 "register_operand" "=v")
793 (vec_select:V_HW_2
794 (vec_concat:<vec_2x_nelts>
795 (match_operand:V_HW_2 1 "register_operand" "v")
796 (match_operand:V_HW_2 2 "register_operand" "v"))
797 (parallel [(const_int 1) (const_int 2)])))]
798 "TARGET_VX"
799 "vpdi\t%v0,%v1,%v2,4"
800 [(set_attr "op_type" "VRR")])
801
802 ; Second DW of op1 and first DW of op2 (when interpreted as 2-element vector).
803 (define_insn "@vpdi4_2<mode>"
804 [(set (match_operand:V_HW_4 0 "register_operand" "=v")
805 (vec_select:V_HW_4
806 (vec_concat:<vec_2x_nelts>
807 (match_operand:V_HW_4 1 "register_operand" "v")
808 (match_operand:V_HW_4 2 "register_operand" "v"))
809 (parallel [(const_int 2) (const_int 3) (const_int 4) (const_int 5)])))]
810 "TARGET_VX"
811 "vpdi\t%v0,%v1,%v2,4"
812 [(set_attr "op_type" "VRR")])
813
814 (define_insn "*vmrhb"
815 [(set (match_operand:V16QI 0 "register_operand" "=v")
816 (vec_select:V16QI
817 (vec_concat:V32QI (match_operand:V16QI 1 "register_operand" "v")
818 (match_operand:V16QI 2 "register_operand" "v"))
819 (parallel [(const_int 0) (const_int 16)
820 (const_int 1) (const_int 17)
821 (const_int 2) (const_int 18)
822 (const_int 3) (const_int 19)
823 (const_int 4) (const_int 20)
824 (const_int 5) (const_int 21)
825 (const_int 6) (const_int 22)
826 (const_int 7) (const_int 23)])))]
827 "TARGET_VX"
828 "vmrhb\t%0,%1,%2";
829 [(set_attr "op_type" "VRR")])
830
831 (define_insn "*vmrlb"
832 [(set (match_operand:V16QI 0 "register_operand" "=v")
833 (vec_select:V16QI
834 (vec_concat:V32QI (match_operand:V16QI 1 "register_operand" "v")
835 (match_operand:V16QI 2 "register_operand" "v"))
836 (parallel [(const_int 8) (const_int 24)
837 (const_int 9) (const_int 25)
838 (const_int 10) (const_int 26)
839 (const_int 11) (const_int 27)
840 (const_int 12) (const_int 28)
841 (const_int 13) (const_int 29)
842 (const_int 14) (const_int 30)
843 (const_int 15) (const_int 31)])))]
844 "TARGET_VX"
845 "vmrlb\t%0,%1,%2";
846 [(set_attr "op_type" "VRR")])
847
848 (define_insn "*vmrhh"
849 [(set (match_operand:V8HI 0 "register_operand" "=v")
850 (vec_select:V8HI
851 (vec_concat:V16HI (match_operand:V8HI 1 "register_operand" "v")
852 (match_operand:V8HI 2 "register_operand" "v"))
853 (parallel [(const_int 0) (const_int 8)
854 (const_int 1) (const_int 9)
855 (const_int 2) (const_int 10)
856 (const_int 3) (const_int 11)])))]
857 "TARGET_VX"
858 "vmrhh\t%0,%1,%2";
859 [(set_attr "op_type" "VRR")])
860
861 (define_insn "*vmrlh"
862 [(set (match_operand:V8HI 0 "register_operand" "=v")
863 (vec_select:V8HI
864 (vec_concat:V16HI (match_operand:V8HI 1 "register_operand" "v")
865 (match_operand:V8HI 2 "register_operand" "v"))
866 (parallel [(const_int 4) (const_int 12)
867 (const_int 5) (const_int 13)
868 (const_int 6) (const_int 14)
869 (const_int 7) (const_int 15)])))]
870 "TARGET_VX"
871 "vmrlh\t%0,%1,%2";
872 [(set_attr "op_type" "VRR")])
873
874 (define_insn "*vmrhf"
875 [(set (match_operand:V_HW_4 0 "register_operand" "=v")
876 (vec_select:V_HW_4
877 (vec_concat:<vec_2x_nelts> (match_operand:V_HW_4 1 "register_operand" "v")
878 (match_operand:V_HW_4 2 "register_operand" "v"))
879 (parallel [(const_int 0) (const_int 4)
880 (const_int 1) (const_int 5)])))]
881 "TARGET_VX"
882 "vmrhf\t%0,%1,%2";
883 [(set_attr "op_type" "VRR")])
884
885 (define_insn "*vmrhf_half<mode>"
886 [(set (match_operand:V_HW_4 0 "register_operand" "=v")
887 (vec_select:V_HW_4
888 (vec_concat:V_HW_4 (match_operand:<vec_halfnumelts> 1 "register_operand" "v")
889 (match_operand:<vec_halfnumelts> 2 "register_operand" "v"))
890 (parallel [(const_int 0) (const_int 2)
891 (const_int 1) (const_int 3)])))]
892 "TARGET_VX"
893 "vmrhf\t%0,%1,%2";
894 [(set_attr "op_type" "VRR")])
895
896 (define_insn "*vmrlf"
897 [(set (match_operand:V_HW_4 0 "register_operand" "=v")
898 (vec_select:V_HW_4
899 (vec_concat:<vec_2x_nelts> (match_operand:V_HW_4 1 "register_operand" "v")
900 (match_operand:V_HW_4 2 "register_operand" "v"))
901 (parallel [(const_int 2) (const_int 6)
902 (const_int 3) (const_int 7)])))]
903 "TARGET_VX"
904 "vmrlf\t%0,%1,%2";
905 [(set_attr "op_type" "VRR")])
906
907 (define_insn "*vmrhg"
908 [(set (match_operand:V_HW_2 0 "register_operand" "=v")
909 (vec_select:V_HW_2
910 (vec_concat:<vec_2x_nelts> (match_operand:V_HW_2 1 "register_operand" "v")
911 (match_operand:V_HW_2 2 "register_operand" "v"))
912 (parallel [(const_int 0) (const_int 2)])))]
913 "TARGET_VX"
914 "vmrhg\t%0,%1,%2";
915 [(set_attr "op_type" "VRR")])
916
917 (define_insn "*vmrlg"
918 [(set (match_operand:V_HW_2 0 "register_operand" "=v")
919 (vec_select:V_HW_2
920 (vec_concat:<vec_2x_nelts> (match_operand:V_HW_2 1 "register_operand" "v")
921 (match_operand:V_HW_2 2 "register_operand" "v"))
922 (parallel [(const_int 1) (const_int 3)])))]
923 "TARGET_VX"
924 "vmrlg\t%0,%1,%2";
925 [(set_attr "op_type" "VRR")])
926
927 (define_insn "tf_to_fprx2"
928 [(set (match_operand:FPRX2 0 "register_operand" "=f,f ,f")
929 (unspec:FPRX2 [(match_operand:TF 1 "general_operand" "v,AR,AT")]
930 UNSPEC_TF_TO_FPRX2))]
931 "TARGET_VXE"
932 {
933 char buf[64];
934 const char *reg_pair = reg_names[REGNO (operands[0]) + 1];
935 switch (which_alternative)
936 {
937 case 0:
938 if (REGNO (operands[0]) == REGNO (operands[1]))
939 {
940 reg_pair += 2; // get rid of prefix %f
941 snprintf (buf, sizeof (buf), "vpdi\t%%%%v%s,%%v1,%%%%v%s,5", reg_pair, reg_pair);
942 output_asm_insn (buf, operands);
943 return "";
944 }
945 else
946 {
947 reg_pair += 2; // get rid of prefix %f
948 snprintf (buf, sizeof (buf), "ldr\t%%f0,%%f1;vpdi\t%%%%v%s,%%v1,%%%%v%s,5", reg_pair, reg_pair);
949 output_asm_insn (buf, operands);
950 return "";
951 }
952 case 1:
953 {
954 snprintf (buf, sizeof (buf), "ld\t%%f0,%%1;ld\t%%%s,8+%%1", reg_pair);
955 output_asm_insn (buf, operands);
956 return "";
957 }
958 case 2:
959 {
960 snprintf (buf, sizeof (buf), "ldy\t%%f0,%%1;ldy\t%%%s,8+%%1", reg_pair);
961 output_asm_insn (buf, operands);
962 return "";
963 }
964 default: gcc_unreachable ();
965 }
966 })
967
968 ;; VECTOR REVERSE ELEMENTS V16QI
969
970 (define_expand "eltswapv16qi"
971 [(parallel
972 [(set (match_operand:V16QI 0 "nonimmediate_operand")
973 (vec_select:V16QI
974 (match_operand:V16QI 1 "nonimmediate_operand")
975 (match_dup 2)))
976 (use (match_dup 3))])]
977 "TARGET_VX"
978 {
979 rtvec vec = rtvec_alloc (16);
980 for (int i = 0; i < 16; ++i)
981 RTVEC_ELT (vec, i) = GEN_INT (15 - i);
982 operands[2] = gen_rtx_PARALLEL (VOIDmode, vec);
983 operands[3] = gen_rtx_CONST_VECTOR (V16QImode, vec);
984 })
985
986 (define_insn_and_split "*eltswapv16qi"
987 [(set (match_operand:V16QI 0 "nonimmediate_operand" "=v,^R,^v")
988 (vec_select:V16QI
989 (match_operand:V16QI 1 "nonimmediate_operand" "v,^v,^R")
990 (parallel [(const_int 15)
991 (const_int 14)
992 (const_int 13)
993 (const_int 12)
994 (const_int 11)
995 (const_int 10)
996 (const_int 9)
997 (const_int 8)
998 (const_int 7)
999 (const_int 6)
1000 (const_int 5)
1001 (const_int 4)
1002 (const_int 3)
1003 (const_int 2)
1004 (const_int 1)
1005 (const_int 0)])))
1006 (use (match_operand:V16QI 2 "permute_pattern_operand" "v,X,X"))]
1007 "TARGET_VX"
1008 "@
1009 #
1010 vstbrq\t%v1,%0
1011 vlbrq\t%v0,%1"
1012 "&& reload_completed && REG_P (operands[0]) && REG_P (operands[1])"
1013 [(set (match_dup 0)
1014 (unspec:V16QI [(match_dup 1)
1015 (match_dup 1)
1016 (match_dup 2)]
1017 UNSPEC_VEC_PERM))]
1018 ""
1019 [(set_attr "cpu_facility" "*,vxe2,vxe2")
1020 (set_attr "op_type" "*,VRX,VRX")])
1021
1022 ;; VECTOR REVERSE ELEMENTS V8HI
1023
1024 (define_insn_and_split "eltswapv8hi"
1025 [(set (match_operand:V8HI 0 "nonimmediate_operand" "=v,R,v")
1026 (vec_select:V8HI
1027 (match_operand:V8HI 1 "nonimmediate_operand" "v,v,R")
1028 (parallel [(const_int 7)
1029 (const_int 6)
1030 (const_int 5)
1031 (const_int 4)
1032 (const_int 3)
1033 (const_int 2)
1034 (const_int 1)
1035 (const_int 0)])))
1036 (clobber (match_scratch:V2DI 2 "=&v,X,X"))
1037 (clobber (match_scratch:V4SI 3 "=&v,X,X"))]
1038 "TARGET_VX"
1039 "@
1040 #
1041 vsterh\t%v1,%0
1042 vlerh\t%v0,%1"
1043 "&& reload_completed && REG_P (operands[0]) && REG_P (operands[1])"
1044 [(set (match_dup 2)
1045 (subreg:V2DI (match_dup 1) 0))
1046 (set (match_dup 2)
1047 (vec_select:V2DI
1048 (match_dup 2)
1049 (parallel [(const_int 1) (const_int 0)])))
1050 (set (match_dup 2)
1051 (rotate:V2DI
1052 (match_dup 2)
1053 (const_int 32)))
1054 (set (match_dup 3)
1055 (subreg:V4SI (match_dup 2) 0))
1056 (set (match_dup 3)
1057 (rotate:V4SI
1058 (match_dup 3)
1059 (const_int 16)))
1060 (set (match_dup 0)
1061 (subreg:V8HI (match_dup 3) 0))]
1062 ""
1063 [(set_attr "cpu_facility" "*,vxe2,vxe2")
1064 (set_attr "op_type" "*,VRX,VRX")])
1065
1066 ;; VECTOR REVERSE ELEMENTS V4SI / V4SF
1067
1068 (define_insn_and_split "eltswap<mode>"
1069 [(set (match_operand:V_HW_4 0 "nonimmediate_operand" "=v,R,v")
1070 (vec_select:V_HW_4
1071 (match_operand:V_HW_4 1 "nonimmediate_operand" "v,v,R")
1072 (parallel [(const_int 3)
1073 (const_int 2)
1074 (const_int 1)
1075 (const_int 0)])))
1076 (clobber (match_scratch:V2DI 2 "=&v,X,X"))]
1077 "TARGET_VX"
1078 "@
1079 #
1080 vsterf\t%v1,%0
1081 vlerf\t%v0,%1"
1082 "&& reload_completed && REG_P (operands[0]) && REG_P (operands[1])"
1083 [(set (match_dup 2)
1084 (subreg:V2DI (match_dup 1) 0))
1085 (set (match_dup 2)
1086 (vec_select:V2DI
1087 (match_dup 2)
1088 (parallel [(const_int 1) (const_int 0)])))
1089 (set (match_dup 2)
1090 (rotate:V2DI
1091 (match_dup 2)
1092 (const_int 32)))
1093 (set (match_dup 0)
1094 (subreg:V_HW_4 (match_dup 2) 0))]
1095 ""
1096 [(set_attr "cpu_facility" "*,vxe2,vxe2")
1097 (set_attr "op_type" "*,VRX,VRX")])
1098
1099 ;; VECTOR REVERSE ELEMENTS V2DI / V2DF
1100
1101 (define_insn "eltswap<mode>"
1102 [(set (match_operand:V_HW_2 0 "nonimmediate_operand" "=v,R,v")
1103 (vec_select:V_HW_2
1104 (match_operand:V_HW_2 1 "nonimmediate_operand" "v,v,R")
1105 (parallel [(const_int 1)
1106 (const_int 0)])))]
1107 "TARGET_VX"
1108 "@
1109 vpdi\t%v0,%v1,%v1,4
1110 vsterg\t%v1,%0
1111 vlerg\t%v0,%1"
1112 [(set_attr "cpu_facility" "vx,vxe2,vxe2")
1113 (set_attr "op_type" "VRR,VRX,VRX")])
1114
1115 ;;
1116 ;; Vector integer arithmetic instructions
1117 ;;
1118
1119 ; vab, vah, vaf, vag, vaq
1120
1121 ; We use nonimmediate_operand instead of register_operand since it is
1122 ; better to have the reloads into VRs instead of splitting the
1123 ; operation into two DImode ADDs.
1124 (define_insn "<ti*>add<mode>3"
1125 [(set (match_operand:VIT 0 "nonimmediate_operand" "=v")
1126 (plus:VIT (match_operand:VIT 1 "nonimmediate_operand" "v")
1127 (match_operand:VIT 2 "general_operand" "v")))]
1128 "TARGET_VX"
1129 "va<bhfgq>\t%v0,%v1,%v2"
1130 [(set_attr "op_type" "VRR")])
1131
1132 ; vsb, vsh, vsf, vsg, vsq
1133 (define_insn "<ti*>sub<mode>3"
1134 [(set (match_operand:VIT 0 "nonimmediate_operand" "=v")
1135 (minus:VIT (match_operand:VIT 1 "nonimmediate_operand" "v")
1136 (match_operand:VIT 2 "general_operand" "v")))]
1137 "TARGET_VX"
1138 "vs<bhfgq>\t%v0,%v1,%v2"
1139 [(set_attr "op_type" "VRR")])
1140
1141 ; vmlb, vmlhw, vmlf, vmlg, vmlq
1142 (define_insn "mul<mode>3"
1143 [(set (match_operand:VIT_HW_VXE3_DT 0 "register_operand" "=v")
1144 (mult:VIT_HW_VXE3_DT (match_operand:VIT_HW_VXE3_DT 1 "register_operand" "v")
1145 (match_operand:VIT_HW_VXE3_DT 2 "register_operand" "v")))]
1146 "TARGET_VX"
1147 "vml<bhfgq><w>\t%v0,%v1,%v2"
1148 [(set_attr "op_type" "VRR")])
1149
1150 ; vdf, vdg, vdq
1151 (define_insn "div<mode>3"
1152 [(set (match_operand:VI_HW_SDT 0 "register_operand" "=v")
1153 (div:VI_HW_SDT (match_operand:VI_HW_SDT 1 "register_operand" "v")
1154 (match_operand:VI_HW_SDT 2 "register_operand" "v")))]
1155 "TARGET_VXE3"
1156 "vd<bhfgq>\t%v0,%v1,%v2,0"
1157 [(set_attr "op_type" "VRR")])
1158
1159 ; vdlf, vdlg, vdlq
1160 (define_insn "udiv<mode>3"
1161 [(set (match_operand:VI_HW_SDT 0 "register_operand" "=v")
1162 (udiv:VI_HW_SDT (match_operand:VI_HW_SDT 1 "register_operand" "v")
1163 (match_operand:VI_HW_SDT 2 "register_operand" "v")))]
1164 "TARGET_VXE3"
1165 "vdl<bhfgq>\t%v0,%v1,%v2,0"
1166 [(set_attr "op_type" "VRR")])
1167
1168 ; vrf, vrg, vrq
1169 (define_insn "mod<mode>3"
1170 [(set (match_operand:VI_HW_SDT 0 "register_operand" "=v")
1171 (mod:VI_HW_SDT (match_operand:VI_HW_SDT 1 "register_operand" "v")
1172 (match_operand:VI_HW_SDT 2 "register_operand" "v")))]
1173 "TARGET_VXE3"
1174 "vr<bhfgq>\t%v0,%v1,%v2,0"
1175 [(set_attr "op_type" "VRR")])
1176
1177 ; vrlf, vrlg, vrlq
1178 (define_insn "umod<mode>3"
1179 [(set (match_operand:VI_HW_SDT 0 "register_operand" "=v")
1180 (umod:VI_HW_SDT (match_operand:VI_HW_SDT 1 "register_operand" "v")
1181 (match_operand:VI_HW_SDT 2 "register_operand" "v")))]
1182 "TARGET_VXE3"
1183 "vrl<bhfgq>\t%v0,%v1,%v2,0"
1184 [(set_attr "op_type" "VRR")])
1185
1186 ; vlcb, vlch, vlcf, vlcg
1187 (define_insn "neg<mode>2"
1188 [(set (match_operand:VI 0 "register_operand" "=v")
1189 (neg:VI (match_operand:VI 1 "register_operand" "v")))]
1190 "TARGET_VX"
1191 "vlc<bhfgq>\t%v0,%v1"
1192 [(set_attr "op_type" "VRR")])
1193
1194 (define_expand "abs<mode>2"
1195 [(set (match_operand:VIT 0 "register_operand" "=v")
1196 (abs:VIT (match_operand:VIT 1 "register_operand" "v")))]
1197 "TARGET_VX"
1198 {
1199 // Emulate via vec_sel (op1, -op1, op1 < 0)
1200 if ((<MODE>mode == V1TImode || <MODE>mode == TImode) && !TARGET_VXE3)
1201 {
1202 rtx zero = gen_reg_rtx (<MODE>mode);
1203 rtx neg_op1 = gen_reg_rtx (<MODE>mode);
1204 rtx lt = gen_reg_rtx (<MODE>mode);
1205 emit_move_insn (zero, GEN_INT (0));
1206 emit_move_insn (neg_op1, gen_rtx_MINUS (<MODE>mode, zero, operands[1]));
1207 s390_expand_vec_compare (lt, LT, operands[1], zero);
1208 emit_insn (gen_vec_sel0<mode> (operands[0], operands[1], neg_op1, lt, GEN_INT (0)));
1209 DONE;
1210 }
1211 })
1212
1213 ; vlpb, vlph, vlpf, vlpg, vlpq
1214 (define_insn "*abs<mode>2"
1215 [(set (match_operand:VIT_VXE3 0 "register_operand" "=v")
1216 (abs:VIT_VXE3 (match_operand:VIT_VXE3 1 "register_operand" "v")))]
1217 "TARGET_VX"
1218 "vlp<bhfgq>\t%v0,%v1"
1219 [(set_attr "op_type" "VRR")])
1220
1221
1222 ; Vector sum across
1223
1224 ; Sum across DImode parts of the 1st operand and add the rightmost
1225 ; element of 2nd operand
1226 ; vsumgh, vsumgf
1227 (define_insn "*vec_sum2<mode>"
1228 [(set (match_operand:V2DI 0 "register_operand" "=v")
1229 (unspec:V2DI [(match_operand:VI_HW_HS 1 "register_operand" "v")
1230 (match_operand:VI_HW_HS 2 "register_operand" "v")]
1231 UNSPEC_VEC_VSUMG))]
1232 "TARGET_VX"
1233 "vsumg<bhfgq>\t%v0,%v1,%v2"
1234 [(set_attr "op_type" "VRR")])
1235
1236 ; vsumb, vsumh
1237 (define_insn "*vec_sum4<mode>"
1238 [(set (match_operand:V4SI 0 "register_operand" "=v")
1239 (unspec:V4SI [(match_operand:VI_HW_QH 1 "register_operand" "v")
1240 (match_operand:VI_HW_QH 2 "register_operand" "v")]
1241 UNSPEC_VEC_VSUM))]
1242 "TARGET_VX"
1243 "vsum<bhfgq>\t%v0,%v1,%v2"
1244 [(set_attr "op_type" "VRR")])
1245
1246 ;;
1247 ;; Vector bit instructions (int + fp)
1248 ;;
1249
1250 ; Vector and
1251
1252 (define_insn "and<mode>3"
1253 [(set (match_operand:VT 0 "register_operand" "=v")
1254 (and:VT (match_operand:VT 1 "register_operand" "v")
1255 (match_operand:VT 2 "register_operand" "v")))]
1256 "TARGET_VX"
1257 "vn\t%v0,%v1,%v2"
1258 [(set_attr "op_type" "VRR")])
1259
1260 ; Vector not and
1261
1262 (define_insn "notand<mode>3"
1263 [(set (match_operand:VT 0 "register_operand" "=v")
1264 (ior:VT (not:VT (match_operand:VT 1 "register_operand" "v"))
1265 (not:VT (match_operand:VT 2 "register_operand" "v"))))]
1266 "TARGET_VXE"
1267 "vnn\t%v0,%v1,%v2"
1268 [(set_attr "op_type" "VRR")])
1269
1270 ; Vector or
1271
1272 (define_insn "ior<mode>3"
1273 [(set (match_operand:VT 0 "register_operand" "=v")
1274 (ior:VT (match_operand:VT 1 "register_operand" "v")
1275 (match_operand:VT 2 "register_operand" "v")))]
1276 "TARGET_VX"
1277 "vo\t%v0,%v1,%v2"
1278 [(set_attr "op_type" "VRR")])
1279
1280 ; Vector or with complement
1281
1282 (define_insn "ior_not<mode>3"
1283 [(set (match_operand:VT 0 "register_operand" "=v")
1284 (ior:VT (not:VT (match_operand:VT 2 "register_operand" "v"))
1285 (match_operand:VT 1 "register_operand" "v")))]
1286 "TARGET_VXE"
1287 "voc\t%v0,%v1,%v2"
1288 [(set_attr "op_type" "VRR")])
1289
1290 ; Vector xor
1291
1292 (define_insn "xor<mode>3"
1293 [(set (match_operand:VT 0 "register_operand" "=v")
1294 (xor:VT (match_operand:VT 1 "register_operand" "v")
1295 (match_operand:VT 2 "register_operand" "v")))]
1296 "TARGET_VX"
1297 "vx\t%v0,%v1,%v2"
1298 [(set_attr "op_type" "VRR")])
1299
1300 ; Vector not xor
1301
1302 (define_insn "notxor<mode>3"
1303 [(set (match_operand:VT 0 "register_operand" "=v")
1304 (not:VT (xor:VT (match_operand:VT 1 "register_operand" "v")
1305 (match_operand:VT 2 "register_operand" "v"))))]
1306 "TARGET_VXE"
1307 "vnx\t%v0,%v1,%v2"
1308 [(set_attr "op_type" "VRR")])
1309
1310 ; Bitwise inversion of a vector
1311 (define_insn "one_cmpl<mode>2"
1312 [(set (match_operand:VT 0 "register_operand" "=v")
1313 (not:VT (match_operand:VT 1 "register_operand" "v")))]
1314 "TARGET_VX"
1315 "vnot\t%v0,%v1"
1316 [(set_attr "op_type" "VRR")])
1317
1318 ; Vector population count
1319
1320 (define_expand "popcount<mode>2"
1321 [(set (match_operand:VI_HW 0 "register_operand" "=v")
1322 (unspec:VI_HW [(match_operand:VI_HW 1 "register_operand" "v")]
1323 UNSPEC_POPCNT))]
1324 "TARGET_VX"
1325 {
1326 if (TARGET_VXE)
1327 emit_insn (gen_popcount<mode>2_vxe (operands[0], operands[1]));
1328 else
1329 emit_insn (gen_popcount<mode>2_vx (operands[0], operands[1]));
1330 DONE;
1331 })
1332
1333 ; vpopctb, vpopcth, vpopctf, vpopctg
1334 (define_insn "popcount<mode>2_vxe"
1335 [(set (match_operand:VI_HW 0 "register_operand" "=v")
1336 (unspec:VI_HW [(match_operand:VI_HW 1 "register_operand" "v")]
1337 UNSPEC_POPCNT))]
1338 "TARGET_VXE"
1339 "vpopct<bhfgq>\t%v0,%v1"
1340 [(set_attr "op_type" "VRR")])
1341
1342 (define_insn "popcountv16qi2_vx"
1343 [(set (match_operand:V16QI 0 "register_operand" "=v")
1344 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")]
1345 UNSPEC_POPCNT))]
1346 "TARGET_VX && !TARGET_VXE"
1347 "vpopct\t%v0,%v1,0"
1348 [(set_attr "op_type" "VRR")])
1349
1350 ; vpopct only counts bits in byte elements. Bigger element sizes need
1351 ; to be emulated. Word and doubleword elements can use the sum across
1352 ; instructions. For halfword sized elements we do a shift of a copy
1353 ; of the result, add it to the result and extend it to halfword
1354 ; element size (unpack).
1355
1356 (define_expand "popcountv8hi2_vx"
1357 [(set (match_dup 2)
1358 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")]
1359 UNSPEC_POPCNT))
1360 ; Make a copy of the result
1361 (set (match_dup 3) (match_dup 2))
1362 ; Generate the shift count operand in a VR (8->byte 7)
1363 (set (match_dup 4) (match_dup 5))
1364 (set (match_dup 4) (unspec:V16QI [(const_int 8)
1365 (const_int 7)
1366 (match_dup 4)] UNSPEC_VEC_SET))
1367 ; Vector shift right logical by one byte
1368 (set (match_dup 3)
1369 (unspec:V16QI [(match_dup 3) (match_dup 4)] UNSPEC_VEC_SRLB))
1370 ; Add the shifted and the original result
1371 (set (match_dup 2)
1372 (plus:V16QI (match_dup 2) (match_dup 3)))
1373 ; Generate mask for the odd numbered byte elements
1374 (set (match_dup 3)
1375 (const_vector:V16QI [(const_int 0) (const_int -1)
1376 (const_int 0) (const_int -1)
1377 (const_int 0) (const_int -1)
1378 (const_int 0) (const_int -1)
1379 (const_int 0) (const_int -1)
1380 (const_int 0) (const_int -1)
1381 (const_int 0) (const_int -1)
1382 (const_int 0) (const_int -1)]))
1383 ; Zero out the even indexed bytes
1384 (set (match_operand:V8HI 0 "register_operand" "=v")
1385 (and:V8HI (subreg:V8HI (match_dup 2) 0)
1386 (subreg:V8HI (match_dup 3) 0)))
1387 ]
1388 "TARGET_VX && !TARGET_VXE"
1389 {
1390 operands[1] = simplify_gen_subreg (V16QImode, operands[1],
1391 V8HImode, 0);
1392 operands[2] = gen_reg_rtx (V16QImode);
1393 operands[3] = gen_reg_rtx (V16QImode);
1394 operands[4] = gen_reg_rtx (V16QImode);
1395 operands[5] = CONST0_RTX (V16QImode);
1396 })
1397
1398 (define_expand "popcountv4si2_vx"
1399 [(set (match_dup 2)
1400 (unspec:V16QI [(match_operand:V4SI 1 "register_operand" "v")]
1401 UNSPEC_POPCNT))
1402 (set (match_operand:V4SI 0 "register_operand" "=v")
1403 (unspec:V4SI [(match_dup 2) (match_dup 3)]
1404 UNSPEC_VEC_VSUM))]
1405 "TARGET_VX && !TARGET_VXE"
1406 {
1407 operands[1] = simplify_gen_subreg (V16QImode, operands[1], V4SImode, 0);
1408 operands[2] = gen_reg_rtx (V16QImode);
1409 operands[3] = force_reg (V16QImode, CONST0_RTX (V16QImode));
1410 })
1411
1412 (define_expand "popcountv2di2_vx"
1413 [(set (match_dup 2)
1414 (unspec:V16QI [(match_operand:V2DI 1 "register_operand" "v")]
1415 UNSPEC_POPCNT))
1416 (set (match_dup 3)
1417 (unspec:V4SI [(match_dup 2) (match_dup 4)]
1418 UNSPEC_VEC_VSUM))
1419 (set (match_operand:V2DI 0 "register_operand" "=v")
1420 (unspec:V2DI [(match_dup 3) (match_dup 5)]
1421 UNSPEC_VEC_VSUMG))]
1422 "TARGET_VX && !TARGET_VXE"
1423 {
1424 operands[1] = simplify_gen_subreg (V16QImode, operands[1], V2DImode, 0);
1425 operands[2] = gen_reg_rtx (V16QImode);
1426 operands[3] = gen_reg_rtx (V4SImode);
1427 operands[4] = force_reg (V16QImode, CONST0_RTX (V16QImode));
1428 operands[5] = force_reg (V4SImode, CONST0_RTX (V4SImode));
1429 })
1430
1431 ; Count leading zeros
1432 ; vclzb, vclzh, vclzf, vclzg, vclzq
1433 (define_insn "clz<mode>2"
1434 [(set (match_operand:VT_VXE3 0 "register_operand" "=v")
1435 (clz:VT_VXE3 (match_operand:VT_VXE3 1 "register_operand" "v")))]
1436 "TARGET_VX"
1437 "vclz<bhfgq>\t%v0,%v1"
1438 [(set_attr "op_type" "VRR")])
1439
1440 ; Count trailing zeros
1441 ; vctzb, vctzh, vctzf, vctzg, vctzq
1442 (define_insn "ctz<mode>2"
1443 [(set (match_operand:VT_VXE3 0 "register_operand" "=v")
1444 (ctz:VT_VXE3 (match_operand:VT_VXE3 1 "register_operand" "v")))]
1445 "TARGET_VX"
1446 "vctz<bhfgq>\t%v0,%v1"
1447 [(set_attr "op_type" "VRR")])
1448
1449
1450
1451 ; Each vector element rotated by the corresponding vector element
1452 ; verllvb, verllvh, verllvf, verllvg
1453 (define_insn "vrotl<mode>3"
1454 [(set (match_operand:VI 0 "register_operand" "=v")
1455 (rotate:VI (match_operand:VI 1 "register_operand" "v")
1456 (match_operand:VI 2 "register_operand" "v")))]
1457 "TARGET_VX"
1458 "verllv<bhfgq>\t%v0,%v1,%v2"
1459 [(set_attr "op_type" "VRR")])
1460
1461
1462 ; Vector rotate and shift by scalar instructions
1463
1464 (define_code_iterator VEC_SHIFTS [ashift ashiftrt lshiftrt rotate])
1465 (define_code_attr vec_shifts_name [(ashift "ashl") (ashiftrt "ashr")
1466 (lshiftrt "lshr") (rotate "rotl")])
1467 (define_code_attr vec_shifts_mnem [(ashift "vesl") (ashiftrt "vesra")
1468 (lshiftrt "vesrl") (rotate "verll")])
1469
1470 ; Each vector element rotated by a scalar
1471 (define_expand "<vec_shifts_name><mode>3"
1472 [(set (match_operand:VIT 0 "register_operand" "")
1473 (VEC_SHIFTS:VIT (match_operand:VIT 1 "register_operand" "")
1474 (match_operand:QI 2 "shift_count_operand" "")))]
1475 "TARGET_VX && ((<MODE>mode != V1TImode && <MODE>mode != TImode) || <CODE> != ROTATE)"
1476 {
1477 if (<MODE>mode == V1TImode || <MODE>mode == TImode)
1478 {
1479 rtx shift_count = gen_reg_rtx (V16QImode);
1480 emit_insn (gen_vec_splatsv16qi (shift_count, operands[2]));
1481
1482 if (!CONST_INT_P (operands[2]) || UINTVAL (operands[2]) > 7)
1483 switch (<CODE>)
1484 {
1485 case ASHIFT: emit_insn (gen_vec_slb (<MODE>mode, operands[0], operands[1], shift_count)); break;
1486 case ASHIFTRT: emit_insn (gen_vec_srab (<MODE>mode, operands[0], operands[1], shift_count)); break;
1487 case LSHIFTRT: emit_insn (gen_vec_srb (<MODE>mode, operands[0], operands[1], shift_count)); break;
1488 default: gcc_unreachable ();
1489 }
1490 else
1491 emit_move_insn (operands[0], operands[1]);
1492
1493 if (!CONST_INT_P (operands[2]) || (UINTVAL (operands[2]) & 7) != 0)
1494 {
1495 switch (<CODE>)
1496 {
1497 case ASHIFT: emit_insn (gen_vec_sll (<MODE>mode, V16QImode, operands[0], operands[0], shift_count)); break;
1498 case ASHIFTRT: emit_insn (gen_vec_sral (<MODE>mode, V16QImode, operands[0], operands[0], shift_count)); break;
1499 case LSHIFTRT: emit_insn (gen_vec_srl (<MODE>mode, V16QImode, operands[0], operands[0], shift_count)); break;
1500 default: gcc_unreachable ();
1501 }
1502 }
1503
1504 DONE;
1505 }
1506 })
1507
1508 ; verllb, verllh, verllf, verllg
1509 ; veslb, veslh, veslf, veslg
1510 ; vesrab, vesrah, vesraf, vesrag
1511 ; vesrlb, vesrlh, vesrlf, vesrlg
1512 (define_insn "*<vec_shifts_name><mode>3"
1513 [(set (match_operand:VI 0 "register_operand" "=v")
1514 (VEC_SHIFTS:VI (match_operand:VI 1 "register_operand" "v")
1515 (match_operand:QI 2 "shift_count_operand_vec" "jsc")))]
1516 "TARGET_VX
1517 && s390_valid_shift_count (operands[2],
1518 GET_MODE_BITSIZE (GET_MODE_INNER (<MODE>mode)) - 1)
1519 "
1520 "<vec_shifts_mnem><bhfgq>\t%v0,%v1,%Y2"
1521 [(set_attr "op_type" "VRS")])
1522
1523 ; verllg for V4SI/V4SF. This swaps the first and the second two
1524 ; elements of a vector and is only valid in that context.
1525 (define_expand "rotl<mode>3_di"
1526 [
1527 (set (match_dup 2)
1528 (subreg:V2DI (match_operand:V_HW_4 1) 0))
1529 (set (match_dup 3)
1530 (rotate:V2DI
1531 (match_dup 2)
1532 (const_int 32)))
1533 (set (match_operand:V_HW_4 0)
1534 (subreg:V_HW_4 (match_dup 3) 0))]
1535 "TARGET_VX"
1536 {
1537 operands[2] = gen_reg_rtx (V2DImode);
1538 operands[3] = gen_reg_rtx (V2DImode);
1539 })
1540
1541 ; Shift each element by corresponding vector element
1542
1543 ; veslvb, veslvh, veslvf, veslvg
1544 (define_insn "vashl<mode>3"
1545 [(set (match_operand:VI 0 "register_operand" "=v")
1546 (ashift:VI (match_operand:VI 1 "register_operand" "v")
1547 (match_operand:VI 2 "register_operand" "v")))]
1548 "TARGET_VX"
1549 "veslv<bhfgq>\t%v0,%v1,%v2"
1550 [(set_attr "op_type" "VRR")])
1551
1552 ; vesravb, vesravh, vesravf, vesravg
1553 (define_insn "vashr<mode>3"
1554 [(set (match_operand:VI 0 "register_operand" "=v")
1555 (ashiftrt:VI (match_operand:VI 1 "register_operand" "v")
1556 (match_operand:VI 2 "register_operand" "v")))]
1557 "TARGET_VX"
1558 "vesrav<bhfgq>\t%v0,%v1,%v2"
1559 [(set_attr "op_type" "VRR")])
1560
1561 ; vesrlvb, vesrlvh, vesrlvf, vesrlvg
1562 (define_insn "vlshr<mode>3"
1563 [(set (match_operand:VI 0 "register_operand" "=v")
1564 (lshiftrt:VI (match_operand:VI 1 "register_operand" "v")
1565 (match_operand:VI 2 "register_operand" "v")))]
1566 "TARGET_VX"
1567 "vesrlv<bhfgq>\t%v0,%v1,%v2"
1568 [(set_attr "op_type" "VRR")])
1569
1570 ; Vector shift right logical by byte
1571
1572 ; Pattern used by e.g. popcount
1573 (define_insn "*vec_srb<mode>"
1574 [(set (match_operand:V_HW3 0 "register_operand" "=v")
1575 (unspec:V_HW3 [(match_operand:V_HW3 1 "register_operand" "v")
1576 (match_operand:V16QI 2 "register_operand" "v")]
1577 UNSPEC_VEC_SRLB))]
1578 "TARGET_VX"
1579 "vsrlb\t%v0,%v1,%v2"
1580 [(set_attr "op_type" "VRR")])
1581
1582
1583 ; Vector shift left by byte
1584
1585 (define_insn "*vec_slb<mode>"
1586 [(set (match_operand:V_HW3 0 "register_operand" "=v")
1587 (unspec:V_HW3 [(match_operand:V_HW3 1 "register_operand" "v")
1588 (match_operand:V16QI 2 "register_operand" "v")]
1589 UNSPEC_VEC_SLB))]
1590 "TARGET_VX"
1591 "vslb\t%v0,%v1,%v2"
1592 [(set_attr "op_type" "VRR")])
1593
1594 ; vec_shr is defined as shift towards element 0
1595 ; this means it is a left shift on BE targets!
1596 (define_expand "vec_shr_<mode>"
1597 [(set (match_dup 3)
1598 (unspec:V16QI [(match_operand:SI 2 "const_shift_by_byte_operand" "")
1599 (const_int 7)
1600 (match_dup 3)]
1601 UNSPEC_VEC_SET))
1602 (set (match_operand:V_128 0 "register_operand" "")
1603 (unspec:V_128 [(match_operand:V_128 1 "register_operand" "")
1604 (match_dup 3)]
1605 UNSPEC_VEC_SLB))]
1606 "TARGET_VX"
1607 {
1608 operands[3] = gen_reg_rtx(V16QImode);
1609 })
1610
1611 (define_expand "smin<mode>3"
1612 [(set (match_operand:VIT 0 "register_operand" "=v")
1613 (smin:VIT (match_operand:VIT 1 "register_operand" "v")
1614 (match_operand:VIT 2 "register_operand" "v")))]
1615 "TARGET_VX"
1616 {
1617 // Emulate via vec_sel (op1, op2, op2 < op1)
1618 if ((<MODE>mode == V1TImode || <MODE>mode == TImode) && !TARGET_VXE3)
1619 {
1620 rtx lt = gen_reg_rtx (<MODE>mode);
1621 s390_expand_vec_compare (lt, LT, operands[2], operands[1]);
1622 emit_insn (gen_vec_sel0<mode> (operands[0], operands[1], operands[2], lt, GEN_INT (0)));
1623 DONE;
1624 }
1625 })
1626
1627 ; vmnb, vmnh, vmnf, vmng, vmnq
1628 (define_insn "*smin<mode>3"
1629 [(set (match_operand:VIT_VXE3 0 "register_operand" "=v")
1630 (smin:VIT_VXE3 (match_operand:VIT_VXE3 1 "register_operand" "v")
1631 (match_operand:VIT_VXE3 2 "register_operand" "v")))]
1632 "TARGET_VX"
1633 "vmn<bhfgq>\t%v0,%v1,%v2"
1634 [(set_attr "op_type" "VRR")])
1635
1636 (define_expand "smax<mode>3"
1637 [(set (match_operand:VIT 0 "register_operand" "=v")
1638 (smax:VIT (match_operand:VIT 1 "register_operand" "v")
1639 (match_operand:VIT 2 "register_operand" "v")))]
1640 "TARGET_VX"
1641 {
1642 // Emulate via vec_sel (op1, op2, op1 < op2)
1643 if ((<MODE>mode == V1TImode || <MODE>mode == TImode) && !TARGET_VXE3)
1644 {
1645 rtx lt = gen_reg_rtx (<MODE>mode);
1646 s390_expand_vec_compare (lt, LT, operands[1], operands[2]);
1647 emit_insn (gen_vec_sel0<mode> (operands[0], operands[1], operands[2], lt, GEN_INT (0)));
1648 DONE;
1649 }
1650 })
1651
1652 ; vmxb, vmxh, vmxf, vmxg, vmxq
1653 (define_insn "*smax<mode>3"
1654 [(set (match_operand:VIT_VXE3 0 "register_operand" "=v")
1655 (smax:VIT_VXE3 (match_operand:VIT_VXE3 1 "register_operand" "v")
1656 (match_operand:VIT_VXE3 2 "register_operand" "v")))]
1657 "TARGET_VX"
1658 "vmx<bhfgq>\t%v0,%v1,%v2"
1659 [(set_attr "op_type" "VRR")])
1660
1661 (define_expand "umin<mode>3"
1662 [(set (match_operand:VIT 0 "register_operand" "=v")
1663 (umin:VIT (match_operand:VIT 1 "register_operand" "v")
1664 (match_operand:VIT 2 "register_operand" "v")))]
1665 "TARGET_VX"
1666 {
1667 // Emulate via vec_sel (op1, op2, op2 < op1)
1668 if ((<MODE>mode == V1TImode || <MODE>mode == TImode) && !TARGET_VXE3)
1669 {
1670 rtx ltu = gen_reg_rtx (<MODE>mode);
1671 s390_expand_vec_compare (ltu, LTU, operands[2], operands[1]);
1672 emit_insn (gen_vec_sel0<mode> (operands[0], operands[1], operands[2], ltu, GEN_INT (0)));
1673 DONE;
1674 }
1675 })
1676
1677 ; vmnlb, vmnlh, vmnlf, vmnlg, vmnlq
1678 (define_insn "*umin<mode>3"
1679 [(set (match_operand:VIT_VXE3 0 "register_operand" "=v")
1680 (umin:VIT_VXE3 (match_operand:VIT_VXE3 1 "register_operand" "v")
1681 (match_operand:VIT_VXE3 2 "register_operand" "v")))]
1682 "TARGET_VX"
1683 "vmnl<bhfgq>\t%v0,%v1,%v2"
1684 [(set_attr "op_type" "VRR")])
1685
1686 (define_expand "umax<mode>3"
1687 [(set (match_operand:VIT 0 "register_operand" "=v")
1688 (umax:VIT (match_operand:VIT 1 "register_operand" "v")
1689 (match_operand:VIT 2 "register_operand" "v")))]
1690 "TARGET_VX"
1691 {
1692 // Emulate via vec_sel (op1, op2, op1 < op2)
1693 if ((<MODE>mode == V1TImode || <MODE>mode == TImode) && !TARGET_VXE3)
1694 {
1695 rtx ltu = gen_reg_rtx (<MODE>mode);
1696 s390_expand_vec_compare (ltu, LTU, operands[1], operands[2]);
1697 emit_insn (gen_vec_sel0<mode> (operands[0], operands[1], operands[2], ltu, GEN_INT (0)));
1698 DONE;
1699 }
1700 })
1701
1702 ; vmxlb, vmxlh, vmxlf, vmxlg, vmxlq
1703 (define_insn "*umax<mode>3"
1704 [(set (match_operand:VIT_VXE3 0 "register_operand" "=v")
1705 (umax:VIT_VXE3 (match_operand:VIT_VXE3 1 "register_operand" "v")
1706 (match_operand:VIT_VXE3 2 "register_operand" "v")))]
1707 "TARGET_VX"
1708 "vmxl<bhfgq>\t%v0,%v1,%v2"
1709 [(set_attr "op_type" "VRR")])
1710
1711 ; vmeb, vmeh, vmef, vmeg
1712 (define_insn "vec_widen_smult_even_<mode>"
1713 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
1714 (unspec:<vec_double> [(match_operand:VI_VXE3 1 "register_operand" "v")
1715 (match_operand:VI_VXE3 2 "register_operand" "v")]
1716 UNSPEC_VEC_SMULT_EVEN))]
1717 "TARGET_VX"
1718 "vme<bhfgq>\t%v0,%v1,%v2"
1719 [(set_attr "op_type" "VRR")])
1720
1721 ; vmleb, vmleh, vmlef, vmleg
1722 (define_insn "vec_widen_umult_even_<mode>"
1723 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
1724 (unspec:<vec_double> [(match_operand:VI_VXE3 1 "register_operand" "v")
1725 (match_operand:VI_VXE3 2 "register_operand" "v")]
1726 UNSPEC_VEC_UMULT_EVEN))]
1727 "TARGET_VX"
1728 "vmle<bhfgq>\t%v0,%v1,%v2"
1729 [(set_attr "op_type" "VRR")])
1730
1731 ; vmob, vmoh, vmof, vmog
1732 (define_insn "vec_widen_smult_odd_<mode>"
1733 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
1734 (unspec:<vec_double> [(match_operand:VI_VXE3 1 "register_operand" "v")
1735 (match_operand:VI_VXE3 2 "register_operand" "v")]
1736 UNSPEC_VEC_SMULT_ODD))]
1737 "TARGET_VX"
1738 "vmo<bhfgq>\t%v0,%v1,%v2"
1739 [(set_attr "op_type" "VRR")])
1740
1741 ; vmlob, vmloh, vmlof, vmlog
1742 (define_insn "vec_widen_umult_odd_<mode>"
1743 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
1744 (unspec:<vec_double> [(match_operand:VI_VXE3 1 "register_operand" "v")
1745 (match_operand:VI_VXE3 2 "register_operand" "v")]
1746 UNSPEC_VEC_UMULT_ODD))]
1747 "TARGET_VX"
1748 "vmlo<bhfgq>\t%v0,%v1,%v2"
1749 [(set_attr "op_type" "VRR")])
1750
1751
1752 ; Widening hi/lo multiplications
1753
1754 ; The S/390 instructions vml and vmh return the low or high parts of
1755 ; the double sized result elements in the corresponding elements of
1756 ; the target register. That's NOT what the vec_widen_umult_lo/hi
1757 ; patterns are expected to do.
1758
1759 ; We emulate the widening lo/hi multiplies with the even/odd versions
1760 ; followed by a vector merge
1761
1762
1763 (define_expand "vec_widen_umult_lo_<mode>"
1764 [(set (match_dup 3)
1765 (unspec:<vec_double> [(match_operand:VI_QHS 1 "register_operand" "")
1766 (match_operand:VI_QHS 2 "register_operand" "")]
1767 UNSPEC_VEC_UMULT_EVEN))
1768 (set (match_dup 4)
1769 (unspec:<vec_double> [(match_dup 1) (match_dup 2)]
1770 UNSPEC_VEC_UMULT_ODD))
1771 (set (match_operand:<vec_double> 0 "register_operand" "")
1772 (vec_select:<vec_double>
1773 (vec_concat:<VEC_2X_WIDE> (match_dup 3) (match_dup 4))
1774 (match_dup 5)))]
1775 "TARGET_VX"
1776 {
1777 operands[3] = gen_reg_rtx (<vec_double>mode);
1778 operands[4] = gen_reg_rtx (<vec_double>mode);
1779 operands[5] = s390_expand_merge_perm_const (<vec_double>mode, false);
1780 })
1781
1782 (define_expand "vec_widen_umult_hi_<mode>"
1783 [(set (match_dup 3)
1784 (unspec:<vec_double> [(match_operand:VI_QHS 1 "register_operand" "")
1785 (match_operand:VI_QHS 2 "register_operand" "")]
1786 UNSPEC_VEC_UMULT_EVEN))
1787 (set (match_dup 4)
1788 (unspec:<vec_double> [(match_dup 1) (match_dup 2)]
1789 UNSPEC_VEC_UMULT_ODD))
1790 (set (match_operand:<vec_double> 0 "register_operand" "")
1791 (vec_select:<vec_double>
1792 (vec_concat:<VEC_2X_WIDE> (match_dup 3) (match_dup 4))
1793 (match_dup 5)))]
1794 "TARGET_VX"
1795 {
1796 operands[3] = gen_reg_rtx (<vec_double>mode);
1797 operands[4] = gen_reg_rtx (<vec_double>mode);
1798 operands[5] = s390_expand_merge_perm_const (<vec_double>mode, true);
1799 })
1800
1801 (define_expand "vec_widen_smult_lo_<mode>"
1802 [(set (match_dup 3)
1803 (unspec:<vec_double> [(match_operand:VI_QHS 1 "register_operand" "")
1804 (match_operand:VI_QHS 2 "register_operand" "")]
1805 UNSPEC_VEC_SMULT_EVEN))
1806 (set (match_dup 4)
1807 (unspec:<vec_double> [(match_dup 1) (match_dup 2)]
1808 UNSPEC_VEC_SMULT_ODD))
1809 (set (match_operand:<vec_double> 0 "register_operand" "")
1810 (vec_select:<vec_double>
1811 (vec_concat:<VEC_2X_WIDE> (match_dup 3) (match_dup 4))
1812 (match_dup 5)))]
1813 "TARGET_VX"
1814 {
1815 operands[3] = gen_reg_rtx (<vec_double>mode);
1816 operands[4] = gen_reg_rtx (<vec_double>mode);
1817 operands[5] = s390_expand_merge_perm_const (<vec_double>mode, false);
1818 })
1819
1820 (define_expand "vec_widen_smult_hi_<mode>"
1821 [(set (match_dup 3)
1822 (unspec:<vec_double> [(match_operand:VI_QHS 1 "register_operand" "")
1823 (match_operand:VI_QHS 2 "register_operand" "")]
1824 UNSPEC_VEC_SMULT_EVEN))
1825 (set (match_dup 4)
1826 (unspec:<vec_double> [(match_dup 1) (match_dup 2)]
1827 UNSPEC_VEC_SMULT_ODD))
1828 (set (match_operand:<vec_double> 0 "register_operand" "")
1829 (vec_select:<vec_double>
1830 (vec_concat:<VEC_2X_WIDE> (match_dup 3) (match_dup 4))
1831 (match_dup 5)))]
1832 "TARGET_VX"
1833 {
1834 operands[3] = gen_reg_rtx (<vec_double>mode);
1835 operands[4] = gen_reg_rtx (<vec_double>mode);
1836 operands[5] = s390_expand_merge_perm_const (<vec_double>mode, true);
1837 })
1838
1839 ; vec_widen_ushiftl_hi
1840 ; vec_widen_ushiftl_lo
1841 ; vec_widen_sshiftl_hi
1842 ; vec_widen_sshiftl_lo
1843
1844 ;;
1845 ;; Vector floating point arithmetic instructions
1846 ;;
1847
1848 ; vfasb, vfadb, wfasb, wfadb, wfaxb
1849 (define_insn "add<mode>3<tf_vr>"
1850 [(set (match_operand:VF_HW 0 "register_operand" "=v")
1851 (plus:VF_HW (match_operand:VF_HW 1 "register_operand" "v")
1852 (match_operand:VF_HW 2 "register_operand" "v")))]
1853 "TARGET_VX"
1854 "<vw>fa<sdx>b\t%v0,%v1,%v2"
1855 [(set_attr "op_type" "VRR")])
1856
1857 (define_expand "addtf3"
1858 [(match_operand:TF 0 "register_operand" "")
1859 (match_operand:TF 1 "nonimmediate_operand" "")
1860 (match_operand:TF 2 "general_operand" "")]
1861 "HAVE_TF (addtf3)"
1862 { EXPAND_TF (addtf3, 3); })
1863
1864 ; vfssb, vfsdb, wfssb, wfsdb, wfsxb
1865 (define_insn "sub<mode>3<tf_vr>"
1866 [(set (match_operand:VF_HW 0 "register_operand" "=v")
1867 (minus:VF_HW (match_operand:VF_HW 1 "register_operand" "v")
1868 (match_operand:VF_HW 2 "register_operand" "v")))]
1869 "TARGET_VX"
1870 "<vw>fs<sdx>b\t%v0,%v1,%v2"
1871 [(set_attr "op_type" "VRR")])
1872
1873 (define_expand "subtf3"
1874 [(match_operand:TF 0 "register_operand" "")
1875 (match_operand:TF 1 "register_operand" "")
1876 (match_operand:TF 2 "general_operand" "")]
1877 "HAVE_TF (subtf3)"
1878 { EXPAND_TF (subtf3, 3); })
1879
1880 ; vfmsb, vfmdb, wfmsb, wfmdb, wfmxb
1881 (define_insn "mul<mode>3<tf_vr>"
1882 [(set (match_operand:VF_HW 0 "register_operand" "=v")
1883 (mult:VF_HW (match_operand:VF_HW 1 "register_operand" "v")
1884 (match_operand:VF_HW 2 "register_operand" "v")))]
1885 "TARGET_VX"
1886 "<vw>fm<sdx>b\t%v0,%v1,%v2"
1887 [(set_attr "op_type" "VRR")])
1888
1889 (define_expand "multf3"
1890 [(match_operand:TF 0 "register_operand" "")
1891 (match_operand:TF 1 "nonimmediate_operand" "")
1892 (match_operand:TF 2 "general_operand" "")]
1893 "HAVE_TF (multf3)"
1894 { EXPAND_TF (multf3, 3); })
1895
1896 ; vfdsb, vfddb, wfdsb, wfddb, wfdxb
1897 (define_insn "div<mode>3<tf_vr>"
1898 [(set (match_operand:VF_HW 0 "register_operand" "=v")
1899 (div:VF_HW (match_operand:VF_HW 1 "register_operand" "v")
1900 (match_operand:VF_HW 2 "register_operand" "v")))]
1901 "TARGET_VX"
1902 "<vw>fd<sdx>b\t%v0,%v1,%v2"
1903 [(set_attr "op_type" "VRR")])
1904
1905 (define_expand "divtf3"
1906 [(match_operand:TF 0 "register_operand" "")
1907 (match_operand:TF 1 "register_operand" "")
1908 (match_operand:TF 2 "general_operand" "")]
1909 "HAVE_TF (divtf3)"
1910 { EXPAND_TF (divtf3, 3); })
1911
1912 ; vfsqsb, vfsqdb, wfsqsb, wfsqdb, wfsqxb
1913 (define_insn "sqrt<mode>2<tf_vr>"
1914 [(set (match_operand:VF_HW 0 "register_operand" "=v")
1915 (sqrt:VF_HW (match_operand:VF_HW 1 "register_operand" "v")))]
1916 "TARGET_VX"
1917 "<vw>fsq<sdx>b\t%v0,%v1"
1918 [(set_attr "op_type" "VRR")])
1919
1920 (define_expand "sqrttf2"
1921 [(match_operand:TF 0 "register_operand" "")
1922 (match_operand:TF 1 "general_operand" "")]
1923 "HAVE_TF (sqrttf2)"
1924 { EXPAND_TF (sqrttf2, 2); })
1925
1926 ; vfmasb, vfmadb, wfmasb, wfmadb, wfmaxb
1927 (define_insn "fma<mode>4"
1928 [(set (match_operand:VF_HW 0 "register_operand" "=v")
1929 (fma:VF_HW (match_operand:VF_HW 1 "register_operand" "v")
1930 (match_operand:VF_HW 2 "register_operand" "v")
1931 (match_operand:VF_HW 3 "register_operand" "v")))]
1932 "TARGET_VX && s390_fma_allowed_p (<MODE>mode)"
1933 "<vw>fma<sdx>b\t%v0,%v1,%v2,%v3"
1934 [(set_attr "op_type" "VRR")])
1935
1936 ; vfmssb, vfmsdb, wfmssb, wfmsdb, wfmsxb
1937 (define_insn "fms<mode>4"
1938 [(set (match_operand:VF_HW 0 "register_operand" "=v")
1939 (fma:VF_HW (match_operand:VF_HW 1 "register_operand" "v")
1940 (match_operand:VF_HW 2 "register_operand" "v")
1941 (neg:VF_HW (match_operand:VF_HW 3 "register_operand" "v"))))]
1942 "TARGET_VX && s390_fma_allowed_p (<MODE>mode)"
1943 "<vw>fms<sdx>b\t%v0,%v1,%v2,%v3"
1944 [(set_attr "op_type" "VRR")])
1945
1946 ; vfnmasb, vfnmadb, wfnmasb, wfnmadb, wfnmaxb
1947 (define_insn "neg_fma<mode>4"
1948 [(set (match_operand:VF_HW 0 "register_operand" "=v")
1949 (neg:VF_HW
1950 (fma:VF_HW (match_operand:VF_HW 1 "register_operand" "v")
1951 (match_operand:VF_HW 2 "register_operand" "v")
1952 (match_operand:VF_HW 3 "register_operand" "v"))))]
1953 "TARGET_VXE && s390_fma_allowed_p (<MODE>mode)"
1954 "<vw>fnma<sdx>b\t%v0,%v1,%v2,%v3"
1955 [(set_attr "op_type" "VRR")])
1956
1957 ; vfnmssb, vfnmsdb, wfnmssb, wfnmsdb, wfnmsxb
1958 (define_insn "neg_fms<mode>4"
1959 [(set (match_operand:VF_HW 0 "register_operand" "=v")
1960 (neg:VF_HW
1961 (fma:VF_HW (match_operand:VF_HW 1 "register_operand" "v")
1962 (match_operand:VF_HW 2 "register_operand" "v")
1963 (neg:VF_HW (match_operand:VF_HW 3 "register_operand" "v")))))]
1964 "TARGET_VXE && s390_fma_allowed_p (<MODE>mode)"
1965 "<vw>fnms<sdx>b\t%v0,%v1,%v2,%v3"
1966 [(set_attr "op_type" "VRR")])
1967
1968 ; vflcsb, vflcdb, wflcsb, wflcdb, wflcxb
1969 (define_insn "neg<mode>2<tf_vr>"
1970 [(set (match_operand:VFT 0 "register_operand" "=v")
1971 (neg:VFT (match_operand:VFT 1 "register_operand" "v")))]
1972 "TARGET_VX"
1973 "<vw>flc<sdx>b\t%v0,%v1"
1974 [(set_attr "op_type" "VRR")])
1975
1976 (define_expand "negtf2"
1977 [(match_operand:TF 0 "register_operand" "")
1978 (match_operand:TF 1 "register_operand" "")]
1979 "HAVE_TF (negtf2)"
1980 { EXPAND_TF (negtf2, 2); })
1981
1982 ; vflpsb, vflpdb, wflpsb, wflpdb, wflpxb
1983 (define_insn "abs<mode>2<tf_vr>"
1984 [(set (match_operand:VFT 0 "register_operand" "=v")
1985 (abs:VFT (match_operand:VFT 1 "register_operand" "v")))]
1986 "TARGET_VX"
1987 "<vw>flp<sdx>b\t%v0,%v1"
1988 [(set_attr "op_type" "VRR")])
1989
1990 (define_expand "abstf2"
1991 [(match_operand:TF 0 "register_operand" "")
1992 (match_operand:TF 1 "register_operand" "")]
1993 "HAVE_TF (abstf2)"
1994 { EXPAND_TF (abstf2, 2); })
1995
1996 ; vflnsb, vflndb, wflnsb, wflndb, wflnxb
1997 (define_insn "negabs<mode>2"
1998 [(set (match_operand:VFT 0 "register_operand" "=v")
1999 (neg:VFT (abs:VFT (match_operand:VFT 1 "register_operand" "v"))))]
2000 "TARGET_VX"
2001 "<vw>fln<sdx>b\t%v0,%v1"
2002 [(set_attr "op_type" "VRR")])
2003
2004 (define_expand "smax<mode>3"
2005 [(set (match_operand:VF_HW 0 "register_operand")
2006 (smax:VF_HW (match_operand:VF_HW 1 "register_operand")
2007 (match_operand:VF_HW 2 "register_operand")))]
2008 "TARGET_VX")
2009
2010 ; vfmaxsb, vfmaxdb, wfmaxsb, wfmaxdb, wfmaxxb
2011 (define_insn "*smax<mode>3_vxe"
2012 [(set (match_operand:VF_HW 0 "register_operand" "=v")
2013 (smax:VF_HW (match_operand:VF_HW 1 "register_operand" "v")
2014 (match_operand:VF_HW 2 "register_operand" "v")))]
2015 "TARGET_VXE"
2016 "<vw>fmax<sdx>b\t%v0,%v1,%v2,4"
2017 [(set_attr "op_type" "VRR")])
2018
2019 ; Emulate with compare + select
2020 (define_insn_and_split "*smaxv2df3_vx"
2021 [(set (match_operand:V2DF 0 "register_operand" "=v")
2022 (smax:V2DF (match_operand:V2DF 1 "register_operand" "v")
2023 (match_operand:V2DF 2 "register_operand" "v")))]
2024 "TARGET_VX && !TARGET_VXE"
2025 "#"
2026 "&& 1"
2027 [(set (match_dup 3)
2028 (not:V2DI
2029 (unge:V2DI (match_dup 2) (match_dup 1))))
2030 (set (match_dup 0)
2031 (if_then_else:V2DF
2032 (eq (match_dup 3) (match_dup 4))
2033 (match_dup 2)
2034 (match_dup 1)))]
2035 {
2036 operands[3] = gen_reg_rtx (V2DImode);
2037 operands[4] = CONST0_RTX (V2DImode);
2038 })
2039
2040 (define_expand "smin<mode>3"
2041 [(set (match_operand:VF_HW 0 "register_operand")
2042 (smin:VF_HW (match_operand:VF_HW 1 "register_operand")
2043 (match_operand:VF_HW 2 "register_operand")))]
2044 "TARGET_VX")
2045
2046 ; vfminsb, vfmindb, wfminsb, wfmindb, wfminxb
2047 (define_insn "*smin<mode>3_vxe"
2048 [(set (match_operand:VF_HW 0 "register_operand" "=v")
2049 (smin:VF_HW (match_operand:VF_HW 1 "register_operand" "v")
2050 (match_operand:VF_HW 2 "register_operand" "v")))]
2051 "TARGET_VXE"
2052 "<vw>fmin<sdx>b\t%v0,%v1,%v2,4"
2053 [(set_attr "op_type" "VRR")])
2054
2055 ; Emulate with compare + select
2056 (define_insn_and_split "*sminv2df3_vx"
2057 [(set (match_operand:V2DF 0 "register_operand" "=v")
2058 (smin:V2DF (match_operand:V2DF 1 "register_operand" "v")
2059 (match_operand:V2DF 2 "register_operand" "v")))]
2060 "TARGET_VX && !TARGET_VXE"
2061 "#"
2062 "&& 1"
2063 [(set (match_dup 3)
2064 (not:V2DI
2065 (unge:V2DI (match_dup 2) (match_dup 1))))
2066 (set (match_dup 0)
2067 (if_then_else:V2DF
2068 (eq (match_dup 3) (match_dup 4))
2069 (match_dup 1)
2070 (match_dup 2)))]
2071 {
2072 operands[3] = gen_reg_rtx (V2DImode);
2073 operands[4] = CONST0_RTX (V2DImode);
2074 })
2075
2076 ; Vector copysign, implement using vector select
2077 (define_expand "copysign<mode>3"
2078 [(set (match_operand:VFT 0 "register_operand" "")
2079 (ior:VFT
2080 (and:VFT (match_operand:VFT 2 "register_operand" "")
2081 (match_dup 3))
2082 (and:VFT (not:VFT (match_dup 3))
2083 (match_operand:VFT 1 "register_operand" ""))))]
2084 "TARGET_VX"
2085 {
2086 rtx mask = s390_build_signbit_mask (<MODE>mode);
2087 operands[3] = force_reg (<MODE>mode, mask);
2088 })
2089
2090 ;;
2091 ;; Compares
2092 ;;
2093
2094 (define_expand "vec_cmp<mode><tointvec>"
2095 [(set (match_operand:<TOINTVEC> 0 "register_operand" "")
2096 (match_operator:<TOINTVEC> 1 "vcond_comparison_operator"
2097 [(match_operand:V_HW1 2 "register_operand" "")
2098 (match_operand:V_HW1 3 "nonmemory_operand" "")]))]
2099 "TARGET_VX"
2100 {
2101 s390_expand_vec_compare (operands[0], GET_CODE(operands[1]), operands[2], operands[3]);
2102 DONE;
2103 })
2104
2105 (define_expand "vec_cmpu<VIT_HW:mode><VIT_HW:mode>"
2106 [(set (match_operand:VIT_HW 0 "register_operand" "")
2107 (match_operator:VIT_HW 1 ""
2108 [(match_operand:VIT_HW 2 "register_operand" "")
2109 (match_operand:VIT_HW 3 "register_operand" "")]))]
2110 "TARGET_VX"
2111 {
2112 s390_expand_vec_compare (operands[0], GET_CODE(operands[1]), operands[2], operands[3]);
2113 DONE;
2114 })
2115
2116 (define_insn "*vec_cmp<VICMP_HW_OP:code><VIT_VXE3:mode><VIT_VXE3:mode>_nocc"
2117 [(set (match_operand:VIT_VXE3 2 "register_operand" "=v")
2118 (VICMP_HW_OP:VIT_VXE3 (match_operand:VIT_VXE3 0 "register_operand" "v")
2119 (match_operand:VIT_VXE3 1 "register_operand" "v")))]
2120 "TARGET_VX"
2121 "vc<VICMP_HW_OP:insn_cmp_op><VIT_VXE3:bhfgq>\t%v2,%v0,%v1"
2122 [(set_attr "op_type" "VRR")])
2123
2124 (define_insn_and_split "*vec_cmpeq<mode><mode>_nocc_emu"
2125 [(set (match_operand:VI_HW_T 0 "register_operand" "=v")
2126 (eq:VI_HW_T (match_operand:VI_HW_T 1 "register_operand" "v")
2127 (match_operand:VI_HW_T 2 "register_operand" "v")))]
2128 "TARGET_VX && !TARGET_VXE3"
2129 "#"
2130 "&& can_create_pseudo_p ()"
2131 [(set (match_dup 3)
2132 (eq:V2DI (match_dup 1) (match_dup 2)))
2133 (set (match_dup 4)
2134 (vec_select:V2DI (match_dup 3) (parallel [(const_int 1) (const_int 0)])))
2135 (set (match_dup 3)
2136 (and:V2DI (match_dup 3) (match_dup 4)))
2137 (set (match_dup 0)
2138 (subreg:<MODE> (match_dup 3) 0))]
2139 {
2140 operands[1] = simplify_gen_subreg (V2DImode, operands[1], <MODE>mode, 0);
2141 operands[2] = simplify_gen_subreg (V2DImode, operands[2], <MODE>mode, 0);
2142 operands[3] = gen_reg_rtx (V2DImode);
2143 operands[4] = gen_reg_rtx (V2DImode);
2144 })
2145
2146 (define_insn_and_split "*vec_cmpgt<mode><mode>_nocc_emu"
2147 [(set (match_operand:VI_HW_T 0 "register_operand" "=v")
2148 (gt:VI_HW_T (match_operand:VI_HW_T 1 "register_operand" "v")
2149 (match_operand:VI_HW_T 2 "register_operand" "v")))]
2150 "TARGET_VX && !TARGET_VXE3"
2151 "#"
2152 "&& can_create_pseudo_p ()"
2153 [(set (match_dup 3)
2154 (gt:V2DI (match_dup 1) (match_dup 2)))
2155 (set (match_dup 4)
2156 (eq:V2DI (match_dup 1) (match_dup 2)))
2157 (set (match_dup 5)
2158 (gtu:V2DI (match_dup 1) (match_dup 2)))
2159 (set (match_dup 5)
2160 (vec_select:V2DI (match_dup 5) (parallel [(const_int 1) (const_int 0)])))
2161 (set (match_dup 4)
2162 (and:V2DI (match_dup 4) (match_dup 5)))
2163 (set (match_dup 4)
2164 (ior:V2DI (match_dup 3) (match_dup 4)))
2165 (set (match_dup 4)
2166 (vec_duplicate:V2DI
2167 (vec_select:DI
2168 (match_dup 4)
2169 (parallel [(const_int 0)]))))
2170 (set (match_dup 0)
2171 (subreg:<MODE> (match_dup 4) 0))]
2172 {
2173 operands[1] = simplify_gen_subreg (V2DImode, operands[1], <MODE>mode, 0);
2174 operands[2] = simplify_gen_subreg (V2DImode, operands[2], <MODE>mode, 0);
2175 operands[3] = gen_reg_rtx (V2DImode);
2176 operands[4] = gen_reg_rtx (V2DImode);
2177 operands[5] = gen_reg_rtx (V2DImode);
2178 })
2179
2180 (define_insn_and_split "*vec_cmpgtu<mode><mode>_nocc_emu"
2181 [(set (match_operand:VI_HW_T 0 "register_operand" "=v")
2182 (gtu:VI_HW_T (match_operand:VI_HW_T 1 "register_operand" "v")
2183 (match_operand:VI_HW_T 2 "register_operand" "v")))]
2184 "TARGET_VX && !TARGET_VXE3"
2185 "#"
2186 "&& can_create_pseudo_p ()"
2187 [(set (match_dup 3)
2188 (gtu:V2DI (match_dup 1) (match_dup 2)))
2189 (set (match_dup 4)
2190 (eq:V2DI (match_dup 1) (match_dup 2)))
2191 (set (match_dup 5)
2192 (vec_select:V2DI (match_dup 3) (parallel [(const_int 1) (const_int 0)])))
2193 (set (match_dup 4)
2194 (and:V2DI (match_dup 4) (match_dup 5)))
2195 (set (match_dup 4)
2196 (ior:V2DI (match_dup 3) (match_dup 4)))
2197 (set (match_dup 4)
2198 (vec_duplicate:V2DI
2199 (vec_select:DI
2200 (match_dup 4)
2201 (parallel [(const_int 0)]))))
2202 (set (match_dup 0)
2203 (subreg:<MODE> (match_dup 4) 0))]
2204 {
2205 operands[1] = simplify_gen_subreg (V2DImode, operands[1], <MODE>mode, 0);
2206 operands[2] = simplify_gen_subreg (V2DImode, operands[2], <MODE>mode, 0);
2207 operands[3] = gen_reg_rtx (V2DImode);
2208 operands[4] = gen_reg_rtx (V2DImode);
2209 operands[5] = gen_reg_rtx (V2DImode);
2210 })
2211
2212
2213 ;;
2214 ;; Floating point compares
2215 ;;
2216
2217 ; vfcesb, vfcedb, wfcexb: non-signaling "==" comparison (a == b)
2218 (define_insn "*vec_cmpeq<mode>_quiet_nocc"
2219 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2220 (eq:<TOINTVEC> (match_operand:VFT 1 "register_operand" "v")
2221 (match_operand:VFT 2 "register_operand" "v")))]
2222 "TARGET_VX"
2223 "<vw>fce<sdx>b\t%v0,%v1,%v2"
2224 [(set_attr "op_type" "VRR")])
2225
2226 ; vfchsb, vfchdb, wfchxb: non-signaling > comparison (!(b u>= a))
2227 (define_insn "vec_cmpgt<mode>_quiet_nocc"
2228 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2229 (not:<TOINTVEC>
2230 (unge:<TOINTVEC> (match_operand:VFT 2 "register_operand" "v")
2231 (match_operand:VFT 1 "register_operand" "v"))))]
2232 "TARGET_VX"
2233 "<vw>fch<sdx>b\t%v0,%v1,%v2"
2234 [(set_attr "op_type" "VRR")])
2235
2236 (define_expand "vec_cmplt<mode>_quiet_nocc"
2237 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2238 (not:<TOINTVEC>
2239 (unge:<TOINTVEC> (match_operand:VFT 1 "register_operand" "v")
2240 (match_operand:VFT 2 "register_operand" "v"))))]
2241 "TARGET_VX")
2242
2243 ; vfchesb, vfchedb, wfchexb: non-signaling >= comparison (!(a u< b))
2244 (define_insn "vec_cmpge<mode>_quiet_nocc"
2245 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2246 (not:<TOINTVEC>
2247 (unlt:<TOINTVEC> (match_operand:VFT 1 "register_operand" "v")
2248 (match_operand:VFT 2 "register_operand" "v"))))]
2249 "TARGET_VX"
2250 "<vw>fche<sdx>b\t%v0,%v1,%v2"
2251 [(set_attr "op_type" "VRR")])
2252
2253 (define_expand "vec_cmple<mode>_quiet_nocc"
2254 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2255 (not:<TOINTVEC>
2256 (unlt:<TOINTVEC> (match_operand:VFT 2 "register_operand" "v")
2257 (match_operand:VFT 1 "register_operand" "v"))))]
2258 "TARGET_VX")
2259
2260 ; vfkesb, vfkedb, wfkexb: signaling == comparison ((a >= b) & (b >= a))
2261 (define_insn "*vec_cmpeq<mode>_signaling_nocc"
2262 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2263 (and:<TOINTVEC>
2264 (ge:<TOINTVEC> (match_operand:VFT 1 "register_operand" "v")
2265 (match_operand:VFT 2 "register_operand" "v"))
2266 (ge:<TOINTVEC> (match_dup 2)
2267 (match_dup 1))))]
2268 "TARGET_VXE"
2269 "<vw>fke<sdx>b\t%v0,%v1,%v2"
2270 [(set_attr "op_type" "VRR")])
2271
2272 ; vfkhsb, vfkhdb, wfkhxb: signaling > comparison (a > b)
2273 (define_insn "*vec_cmpgt<mode>_signaling_nocc"
2274 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2275 (gt:<TOINTVEC> (match_operand:VFT 1 "register_operand" "v")
2276 (match_operand:VFT 2 "register_operand" "v")))]
2277 "TARGET_VXE"
2278 "<vw>fkh<sdx>b\t%v0,%v1,%v2"
2279 [(set_attr "op_type" "VRR")])
2280
2281 (define_insn "*vec_cmpgt<mode>_signaling_finite_nocc"
2282 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2283 (gt:<TOINTVEC> (match_operand:VFT 1 "register_operand" "v")
2284 (match_operand:VFT 2 "register_operand" "v")))]
2285 "TARGET_NONSIGNALING_VECTOR_COMPARE_OK"
2286 "<vw>fch<sdx>b\t%v0,%v1,%v2"
2287 [(set_attr "op_type" "VRR")])
2288
2289 ; vfkhesb, vfkhedb, wfkhexb: signaling >= comparison (a >= b)
2290 (define_insn "*vec_cmpge<mode>_signaling_nocc"
2291 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2292 (ge:<TOINTVEC> (match_operand:VFT 1 "register_operand" "v")
2293 (match_operand:VFT 2 "register_operand" "v")))]
2294 "TARGET_VXE"
2295 "<vw>fkhe<sdx>b\t%v0,%v1,%v2"
2296 [(set_attr "op_type" "VRR")])
2297
2298 (define_insn "*vec_cmpge<mode>_signaling_finite_nocc"
2299 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2300 (ge:<TOINTVEC> (match_operand:VFT 1 "register_operand" "v")
2301 (match_operand:VFT 2 "register_operand" "v")))]
2302 "TARGET_NONSIGNALING_VECTOR_COMPARE_OK"
2303 "<vw>fche<sdx>b\t%v0,%v1,%v2"
2304 [(set_attr "op_type" "VRR")])
2305
2306 ; Expanders for not directly supported comparisons
2307 ; Signaling comparisons must be expressed via signaling rtxes only,
2308 ; and quiet comparisons must be expressed via quiet rtxes only.
2309
2310 ; UNGT a u> b -> !!(b u< a)
2311 (define_expand "vec_cmpungt<mode>"
2312 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2313 (not:<TOINTVEC>
2314 (unlt:<TOINTVEC> (match_operand:VFT 2 "register_operand" "v")
2315 (match_operand:VFT 1 "register_operand" "v"))))
2316 (set (match_dup 0)
2317 (not:<TOINTVEC> (match_dup 0)))]
2318 "TARGET_VX")
2319
2320 ; UNGE a u>= b -> !!(a u>= b)
2321 (define_expand "vec_cmpunge<mode>"
2322 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2323 (not:<TOINTVEC>
2324 (unge:<TOINTVEC> (match_operand:VFT 1 "register_operand" "v")
2325 (match_operand:VFT 2 "register_operand" "v"))))
2326 (set (match_dup 0)
2327 (not:<TOINTVEC> (match_dup 0)))]
2328 "TARGET_VX")
2329
2330 ; UNEQ a u== b -> !(!(a u>= b) | !(b u>= a))
2331 (define_expand "vec_cmpuneq<mode>"
2332 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2333 (not:<TOINTVEC>
2334 (unge:<TOINTVEC> (match_operand:VFT 1 "register_operand" "v")
2335 (match_operand:VFT 2 "register_operand" "v"))))
2336 (set (match_dup 3)
2337 (not:<TOINTVEC>
2338 (unge:<TOINTVEC> (match_dup 2)
2339 (match_dup 1))))
2340 (set (match_dup 0)
2341 (ior:<TOINTVEC> (match_dup 0)
2342 (match_dup 3)))
2343 (set (match_dup 0)
2344 (not:<TOINTVEC> (match_dup 0)))]
2345 "TARGET_VX"
2346 {
2347 operands[3] = gen_reg_rtx (<TOINTVEC>mode);
2348 })
2349
2350 ; LTGT a <> b -> a > b | b > a
2351 (define_expand "vec_cmpltgt<mode>"
2352 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2353 (gt:<TOINTVEC> (match_operand:VFT 1 "register_operand" "v")
2354 (match_operand:VFT 2 "register_operand" "v")))
2355 (set (match_dup 3) (gt:<TOINTVEC> (match_dup 2) (match_dup 1)))
2356 (set (match_dup 0) (ior:<TOINTVEC> (match_dup 0) (match_dup 3)))]
2357 "TARGET_VXE"
2358 {
2359 operands[3] = gen_reg_rtx (<TOINTVEC>mode);
2360 })
2361
2362 ; ORDERED (a, b): !(a u< b) | !(a u>= b)
2363 (define_expand "vec_cmpordered<mode>"
2364 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
2365 (not:<TOINTVEC>
2366 (unlt:<TOINTVEC> (match_operand:VFT 1 "register_operand" "v")
2367 (match_operand:VFT 2 "register_operand" "v"))))
2368 (set (match_dup 3)
2369 (not:<TOINTVEC>
2370 (unge:<TOINTVEC> (match_dup 1)
2371 (match_dup 2))))
2372 (set (match_dup 0)
2373 (ior:<TOINTVEC> (match_dup 0)
2374 (match_dup 3)))]
2375 "TARGET_VX"
2376 {
2377 operands[3] = gen_reg_rtx (<TOINTVEC>mode);
2378 })
2379
2380 ; UNORDERED (a, b): !ORDERED (a, b)
2381 (define_expand "vec_cmpunordered<mode>"
2382 [(match_operand:<TOINTVEC> 0 "register_operand" "=v")
2383 (match_operand:VFT 1 "register_operand" "v")
2384 (match_operand:VFT 2 "register_operand" "v")]
2385 "TARGET_VX"
2386 {
2387 emit_insn (gen_vec_cmpordered<mode> (operands[0], operands[1], operands[2]));
2388 emit_insn (gen_rtx_SET (operands[0],
2389 gen_rtx_NOT (<TOINTVEC>mode, operands[0])));
2390 DONE;
2391 })
2392
2393 (define_code_iterator VEC_CMP_EXPAND
2394 [ungt unge uneq ltgt ordered unordered])
2395
2396 (define_expand "vec_cmp<code>"
2397 [(match_operand 0 "register_operand" "")
2398 (VEC_CMP_EXPAND (match_operand 1 "register_operand" "")
2399 (match_operand 2 "register_operand" ""))]
2400 "TARGET_VX"
2401 {
2402 if (GET_MODE (operands[1]) == V4SFmode)
2403 emit_insn (gen_vec_cmp<code>v4sf (operands[0], operands[1], operands[2]));
2404 else if (GET_MODE (operands[1]) == V2DFmode)
2405 emit_insn (gen_vec_cmp<code>v2df (operands[0], operands[1], operands[2]));
2406 else
2407 gcc_unreachable ();
2408
2409 DONE;
2410 })
2411
2412 (define_insn "*vec_load_pair<mode>"
2413 [(set (match_operand:V_HW_2 0 "register_operand" "=v,v")
2414 (vec_concat:V_HW_2 (match_operand:<non_vec> 1 "register_operand" "d,v")
2415 (match_operand:<non_vec> 2 "register_operand" "d,v")))]
2416 "TARGET_VX"
2417 "@
2418 vlvgp\t%v0,%1,%2
2419 vmrhg\t%v0,%v1,%v2"
2420 [(set_attr "op_type" "VRR,VRR")])
2421
2422 (define_insn "vllv16qi"
2423 [(set (match_operand:V16QI 0 "register_operand" "=v")
2424 (unspec:V16QI [(match_operand:SI 1 "register_operand" "d")
2425 (match_operand:BLK 2 "memory_operand" "Q")]
2426 UNSPEC_VEC_LOAD_LEN))]
2427 "TARGET_VX"
2428 "vll\t%v0,%1,%2"
2429 [(set_attr "op_type" "VRS")])
2430
2431 ; vfeebs, vfeehs, vfeefs
2432 ; vfeezbs, vfeezhs, vfeezfs
2433 (define_insn "@vec_vfees<mode>"
2434 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
2435 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")
2436 (match_operand:VI_HW_QHS 2 "register_operand" "v")
2437 (match_operand:QI 3 "const_mask_operand" "C")]
2438 UNSPEC_VEC_VFEE))
2439 (set (reg:CCRAW CC_REGNUM)
2440 (unspec:CCRAW [(match_dup 1)
2441 (match_dup 2)
2442 (match_dup 3)]
2443 UNSPEC_VEC_VFEECC))]
2444 "TARGET_VX"
2445 {
2446 unsigned HOST_WIDE_INT flags = UINTVAL (operands[3]);
2447
2448 gcc_assert (!(flags & ~(VSTRING_FLAG_ZS | VSTRING_FLAG_CS)));
2449 flags &= ~VSTRING_FLAG_CS;
2450
2451 if (flags == VSTRING_FLAG_ZS)
2452 return "vfeez<bhfgq>s\t%v0,%v1,%v2";
2453 return "vfee<bhfgq>s\t%v0,%v1,%v2";
2454 }
2455 [(set_attr "op_type" "VRR")])
2456
2457 ; vfenebs, vfenehs, vfenefs
2458 ; vfenezbs, vfenezhs, vfenezfs
2459 (define_insn "vec_vfenes<mode>"
2460 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
2461 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")
2462 (match_operand:VI_HW_QHS 2 "register_operand" "v")
2463 (match_operand:QI 3 "const_mask_operand" "C")]
2464 UNSPEC_VEC_VFENE))
2465 (set (reg:CCRAW CC_REGNUM)
2466 (unspec:CCRAW [(match_dup 1)
2467 (match_dup 2)
2468 (match_dup 3)]
2469 UNSPEC_VEC_VFENECC))]
2470 "TARGET_VX"
2471 {
2472 unsigned HOST_WIDE_INT flags = UINTVAL (operands[3]);
2473
2474 gcc_assert (!(flags & ~(VSTRING_FLAG_ZS | VSTRING_FLAG_CS)));
2475 flags &= ~VSTRING_FLAG_CS;
2476
2477 if (flags == VSTRING_FLAG_ZS)
2478 return "vfenez<bhfgq>s\t%v0,%v1,%v2";
2479 return "vfene<bhfgq>s\t%v0,%v1,%v2";
2480 }
2481 [(set_attr "op_type" "VRR")])
2482
2483
2484 ; Vector select
2485
2486 ; The following splitters simplify vec_sel for constant 0 or -1
2487 ; selection sources. This is required to generate efficient code for
2488 ; vcond.
2489
2490 ; a = b == c;
2491 (define_split
2492 [(set (match_operand:V 0 "register_operand" "")
2493 (if_then_else:V
2494 (eq (match_operand:<TOINTVEC> 3 "register_operand" "")
2495 (match_operand:V 4 "const0_operand" ""))
2496 (match_operand:V 1 "const0_operand" "")
2497 (match_operand:V 2 "all_ones_operand" "")))]
2498 "TARGET_VX"
2499 [(set (match_dup 0) (match_dup 3))]
2500 {
2501 PUT_MODE (operands[3], <V:MODE>mode);
2502 })
2503
2504 ; a = ~(b == c)
2505 (define_split
2506 [(set (match_operand:V 0 "register_operand" "")
2507 (if_then_else:V
2508 (eq (match_operand:<TOINTVEC> 3 "register_operand" "")
2509 (match_operand:V 4 "const0_operand" ""))
2510 (match_operand:V 1 "all_ones_operand" "")
2511 (match_operand:V 2 "const0_operand" "")))]
2512 "TARGET_VX"
2513 [(set (match_dup 0) (not:V (match_dup 3)))]
2514 {
2515 PUT_MODE (operands[3], <V:MODE>mode);
2516 })
2517
2518 ; a = b != c
2519 (define_split
2520 [(set (match_operand:V 0 "register_operand" "")
2521 (if_then_else:V
2522 (ne (match_operand:<TOINTVEC> 3 "register_operand" "")
2523 (match_operand:V 4 "const0_operand" ""))
2524 (match_operand:V 1 "all_ones_operand" "")
2525 (match_operand:V 2 "const0_operand" "")))]
2526 "TARGET_VX"
2527 [(set (match_dup 0) (match_dup 3))]
2528 {
2529 PUT_MODE (operands[3], <V:MODE>mode);
2530 })
2531
2532 ; a = ~(b != c)
2533 (define_split
2534 [(set (match_operand:V 0 "register_operand" "")
2535 (if_then_else:V
2536 (ne (match_operand:<TOINTVEC> 3 "register_operand" "")
2537 (match_operand:V 4 "const0_operand" ""))
2538 (match_operand:V 1 "const0_operand" "")
2539 (match_operand:V 2 "all_ones_operand" "")))]
2540 "TARGET_VX"
2541 [(set (match_dup 0) (not:V (match_dup 3)))]
2542 {
2543 PUT_MODE (operands[3], <V:MODE>mode);
2544 })
2545
2546 ; op0 = op3 == 0 ? op1 : op2
2547 (define_insn "vec_sel0<mode>"
2548 [(set (match_operand:VT 0 "register_operand" "=v")
2549 (if_then_else:VT
2550 (eq (match_operand:<TOINTVEC> 3 "register_operand" "v")
2551 (match_operand:<TOINTVEC> 4 "const0_operand" ""))
2552 (match_operand:VT 1 "register_operand" "v")
2553 (match_operand:VT 2 "register_operand" "v")))]
2554 "TARGET_VX"
2555 "vsel\t%v0,%2,%1,%3"
2556 [(set_attr "op_type" "VRR")])
2557
2558 ; op0 = !op3 == 0 ? op1 : op2
2559 (define_insn "*vec_sel0<mode>"
2560 [(set (match_operand:V 0 "register_operand" "=v")
2561 (if_then_else:V
2562 (eq (not:<TOINTVEC> (match_operand:<TOINTVEC> 3 "register_operand" "v"))
2563 (match_operand:<TOINTVEC> 4 "const0_operand" ""))
2564 (match_operand:V 1 "register_operand" "v")
2565 (match_operand:V 2 "register_operand" "v")))]
2566 "TARGET_VX"
2567 "vsel\t%v0,%1,%2,%3"
2568 [(set_attr "op_type" "VRR")])
2569
2570 ; op0 = op3 == -1 ? op1 : op2
2571 (define_insn "*vec_sel1<mode>"
2572 [(set (match_operand:V 0 "register_operand" "=v")
2573 (if_then_else:V
2574 (eq (match_operand:<TOINTVEC> 3 "register_operand" "v")
2575 (match_operand:<TOINTVEC> 4 "all_ones_operand" ""))
2576 (match_operand:V 1 "register_operand" "v")
2577 (match_operand:V 2 "register_operand" "v")))]
2578 "TARGET_VX"
2579 "vsel\t%v0,%1,%2,%3"
2580 [(set_attr "op_type" "VRR")])
2581
2582 ; op0 = !op3 == -1 ? op1 : op2
2583 (define_insn "*vec_sel1<mode>"
2584 [(set (match_operand:V 0 "register_operand" "=v")
2585 (if_then_else:V
2586 (eq (not:<TOINTVEC> (match_operand:<TOINTVEC> 3 "register_operand" "v"))
2587 (match_operand:<TOINTVEC> 4 "all_ones_operand" ""))
2588 (match_operand:V 1 "register_operand" "v")
2589 (match_operand:V 2 "register_operand" "v")))]
2590 "TARGET_VX"
2591 "vsel\t%v0,%2,%1,%3"
2592 [(set_attr "op_type" "VRR")])
2593
2594 ; vec_pack_trunc
2595
2596 ; vpkh, vpkf, vpkg
2597 (define_insn "vec_pack_trunc_<mode>"
2598 [(set (match_operand:<vec_half> 0 "register_operand" "=v")
2599 (vec_concat:<vec_half>
2600 (truncate:<vec_halfhalf>
2601 (match_operand:VI_HW_HSD 1 "register_operand" "v"))
2602 (truncate:<vec_halfhalf>
2603 (match_operand:VI_HW_HSD 2 "register_operand" "v"))))]
2604 "TARGET_VX"
2605 "vpk<bhfgq>\t%0,%1,%2"
2606 [(set_attr "op_type" "VRR")])
2607
2608 ; vpksh, vpksf, vpksg
2609 (define_insn "vec_pack_ssat_<mode>"
2610 [(set (match_operand:<vec_half> 0 "register_operand" "=v")
2611 (vec_concat:<vec_half>
2612 (ss_truncate:<vec_halfhalf>
2613 (match_operand:VI_HW_HSD 1 "register_operand" "v"))
2614 (ss_truncate:<vec_halfhalf>
2615 (match_operand:VI_HW_HSD 2 "register_operand" "v"))))]
2616 "TARGET_VX"
2617 "vpks<bhfgq>\t%0,%1,%2"
2618 [(set_attr "op_type" "VRR")])
2619
2620 ; vpklsh, vpklsf, vpklsg
2621 (define_insn "vec_pack_usat_<mode>"
2622 [(set (match_operand:<vec_half> 0 "register_operand" "=v")
2623 (vec_concat:<vec_half>
2624 (us_truncate:<vec_halfhalf>
2625 (match_operand:VI_HW_HSD 1 "register_operand" "v"))
2626 (us_truncate:<vec_halfhalf>
2627 (match_operand:VI_HW_HSD 2 "register_operand" "v"))))]
2628 "TARGET_VX"
2629 "vpkls<bhfgq>\t%0,%1,%2"
2630 [(set_attr "op_type" "VRR")])
2631
2632 ;; vector unpack / extend
2633
2634 (define_insn "<extend_insn><VI_EXTEND:mode><vec_2x_wide>2"
2635 [(set (match_operand:<VEC_2X_WIDE> 0 "register_operand" "=v")
2636 (any_extend:<VEC_2X_WIDE>
2637 (match_operand:VI_EXTEND 1 "register_operand" "v")))]
2638 "TARGET_VX"
2639 "vup<zero_extend>h<bhfgq>\t%0,%1"
2640 [(set_attr "op_type" "VRR")])
2641
2642 (define_expand "extendv2sfv2df2"
2643 [(set (match_dup 2)
2644 (vec_select:V4SF
2645 (vec_concat:V4SF (match_operand:V2SF 1 "register_operand")
2646 (match_dup 1))
2647 (parallel [(const_int 0) (const_int 2)
2648 (const_int 1) (const_int 3)])))
2649 (set (match_operand:V2DF 0 "register_operand")
2650 (float_extend:V2DF
2651 (vec_select:V2SF
2652 (match_dup 2)
2653 (parallel [(const_int 0) (const_int 2)]))))]
2654 "TARGET_VX"
2655 {
2656 operands[2] = gen_reg_rtx (V4SFmode);
2657 })
2658
2659 ;; vector unpack v16qi
2660
2661 ; signed
2662
2663 (define_insn "vec_unpacks_hi_v16qi"
2664 [(set (match_operand:V8HI 0 "register_operand" "=v")
2665 (sign_extend:V8HI
2666 (vec_select:V8QI
2667 (match_operand:V16QI 1 "register_operand" "v")
2668 (parallel [(const_int 0)(const_int 1)(const_int 2)(const_int 3)
2669 (const_int 4)(const_int 5)(const_int 6)(const_int 7)]))))]
2670 "TARGET_VX"
2671 "vuphb\t%0,%1"
2672 [(set_attr "op_type" "VRR")])
2673
2674 (define_insn "vec_unpacks_lo_v16qi"
2675 [(set (match_operand:V8HI 0 "register_operand" "=v")
2676 (sign_extend:V8HI
2677 (vec_select:V8QI
2678 (match_operand:V16QI 1 "register_operand" "v")
2679 (parallel [(const_int 8) (const_int 9) (const_int 10)(const_int 11)
2680 (const_int 12)(const_int 13)(const_int 14)(const_int 15)]))))]
2681 "TARGET_VX"
2682 "vuplb\t%0,%1"
2683 [(set_attr "op_type" "VRR")])
2684
2685 ; unsigned
2686
2687 (define_insn "vec_unpacku_hi_v16qi"
2688 [(set (match_operand:V8HI 0 "register_operand" "=v")
2689 (zero_extend:V8HI
2690 (vec_select:V8QI
2691 (match_operand:V16QI 1 "register_operand" "v")
2692 (parallel [(const_int 0)(const_int 1)(const_int 2)(const_int 3)
2693 (const_int 4)(const_int 5)(const_int 6)(const_int 7)]))))]
2694 "TARGET_VX"
2695 "vuplhb\t%0,%1"
2696 [(set_attr "op_type" "VRR")])
2697
2698 (define_insn "vec_unpacku_lo_v16qi"
2699 [(set (match_operand:V8HI 0 "register_operand" "=v")
2700 (zero_extend:V8HI
2701 (vec_select:V8QI
2702 (match_operand:V16QI 1 "register_operand" "v")
2703 (parallel [(const_int 8) (const_int 9) (const_int 10)(const_int 11)
2704 (const_int 12)(const_int 13)(const_int 14)(const_int 15)]))))]
2705 "TARGET_VX"
2706 "vupllb\t%0,%1"
2707 [(set_attr "op_type" "VRR")])
2708
2709 ;; vector unpack v8hi
2710
2711 ; signed
2712
2713 (define_insn "vec_unpacks_hi_v8hi"
2714 [(set (match_operand:V4SI 0 "register_operand" "=v")
2715 (sign_extend:V4SI
2716 (vec_select:V4HI
2717 (match_operand:V8HI 1 "register_operand" "v")
2718 (parallel [(const_int 0)(const_int 1)(const_int 2)(const_int 3)]))))]
2719 "TARGET_VX"
2720 "vuphh\t%0,%1"
2721 [(set_attr "op_type" "VRR")])
2722
2723 (define_insn "vec_unpacks_lo_v8hi"
2724 [(set (match_operand:V4SI 0 "register_operand" "=v")
2725 (sign_extend:V4SI
2726 (vec_select:V4HI
2727 (match_operand:V8HI 1 "register_operand" "v")
2728 (parallel [(const_int 4)(const_int 5)(const_int 6)(const_int 7)]))))]
2729 "TARGET_VX"
2730 "vuplhw\t%0,%1"
2731 [(set_attr "op_type" "VRR")])
2732
2733 ; unsigned
2734
2735 (define_insn "vec_unpacku_hi_v8hi"
2736 [(set (match_operand:V4SI 0 "register_operand" "=v")
2737 (zero_extend:V4SI
2738 (vec_select:V4HI
2739 (match_operand:V8HI 1 "register_operand" "v")
2740 (parallel [(const_int 0)(const_int 1)(const_int 2)(const_int 3)]))))]
2741 "TARGET_VX"
2742 "vuplhh\t%0,%1"
2743 [(set_attr "op_type" "VRR")])
2744
2745 (define_insn "vec_unpacku_lo_v8hi"
2746 [(set (match_operand:V4SI 0 "register_operand" "=v")
2747 (zero_extend:V4SI
2748 (vec_select:V4HI
2749 (match_operand:V8HI 1 "register_operand" "v")
2750 (parallel [(const_int 4)(const_int 5)(const_int 6)(const_int 7)]))))]
2751 "TARGET_VX"
2752 "vupllh\t%0,%1"
2753 [(set_attr "op_type" "VRR")])
2754
2755 ;; vector unpack v4si
2756
2757 ; signed
2758
2759 (define_insn "vec_unpacks_hi_v4si"
2760 [(set (match_operand:V2DI 0 "register_operand" "=v")
2761 (sign_extend:V2DI
2762 (vec_select:V2SI
2763 (match_operand:V4SI 1 "register_operand" "v")
2764 (parallel [(const_int 0)(const_int 1)]))))]
2765 "TARGET_VX"
2766 "vuphf\t%0,%1"
2767 [(set_attr "op_type" "VRR")])
2768
2769 (define_insn "vec_unpacks_lo_v4si"
2770 [(set (match_operand:V2DI 0 "register_operand" "=v")
2771 (sign_extend:V2DI
2772 (vec_select:V2SI
2773 (match_operand:V4SI 1 "register_operand" "v")
2774 (parallel [(const_int 2)(const_int 3)]))))]
2775 "TARGET_VX"
2776 "vuplf\t%0,%1"
2777 [(set_attr "op_type" "VRR")])
2778
2779 ; unsigned
2780
2781 (define_insn "vec_unpacku_hi_v4si"
2782 [(set (match_operand:V2DI 0 "register_operand" "=v")
2783 (zero_extend:V2DI
2784 (vec_select:V2SI
2785 (match_operand:V4SI 1 "register_operand" "v")
2786 (parallel [(const_int 0)(const_int 1)]))))]
2787 "TARGET_VX"
2788 "vuplhf\t%0,%1"
2789 [(set_attr "op_type" "VRR")])
2790
2791 (define_insn "vec_unpacku_lo_v4si"
2792 [(set (match_operand:V2DI 0 "register_operand" "=v")
2793 (zero_extend:V2DI
2794 (vec_select:V2SI
2795 (match_operand:V4SI 1 "register_operand" "v")
2796 (parallel [(const_int 2)(const_int 3)]))))]
2797 "TARGET_VX"
2798 "vupllf\t%0,%1"
2799 [(set_attr "op_type" "VRR")])
2800
2801 ;; vector load lengthened
2802
2803 ; vflls float -> double
2804 (define_insn "*vec_extendv4sf"
2805 [(set (match_operand:V2DF 0 "register_operand" "=v")
2806 (float_extend:V2DF
2807 (vec_select:V2SF
2808 (match_operand:V4SF 1 "register_operand" "v")
2809 (parallel [(const_int 0) (const_int 2)]))))]
2810 "TARGET_VX"
2811 "vldeb\t%v0,%v1"
2812 [(set_attr "op_type" "VRR")])
2813
2814 (define_expand "vec_unpacks_lo_v4sf"
2815 [(set (match_dup 2)
2816 (vec_select:V4SF
2817 (vec_concat:V8SF (match_operand:V4SF 1 "register_operand" "") (match_dup 1))
2818 (match_dup 3)))
2819 (set (match_operand:V2DF 0 "register_operand" "")
2820 (float_extend:V2DF
2821 (vec_select:V2SF
2822 (match_dup 2)
2823 (parallel [(const_int 0) (const_int 2)]))))]
2824 "TARGET_VX"
2825 {
2826 operands[2] = gen_reg_rtx(V4SFmode);
2827 operands[3] = s390_expand_merge_perm_const (V4SFmode, false);
2828 })
2829
2830 (define_expand "vec_unpacks_hi_v4sf"
2831 [(set (match_dup 2)
2832 (vec_select:V4SF
2833 (vec_concat:V8SF (match_operand:V4SF 1 "register_operand" "") (match_dup 1))
2834 (match_dup 3)))
2835 (set (match_operand:V2DF 0 "register_operand" "")
2836 (float_extend:V2DF
2837 (vec_select:V2SF
2838 (match_dup 2)
2839 (parallel [(const_int 0) (const_int 2)]))))]
2840 "TARGET_VX"
2841 {
2842 operands[2] = gen_reg_rtx(V4SFmode);
2843 operands[3] = s390_expand_merge_perm_const (V4SFmode, true);
2844 })
2845
2846
2847 ; double -> long double
2848 (define_insn "*vec_extendv2df"
2849 [(set (match_operand:V1TF 0 "register_operand" "=v")
2850 (float_extend:V1TF
2851 (vec_select:V1DF
2852 (match_operand:V2DF 1 "register_operand" "v")
2853 (parallel [(const_int 0)]))))]
2854 "TARGET_VXE"
2855 "wflld\t%v0,%v1"
2856 [(set_attr "op_type" "VRR")])
2857
2858 (define_expand "vec_unpacks_lo_v2df"
2859 [(set (match_dup 2)
2860 (vec_select:V2DF
2861 (vec_concat:V4DF (match_operand:V2DF 1 "register_operand" "") (match_dup 1))
2862 (match_dup 3)))
2863 (set (match_operand:V1TF 0 "register_operand" "")
2864 (float_extend:V1TF
2865 (vec_select:V1DF
2866 (match_dup 2)
2867 (parallel [(const_int 0)]))))]
2868 "TARGET_VXE"
2869 {
2870 operands[2] = gen_reg_rtx (V2DFmode);
2871 operands[3] = s390_expand_merge_perm_const (V2DFmode, false);
2872 })
2873
2874 (define_expand "vec_unpacks_hi_v2df"
2875 [(set (match_dup 2)
2876 (vec_select:V2DF
2877 (vec_concat:V4DF (match_operand:V2DF 1 "register_operand" "") (match_dup 1))
2878 (match_dup 3)))
2879 (set (match_operand:V1TF 0 "register_operand" "")
2880 (float_extend:V1TF
2881 (vec_select:V1DF
2882 (match_dup 2)
2883 (parallel [(const_int 0)]))))]
2884 "TARGET_VXE"
2885 {
2886 operands[2] = gen_reg_rtx (V2DFmode);
2887 operands[3] = s390_expand_merge_perm_const (V2DFmode, true);
2888 })
2889
2890
2891 ; 2 x v2df -> 1 x v4sf
2892 (define_expand "vec_pack_trunc_v2df"
2893 [(set (match_dup 3)
2894 (unspec:V4SF [(match_operand:V2DF 1 "register_operand" "")
2895 (const_int VEC_INEXACT)
2896 (const_int VEC_RND_CURRENT)]
2897 UNSPEC_VEC_VFLR))
2898 (set (match_dup 4)
2899 (unspec:V4SF [(match_operand:V2DF 2 "register_operand" "")
2900 (const_int VEC_INEXACT)
2901 (const_int VEC_RND_CURRENT)]
2902 UNSPEC_VEC_VFLR))
2903 (set (match_dup 6)
2904 (unspec:V16QI [(subreg:V16QI (match_dup 3) 0)
2905 (subreg:V16QI (match_dup 4) 0)
2906 (match_dup 5)]
2907 UNSPEC_VEC_PERM))
2908 (set (match_operand:V4SF 0 "register_operand" "")
2909 (subreg:V4SF (match_dup 6) 0))]
2910 "TARGET_VX"
2911 {
2912 rtx constv, perm[16];
2913 int i;
2914
2915 for (i = 0; i < 4; ++i)
2916 {
2917 perm[i] = GEN_INT (i);
2918 perm[i + 4] = GEN_INT (i + 8);
2919 perm[i + 8] = GEN_INT (i + 16);
2920 perm[i + 12] = GEN_INT (i + 24);
2921 }
2922 constv = gen_rtx_CONST_VECTOR (V16QImode, gen_rtvec_v (16, perm));
2923
2924 operands[3] = gen_reg_rtx (V4SFmode);
2925 operands[4] = gen_reg_rtx (V4SFmode);
2926 operands[5] = force_reg (V16QImode, constv);
2927 operands[6] = gen_reg_rtx (V16QImode);
2928 })
2929
2930 ;
2931 ; BFP <-> integer conversions
2932 ;
2933
2934 ; signed integer to floating point
2935
2936 ; op2: inexact exception not suppressed (IEEE 754 2008)
2937 ; op3: according to current rounding mode
2938 ; vcdgb, vcefb
2939 (define_insn "float<tointvec><mode>2"
2940 [(set (match_operand:VX_VEC_CONV_BFP 0 "register_operand" "=v")
2941 (float:VX_VEC_CONV_BFP (match_operand:<TOINTVEC> 1 "register_operand" "v")))]
2942 "TARGET_VX"
2943 "vc<xde><bhfgq>b\t%v0,%v1,0,0"
2944 [(set_attr "op_type" "VRR")])
2945
2946 ; There is no instruction for loading a signed integer into an extended BFP
2947 ; operand in a VR, therefore we need to load it into a FPR pair first.
2948 (define_expand "float<mode>tf2_vr"
2949 [(set (match_dup 2)
2950 (float:FPRX2 (match_operand:DSI 1 "register_operand" "")))
2951 (set (match_operand:TF 0 "register_operand" "")
2952 (subreg:TF (match_dup 2) 0))]
2953 "TARGET_VXE"
2954 {
2955 operands[2] = gen_reg_rtx (FPRX2mode);
2956 })
2957
2958 (define_expand "float<mode>tf2"
2959 [(match_operand:TF 0 "register_operand" "")
2960 (match_operand:DSI 1 "register_operand" "")]
2961 "HAVE_TF (float<mode>tf2)"
2962 { EXPAND_TF (float<mode>tf2, 2); })
2963
2964 ; unsigned integer to floating point
2965
2966 ; op2: inexact exception not suppressed (IEEE 754 2008)
2967 ; op3: according to current rounding mode
2968 ; vcdlgb, vcelfb
2969 (define_insn "floatuns<tointvec><mode>2"
2970 [(set (match_operand:VX_VEC_CONV_BFP 0 "register_operand" "=v")
2971 (unsigned_float:VX_VEC_CONV_BFP (match_operand:<TOINTVEC> 1 "register_operand" "v")))]
2972 "TARGET_VX"
2973 "vc<xde>l<bhfgq>b\t%v0,%v1,0,0"
2974 [(set_attr "op_type" "VRR")])
2975
2976 ; There is no instruction for loading an unsigned integer into an extended BFP
2977 ; operand in a VR, therefore load it into a FPR pair first.
2978 (define_expand "floatuns<mode>tf2_vr"
2979 [(set (match_dup 2)
2980 (unsigned_float:FPRX2 (match_operand:GPR 1 "register_operand" "")))
2981 (set (match_operand:TF 0 "register_operand" "")
2982 (subreg:TF (match_dup 2) 0))]
2983 "TARGET_VXE"
2984 {
2985 operands[2] = gen_reg_rtx (FPRX2mode);
2986 })
2987
2988 (define_expand "floatuns<mode>tf2"
2989 [(match_operand:TF 0 "register_operand" "")
2990 (match_operand:GPR 1 "register_operand" "")]
2991 "HAVE_TF (floatuns<mode>tf2)"
2992 { EXPAND_TF (floatuns<mode>tf2, 2); })
2993
2994 ; floating point to signed integer
2995
2996 ; op2: inexact exception not suppressed (IEEE 754 2008)
2997 ; op3: rounding mode 5 (round towards 0 C11 6.3.1.4)
2998 ; vcgdb, vcfeb
2999 (define_insn "fix_trunc<mode><tointvec>2"
3000 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
3001 (fix:<TOINTVEC> (match_operand:VX_VEC_CONV_BFP 1 "register_operand" "v")))]
3002 "TARGET_VX"
3003 "vc<bhfgq><xde>b\t%v0,%v1,0,5"
3004 [(set_attr "op_type" "VRR")])
3005
3006 ; There is no instruction for rounding an extended BFP operand in a VR into
3007 ; a signed integer, therefore copy it into a FPR pair first.
3008 (define_expand "fix_trunctf<mode>2_vr"
3009 [(set (match_dup 2)
3010 (unspec:FPRX2 [(match_operand:TF 1 "register_operand")] UNSPEC_TF_TO_FPRX2))
3011 (parallel [(set (match_operand:GPR 0 "register_operand" "")
3012 (fix:GPR (match_dup 2)))
3013 (unspec:GPR [(const_int BFP_RND_TOWARD_0)] UNSPEC_ROUND)
3014 (clobber (reg:CC CC_REGNUM))])]
3015 "TARGET_VXE"
3016 {
3017 operands[2] = gen_reg_rtx (FPRX2mode);
3018 })
3019
3020 (define_expand "fix_trunctf<mode>2"
3021 [(match_operand:GPR 0 "register_operand" "")
3022 (match_operand:TF 1 "register_operand" "")]
3023 "HAVE_TF (fix_trunctf<mode>2)"
3024 { EXPAND_TF (fix_trunctf<mode>2, 2); })
3025
3026 ; floating point to unsigned integer
3027
3028 ; op2: inexact exception not suppressed (IEEE 754 2008)
3029 ; op3: rounding mode 5 (round towards 0 C11 6.3.1.4)
3030 ; vclgdb, vclfeb
3031 (define_insn "fixuns_trunc<VX_VEC_CONV_BFP:mode><tointvec>2"
3032 [(set (match_operand:<TOINTVEC> 0 "register_operand" "=v")
3033 (unsigned_fix:<TOINTVEC> (match_operand:VX_VEC_CONV_BFP 1 "register_operand" "v")))]
3034 "TARGET_VX"
3035 "vcl<bhfgq><xde>b\t%v0,%v1,0,5"
3036 [(set_attr "op_type" "VRR")])
3037
3038 ; There is no instruction for rounding an extended BFP operand in a VR into
3039 ; an unsigned integer, therefore copy it into a FPR pair first.
3040 (define_expand "fixuns_trunctf<mode>2_vr"
3041 [(set (match_dup 2)
3042 (unspec:FPRX2 [(match_operand:TF 1 "register_operand")] UNSPEC_TF_TO_FPRX2))
3043 (parallel [(set (match_operand:GPR 0 "register_operand" "")
3044 (unsigned_fix:GPR (match_dup 2)))
3045 (unspec:GPR [(const_int BFP_RND_TOWARD_0)] UNSPEC_ROUND)
3046 (clobber (reg:CC CC_REGNUM))])]
3047 "TARGET_VXE"
3048 {
3049 operands[2] = gen_reg_rtx (FPRX2mode);
3050 })
3051
3052 (define_expand "fixuns_trunctf<mode>2"
3053 [(match_operand:GPR 0 "register_operand" "")
3054 (match_operand:TF 1 "register_operand" "")]
3055 "HAVE_TF (fixuns_trunctf<mode>2)"
3056 { EXPAND_TF (fixuns_trunctf<mode>2, 2); })
3057
3058 ; load fp integer
3059
3060 ; vfisb, wfisb, vfidb, wfidb, wfixb; suppress inexact exceptions
3061 (define_insn "<FPINT:fpint_name><VF_HW:mode>2<VF_HW:tf_vr>"
3062 [(set (match_operand:VF_HW 0 "register_operand" "=v")
3063 (unspec:VF_HW [(match_operand:VF_HW 1 "register_operand" "v")]
3064 FPINT))]
3065 "TARGET_VX"
3066 "<vw>fi<VF_HW:sdx>b\t%v0,%v1,4,<FPINT:fpint_roundingmode>"
3067 [(set_attr "op_type" "VRR")])
3068
3069 (define_expand "<FPINT:fpint_name>tf2"
3070 [(match_operand:TF 0 "register_operand" "")
3071 (match_operand:TF 1 "register_operand" "")
3072 ; recognize FPINT as an iterator
3073 (unspec:TF [(match_dup 1)] FPINT)]
3074 "HAVE_TF (<FPINT:fpint_name>tf2)"
3075 { EXPAND_TF (<FPINT:fpint_name>tf2, 2); })
3076
3077 ; vfisb, wfisb, vfidb, wfidb, wfixb; raise inexact exceptions
3078 (define_insn "rint<mode>2<tf_vr>"
3079 [(set (match_operand:VF_HW 0 "register_operand" "=v")
3080 (unspec:VF_HW [(match_operand:VF_HW 1 "register_operand" "v")]
3081 UNSPEC_FPINT_RINT))]
3082 "TARGET_VX"
3083 "<vw>fi<sdx>b\t%v0,%v1,0,0"
3084 [(set_attr "op_type" "VRR")])
3085
3086 (define_expand "rinttf2"
3087 [(match_operand:TF 0 "register_operand" "")
3088 (match_operand:TF 1 "register_operand" "")]
3089 "HAVE_TF (rinttf2)"
3090 { EXPAND_TF (rinttf2, 2); })
3091
3092 ; load rounded
3093
3094 ; wflrx
3095 (define_insn "*trunctfdf2_vr"
3096 [(set (match_operand:DF 0 "register_operand" "=f")
3097 (float_truncate:DF (match_operand:TF 1 "register_operand" "v")))
3098 (unspec:DF [(match_operand 2 "const_int_operand" "")]
3099 UNSPEC_ROUND)]
3100 "TARGET_VXE"
3101 "wflrx\t%v0,%v1,0,%2"
3102 [(set_attr "op_type" "VRR")])
3103
3104 (define_expand "trunctfdf2_vr"
3105 [(parallel [
3106 (set (match_operand:DF 0 "register_operand" "")
3107 (float_truncate:DF (match_operand:TF 1 "register_operand" "")))
3108 (unspec:DF [(const_int BFP_RND_CURRENT)] UNSPEC_ROUND)])]
3109 "TARGET_VXE")
3110
3111 (define_expand "trunctfdf2"
3112 [(match_operand:DF 0 "register_operand" "")
3113 (match_operand:TF 1 "register_operand" "")]
3114 "HAVE_TF (trunctfdf2)"
3115 { EXPAND_TF (trunctfdf2, 2); })
3116
3117 ; wflrx + (ledbr|wledb)
3118 (define_expand "trunctfsf2_vr"
3119 [(parallel [
3120 (set (match_dup 2)
3121 (float_truncate:DF (match_operand:TF 1 "register_operand" "")))
3122 (unspec:DF [(const_int BFP_RND_PREP_FOR_SHORT_PREC)] UNSPEC_ROUND)])
3123 (set (match_operand:SF 0 "register_operand" "")
3124 (float_truncate:SF (match_dup 2)))]
3125 "TARGET_VXE"
3126 {
3127 operands[2] = gen_reg_rtx(DFmode);
3128 })
3129
3130 (define_expand "trunctfsf2"
3131 [(match_operand:SF 0 "register_operand" "")
3132 (match_operand:TF 1 "register_operand" "")]
3133 "HAVE_TF (trunctfsf2)"
3134 { EXPAND_TF (trunctfsf2, 2); })
3135
3136 (define_expand "trunctf<DFP_ALL:mode>2_vr"
3137 [(match_operand:DFP_ALL 0 "nonimmediate_operand" "")
3138 (match_operand:TF 1 "nonimmediate_operand" "")]
3139 "TARGET_HARD_DFP
3140 && GET_MODE_SIZE (TFmode) > GET_MODE_SIZE (<DFP_ALL:MODE>mode)
3141 && TARGET_VXE"
3142 {
3143 rtx fprx2 = gen_reg_rtx (FPRX2mode);
3144 emit_insn (gen_tf_to_fprx2 (fprx2, operands[1]));
3145 emit_insn (gen_truncfprx2<DFP_ALL:mode>2 (operands[0], fprx2));
3146 DONE;
3147 })
3148
3149 (define_expand "trunctf<DFP_ALL:mode>2"
3150 [(match_operand:DFP_ALL 0 "nonimmediate_operand" "")
3151 (match_operand:TF 1 "nonimmediate_operand" "")]
3152 "HAVE_TF (trunctf<DFP_ALL:mode>2)"
3153 { EXPAND_TF (trunctf<DFP_ALL:mode>2, 2); })
3154
3155 (define_expand "trunctdtf2_vr"
3156 [(match_operand:TF 0 "nonimmediate_operand" "")
3157 (match_operand:TD 1 "nonimmediate_operand" "")]
3158 "TARGET_HARD_DFP && TARGET_VXE"
3159 {
3160 rtx fprx2 = gen_reg_rtx (FPRX2mode);
3161 emit_insn (gen_trunctdfprx22 (fprx2, operands[1]));
3162 emit_insn (gen_fprx2_to_tf (operands[0], fprx2));
3163 DONE;
3164 })
3165
3166 (define_expand "trunctdtf2"
3167 [(match_operand:TF 0 "nonimmediate_operand" "")
3168 (match_operand:TD 1 "nonimmediate_operand" "")]
3169 "HAVE_TF (trunctdtf2)"
3170 { EXPAND_TF (trunctdtf2, 2); })
3171
3172 ; load lengthened
3173
3174 (define_insn "extenddftf2_vr"
3175 [(set (match_operand:TF 0 "register_operand" "=v")
3176 (float_extend:TF (match_operand:DF 1 "register_operand" "f")))]
3177 "TARGET_VXE"
3178 "wflld\t%v0,%v1"
3179 [(set_attr "op_type" "VRR")])
3180
3181 (define_expand "extenddftf2"
3182 [(match_operand:TF 0 "register_operand" "")
3183 (match_operand:DF 1 "nonimmediate_operand" "")]
3184 "HAVE_TF (extenddftf2)"
3185 { EXPAND_TF (extenddftf2, 2); })
3186
3187 (define_expand "extendsftf2_vr"
3188 [(set (match_dup 2)
3189 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "")))
3190 (set (match_operand:TF 0 "register_operand" "")
3191 (float_extend:TF (match_dup 2)))]
3192 "TARGET_VXE"
3193 {
3194 operands[2] = gen_reg_rtx(DFmode);
3195 })
3196
3197 (define_expand "extendsftf2"
3198 [(match_operand:TF 0 "register_operand" "")
3199 (match_operand:SF 1 "nonimmediate_operand" "")]
3200 "HAVE_TF (extendsftf2)"
3201 { EXPAND_TF (extendsftf2, 2); })
3202
3203 (define_expand "extend<DFP_ALL:mode>tf2_vr"
3204 [(match_operand:TF 0 "nonimmediate_operand" "")
3205 (match_operand:DFP_ALL 1 "nonimmediate_operand" "")]
3206 "TARGET_HARD_DFP
3207 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) < GET_MODE_SIZE (TFmode)
3208 && TARGET_VXE"
3209 {
3210 rtx fprx2 = gen_reg_rtx (FPRX2mode);
3211 emit_insn (gen_extend<DFP_ALL:mode>fprx22 (fprx2, operands[1]));
3212 emit_insn (gen_fprx2_to_tf (operands[0], fprx2));
3213 DONE;
3214 })
3215
3216 (define_expand "extend<DFP_ALL:mode>tf2"
3217 [(match_operand:TF 0 "nonimmediate_operand" "")
3218 (match_operand:DFP_ALL 1 "nonimmediate_operand" "")]
3219 "HAVE_TF (extend<DFP_ALL:mode>tf2)"
3220 { EXPAND_TF (extend<DFP_ALL:mode>tf2, 2); })
3221
3222 (define_expand "extendtftd2_vr"
3223 [(match_operand:TD 0 "nonimmediate_operand" "")
3224 (match_operand:TF 1 "nonimmediate_operand" "")]
3225 "TARGET_HARD_DFP && TARGET_VXE"
3226 {
3227 rtx fprx2 = gen_reg_rtx (FPRX2mode);
3228 emit_insn (gen_tf_to_fprx2 (fprx2, operands[1]));
3229 emit_insn (gen_extendfprx2td2 (operands[0], fprx2));
3230 DONE;
3231 })
3232
3233 (define_expand "extendtftd2"
3234 [(match_operand:TD 0 "nonimmediate_operand" "")
3235 (match_operand:TF 1 "nonimmediate_operand" "")]
3236 "HAVE_TF (extendtftd2)"
3237 { EXPAND_TF (extendtftd2, 2); })
3238
3239 ; test data class
3240
3241 (define_expand "<tdc_insn>tf2_vr"
3242 [(parallel
3243 [(set (reg:CCRAW CC_REGNUM)
3244 (unspec:CCRAW [(match_operand:TF 1 "register_operand" "")
3245 (const_int TDC_CLASS_BFP)]
3246 UNSPEC_VEC_VFTCICC))
3247 (clobber (scratch:TI))])
3248 (set (match_operand:SI 0 "register_operand" "")
3249 (const_int 0))
3250 (set (match_dup 0)
3251 (if_then_else:SI (eq (reg:CCRAW CC_REGNUM) (const_int 8))
3252 (const_int 1)
3253 (match_dup 0)))]
3254 "TARGET_VXE")
3255
3256 (define_expand "<tdc_insn>tf2"
3257 [(match_operand:SI 0 "register_operand" "")
3258 (match_operand:TF 1 "register_operand" "")
3259 (const_int TDC_CLASS_BFP)]
3260 "HAVE_TF (<tdc_insn>tf2)"
3261 { EXPAND_TF (<tdc_insn>tf2, 2); })
3262
3263 ;
3264 ; Vector byte swap patterns
3265 ;
3266
3267 ; FIXME: The bswap rtl standard name currently does not appear to be
3268 ; used for vector modes.
3269 (define_expand "bswap<mode>"
3270 [(parallel
3271 [(set (match_operand:VT_HW_HSDT 0 "nonimmediate_operand" "")
3272 (bswap:VT_HW_HSDT (match_operand:VT_HW_HSDT 1 "nonimmediate_operand" "")))
3273 (use (match_dup 2))])]
3274 "TARGET_VX"
3275 {
3276 static const char p[4][16] =
3277 { { 1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14 }, /* H */
3278 { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 }, /* S */
3279 { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8 }, /* D */
3280 { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 } }; /* T */
3281 const char *perm;
3282 rtx perm_rtx[16];
3283
3284 switch (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)))
3285 {
3286 case 2: perm = p[0]; break;
3287 case 4: perm = p[1]; break;
3288 case 8: perm = p[2]; break;
3289 case 16: perm = p[3]; break;
3290 default: gcc_unreachable ();
3291 }
3292 for (int i = 0; i < 16; i++)
3293 perm_rtx[i] = GEN_INT (perm[i]);
3294
3295 operands[2] = gen_rtx_CONST_VECTOR (V16QImode, gen_rtvec_v (16, perm_rtx));
3296
3297 /* Without vxe2 we do not have byte swap instructions dealing
3298 directly with memory operands. So instead of waiting until
3299 reload to fix that up switch over to vector permute right
3300 now. */
3301 if (!TARGET_VXE2)
3302 {
3303 rtx in = force_reg (V16QImode, simplify_gen_subreg (V16QImode, operands[1], <MODE>mode, 0));
3304 rtx permute = force_reg (V16QImode, force_const_mem (V16QImode, operands[2]));
3305 rtx out = gen_reg_rtx (V16QImode);
3306
3307 emit_insn (gen_vec_permv16qi (out, in, in, permute));
3308 emit_move_insn (operands[0], simplify_gen_subreg (<MODE>mode, out, V16QImode, 0));
3309 DONE;
3310 }
3311 })
3312
3313 ; Switching late to the reg-reg variant requires the vector permute
3314 ; pattern to be pushed into literal pool and allocating a vector
3315 ; register to load it into. We rely on both being provided by LRA
3316 ; when fixing up the v constraint for operand 2.
3317
3318 ; permute_pattern_operand: general_operand would reject the permute
3319 ; pattern constants since these are not accepted by
3320 ; s390_legimitate_constant_p
3321
3322 ; ^R: Prevent these alternatives from being chosen if it would require
3323 ; pushing the operand into memory first
3324
3325 ; vlbrh, vlbrf, vlbrg, vlbrq, vstbrh, vstbrf, vstbrg, vstbrq
3326 (define_insn_and_split "*bswap<mode>"
3327 [(set (match_operand:VT_HW_HSDT 0 "nonimmediate_operand" "=v, v,^R")
3328 (bswap:VT_HW_HSDT (match_operand:VT_HW_HSDT 1 "nonimmediate_operand" "v,^R, v")))
3329 (use (match_operand:V16QI 2 "permute_pattern_operand" "v, X, X"))]
3330 "TARGET_VXE2"
3331 "@
3332 #
3333 vlbr<bhfgq>\t%v0,%1
3334 vstbr<bhfgq>\t%v1,%0"
3335 "&& reload_completed
3336 && !memory_operand (operands[0], <MODE>mode)
3337 && !memory_operand (operands[1], <MODE>mode)"
3338 [(set (match_dup 0)
3339 (subreg:VT_HW_HSDT
3340 (unspec:V16QI [(subreg:V16QI (match_dup 1) 0)
3341 (subreg:V16QI (match_dup 1) 0)
3342 (match_dup 2)]
3343 UNSPEC_VEC_PERM) 0))]
3344 ""
3345 [(set_attr "op_type" "*,VRX,VRX")])
3346
3347 (define_insn "*vstbr<mode>"
3348 [(set (match_operand:VI_HW_HSDT 0 "memory_operand" "=R")
3349 (bswap:VI_HW_HSDT (match_operand:VI_HW_HSDT 1 "register_operand" "v")))]
3350 "TARGET_VXE2"
3351 "vstbr<bhfgq>\t%v1,%0"
3352 [(set_attr "op_type" "VRX")])
3353
3354 ;
3355 ; Implement len_load/len_store optabs with vll/vstl.
3356 (define_expand "len_load_v16qi"
3357 [(match_operand:V16QI 0 "register_operand")
3358 (match_operand:V16QI 1 "memory_operand")
3359 (match_operand:QI 2 "register_operand")
3360 (match_operand:QI 3 "vll_bias_operand")
3361 ]
3362 "TARGET_VX && TARGET_64BIT"
3363 {
3364 rtx mem = adjust_address (operands[1], BLKmode, 0);
3365
3366 rtx len = gen_reg_rtx (SImode);
3367 emit_move_insn (len, gen_rtx_ZERO_EXTEND (SImode, operands[2]));
3368 emit_insn (gen_vllv16qi (operands[0], len, mem));
3369 DONE;
3370 })
3371
3372 (define_expand "len_store_v16qi"
3373 [(match_operand:V16QI 0 "memory_operand")
3374 (match_operand:V16QI 1 "register_operand")
3375 (match_operand:QI 2 "register_operand")
3376 (match_operand:QI 3 "vll_bias_operand")
3377 ]
3378 "TARGET_VX && TARGET_64BIT"
3379 {
3380 rtx mem = adjust_address (operands[0], BLKmode, 0);
3381
3382 rtx len = gen_reg_rtx (SImode);
3383 emit_move_insn (len, gen_rtx_ZERO_EXTEND (SImode, operands[2]));
3384 emit_insn (gen_vstlv16qi (operands[1], len, mem));
3385 DONE;
3386 });;
3387
3388 (define_code_iterator LOGIC_OP1 [and ior xor])
3389 (define_code_iterator LOGIC_OP2 [and ior xor])
3390 (define_code_attr logic_op [(and "&") (ior "|") (xor "^")])
3391 (define_code_attr logic_op_stringify [(and "and") (ior "ior") (xor "xor")])
3392
3393 (define_insn_and_split "*veval<mode>_<LOGIC_OP1:logic_op_stringify><LOGIC_OP2:logic_op_stringify>"
3394 [(set (match_operand:VIT 0 "register_operand" "=v")
3395 (LOGIC_OP1:VIT
3396 (LOGIC_OP2:VIT
3397 (match_operand:VIT 1 "register_operand" "v")
3398 (match_operand:VIT 2 "register_operand" "v"))
3399 (match_operand:VIT 3 "register_operand" "v")))]
3400 "TARGET_VXE3"
3401 "#"
3402 "&& true"
3403 [(set (match_dup 0)
3404 (unspec:VIT [(match_dup 3)
3405 (match_dup 1)
3406 (match_dup 2)
3407 (match_dup 4)]
3408 UNSPEC_VEC_VEVAL))]
3409 {
3410 int op = 15 <LOGIC_OP1:logic_op> (23 <LOGIC_OP2:logic_op> 113);
3411 operands[4] = GEN_INT (op);
3412 })
3413
3414 (define_insn "veval<mode>"
3415 [(set (match_operand:VIT 0 "register_operand" "=v")
3416 (unspec:VIT [(match_operand:VIT 1 "register_operand" "v")
3417 (match_operand:VIT 2 "register_operand" "v")
3418 (match_operand:VIT 3 "register_operand" "v")
3419 (match_operand:QI 4 "const_int_operand")]
3420 UNSPEC_VEC_VEVAL))]
3421 "TARGET_VXE3"
3422 "veval\t%v0,%v1,%v2,%v3,%b4"
3423 [(set_attr "op_type" "VRI")])
3424
3425 ; reduc_smin
3426 ; reduc_smax
3427 ; reduc_umin
3428 ; reduc_umax
3429
3430 ; vec_pack_sfix_trunc: convert + pack ?
3431 ; vec_pack_ufix_trunc
3432 ; vec_unpacks_float_hi
3433 ; vec_unpacks_float_lo
3434 ; vec_unpacku_float_hi
3435 ; vec_unpacku_float_lo