OSDN Git Service

2005-05-09 Adrian Straetling <straetling@de.ibm.com>
[pf3gnuchains/gcc-fork.git] / gcc / config / s390 / s390.md
1 ;;- Machine description for GNU compiler -- S/390 / zSeries version.
2 ;;  Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;;  Free Software Foundation, Inc.
4 ;;  Contributed by Hartmut Penner (hpenner@de.ibm.com) and
5 ;;                 Ulrich Weigand (uweigand@de.ibm.com).
6
7 ;; This file is part of GCC.
8
9 ;; GCC is free software; you can redistribute it and/or modify it under
10 ;; the terms of the GNU General Public License as published by the Free
11 ;; Software Foundation; either version 2, or (at your option) any later
12 ;; version.
13
14 ;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 ;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17 ;; for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING.  If not, write to the Free
21 ;; Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 ;; 02111-1307, USA.
23
24 ;;
25 ;; Special constraints for s/390 machine description:
26 ;;
27 ;;    a -- Any address register from 1 to 15.
28 ;;    c -- Condition code register 33.
29 ;;    d -- Any register from 0 to 15.
30 ;;    I -- An 8-bit constant (0..255).
31 ;;    J -- A 12-bit constant (0..4095).
32 ;;    K -- A 16-bit constant (-32768..32767).
33 ;;    L -- Value appropriate as displacement.
34 ;;         (0..4095) for short displacement
35 ;;         (-524288..524287) for long displacement
36 ;;    M -- Constant integer with a value of 0x7fffffff.
37 ;;    N -- Multiple letter constraint followed by 4 parameter letters.
38 ;;         0..9,x:  number of the part counting from most to least significant
39 ;;         H,Q:     mode of the part
40 ;;         D,S,H:   mode of the containing operand
41 ;;         0,F:     value of the other parts (F - all bits set)
42 ;;
43 ;;         The constraint matches if the specified part of a constant
44 ;;         has a value different from its other parts.  If the letter x
45 ;;         is specified instead of a part number, the constraint matches
46 ;;         if there is any single part with non-default value.
47 ;;    Q -- Memory reference without index register and with short displacement.
48 ;;    R -- Memory reference with index register and short displacement.
49 ;;    S -- Memory reference without index register but with long displacement.
50 ;;    T -- Memory reference with index register and long displacement.
51 ;;    A -- Multiple letter constraint followed by Q, R, S, or T:
52 ;;         Offsettable memory reference of type specified by second letter.
53 ;;    B -- Multiple letter constraint followed by Q, R, S, or T:
54 ;;         Memory reference of the type specified by second letter that
55 ;;         does *not* refer to a literal pool entry.
56 ;;    U -- Pointer with short displacement.
57 ;;    W -- Pointer with long displacement.
58 ;;    Y -- Shift count operand.
59 ;;
60 ;; Special formats used for outputting 390 instructions.
61 ;;
62 ;;     %C: print opcode suffix for branch condition.
63 ;;     %D: print opcode suffix for inverse branch condition.
64 ;;     %J: print tls_load/tls_gdcall/tls_ldcall suffix
65 ;;     %O: print only the displacement of a memory reference.
66 ;;     %R: print only the base register of a memory reference.
67 ;;     %S: print S-type memory reference (base+displacement).
68 ;;     %N: print the second word of a DImode operand.
69 ;;     %M: print the second word of a TImode operand.
70
71 ;;     %b: print integer X as if it's an unsigned byte.
72 ;;     %x: print integer X as if it's an unsigned word.
73 ;;     %h: print integer X as if it's a signed word.
74 ;;     %i: print the first nonzero HImode part of X
75 ;;     %j: print the first HImode part unequal to 0xffff of X
76
77 ;;
78 ;; We have a special constraint for pattern matching.
79 ;;
80 ;;   s_operand -- Matches a valid S operand in a RS, SI or SS type instruction.
81 ;;
82
83 ;;
84 ;; UNSPEC usage
85 ;;
86
87 (define_constants
88   [; Miscellaneous
89    (UNSPEC_ROUND                1)
90    (UNSPEC_CMPINT               2)
91    (UNSPEC_SETHIGH              10)
92
93    ; GOT/PLT and lt-relative accesses
94    (UNSPEC_LTREL_OFFSET         100)
95    (UNSPEC_LTREL_BASE           101)
96    (UNSPEC_GOTENT               110)
97    (UNSPEC_GOT                  111)
98    (UNSPEC_GOTOFF               112)
99    (UNSPEC_PLT                  113)
100    (UNSPEC_PLTOFF               114)
101
102    ; Literal pool
103    (UNSPEC_RELOAD_BASE          210)
104    (UNSPEC_MAIN_BASE            211)
105    (UNSPEC_LTREF                212)
106    (UNSPEC_INSN                 213)
107    (UNSPEC_EXECUTE              214)
108
109    ; TLS relocation specifiers
110    (UNSPEC_TLSGD                500)
111    (UNSPEC_TLSLDM               501)
112    (UNSPEC_NTPOFF               502)
113    (UNSPEC_DTPOFF               503)
114    (UNSPEC_GOTNTPOFF            504)
115    (UNSPEC_INDNTPOFF            505)
116
117    ; TLS support
118    (UNSPEC_TLSLDM_NTPOFF        511)
119    (UNSPEC_TLS_LOAD             512)
120
121    ; String Functions
122    (UNSPEC_SRST         600)
123  ])
124
125 ;;
126 ;; UNSPEC_VOLATILE usage
127 ;;
128
129 (define_constants
130   [; Blockage
131    (UNSPECV_BLOCKAGE            0)
132
133    ; TPF Support
134    (UNSPECV_TPF_PROLOGUE        20)
135    (UNSPECV_TPF_EPILOGUE        21)
136
137    ; Literal pool
138    (UNSPECV_POOL                200)
139    (UNSPECV_POOL_SECTION        201)
140    (UNSPECV_POOL_ALIGN          202)
141    (UNSPECV_POOL_ENTRY          203)
142    (UNSPECV_MAIN_POOL           300)
143
144    ; TLS support
145    (UNSPECV_SET_TP              500)
146   ])
147
148
149 ;; Instruction operand type as used in the Principles of Operation.
150 ;; Used to determine defaults for length and other attribute values.
151
152 (define_attr "op_type"
153   "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY"
154   (const_string "NN"))
155
156 ;; Instruction type attribute used for scheduling.
157
158 (define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
159                      cs,vs,store,idiv,
160                      imulhi,imulsi,imuldi,
161                      branch,jsr,fsimpd,fsimps,
162                      floadd,floads,fstored, fstores,
163                      fmuld,fmuls,fdivd,fdivs,
164                      ftoi,itof,fsqrtd,fsqrts,
165                      other"
166   (cond [(eq_attr "op_type" "NN")  (const_string "other")
167          (eq_attr "op_type" "SS")  (const_string "cs")]
168     (const_string "integer")))
169
170 ;; Another attribute used for scheduling purposes:
171 ;;   agen: Instruction uses the address generation unit
172 ;;   reg: Instruction does not use the agen unit
173
174 (define_attr "atype" "agen,reg"
175   (cond [(eq_attr "op_type" "E")   (const_string "reg")
176          (eq_attr "op_type" "RR")  (const_string "reg")
177          (eq_attr "op_type" "RX")  (const_string "agen")
178          (eq_attr "op_type" "RI")  (const_string "reg")
179          (eq_attr "op_type" "RRE") (const_string "reg")
180          (eq_attr "op_type" "RS")  (const_string "agen")
181          (eq_attr "op_type" "RSI") (const_string "agen")
182          (eq_attr "op_type" "S")   (const_string "agen")
183          (eq_attr "op_type" "SI")  (const_string "agen")
184          (eq_attr "op_type" "SS")  (const_string "agen")
185          (eq_attr "op_type" "SSE") (const_string "agen")
186          (eq_attr "op_type" "RXE") (const_string "agen")
187          (eq_attr "op_type" "RSE") (const_string "agen")
188          (eq_attr "op_type" "RIL") (const_string "agen")
189          (eq_attr "op_type" "RXY") (const_string "agen")
190          (eq_attr "op_type" "RSY") (const_string "agen")
191          (eq_attr "op_type" "SIY") (const_string "agen")]
192     (const_string "agen")))
193
194 ;; Length in bytes.
195
196 (define_attr "length" ""
197   (cond [(eq_attr "op_type" "E")   (const_int 2)
198          (eq_attr "op_type" "RR")  (const_int 2)
199          (eq_attr "op_type" "RX")  (const_int 4)
200          (eq_attr "op_type" "RI")  (const_int 4)
201          (eq_attr "op_type" "RRE") (const_int 4)
202          (eq_attr "op_type" "RS")  (const_int 4)
203          (eq_attr "op_type" "RSI") (const_int 4)
204          (eq_attr "op_type" "S")   (const_int 4)
205          (eq_attr "op_type" "SI")  (const_int 4)
206          (eq_attr "op_type" "SS")  (const_int 6)
207          (eq_attr "op_type" "SSE") (const_int 6)
208          (eq_attr "op_type" "RXE") (const_int 6)
209          (eq_attr "op_type" "RSE") (const_int 6)
210          (eq_attr "op_type" "RIL") (const_int 6)
211          (eq_attr "op_type" "RXY") (const_int 6)
212          (eq_attr "op_type" "RSY") (const_int 6)
213          (eq_attr "op_type" "SIY") (const_int 6)]
214     (const_int 6)))
215
216
217 ;; Processor type.  This attribute must exactly match the processor_type
218 ;; enumeration in s390.h.  The current machine description does not
219 ;; distinguish between g5 and g6, but there are differences between the two
220 ;; CPUs could in theory be modeled.
221
222 (define_attr "cpu" "g5,g6,z900,z990"
223   (const (symbol_ref "s390_tune")))
224
225 ;; Pipeline description for z900.  For lack of anything better,
226 ;; this description is also used for the g5 and g6.
227 (include "2064.md")
228
229 ;; Pipeline description for z990. 
230 (include "2084.md")
231
232 ;; Predicates
233 (include "predicates.md")
234
235
236 ;; Macros
237
238 ;; This mode macro allows 31-bit and 64-bit GPR patterns to be generated
239 ;; from the same template.
240 (define_mode_macro GPR [(DI "TARGET_64BIT") SI])
241
242 ;; This mode macro allows :P to be used for patterns that operate on
243 ;; pointer-sized quantities.  Exactly one of the two alternatives will match.
244 (define_mode_macro P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
245
246 ;; This mode macro allows the QI and HI patterns to be defined from
247 ;; the same template.
248 (define_mode_macro HQI [HI QI])
249
250 ;; This mode macro allows the integer patterns to be defined from the
251 ;; same template.
252 (define_mode_macro INT [(DI "TARGET_64BIT") SI HI QI])
253
254 ;; This macro allows to unify all 'bCOND' expander patterns.
255 (define_code_macro COMPARE [eq ne gt gtu lt ltu ge geu le leu unordered 
256                             ordered uneq unlt ungt unle unge ltgt])
257
258
259 ;; ICM mask required to load MODE value into the highest subreg
260 ;; of a SImode register.
261 (define_mode_attr icm_hi [(HI "12") (QI "8")])
262
263 ;; ICM mask required to load MODE value into the lowest subreg
264 ;; of a SImode register.
265 (define_mode_attr icm_lo [(HI "3") (QI "1")])
266
267 ;; Maximum unsigned integer that fits in MODE.
268 (define_mode_attr max_uint [(HI "65535") (QI "255")])
269
270
271 ;;
272 ;;- Compare instructions.
273 ;;
274
275 (define_expand "cmp<mode>"
276   [(set (reg:CC 33)
277         (compare:CC (match_operand:GPR 0 "register_operand" "")
278                     (match_operand:GPR 1 "general_operand" "")))]
279   ""
280 {
281   s390_compare_op0 = operands[0];
282   s390_compare_op1 = operands[1];
283   DONE;
284 })
285
286 (define_expand "cmpdf"
287   [(set (reg:CC 33)
288         (compare:CC (match_operand:DF 0 "register_operand" "")
289                     (match_operand:DF 1 "general_operand" "")))]
290   "TARGET_HARD_FLOAT"
291 {
292   s390_compare_op0 = operands[0];
293   s390_compare_op1 = operands[1];
294   DONE;
295 })
296
297 (define_expand "cmpsf"
298   [(set (reg:CC 33)
299         (compare:CC (match_operand:SF 0 "register_operand" "")
300                     (match_operand:SF 1 "general_operand" "")))]
301   "TARGET_HARD_FLOAT"
302 {
303   s390_compare_op0 = operands[0];
304   s390_compare_op1 = operands[1];
305   DONE;
306 })
307
308
309 ; Test-under-Mask instructions
310
311 (define_insn "*tmqi_mem"
312   [(set (reg 33)
313         (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
314                          (match_operand:QI 1 "immediate_operand" "n,n"))
315                  (match_operand:QI 2 "immediate_operand" "n,n")))]
316   "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 0))"
317   "@
318    tm\t%S0,%b1
319    tmy\t%S0,%b1"
320   [(set_attr "op_type" "SI,SIY")])
321
322 (define_insn "*tmdi_reg"
323   [(set (reg 33)
324         (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
325                          (match_operand:DI 1 "immediate_operand"
326                                              "N0HD0,N1HD0,N2HD0,N3HD0"))
327                  (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
328   "TARGET_64BIT
329    && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 1))
330    && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
331   "@
332    tmhh\t%0,%i1
333    tmhl\t%0,%i1
334    tmlh\t%0,%i1
335    tmll\t%0,%i1"
336   [(set_attr "op_type" "RI")])
337
338 (define_insn "*tmsi_reg"
339   [(set (reg 33)
340         (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
341                          (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
342                  (match_operand:SI 2 "immediate_operand" "n,n")))]
343   "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 1))
344    && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
345   "@
346    tmh\t%0,%i1
347    tml\t%0,%i1"
348   [(set_attr "op_type" "RI")])
349
350 (define_insn "*tm<mode>_full"
351   [(set (reg 33)
352         (compare (match_operand:HQI 0 "register_operand" "d")
353                  (match_operand:HQI 1 "immediate_operand" "n")))]
354   "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], 1))"
355   "tml\t%0,<max_uint>"
356   [(set_attr "op_type" "RI")])
357
358
359 ; Load-and-Test instructions
360
361 (define_insn "*tstdi_sign"
362   [(set (reg 33)
363         (compare (ashiftrt:DI (ashift:DI (subreg:DI (match_operand:SI 0 "register_operand" "d") 0)
364                                          (const_int 32)) (const_int 32))
365                  (match_operand:DI 1 "const0_operand" "")))
366    (set (match_operand:DI 2 "register_operand" "=d")
367         (sign_extend:DI (match_dup 0)))]
368   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
369   "ltgfr\t%2,%0"
370   [(set_attr "op_type" "RRE")])
371
372 (define_insn "*tstdi"
373   [(set (reg 33)
374         (compare (match_operand:DI 0 "register_operand" "d")
375                  (match_operand:DI 1 "const0_operand" "")))
376    (set (match_operand:DI 2 "register_operand" "=d")
377         (match_dup 0))]
378   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
379   "ltgr\t%2,%0"
380   [(set_attr "op_type" "RRE")])
381
382 (define_insn "*tstdi_cconly"
383   [(set (reg 33)
384         (compare (match_operand:DI 0 "register_operand" "d")
385                  (match_operand:DI 1 "const0_operand" "")))]
386   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
387   "ltgr\t%0,%0"
388   [(set_attr "op_type" "RRE")])
389
390 (define_insn "*tstdi_cconly_31"
391   [(set (reg 33)
392         (compare (match_operand:DI 0 "register_operand" "d")
393                  (match_operand:DI 1 "const0_operand" "")))]
394   "s390_match_ccmode(insn, CCSmode) && !TARGET_64BIT"
395   "srda\t%0,0"
396   [(set_attr "op_type" "RS")
397    (set_attr "atype"   "reg")])
398
399
400 (define_insn "*tstsi"
401   [(set (reg 33)
402         (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
403                  (match_operand:SI 1 "const0_operand" "")))
404    (set (match_operand:SI 2 "register_operand" "=d,d,d")
405         (match_dup 0))]
406   "s390_match_ccmode(insn, CCSmode)"
407   "@
408    ltr\t%2,%0
409    icm\t%2,15,%S0
410    icmy\t%2,15,%S0"
411   [(set_attr "op_type" "RR,RS,RSY")])
412
413 (define_insn "*tstsi_cconly"
414   [(set (reg 33)
415         (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
416                  (match_operand:SI 1 "const0_operand" "")))
417    (clobber (match_scratch:SI 2 "=X,d,d"))]
418   "s390_match_ccmode(insn, CCSmode)"
419   "@
420    ltr\t%0,%0
421    icm\t%2,15,%S0
422    icmy\t%2,15,%S0"
423   [(set_attr "op_type" "RR,RS,RSY")])
424
425 (define_insn "*tstsi_cconly2"
426   [(set (reg 33)
427         (compare (match_operand:SI 0 "register_operand" "d")
428                  (match_operand:SI 1 "const0_operand" "")))]
429   "s390_match_ccmode(insn, CCSmode)"
430   "ltr\t%0,%0"
431   [(set_attr "op_type" "RR")])
432
433 (define_insn "*tst<mode>CCT"
434   [(set (reg 33)
435         (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
436                  (match_operand:HQI 1 "const0_operand" "")))
437    (set (match_operand:HQI 2 "register_operand" "=d,d,0")
438         (match_dup 0))]
439   "s390_match_ccmode(insn, CCTmode)"
440   "@
441    icm\t%2,<icm_lo>,%S0
442    icmy\t%2,<icm_lo>,%S0
443    tml\t%0,<max_uint>"
444   [(set_attr "op_type" "RS,RSY,RI")])
445
446 (define_insn "*tsthiCCT_cconly"
447   [(set (reg 33)
448         (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
449                  (match_operand:HI 1 "const0_operand" "")))
450    (clobber (match_scratch:HI 2 "=d,d,X"))]
451   "s390_match_ccmode(insn, CCTmode)"
452   "@
453    icm\t%2,3,%S0
454    icmy\t%2,3,%S0
455    tml\t%0,65535"
456   [(set_attr "op_type" "RS,RSY,RI")])
457
458 (define_insn "*tstqiCCT_cconly"
459   [(set (reg 33)
460         (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
461                  (match_operand:QI 1 "const0_operand" "")))]
462   "s390_match_ccmode(insn, CCTmode)"
463   "@
464    cli\t%S0,0
465    cliy\t%S0,0
466    tml\t%0,255"
467   [(set_attr "op_type" "SI,SIY,RI")])
468
469 (define_insn "*tst<mode>"
470   [(set (reg 33)
471         (compare (match_operand:HQI 0 "s_operand" "Q,S")
472                  (match_operand:HQI 1 "const0_operand" "")))
473    (set (match_operand:HQI 2 "register_operand" "=d,d")
474         (match_dup 0))]
475   "s390_match_ccmode(insn, CCSmode)"
476   "@
477    icm\t%2,<icm_lo>,%S0
478    icmy\t%2,<icm_lo>,%S0"
479   [(set_attr "op_type" "RS,RSY")])
480
481 (define_insn "*tst<mode>_cconly"
482   [(set (reg 33)
483         (compare (match_operand:HQI 0 "s_operand" "Q,S")
484                  (match_operand:HQI 1 "const0_operand" "")))
485    (clobber (match_scratch:HQI 2 "=d,d"))]
486   "s390_match_ccmode(insn, CCSmode)"
487   "@
488    icm\t%2,<icm_lo>,%S0
489    icmy\t%2,<icm_lo>,%S0"
490   [(set_attr "op_type" "RS,RSY")])
491
492
493 ; Compare (equality) instructions
494
495 (define_insn "*cmpdi_cct"
496   [(set (reg 33)
497         (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,Q")
498                  (match_operand:DI 1 "general_operand" "d,K,m,BQ")))]
499   "s390_match_ccmode (insn, CCTmode) && TARGET_64BIT"
500   "@
501    cgr\t%0,%1
502    cghi\t%0,%h1
503    cg\t%0,%1
504    #"
505   [(set_attr "op_type" "RRE,RI,RXY,SS")])
506
507 (define_insn "*cmpsi_cct"
508   [(set (reg 33)
509         (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,Q")
510                  (match_operand:SI 1 "general_operand" "d,K,R,T,BQ")))]
511   "s390_match_ccmode (insn, CCTmode)"
512   "@
513    cr\t%0,%1
514    chi\t%0,%h1
515    c\t%0,%1
516    cy\t%0,%1
517    #"
518   [(set_attr "op_type" "RR,RI,RX,RXY,SS")])
519
520
521 ; Compare (signed) instructions
522
523 (define_insn "*cmpdi_ccs_sign"
524   [(set (reg 33)
525         (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m"))
526                  (match_operand:DI 0 "register_operand" "d,d")))]
527   "s390_match_ccmode(insn, CCSRmode) && TARGET_64BIT"
528   "@
529    cgfr\t%0,%1
530    cgf\t%0,%1"
531   [(set_attr "op_type" "RRE,RXY")])
532
533 (define_insn "*cmpdi_ccs"
534   [(set (reg 33)
535         (compare (match_operand:DI 0 "register_operand" "d,d,d")
536                  (match_operand:DI 1 "general_operand" "d,K,m")))]
537   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
538   "@
539    cgr\t%0,%1
540    cghi\t%0,%h1
541    cg\t%0,%1"
542   [(set_attr "op_type" "RRE,RI,RXY")])
543
544 (define_insn "*cmpsi_ccs_sign"
545   [(set (reg 33)
546         (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T"))
547                  (match_operand:SI 0 "register_operand" "d,d")))]
548   "s390_match_ccmode(insn, CCSRmode)"
549   "@
550    ch\t%0,%1
551    chy\t%0,%1"
552   [(set_attr "op_type" "RX,RXY")])
553
554 (define_insn "*cmpsi_ccs"
555   [(set (reg 33)
556         (compare (match_operand:SI 0 "register_operand" "d,d,d,d")
557                  (match_operand:SI 1 "general_operand" "d,K,R,T")))]
558   "s390_match_ccmode(insn, CCSmode)"
559   "@
560    cr\t%0,%1
561    chi\t%0,%h1
562    c\t%0,%1
563    cy\t%0,%1"
564   [(set_attr "op_type" "RR,RI,RX,RXY")])
565
566
567 ; Compare (unsigned) instructions
568
569 (define_insn "*cmpdi_ccu_zero"
570   [(set (reg 33)
571         (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m"))
572                  (match_operand:DI 0 "register_operand" "d,d")))]
573   "s390_match_ccmode (insn, CCURmode) && TARGET_64BIT"
574   "@
575    clgfr\t%0,%1
576    clgf\t%0,%1"
577   [(set_attr "op_type" "RRE,RXY")])
578
579 (define_insn "*cmpdi_ccu"
580   [(set (reg 33)
581         (compare (match_operand:DI 0 "nonimmediate_operand" "d,d,Q,BQ")
582                  (match_operand:DI 1 "general_operand" "d,m,BQ,Q")))]
583   "s390_match_ccmode (insn, CCUmode) && TARGET_64BIT"
584   "@
585    clgr\t%0,%1
586    clg\t%0,%1
587    #
588    #"
589   [(set_attr "op_type" "RRE,RXY,SS,SS")])
590
591 (define_insn "*cmpsi_ccu"
592   [(set (reg 33)
593         (compare (match_operand:SI 0 "nonimmediate_operand" "d,d,d,Q,BQ")
594                  (match_operand:SI 1 "general_operand" "d,R,T,BQ,Q")))]
595   "s390_match_ccmode (insn, CCUmode)"
596   "@
597    clr\t%0,%1
598    cl\t%0,%1
599    cly\t%0,%1
600    #
601    #"
602   [(set_attr "op_type" "RR,RX,RXY,SS,SS")])
603
604 (define_insn "*cmphi_ccu"
605   [(set (reg 33)
606         (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,BQ")
607                  (match_operand:HI 1 "general_operand" "Q,S,BQ,Q")))]
608   "s390_match_ccmode (insn, CCUmode)
609    && !register_operand (operands[1], HImode)"
610   "@
611    clm\t%0,3,%S1
612    clmy\t%0,3,%S1
613    #
614    #"
615   [(set_attr "op_type" "RS,RSY,SS,SS")])
616
617 (define_insn "*cmpqi_ccu"
618   [(set (reg 33)
619         (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
620                  (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
621   "s390_match_ccmode (insn, CCUmode)
622    && !register_operand (operands[1], QImode)"
623   "@
624    clm\t%0,1,%S1
625    clmy\t%0,1,%S1
626    cli\t%S0,%b1
627    cliy\t%S0,%b1
628    #
629    #"
630   [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")])
631
632
633 ; Block compare (CLC) instruction patterns.
634
635 (define_insn "*clc"
636   [(set (reg 33)
637         (compare (match_operand:BLK 0 "memory_operand" "Q")
638                  (match_operand:BLK 1 "memory_operand" "Q")))
639    (use (match_operand 2 "const_int_operand" "n"))]
640   "s390_match_ccmode (insn, CCUmode)
641    && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
642   "clc\t%O0(%2,%R0),%S1"
643   [(set_attr "op_type" "SS")])
644
645 (define_split
646   [(set (reg 33)
647         (compare (match_operand 0 "memory_operand" "")
648                  (match_operand 1 "memory_operand" "")))]
649   "reload_completed
650    && s390_match_ccmode (insn, CCUmode)
651    && GET_MODE (operands[0]) == GET_MODE (operands[1])
652    && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
653   [(parallel
654     [(set (match_dup 0) (match_dup 1))
655      (use (match_dup 2))])]
656 {
657   operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
658   operands[0] = adjust_address (operands[0], BLKmode, 0);
659   operands[1] = adjust_address (operands[1], BLKmode, 0);
660
661   operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
662                                  operands[0], operands[1]);
663   operands[0] = SET_DEST (PATTERN (curr_insn));
664 })
665
666
667 ; DF instructions
668
669 (define_insn "*cmpdf_ccs_0"
670   [(set (reg 33)
671         (compare (match_operand:DF 0 "register_operand" "f")
672                  (match_operand:DF 1 "const0_operand" "")))]
673   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
674   "ltdbr\t%0,%0"
675    [(set_attr "op_type" "RRE")
676     (set_attr "type"  "fsimpd")])
677
678 (define_insn "*cmpdf_ccs_0_ibm"
679   [(set (reg 33)
680         (compare (match_operand:DF 0 "register_operand" "f")
681                  (match_operand:DF 1 "const0_operand" "")))]
682   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
683   "ltdr\t%0,%0"
684    [(set_attr "op_type" "RR")
685     (set_attr "type"  "fsimpd")])
686
687 (define_insn "*cmpdf_ccs"
688   [(set (reg 33)
689         (compare (match_operand:DF 0 "register_operand" "f,f")
690                  (match_operand:DF 1 "general_operand" "f,R")))]
691   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
692   "@
693    cdbr\t%0,%1
694    cdb\t%0,%1"
695    [(set_attr "op_type" "RRE,RXE")
696     (set_attr "type"  "fsimpd")])
697
698 (define_insn "*cmpdf_ccs_ibm"
699   [(set (reg 33)
700         (compare (match_operand:DF 0 "register_operand" "f,f")
701                  (match_operand:DF 1 "general_operand" "f,R")))]
702   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
703   "@
704    cdr\t%0,%1
705    cd\t%0,%1"
706    [(set_attr "op_type" "RR,RX")
707     (set_attr "type"  "fsimpd")])
708
709
710 ; SF instructions
711
712 (define_insn "*cmpsf_ccs_0"
713   [(set (reg 33)
714         (compare (match_operand:SF 0 "register_operand" "f")
715                  (match_operand:SF 1 "const0_operand" "")))]
716   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
717   "ltebr\t%0,%0"
718    [(set_attr "op_type" "RRE")
719     (set_attr "type"  "fsimps")])
720
721 (define_insn "*cmpsf_ccs_0_ibm"
722   [(set (reg 33)
723         (compare (match_operand:SF 0 "register_operand" "f")
724                  (match_operand:SF 1 "const0_operand" "")))]
725   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
726   "lter\t%0,%0"
727    [(set_attr "op_type" "RR")
728     (set_attr "type"  "fsimps")])
729
730 (define_insn "*cmpsf_ccs"
731   [(set (reg 33)
732         (compare (match_operand:SF 0 "register_operand" "f,f")
733                  (match_operand:SF 1 "general_operand" "f,R")))]
734   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
735   "@
736    cebr\t%0,%1
737    ceb\t%0,%1"
738    [(set_attr "op_type" "RRE,RXE")
739     (set_attr "type"  "fsimps")])
740
741 (define_insn "*cmpsf_ccs"
742   [(set (reg 33)
743         (compare (match_operand:SF 0 "register_operand" "f,f")
744                  (match_operand:SF 1 "general_operand" "f,R")))]
745   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
746   "@
747    cer\t%0,%1
748    ce\t%0,%1"
749    [(set_attr "op_type" "RR,RX")
750     (set_attr "type"  "fsimps")])
751
752
753 ;;
754 ;;- Move instructions.
755 ;;
756
757 ;
758 ; movti instruction pattern(s).
759 ;
760
761 (define_insn "movti"
762   [(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o,Q")
763         (match_operand:TI 1 "general_operand" "QS,d,dKm,d,Q"))]
764   "TARGET_64BIT"
765   "@
766    lmg\t%0,%N0,%S1
767    stmg\t%1,%N1,%S0
768    #
769    #
770    #"
771   [(set_attr "op_type" "RSY,RSY,*,*,SS")
772    (set_attr "type" "lm,stm,*,*,*")])
773
774 (define_split
775   [(set (match_operand:TI 0 "nonimmediate_operand" "")
776         (match_operand:TI 1 "general_operand" ""))]
777   "TARGET_64BIT && reload_completed
778    && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
779   [(set (match_dup 2) (match_dup 4))
780    (set (match_dup 3) (match_dup 5))]
781 {
782   operands[2] = operand_subword (operands[0], 0, 0, TImode);
783   operands[3] = operand_subword (operands[0], 1, 0, TImode);
784   operands[4] = operand_subword (operands[1], 0, 0, TImode);
785   operands[5] = operand_subword (operands[1], 1, 0, TImode);
786 })
787
788 (define_split
789   [(set (match_operand:TI 0 "nonimmediate_operand" "")
790         (match_operand:TI 1 "general_operand" ""))]
791   "TARGET_64BIT && reload_completed
792    && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
793   [(set (match_dup 2) (match_dup 4))
794    (set (match_dup 3) (match_dup 5))]
795 {
796   operands[2] = operand_subword (operands[0], 1, 0, TImode);
797   operands[3] = operand_subword (operands[0], 0, 0, TImode);
798   operands[4] = operand_subword (operands[1], 1, 0, TImode);
799   operands[5] = operand_subword (operands[1], 0, 0, TImode);
800 })
801
802 (define_split
803   [(set (match_operand:TI 0 "register_operand" "")
804         (match_operand:TI 1 "memory_operand" ""))]
805   "TARGET_64BIT && reload_completed
806    && !s_operand (operands[1], VOIDmode)"
807   [(set (match_dup 0) (match_dup 1))]
808 {
809   rtx addr = operand_subword (operands[0], 1, 0, TImode);
810   s390_load_address (addr, XEXP (operands[1], 0));
811   operands[1] = replace_equiv_address (operands[1], addr);
812 })
813
814 (define_expand "reload_outti"
815   [(parallel [(match_operand:TI 0 "" "")
816               (match_operand:TI 1 "register_operand" "d")
817               (match_operand:DI 2 "register_operand" "=&a")])]
818   "TARGET_64BIT"
819 {
820   gcc_assert (MEM_P (operands[0]));
821   s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
822   operands[0] = replace_equiv_address (operands[0], operands[2]);
823   emit_move_insn (operands[0], operands[1]);
824   DONE;
825 })
826
827 ;
828 ; movdi instruction pattern(s).
829 ;
830
831 (define_expand "movdi"
832   [(set (match_operand:DI 0 "general_operand" "")
833         (match_operand:DI 1 "general_operand" ""))]
834   ""
835 {
836   /* Handle symbolic constants.  */
837   if (TARGET_64BIT && SYMBOLIC_CONST (operands[1]))
838     emit_symbolic_move (operands);
839 })
840
841 (define_insn "*movdi_larl"
842   [(set (match_operand:DI 0 "register_operand" "=d")
843         (match_operand:DI 1 "larl_operand" "X"))]
844   "TARGET_64BIT
845    && !FP_REG_P (operands[0])"
846   "larl\t%0,%1"
847    [(set_attr "op_type" "RIL")
848     (set_attr "type"    "larl")])
849
850 (define_insn "*movdi_64"
851   [(set (match_operand:DI 0 "nonimmediate_operand"
852                             "=d,d,d,d,d,d,d,d,m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
853         (match_operand:DI 1 "general_operand"
854                             "K,N0HD0,N1HD0,N2HD0,N3HD0,L,d,m,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
855   "TARGET_64BIT"
856   "@
857    lghi\t%0,%h1
858    llihh\t%0,%i1
859    llihl\t%0,%i1
860    llilh\t%0,%i1
861    llill\t%0,%i1
862    lay\t%0,%a1
863    lgr\t%0,%1
864    lg\t%0,%1
865    stg\t%1,%0
866    ldr\t%0,%1
867    ld\t%0,%1
868    ldy\t%0,%1
869    std\t%1,%0
870    stdy\t%1,%0
871    #
872    #
873    stam\t%1,%N1,%S0
874    lam\t%0,%N0,%S1
875    #"
876   [(set_attr "op_type" "RI,RI,RI,RI,RI,RXY,RRE,RXY,RXY,
877                         RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
878    (set_attr "type" "*,*,*,*,*,la,lr,load,store,
879                      floadd,floadd,floadd,fstored,fstored,*,*,*,*,*")])
880
881 (define_split
882   [(set (match_operand:DI 0 "register_operand" "")
883         (match_operand:DI 1 "register_operand" ""))]
884   "TARGET_64BIT && ACCESS_REG_P (operands[1])"
885   [(set (match_dup 2) (match_dup 3))
886    (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
887    (set (strict_low_part (match_dup 2)) (match_dup 4))]
888   "operands[2] = gen_lowpart (SImode, operands[0]);
889    s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
890
891 (define_split
892   [(set (match_operand:DI 0 "register_operand" "")
893         (match_operand:DI 1 "register_operand" ""))]
894   "TARGET_64BIT && ACCESS_REG_P (operands[0])
895    && dead_or_set_p (insn, operands[1])"
896   [(set (match_dup 3) (match_dup 2))
897    (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
898    (set (match_dup 4) (match_dup 2))]
899   "operands[2] = gen_lowpart (SImode, operands[1]);
900    s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
901
902 (define_split
903   [(set (match_operand:DI 0 "register_operand" "")
904         (match_operand:DI 1 "register_operand" ""))]
905   "TARGET_64BIT && ACCESS_REG_P (operands[0])
906    && !dead_or_set_p (insn, operands[1])"
907   [(set (match_dup 3) (match_dup 2))
908    (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
909    (set (match_dup 4) (match_dup 2))
910    (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
911   "operands[2] = gen_lowpart (SImode, operands[1]);
912    s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
913
914 (define_insn "*movdi_31"
915   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,Q,d,o,!*f,!*f,!*f,!R,!T,Q")
916         (match_operand:DI 1 "general_operand" "Q,d,dKm,d,*f,R,T,*f,*f,Q"))]
917   "!TARGET_64BIT"
918   "@
919    lm\t%0,%N0,%S1
920    stm\t%1,%N1,%S0
921    #
922    #
923    ldr\t%0,%1
924    ld\t%0,%1
925    ldy\t%0,%1
926    std\t%1,%0
927    stdy\t%1,%0
928    #"
929   [(set_attr "op_type" "RS,RS,*,*,RR,RX,RXY,RX,RXY,SS")
930    (set_attr "type" "lm,stm,*,*,floadd,floadd,floadd,fstored,fstored,*")])
931
932 (define_split
933   [(set (match_operand:DI 0 "nonimmediate_operand" "")
934         (match_operand:DI 1 "general_operand" ""))]
935   "!TARGET_64BIT && reload_completed
936    && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
937   [(set (match_dup 2) (match_dup 4))
938    (set (match_dup 3) (match_dup 5))]
939 {
940   operands[2] = operand_subword (operands[0], 0, 0, DImode);
941   operands[3] = operand_subword (operands[0], 1, 0, DImode);
942   operands[4] = operand_subword (operands[1], 0, 0, DImode);
943   operands[5] = operand_subword (operands[1], 1, 0, DImode);
944 })
945
946 (define_split
947   [(set (match_operand:DI 0 "nonimmediate_operand" "")
948         (match_operand:DI 1 "general_operand" ""))]
949   "!TARGET_64BIT && reload_completed
950    && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
951   [(set (match_dup 2) (match_dup 4))
952    (set (match_dup 3) (match_dup 5))]
953 {
954   operands[2] = operand_subword (operands[0], 1, 0, DImode);
955   operands[3] = operand_subword (operands[0], 0, 0, DImode);
956   operands[4] = operand_subword (operands[1], 1, 0, DImode);
957   operands[5] = operand_subword (operands[1], 0, 0, DImode);
958 })
959
960 (define_split
961   [(set (match_operand:DI 0 "register_operand" "")
962         (match_operand:DI 1 "memory_operand" ""))]
963   "!TARGET_64BIT && reload_completed
964    && !FP_REG_P (operands[0])
965    && !s_operand (operands[1], VOIDmode)"
966   [(set (match_dup 0) (match_dup 1))]
967 {
968   rtx addr = operand_subword (operands[0], 1, 0, DImode);
969   s390_load_address (addr, XEXP (operands[1], 0));
970   operands[1] = replace_equiv_address (operands[1], addr);
971 })
972
973 (define_expand "reload_outdi"
974   [(parallel [(match_operand:DI 0 "" "")
975               (match_operand:DI 1 "register_operand" "d")
976               (match_operand:SI 2 "register_operand" "=&a")])]
977   "!TARGET_64BIT"
978 {
979   gcc_assert (MEM_P (operands[0]));
980   s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
981   operands[0] = replace_equiv_address (operands[0], operands[2]);
982   emit_move_insn (operands[0], operands[1]);
983   DONE;
984 })
985
986 (define_peephole2
987   [(set (match_operand:DI 0 "register_operand" "")
988         (mem:DI (match_operand 1 "address_operand" "")))]
989   "TARGET_64BIT
990    && !FP_REG_P (operands[0])
991    && GET_CODE (operands[1]) == SYMBOL_REF
992    && CONSTANT_POOL_ADDRESS_P (operands[1])
993    && get_pool_mode (operands[1]) == DImode
994    && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
995   [(set (match_dup 0) (match_dup 2))]
996   "operands[2] = get_pool_constant (operands[1]);")
997
998 (define_insn "*la_64"
999   [(set (match_operand:DI 0 "register_operand" "=d,d")
1000         (match_operand:QI 1 "address_operand" "U,W"))]
1001   "TARGET_64BIT"
1002   "@
1003    la\t%0,%a1
1004    lay\t%0,%a1"
1005   [(set_attr "op_type" "RX,RXY")
1006    (set_attr "type"    "la")])
1007
1008 (define_peephole2
1009   [(parallel
1010     [(set (match_operand:DI 0 "register_operand" "")
1011           (match_operand:QI 1 "address_operand" ""))
1012      (clobber (reg:CC 33))])]
1013   "TARGET_64BIT
1014    && preferred_la_operand_p (operands[1], const0_rtx)"
1015   [(set (match_dup 0) (match_dup 1))]
1016   "")
1017
1018 (define_peephole2
1019   [(set (match_operand:DI 0 "register_operand" "")
1020         (match_operand:DI 1 "register_operand" ""))
1021    (parallel
1022     [(set (match_dup 0)
1023           (plus:DI (match_dup 0)
1024                    (match_operand:DI 2 "nonmemory_operand" "")))
1025      (clobber (reg:CC 33))])]
1026   "TARGET_64BIT
1027    && !reg_overlap_mentioned_p (operands[0], operands[2])
1028    && preferred_la_operand_p (operands[1], operands[2])"
1029   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1030   "")
1031
1032 (define_expand "reload_indi"
1033   [(parallel [(match_operand:DI 0 "register_operand" "=a")
1034               (match_operand:DI 1 "s390_plus_operand" "")
1035               (match_operand:DI 2 "register_operand" "=&a")])]
1036   "TARGET_64BIT"
1037 {
1038   s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1039   DONE;
1040 })
1041
1042 ;
1043 ; movsi instruction pattern(s).
1044 ;
1045
1046 (define_expand "movsi"
1047   [(set (match_operand:SI 0 "general_operand" "")
1048         (match_operand:SI 1 "general_operand" ""))]
1049   ""
1050 {
1051   /* Handle symbolic constants.  */
1052   if (!TARGET_64BIT && SYMBOLIC_CONST (operands[1]))
1053     emit_symbolic_move (operands);
1054 })
1055
1056 (define_insn "*movsi_larl"
1057   [(set (match_operand:SI 0 "register_operand" "=d")
1058         (match_operand:SI 1 "larl_operand" "X"))]
1059   "!TARGET_64BIT && TARGET_CPU_ZARCH
1060    && !FP_REG_P (operands[0])"
1061   "larl\t%0,%1"
1062    [(set_attr "op_type" "RIL")
1063     (set_attr "type"    "larl")])
1064
1065 (define_insn "*movsi_zarch"
1066   [(set (match_operand:SI 0 "nonimmediate_operand"
1067                             "=d,d,d,d,d,d,d,R,T,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
1068         (match_operand:SI 1 "general_operand"
1069                             "K,N0HS0,N1HS0,L,d,R,T,d,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
1070   "TARGET_ZARCH"
1071   "@
1072    lhi\t%0,%h1
1073    llilh\t%0,%i1
1074    llill\t%0,%i1
1075    lay\t%0,%a1
1076    lr\t%0,%1
1077    l\t%0,%1
1078    ly\t%0,%1
1079    st\t%1,%0
1080    sty\t%1,%0
1081    ler\t%0,%1
1082    le\t%0,%1
1083    ley\t%0,%1
1084    ste\t%1,%0
1085    stey\t%1,%0
1086    ear\t%0,%1
1087    sar\t%0,%1
1088    stam\t%1,%1,%S0
1089    lam\t%0,%0,%S1
1090    #"
1091   [(set_attr "op_type" "RI,RI,RI,RXY,RR,RX,RXY,RX,RXY,
1092                         RR,RX,RXY,RX,RXY,RRE,RRE,RS,RS,SS")
1093    (set_attr "type" "*,*,*,la,lr,load,load,store,store,
1094                      floads,floads,floads,fstores,fstores,*,*,*,*,*")])
1095
1096 (define_insn "*movsi_esa"
1097   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!R,d,t,Q,t,?Q")
1098         (match_operand:SI 1 "general_operand" "K,d,R,d,*f,R,*f,t,d,t,Q,?Q"))]
1099   "!TARGET_ZARCH"
1100   "@
1101    lhi\t%0,%h1
1102    lr\t%0,%1
1103    l\t%0,%1
1104    st\t%1,%0
1105    ler\t%0,%1
1106    le\t%0,%1
1107    ste\t%1,%0
1108    ear\t%0,%1
1109    sar\t%0,%1
1110    stam\t%1,%1,%S0
1111    lam\t%0,%0,%S1
1112    #"
1113   [(set_attr "op_type" "RI,RR,RX,RX,RR,RX,RX,RRE,RRE,RS,RS,SS")
1114    (set_attr "type" "*,lr,load,store,floads,floads,fstores,*,*,*,*,*")])
1115
1116 (define_peephole2
1117   [(set (match_operand:SI 0 "register_operand" "")
1118         (mem:SI (match_operand 1 "address_operand" "")))]
1119   "!FP_REG_P (operands[0])
1120    && GET_CODE (operands[1]) == SYMBOL_REF
1121    && CONSTANT_POOL_ADDRESS_P (operands[1])
1122    && get_pool_mode (operands[1]) == SImode
1123    && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1124   [(set (match_dup 0) (match_dup 2))]
1125   "operands[2] = get_pool_constant (operands[1]);")
1126
1127 (define_insn "*la_31"
1128   [(set (match_operand:SI 0 "register_operand" "=d,d")
1129         (match_operand:QI 1 "address_operand" "U,W"))]
1130   "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
1131   "@
1132    la\t%0,%a1
1133    lay\t%0,%a1"
1134   [(set_attr "op_type"  "RX,RXY")
1135    (set_attr "type"     "la")])
1136
1137 (define_peephole2
1138   [(parallel
1139     [(set (match_operand:SI 0 "register_operand" "")
1140           (match_operand:QI 1 "address_operand" ""))
1141      (clobber (reg:CC 33))])]
1142   "!TARGET_64BIT
1143    && preferred_la_operand_p (operands[1], const0_rtx)"
1144   [(set (match_dup 0) (match_dup 1))]
1145   "")
1146
1147 (define_peephole2
1148   [(set (match_operand:SI 0 "register_operand" "")
1149         (match_operand:SI 1 "register_operand" ""))
1150    (parallel
1151     [(set (match_dup 0)
1152           (plus:SI (match_dup 0)
1153                    (match_operand:SI 2 "nonmemory_operand" "")))
1154      (clobber (reg:CC 33))])]
1155   "!TARGET_64BIT
1156    && !reg_overlap_mentioned_p (operands[0], operands[2])
1157    && preferred_la_operand_p (operands[1], operands[2])"
1158   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
1159   "")
1160
1161 (define_insn "*la_31_and"
1162   [(set (match_operand:SI 0 "register_operand" "=d,d")
1163         (and:SI (match_operand:QI 1 "address_operand" "U,W")
1164                 (const_int 2147483647)))]
1165   "!TARGET_64BIT"
1166   "@
1167    la\t%0,%a1
1168    lay\t%0,%a1"
1169   [(set_attr "op_type"  "RX,RXY")
1170    (set_attr "type"     "la")])
1171
1172 (define_insn_and_split "*la_31_and_cc"
1173   [(set (match_operand:SI 0 "register_operand" "=d")
1174         (and:SI (match_operand:QI 1 "address_operand" "p")
1175                 (const_int 2147483647)))
1176    (clobber (reg:CC 33))]
1177   "!TARGET_64BIT"
1178   "#"
1179   "&& reload_completed"
1180   [(set (match_dup 0)
1181         (and:SI (match_dup 1) (const_int 2147483647)))]
1182   ""
1183   [(set_attr "op_type"  "RX")
1184    (set_attr "type"     "la")])
1185
1186 (define_insn "force_la_31"
1187   [(set (match_operand:SI 0 "register_operand" "=d,d")
1188         (match_operand:QI 1 "address_operand" "U,W"))
1189    (use (const_int 0))]
1190   "!TARGET_64BIT"
1191   "@
1192    la\t%0,%a1
1193    lay\t%0,%a1"
1194   [(set_attr "op_type"  "RX")
1195    (set_attr "type"     "la")])
1196
1197 (define_expand "reload_insi"
1198   [(parallel [(match_operand:SI 0 "register_operand" "=a")
1199               (match_operand:SI 1 "s390_plus_operand" "")
1200               (match_operand:SI 2 "register_operand" "=&a")])]
1201   "!TARGET_64BIT"
1202 {
1203   s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1204   DONE;
1205 })
1206
1207 ;
1208 ; movhi instruction pattern(s).
1209 ;
1210
1211 (define_expand "movhi"
1212   [(set (match_operand:HI 0 "nonimmediate_operand" "")
1213         (match_operand:HI 1 "general_operand" ""))]
1214   ""
1215 {
1216   /* Make it explicit that loading a register from memory
1217      always sign-extends (at least) to SImode.  */
1218   if (optimize && !no_new_pseudos
1219       && register_operand (operands[0], VOIDmode)
1220       && GET_CODE (operands[1]) == MEM)
1221     {
1222       rtx tmp = gen_reg_rtx (SImode);
1223       rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
1224       emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1225       operands[1] = gen_lowpart (HImode, tmp);
1226     }
1227 })
1228
1229 (define_insn "*movhi"
1230   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,R,T,?Q")
1231         (match_operand:HI 1 "general_operand" "d,n,R,T,d,d,?Q"))]
1232   ""
1233   "@
1234    lr\t%0,%1
1235    lhi\t%0,%h1
1236    lh\t%0,%1
1237    lhy\t%0,%1
1238    sth\t%1,%0
1239    sthy\t%1,%0
1240    #"
1241   [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SS")
1242    (set_attr "type" "lr,*,*,*,store,store,*")])
1243
1244 (define_peephole2
1245   [(set (match_operand:HI 0 "register_operand" "")
1246         (mem:HI (match_operand 1 "address_operand" "")))]
1247   "GET_CODE (operands[1]) == SYMBOL_REF
1248    && CONSTANT_POOL_ADDRESS_P (operands[1])
1249    && get_pool_mode (operands[1]) == HImode
1250    && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1251   [(set (match_dup 0) (match_dup 2))]
1252   "operands[2] = get_pool_constant (operands[1]);")
1253
1254 ;
1255 ; movqi instruction pattern(s).
1256 ;
1257
1258 (define_expand "movqi"
1259   [(set (match_operand:QI 0 "nonimmediate_operand" "")
1260         (match_operand:QI 1 "general_operand" ""))]
1261   ""
1262 {
1263   /* On z/Architecture, zero-extending from memory to register
1264      is just as fast as a QImode load.  */
1265   if (TARGET_ZARCH && optimize && !no_new_pseudos
1266       && register_operand (operands[0], VOIDmode)
1267       && GET_CODE (operands[1]) == MEM)
1268     {
1269       rtx tmp = gen_reg_rtx (word_mode);
1270       rtx ext = gen_rtx_ZERO_EXTEND (word_mode, operands[1]);
1271       emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1272       operands[1] = gen_lowpart (QImode, tmp);
1273     }
1274 })
1275
1276 (define_insn "*movqi"
1277   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q")
1278         (match_operand:QI 1 "general_operand" "d,n,R,T,d,d,n,n,?Q"))]
1279   ""
1280   "@
1281    lr\t%0,%1
1282    lhi\t%0,%b1
1283    ic\t%0,%1
1284    icy\t%0,%1
1285    stc\t%1,%0
1286    stcy\t%1,%0
1287    mvi\t%S0,%b1
1288    mviy\t%S0,%b1
1289    #"
1290   [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS")
1291    (set_attr "type" "lr,*,*,*,store,store,store,store,*")])
1292
1293 (define_peephole2
1294   [(set (match_operand:QI 0 "nonimmediate_operand" "")
1295         (mem:QI (match_operand 1 "address_operand" "")))]
1296   "GET_CODE (operands[1]) == SYMBOL_REF
1297    && CONSTANT_POOL_ADDRESS_P (operands[1])
1298    && get_pool_mode (operands[1]) == QImode
1299    && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1300   [(set (match_dup 0) (match_dup 2))]
1301   "operands[2] = get_pool_constant (operands[1]);")
1302
1303 ;
1304 ; movstrictqi instruction pattern(s).
1305 ;
1306
1307 (define_insn "*movstrictqi"
1308   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
1309                          (match_operand:QI 1 "memory_operand" "R,T"))]
1310   ""
1311   "@
1312    ic\t%0,%1
1313    icy\t%0,%1"
1314   [(set_attr "op_type"  "RX,RXY")])
1315
1316 ;
1317 ; movstricthi instruction pattern(s).
1318 ;
1319
1320 (define_insn "*movstricthi"
1321   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
1322                          (match_operand:HI 1 "memory_operand" "Q,S"))
1323    (clobber (reg:CC 33))]
1324   ""
1325   "@
1326    icm\t%0,3,%S1
1327    icmy\t%0,3,%S1"
1328   [(set_attr "op_type" "RS,RSY")])
1329
1330 ;
1331 ; movstrictsi instruction pattern(s).
1332 ;
1333
1334 (define_insn "movstrictsi"
1335   [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
1336                          (match_operand:SI 1 "general_operand" "d,R,T,t"))]
1337   "TARGET_64BIT"
1338   "@
1339    lr\t%0,%1
1340    l\t%0,%1
1341    ly\t%0,%1
1342    ear\t%0,%1"
1343   [(set_attr "op_type" "RR,RX,RXY,RRE")
1344    (set_attr "type" "lr,load,load,*")])
1345
1346 ;
1347 ; movdf instruction pattern(s).
1348 ;
1349
1350 (define_expand "movdf"
1351   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1352         (match_operand:DF 1 "general_operand"  ""))]
1353   ""
1354   "")
1355
1356 (define_insn "*movdf_64"
1357   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,R,T,d,d,m,?Q")
1358         (match_operand:DF 1 "general_operand" "f,R,T,f,f,d,m,d,?Q"))]
1359   "TARGET_64BIT"
1360   "@
1361    ldr\t%0,%1
1362    ld\t%0,%1
1363    ldy\t%0,%1
1364    std\t%1,%0
1365    stdy\t%1,%0
1366    lgr\t%0,%1
1367    lg\t%0,%1
1368    stg\t%1,%0
1369    #"
1370   [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RRE,RXY,RXY,SS")
1371    (set_attr "type" "floadd,floadd,floadd,fstored,fstored,lr,load,store,*")])
1372
1373 (define_insn "*movdf_31"
1374   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,R,T,d,Q,d,o,Q")
1375         (match_operand:DF 1 "general_operand" "f,R,T,f,f,Q,d,dKm,d,Q"))]
1376   "!TARGET_64BIT"
1377   "@
1378    ldr\t%0,%1
1379    ld\t%0,%1
1380    ldy\t%0,%1
1381    std\t%1,%0
1382    stdy\t%1,%0
1383    lm\t%0,%N0,%S1
1384    stm\t%1,%N1,%S0
1385    #
1386    #
1387    #"
1388   [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RS,RS,*,*,SS")
1389    (set_attr "type" "floadd,floadd,floadd,fstored,fstored,lm,stm,*,*,*")])
1390
1391 (define_split
1392   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1393         (match_operand:DF 1 "general_operand" ""))]
1394   "!TARGET_64BIT && reload_completed
1395    && s390_split_ok_p (operands[0], operands[1], DFmode, 0)"
1396   [(set (match_dup 2) (match_dup 4))
1397    (set (match_dup 3) (match_dup 5))]
1398 {
1399   operands[2] = operand_subword (operands[0], 0, 0, DFmode);
1400   operands[3] = operand_subword (operands[0], 1, 0, DFmode);
1401   operands[4] = operand_subword (operands[1], 0, 0, DFmode);
1402   operands[5] = operand_subword (operands[1], 1, 0, DFmode);
1403 })
1404
1405 (define_split
1406   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1407         (match_operand:DF 1 "general_operand" ""))]
1408   "!TARGET_64BIT && reload_completed
1409    && s390_split_ok_p (operands[0], operands[1], DFmode, 1)"
1410   [(set (match_dup 2) (match_dup 4))
1411    (set (match_dup 3) (match_dup 5))]
1412 {
1413   operands[2] = operand_subword (operands[0], 1, 0, DFmode);
1414   operands[3] = operand_subword (operands[0], 0, 0, DFmode);
1415   operands[4] = operand_subword (operands[1], 1, 0, DFmode);
1416   operands[5] = operand_subword (operands[1], 0, 0, DFmode);
1417 })
1418
1419 (define_split
1420   [(set (match_operand:DF 0 "register_operand" "")
1421         (match_operand:DF 1 "memory_operand" ""))]
1422   "!TARGET_64BIT && reload_completed
1423    && !FP_REG_P (operands[0])
1424    && !s_operand (operands[1], VOIDmode)"
1425   [(set (match_dup 0) (match_dup 1))]
1426 {
1427   rtx addr = operand_subword (operands[0], 1, 0, DFmode);
1428   s390_load_address (addr, XEXP (operands[1], 0));
1429   operands[1] = replace_equiv_address (operands[1], addr);
1430 })
1431
1432 (define_expand "reload_outdf"
1433   [(parallel [(match_operand:DF 0 "" "")
1434               (match_operand:DF 1 "register_operand" "d")
1435               (match_operand:SI 2 "register_operand" "=&a")])]
1436   "!TARGET_64BIT"
1437 {
1438   gcc_assert (MEM_P (operands[0]));
1439   s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
1440   operands[0] = replace_equiv_address (operands[0], operands[2]);
1441   emit_move_insn (operands[0], operands[1]);
1442   DONE;
1443 })
1444
1445 ;
1446 ; movsf instruction pattern(s).
1447 ;
1448
1449 (define_insn "movsf"
1450   [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,R,T,d,d,d,R,T,?Q")
1451         (match_operand:SF 1 "general_operand" "f,R,T,f,f,d,R,T,d,d,?Q"))]
1452   ""
1453   "@
1454    ler\t%0,%1
1455    le\t%0,%1
1456    ley\t%0,%1
1457    ste\t%1,%0
1458    stey\t%1,%0
1459    lr\t%0,%1
1460    l\t%0,%1
1461    ly\t%0,%1
1462    st\t%1,%0
1463    sty\t%1,%0
1464    #"
1465   [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RR,RX,RXY,RX,RXY,SS")
1466    (set_attr "type" "floads,floads,floads,fstores,fstores,
1467                      lr,load,load,store,store,*")])
1468
1469 ;
1470 ; movcc instruction pattern
1471 ;
1472
1473 (define_insn "movcc"
1474   [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
1475         (match_operand:CC 1 "nonimmediate_operand" "d,d,c,R,T,d,d"))]
1476   ""
1477   "@
1478    lr\t%0,%1
1479    tmh\t%1,12288
1480    ipm\t%0
1481    st\t%0,%1
1482    sty\t%0,%1
1483    l\t%1,%0
1484    ly\t%1,%0"
1485   [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
1486    (set_attr "type" "lr,*,*,store,store,load,load")])
1487
1488 ;
1489 ; Block move (MVC) patterns.
1490 ;
1491
1492 (define_insn "*mvc"
1493   [(set (match_operand:BLK 0 "memory_operand" "=Q")
1494         (match_operand:BLK 1 "memory_operand" "Q"))
1495    (use (match_operand 2 "const_int_operand" "n"))]
1496   "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
1497   "mvc\t%O0(%2,%R0),%S1"
1498   [(set_attr "op_type" "SS")])
1499
1500 (define_split
1501   [(set (match_operand 0 "memory_operand" "")
1502         (match_operand 1 "memory_operand" ""))]
1503   "reload_completed
1504    && GET_MODE (operands[0]) == GET_MODE (operands[1])
1505    && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
1506   [(parallel
1507     [(set (match_dup 0) (match_dup 1))
1508      (use (match_dup 2))])]
1509 {
1510   operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
1511   operands[0] = adjust_address (operands[0], BLKmode, 0);
1512   operands[1] = adjust_address (operands[1], BLKmode, 0);
1513 })
1514
1515 (define_peephole2
1516   [(parallel
1517     [(set (match_operand:BLK 0 "memory_operand" "")
1518           (match_operand:BLK 1 "memory_operand" ""))
1519      (use (match_operand 2 "const_int_operand" ""))])
1520    (parallel
1521     [(set (match_operand:BLK 3 "memory_operand" "")
1522           (match_operand:BLK 4 "memory_operand" ""))
1523      (use (match_operand 5 "const_int_operand" ""))])]
1524   "s390_offset_p (operands[0], operands[3], operands[2])
1525    && s390_offset_p (operands[1], operands[4], operands[2])
1526    && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
1527   [(parallel
1528     [(set (match_dup 6) (match_dup 7))
1529      (use (match_dup 8))])]
1530   "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
1531    operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
1532    operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
1533
1534
1535 ;
1536 ; load_multiple pattern(s).
1537 ;
1538 ; ??? Due to reload problems with replacing registers inside match_parallel
1539 ; we currently support load_multiple/store_multiple only after reload.
1540 ;
1541
1542 (define_expand "load_multiple"
1543   [(match_par_dup 3 [(set (match_operand 0 "" "")
1544                           (match_operand 1 "" ""))
1545                      (use (match_operand 2 "" ""))])]
1546   "reload_completed"
1547 {
1548   enum machine_mode mode;
1549   int regno;
1550   int count;
1551   rtx from;
1552   int i, off;
1553
1554   /* Support only loading a constant number of fixed-point registers from
1555      memory and only bother with this if more than two */
1556   if (GET_CODE (operands[2]) != CONST_INT
1557       || INTVAL (operands[2]) < 2
1558       || INTVAL (operands[2]) > 16
1559       || GET_CODE (operands[1]) != MEM
1560       || GET_CODE (operands[0]) != REG
1561       || REGNO (operands[0]) >= 16)
1562     FAIL;
1563
1564   count = INTVAL (operands[2]);
1565   regno = REGNO (operands[0]);
1566   mode = GET_MODE (operands[0]);
1567   if (mode != SImode && mode != word_mode)
1568     FAIL;
1569
1570   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
1571   if (no_new_pseudos)
1572     {
1573       if (GET_CODE (XEXP (operands[1], 0)) == REG)
1574         {
1575           from = XEXP (operands[1], 0);
1576           off = 0;
1577         }
1578       else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
1579                && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
1580                && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
1581         {
1582           from = XEXP (XEXP (operands[1], 0), 0);
1583           off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
1584         }
1585       else
1586         FAIL;
1587     }
1588   else
1589     {
1590       from = force_reg (Pmode, XEXP (operands[1], 0));
1591       off = 0;
1592     }
1593
1594   for (i = 0; i < count; i++)
1595     XVECEXP (operands[3], 0, i)
1596       = gen_rtx_SET (VOIDmode, gen_rtx_REG (mode, regno + i),
1597                      change_address (operands[1], mode,
1598                        plus_constant (from, off + i * GET_MODE_SIZE (mode))));
1599 })
1600
1601 (define_insn "*load_multiple_di"
1602   [(match_parallel 0 "load_multiple_operation"
1603                    [(set (match_operand:DI 1 "register_operand" "=r")
1604                          (match_operand:DI 2 "s_operand" "QS"))])]
1605   "reload_completed && word_mode == DImode"
1606 {
1607   int words = XVECLEN (operands[0], 0);
1608   operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
1609   return "lmg\t%1,%0,%S2";
1610 }
1611    [(set_attr "op_type" "RSY")
1612     (set_attr "type"    "lm")])
1613
1614 (define_insn "*load_multiple_si"
1615   [(match_parallel 0 "load_multiple_operation"
1616                    [(set (match_operand:SI 1 "register_operand" "=r,r")
1617                          (match_operand:SI 2 "s_operand" "Q,S"))])]
1618   "reload_completed"
1619 {
1620   int words = XVECLEN (operands[0], 0);
1621   operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
1622   return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
1623 }
1624    [(set_attr "op_type" "RS,RSY")
1625     (set_attr "type"    "lm")])
1626
1627 ;
1628 ; store multiple pattern(s).
1629 ;
1630
1631 (define_expand "store_multiple"
1632   [(match_par_dup 3 [(set (match_operand 0 "" "")
1633                           (match_operand 1 "" ""))
1634                      (use (match_operand 2 "" ""))])]
1635   "reload_completed"
1636 {
1637   enum machine_mode mode;
1638   int regno;
1639   int count;
1640   rtx to;
1641   int i, off;
1642
1643   /* Support only storing a constant number of fixed-point registers to
1644      memory and only bother with this if more than two.  */
1645   if (GET_CODE (operands[2]) != CONST_INT
1646       || INTVAL (operands[2]) < 2
1647       || INTVAL (operands[2]) > 16
1648       || GET_CODE (operands[0]) != MEM
1649       || GET_CODE (operands[1]) != REG
1650       || REGNO (operands[1]) >= 16)
1651     FAIL;
1652
1653   count = INTVAL (operands[2]);
1654   regno = REGNO (operands[1]);
1655   mode = GET_MODE (operands[1]);
1656   if (mode != SImode && mode != word_mode)
1657     FAIL;
1658
1659   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
1660
1661   if (no_new_pseudos)
1662     {
1663       if (GET_CODE (XEXP (operands[0], 0)) == REG)
1664         {
1665           to = XEXP (operands[0], 0);
1666           off = 0;
1667         }
1668       else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
1669                && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
1670                && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
1671         {
1672           to = XEXP (XEXP (operands[0], 0), 0);
1673           off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
1674         }
1675       else
1676         FAIL;
1677     }
1678   else
1679     {
1680       to = force_reg (Pmode, XEXP (operands[0], 0));
1681       off = 0;
1682     }
1683
1684   for (i = 0; i < count; i++)
1685     XVECEXP (operands[3], 0, i)
1686       = gen_rtx_SET (VOIDmode,
1687                      change_address (operands[0], mode,
1688                        plus_constant (to, off + i * GET_MODE_SIZE (mode))),
1689                      gen_rtx_REG (mode, regno + i));
1690 })
1691
1692 (define_insn "*store_multiple_di"
1693   [(match_parallel 0 "store_multiple_operation"
1694                    [(set (match_operand:DI 1 "s_operand" "=QS")
1695                          (match_operand:DI 2 "register_operand" "r"))])]
1696   "reload_completed && word_mode == DImode"
1697 {
1698   int words = XVECLEN (operands[0], 0);
1699   operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
1700   return "stmg\t%2,%0,%S1";
1701 }
1702    [(set_attr "op_type" "RSY")
1703     (set_attr "type"    "stm")])
1704
1705
1706 (define_insn "*store_multiple_si"
1707   [(match_parallel 0 "store_multiple_operation"
1708                    [(set (match_operand:SI 1 "s_operand" "=Q,S")
1709                          (match_operand:SI 2 "register_operand" "r,r"))])]
1710   "reload_completed"
1711 {
1712   int words = XVECLEN (operands[0], 0);
1713   operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
1714   return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
1715 }
1716    [(set_attr "op_type" "RS,RSY")
1717     (set_attr "type"    "stm")])
1718
1719 ;;
1720 ;; String instructions.
1721 ;;
1722
1723 (define_insn "*execute"
1724   [(match_parallel 0 ""
1725     [(unspec [(match_operand 1 "register_operand" "a")
1726               (match_operand:BLK 2 "memory_operand" "R")
1727               (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
1728   "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
1729    && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
1730   "ex\t%1,%2"
1731   [(set_attr "op_type" "RX")
1732    (set_attr "type" "cs")])
1733
1734
1735 ;
1736 ; strlenM instruction pattern(s).
1737 ;
1738
1739 (define_expand "strlen<mode>"
1740   [(set (reg:QI 0) (match_operand:QI 2 "immediate_operand" ""))
1741    (parallel
1742     [(set (match_dup 4)
1743           (unspec:P [(const_int 0)
1744                       (match_operand:BLK 1 "memory_operand" "")
1745                       (reg:QI 0)
1746                       (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
1747      (clobber (scratch:P))
1748      (clobber (reg:CC 33))])
1749    (parallel
1750     [(set (match_operand:P 0 "register_operand" "")
1751           (minus:P (match_dup 4) (match_dup 5)))
1752      (clobber (reg:CC 33))])]
1753   ""
1754 {
1755   operands[4] = gen_reg_rtx (Pmode);
1756   operands[5] = gen_reg_rtx (Pmode);
1757   emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
1758   operands[1] = replace_equiv_address (operands[1], operands[5]);
1759 })
1760
1761 (define_insn "*strlen<mode>"
1762   [(set (match_operand:P 0 "register_operand" "=a")
1763         (unspec:P [(match_operand:P 2 "general_operand" "0")
1764                     (mem:BLK (match_operand:P 3 "register_operand" "1"))
1765                     (reg:QI 0)
1766                     (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
1767    (clobber (match_scratch:P 1 "=a"))
1768    (clobber (reg:CC 33))]
1769   ""
1770   "srst\t%0,%1\;jo\t.-4"
1771   [(set_attr "length" "8")
1772    (set_attr "type" "vs")])
1773
1774 ;
1775 ; movmemM instruction pattern(s).
1776 ;
1777
1778 (define_expand "movmem<mode>"
1779   [(set (match_operand:BLK 0 "memory_operand" "")
1780         (match_operand:BLK 1 "memory_operand" ""))
1781    (use (match_operand:GPR 2 "general_operand" ""))
1782    (match_operand 3 "" "")]
1783   ""
1784   "s390_expand_movmem (operands[0], operands[1], operands[2]); DONE;")
1785
1786 ; Move a block that is up to 256 bytes in length.
1787 ; The block length is taken as (operands[2] % 256) + 1.
1788
1789 (define_expand "movmem_short"
1790   [(parallel
1791     [(set (match_operand:BLK 0 "memory_operand" "")
1792           (match_operand:BLK 1 "memory_operand" ""))
1793      (use (match_operand 2 "nonmemory_operand" ""))
1794      (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
1795      (clobber (match_dup 3))])]
1796   ""
1797   "operands[3] = gen_rtx_SCRATCH (Pmode);")
1798
1799 (define_insn "*movmem_short"
1800   [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q")
1801         (match_operand:BLK 1 "memory_operand" "Q,Q,Q"))
1802    (use (match_operand 2 "nonmemory_operand" "n,a,a"))
1803    (use (match_operand 3 "immediate_operand" "X,R,X"))
1804    (clobber (match_scratch 4 "=X,X,&a"))]
1805   "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
1806    && GET_MODE (operands[4]) == Pmode"
1807   "#"
1808   [(set_attr "type" "cs")])
1809
1810 (define_split
1811   [(set (match_operand:BLK 0 "memory_operand" "")
1812         (match_operand:BLK 1 "memory_operand" ""))
1813    (use (match_operand 2 "const_int_operand" ""))
1814    (use (match_operand 3 "immediate_operand" ""))
1815    (clobber (scratch))]
1816   "reload_completed"
1817   [(parallel
1818     [(set (match_dup 0) (match_dup 1))
1819      (use (match_dup 2))])]
1820   "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
1821
1822 (define_split
1823   [(set (match_operand:BLK 0 "memory_operand" "")
1824         (match_operand:BLK 1 "memory_operand" ""))
1825    (use (match_operand 2 "register_operand" ""))
1826    (use (match_operand 3 "memory_operand" ""))
1827    (clobber (scratch))]
1828   "reload_completed"
1829   [(parallel
1830     [(unspec [(match_dup 2) (match_dup 3)
1831               (const_int 0)] UNSPEC_EXECUTE)
1832      (set (match_dup 0) (match_dup 1))
1833      (use (const_int 1))])]
1834   "")
1835
1836 (define_split
1837   [(set (match_operand:BLK 0 "memory_operand" "")
1838         (match_operand:BLK 1 "memory_operand" ""))
1839    (use (match_operand 2 "register_operand" ""))
1840    (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
1841    (clobber (match_operand 3 "register_operand" ""))]
1842   "reload_completed && TARGET_CPU_ZARCH"
1843   [(set (match_dup 3) (label_ref (match_dup 4)))
1844    (parallel
1845     [(unspec [(match_dup 2) (mem:BLK (match_dup 3)) 
1846               (label_ref (match_dup 4))] UNSPEC_EXECUTE)
1847      (set (match_dup 0) (match_dup 1))
1848      (use (const_int 1))])]
1849   "operands[4] = gen_label_rtx ();")
1850
1851 ; Move a block of arbitrary length.
1852
1853 (define_expand "movmem_long"
1854   [(parallel
1855     [(clobber (match_dup 2))
1856      (clobber (match_dup 3))
1857      (set (match_operand:BLK 0 "memory_operand" "")
1858           (match_operand:BLK 1 "memory_operand" ""))
1859      (use (match_operand 2 "general_operand" ""))
1860      (use (match_dup 3))
1861      (clobber (reg:CC 33))])]
1862   ""
1863 {
1864   enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
1865   rtx reg0 = gen_reg_rtx (dword_mode);
1866   rtx reg1 = gen_reg_rtx (dword_mode);
1867   rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
1868   rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
1869   rtx len0 = gen_lowpart (Pmode, reg0);
1870   rtx len1 = gen_lowpart (Pmode, reg1);
1871
1872   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
1873   emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
1874   emit_move_insn (len0, operands[2]);
1875
1876   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
1877   emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
1878   emit_move_insn (len1, operands[2]);
1879
1880   operands[0] = replace_equiv_address_nv (operands[0], addr0);
1881   operands[1] = replace_equiv_address_nv (operands[1], addr1);
1882   operands[2] = reg0;
1883   operands[3] = reg1;
1884 })
1885
1886 (define_insn "*movmem_long_64"
1887   [(clobber (match_operand:TI 0 "register_operand" "=d"))
1888    (clobber (match_operand:TI 1 "register_operand" "=d"))
1889    (set (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
1890         (mem:BLK (subreg:DI (match_operand:TI 3 "register_operand" "1") 0)))
1891    (use (match_dup 2))
1892    (use (match_dup 3))
1893    (clobber (reg:CC 33))]
1894   "TARGET_64BIT"
1895   "mvcle\t%0,%1,0\;jo\t.-4"
1896   [(set_attr "length" "8")
1897    (set_attr "type" "vs")])
1898
1899 (define_insn "*movmem_long_31"
1900   [(clobber (match_operand:DI 0 "register_operand" "=d"))
1901    (clobber (match_operand:DI 1 "register_operand" "=d"))
1902    (set (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
1903         (mem:BLK (subreg:SI (match_operand:DI 3 "register_operand" "1") 0)))
1904    (use (match_dup 2))
1905    (use (match_dup 3))
1906    (clobber (reg:CC 33))]
1907   "!TARGET_64BIT"
1908   "mvcle\t%0,%1,0\;jo\t.-4"
1909   [(set_attr "length" "8")
1910    (set_attr "type" "vs")])
1911
1912 ;
1913 ; clrmemM instruction pattern(s).
1914 ;
1915
1916 (define_expand "clrmem<mode>"
1917   [(set (match_operand:BLK 0 "memory_operand" "")
1918         (const_int 0))
1919    (use (match_operand:GPR 1 "general_operand" ""))
1920    (match_operand 2 "" "")]
1921   ""
1922   "s390_expand_clrmem (operands[0], operands[1]); DONE;")
1923
1924 ; Clear a block that is up to 256 bytes in length.
1925 ; The block length is taken as (operands[1] % 256) + 1.
1926
1927 (define_expand "clrmem_short"
1928   [(parallel
1929     [(set (match_operand:BLK 0 "memory_operand" "")
1930           (const_int 0))
1931      (use (match_operand 1 "nonmemory_operand" ""))
1932      (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
1933      (clobber (match_dup 2))
1934      (clobber (reg:CC 33))])]
1935   ""
1936   "operands[2] = gen_rtx_SCRATCH (Pmode);")
1937
1938 (define_insn "*clrmem_short"
1939   [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q")
1940         (const_int 0))
1941    (use (match_operand 1 "nonmemory_operand" "n,a,a"))
1942    (use (match_operand 2 "immediate_operand" "X,R,X"))
1943    (clobber (match_scratch 3 "=X,X,&a"))
1944    (clobber (reg:CC 33))]
1945   "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)
1946    && GET_MODE (operands[3]) == Pmode"
1947   "#"
1948   [(set_attr "type" "cs")])
1949
1950 (define_split
1951   [(set (match_operand:BLK 0 "memory_operand" "")
1952         (const_int 0))
1953    (use (match_operand 1 "const_int_operand" ""))
1954    (use (match_operand 2 "immediate_operand" ""))
1955    (clobber (scratch))
1956    (clobber (reg:CC 33))]
1957   "reload_completed"
1958   [(parallel
1959     [(set (match_dup 0) (const_int 0))
1960      (use (match_dup 1))
1961      (clobber (reg:CC 33))])]
1962   "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
1963
1964 (define_split
1965   [(set (match_operand:BLK 0 "memory_operand" "")
1966         (const_int 0))
1967    (use (match_operand 1 "register_operand" ""))
1968    (use (match_operand 2 "memory_operand" ""))
1969    (clobber (scratch))
1970    (clobber (reg:CC 33))]
1971   "reload_completed"
1972   [(parallel
1973     [(unspec [(match_dup 1) (match_dup 2)
1974               (const_int 0)] UNSPEC_EXECUTE)
1975      (set (match_dup 0) (const_int 0))
1976      (use (const_int 1))
1977      (clobber (reg:CC 33))])]
1978   "")
1979
1980 (define_split
1981   [(set (match_operand:BLK 0 "memory_operand" "")
1982         (const_int 0))
1983    (use (match_operand 1 "register_operand" ""))
1984    (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
1985    (clobber (match_operand 2 "register_operand" ""))
1986    (clobber (reg:CC 33))]
1987   "reload_completed && TARGET_CPU_ZARCH"
1988   [(set (match_dup 2) (label_ref (match_dup 3)))
1989    (parallel
1990     [(unspec [(match_dup 1) (mem:BLK (match_dup 2)) 
1991               (label_ref (match_dup 3))] UNSPEC_EXECUTE)
1992      (set (match_dup 0) (const_int 0))
1993      (use (const_int 1))
1994      (clobber (reg:CC 33))])]
1995   "operands[3] = gen_label_rtx ();")
1996
1997 ; Clear a block of arbitrary length.
1998
1999 (define_expand "clrmem_long"
2000   [(parallel
2001     [(clobber (match_dup 1))
2002      (set (match_operand:BLK 0 "memory_operand" "")
2003           (const_int 0))
2004      (use (match_operand 1 "general_operand" ""))
2005      (use (match_dup 2))
2006      (clobber (reg:CC 33))])]
2007   ""
2008 {
2009   enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2010   rtx reg0 = gen_reg_rtx (dword_mode);
2011   rtx reg1 = gen_reg_rtx (dword_mode);
2012   rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2013   rtx len0 = gen_lowpart (Pmode, reg0);
2014
2015   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2016   emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2017   emit_move_insn (len0, operands[1]);
2018
2019   emit_move_insn (reg1, const0_rtx);
2020
2021   operands[0] = replace_equiv_address_nv (operands[0], addr0);
2022   operands[1] = reg0;
2023   operands[2] = reg1;
2024 })
2025
2026 (define_insn "*clrmem_long_64"
2027   [(clobber (match_operand:TI 0 "register_operand" "=d"))
2028    (set (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
2029         (const_int 0))
2030    (use (match_dup 2))
2031    (use (match_operand:TI 1 "register_operand" "d"))
2032    (clobber (reg:CC 33))]
2033   "TARGET_64BIT"
2034   "mvcle\t%0,%1,0\;jo\t.-4"
2035   [(set_attr "length" "8")
2036    (set_attr "type" "vs")])
2037
2038 (define_insn "*clrmem_long_31"
2039   [(clobber (match_operand:DI 0 "register_operand" "=d"))
2040    (set (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
2041         (const_int 0))
2042    (use (match_dup 2))
2043    (use (match_operand:DI 1 "register_operand" "d"))
2044    (clobber (reg:CC 33))]
2045   "!TARGET_64BIT"
2046   "mvcle\t%0,%1,0\;jo\t.-4"
2047   [(set_attr "length" "8")
2048    (set_attr "type" "vs")])
2049
2050 ;
2051 ; cmpmemM instruction pattern(s).
2052 ;
2053
2054 (define_expand "cmpmemsi"
2055   [(set (match_operand:SI 0 "register_operand" "")
2056         (compare:SI (match_operand:BLK 1 "memory_operand" "")
2057                     (match_operand:BLK 2 "memory_operand" "") ) )
2058    (use (match_operand:SI 3 "general_operand" ""))
2059    (use (match_operand:SI 4 "" ""))]
2060   ""
2061   "s390_expand_cmpmem (operands[0], operands[1],
2062                        operands[2], operands[3]); DONE;")
2063
2064 ; Compare a block that is up to 256 bytes in length.
2065 ; The block length is taken as (operands[2] % 256) + 1.
2066
2067 (define_expand "cmpmem_short"
2068   [(parallel
2069     [(set (reg:CCU 33)
2070           (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2071                        (match_operand:BLK 1 "memory_operand" "")))
2072      (use (match_operand 2 "nonmemory_operand" ""))
2073      (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2074      (clobber (match_dup 3))])]
2075   ""
2076   "operands[3] = gen_rtx_SCRATCH (Pmode);")
2077
2078 (define_insn "*cmpmem_short"
2079   [(set (reg:CCU 33)
2080         (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q")
2081                      (match_operand:BLK 1 "memory_operand" "Q,Q,Q")))
2082    (use (match_operand 2 "nonmemory_operand" "n,a,a"))
2083    (use (match_operand 3 "immediate_operand" "X,R,X"))
2084    (clobber (match_scratch 4 "=X,X,&a"))]
2085   "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2086    && GET_MODE (operands[4]) == Pmode"
2087   "#"
2088   [(set_attr "type" "cs")])
2089
2090 (define_split
2091   [(set (reg:CCU 33)
2092         (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2093                      (match_operand:BLK 1 "memory_operand" "")))
2094    (use (match_operand 2 "const_int_operand" ""))
2095    (use (match_operand 3 "immediate_operand" ""))
2096    (clobber (scratch))]
2097   "reload_completed"
2098   [(parallel
2099     [(set (reg:CCU 33) (compare:CCU (match_dup 0) (match_dup 1)))
2100      (use (match_dup 2))])]
2101   "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2102
2103 (define_split
2104   [(set (reg:CCU 33)
2105         (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2106                      (match_operand:BLK 1 "memory_operand" "")))
2107    (use (match_operand 2 "register_operand" ""))
2108    (use (match_operand 3 "memory_operand" ""))
2109    (clobber (scratch))]
2110   "reload_completed"
2111   [(parallel
2112     [(unspec [(match_dup 2) (match_dup 3)
2113               (const_int 0)] UNSPEC_EXECUTE)
2114      (set (reg:CCU 33) (compare:CCU (match_dup 0) (match_dup 1)))
2115      (use (const_int 1))])]
2116   "")
2117
2118 (define_split
2119   [(set (reg:CCU 33)
2120         (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2121                      (match_operand:BLK 1 "memory_operand" "")))
2122    (use (match_operand 2 "register_operand" ""))
2123    (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2124    (clobber (match_operand 3 "register_operand" ""))]
2125   "reload_completed && TARGET_CPU_ZARCH"
2126   [(set (match_dup 3) (label_ref (match_dup 4)))
2127    (parallel
2128     [(unspec [(match_dup 2) (mem:BLK (match_dup 3)) 
2129               (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2130      (set (reg:CCU 33) (compare:CCU (match_dup 0) (match_dup 1)))
2131      (use (const_int 1))])]
2132   "operands[4] = gen_label_rtx ();")
2133
2134 ; Compare a block of arbitrary length.
2135
2136 (define_expand "cmpmem_long"
2137   [(parallel
2138     [(clobber (match_dup 2))
2139      (clobber (match_dup 3))
2140      (set (reg:CCU 33)
2141           (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2142                        (match_operand:BLK 1 "memory_operand" "")))
2143      (use (match_operand 2 "general_operand" ""))
2144      (use (match_dup 3))])]
2145   ""
2146 {
2147   enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2148   rtx reg0 = gen_reg_rtx (dword_mode);
2149   rtx reg1 = gen_reg_rtx (dword_mode);
2150   rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2151   rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
2152   rtx len0 = gen_lowpart (Pmode, reg0);
2153   rtx len1 = gen_lowpart (Pmode, reg1);
2154
2155   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2156   emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2157   emit_move_insn (len0, operands[2]);
2158
2159   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
2160   emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2161   emit_move_insn (len1, operands[2]);
2162
2163   operands[0] = replace_equiv_address_nv (operands[0], addr0);
2164   operands[1] = replace_equiv_address_nv (operands[1], addr1);
2165   operands[2] = reg0;
2166   operands[3] = reg1;
2167 })
2168
2169 (define_insn "*cmpmem_long_64"
2170   [(clobber (match_operand:TI 0 "register_operand" "=d"))
2171    (clobber (match_operand:TI 1 "register_operand" "=d"))
2172    (set (reg:CCU 33)
2173         (compare:CCU (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
2174                      (mem:BLK (subreg:DI (match_operand:TI 3 "register_operand" "1") 0))))
2175    (use (match_dup 2))
2176    (use (match_dup 3))]
2177   "TARGET_64BIT"
2178   "clcle\t%0,%1,0\;jo\t.-4"
2179   [(set_attr "length" "8")
2180    (set_attr "type" "vs")])
2181
2182 (define_insn "*cmpmem_long_31"
2183   [(clobber (match_operand:DI 0 "register_operand" "=d"))
2184    (clobber (match_operand:DI 1 "register_operand" "=d"))
2185    (set (reg:CCU 33)
2186         (compare:CCU (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
2187                      (mem:BLK (subreg:SI (match_operand:DI 3 "register_operand" "1") 0))))
2188    (use (match_dup 2))
2189    (use (match_dup 3))]
2190   "!TARGET_64BIT"
2191   "clcle\t%0,%1,0\;jo\t.-4"
2192   [(set_attr "length" "8")
2193    (set_attr "type" "vs")])
2194
2195 ; Convert CCUmode condition code to integer.
2196 ; Result is zero if EQ, positive if LTU, negative if GTU.
2197
2198 (define_insn_and_split "cmpint"
2199   [(set (match_operand:SI 0 "register_operand" "=d")
2200         (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2201                    UNSPEC_CMPINT))
2202    (clobber (reg:CC 33))]
2203   ""
2204   "#"
2205   "reload_completed"
2206   [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
2207    (parallel
2208     [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
2209      (clobber (reg:CC 33))])])
2210
2211 (define_insn_and_split "*cmpint_cc"
2212   [(set (reg 33)
2213         (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2214                             UNSPEC_CMPINT)
2215                  (const_int 0)))
2216    (set (match_operand:SI 0 "register_operand" "=d")
2217         (unspec:SI [(match_dup 1)] UNSPEC_CMPINT))]
2218   "s390_match_ccmode (insn, CCSmode)"
2219   "#"
2220   "&& reload_completed"
2221   [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
2222    (parallel
2223     [(set (match_dup 2) (match_dup 3))
2224      (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
2225 {
2226   rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
2227   operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
2228   operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
2229 })
2230
2231 (define_insn_and_split "*cmpint_sign"
2232   [(set (match_operand:DI 0 "register_operand" "=d")
2233         (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2234                                    UNSPEC_CMPINT)))
2235    (clobber (reg:CC 33))]
2236   "TARGET_64BIT"
2237   "#"
2238   "&& reload_completed"
2239   [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
2240    (parallel
2241     [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
2242      (clobber (reg:CC 33))])])
2243
2244 (define_insn_and_split "*cmpint_sign_cc"
2245   [(set (reg 33)
2246         (compare (ashiftrt:DI (ashift:DI (subreg:DI 
2247                    (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2248                               UNSPEC_CMPINT) 0)
2249                    (const_int 32)) (const_int 32))
2250                  (const_int 0)))
2251    (set (match_operand:DI 0 "register_operand" "=d")
2252         (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_CMPINT)))]
2253   "s390_match_ccmode (insn, CCSmode) && TARGET_64BIT"
2254   "#"
2255   "&& reload_completed"
2256   [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
2257    (parallel
2258     [(set (match_dup 2) (match_dup 3))
2259      (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
2260 {
2261   rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
2262   operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
2263   operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
2264 })
2265
2266
2267 ;;
2268 ;;- Conversion instructions.
2269 ;;
2270
2271
2272 (define_insn "*sethigh<mode>si"
2273   [(set (match_operand:SI 0 "register_operand" "=d,d")
2274         (unspec:SI [(match_operand:HQI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
2275    (clobber (reg:CC 33))]
2276   ""
2277   "@
2278    icm\t%0,<icm_hi>,%S1
2279    icmy\t%0,<icm_hi>,%S1"
2280   [(set_attr "op_type" "RS,RSY")])
2281
2282 (define_insn "*sethighqidi_64"
2283   [(set (match_operand:DI 0 "register_operand" "=d")
2284         (unspec:DI [(match_operand:QI 1 "s_operand" "QS")] UNSPEC_SETHIGH))
2285    (clobber (reg:CC 33))]
2286   "TARGET_64BIT"
2287   "icmh\t%0,8,%S1"
2288   [(set_attr "op_type" "RSY")])
2289
2290 (define_insn "*sethighqidi_31"
2291   [(set (match_operand:DI 0 "register_operand" "=d,d")
2292         (unspec:DI [(match_operand:QI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
2293    (clobber (reg:CC 33))]
2294   "!TARGET_64BIT"
2295   "@
2296    icm\t%0,8,%S1
2297    icmy\t%0,8,%S1"
2298   [(set_attr "op_type" "RS,RSY")])
2299
2300 (define_insn_and_split "*extractqi"
2301   [(set (match_operand:SI 0 "register_operand" "=d")
2302         (zero_extract:SI (match_operand:QI 1 "s_operand" "Q")
2303                          (match_operand 2 "const_int_operand" "n")
2304                          (const_int 0)))
2305    (clobber (reg:CC 33))]
2306   "!TARGET_64BIT
2307    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 8"
2308   "#"
2309   "&& reload_completed"
2310   [(parallel
2311     [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
2312      (clobber (reg:CC 33))])
2313     (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
2314 {
2315   operands[2] = GEN_INT (32 - INTVAL (operands[2]));
2316   operands[1] = change_address (operands[1], QImode, 0);
2317 })
2318
2319 (define_insn_and_split "*extracthi"
2320   [(set (match_operand:SI 0 "register_operand" "=d")
2321         (zero_extract:SI (match_operand:QI 1 "s_operand" "Q")
2322                          (match_operand 2 "const_int_operand" "n")
2323                          (const_int 0)))
2324    (clobber (reg:CC 33))]
2325   "!TARGET_64BIT
2326    && INTVAL (operands[2]) >= 8 && INTVAL (operands[2]) < 16"
2327   "#"
2328   "&& reload_completed"
2329   [(parallel
2330     [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
2331      (clobber (reg:CC 33))])
2332     (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
2333 {
2334   operands[2] = GEN_INT (32 - INTVAL (operands[2]));
2335   operands[1] = change_address (operands[1], HImode, 0);
2336 })
2337
2338 ;
2339 ; extendsidi2 instruction pattern(s).
2340 ;
2341
2342 (define_expand "extendsidi2"
2343   [(set (match_operand:DI 0 "register_operand" "")
2344         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2345   ""
2346   "
2347 {
2348   if (!TARGET_64BIT)
2349     {
2350       emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2351       emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
2352       emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
2353       emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
2354       DONE;
2355     }
2356 }
2357 ")
2358
2359 (define_insn "*extendsidi2"
2360   [(set (match_operand:DI 0 "register_operand" "=d,d")
2361         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2362   "TARGET_64BIT"
2363   "@
2364    lgfr\t%0,%1
2365    lgf\t%0,%1"
2366   [(set_attr "op_type" "RRE,RXY")])
2367
2368 ;
2369 ; extendhidi2 instruction pattern(s).
2370 ;
2371
2372 (define_expand "extendhidi2"
2373   [(set (match_operand:DI 0 "register_operand" "")
2374         (sign_extend:DI (match_operand:HI 1 "register_operand" "")))]
2375   ""
2376   "
2377 {
2378   if (!TARGET_64BIT)
2379     {
2380       rtx tmp = gen_reg_rtx (SImode);
2381       emit_insn (gen_extendhisi2 (tmp, operands[1]));
2382       emit_insn (gen_extendsidi2 (operands[0], tmp));
2383       DONE;
2384     }
2385   else
2386     {
2387       operands[1] = gen_lowpart (DImode, operands[1]);
2388       emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (48)));
2389       emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (48)));
2390       DONE;
2391     }
2392 }
2393 ")
2394
2395 (define_insn "*extendhidi2"
2396   [(set (match_operand:DI 0 "register_operand" "=d")
2397         (sign_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
2398   "TARGET_64BIT"
2399   "lgh\t%0,%1"
2400   [(set_attr "op_type" "RXY")])
2401
2402 ;
2403 ; extendqidi2 instruction pattern(s).
2404 ;
2405
2406 (define_expand "extendqidi2"
2407   [(set (match_operand:DI 0 "register_operand" "")
2408         (sign_extend:DI (match_operand:QI 1 "register_operand" "")))]
2409   ""
2410   "
2411 {
2412   if (!TARGET_64BIT)
2413     {
2414       rtx tmp = gen_reg_rtx (SImode);
2415       emit_insn (gen_extendqisi2 (tmp, operands[1]));
2416       emit_insn (gen_extendsidi2 (operands[0], tmp));
2417       DONE;
2418     }
2419   else
2420     {
2421       operands[1] = gen_lowpart (DImode, operands[1]);
2422       emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (56)));
2423       emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (56)));
2424       DONE;
2425     }
2426 }
2427 ")
2428
2429 (define_insn "*extendqidi2"
2430   [(set (match_operand:DI 0 "register_operand" "=d")
2431         (sign_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
2432   "TARGET_64BIT && TARGET_LONG_DISPLACEMENT"
2433   "lgb\t%0,%1"
2434   [(set_attr "op_type" "RXY")])
2435
2436 (define_insn_and_split "*extendqidi2_short_displ"
2437   [(set (match_operand:DI 0 "register_operand" "=d")
2438         (sign_extend:DI (match_operand:QI 1 "s_operand" "Q")))
2439    (clobber (reg:CC 33))]
2440   "TARGET_64BIT && !TARGET_LONG_DISPLACEMENT"
2441   "#"
2442   "&& reload_completed"
2443   [(parallel
2444     [(set (match_dup 0) (unspec:DI [(match_dup 1)] UNSPEC_SETHIGH))
2445      (clobber (reg:CC 33))])
2446    (parallel
2447     [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 56)))
2448      (clobber (reg:CC 33))])]
2449   "")
2450
2451 ;
2452 ; extendhisi2 instruction pattern(s).
2453 ;
2454
2455 (define_expand "extendhisi2"
2456   [(set (match_operand:SI 0 "register_operand" "")
2457         (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
2458   ""
2459   "
2460 {
2461   operands[1] = gen_lowpart (SImode, operands[1]);
2462   emit_insn (gen_ashlsi3 (operands[0], operands[1], GEN_INT (16)));
2463   emit_insn (gen_ashrsi3 (operands[0], operands[0], GEN_INT (16)));
2464   DONE;
2465 }
2466 ")
2467
2468 (define_insn "*extendhisi2"
2469   [(set (match_operand:SI 0 "register_operand" "=d,d")
2470         (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
2471   ""
2472   "@
2473    lh\t%0,%1
2474    lhy\t%0,%1"
2475   [(set_attr "op_type" "RX,RXY")])
2476
2477 ;
2478 ; extendqisi2 instruction pattern(s).
2479 ;
2480
2481 (define_expand "extendqisi2"
2482   [(set (match_operand:SI 0 "register_operand" "")
2483         (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
2484   ""
2485   "
2486 {
2487   operands[1] = gen_lowpart (SImode, operands[1]);
2488   emit_insn (gen_ashlsi3 (operands[0], operands[1], GEN_INT (24)));
2489   emit_insn (gen_ashrsi3 (operands[0], operands[0], GEN_INT (24)));
2490   DONE;
2491 }
2492 ")
2493
2494 (define_insn "*extendqisi2"
2495   [(set (match_operand:SI 0 "register_operand" "=d")
2496         (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
2497   "TARGET_LONG_DISPLACEMENT"
2498   "lb\t%0,%1"
2499   [(set_attr "op_type" "RXY")])
2500
2501 (define_insn_and_split "*extendqisi2_short_displ"
2502   [(set (match_operand:SI 0 "register_operand" "=d")
2503         (sign_extend:SI (match_operand:QI 1 "s_operand" "Q")))
2504    (clobber (reg:CC 33))]
2505   "!TARGET_LONG_DISPLACEMENT"
2506   "#"
2507   "&& reload_completed"
2508   [(parallel
2509     [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
2510      (clobber (reg:CC 33))])
2511    (parallel
2512     [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 24)))
2513      (clobber (reg:CC 33))])]
2514   "")
2515
2516 ;
2517 ; extendqihi2 instruction pattern(s).
2518 ;
2519
2520
2521 ;
2522 ; zero_extendsidi2 instruction pattern(s).
2523 ;
2524
2525 (define_expand "zero_extendsidi2"
2526   [(set (match_operand:DI 0 "register_operand" "")
2527         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2528   ""
2529   "
2530 {
2531   if (!TARGET_64BIT)
2532     {
2533       emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2534       emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
2535       emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
2536       DONE;
2537     }
2538 }
2539 ")
2540
2541 (define_insn "*zero_extendsidi2"
2542   [(set (match_operand:DI 0 "register_operand" "=d,d")
2543         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2544   "TARGET_64BIT"
2545   "@
2546    llgfr\t%0,%1
2547    llgf\t%0,%1"
2548   [(set_attr "op_type" "RRE,RXY")])
2549
2550 ;
2551 ; zero_extendhidi2 instruction pattern(s).
2552 ;
2553
2554 (define_expand "zero_extendhidi2"
2555   [(set (match_operand:DI 0 "register_operand" "")
2556         (zero_extend:DI (match_operand:HI 1 "register_operand" "")))]
2557   ""
2558   "
2559 {
2560   if (!TARGET_64BIT)
2561     {
2562       rtx tmp = gen_reg_rtx (SImode);
2563       emit_insn (gen_zero_extendhisi2 (tmp, operands[1]));
2564       emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
2565       DONE;
2566     }
2567   else
2568     {
2569       operands[1] = gen_lowpart (DImode, operands[1]);
2570       emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (48)));
2571       emit_insn (gen_lshrdi3 (operands[0], operands[0], GEN_INT (48)));
2572       DONE;
2573     }
2574 }
2575 ")
2576
2577 (define_insn "*zero_extendhidi2"
2578   [(set (match_operand:DI 0 "register_operand" "=d")
2579         (zero_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
2580   "TARGET_64BIT"
2581   "llgh\t%0,%1"
2582   [(set_attr "op_type" "RXY")])
2583
2584 ;
2585 ; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
2586 ;
2587
2588 (define_insn "*llgt_sidi"
2589   [(set (match_operand:DI 0 "register_operand" "=d")
2590         (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
2591                 (const_int 2147483647)))]
2592   "TARGET_64BIT"
2593   "llgt\t%0,%1"
2594   [(set_attr "op_type"  "RXE")])
2595
2596 (define_insn_and_split "*llgt_sidi_split"
2597   [(set (match_operand:DI 0 "register_operand" "=d")
2598         (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
2599                 (const_int 2147483647)))
2600    (clobber (reg:CC 33))]
2601   "TARGET_64BIT"
2602   "#"
2603   "&& reload_completed"
2604   [(set (match_dup 0)
2605         (and:DI (subreg:DI (match_dup 1) 0)
2606                 (const_int 2147483647)))]
2607   "")
2608
2609 (define_insn "*llgt_sisi"
2610   [(set (match_operand:SI 0 "register_operand" "=d,d")
2611         (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,m")
2612                 (const_int 2147483647)))]
2613   "TARGET_64BIT"
2614   "@
2615    llgtr\t%0,%1
2616    llgt\t%0,%1"
2617   [(set_attr "op_type"  "RRE,RXE")])
2618
2619 (define_split
2620   [(set (match_operand:SI 0 "register_operand" "")
2621         (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
2622                 (const_int 2147483647)))
2623    (clobber (reg:CC 33))]
2624   "TARGET_64BIT && reload_completed"
2625   [(set (match_dup 0)
2626         (and:SI (match_dup 1)
2627                 (const_int 2147483647)))]
2628   "")
2629
2630 (define_insn "*llgt_didi"
2631   [(set (match_operand:DI 0 "register_operand" "=d,d")
2632         (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
2633                 (const_int 2147483647)))]
2634   "TARGET_64BIT"
2635   "@
2636    llgtr\t%0,%1
2637    llgt\t%0,%N1"
2638   [(set_attr "op_type"  "RRE,RXE")])
2639
2640 (define_split
2641   [(set (match_operand:DI 0 "register_operand" "")
2642         (and:DI (match_operand:DI 1 "nonimmediate_operand" "")
2643                 (const_int 2147483647)))
2644    (clobber (reg:CC 33))]
2645   "TARGET_64BIT && reload_completed"
2646   [(set (match_dup 0)
2647         (and:DI (match_dup 1)
2648                 (const_int 2147483647)))]
2649   "")
2650
2651 ;
2652 ; zero_extendqidi2 instruction pattern(s)
2653 ;
2654
2655 (define_expand "zero_extendqidi2"
2656   [(set (match_operand:DI 0 "register_operand" "")
2657         (zero_extend:DI (match_operand:QI 1 "register_operand" "")))]
2658   ""
2659   "
2660 {
2661   if (!TARGET_64BIT)
2662     {
2663       rtx tmp = gen_reg_rtx (SImode);
2664       emit_insn (gen_zero_extendqisi2 (tmp, operands[1]));
2665       emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
2666       DONE;
2667     }
2668   else
2669     {
2670       operands[1] = gen_lowpart (DImode, operands[1]);
2671       emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (56)));
2672       emit_insn (gen_lshrdi3 (operands[0], operands[0], GEN_INT (56)));
2673       DONE;
2674     }
2675 }
2676 ")
2677
2678 (define_insn "*zero_extendqidi2"
2679   [(set (match_operand:DI 0 "register_operand" "=d")
2680         (zero_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
2681   "TARGET_64BIT"
2682   "llgc\t%0,%1"
2683   [(set_attr "op_type" "RXY")])
2684
2685 ;
2686 ; zero_extendhisi2 instruction pattern(s).
2687 ;
2688
2689 (define_expand "zero_extendhisi2"
2690   [(set (match_operand:SI 0 "register_operand" "")
2691         (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
2692   ""
2693   "
2694 {
2695   operands[1] = gen_lowpart (SImode, operands[1]);
2696   emit_insn (gen_andsi3 (operands[0], operands[1], GEN_INT (0xffff)));
2697   DONE;
2698 }
2699 ")
2700
2701 (define_insn "*zero_extendhisi2_64"
2702   [(set (match_operand:SI 0 "register_operand" "=d")
2703         (zero_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
2704   "TARGET_ZARCH"
2705   "llgh\t%0,%1"
2706   [(set_attr "op_type" "RXY")])
2707
2708 (define_insn_and_split "*zero_extendhisi2_31"
2709   [(set (match_operand:SI 0 "register_operand" "=&d")
2710         (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
2711    (clobber (reg:CC 33))]
2712   "!TARGET_ZARCH"
2713   "#"
2714   "&& reload_completed"
2715   [(set (match_dup 0) (const_int 0))
2716    (parallel
2717     [(set (strict_low_part (match_dup 2)) (match_dup 1))
2718      (clobber (reg:CC 33))])]
2719   "operands[2] = gen_lowpart (HImode, operands[0]);")
2720
2721 ;
2722 ; zero_extendqisi2 instruction pattern(s).
2723 ;
2724
2725 (define_expand "zero_extendqisi2"
2726   [(set (match_operand:SI 0 "register_operand" "")
2727         (zero_extend:SI (match_operand:QI 1 "register_operand" "")))]
2728   ""
2729   "
2730 {
2731   operands[1] = gen_lowpart (SImode, operands[1]);
2732   emit_insn (gen_andsi3 (operands[0], operands[1], GEN_INT (0xff)));
2733   DONE;
2734 }
2735 ")
2736
2737 (define_insn "*zero_extendqisi2_64"
2738   [(set (match_operand:SI 0 "register_operand" "=d")
2739         (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
2740   "TARGET_ZARCH"
2741   "llgc\t%0,%1"
2742   [(set_attr "op_type" "RXY")])
2743
2744 (define_insn_and_split "*zero_extendqisi2_31"
2745   [(set (match_operand:SI 0 "register_operand" "=&d")
2746         (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
2747   "!TARGET_ZARCH"
2748   "#"
2749   "&& reload_completed"
2750   [(set (match_dup 0) (const_int 0))
2751    (set (strict_low_part (match_dup 2)) (match_dup 1))]
2752   "operands[2] = gen_lowpart (QImode, operands[0]);")
2753
2754 ;
2755 ; zero_extendqihi2 instruction pattern(s).
2756 ;
2757
2758 (define_expand "zero_extendqihi2"
2759   [(set (match_operand:HI 0 "register_operand" "")
2760         (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
2761   "TARGET_ZARCH"
2762   "
2763 {
2764   operands[1] = gen_lowpart (HImode, operands[1]);
2765   emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
2766   DONE;
2767 }
2768 ")
2769
2770 (define_insn "*zero_extendqihi2_64"
2771   [(set (match_operand:HI 0 "register_operand" "=d")
2772         (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
2773   "TARGET_ZARCH"
2774   "llgc\t%0,%1"
2775   [(set_attr "op_type" "RXY")])
2776
2777 (define_insn_and_split "*zero_extendqihi2_31"
2778   [(set (match_operand:HI 0 "register_operand" "=&d")
2779         (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
2780   "!TARGET_ZARCH"
2781   "#"
2782   "&& reload_completed"
2783   [(set (match_dup 0) (const_int 0))
2784    (set (strict_low_part (match_dup 2)) (match_dup 1))]
2785   "operands[2] = gen_lowpart (QImode, operands[0]);")
2786
2787
2788 ;
2789 ; fixuns_truncdfdi2 and fix_truncdfsi2 instruction pattern(s).
2790 ;
2791
2792 (define_expand "fixuns_truncdfdi2"
2793   [(set (match_operand:DI 0 "register_operand" "")
2794         (unsigned_fix:DI (match_operand:DF 1 "register_operand" "")))]
2795   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2796 {
2797   rtx label1 = gen_label_rtx ();
2798   rtx label2 = gen_label_rtx ();
2799   rtx temp = gen_reg_rtx (DFmode);
2800   operands[1] = force_reg (DFmode, operands[1]);
2801
2802   emit_insn (gen_cmpdf (operands[1],
2803         CONST_DOUBLE_FROM_REAL_VALUE (
2804           REAL_VALUE_ATOF ("9223372036854775808.0", DFmode), DFmode)));
2805   emit_jump_insn (gen_blt (label1));
2806   emit_insn (gen_subdf3 (temp, operands[1],
2807         CONST_DOUBLE_FROM_REAL_VALUE (
2808           REAL_VALUE_ATOF ("18446744073709551616.0", DFmode), DFmode)));
2809   emit_insn (gen_fix_truncdfdi2_ieee (operands[0], temp, GEN_INT(7)));
2810   emit_jump (label2);
2811
2812   emit_label (label1);
2813   emit_insn (gen_fix_truncdfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2814   emit_label (label2);
2815   DONE;
2816 })
2817
2818 (define_expand "fix_truncdfdi2"
2819   [(set (match_operand:DI 0 "register_operand" "")
2820         (fix:DI (match_operand:DF 1 "nonimmediate_operand" "")))]
2821   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2822 {
2823   operands[1] = force_reg (DFmode, operands[1]);
2824   emit_insn (gen_fix_truncdfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2825   DONE;
2826 })
2827
2828 (define_insn "fix_truncdfdi2_ieee"
2829   [(set (match_operand:DI 0 "register_operand" "=d")
2830         (fix:DI (match_operand:DF 1 "register_operand" "f")))
2831    (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
2832    (clobber (reg:CC 33))]
2833   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2834   "cgdbr\t%0,%h2,%1"
2835   [(set_attr "op_type" "RRE")
2836    (set_attr "type"    "ftoi")])
2837
2838 ;
2839 ; fixuns_truncdfsi2 and fix_truncdfsi2 instruction pattern(s).
2840 ;
2841
2842 (define_expand "fixuns_truncdfsi2"
2843   [(set (match_operand:SI 0 "register_operand" "")
2844         (unsigned_fix:SI (match_operand:DF 1 "register_operand" "")))]
2845   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2846 {
2847   rtx label1 = gen_label_rtx ();
2848   rtx label2 = gen_label_rtx ();
2849   rtx temp = gen_reg_rtx (DFmode);
2850
2851   operands[1] = force_reg (DFmode,operands[1]);
2852   emit_insn (gen_cmpdf (operands[1],
2853         CONST_DOUBLE_FROM_REAL_VALUE (
2854           REAL_VALUE_ATOF ("2147483648.0", DFmode), DFmode)));
2855   emit_jump_insn (gen_blt (label1));
2856   emit_insn (gen_subdf3 (temp, operands[1],
2857         CONST_DOUBLE_FROM_REAL_VALUE (
2858           REAL_VALUE_ATOF ("4294967296.0", DFmode), DFmode)));
2859   emit_insn (gen_fix_truncdfsi2_ieee (operands[0], temp, GEN_INT (7)));
2860   emit_jump (label2);
2861
2862   emit_label (label1);
2863   emit_insn (gen_fix_truncdfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2864   emit_label (label2);
2865   DONE;
2866 })
2867
2868 (define_expand "fix_truncdfsi2"
2869   [(set (match_operand:SI 0 "register_operand" "")
2870         (fix:SI (match_operand:DF 1 "nonimmediate_operand" "")))]
2871   "TARGET_HARD_FLOAT"
2872 {
2873   if (TARGET_IBM_FLOAT)
2874     {
2875       /* This is the algorithm from POP chapter A.5.7.2.  */
2876
2877       rtx temp   = assign_stack_local (BLKmode, 8, BITS_PER_WORD);
2878       rtx two31r = s390_gen_rtx_const_DI (0x4f000000, 0x08000000);
2879       rtx two32  = s390_gen_rtx_const_DI (0x4e000001, 0x00000000);
2880
2881       operands[1] = force_reg (DFmode, operands[1]);
2882       emit_insn (gen_fix_truncdfsi2_ibm (operands[0], operands[1],
2883                                          two31r, two32, temp));
2884     }
2885   else
2886     {
2887       operands[1] = force_reg (DFmode, operands[1]);
2888       emit_insn (gen_fix_truncdfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2889     }
2890
2891   DONE;
2892 })
2893
2894 (define_insn "fix_truncdfsi2_ieee"
2895   [(set (match_operand:SI 0 "register_operand" "=d")
2896         (fix:SI (match_operand:DF 1 "register_operand" "f")))
2897     (unspec:SI [(match_operand:SI 2 "immediate_operand" "K")] UNSPEC_ROUND)
2898     (clobber (reg:CC 33))]
2899   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2900   "cfdbr\t%0,%h2,%1"
2901    [(set_attr "op_type" "RRE")
2902     (set_attr "type"    "ftoi")])
2903
2904 (define_insn "fix_truncdfsi2_ibm"
2905   [(set (match_operand:SI 0 "register_operand" "=d")
2906         (fix:SI (match_operand:DF 1 "nonimmediate_operand" "+f")))
2907    (use (match_operand:DI 2 "immediate_operand" "m"))
2908    (use (match_operand:DI 3 "immediate_operand" "m"))
2909    (use (match_operand:BLK 4 "memory_operand" "m"))
2910    (clobber (reg:CC 33))]
2911   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
2912 {
2913    output_asm_insn ("sd\t%1,%2", operands);
2914    output_asm_insn ("aw\t%1,%3", operands);
2915    output_asm_insn ("std\t%1,%4", operands);
2916    output_asm_insn ("xi\t%N4,128", operands);
2917    return "l\t%0,%N4";
2918 }
2919   [(set_attr "length" "20")])
2920
2921 ;
2922 ; fixuns_truncsfdi2 and fix_truncsfdi2 instruction pattern(s).
2923 ;
2924
2925 (define_expand "fixuns_truncsfdi2"
2926   [(set (match_operand:DI 0 "register_operand" "")
2927         (unsigned_fix:DI (match_operand:SF 1 "register_operand" "")))]
2928   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2929 {
2930   rtx label1 = gen_label_rtx ();
2931   rtx label2 = gen_label_rtx ();
2932   rtx temp = gen_reg_rtx (SFmode);
2933
2934   operands[1] = force_reg (SFmode, operands[1]);
2935   emit_insn (gen_cmpsf (operands[1],
2936         CONST_DOUBLE_FROM_REAL_VALUE (
2937           REAL_VALUE_ATOF ("9223372036854775808.0", SFmode), SFmode)));
2938   emit_jump_insn (gen_blt (label1));
2939
2940   emit_insn (gen_subsf3 (temp, operands[1],
2941         CONST_DOUBLE_FROM_REAL_VALUE (
2942           REAL_VALUE_ATOF ("18446744073709551616.0", SFmode), SFmode)));
2943   emit_insn (gen_fix_truncsfdi2_ieee (operands[0], temp, GEN_INT(7)));
2944   emit_jump (label2);
2945
2946   emit_label (label1);
2947   emit_insn (gen_fix_truncsfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2948   emit_label (label2);
2949   DONE;
2950 })
2951
2952 (define_expand "fix_truncsfdi2"
2953   [(set (match_operand:DI 0 "register_operand" "")
2954         (fix:DI (match_operand:SF 1 "nonimmediate_operand" "")))]
2955   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2956 {
2957   operands[1] = force_reg (SFmode, operands[1]);
2958   emit_insn (gen_fix_truncsfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2959   DONE;
2960 })
2961
2962 (define_insn "fix_truncsfdi2_ieee"
2963   [(set (match_operand:DI 0 "register_operand" "=d")
2964         (fix:DI (match_operand:SF 1 "register_operand"  "f")))
2965    (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
2966    (clobber (reg:CC 33))]
2967   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2968   "cgebr\t%0,%h2,%1"
2969   [(set_attr "op_type" "RRE")
2970    (set_attr "type"    "ftoi")])
2971
2972 ;
2973 ; fixuns_truncsfsi2 and fix_truncsfsi2 instruction pattern(s).
2974 ;
2975
2976 (define_expand "fixuns_truncsfsi2"
2977   [(set (match_operand:SI 0 "register_operand" "")
2978         (unsigned_fix:SI (match_operand:SF 1 "register_operand" "")))]
2979   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2980 {
2981   rtx label1 = gen_label_rtx ();
2982   rtx label2 = gen_label_rtx ();
2983   rtx temp = gen_reg_rtx (SFmode);
2984
2985   operands[1] = force_reg (SFmode, operands[1]);
2986   emit_insn (gen_cmpsf (operands[1],
2987         CONST_DOUBLE_FROM_REAL_VALUE (
2988           REAL_VALUE_ATOF ("2147483648.0", SFmode), SFmode)));
2989   emit_jump_insn (gen_blt (label1));
2990   emit_insn (gen_subsf3 (temp, operands[1],
2991         CONST_DOUBLE_FROM_REAL_VALUE (
2992           REAL_VALUE_ATOF ("4294967296.0", SFmode), SFmode)));
2993   emit_insn (gen_fix_truncsfsi2_ieee (operands[0], temp, GEN_INT (7)));
2994   emit_jump (label2);
2995
2996   emit_label (label1);
2997   emit_insn (gen_fix_truncsfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2998   emit_label (label2);
2999   DONE;
3000 })
3001
3002 (define_expand "fix_truncsfsi2"
3003   [(set (match_operand:SI 0 "register_operand" "")
3004         (fix:SI (match_operand:SF 1 "nonimmediate_operand" "")))]
3005   "TARGET_HARD_FLOAT"
3006 {
3007   if (TARGET_IBM_FLOAT)
3008     {
3009       /* Convert to DFmode and then use the POP algorithm.  */
3010       rtx temp = gen_reg_rtx (DFmode);
3011       emit_insn (gen_extendsfdf2 (temp, operands[1]));
3012       emit_insn (gen_fix_truncdfsi2 (operands[0], temp));
3013     }
3014   else
3015     {
3016       operands[1] = force_reg (SFmode, operands[1]);
3017       emit_insn (gen_fix_truncsfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
3018     }
3019
3020   DONE;
3021 })
3022
3023 (define_insn "fix_truncsfsi2_ieee"
3024   [(set (match_operand:SI 0 "register_operand" "=d")
3025         (fix:SI (match_operand:SF 1 "register_operand" "f")))
3026     (unspec:SI [(match_operand:SI 2 "immediate_operand" "K")] UNSPEC_ROUND)
3027     (clobber (reg:CC 33))]
3028   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3029   "cfebr\t%0,%h2,%1"
3030   [(set_attr "op_type" "RRE")
3031    (set_attr "type"    "ftoi")])
3032
3033 ;
3034 ; floatdidf2 instruction pattern(s).
3035 ;
3036
3037 (define_insn "floatdidf2"
3038   [(set (match_operand:DF 0 "register_operand" "=f")
3039         (float:DF (match_operand:DI 1 "register_operand" "d")))]
3040   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3041   "cdgbr\t%0,%1"
3042   [(set_attr "op_type" "RRE")
3043    (set_attr "type"    "itof" )])
3044
3045 ;
3046 ; floatdisf2 instruction pattern(s).
3047 ;
3048
3049 (define_insn "floatdisf2"
3050   [(set (match_operand:SF 0 "register_operand" "=f")
3051         (float:SF (match_operand:DI 1 "register_operand" "d")))]
3052   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3053   "cegbr\t%0,%1"
3054   [(set_attr "op_type" "RRE")
3055    (set_attr "type"    "itof" )])
3056
3057 ;
3058 ; floatsidf2 instruction pattern(s).
3059 ;
3060
3061 (define_expand "floatsidf2"
3062   [(set (match_operand:DF 0 "register_operand" "")
3063         (float:DF (match_operand:SI 1 "register_operand" "")))]
3064   "TARGET_HARD_FLOAT"
3065 {
3066   if (TARGET_IBM_FLOAT)
3067     {
3068       /* This is the algorithm from POP chapter A.5.7.1.  */
3069
3070       rtx temp  = assign_stack_local (BLKmode, 8, BITS_PER_WORD);
3071       rtx two31 = s390_gen_rtx_const_DI (0x4e000000, 0x80000000);
3072
3073       emit_insn (gen_floatsidf2_ibm (operands[0], operands[1], two31, temp));
3074       DONE;
3075     }
3076 })
3077
3078 (define_insn "floatsidf2_ieee"
3079   [(set (match_operand:DF 0 "register_operand" "=f")
3080         (float:DF (match_operand:SI 1 "register_operand" "d")))]
3081   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3082   "cdfbr\t%0,%1"
3083   [(set_attr "op_type" "RRE")
3084    (set_attr "type"   "itof" )])
3085
3086 (define_insn "floatsidf2_ibm"
3087   [(set (match_operand:DF 0 "register_operand" "=f")
3088         (float:DF (match_operand:SI 1 "register_operand" "d")))
3089    (use (match_operand:DI 2 "immediate_operand" "m"))
3090    (use (match_operand:BLK 3 "memory_operand" "m"))
3091    (clobber (reg:CC 33))]
3092   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3093 {
3094    output_asm_insn ("st\t%1,%N3", operands);
3095    output_asm_insn ("xi\t%N3,128", operands);
3096    output_asm_insn ("mvc\t%O3(4,%R3),%2", operands);
3097    output_asm_insn ("ld\t%0,%3", operands);
3098    return "sd\t%0,%2";
3099 }
3100   [(set_attr "length" "20")])
3101
3102 ;
3103 ; floatsisf2 instruction pattern(s).
3104 ;
3105
3106 (define_expand "floatsisf2"
3107   [(set (match_operand:SF 0 "register_operand" "")
3108         (float:SF (match_operand:SI 1 "register_operand" "")))]
3109   "TARGET_HARD_FLOAT"
3110 {
3111   if (TARGET_IBM_FLOAT)
3112     {
3113       /* Use the POP algorithm to convert to DFmode and then truncate.  */
3114       rtx temp = gen_reg_rtx (DFmode);
3115       emit_insn (gen_floatsidf2 (temp, operands[1]));
3116       emit_insn (gen_truncdfsf2 (operands[0], temp));
3117       DONE;
3118     }
3119 })
3120
3121 (define_insn "floatsisf2_ieee"
3122   [(set (match_operand:SF 0 "register_operand" "=f")
3123         (float:SF (match_operand:SI 1 "register_operand" "d")))]
3124   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3125   "cefbr\t%0,%1"
3126   [(set_attr "op_type" "RRE")
3127    (set_attr "type"    "itof" )])
3128
3129 ;
3130 ; truncdfsf2 instruction pattern(s).
3131 ;
3132
3133 (define_expand "truncdfsf2"
3134   [(set (match_operand:SF 0 "register_operand" "")
3135         (float_truncate:SF (match_operand:DF 1 "register_operand" "")))]
3136   "TARGET_HARD_FLOAT"
3137   "")
3138
3139 (define_insn "truncdfsf2_ieee"
3140   [(set (match_operand:SF 0 "register_operand" "=f")
3141         (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
3142   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3143   "ledbr\t%0,%1"
3144   [(set_attr "op_type"  "RRE")])
3145
3146 (define_insn "truncdfsf2_ibm"
3147   [(set (match_operand:SF 0 "register_operand" "=f,f")
3148         (float_truncate:SF (match_operand:DF 1 "nonimmediate_operand" "f,R")))]
3149   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3150   "@
3151    ler\t%0,%1
3152    le\t%0,%1"
3153   [(set_attr "op_type"  "RR,RX")
3154    (set_attr "type"   "floads,floads")])
3155
3156 ;
3157 ; extendsfdf2 instruction pattern(s).
3158 ;
3159
3160 (define_expand "extendsfdf2"
3161   [(set (match_operand:DF 0 "register_operand" "")
3162         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "")))]
3163   "TARGET_HARD_FLOAT"
3164 {
3165   if (TARGET_IBM_FLOAT)
3166     {
3167       emit_insn (gen_extendsfdf2_ibm (operands[0], operands[1]));
3168       DONE;
3169     }
3170 })
3171
3172 (define_insn "extendsfdf2_ieee"
3173   [(set (match_operand:DF 0 "register_operand" "=f,f")
3174         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand"  "f,R")))]
3175   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3176   "@
3177    ldebr\t%0,%1
3178    ldeb\t%0,%1"
3179   [(set_attr "op_type"  "RRE,RXE")
3180    (set_attr "type"   "floads,floads")])
3181
3182 (define_insn "extendsfdf2_ibm"
3183   [(set (match_operand:DF 0 "register_operand" "=f,f")
3184         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,R")))
3185    (clobber (reg:CC 33))]
3186   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3187   "@
3188    sdr\t%0,%0\;ler\t%0,%1
3189    sdr\t%0,%0\;le\t%0,%1"
3190   [(set_attr "length"   "4,6")
3191    (set_attr "type"     "floads,floads")])
3192
3193
3194 ;;
3195 ;; ARITHMETIC OPERATIONS
3196 ;;
3197 ;  arithmetic operations set the ConditionCode,
3198 ;  because of unpredictable Bits in Register for Halfword and Byte
3199 ;  the ConditionCode can be set wrong in operations for Halfword and Byte
3200
3201 ;;
3202 ;;- Add instructions.
3203 ;;
3204
3205 ;
3206 ; addti3 instruction pattern(s).
3207 ;
3208
3209 (define_insn_and_split "addti3"
3210   [(set (match_operand:TI 0 "register_operand" "=&d")
3211         (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
3212                  (match_operand:TI 2 "general_operand" "do") ) )
3213    (clobber (reg:CC 33))]
3214   "TARGET_64BIT"
3215   "#"
3216   "&& reload_completed"
3217   [(parallel
3218     [(set (reg:CCL1 33)
3219           (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
3220                         (match_dup 7)))
3221      (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
3222    (parallel
3223     [(set (match_dup 3) (plus:DI (plus:DI (match_dup 4) (match_dup 5))
3224                                  (ltu:DI (reg:CCL1 33) (const_int 0))))
3225      (clobber (reg:CC 33))])]
3226   "operands[3] = operand_subword (operands[0], 0, 0, TImode);
3227    operands[4] = operand_subword (operands[1], 0, 0, TImode);
3228    operands[5] = operand_subword (operands[2], 0, 0, TImode);
3229    operands[6] = operand_subword (operands[0], 1, 0, TImode);
3230    operands[7] = operand_subword (operands[1], 1, 0, TImode);
3231    operands[8] = operand_subword (operands[2], 1, 0, TImode);")
3232
3233 ;
3234 ; adddi3 instruction pattern(s).
3235 ;
3236
3237 (define_insn "*adddi3_sign"
3238   [(set (match_operand:DI 0 "register_operand" "=d,d")
3239         (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3240                  (match_operand:DI 1 "register_operand" "0,0")))
3241    (clobber (reg:CC 33))]
3242   "TARGET_64BIT"
3243   "@
3244    agfr\t%0,%2
3245    agf\t%0,%2"
3246   [(set_attr "op_type"  "RRE,RXY")])
3247
3248 (define_insn "*adddi3_zero_cc"
3249   [(set (reg 33)
3250         (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3251                           (match_operand:DI 1 "register_operand" "0,0"))
3252                  (const_int 0)))
3253    (set (match_operand:DI 0 "register_operand" "=d,d")
3254         (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
3255   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3256   "@
3257    algfr\t%0,%2
3258    algf\t%0,%2"
3259   [(set_attr "op_type"  "RRE,RXY")])
3260
3261 (define_insn "*adddi3_zero_cconly"
3262   [(set (reg 33)
3263         (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3264                           (match_operand:DI 1 "register_operand" "0,0"))
3265                  (const_int 0)))
3266    (clobber (match_scratch:DI 0 "=d,d"))]
3267   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3268   "@
3269    algfr\t%0,%2
3270    algf\t%0,%2"
3271   [(set_attr "op_type"  "RRE,RXY")])
3272
3273 (define_insn "*adddi3_zero"
3274   [(set (match_operand:DI 0 "register_operand" "=d,d")
3275         (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3276                  (match_operand:DI 1 "register_operand" "0,0")))
3277    (clobber (reg:CC 33))]
3278   "TARGET_64BIT"
3279   "@
3280    algfr\t%0,%2
3281    algf\t%0,%2"
3282   [(set_attr "op_type"  "RRE,RXY")])
3283
3284 (define_insn "*adddi3_imm_cc"
3285   [(set (reg 33)
3286         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "0")
3287                           (match_operand:DI 2 "const_int_operand" "K"))
3288                  (const_int 0)))
3289    (set (match_operand:DI 0 "register_operand" "=d")
3290         (plus:DI (match_dup 1) (match_dup 2)))]
3291   "TARGET_64BIT
3292    && s390_match_ccmode (insn, CCAmode)
3293    && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")"
3294   "aghi\t%0,%h2"
3295   [(set_attr "op_type"  "RI")])
3296
3297 (define_insn "*adddi3_carry1_cc"
3298   [(set (reg 33)
3299         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3300                           (match_operand:DI 2 "general_operand" "d,m"))
3301                  (match_dup 1)))
3302    (set (match_operand:DI 0 "register_operand" "=d,d")
3303         (plus:DI (match_dup 1) (match_dup 2)))]
3304   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3305   "@
3306    algr\t%0,%2
3307    alg\t%0,%2"
3308   [(set_attr "op_type"  "RRE,RXY")])
3309
3310 (define_insn "*adddi3_carry1_cconly"
3311   [(set (reg 33)
3312         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3313                           (match_operand:DI 2 "general_operand" "d,m"))
3314                  (match_dup 1)))
3315    (clobber (match_scratch:DI 0 "=d,d"))]
3316   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3317   "@
3318    algr\t%0,%2
3319    alg\t%0,%2"
3320   [(set_attr "op_type"  "RRE,RXY")])
3321
3322 (define_insn "*adddi3_carry2_cc"
3323   [(set (reg 33)
3324         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3325                           (match_operand:DI 2 "general_operand" "d,m"))
3326                  (match_dup 2)))
3327    (set (match_operand:DI 0 "register_operand" "=d,d")
3328         (plus:DI (match_dup 1) (match_dup 2)))]
3329   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3330   "@
3331    algr\t%0,%2
3332    alg\t%0,%2"
3333   [(set_attr "op_type"  "RRE,RXY")])
3334
3335 (define_insn "*adddi3_carry2_cconly"
3336   [(set (reg 33)
3337         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3338                           (match_operand:DI 2 "general_operand" "d,m"))
3339                  (match_dup 2)))
3340    (clobber (match_scratch:DI 0 "=d,d"))]
3341   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3342   "@
3343    algr\t%0,%2
3344    alg\t%0,%2"
3345   [(set_attr "op_type"  "RRE,RXY")])
3346
3347 (define_insn "*adddi3_cc"
3348   [(set (reg 33)
3349         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3350                           (match_operand:DI 2 "general_operand" "d,m"))
3351                  (const_int 0)))
3352    (set (match_operand:DI 0 "register_operand" "=d,d")
3353         (plus:DI (match_dup 1) (match_dup 2)))]
3354   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3355   "@
3356    algr\t%0,%2
3357    alg\t%0,%2"
3358   [(set_attr "op_type"  "RRE,RXY")])
3359
3360 (define_insn "*adddi3_cconly"
3361   [(set (reg 33)
3362         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3363                           (match_operand:DI 2 "general_operand" "d,m"))
3364                  (const_int 0)))
3365    (clobber (match_scratch:DI 0 "=d,d"))]
3366   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3367   "@
3368    algr\t%0,%2
3369    alg\t%0,%2"
3370   [(set_attr "op_type"  "RRE,RXY")])
3371
3372 (define_insn "*adddi3_cconly2"
3373   [(set (reg 33)
3374         (compare (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3375                  (neg:SI (match_operand:DI 2 "general_operand" "d,m"))))
3376    (clobber (match_scratch:DI 0 "=d,d"))]
3377   "s390_match_ccmode(insn, CCLmode) && TARGET_64BIT"
3378   "@
3379    algr\t%0,%2
3380    alg\t%0,%2"
3381   [(set_attr "op_type"  "RRE,RXY")])
3382
3383 (define_insn "*adddi3_64"
3384   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3385         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
3386                  (match_operand:DI 2 "general_operand" "d,K,m") ) )
3387    (clobber (reg:CC 33))]
3388   "TARGET_64BIT"
3389   "@
3390    agr\t%0,%2
3391    aghi\t%0,%h2
3392    ag\t%0,%2"
3393   [(set_attr "op_type"  "RRE,RI,RXY")])
3394
3395 (define_insn_and_split "*adddi3_31z"
3396   [(set (match_operand:DI 0 "register_operand" "=&d")
3397         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
3398                  (match_operand:DI 2 "general_operand" "do") ) )
3399    (clobber (reg:CC 33))]
3400   "!TARGET_64BIT && TARGET_CPU_ZARCH"
3401   "#"
3402   "&& reload_completed"
3403   [(parallel
3404     [(set (reg:CCL1 33)
3405           (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
3406                         (match_dup 7)))
3407      (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
3408    (parallel
3409     [(set (match_dup 3) (plus:SI (plus:SI (match_dup 4) (match_dup 5))
3410                                  (ltu:SI (reg:CCL1 33) (const_int 0))))
3411      (clobber (reg:CC 33))])]
3412   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3413    operands[4] = operand_subword (operands[1], 0, 0, DImode);
3414    operands[5] = operand_subword (operands[2], 0, 0, DImode);
3415    operands[6] = operand_subword (operands[0], 1, 0, DImode);
3416    operands[7] = operand_subword (operands[1], 1, 0, DImode);
3417    operands[8] = operand_subword (operands[2], 1, 0, DImode);")
3418
3419 (define_insn_and_split "*adddi3_31"
3420   [(set (match_operand:DI 0 "register_operand" "=&d")
3421         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
3422                  (match_operand:DI 2 "general_operand" "do") ) )
3423    (clobber (reg:CC 33))]
3424   "!TARGET_CPU_ZARCH"
3425   "#"
3426   "&& reload_completed"
3427   [(parallel
3428     [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
3429      (clobber (reg:CC 33))])
3430    (parallel
3431     [(set (reg:CCL1 33)
3432           (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
3433                         (match_dup 7)))
3434      (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
3435    (set (pc)
3436         (if_then_else (ltu (reg:CCL1 33) (const_int 0))
3437                       (pc)
3438                       (label_ref (match_dup 9))))
3439    (parallel
3440     [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
3441      (clobber (reg:CC 33))])
3442    (match_dup 9)]
3443   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3444    operands[4] = operand_subword (operands[1], 0, 0, DImode);
3445    operands[5] = operand_subword (operands[2], 0, 0, DImode);
3446    operands[6] = operand_subword (operands[0], 1, 0, DImode);
3447    operands[7] = operand_subword (operands[1], 1, 0, DImode);
3448    operands[8] = operand_subword (operands[2], 1, 0, DImode);
3449    operands[9] = gen_label_rtx ();")
3450
3451 (define_expand "adddi3"
3452   [(parallel
3453     [(set (match_operand:DI 0 "register_operand" "")
3454           (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
3455                    (match_operand:DI 2 "general_operand" "")))
3456      (clobber (reg:CC 33))])]
3457   ""
3458   "")
3459
3460 ;
3461 ; addsi3 instruction pattern(s).
3462 ;
3463
3464 (define_insn "*addsi3_imm_cc"
3465   [(set (reg 33)
3466         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "0")
3467                           (match_operand:SI 2 "const_int_operand" "K"))
3468                  (const_int 0)))
3469    (set (match_operand:SI 0 "register_operand" "=d")
3470         (plus:SI (match_dup 1) (match_dup 2)))]
3471   "s390_match_ccmode (insn, CCAmode)
3472    && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")"
3473   "ahi\t%0,%h2"
3474   [(set_attr "op_type"  "RI")])
3475
3476 (define_insn "*addsi3_carry1_cc"
3477   [(set (reg 33)
3478         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3479                           (match_operand:SI 2 "general_operand" "d,R,T"))
3480                  (match_dup 1)))
3481    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3482         (plus:SI (match_dup 1) (match_dup 2)))]
3483   "s390_match_ccmode (insn, CCL1mode)"
3484   "@
3485    alr\t%0,%2
3486    al\t%0,%2
3487    aly\t%0,%2"
3488   [(set_attr "op_type"  "RR,RX,RXY")])
3489
3490 (define_insn "*addsi3_carry1_cconly"
3491   [(set (reg 33)
3492         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3493                           (match_operand:SI 2 "general_operand" "d,R,T"))
3494                  (match_dup 1)))
3495    (clobber (match_scratch:SI 0 "=d,d,d"))]
3496   "s390_match_ccmode (insn, CCL1mode)"
3497   "@
3498    alr\t%0,%2
3499    al\t%0,%2
3500    aly\t%0,%2"
3501   [(set_attr "op_type"  "RR,RX,RXY")])
3502
3503 (define_insn "*addsi3_carry2_cc"
3504   [(set (reg 33)
3505         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3506                           (match_operand:SI 2 "general_operand" "d,R,T"))
3507                  (match_dup 2)))
3508    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3509         (plus:SI (match_dup 1) (match_dup 2)))]
3510   "s390_match_ccmode (insn, CCL1mode)"
3511   "@
3512    alr\t%0,%2
3513    al\t%0,%2
3514    aly\t%0,%2"
3515   [(set_attr "op_type"  "RR,RX,RXY")])
3516
3517 (define_insn "*addsi3_carry2_cconly"
3518   [(set (reg 33)
3519         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3520                           (match_operand:SI 2 "general_operand" "d,R,T"))
3521                  (match_dup 2)))
3522    (clobber (match_scratch:SI 0 "=d,d,d"))]
3523   "s390_match_ccmode (insn, CCL1mode)"
3524   "@
3525    alr\t%0,%2
3526    al\t%0,%2
3527    aly\t%0,%2"
3528   [(set_attr "op_type"  "RR,RX,RXY")])
3529
3530 (define_insn "*addsi3_cc"
3531   [(set (reg 33)
3532         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3533                           (match_operand:SI 2 "general_operand" "d,R,T"))
3534                  (const_int 0)))
3535    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3536         (plus:SI (match_dup 1) (match_dup 2)))]
3537   "s390_match_ccmode (insn, CCLmode)"
3538   "@
3539    alr\t%0,%2
3540    al\t%0,%2
3541    aly\t%0,%2"
3542   [(set_attr "op_type"  "RR,RX,RXY")])
3543
3544 (define_insn "*addsi3_cconly"
3545   [(set (reg 33)
3546         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3547                           (match_operand:SI 2 "general_operand" "d,R,T"))
3548                  (const_int 0)))
3549    (clobber (match_scratch:SI 0 "=d,d,d"))]
3550   "s390_match_ccmode (insn, CCLmode)"
3551   "@
3552    alr\t%0,%2
3553    al\t%0,%2
3554    aly\t%0,%2"
3555   [(set_attr "op_type"  "RR,RX,RXY")])
3556
3557 (define_insn "*addsi3_cconly2"
3558   [(set (reg 33)
3559         (compare (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3560                  (neg:SI (match_operand:SI 2 "general_operand" "d,R,T"))))
3561    (clobber (match_scratch:SI 0 "=d,d,d"))]
3562   "s390_match_ccmode (insn, CCLmode)"
3563   "@
3564    alr\t%0,%2
3565    al\t%0,%2
3566    aly\t%0,%2"
3567   [(set_attr "op_type"  "RR,RX,RXY")])
3568
3569 (define_insn "*addsi3_sign"
3570   [(set (match_operand:SI 0 "register_operand" "=d,d")
3571         (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
3572                  (match_operand:SI 1 "register_operand" "0,0")))
3573    (clobber (reg:CC 33))]
3574   ""
3575   "@
3576    ah\t%0,%2
3577    ahy\t%0,%2"
3578   [(set_attr "op_type"  "RX,RXY")])
3579
3580 (define_insn "addsi3"
3581   [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
3582         (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
3583                  (match_operand:SI 2 "general_operand" "d,K,R,T")))
3584    (clobber (reg:CC 33))]
3585   ""
3586   "@
3587    ar\t%0,%2
3588    ahi\t%0,%h2
3589    a\t%0,%2
3590    ay\t%0,%2"
3591   [(set_attr "op_type"  "RR,RI,RX,RXY")])
3592
3593 ;
3594 ; adddf3 instruction pattern(s).
3595 ;
3596
3597 (define_expand "adddf3"
3598   [(parallel
3599     [(set (match_operand:DF 0 "register_operand" "=f,f")
3600           (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3601                    (match_operand:DF 2 "general_operand" "f,R")))
3602      (clobber (reg:CC 33))])]
3603   "TARGET_HARD_FLOAT"
3604   "")
3605
3606 (define_insn "*adddf3"
3607   [(set (match_operand:DF 0 "register_operand" "=f,f")
3608         (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3609                  (match_operand:DF 2 "general_operand" "f,R")))
3610    (clobber (reg:CC 33))]
3611   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3612   "@
3613    adbr\t%0,%2
3614    adb\t%0,%2"
3615   [(set_attr "op_type"  "RRE,RXE")
3616    (set_attr "type"     "fsimpd,fsimpd")])
3617
3618 (define_insn "*adddf3_cc"
3619   [(set (reg 33)
3620         (compare (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3621                           (match_operand:DF 2 "general_operand" "f,R"))
3622                  (match_operand:DF 3 "const0_operand" "")))
3623    (set (match_operand:DF 0 "register_operand" "=f,f")
3624         (plus:DF (match_dup 1) (match_dup 2)))]
3625   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3626   "@
3627    adbr\t%0,%2
3628    adb\t%0,%2"
3629   [(set_attr "op_type"  "RRE,RXE")
3630    (set_attr "type"     "fsimpd,fsimpd")])
3631
3632 (define_insn "*adddf3_cconly"
3633   [(set (reg 33)
3634         (compare (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3635                           (match_operand:DF 2 "general_operand" "f,R"))
3636                  (match_operand:DF 3 "const0_operand" "")))
3637    (clobber (match_scratch:DF 0 "=f,f"))]
3638   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3639   "@
3640   adbr\t%0,%2
3641   adb\t%0,%2"
3642   [(set_attr "op_type"  "RRE,RXE")
3643    (set_attr "type"     "fsimpd,fsimpd")])
3644
3645 (define_insn "*adddf3_ibm"
3646   [(set (match_operand:DF 0 "register_operand" "=f,f")
3647         (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3648                  (match_operand:DF 2 "general_operand" "f,R")))
3649    (clobber (reg:CC 33))]
3650   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3651   "@
3652    adr\t%0,%2
3653    ad\t%0,%2"
3654   [(set_attr "op_type"  "RR,RX")
3655    (set_attr "type"     "fsimpd,fsimpd")])
3656
3657 ;
3658 ; addsf3 instruction pattern(s).
3659 ;
3660
3661 (define_expand "addsf3"
3662   [(parallel
3663     [(set (match_operand:SF 0 "register_operand" "=f,f")
3664           (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3665                    (match_operand:SF 2 "general_operand" "f,R")))
3666      (clobber (reg:CC 33))])]
3667   "TARGET_HARD_FLOAT"
3668   "")
3669
3670 (define_insn "*addsf3"
3671   [(set (match_operand:SF 0 "register_operand" "=f,f")
3672         (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3673                  (match_operand:SF 2 "general_operand" "f,R")))
3674    (clobber (reg:CC 33))]
3675   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3676   "@
3677    aebr\t%0,%2
3678    aeb\t%0,%2"
3679   [(set_attr "op_type"  "RRE,RXE")
3680    (set_attr "type"     "fsimps,fsimps")])
3681
3682 (define_insn "*addsf3_cc"
3683   [(set (reg 33)
3684         (compare (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3685                           (match_operand:SF 2 "general_operand" "f,R"))
3686                  (match_operand:SF 3 "const0_operand" "")))
3687    (set (match_operand:SF 0 "register_operand" "=f,f")
3688         (plus:SF (match_dup 1) (match_dup 2)))]
3689   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3690   "@
3691    aebr\t%0,%2
3692    aeb\t%0,%2"
3693   [(set_attr "op_type"  "RRE,RXE")
3694    (set_attr "type"     "fsimps,fsimps")])
3695
3696 (define_insn "*addsf3_cconly"
3697   [(set (reg 33)
3698         (compare (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3699                           (match_operand:SF 2 "general_operand" "f,R"))
3700                  (match_operand:SF 3 "const0_operand" "")))
3701    (clobber (match_scratch:SF 0 "=f,f"))]
3702   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3703   "@
3704    aebr\t%0,%2
3705    aeb\t%0,%2"
3706   [(set_attr "op_type"  "RRE,RXE")
3707    (set_attr "type"     "fsimps,fsimps")])
3708
3709 (define_insn "*addsf3"
3710   [(set (match_operand:SF 0 "register_operand" "=f,f")
3711         (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3712                  (match_operand:SF 2 "general_operand" "f,R")))
3713    (clobber (reg:CC 33))]
3714   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3715   "@
3716    aer\t%0,%2
3717    ae\t%0,%2"
3718   [(set_attr "op_type"  "RR,RX")
3719    (set_attr "type"     "fsimps,fsimps")])
3720
3721
3722 ;;
3723 ;;- Subtract instructions.
3724 ;;
3725
3726 ;
3727 ; subti3 instruction pattern(s).
3728 ;
3729
3730 (define_insn_and_split "subti3"
3731   [(set (match_operand:TI 0 "register_operand" "=&d")
3732         (minus:TI (match_operand:TI 1 "register_operand" "0")
3733                   (match_operand:TI 2 "general_operand" "do") ) )
3734    (clobber (reg:CC 33))]
3735   "TARGET_64BIT"
3736   "#"
3737   "&& reload_completed"
3738   [(parallel
3739     [(set (reg:CCL2 33)
3740           (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
3741                         (match_dup 7)))
3742      (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
3743    (parallel
3744     [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
3745                                   (gtu:DI (reg:CCL2 33) (const_int 0))))
3746      (clobber (reg:CC 33))])]
3747   "operands[3] = operand_subword (operands[0], 0, 0, TImode);
3748    operands[4] = operand_subword (operands[1], 0, 0, TImode);
3749    operands[5] = operand_subword (operands[2], 0, 0, TImode);
3750    operands[6] = operand_subword (operands[0], 1, 0, TImode);
3751    operands[7] = operand_subword (operands[1], 1, 0, TImode);
3752    operands[8] = operand_subword (operands[2], 1, 0, TImode);")
3753
3754 ;
3755 ; subdi3 instruction pattern(s).
3756 ;
3757
3758 (define_insn "*subdi3_sign"
3759   [(set (match_operand:DI 0 "register_operand" "=d,d")
3760         (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3761                   (sign_extend:DI (match_operand:SI 2 "general_operand" "d,m"))))
3762    (clobber (reg:CC 33))]
3763   "TARGET_64BIT"
3764   "@
3765    sgfr\t%0,%2
3766    sgf\t%0,%2"
3767   [(set_attr "op_type"  "RRE,RXY")])
3768
3769 (define_insn "*subdi3_zero_cc"
3770   [(set (reg 33)
3771         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3772                            (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m")))
3773                  (const_int 0)))
3774    (set (match_operand:DI 0 "register_operand" "=d,d")
3775         (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
3776   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3777   "@
3778    slgfr\t%0,%2
3779    slgf\t%0,%2"
3780   [(set_attr "op_type"  "RRE,RXY")])
3781
3782 (define_insn "*subdi3_zero_cconly"
3783   [(set (reg 33)
3784         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3785                            (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m")))
3786                  (const_int 0)))
3787    (clobber (match_scratch:DI 0 "=d,d"))]
3788   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3789   "@
3790    slgfr\t%0,%2
3791    slgf\t%0,%2"
3792   [(set_attr "op_type"  "RRE,RXY")])
3793
3794 (define_insn "*subdi3_zero"
3795   [(set (match_operand:DI 0 "register_operand" "=d,d")
3796         (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3797                   (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))))
3798    (clobber (reg:CC 33))]
3799   "TARGET_64BIT"
3800   "@
3801    slgfr\t%0,%2
3802    slgf\t%0,%2"
3803   [(set_attr "op_type"  "RRE,RXY")])
3804
3805 (define_insn "*subdi3_borrow_cc"
3806   [(set (reg 33)
3807         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3808                            (match_operand:DI 2 "general_operand" "d,m"))
3809                  (match_dup 1)))
3810    (set (match_operand:DI 0 "register_operand" "=d,d")
3811         (minus:DI (match_dup 1) (match_dup 2)))]
3812   "s390_match_ccmode (insn, CCL2mode) && TARGET_64BIT"
3813   "@
3814    slgr\t%0,%2
3815    slg\t%0,%2"
3816   [(set_attr "op_type"  "RRE,RXY")])
3817
3818 (define_insn "*subdi3_borrow_cconly"
3819   [(set (reg 33)
3820         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3821                            (match_operand:DI 2 "general_operand" "d,m"))
3822                  (match_dup 1)))
3823    (clobber (match_scratch:DI 0 "=d,d"))]
3824   "s390_match_ccmode (insn, CCL2mode) && TARGET_64BIT"
3825   "@
3826    slgr\t%0,%2
3827    slg\t%0,%2"
3828   [(set_attr "op_type"  "RRE,RXY")])
3829
3830 (define_insn "*subdi3_cc"
3831   [(set (reg 33)
3832         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3833                            (match_operand:DI 2 "general_operand" "d,m"))
3834                  (const_int 0)))
3835    (set (match_operand:DI 0 "register_operand" "=d,d")
3836         (minus:DI (match_dup 1) (match_dup 2)))]
3837   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3838   "@
3839    slgr\t%0,%2
3840    slg\t%0,%2"
3841   [(set_attr "op_type"  "RRE,RXY")])
3842
3843 (define_insn "*subdi3_cc2"
3844   [(set (reg 33)
3845         (compare (match_operand:DI 1 "register_operand" "0,0")
3846                  (match_operand:DI 2 "general_operand" "d,m")))
3847    (set (match_operand:DI 0 "register_operand" "=d,d")
3848         (minus:DI (match_dup 1) (match_dup 2)))]
3849   "s390_match_ccmode (insn, CCL3mode) && TARGET_64BIT"
3850   "@
3851    slgr\t%0,%2
3852    slg\t%0,%2"
3853   [(set_attr "op_type"  "RRE,RXY")])
3854
3855 (define_insn "*subdi3_cconly"
3856   [(set (reg 33)
3857         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3858                            (match_operand:DI 2 "general_operand" "d,m"))
3859                  (const_int 0)))
3860    (clobber (match_scratch:DI 0 "=d,d"))]
3861   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3862   "@
3863    slgr\t%0,%2
3864    slg\t%0,%2"
3865   [(set_attr "op_type"  "RRE,RXY")])
3866
3867 (define_insn "*subdi3_cconly2"
3868   [(set (reg 33)
3869         (compare (match_operand:DI 1 "register_operand" "0,0")
3870                  (match_operand:DI 2 "general_operand" "d,m")))
3871    (clobber (match_scratch:DI 0 "=d,d"))]
3872   "s390_match_ccmode (insn, CCL3mode) && TARGET_64BIT"
3873   "@
3874    slgr\t%0,%2
3875    slg\t%0,%2"
3876   [(set_attr "op_type"  "RRE,RXY")])
3877
3878 (define_insn "*subdi3_64"
3879   [(set (match_operand:DI 0 "register_operand" "=d,d")
3880         (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3881                   (match_operand:DI 2 "general_operand" "d,m") ) )
3882    (clobber (reg:CC 33))]
3883   "TARGET_64BIT"
3884   "@
3885    sgr\t%0,%2
3886    sg\t%0,%2"
3887   [(set_attr "op_type"  "RRE,RRE")])
3888
3889 (define_insn_and_split "*subdi3_31z"
3890   [(set (match_operand:DI 0 "register_operand" "=&d")
3891         (minus:DI (match_operand:DI 1 "register_operand" "0")
3892                   (match_operand:DI 2 "general_operand" "do") ) )
3893    (clobber (reg:CC 33))]
3894   "!TARGET_64BIT && TARGET_CPU_ZARCH"
3895   "#"
3896   "&& reload_completed"
3897   [(parallel
3898     [(set (reg:CCL2 33)
3899           (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
3900                         (match_dup 7)))
3901      (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
3902    (parallel
3903     [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
3904                                   (gtu:SI (reg:CCL2 33) (const_int 0))))
3905      (clobber (reg:CC 33))])]
3906   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3907    operands[4] = operand_subword (operands[1], 0, 0, DImode);
3908    operands[5] = operand_subword (operands[2], 0, 0, DImode);
3909    operands[6] = operand_subword (operands[0], 1, 0, DImode);
3910    operands[7] = operand_subword (operands[1], 1, 0, DImode);
3911    operands[8] = operand_subword (operands[2], 1, 0, DImode);")
3912
3913 (define_insn_and_split "*subdi3_31"
3914   [(set (match_operand:DI 0 "register_operand" "=&d")
3915         (minus:DI (match_operand:DI 1 "register_operand" "0")
3916                   (match_operand:DI 2 "general_operand" "do") ) )
3917    (clobber (reg:CC 33))]
3918   "!TARGET_CPU_ZARCH"
3919   "#"
3920   "&& reload_completed"
3921   [(parallel
3922     [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
3923      (clobber (reg:CC 33))])
3924    (parallel
3925     [(set (reg:CCL2 33)
3926           (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
3927                         (match_dup 7)))
3928      (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
3929    (set (pc)
3930         (if_then_else (gtu (reg:CCL2 33) (const_int 0))
3931                       (pc)
3932                       (label_ref (match_dup 9))))
3933    (parallel
3934     [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
3935      (clobber (reg:CC 33))])
3936    (match_dup 9)]
3937   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3938    operands[4] = operand_subword (operands[1], 0, 0, DImode);
3939    operands[5] = operand_subword (operands[2], 0, 0, DImode);
3940    operands[6] = operand_subword (operands[0], 1, 0, DImode);
3941    operands[7] = operand_subword (operands[1], 1, 0, DImode);
3942    operands[8] = operand_subword (operands[2], 1, 0, DImode);
3943    operands[9] = gen_label_rtx ();")
3944
3945 (define_expand "subdi3"
3946   [(parallel
3947     [(set (match_operand:DI 0 "register_operand" "")
3948           (minus:DI (match_operand:DI 1 "register_operand" "")
3949                     (match_operand:DI 2 "general_operand" "")))
3950      (clobber (reg:CC 33))])]
3951   ""
3952   "")
3953
3954 ;
3955 ; subsi3 instruction pattern(s).
3956 ;
3957
3958 (define_insn "*subsi3_borrow_cc"
3959   [(set (reg 33)
3960         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
3961                            (match_operand:SI 2 "general_operand" "d,R,T"))
3962                  (match_dup 1)))
3963    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3964         (minus:SI (match_dup 1) (match_dup 2)))]
3965   "s390_match_ccmode (insn, CCL2mode)"
3966   "@
3967    slr\t%0,%2
3968    sl\t%0,%2
3969    sly\t%0,%2"
3970   [(set_attr "op_type"  "RR,RX,RXY")])
3971
3972 (define_insn "*subsi3_borrow_cconly"
3973   [(set (reg 33)
3974         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
3975                            (match_operand:SI 2 "general_operand" "d,R,T"))
3976                  (match_dup 1)))
3977    (clobber (match_scratch:SI 0 "=d,d,d"))]
3978   "s390_match_ccmode (insn, CCL2mode)"
3979   "@
3980    slr\t%0,%2
3981    sl\t%0,%2
3982    sly\t%0,%2"
3983   [(set_attr "op_type"  "RR,RX,RXY")])
3984
3985 (define_insn "*subsi3_cc"
3986   [(set (reg 33)
3987         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
3988                            (match_operand:SI 2 "general_operand" "d,R,T"))
3989                  (const_int 0)))
3990    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3991         (minus:SI (match_dup 1) (match_dup 2)))]
3992   "s390_match_ccmode (insn, CCLmode)"
3993   "@
3994    slr\t%0,%2
3995    sl\t%0,%2
3996    sly\t%0,%2"
3997   [(set_attr "op_type"  "RR,RX,RXY")])
3998
3999 (define_insn "*subsi3_cc2"
4000   [(set (reg 33)
4001         (compare (match_operand:SI 1 "register_operand" "0,0,0")
4002                  (match_operand:SI 2 "general_operand" "d,R,T")))
4003    (set (match_operand:SI 0 "register_operand" "=d,d,d")
4004         (minus:SI (match_dup 1) (match_dup 2)))]
4005   "s390_match_ccmode (insn, CCL3mode)"
4006   "@
4007    slr\t%0,%2
4008    sl\t%0,%2
4009    sly\t%0,%2"
4010   [(set_attr "op_type"  "RR,RX,RXY")])
4011
4012 (define_insn "*subsi3_cconly"
4013   [(set (reg 33)
4014         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4015                            (match_operand:SI 2 "general_operand" "d,R,T"))
4016                  (const_int 0)))
4017    (clobber (match_scratch:SI 0 "=d,d,d"))]
4018   "s390_match_ccmode (insn, CCLmode)"
4019   "@
4020    slr\t%0,%2
4021    sl\t%0,%2
4022    sly\t%0,%2"
4023   [(set_attr "op_type"  "RR,RX,RXY")])
4024
4025 (define_insn "*subsi3_cconly2"
4026   [(set (reg 33)
4027         (compare (match_operand:SI 1 "register_operand" "0,0,0")
4028                  (match_operand:SI 2 "general_operand" "d,R,T")))
4029    (clobber (match_scratch:SI 0 "=d,d,d"))]
4030   "s390_match_ccmode (insn, CCL3mode)"
4031   "@
4032    slr\t%0,%2
4033    sl\t%0,%2
4034    sly\t%0,%2"
4035   [(set_attr "op_type"  "RR,RX,RXY")])
4036
4037 (define_insn "*subsi3_sign"
4038   [(set (match_operand:SI 0 "register_operand" "=d,d")
4039         (minus:SI (match_operand:SI 1 "register_operand" "0,0")
4040                   (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
4041    (clobber (reg:CC 33))]
4042   ""
4043   "@
4044    sh\t%0,%2
4045    shy\t%0,%2"
4046   [(set_attr "op_type"  "RX,RXY")])
4047
4048 (define_insn "subsi3"
4049   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
4050         (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4051                   (match_operand:SI 2 "general_operand" "d,R,T")))
4052    (clobber (reg:CC 33))]
4053   ""
4054   "@
4055    sr\t%0,%2
4056    s\t%0,%2
4057    sy\t%0,%2"
4058   [(set_attr "op_type"  "RR,RX,RXY")])
4059
4060
4061 ;
4062 ; subdf3 instruction pattern(s).
4063 ;
4064
4065 (define_expand "subdf3"
4066   [(parallel
4067     [(set (match_operand:DF 0 "register_operand" "=f,f")
4068           (minus:DF (match_operand:DF 1 "register_operand" "0,0")
4069                     (match_operand:DF 2 "general_operand" "f,R")))
4070      (clobber (reg:CC 33))])]
4071   "TARGET_HARD_FLOAT"
4072   "")
4073
4074 (define_insn "*subdf3"
4075   [(set (match_operand:DF 0 "register_operand" "=f,f")
4076         (minus:DF (match_operand:DF 1 "register_operand" "0,0")
4077                   (match_operand:DF 2 "general_operand" "f,R")))
4078    (clobber (reg:CC 33))]
4079   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4080   "@
4081    sdbr\t%0,%2
4082    sdb\t%0,%2"
4083   [(set_attr "op_type"  "RRE,RXE")
4084    (set_attr "type"     "fsimpd,fsimpd")])
4085
4086 (define_insn "*subdf3_cc"
4087   [(set (reg 33)
4088         (compare (minus:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")
4089                            (match_operand:DF 2 "general_operand" "f,R"))
4090                  (match_operand:DF 3 "const0_operand" "")))
4091    (set (match_operand:DF 0 "register_operand" "=f,f")
4092         (minus:DF (match_dup 1) (match_dup 2)))]
4093   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4094   "@
4095    sdbr\t%0,%2
4096    sdb\t%0,%2"
4097   [(set_attr "op_type"  "RRE,RXE")
4098    (set_attr "type"     "fsimpd,fsimpd")])
4099
4100 (define_insn "*subdf3_cconly"
4101   [(set (reg 33)
4102         (compare (minus:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")
4103                            (match_operand:DF 2 "general_operand" "f,R"))
4104                  (match_operand:DF 3 "const0_operand" "")))
4105    (clobber (match_scratch:DF 0 "=f,f"))]
4106   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4107   "@
4108    sdbr\t%0,%2
4109    sdb\t%0,%2"
4110   [(set_attr "op_type"  "RRE,RXE")
4111    (set_attr "type"     "fsimpd,fsimpd")])
4112
4113 (define_insn "*subdf3_ibm"
4114   [(set (match_operand:DF 0 "register_operand" "=f,f")
4115         (minus:DF (match_operand:DF 1 "register_operand" "0,0")
4116                   (match_operand:DF 2 "general_operand" "f,R")))
4117    (clobber (reg:CC 33))]
4118   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4119   "@
4120    sdr\t%0,%2
4121    sd\t%0,%2"
4122   [(set_attr "op_type"  "RR,RX")
4123    (set_attr "type"     "fsimpd,fsimpd")])
4124
4125 ;
4126 ; subsf3 instruction pattern(s).
4127 ;
4128
4129 (define_expand "subsf3"
4130   [(parallel
4131     [(set (match_operand:SF 0 "register_operand" "=f,f")
4132           (minus:SF (match_operand:SF 1 "register_operand" "0,0")
4133                     (match_operand:SF 2 "general_operand" "f,R")))
4134      (clobber (reg:CC 33))])]
4135   "TARGET_HARD_FLOAT"
4136   "")
4137
4138 (define_insn "*subsf3"
4139   [(set (match_operand:SF 0 "register_operand" "=f,f")
4140         (minus:SF (match_operand:SF 1 "register_operand" "0,0")
4141                   (match_operand:SF 2 "general_operand" "f,R")))
4142    (clobber (reg:CC 33))]
4143   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4144   "@
4145    sebr\t%0,%2
4146    seb\t%0,%2"
4147   [(set_attr "op_type"  "RRE,RXE")
4148    (set_attr "type"     "fsimps,fsimps")])
4149
4150 (define_insn "*subsf3_cc"
4151   [(set (reg 33)
4152         (compare (minus:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")
4153                            (match_operand:SF 2 "general_operand" "f,R"))
4154                  (match_operand:SF 3 "const0_operand" "")))
4155    (set (match_operand:SF 0 "register_operand" "=f,f")
4156         (minus:SF (match_dup 1) (match_dup 2)))]
4157   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4158   "@
4159    sebr\t%0,%2
4160    seb\t%0,%2"
4161   [(set_attr "op_type"  "RRE,RXE")
4162    (set_attr "type"     "fsimps,fsimps")])
4163
4164 (define_insn "*subsf3_cconly"
4165   [(set (reg 33)
4166         (compare (minus:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")
4167                            (match_operand:SF 2 "general_operand" "f,R"))
4168                  (match_operand:SF 3 "const0_operand" "")))
4169    (clobber (match_scratch:SF 0 "=f,f"))]
4170   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4171   "@
4172    sebr\t%0,%2
4173    seb\t%0,%2"
4174   [(set_attr "op_type"  "RRE,RXE")
4175    (set_attr "type"     "fsimps,fsimps")])
4176
4177 (define_insn "*subsf3_ibm"
4178   [(set (match_operand:SF 0 "register_operand" "=f,f")
4179         (minus:SF (match_operand:SF 1 "register_operand" "0,0")
4180                   (match_operand:SF 2 "general_operand" "f,R")))
4181    (clobber (reg:CC 33))]
4182   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4183   "@
4184    ser\t%0,%2
4185    se\t%0,%2"
4186   [(set_attr "op_type"  "RR,RX")
4187    (set_attr "type"     "fsimps,fsimps")])
4188
4189
4190 ;;
4191 ;;- Conditional add/subtract instructions.
4192 ;;
4193
4194 ;
4195 ; adddicc instruction pattern(s).
4196 ;
4197
4198 (define_insn "*adddi3_alc_cc"
4199   [(set (reg 33)
4200         (compare
4201           (plus:DI (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4202                             (match_operand:DI 2 "general_operand" "d,m"))
4203                    (match_operand:DI 3 "s390_alc_comparison" ""))
4204           (const_int 0)))
4205    (set (match_operand:DI 0 "register_operand" "=d,d")
4206         (plus:DI (plus:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4207   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4208   "@
4209    alcgr\t%0,%2
4210    alcg\t%0,%2"
4211   [(set_attr "op_type"  "RRE,RXY")])
4212
4213 (define_insn "*adddi3_alc"
4214   [(set (match_operand:DI 0 "register_operand" "=d,d")
4215         (plus:DI (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4216                           (match_operand:DI 2 "general_operand" "d,m"))
4217                  (match_operand:DI 3 "s390_alc_comparison" "")))
4218    (clobber (reg:CC 33))]
4219   "TARGET_64BIT"
4220   "@
4221    alcgr\t%0,%2
4222    alcg\t%0,%2"
4223   [(set_attr "op_type"  "RRE,RXY")])
4224
4225 (define_insn "*subdi3_slb_cc"
4226   [(set (reg 33)
4227         (compare
4228           (minus:DI (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
4229                               (match_operand:DI 2 "general_operand" "d,m"))
4230                     (match_operand:DI 3 "s390_slb_comparison" ""))
4231           (const_int 0)))
4232    (set (match_operand:DI 0 "register_operand" "=d,d")
4233         (minus:DI (minus:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4234   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4235   "@
4236    slbgr\t%0,%2
4237    slbg\t%0,%2"
4238   [(set_attr "op_type"  "RRE,RXY")])
4239
4240 (define_insn "*subdi3_slb"
4241   [(set (match_operand:DI 0 "register_operand" "=d,d")
4242         (minus:DI (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
4243                             (match_operand:DI 2 "general_operand" "d,m"))
4244                   (match_operand:DI 3 "s390_slb_comparison" "")))
4245    (clobber (reg:CC 33))]
4246   "TARGET_64BIT"
4247   "@
4248    slbgr\t%0,%2
4249    slbg\t%0,%2"
4250   [(set_attr "op_type"  "RRE,RXY")])
4251
4252 (define_expand "adddicc"
4253   [(match_operand:DI 0 "register_operand" "")
4254    (match_operand 1 "comparison_operator" "")
4255    (match_operand:DI 2 "register_operand" "")
4256    (match_operand:DI 3 "const_int_operand" "")]
4257   "TARGET_64BIT"
4258   "if (!s390_expand_addcc (GET_CODE (operands[1]), 
4259                            s390_compare_op0, s390_compare_op1, 
4260                            operands[0], operands[2], 
4261                            operands[3])) FAIL; DONE;")
4262
4263 ;
4264 ; addsicc instruction pattern(s).
4265 ;
4266
4267 (define_insn "*addsi3_alc_cc"
4268   [(set (reg 33)
4269         (compare
4270           (plus:SI (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
4271                             (match_operand:SI 2 "general_operand" "d,m"))
4272                    (match_operand:SI 3 "s390_alc_comparison" ""))
4273           (const_int 0)))
4274    (set (match_operand:SI 0 "register_operand" "=d,d")
4275         (plus:SI (plus:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4276   "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
4277   "@
4278    alcr\t%0,%2
4279    alc\t%0,%2"
4280   [(set_attr "op_type"  "RRE,RXY")])
4281
4282 (define_insn "*addsi3_alc"
4283   [(set (match_operand:SI 0 "register_operand" "=d,d")
4284         (plus:SI (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
4285                           (match_operand:SI 2 "general_operand" "d,m"))
4286                  (match_operand:SI 3 "s390_alc_comparison" "")))
4287    (clobber (reg:CC 33))]
4288   "TARGET_CPU_ZARCH"
4289   "@
4290    alcr\t%0,%2
4291    alc\t%0,%2"
4292   [(set_attr "op_type"  "RRE,RXY")])
4293
4294 (define_insn "*subsi3_slb_cc"
4295   [(set (reg 33)
4296         (compare
4297           (minus:SI (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
4298                               (match_operand:SI 2 "general_operand" "d,m"))
4299                     (match_operand:SI 3 "s390_slb_comparison" ""))
4300           (const_int 0)))
4301    (set (match_operand:SI 0 "register_operand" "=d,d")
4302         (minus:SI (minus:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4303   "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
4304   "@
4305    slbr\t%0,%2
4306    slb\t%0,%2"
4307   [(set_attr "op_type"  "RRE,RXY")])
4308
4309 (define_insn "*subsi3_slb"
4310   [(set (match_operand:SI 0 "register_operand" "=d,d")
4311         (minus:SI (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
4312                             (match_operand:SI 2 "general_operand" "d,m"))
4313                   (match_operand:SI 3 "s390_slb_comparison" "")))
4314    (clobber (reg:CC 33))]
4315   "TARGET_CPU_ZARCH"
4316   "@
4317    slbr\t%0,%2
4318    slb\t%0,%2"
4319   [(set_attr "op_type"  "RRE,RXY")])
4320
4321 (define_expand "addsicc"
4322   [(match_operand:SI 0 "register_operand" "")
4323    (match_operand 1 "comparison_operator" "")
4324    (match_operand:SI 2 "register_operand" "")
4325    (match_operand:SI 3 "const_int_operand" "")]
4326   "TARGET_CPU_ZARCH"
4327   "if (!s390_expand_addcc (GET_CODE (operands[1]), 
4328                            s390_compare_op0, s390_compare_op1, 
4329                            operands[0], operands[2], 
4330                            operands[3])) FAIL; DONE;")
4331
4332 ;
4333 ; scond instruction pattern(s).
4334 ;
4335
4336 (define_insn_and_split "*sconddi"
4337   [(set (match_operand:DI 0 "register_operand" "=&d")
4338         (match_operand:DI 1 "s390_alc_comparison" ""))
4339    (clobber (reg:CC 33))]
4340   "TARGET_64BIT"
4341   "#"
4342   "&& reload_completed"
4343   [(set (match_dup 0) (const_int 0))
4344    (parallel
4345     [(set (match_dup 0) (plus:DI (plus:DI (match_dup 0) (match_dup 0))
4346                                  (match_dup 1)))
4347      (clobber (reg:CC 33))])]
4348   "")
4349
4350 (define_insn_and_split "*scondsi"
4351   [(set (match_operand:SI 0 "register_operand" "=&d")
4352         (match_operand:SI 1 "s390_alc_comparison" ""))
4353    (clobber (reg:CC 33))]
4354   "TARGET_CPU_ZARCH"
4355   "#"
4356   "&& reload_completed"
4357   [(set (match_dup 0) (const_int 0))
4358    (parallel
4359     [(set (match_dup 0) (plus:SI (plus:SI (match_dup 0) (match_dup 0))
4360                                  (match_dup 1)))
4361      (clobber (reg:CC 33))])]
4362   "")
4363
4364 (define_insn_and_split "*sconddi_neg"
4365   [(set (match_operand:DI 0 "register_operand" "=&d")
4366         (match_operand:DI 1 "s390_slb_comparison" ""))
4367    (clobber (reg:CC 33))]
4368   "TARGET_64BIT"
4369   "#"
4370   "&& reload_completed"
4371   [(set (match_dup 0) (const_int 0))
4372    (parallel
4373     [(set (match_dup 0) (minus:DI (minus:DI (match_dup 0) (match_dup 0))
4374                                   (match_dup 1)))
4375      (clobber (reg:CC 33))])
4376    (parallel
4377     [(set (match_dup 0) (neg:DI (match_dup 0)))
4378      (clobber (reg:CC 33))])]
4379   "")
4380
4381 (define_insn_and_split "*scondsi_neg"
4382   [(set (match_operand:SI 0 "register_operand" "=&d")
4383         (match_operand:SI 1 "s390_slb_comparison" ""))
4384    (clobber (reg:CC 33))]
4385   "TARGET_CPU_ZARCH"
4386   "#"
4387   "&& reload_completed"
4388   [(set (match_dup 0) (const_int 0))
4389    (parallel
4390     [(set (match_dup 0) (minus:SI (minus:SI (match_dup 0) (match_dup 0))
4391                                   (match_dup 1)))
4392      (clobber (reg:CC 33))])
4393    (parallel
4394     [(set (match_dup 0) (neg:SI (match_dup 0)))
4395      (clobber (reg:CC 33))])]
4396   "")
4397
4398 (define_expand "sltu"
4399   [(match_operand:SI 0 "register_operand" "")]
4400   "TARGET_CPU_ZARCH"
4401   "if (!s390_expand_addcc (LTU, s390_compare_op0, s390_compare_op1,
4402                            operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
4403
4404 (define_expand "sgtu"
4405   [(match_operand:SI 0 "register_operand" "")]
4406   "TARGET_CPU_ZARCH"
4407   "if (!s390_expand_addcc (GTU, s390_compare_op0, s390_compare_op1,
4408                            operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
4409
4410 (define_expand "sleu"
4411   [(match_operand:SI 0 "register_operand" "")]
4412   "TARGET_CPU_ZARCH"
4413   "if (!s390_expand_addcc (LEU, s390_compare_op0, s390_compare_op1,
4414                            operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
4415
4416 (define_expand "sgeu"
4417   [(match_operand:SI 0 "register_operand" "")]
4418   "TARGET_CPU_ZARCH"
4419   "if (!s390_expand_addcc (GEU, s390_compare_op0, s390_compare_op1,
4420                            operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
4421
4422
4423 ;;
4424 ;;- Multiply instructions.
4425 ;;
4426
4427 ;
4428 ; muldi3 instruction pattern(s).
4429 ;
4430
4431 (define_insn "*muldi3_sign"
4432   [(set (match_operand:DI 0 "register_operand" "=d,d")
4433         (mult:DI (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "d,m"))
4434                  (match_operand:DI 1 "register_operand" "0,0")))]
4435   "TARGET_64BIT"
4436   "@
4437    msgfr\t%0,%2
4438    msgf\t%0,%2"
4439   [(set_attr "op_type"  "RRE,RXY")
4440    (set_attr "type"     "imuldi")])
4441
4442 (define_insn "muldi3"
4443   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
4444         (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
4445                  (match_operand:DI 2 "general_operand" "d,K,m")))]
4446   "TARGET_64BIT"
4447   "@
4448    msgr\t%0,%2
4449    mghi\t%0,%h2
4450    msg\t%0,%2"
4451   [(set_attr "op_type"  "RRE,RI,RXY")
4452    (set_attr "type"     "imuldi")])
4453
4454 ;
4455 ; mulsi3 instruction pattern(s).
4456 ;
4457
4458 (define_insn "*mulsi3_sign"
4459   [(set (match_operand:SI 0 "register_operand" "=d")
4460         (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R"))
4461                  (match_operand:SI 1 "register_operand" "0")))]
4462   ""
4463   "mh\t%0,%2"
4464   [(set_attr "op_type"  "RX")
4465    (set_attr "type"     "imulhi")])
4466
4467 (define_insn "mulsi3"
4468   [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
4469         (mult:SI  (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
4470                   (match_operand:SI 2 "general_operand" "d,K,R,T")))]
4471   ""
4472   "@
4473    msr\t%0,%2
4474    mhi\t%0,%h2
4475    ms\t%0,%2
4476    msy\t%0,%2"
4477   [(set_attr "op_type"  "RRE,RI,RX,RXY")
4478    (set_attr "type"     "imulsi,imulhi,imulsi,imulsi")])
4479
4480 ;
4481 ; mulsidi3 instruction pattern(s).
4482 ;
4483
4484 (define_insn "mulsidi3"
4485   [(set (match_operand:DI 0 "register_operand" "=d,d")
4486         (mult:DI (sign_extend:DI
4487                    (match_operand:SI 1 "register_operand" "%0,0"))
4488                  (sign_extend:DI
4489                    (match_operand:SI 2 "nonimmediate_operand" "d,R"))))]
4490   "!TARGET_64BIT"
4491   "@
4492    mr\t%0,%2
4493    m\t%0,%2"
4494   [(set_attr "op_type"  "RR,RX")
4495    (set_attr "type"     "imulsi")])
4496
4497 ;
4498 ; umulsidi3 instruction pattern(s).
4499 ;
4500
4501 (define_insn "umulsidi3"
4502   [(set (match_operand:DI 0 "register_operand" "=d,d")
4503         (mult:DI (zero_extend:DI
4504                    (match_operand:SI 1 "register_operand" "%0,0"))
4505                  (zero_extend:DI
4506                    (match_operand:SI 2 "nonimmediate_operand" "d,m"))))]
4507   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4508   "@
4509    mlr\t%0,%2
4510    ml\t%0,%2"
4511   [(set_attr "op_type"  "RRE,RXY")
4512    (set_attr "type"     "imulsi")])
4513
4514 ;
4515 ; muldf3 instruction pattern(s).
4516 ;
4517
4518 (define_expand "muldf3"
4519   [(set (match_operand:DF 0 "register_operand" "=f,f")
4520         (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4521                  (match_operand:DF 2 "general_operand" "f,R")))]
4522   "TARGET_HARD_FLOAT"
4523   "")
4524
4525 (define_insn "*muldf3"
4526   [(set (match_operand:DF 0 "register_operand" "=f,f")
4527         (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4528                  (match_operand:DF 2 "general_operand" "f,R")))]
4529   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4530   "@
4531    mdbr\t%0,%2
4532    mdb\t%0,%2"
4533   [(set_attr "op_type"  "RRE,RXE")
4534    (set_attr "type"     "fmuld")])
4535
4536 (define_insn "*muldf3_ibm"
4537   [(set (match_operand:DF 0 "register_operand" "=f,f")
4538         (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4539                  (match_operand:DF 2 "general_operand" "f,R")))]
4540   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4541   "@
4542    mdr\t%0,%2
4543    md\t%0,%2"
4544   [(set_attr "op_type"  "RR,RX")
4545    (set_attr "type"    "fmuld")])
4546
4547 (define_insn "*fmadddf"
4548   [(set (match_operand:DF 0 "register_operand" "=f,f")
4549         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "%f,f")
4550                           (match_operand:DF 2 "nonimmediate_operand"  "f,R"))
4551                  (match_operand:DF 3 "register_operand" "0,0")))]
4552   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4553   "@
4554    madbr\t%0,%1,%2
4555    madb\t%0,%1,%2"
4556   [(set_attr "op_type"  "RRE,RXE")
4557    (set_attr "type" "fmuld")])
4558
4559 (define_insn "*fmsubdf"
4560   [(set (match_operand:DF 0 "register_operand" "=f,f")
4561         (minus:DF (mult:DF (match_operand:DF 1 "register_operand" "f,f")
4562                            (match_operand:DF 2 "nonimmediate_operand"  "f,R"))
4563                  (match_operand:DF 3 "register_operand" "0,0")))]
4564   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4565   "@
4566    msdbr\t%0,%1,%2
4567    msdb\t%0,%1,%2"
4568   [(set_attr "op_type"  "RRE,RXE")
4569    (set_attr "type" "fmuld")])
4570
4571 ;
4572 ; mulsf3 instruction pattern(s).
4573 ;
4574
4575 (define_expand "mulsf3"
4576   [(set (match_operand:SF 0 "register_operand" "=f,f")
4577         (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4578                  (match_operand:SF 2 "general_operand" "f,R")))]
4579   "TARGET_HARD_FLOAT"
4580   "")
4581
4582 (define_insn "*mulsf3"
4583   [(set (match_operand:SF 0 "register_operand" "=f,f")
4584         (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4585                  (match_operand:SF 2 "general_operand" "f,R")))]
4586   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4587   "@
4588    meebr\t%0,%2
4589    meeb\t%0,%2"
4590   [(set_attr "op_type"  "RRE,RXE")
4591    (set_attr "type"     "fmuls")])
4592
4593 (define_insn "*mulsf3_ibm"
4594   [(set (match_operand:SF 0 "register_operand" "=f,f")
4595         (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4596                  (match_operand:SF 2 "general_operand" "f,R")))]
4597   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4598   "@
4599    mer\t%0,%2
4600    me\t%0,%2"
4601   [(set_attr "op_type"  "RR,RX")
4602    (set_attr "type"     "fmuls")])
4603
4604 (define_insn "*fmaddsf"
4605   [(set (match_operand:SF 0 "register_operand" "=f,f")
4606         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f,f")
4607                           (match_operand:SF 2 "nonimmediate_operand"  "f,R"))
4608                  (match_operand:SF 3 "register_operand" "0,0")))]
4609   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4610   "@
4611    maebr\t%0,%1,%2
4612    maeb\t%0,%1,%2"
4613   [(set_attr "op_type"  "RRE,RXE")
4614    (set_attr "type" "fmuls")])
4615
4616 (define_insn "*fmsubsf"
4617   [(set (match_operand:SF 0 "register_operand" "=f,f")
4618         (minus:SF (mult:SF (match_operand:SF 1 "register_operand" "f,f")
4619                            (match_operand:SF 2 "nonimmediate_operand"  "f,R"))
4620                   (match_operand:SF 3 "register_operand" "0,0")))]
4621   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4622   "@
4623    msebr\t%0,%1,%2
4624    mseb\t%0,%1,%2"
4625   [(set_attr "op_type"  "RRE,RXE")
4626    (set_attr "type" "fmuls")])
4627
4628 ;;
4629 ;;- Divide and modulo instructions.
4630 ;;
4631
4632 ;
4633 ; divmoddi4 instruction pattern(s).
4634 ;
4635
4636 (define_expand "divmoddi4"
4637   [(parallel [(set (match_operand:DI 0 "general_operand" "")
4638                    (div:DI (match_operand:DI 1 "register_operand" "")
4639                            (match_operand:DI 2 "general_operand" "")))
4640               (set (match_operand:DI 3 "general_operand" "")
4641                    (mod:DI (match_dup 1) (match_dup 2)))])
4642    (clobber (match_dup 4))]
4643   "TARGET_64BIT"
4644 {
4645   rtx insn, div_equal, mod_equal;
4646
4647   div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
4648   mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
4649
4650   operands[4] = gen_reg_rtx(TImode);
4651   emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
4652
4653   insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
4654   REG_NOTES (insn) =
4655         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4656
4657   insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
4658   REG_NOTES (insn) =
4659         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4660
4661   DONE;
4662 })
4663
4664 (define_insn "divmodtidi3"
4665   [(set (match_operand:TI 0 "register_operand" "=d,d")
4666         (ior:TI
4667           (ashift:TI
4668             (zero_extend:TI
4669               (mod:DI (match_operand:DI 1 "register_operand" "0,0")
4670                       (match_operand:DI 2 "general_operand" "d,m")))
4671             (const_int 64))
4672           (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
4673   "TARGET_64BIT"
4674   "@
4675    dsgr\t%0,%2
4676    dsg\t%0,%2"
4677   [(set_attr "op_type"  "RRE,RXY")
4678    (set_attr "type"     "idiv")])
4679
4680 (define_insn "divmodtisi3"
4681   [(set (match_operand:TI 0 "register_operand" "=d,d")
4682         (ior:TI
4683           (ashift:TI
4684             (zero_extend:TI
4685               (mod:DI (match_operand:DI 1 "register_operand" "0,0")
4686                       (sign_extend:DI
4687                         (match_operand:SI 2 "nonimmediate_operand" "d,m"))))
4688             (const_int 64))
4689           (zero_extend:TI
4690             (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
4691   "TARGET_64BIT"
4692   "@
4693    dsgfr\t%0,%2
4694    dsgf\t%0,%2"
4695   [(set_attr "op_type"  "RRE,RXY")
4696    (set_attr "type"     "idiv")])
4697
4698 ;
4699 ; udivmoddi4 instruction pattern(s).
4700 ;
4701
4702 (define_expand "udivmoddi4"
4703   [(parallel [(set (match_operand:DI 0 "general_operand" "")
4704                    (udiv:DI (match_operand:DI 1 "general_operand" "")
4705                             (match_operand:DI 2 "nonimmediate_operand" "")))
4706               (set (match_operand:DI 3 "general_operand" "")
4707                    (umod:DI (match_dup 1) (match_dup 2)))])
4708    (clobber (match_dup 4))]
4709   "TARGET_64BIT"
4710 {
4711   rtx insn, div_equal, mod_equal, equal;
4712
4713   div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
4714   mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
4715   equal = gen_rtx_IOR (TImode,
4716                        gen_rtx_ASHIFT (TImode,
4717                                        gen_rtx_ZERO_EXTEND (TImode, mod_equal),
4718                                        GEN_INT (64)),
4719                        gen_rtx_ZERO_EXTEND (TImode, div_equal));
4720
4721   operands[4] = gen_reg_rtx(TImode);
4722   emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4]));
4723   emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
4724   emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
4725   insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
4726   REG_NOTES (insn) =
4727         gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4728
4729   insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
4730   REG_NOTES (insn) =
4731         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4732
4733   insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
4734   REG_NOTES (insn) =
4735         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4736
4737   DONE;
4738 })
4739
4740 (define_insn "udivmodtidi3"
4741   [(set (match_operand:TI 0 "register_operand" "=d,d")
4742         (ior:TI
4743           (ashift:TI
4744             (zero_extend:TI
4745               (truncate:DI
4746                 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
4747                          (zero_extend:TI
4748                            (match_operand:DI 2 "nonimmediate_operand" "d,m")))))
4749             (const_int 64))
4750           (zero_extend:TI
4751             (truncate:DI
4752               (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
4753   "TARGET_64BIT"
4754   "@
4755    dlgr\t%0,%2
4756    dlg\t%0,%2"
4757   [(set_attr "op_type"  "RRE,RXY")
4758    (set_attr "type"     "idiv")])
4759
4760 ;
4761 ; divmodsi4 instruction pattern(s).
4762 ;
4763
4764 (define_expand "divmodsi4"
4765   [(parallel [(set (match_operand:SI 0 "general_operand" "")
4766                    (div:SI (match_operand:SI 1 "general_operand" "")
4767                            (match_operand:SI 2 "nonimmediate_operand" "")))
4768               (set (match_operand:SI 3 "general_operand" "")
4769                    (mod:SI (match_dup 1) (match_dup 2)))])
4770    (clobber (match_dup 4))]
4771   "!TARGET_64BIT"
4772 {
4773   rtx insn, div_equal, mod_equal, equal;
4774
4775   div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
4776   mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
4777   equal = gen_rtx_IOR (DImode,
4778                        gen_rtx_ASHIFT (DImode,
4779                                        gen_rtx_ZERO_EXTEND (DImode, mod_equal),
4780                                        GEN_INT (32)),
4781                        gen_rtx_ZERO_EXTEND (DImode, div_equal));
4782
4783   operands[4] = gen_reg_rtx(DImode);
4784   emit_insn (gen_extendsidi2 (operands[4], operands[1]));
4785   insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
4786   REG_NOTES (insn) =
4787         gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4788
4789   insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
4790   REG_NOTES (insn) =
4791         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4792
4793   insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
4794   REG_NOTES (insn) =
4795         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4796
4797   DONE;
4798 })
4799
4800 (define_insn "divmoddisi3"
4801   [(set (match_operand:DI 0 "register_operand" "=d,d")
4802         (ior:DI
4803           (ashift:DI
4804             (zero_extend:DI
4805               (truncate:SI
4806                 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
4807                         (sign_extend:DI
4808                           (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
4809             (const_int 32))
4810           (zero_extend:DI
4811             (truncate:SI
4812               (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
4813   "!TARGET_64BIT"
4814   "@
4815    dr\t%0,%2
4816    d\t%0,%2"
4817   [(set_attr "op_type"  "RR,RX")
4818    (set_attr "type"     "idiv")])
4819
4820 ;
4821 ; udivsi3 and umodsi3 instruction pattern(s).
4822 ;
4823
4824 (define_expand "udivmodsi4"
4825   [(parallel [(set (match_operand:SI 0 "general_operand" "")
4826                    (udiv:SI (match_operand:SI 1 "general_operand" "")
4827                             (match_operand:SI 2 "nonimmediate_operand" "")))
4828               (set (match_operand:SI 3 "general_operand" "")
4829                    (umod:SI (match_dup 1) (match_dup 2)))])
4830    (clobber (match_dup 4))]
4831   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4832 {
4833   rtx insn, div_equal, mod_equal, equal;
4834
4835   div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4836   mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4837   equal = gen_rtx_IOR (DImode,
4838                        gen_rtx_ASHIFT (DImode,
4839                                        gen_rtx_ZERO_EXTEND (DImode, mod_equal),
4840                                        GEN_INT (32)),
4841                        gen_rtx_ZERO_EXTEND (DImode, div_equal));
4842
4843   operands[4] = gen_reg_rtx(DImode);
4844   emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4]));
4845   emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
4846   emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
4847   insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
4848   REG_NOTES (insn) =
4849         gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4850
4851   insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
4852   REG_NOTES (insn) =
4853         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4854
4855   insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
4856   REG_NOTES (insn) =
4857         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4858
4859   DONE;
4860 })
4861
4862 (define_insn "udivmoddisi3"
4863   [(set (match_operand:DI 0 "register_operand" "=d,d")
4864         (ior:DI
4865           (ashift:DI
4866             (zero_extend:DI
4867               (truncate:SI
4868                 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
4869                          (zero_extend:DI
4870                            (match_operand:SI 2 "nonimmediate_operand" "d,m")))))
4871             (const_int 32))
4872           (zero_extend:DI
4873             (truncate:SI
4874               (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
4875   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4876   "@
4877    dlr\t%0,%2
4878    dl\t%0,%2"
4879   [(set_attr "op_type"  "RRE,RXY")
4880    (set_attr "type"     "idiv")])
4881
4882 (define_expand "udivsi3"
4883   [(set (match_operand:SI 0 "register_operand" "=d")
4884         (udiv:SI (match_operand:SI 1 "general_operand" "")
4885                  (match_operand:SI 2 "general_operand" "")))
4886    (clobber (match_dup 3))]
4887   "!TARGET_64BIT && !TARGET_CPU_ZARCH"
4888 {
4889   rtx insn, udiv_equal, umod_equal, equal;
4890
4891   udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4892   umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4893   equal = gen_rtx_IOR (DImode,
4894                        gen_rtx_ASHIFT (DImode,
4895                                        gen_rtx_ZERO_EXTEND (DImode, umod_equal),
4896                                        GEN_INT (32)),
4897                        gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
4898
4899   operands[3] = gen_reg_rtx (DImode);
4900
4901   if (CONSTANT_P (operands[2]))
4902     {
4903       if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
4904         {
4905           rtx label1 = gen_label_rtx ();
4906
4907           operands[1] = make_safe_from (operands[1], operands[0]);
4908           emit_move_insn (operands[0], const0_rtx);
4909           emit_insn (gen_cmpsi (operands[1], operands[2]));
4910           emit_jump_insn (gen_bltu (label1));
4911           emit_move_insn (operands[0], const1_rtx);
4912           emit_label (label1);
4913         }
4914       else
4915         {
4916           operands[2] = force_reg (SImode, operands[2]);
4917           operands[2] = make_safe_from (operands[2], operands[0]);
4918
4919           emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4920           insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4921                                              operands[2]));
4922           REG_NOTES (insn) =
4923             gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4924
4925           insn = emit_move_insn (operands[0],
4926                                  gen_lowpart (SImode, operands[3]));
4927           REG_NOTES (insn) =
4928             gen_rtx_EXPR_LIST (REG_EQUAL,
4929                                udiv_equal, REG_NOTES (insn));
4930         }
4931     }
4932   else
4933     {
4934       rtx label1 = gen_label_rtx ();
4935       rtx label2 = gen_label_rtx ();
4936       rtx label3 = gen_label_rtx ();
4937
4938       operands[1] = force_reg (SImode, operands[1]);
4939       operands[1] = make_safe_from (operands[1], operands[0]);
4940       operands[2] = force_reg (SImode, operands[2]);
4941       operands[2] = make_safe_from (operands[2], operands[0]);
4942
4943       emit_move_insn (operands[0], const0_rtx);
4944       emit_insn (gen_cmpsi (operands[2], operands[1]));
4945       emit_jump_insn (gen_bgtu (label3));
4946       emit_insn (gen_cmpsi (operands[2], const0_rtx));
4947       emit_jump_insn (gen_blt (label2));
4948       emit_insn (gen_cmpsi (operands[2], const1_rtx));
4949       emit_jump_insn (gen_beq (label1));
4950       emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4951       insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4952                                          operands[2]));
4953       REG_NOTES (insn) =
4954       gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4955
4956       insn = emit_move_insn (operands[0],
4957                              gen_lowpart (SImode, operands[3]));
4958       REG_NOTES (insn) =
4959       gen_rtx_EXPR_LIST (REG_EQUAL,
4960                                udiv_equal, REG_NOTES (insn));
4961       emit_jump (label3);
4962       emit_label (label1);
4963       emit_move_insn (operands[0], operands[1]);
4964       emit_jump (label3);
4965       emit_label (label2);
4966       emit_move_insn (operands[0], const1_rtx);
4967       emit_label (label3);
4968     }
4969   emit_move_insn (operands[0], operands[0]);
4970   DONE;
4971 })
4972
4973 (define_expand "umodsi3"
4974   [(set (match_operand:SI 0 "register_operand" "=d")
4975         (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
4976                  (match_operand:SI 2 "nonimmediate_operand" "")))
4977    (clobber (match_dup 3))]
4978   "!TARGET_64BIT && !TARGET_CPU_ZARCH"
4979 {
4980   rtx insn, udiv_equal, umod_equal, equal;
4981
4982   udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4983   umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4984   equal = gen_rtx_IOR (DImode,
4985                        gen_rtx_ASHIFT (DImode,
4986                                        gen_rtx_ZERO_EXTEND (DImode, umod_equal),
4987                                        GEN_INT (32)),
4988                        gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
4989
4990   operands[3] = gen_reg_rtx (DImode);
4991
4992   if (CONSTANT_P (operands[2]))
4993     {
4994       if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
4995         {
4996           rtx label1 = gen_label_rtx ();
4997
4998           operands[1] = make_safe_from (operands[1], operands[0]);
4999           emit_move_insn (operands[0], operands[1]);
5000           emit_insn (gen_cmpsi (operands[0], operands[2]));
5001           emit_jump_insn (gen_bltu (label1));
5002           emit_insn (gen_abssi2 (operands[0], operands[2]));
5003           emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
5004           emit_label (label1);
5005         }
5006       else
5007         {
5008           operands[2] = force_reg (SImode, operands[2]);
5009           operands[2] = make_safe_from (operands[2], operands[0]);
5010
5011           emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5012           insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5013                                              operands[2]));
5014           REG_NOTES (insn) =
5015             gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
5016
5017           insn = emit_move_insn (operands[0],
5018                                  gen_highpart (SImode, operands[3]));
5019           REG_NOTES (insn) =
5020             gen_rtx_EXPR_LIST (REG_EQUAL,
5021                                umod_equal, REG_NOTES (insn));
5022         }
5023     }
5024   else
5025     {
5026       rtx label1 = gen_label_rtx ();
5027       rtx label2 = gen_label_rtx ();
5028       rtx label3 = gen_label_rtx ();
5029
5030       operands[1] = force_reg (SImode, operands[1]);
5031       operands[1] = make_safe_from (operands[1], operands[0]);
5032       operands[2] = force_reg (SImode, operands[2]);
5033       operands[2] = make_safe_from (operands[2], operands[0]);
5034
5035       emit_move_insn(operands[0], operands[1]);
5036       emit_insn (gen_cmpsi (operands[2], operands[1]));
5037       emit_jump_insn (gen_bgtu (label3));
5038       emit_insn (gen_cmpsi (operands[2], const0_rtx));
5039       emit_jump_insn (gen_blt (label2));
5040       emit_insn (gen_cmpsi (operands[2], const1_rtx));
5041       emit_jump_insn (gen_beq (label1));
5042       emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5043       insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5044                                          operands[2]));
5045       REG_NOTES (insn) =
5046       gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
5047
5048       insn = emit_move_insn (operands[0],
5049                              gen_highpart (SImode, operands[3]));
5050       REG_NOTES (insn) =
5051       gen_rtx_EXPR_LIST (REG_EQUAL,
5052                          umod_equal, REG_NOTES (insn));
5053       emit_jump (label3);
5054       emit_label (label1);
5055       emit_move_insn (operands[0], const0_rtx);
5056       emit_jump (label3);
5057       emit_label (label2);
5058       emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
5059       emit_label (label3);
5060     }
5061   DONE;
5062 })
5063
5064 ;
5065 ; divdf3 instruction pattern(s).
5066 ;
5067
5068 (define_expand "divdf3"
5069   [(set (match_operand:DF 0 "register_operand" "=f,f")
5070         (div:DF (match_operand:DF 1 "register_operand" "0,0")
5071                 (match_operand:DF 2 "general_operand" "f,R")))]
5072   "TARGET_HARD_FLOAT"
5073   "")
5074
5075 (define_insn "*divdf3"
5076   [(set (match_operand:DF 0 "register_operand" "=f,f")
5077         (div:DF (match_operand:DF 1 "register_operand" "0,0")
5078                 (match_operand:DF 2 "general_operand" "f,R")))]
5079   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5080   "@
5081    ddbr\t%0,%2
5082    ddb\t%0,%2"
5083   [(set_attr "op_type"  "RRE,RXE")
5084    (set_attr "type"     "fdivd")])
5085
5086 (define_insn "*divdf3_ibm"
5087   [(set (match_operand:DF 0 "register_operand" "=f,f")
5088         (div:DF (match_operand:DF 1 "register_operand" "0,0")
5089                 (match_operand:DF 2 "general_operand" "f,R")))]
5090   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5091   "@
5092    ddr\t%0,%2
5093    dd\t%0,%2"
5094   [(set_attr "op_type"  "RR,RX")
5095    (set_attr "type"     "fdivd")])
5096
5097 ;
5098 ; divsf3 instruction pattern(s).
5099 ;
5100
5101 (define_expand "divsf3"
5102   [(set (match_operand:SF 0 "register_operand" "=f,f")
5103         (div:SF (match_operand:SF 1 "register_operand" "0,0")
5104                 (match_operand:SF 2 "general_operand" "f,R")))]
5105   "TARGET_HARD_FLOAT"
5106   "")
5107
5108 (define_insn "*divsf3"
5109   [(set (match_operand:SF 0 "register_operand" "=f,f")
5110         (div:SF (match_operand:SF 1 "register_operand" "0,0")
5111                 (match_operand:SF 2 "general_operand" "f,R")))]
5112   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5113   "@
5114    debr\t%0,%2
5115    deb\t%0,%2"
5116   [(set_attr "op_type"  "RRE,RXE")
5117    (set_attr "type"     "fdivs")])
5118
5119 (define_insn "*divsf3"
5120   [(set (match_operand:SF 0 "register_operand" "=f,f")
5121         (div:SF (match_operand:SF 1 "register_operand" "0,0")
5122                 (match_operand:SF 2 "general_operand" "f,R")))]
5123   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5124   "@
5125    der\t%0,%2
5126    de\t%0,%2"
5127   [(set_attr "op_type"  "RR,RX")
5128    (set_attr "type"     "fdivs")])
5129
5130
5131 ;;
5132 ;;- And instructions.
5133 ;;
5134
5135 ;
5136 ; anddi3 instruction pattern(s).
5137 ;
5138
5139 (define_insn "*anddi3_cc"
5140   [(set (reg 33)
5141         (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5142                          (match_operand:DI 2 "general_operand" "d,m"))
5143                  (const_int 0)))
5144    (set (match_operand:DI 0 "register_operand" "=d,d")
5145         (and:DI (match_dup 1) (match_dup 2)))]
5146   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5147   "@
5148    ngr\t%0,%2
5149    ng\t%0,%2"
5150   [(set_attr "op_type"  "RRE,RXY")])
5151
5152 (define_insn "*anddi3_cconly"
5153   [(set (reg 33)
5154         (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5155                          (match_operand:DI 2 "general_operand" "d,m"))
5156                  (const_int 0)))
5157    (clobber (match_scratch:DI 0 "=d,d"))]
5158   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT
5159    /* Do not steal TM patterns.  */
5160    && s390_single_part (operands[2], DImode, HImode, 0) < 0"
5161   "@
5162    ngr\t%0,%2
5163    ng\t%0,%2"
5164   [(set_attr "op_type"  "RRE,RXY")])
5165
5166 (define_insn "*anddi3"
5167   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
5168         (and:DI (match_operand:DI 1 "nonimmediate_operand"
5169                                     "%d,o,0,0,0,0,0,0,0,0")
5170                 (match_operand:DI 2 "general_operand"
5171                                     "M,M,N0HDF,N1HDF,N2HDF,N3HDF,d,m,NxQDF,Q")))
5172    (clobber (reg:CC 33))]
5173   "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
5174   "@
5175    #
5176    #
5177    nihh\t%0,%j2
5178    nihl\t%0,%j2
5179    nilh\t%0,%j2
5180    nill\t%0,%j2
5181    ngr\t%0,%2
5182    ng\t%0,%2
5183    #
5184    #"
5185   [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RRE,RXY,SI,SS")])
5186
5187 (define_split
5188   [(set (match_operand:DI 0 "s_operand" "")
5189         (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
5190    (clobber (reg:CC 33))]
5191   "reload_completed"
5192   [(parallel
5193     [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5194      (clobber (reg:CC 33))])]
5195   "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5196
5197 (define_expand "anddi3"
5198   [(set (match_operand:DI 0 "nonimmediate_operand" "")
5199         (and:DI (match_operand:DI 1 "nonimmediate_operand" "")
5200                 (match_operand:DI 2 "general_operand" "")))
5201    (clobber (reg:CC 33))]
5202   "TARGET_64BIT"
5203   "s390_expand_logical_operator (AND, DImode, operands); DONE;")
5204
5205 ;
5206 ; andsi3 instruction pattern(s).
5207 ;
5208
5209 (define_insn "*andsi3_cc"
5210   [(set (reg 33)
5211         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5212                          (match_operand:SI 2 "general_operand" "d,R,T"))
5213                  (const_int 0)))
5214    (set (match_operand:SI 0 "register_operand" "=d,d,d")
5215         (and:SI (match_dup 1) (match_dup 2)))]
5216   "s390_match_ccmode(insn, CCTmode)"
5217   "@
5218    nr\t%0,%2
5219    n\t%0,%2
5220    ny\t%0,%2"
5221   [(set_attr "op_type"  "RR,RX,RXY")])
5222
5223 (define_insn "*andsi3_cconly"
5224   [(set (reg 33)
5225         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5226                          (match_operand:SI 2 "general_operand" "d,R,T"))
5227                  (const_int 0)))
5228    (clobber (match_scratch:SI 0 "=d,d,d"))]
5229   "s390_match_ccmode(insn, CCTmode)
5230    /* Do not steal TM patterns.  */
5231    && s390_single_part (operands[2], SImode, HImode, 0) < 0"
5232   "@
5233    nr\t%0,%2
5234    n\t%0,%2
5235    ny\t%0,%2"
5236   [(set_attr "op_type"  "RR,RX,RXY")])
5237
5238 (define_insn "*andsi3_zarch"
5239   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,AQ,Q")
5240         (and:SI (match_operand:SI 1 "nonimmediate_operand"
5241                                     "%d,o,0,0,0,0,0,0,0")
5242                 (match_operand:SI 2 "general_operand"
5243                                     "M,M,N0HSF,N1HSF,d,R,T,NxQSF,Q")))
5244    (clobber (reg:CC 33))]
5245   "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5246   "@
5247    #
5248    #
5249    nilh\t%0,%j2
5250    nill\t%0,%j2
5251    nr\t%0,%2
5252    n\t%0,%2
5253    ny\t%0,%2
5254    #
5255    #"
5256   [(set_attr "op_type"  "RRE,RXE,RI,RI,RR,RX,RXY,SI,SS")])
5257
5258 (define_insn "*andsi3_esa"
5259   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5260         (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5261                 (match_operand:SI 2 "general_operand" "d,R,NxQSF,Q")))
5262    (clobber (reg:CC 33))]
5263   "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5264   "@
5265    nr\t%0,%2
5266    n\t%0,%2
5267    #
5268    #"
5269   [(set_attr "op_type"  "RR,RX,SI,SS")])
5270
5271 (define_split
5272   [(set (match_operand:SI 0 "s_operand" "")
5273         (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
5274    (clobber (reg:CC 33))]
5275   "reload_completed"
5276   [(parallel
5277     [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5278      (clobber (reg:CC 33))])]
5279   "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5280
5281 (define_expand "andsi3"
5282   [(set (match_operand:SI 0 "nonimmediate_operand" "")
5283         (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
5284                 (match_operand:SI 2 "general_operand" "")))
5285    (clobber (reg:CC 33))]
5286   ""
5287   "s390_expand_logical_operator (AND, SImode, operands); DONE;")
5288
5289 ;
5290 ; andhi3 instruction pattern(s).
5291 ;
5292
5293 (define_insn "*andhi3_zarch"
5294   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5295         (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
5296                 (match_operand:HI 2 "general_operand" "d,n,NxQHF,Q")))
5297    (clobber (reg:CC 33))]
5298   "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5299   "@
5300    nr\t%0,%2
5301    nill\t%0,%x2
5302    #
5303    #"
5304   [(set_attr "op_type"  "RR,RI,SI,SS")])
5305
5306 (define_insn "*andhi3_esa"
5307   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
5308         (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
5309                 (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
5310    (clobber (reg:CC 33))]
5311   "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5312   "@
5313    nr\t%0,%2
5314    #
5315    #"
5316   [(set_attr "op_type"  "RR,SI,SS")])
5317
5318 (define_split
5319   [(set (match_operand:HI 0 "s_operand" "")
5320         (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
5321    (clobber (reg:CC 33))]
5322   "reload_completed"
5323   [(parallel
5324     [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5325      (clobber (reg:CC 33))])]
5326   "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5327
5328 (define_expand "andhi3"
5329   [(set (match_operand:HI 0 "nonimmediate_operand" "")
5330         (and:HI (match_operand:HI 1 "nonimmediate_operand" "")
5331                 (match_operand:HI 2 "general_operand" "")))
5332    (clobber (reg:CC 33))]
5333   ""
5334   "s390_expand_logical_operator (AND, HImode, operands); DONE;")
5335
5336 ;
5337 ; andqi3 instruction pattern(s).
5338 ;
5339
5340 (define_insn "*andqi3_zarch"
5341   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
5342         (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
5343                 (match_operand:QI 2 "general_operand" "d,n,n,n,Q")))
5344    (clobber (reg:CC 33))]
5345   "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5346   "@
5347    nr\t%0,%2
5348    nill\t%0,%b2
5349    ni\t%S0,%b2
5350    niy\t%S0,%b2
5351    #"
5352   [(set_attr "op_type"  "RR,RI,SI,SIY,SS")])
5353
5354 (define_insn "*andqi3_esa"
5355   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
5356         (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
5357                 (match_operand:QI 2 "general_operand" "d,n,Q")))
5358    (clobber (reg:CC 33))]
5359   "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5360   "@
5361    nr\t%0,%2
5362    ni\t%S0,%b2
5363    #"
5364   [(set_attr "op_type"  "RR,SI,SS")])
5365
5366 (define_expand "andqi3"
5367   [(set (match_operand:QI 0 "nonimmediate_operand" "")
5368         (and:QI (match_operand:QI 1 "nonimmediate_operand" "")
5369                 (match_operand:QI 2 "general_operand" "")))
5370    (clobber (reg:CC 33))]
5371   ""
5372   "s390_expand_logical_operator (AND, QImode, operands); DONE;")
5373
5374 ;
5375 ; Block and (NC) patterns.
5376 ;
5377
5378 (define_insn "*nc"
5379   [(set (match_operand:BLK 0 "memory_operand" "=Q")
5380         (and:BLK (match_dup 0)
5381                  (match_operand:BLK 1 "memory_operand" "Q")))
5382    (use (match_operand 2 "const_int_operand" "n"))
5383    (clobber (reg:CC 33))]
5384   "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
5385   "nc\t%O0(%2,%R0),%S1"
5386   [(set_attr "op_type" "SS")])
5387
5388 (define_split
5389   [(set (match_operand 0 "memory_operand" "")
5390         (and (match_dup 0)
5391              (match_operand 1 "memory_operand" "")))
5392    (clobber (reg:CC 33))]
5393   "reload_completed
5394    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5395    && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
5396   [(parallel
5397     [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
5398      (use (match_dup 2))
5399      (clobber (reg:CC 33))])]
5400 {
5401   operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
5402   operands[0] = adjust_address (operands[0], BLKmode, 0);
5403   operands[1] = adjust_address (operands[1], BLKmode, 0);
5404 })
5405
5406 (define_peephole2
5407   [(parallel
5408     [(set (match_operand:BLK 0 "memory_operand" "")
5409           (and:BLK (match_dup 0)
5410                    (match_operand:BLK 1 "memory_operand" "")))
5411      (use (match_operand 2 "const_int_operand" ""))
5412      (clobber (reg:CC 33))])
5413    (parallel
5414     [(set (match_operand:BLK 3 "memory_operand" "")
5415           (and:BLK (match_dup 3)
5416                    (match_operand:BLK 4 "memory_operand" "")))
5417      (use (match_operand 5 "const_int_operand" ""))
5418      (clobber (reg:CC 33))])]
5419   "s390_offset_p (operands[0], operands[3], operands[2])
5420    && s390_offset_p (operands[1], operands[4], operands[2])
5421    && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
5422   [(parallel
5423     [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
5424      (use (match_dup 8))
5425      (clobber (reg:CC 33))])]
5426   "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
5427    operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
5428    operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
5429
5430
5431 ;;
5432 ;;- Bit set (inclusive or) instructions.
5433 ;;
5434
5435 ;
5436 ; iordi3 instruction pattern(s).
5437 ;
5438
5439 (define_insn "*iordi3_cc"
5440   [(set (reg 33)
5441         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5442                          (match_operand:DI 2 "general_operand" "d,m"))
5443                  (const_int 0)))
5444    (set (match_operand:DI 0 "register_operand" "=d,d")
5445         (ior:DI (match_dup 1) (match_dup 2)))]
5446   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5447   "@
5448    ogr\t%0,%2
5449    og\t%0,%2"
5450   [(set_attr "op_type"  "RRE,RXY")])
5451
5452 (define_insn "*iordi3_cconly"
5453   [(set (reg 33)
5454         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5455                          (match_operand:DI 2 "general_operand" "d,m"))
5456                  (const_int 0)))
5457    (clobber (match_scratch:DI 0 "=d,d"))]
5458   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5459   "@
5460    ogr\t%0,%2
5461    og\t%0,%2"
5462   [(set_attr "op_type"  "RRE,RXY")])
5463
5464 (define_insn "*iordi3"
5465   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,AQ,Q")
5466         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0")
5467                 (match_operand:DI 2 "general_operand"
5468                                     "N0HD0,N1HD0,N2HD0,N3HD0,d,m,NxQD0,Q")))
5469    (clobber (reg:CC 33))]
5470   "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
5471   "@
5472    oihh\t%0,%i2
5473    oihl\t%0,%i2
5474    oilh\t%0,%i2
5475    oill\t%0,%i2
5476    ogr\t%0,%2
5477    og\t%0,%2
5478    #
5479    #"
5480   [(set_attr "op_type"  "RI,RI,RI,RI,RRE,RXY,SI,SS")])
5481
5482 (define_split
5483   [(set (match_operand:DI 0 "s_operand" "")
5484         (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
5485    (clobber (reg:CC 33))]
5486   "reload_completed"
5487   [(parallel
5488     [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
5489      (clobber (reg:CC 33))])]
5490   "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
5491
5492 (define_expand "iordi3"
5493   [(set (match_operand:DI 0 "nonimmediate_operand" "")
5494         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "")
5495                 (match_operand:DI 2 "general_operand" "")))
5496    (clobber (reg:CC 33))]
5497   "TARGET_64BIT"
5498   "s390_expand_logical_operator (IOR, DImode, operands); DONE;")
5499
5500 ;
5501 ; iorsi3 instruction pattern(s).
5502 ;
5503
5504 (define_insn "*iorsi3_cc"
5505   [(set (reg 33)
5506         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5507                          (match_operand:SI 2 "general_operand" "d,R,T"))
5508                  (const_int 0)))
5509    (set (match_operand:SI 0 "register_operand" "=d,d,d")
5510         (ior:SI (match_dup 1) (match_dup 2)))]
5511   "s390_match_ccmode(insn, CCTmode)"
5512   "@
5513    or\t%0,%2
5514    o\t%0,%2
5515    oy\t%0,%2"
5516   [(set_attr "op_type"  "RR,RX,RXY")])
5517
5518 (define_insn "*iorsi3_cconly"
5519   [(set (reg 33)
5520         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5521                          (match_operand:SI 2 "general_operand" "d,R,T"))
5522                  (const_int 0)))
5523    (clobber (match_scratch:SI 0 "=d,d,d"))]
5524   "s390_match_ccmode(insn, CCTmode)"
5525   "@
5526    or\t%0,%2
5527    o\t%0,%2
5528    oy\t%0,%2"
5529   [(set_attr "op_type"  "RR,RX,RXY")])
5530
5531 (define_insn "*iorsi3_zarch"
5532   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,AQ,Q")
5533         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0")
5534                 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,d,R,T,NxQS0,Q")))
5535    (clobber (reg:CC 33))]
5536   "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5537   "@
5538    oilh\t%0,%i2
5539    oill\t%0,%i2
5540    or\t%0,%2
5541    o\t%0,%2
5542    oy\t%0,%2
5543    #
5544    #"
5545   [(set_attr "op_type"  "RI,RI,RR,RX,RXY,SI,SS")])
5546
5547 (define_insn "*iorsi3_esa"
5548   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5549         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5550                 (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
5551    (clobber (reg:CC 33))]
5552   "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5553   "@
5554    or\t%0,%2
5555    o\t%0,%2
5556    #
5557    #"
5558   [(set_attr "op_type"  "RR,RX,SI,SS")])
5559
5560 (define_split
5561   [(set (match_operand:SI 0 "s_operand" "")
5562         (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
5563    (clobber (reg:CC 33))]
5564   "reload_completed"
5565   [(parallel
5566     [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
5567      (clobber (reg:CC 33))])]
5568   "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
5569
5570 (define_expand "iorsi3"
5571   [(set (match_operand:SI 0 "nonimmediate_operand" "")
5572         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "")
5573                 (match_operand:SI 2 "general_operand" "")))
5574    (clobber (reg:CC 33))]
5575   ""
5576   "s390_expand_logical_operator (IOR, SImode, operands); DONE;")
5577
5578 ;
5579 ; iorhi3 instruction pattern(s).
5580 ;
5581
5582 (define_insn "*iorhi3_zarch"
5583   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5584         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
5585                 (match_operand:HI 2 "general_operand" "d,n,NxQH0,Q")))
5586    (clobber (reg:CC 33))]
5587   "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5588   "@
5589    or\t%0,%2
5590    oill\t%0,%x2
5591    #
5592    #"
5593   [(set_attr "op_type"  "RR,RI,SI,SS")])
5594
5595 (define_insn "*iorhi3_esa"
5596   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
5597         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
5598                 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
5599    (clobber (reg:CC 33))]
5600   "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5601   "@
5602    or\t%0,%2
5603    #
5604    #"
5605   [(set_attr "op_type"  "RR,SI,SS")])
5606
5607 (define_split
5608   [(set (match_operand:HI 0 "s_operand" "")
5609         (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
5610    (clobber (reg:CC 33))]
5611   "reload_completed"
5612   [(parallel
5613     [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
5614      (clobber (reg:CC 33))])]
5615   "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
5616
5617 (define_expand "iorhi3"
5618   [(set (match_operand:HI 0 "nonimmediate_operand" "")
5619         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "")
5620                 (match_operand:HI 2 "general_operand" "")))
5621    (clobber (reg:CC 33))]
5622   ""
5623   "s390_expand_logical_operator (IOR, HImode, operands); DONE;")
5624
5625 ;
5626 ; iorqi3 instruction pattern(s).
5627 ;
5628
5629 (define_insn "*iorqi3_zarch"
5630   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
5631         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
5632                 (match_operand:QI 2 "general_operand" "d,n,n,n,Q")))
5633    (clobber (reg:CC 33))]
5634   "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5635   "@
5636    or\t%0,%2
5637    oill\t%0,%b2
5638    oi\t%S0,%b2
5639    oiy\t%S0,%b2
5640    #"
5641   [(set_attr "op_type"  "RR,RI,SI,SIY,SS")])
5642
5643 (define_insn "*iorqi3_esa"
5644   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
5645         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
5646                 (match_operand:QI 2 "general_operand" "d,n,Q")))
5647    (clobber (reg:CC 33))]
5648   "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5649   "@
5650    or\t%0,%2
5651    oi\t%S0,%b2
5652    #"
5653   [(set_attr "op_type"  "RR,SI,SS")])
5654
5655 (define_expand "iorqi3"
5656   [(set (match_operand:QI 0 "nonimmediate_operand" "")
5657         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "")
5658                 (match_operand:QI 2 "general_operand" "")))
5659    (clobber (reg:CC 33))]
5660   ""
5661   "s390_expand_logical_operator (IOR, QImode, operands); DONE;")
5662
5663 ;
5664 ; Block inclusive or (OC) patterns.
5665 ;
5666
5667 (define_insn "*oc"
5668   [(set (match_operand:BLK 0 "memory_operand" "=Q")
5669         (ior:BLK (match_dup 0)
5670                  (match_operand:BLK 1 "memory_operand" "Q")))
5671    (use (match_operand 2 "const_int_operand" "n"))
5672    (clobber (reg:CC 33))]
5673   "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
5674   "oc\t%O0(%2,%R0),%S1"
5675   [(set_attr "op_type" "SS")])
5676
5677 (define_split
5678   [(set (match_operand 0 "memory_operand" "")
5679         (ior (match_dup 0)
5680              (match_operand 1 "memory_operand" "")))
5681    (clobber (reg:CC 33))]
5682   "reload_completed
5683    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5684    && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
5685   [(parallel
5686     [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
5687      (use (match_dup 2))
5688      (clobber (reg:CC 33))])]
5689 {
5690   operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
5691   operands[0] = adjust_address (operands[0], BLKmode, 0);
5692   operands[1] = adjust_address (operands[1], BLKmode, 0);
5693 })
5694
5695 (define_peephole2
5696   [(parallel
5697     [(set (match_operand:BLK 0 "memory_operand" "")
5698           (ior:BLK (match_dup 0)
5699                    (match_operand:BLK 1 "memory_operand" "")))
5700      (use (match_operand 2 "const_int_operand" ""))
5701      (clobber (reg:CC 33))])
5702    (parallel
5703     [(set (match_operand:BLK 3 "memory_operand" "")
5704           (ior:BLK (match_dup 3)
5705                    (match_operand:BLK 4 "memory_operand" "")))
5706      (use (match_operand 5 "const_int_operand" ""))
5707      (clobber (reg:CC 33))])]
5708   "s390_offset_p (operands[0], operands[3], operands[2])
5709    && s390_offset_p (operands[1], operands[4], operands[2])
5710    && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
5711   [(parallel
5712     [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
5713      (use (match_dup 8))
5714      (clobber (reg:CC 33))])]
5715   "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
5716    operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
5717    operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
5718
5719
5720 ;;
5721 ;;- Xor instructions.
5722 ;;
5723
5724 ;
5725 ; xordi3 instruction pattern(s).
5726 ;
5727
5728 (define_insn "*xordi3_cc"
5729   [(set (reg 33)
5730         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5731                          (match_operand:DI 2 "general_operand" "d,m"))
5732                  (const_int 0)))
5733    (set (match_operand:DI 0 "register_operand" "=d,d")
5734         (xor:DI (match_dup 1) (match_dup 2)))]
5735   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5736   "@
5737    xgr\t%0,%2
5738    xg\t%0,%2"
5739   [(set_attr "op_type"  "RRE,RXY")])
5740
5741 (define_insn "*xordi3_cconly"
5742   [(set (reg 33)
5743         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5744                          (match_operand:DI 2 "general_operand" "d,m"))
5745                  (const_int 0)))
5746    (clobber (match_scratch:DI 0 "=d,d"))]
5747   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5748   "@
5749    xgr\t%0,%2
5750    xr\t%0,%2"
5751   [(set_attr "op_type"  "RRE,RXY")])
5752
5753 (define_insn "*xordi3"
5754   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5755         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
5756                 (match_operand:DI 2 "general_operand" "d,m,NxQD0,Q")))
5757    (clobber (reg:CC 33))]
5758   "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
5759   "@
5760    xgr\t%0,%2
5761    xg\t%0,%2
5762    #
5763    #"
5764   [(set_attr "op_type"  "RRE,RXY,SI,SS")])
5765
5766 (define_split
5767   [(set (match_operand:DI 0 "s_operand" "")
5768         (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
5769    (clobber (reg:CC 33))]
5770   "reload_completed"
5771   [(parallel
5772     [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
5773      (clobber (reg:CC 33))])]
5774   "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
5775
5776 (define_expand "xordi3"
5777   [(set (match_operand:DI 0 "nonimmediate_operand" "")
5778         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "")
5779                 (match_operand:DI 2 "general_operand" "")))
5780    (clobber (reg:CC 33))]
5781   "TARGET_64BIT"
5782   "s390_expand_logical_operator (XOR, DImode, operands); DONE;")
5783
5784 ;
5785 ; xorsi3 instruction pattern(s).
5786 ;
5787
5788 (define_insn "*xorsi3_cc"
5789   [(set (reg 33)
5790         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5791                          (match_operand:SI 2 "general_operand" "d,R,T"))
5792                  (const_int 0)))
5793    (set (match_operand:SI 0 "register_operand" "=d,d,d")
5794         (xor:SI (match_dup 1) (match_dup 2)))]
5795   "s390_match_ccmode(insn, CCTmode)"
5796   "@
5797    xr\t%0,%2
5798    x\t%0,%2
5799    xy\t%0,%2"
5800   [(set_attr "op_type"  "RR,RX,RXY")])
5801
5802 (define_insn "*xorsi3_cconly"
5803   [(set (reg 33)
5804         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5805                          (match_operand:SI 2 "general_operand" "d,R,T"))
5806                  (const_int 0)))
5807    (clobber (match_scratch:SI 0 "=d,d,d"))]
5808   "s390_match_ccmode(insn, CCTmode)"
5809   "@
5810    xr\t%0,%2
5811    x\t%0,%2
5812    xy\t%0,%2"
5813   [(set_attr "op_type"  "RR,RX,RXY")])
5814
5815 (define_insn "*xorsi3"
5816   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,AQ,Q")
5817         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0")
5818                 (match_operand:SI 2 "general_operand" "d,R,T,NxQS0,Q")))
5819    (clobber (reg:CC 33))]
5820   "s390_logical_operator_ok_p (operands)"
5821   "@
5822    xr\t%0,%2
5823    x\t%0,%2
5824    xy\t%0,%2
5825    #
5826    #"
5827   [(set_attr "op_type"  "RR,RX,RXY,SI,SS")])
5828
5829 (define_split
5830   [(set (match_operand:SI 0 "s_operand" "")
5831         (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
5832    (clobber (reg:CC 33))]
5833   "reload_completed"
5834   [(parallel
5835     [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
5836      (clobber (reg:CC 33))])]
5837   "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
5838
5839 (define_expand "xorsi3"
5840   [(set (match_operand:SI 0 "nonimmediate_operand" "")
5841         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "")
5842                 (match_operand:SI 2 "general_operand" "")))
5843    (clobber (reg:CC 33))]
5844   ""
5845   "s390_expand_logical_operator (XOR, SImode, operands); DONE;")
5846
5847 ;
5848 ; xorhi3 instruction pattern(s).
5849 ;
5850
5851 (define_insn "*xorhi3"
5852   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
5853         (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
5854                 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
5855    (clobber (reg:CC 33))]
5856   "s390_logical_operator_ok_p (operands)"
5857   "@
5858    xr\t%0,%2
5859    #
5860    #"
5861   [(set_attr "op_type"  "RR,SI,SS")])
5862
5863 (define_split
5864   [(set (match_operand:HI 0 "s_operand" "")
5865         (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
5866    (clobber (reg:CC 33))]
5867   "reload_completed"
5868   [(parallel
5869     [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
5870      (clobber (reg:CC 33))])]
5871   "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
5872
5873 (define_expand "xorhi3"
5874   [(set (match_operand:HI 0 "nonimmediate_operand" "")
5875         (xor:HI (match_operand:HI 1 "nonimmediate_operand" "")
5876                 (match_operand:HI 2 "general_operand" "")))
5877    (clobber (reg:CC 33))]
5878   ""
5879   "s390_expand_logical_operator (XOR, HImode, operands); DONE;")
5880
5881 ;
5882 ; xorqi3 instruction pattern(s).
5883 ;
5884
5885 (define_insn "*xorqi3"
5886   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,S,Q")
5887         (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0")
5888                 (match_operand:QI 2 "general_operand" "d,n,n,Q")))
5889    (clobber (reg:CC 33))]
5890   "s390_logical_operator_ok_p (operands)"
5891   "@
5892    xr\t%0,%2
5893    xi\t%S0,%b2
5894    xiy\t%S0,%b2
5895    #"
5896   [(set_attr "op_type"  "RR,SI,SIY,SS")])
5897
5898 (define_expand "xorqi3"
5899   [(set (match_operand:QI 0 "nonimmediate_operand" "")
5900         (xor:QI (match_operand:QI 1 "nonimmediate_operand" "")
5901                 (match_operand:QI 2 "general_operand" "")))
5902    (clobber (reg:CC 33))]
5903   ""
5904   "s390_expand_logical_operator (XOR, QImode, operands); DONE;")
5905
5906 ;
5907 ; Block exclusive or (XC) patterns.
5908 ;
5909
5910 (define_insn "*xc"
5911   [(set (match_operand:BLK 0 "memory_operand" "=Q")
5912         (xor:BLK (match_dup 0)
5913                  (match_operand:BLK 1 "memory_operand" "Q")))
5914    (use (match_operand 2 "const_int_operand" "n"))
5915    (clobber (reg:CC 33))]
5916   "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
5917   "xc\t%O0(%2,%R0),%S1"
5918   [(set_attr "op_type" "SS")])
5919
5920 (define_split
5921   [(set (match_operand 0 "memory_operand" "")
5922         (xor (match_dup 0)
5923              (match_operand 1 "memory_operand" "")))
5924    (clobber (reg:CC 33))]
5925   "reload_completed
5926    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5927    && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
5928   [(parallel
5929     [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
5930      (use (match_dup 2))
5931      (clobber (reg:CC 33))])]
5932 {
5933   operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
5934   operands[0] = adjust_address (operands[0], BLKmode, 0);
5935   operands[1] = adjust_address (operands[1], BLKmode, 0);
5936 })
5937
5938 (define_peephole2
5939   [(parallel
5940     [(set (match_operand:BLK 0 "memory_operand" "")
5941           (xor:BLK (match_dup 0)
5942                    (match_operand:BLK 1 "memory_operand" "")))
5943      (use (match_operand 2 "const_int_operand" ""))
5944      (clobber (reg:CC 33))])
5945    (parallel
5946     [(set (match_operand:BLK 3 "memory_operand" "")
5947           (xor:BLK (match_dup 3)
5948                    (match_operand:BLK 4 "memory_operand" "")))
5949      (use (match_operand 5 "const_int_operand" ""))
5950      (clobber (reg:CC 33))])]
5951   "s390_offset_p (operands[0], operands[3], operands[2])
5952    && s390_offset_p (operands[1], operands[4], operands[2])
5953    && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
5954   [(parallel
5955     [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
5956      (use (match_dup 8))
5957      (clobber (reg:CC 33))])]
5958   "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
5959    operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
5960    operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
5961
5962 ;
5963 ; Block xor (XC) patterns with src == dest.
5964 ;
5965
5966 (define_insn "*xc_zero"
5967   [(set (match_operand:BLK 0 "memory_operand" "=Q")
5968         (const_int 0))
5969    (use (match_operand 1 "const_int_operand" "n"))
5970    (clobber (reg:CC 33))]
5971   "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
5972   "xc\t%O0(%1,%R0),%S0"
5973   [(set_attr "op_type" "SS")])
5974
5975 (define_peephole2
5976   [(parallel
5977     [(set (match_operand:BLK 0 "memory_operand" "")
5978           (const_int 0))
5979      (use (match_operand 1 "const_int_operand" ""))
5980      (clobber (reg:CC 33))])
5981    (parallel
5982     [(set (match_operand:BLK 2 "memory_operand" "")
5983           (const_int 0))
5984      (use (match_operand 3 "const_int_operand" ""))
5985      (clobber (reg:CC 33))])]
5986   "s390_offset_p (operands[0], operands[2], operands[1])
5987    && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
5988   [(parallel
5989     [(set (match_dup 4) (const_int 0))
5990      (use (match_dup 5))
5991      (clobber (reg:CC 33))])]
5992   "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
5993    operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
5994
5995
5996 ;;
5997 ;;- Negate instructions.
5998 ;;
5999
6000 ;
6001 ; negdi2 instruction pattern(s).
6002 ;
6003
6004 (define_expand "negdi2"
6005   [(parallel
6006     [(set (match_operand:DI 0 "register_operand" "=d")
6007           (neg:DI (match_operand:DI 1 "register_operand" "d")))
6008      (clobber (reg:CC 33))])]
6009   ""
6010   "")
6011
6012 (define_insn "*negdi2_sign_cc"
6013   [(set (reg 33)
6014         (compare (neg:DI (ashiftrt:DI (ashift:DI (subreg:DI
6015                            (match_operand:SI 1 "register_operand" "d") 0)
6016                            (const_int 32)) (const_int 32)))
6017                  (const_int 0)))
6018    (set (match_operand:DI 0 "register_operand" "=d")
6019         (neg:DI (sign_extend:DI (match_dup 1))))]
6020   "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6021   "lcgfr\t%0,%1"
6022   [(set_attr "op_type"  "RRE")])
6023   
6024 (define_insn "*negdi2_sign"
6025   [(set (match_operand:DI 0 "register_operand" "=d")
6026         (neg:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
6027    (clobber (reg:CC 33))]
6028   "TARGET_64BIT"
6029   "lcgfr\t%0,%1"
6030   [(set_attr "op_type"  "RRE")])
6031
6032 (define_insn "*negdi2_cc"
6033   [(set (reg 33)
6034         (compare (neg:DI (match_operand:DI 1 "register_operand" "d"))
6035                  (const_int 0)))
6036    (set (match_operand:DI 0 "register_operand" "=d")
6037         (neg:DI (match_dup 1)))]
6038   "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6039   "lcgr\t%0,%1"
6040   [(set_attr "op_type"  "RRE")])
6041   
6042 (define_insn "*negdi2_cconly"
6043   [(set (reg 33)
6044         (compare (neg:DI (match_operand:DI 1 "register_operand" "d"))
6045                  (const_int 0)))
6046    (clobber (match_scratch:DI 0 "=d"))]
6047   "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6048   "lcgr\t%0,%1"
6049   [(set_attr "op_type"  "RRE")])
6050   
6051 (define_insn "*negdi2_64"
6052   [(set (match_operand:DI 0 "register_operand" "=d")
6053         (neg:DI (match_operand:DI 1 "register_operand" "d")))
6054    (clobber (reg:CC 33))]
6055   "TARGET_64BIT"
6056   "lcgr\t%0,%1"
6057   [(set_attr "op_type"  "RRE")])
6058
6059 (define_insn_and_split "*negdi2_31"
6060   [(set (match_operand:DI 0 "register_operand" "=d")
6061         (neg:DI (match_operand:DI 1 "register_operand" "d")))
6062    (clobber (reg:CC 33))]
6063   "!TARGET_64BIT"
6064   "#"
6065   "&& reload_completed"
6066   [(parallel
6067     [(set (match_dup 2) (neg:SI (match_dup 3)))
6068      (clobber (reg:CC 33))])
6069    (parallel
6070     [(set (reg:CCAP 33)
6071           (compare:CCAP (neg:SI (match_dup 5)) (const_int 0)))
6072      (set (match_dup 4) (neg:SI (match_dup 5)))])
6073    (set (pc)
6074         (if_then_else (ne (reg:CCAP 33) (const_int 0))
6075                       (pc)
6076                       (label_ref (match_dup 6))))
6077    (parallel
6078     [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
6079      (clobber (reg:CC 33))])
6080    (match_dup 6)]
6081   "operands[2] = operand_subword (operands[0], 0, 0, DImode);
6082    operands[3] = operand_subword (operands[1], 0, 0, DImode);
6083    operands[4] = operand_subword (operands[0], 1, 0, DImode);
6084    operands[5] = operand_subword (operands[1], 1, 0, DImode);
6085    operands[6] = gen_label_rtx ();")
6086
6087 ;
6088 ; negsi2 instruction pattern(s).
6089 ;
6090
6091 (define_insn "*negsi2_cc"
6092   [(set (reg 33)
6093         (compare (neg:SI (match_operand:SI 1 "register_operand" "d"))
6094                  (const_int 0)))
6095    (set (match_operand:SI 0 "register_operand" "=d")
6096         (neg:SI (match_dup 1)))]
6097   "s390_match_ccmode (insn, CCAmode)"
6098   "lcr\t%0,%1"
6099   [(set_attr "op_type"  "RR")])
6100   
6101 (define_insn "*negsi2_cconly"
6102   [(set (reg 33)
6103         (compare (neg:SI (match_operand:SI 1 "register_operand" "d"))
6104                  (const_int 0)))
6105    (clobber (match_scratch:SI 0 "=d"))]
6106   "s390_match_ccmode (insn, CCAmode)"
6107   "lcr\t%0,%1"
6108   [(set_attr "op_type"  "RR")])
6109   
6110 (define_insn "negsi2"
6111   [(set (match_operand:SI 0 "register_operand" "=d")
6112         (neg:SI (match_operand:SI 1 "register_operand" "d")))
6113    (clobber (reg:CC 33))]
6114   ""
6115   "lcr\t%0,%1"
6116   [(set_attr "op_type"  "RR")])
6117
6118 ;
6119 ; negdf2 instruction pattern(s).
6120 ;
6121
6122 (define_expand "negdf2"
6123   [(parallel
6124     [(set (match_operand:DF 0 "register_operand" "=f")
6125           (neg:DF (match_operand:DF 1 "register_operand" "f")))
6126      (clobber (reg:CC 33))])]
6127   "TARGET_HARD_FLOAT"
6128   "")
6129
6130 (define_insn "*negdf2_cc"
6131   [(set (reg 33)
6132         (compare (neg:DF (match_operand:DF 1 "register_operand" "f"))
6133                  (match_operand:DF 2 "const0_operand" "")))
6134    (set (match_operand:DF 0 "register_operand" "=f")
6135         (neg:DF (match_dup 1)))]
6136   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6137   "lcdbr\t%0,%1"
6138   [(set_attr "op_type"  "RRE")
6139    (set_attr "type"     "fsimpd")])
6140   
6141 (define_insn "*negdf2_cconly"
6142   [(set (reg 33)
6143         (compare (neg:DF (match_operand:DF 1 "register_operand" "f"))
6144                  (match_operand:DF 2 "const0_operand" "")))
6145    (clobber (match_scratch:DF 0 "=f"))]
6146   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6147   "lcdbr\t%0,%1"
6148   [(set_attr "op_type"  "RRE")
6149    (set_attr "type"     "fsimpd")])
6150   
6151 (define_insn "*negdf2"
6152   [(set (match_operand:DF 0 "register_operand" "=f")
6153         (neg:DF (match_operand:DF 1 "register_operand" "f")))
6154    (clobber (reg:CC 33))]
6155   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6156   "lcdbr\t%0,%1"
6157   [(set_attr "op_type"  "RRE")
6158    (set_attr "type"     "fsimpd")])
6159
6160 (define_insn "*negdf2_ibm"
6161   [(set (match_operand:DF 0 "register_operand" "=f")
6162         (neg:DF (match_operand:DF 1 "register_operand" "f")))
6163    (clobber (reg:CC 33))]
6164   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
6165   "lcdr\t%0,%1"
6166   [(set_attr "op_type"  "RR")
6167    (set_attr "type"     "fsimpd")])
6168
6169 ;
6170 ; negsf2 instruction pattern(s).
6171 ;
6172
6173 (define_expand "negsf2"
6174   [(parallel
6175     [(set (match_operand:SF 0 "register_operand" "=f")
6176           (neg:SF (match_operand:SF 1 "register_operand" "f")))
6177      (clobber (reg:CC 33))])]
6178   "TARGET_HARD_FLOAT"
6179   "")
6180
6181 (define_insn "*negsf2_cc"
6182   [(set (reg 33)
6183         (compare (neg:SF (match_operand:SF 1 "register_operand" "f"))
6184                  (match_operand:SF 2 "const0_operand" "")))
6185    (set (match_operand:SF 0 "register_operand" "=f")
6186         (neg:SF (match_dup 1)))]
6187   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6188   "lcebr\t%0,%1"
6189   [(set_attr "op_type"  "RRE")
6190    (set_attr "type"     "fsimps")])
6191   
6192 (define_insn "*negsf2_cconly"
6193   [(set (reg 33)
6194         (compare (neg:SF (match_operand:SF 1 "register_operand" "f"))
6195                  (match_operand:SF 2 "const0_operand" "")))
6196    (clobber (match_scratch:SF 0 "=f"))]
6197   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6198   "lcebr\t%0,%1"
6199   [(set_attr "op_type"  "RRE")
6200    (set_attr "type"     "fsimps")])
6201   
6202 (define_insn "*negsf2"
6203   [(set (match_operand:SF 0 "register_operand" "=f")
6204         (neg:SF (match_operand:SF 1 "register_operand" "f")))
6205    (clobber (reg:CC 33))]
6206   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6207   "lcebr\t%0,%1"
6208   [(set_attr "op_type"  "RRE")
6209    (set_attr "type"     "fsimps")])
6210
6211 (define_insn "*negsf2"
6212   [(set (match_operand:SF 0 "register_operand" "=f")
6213         (neg:SF (match_operand:SF 1 "register_operand" "f")))
6214    (clobber (reg:CC 33))]
6215   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
6216   "lcer\t%0,%1"
6217   [(set_attr "op_type"  "RR")
6218    (set_attr "type"     "fsimps")])
6219
6220
6221 ;;
6222 ;;- Absolute value instructions.
6223 ;;
6224
6225 ;
6226 ; absdi2 instruction pattern(s).
6227 ;
6228
6229 (define_insn "*absdi2_sign_cc"
6230   [(set (reg 33)
6231         (compare (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
6232                            (match_operand:SI 1 "register_operand" "d") 0)
6233                            (const_int 32)) (const_int 32)))
6234                  (const_int 0)))
6235    (set (match_operand:DI 0 "register_operand" "=d")
6236         (abs:DI (sign_extend:DI (match_dup 1))))]
6237   "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6238   "lpgfr\t%0,%1"
6239   [(set_attr "op_type"  "RRE")])
6240
6241 (define_insn "*absdi2_sign"
6242   [(set (match_operand:DI 0 "register_operand" "=d")
6243         (abs:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
6244    (clobber (reg:CC 33))]
6245   "TARGET_64BIT"
6246   "lpgfr\t%0,%1"
6247   [(set_attr "op_type"  "RRE")])
6248
6249 (define_insn "*absdi2_cc"
6250   [(set (reg 33)
6251         (compare (abs:DI (match_operand:DI 1 "register_operand" "d"))
6252                  (const_int 0)))
6253    (set (match_operand:DI 0 "register_operand" "=d")
6254         (abs:DI (match_dup 1)))]
6255   "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6256   "lpgr\t%0,%1"
6257   [(set_attr "op_type"  "RRE")])
6258   
6259 (define_insn "*absdi2_cconly"
6260   [(set (reg 33)
6261         (compare (abs:DI (match_operand:DI 1 "register_operand" "d"))
6262                  (const_int 0)))
6263    (clobber (match_scratch:DI 0 "=d"))]
6264   "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6265   "lpgr\t%0,%1"
6266   [(set_attr "op_type"  "RRE")])
6267   
6268 (define_insn "absdi2"
6269   [(set (match_operand:DI 0 "register_operand" "=d")
6270         (abs:DI (match_operand:DI 1 "register_operand" "d")))
6271    (clobber (reg:CC 33))]
6272   "TARGET_64BIT"
6273   "lpgr\t%0,%1"
6274   [(set_attr "op_type"  "RRE")])
6275
6276 ;
6277 ; abssi2 instruction pattern(s).
6278 ;
6279
6280 (define_insn "*abssi2_cc"
6281   [(set (reg 33)
6282         (compare (abs:SI (match_operand:SI 1 "register_operand" "d"))
6283                  (const_int 0)))
6284    (set (match_operand:SI 0 "register_operand" "=d")
6285         (abs:SI (match_dup 1)))]
6286   "s390_match_ccmode (insn, CCAmode)"
6287   "lpr\t%0,%1"
6288   [(set_attr "op_type"  "RR")])
6289   
6290 (define_insn "*abssi2_cconly"
6291   [(set (reg 33)
6292         (compare (abs:SI (match_operand:SI 1 "register_operand" "d"))
6293                  (const_int 0)))
6294    (clobber (match_scratch:SI 0 "=d"))]
6295   "s390_match_ccmode (insn, CCAmode)"
6296   "lpr\t%0,%1"
6297   [(set_attr "op_type"  "RR")])
6298   
6299 (define_insn "abssi2"
6300   [(set (match_operand:SI 0 "register_operand" "=d")
6301         (abs:SI (match_operand:SI 1 "register_operand" "d")))
6302    (clobber (reg:CC 33))]
6303   ""
6304   "lpr\t%0,%1"
6305   [(set_attr "op_type"  "RR")])
6306
6307 ;
6308 ; absdf2 instruction pattern(s).
6309 ;
6310
6311 (define_expand "absdf2"
6312   [(parallel
6313     [(set (match_operand:DF 0 "register_operand" "=f")
6314           (abs:DF (match_operand:DF 1 "register_operand" "f")))
6315      (clobber (reg:CC 33))])]
6316   "TARGET_HARD_FLOAT"
6317   "")
6318
6319 (define_insn "*absdf2_cc"
6320   [(set (reg 33)
6321         (compare (abs:DF (match_operand:DF 1 "register_operand" "f"))
6322                  (match_operand:DF 2 "const0_operand" "")))
6323    (set (match_operand:DF 0 "register_operand" "=f")
6324         (abs:DF (match_dup 1)))]
6325   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6326   "lpdbr\t%0,%1"
6327   [(set_attr "op_type"  "RRE")
6328    (set_attr "type"     "fsimpd")])
6329   
6330 (define_insn "*absdf2_cconly"
6331   [(set (reg 33)
6332         (compare (abs:DF (match_operand:DF 1 "register_operand" "f"))
6333                  (match_operand:DF 2 "const0_operand" "")))
6334    (clobber (match_scratch:DF 0 "=f"))]
6335   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6336   "lpdbr\t%0,%1"
6337   [(set_attr "op_type"  "RRE")
6338    (set_attr "type"     "fsimpd")])
6339   
6340 (define_insn "*absdf2"
6341   [(set (match_operand:DF 0 "register_operand" "=f")
6342         (abs:DF (match_operand:DF 1 "register_operand" "f")))
6343    (clobber (reg:CC 33))]
6344   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6345   "lpdbr\t%0,%1"
6346   [(set_attr "op_type"  "RRE")
6347    (set_attr "type"     "fsimpd")])
6348
6349 (define_insn "*absdf2_ibm"
6350   [(set (match_operand:DF 0 "register_operand" "=f")
6351         (abs:DF (match_operand:DF 1 "register_operand" "f")))
6352    (clobber (reg:CC 33))]
6353   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
6354   "lpdr\t%0,%1"
6355   [(set_attr "op_type"  "RR")
6356    (set_attr "type"     "fsimpd")])
6357
6358 ;
6359 ; abssf2 instruction pattern(s).
6360 ;
6361
6362 (define_expand "abssf2"
6363   [(parallel
6364     [(set (match_operand:SF 0 "register_operand" "=f")
6365           (abs:SF (match_operand:SF 1 "register_operand" "f")))
6366      (clobber (reg:CC 33))])]
6367   "TARGET_HARD_FLOAT"
6368   "")
6369
6370 (define_insn "*abssf2_cc"
6371   [(set (reg 33)
6372         (compare (abs:SF (match_operand:SF 1 "register_operand" "f"))
6373                  (match_operand:SF 2 "const0_operand" "")))
6374    (set (match_operand:SF 0 "register_operand" "=f")
6375         (abs:SF (match_dup 1)))]
6376   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6377   "lpebr\t%0,%1"
6378   [(set_attr "op_type"  "RRE")
6379    (set_attr "type"     "fsimps")])
6380   
6381 (define_insn "*abssf2_cconly"
6382   [(set (reg 33)
6383         (compare (abs:SF (match_operand:SF 1 "register_operand" "f"))
6384                  (match_operand:SF 2 "const0_operand" "")))
6385    (clobber (match_scratch:SF 0 "=f"))]
6386   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6387   "lpebr\t%0,%1"
6388   [(set_attr "op_type"  "RRE")
6389    (set_attr "type"     "fsimps")])
6390   
6391 (define_insn "*abssf2"
6392   [(set (match_operand:SF 0 "register_operand" "=f")
6393         (abs:SF (match_operand:SF 1 "register_operand" "f")))
6394    (clobber (reg:CC 33))]
6395   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6396   "lpebr\t%0,%1"
6397   [(set_attr "op_type"  "RRE")
6398    (set_attr "type"     "fsimps")])
6399
6400 (define_insn "*abssf2_ibm"
6401   [(set (match_operand:SF 0 "register_operand" "=f")
6402         (abs:SF (match_operand:SF 1 "register_operand" "f")))
6403    (clobber (reg:CC 33))]
6404   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
6405   "lper\t%0,%1"
6406   [(set_attr "op_type"  "RR")
6407    (set_attr "type"     "fsimps")])
6408
6409 ;;
6410 ;;- Negated absolute value instructions
6411 ;;
6412
6413 ;
6414 ; Integer
6415 ;
6416
6417 (define_insn "*negabsdi2_sign_cc"
6418   [(set (reg 33)
6419         (compare (neg:DI (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
6420                            (match_operand:SI 1 "register_operand" "d") 0)
6421                            (const_int 32)) (const_int 32))))
6422                  (const_int 0)))
6423    (set (match_operand:DI 0 "register_operand" "=d")
6424         (neg:DI (abs:DI (sign_extend:DI (match_dup 1)))))]
6425   "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6426   "lngfr\t%0,%1"
6427   [(set_attr "op_type"  "RRE")])
6428  
6429 (define_insn "*negabsdi2_sign"
6430   [(set (match_operand:DI 0 "register_operand" "=d")
6431         (neg:DI (abs:DI (sign_extend:DI
6432                           (match_operand:SI 1 "register_operand" "d")))))
6433    (clobber (reg:CC 33))]
6434   "TARGET_64BIT"
6435   "lngfr\t%0,%1"
6436   [(set_attr "op_type" "RRE")])
6437
6438 (define_insn "*negabsdi2_cc"
6439   [(set (reg 33)
6440         (compare (neg:DI (abs:DI (match_operand:DI 1 "register_operand" "d")))
6441                  (const_int 0)))
6442    (set (match_operand:DI 0 "register_operand" "=d")
6443         (neg:DI (abs:DI (match_dup 1))))]
6444   "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6445   "lngr\t%0,%1"
6446   [(set_attr "op_type"  "RRE")])
6447   
6448 (define_insn "*negabsdi2_cconly"
6449   [(set (reg 33)
6450         (compare (neg:DI (abs:DI (match_operand:DI 1 "register_operand" "d")))
6451                  (const_int 0)))
6452    (clobber (match_scratch:DI 0 "=d"))]
6453   "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6454   "lngr\t%0,%1"
6455   [(set_attr "op_type"  "RRE")])
6456   
6457 (define_insn "*negabsdi2"
6458   [(set (match_operand:DI 0 "register_operand" "=d")
6459         (neg:DI (abs:DI (match_operand:DI 1 "register_operand" "d"))))
6460    (clobber (reg:CC 33))]
6461   "TARGET_64BIT"
6462   "lngr\t%0,%1"
6463   [(set_attr "op_type" "RRE")])
6464
6465 (define_insn "*negabssi2_cc"
6466   [(set (reg 33)
6467         (compare (neg:SI (abs:SI (match_operand:SI 1 "register_operand" "d")))
6468                  (const_int 0)))
6469    (set (match_operand:SI 0 "register_operand" "=d")
6470         (neg:SI (abs:SI (match_dup 1))))]
6471   "s390_match_ccmode (insn, CCAmode)"
6472   "lnr\t%0,%1"
6473   [(set_attr "op_type"  "RR")])
6474   
6475 (define_insn "*negabssi2_cconly"
6476   [(set (reg 33)
6477         (compare (neg:SI (abs:SI (match_operand:SI 1 "register_operand" "d")))
6478                  (const_int 0)))
6479    (clobber (match_scratch:SI 0 "=d"))]
6480   "s390_match_ccmode (insn, CCAmode)"
6481   "lnr\t%0,%1"
6482   [(set_attr "op_type"  "RR")])
6483   
6484 (define_insn "*negabssi2"
6485   [(set (match_operand:SI 0 "register_operand" "=d")
6486         (neg:SI (abs:SI (match_operand:SI 1 "register_operand" "d"))))
6487    (clobber (reg:CC 33))]
6488   ""
6489   "lnr\t%0,%1"
6490   [(set_attr "op_type" "RR")])
6491
6492 ;
6493 ; Floating point
6494 ;
6495
6496 (define_insn "*negabsdf2_cc"
6497   [(set (reg 33)
6498         (compare (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f")))
6499                  (match_operand:DF 2 "const0_operand" "")))
6500    (set (match_operand:DF 0 "register_operand" "=f")
6501         (neg:DF (abs:DF (match_dup 1))))]
6502   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6503   "lndbr\t%0,%1"
6504   [(set_attr "op_type"  "RRE")
6505    (set_attr "type"     "fsimpd")])
6506   
6507 (define_insn "*negabsdf2_cconly"
6508   [(set (reg 33)
6509         (compare (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f")))
6510                  (match_operand:DF 2 "const0_operand" "")))
6511    (clobber (match_scratch:DF 0 "=f"))]
6512   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6513   "lndbr\t%0,%1"
6514   [(set_attr "op_type"  "RRE")
6515    (set_attr "type"     "fsimpd")])
6516   
6517 (define_insn "*negabsdf2"
6518   [(set (match_operand:DF 0 "register_operand" "=f")
6519         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6520    (clobber (reg:CC 33))]
6521   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6522   "lndbr\t%0,%1"
6523   [(set_attr "op_type"  "RRE")
6524    (set_attr "type"     "fsimpd")])
6525
6526 (define_insn "*negabssf2_cc"
6527   [(set (reg 33)
6528         (compare (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f")))
6529                  (match_operand:SF 2 "const0_operand" "")))
6530    (set (match_operand:SF 0 "register_operand" "=f")
6531         (neg:SF (abs:SF (match_dup 1))))]
6532   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6533   "lnebr\t%0,%1"
6534   [(set_attr "op_type"  "RRE")
6535    (set_attr "type"     "fsimps")])
6536   
6537 (define_insn "*negabssf2_cconly"
6538   [(set (reg 33)
6539         (compare (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f")))
6540                  (match_operand:SF 2 "const0_operand" "")))
6541    (clobber (match_scratch:SF 0 "=f"))]
6542   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6543   "lnebr\t%0,%1"
6544   [(set_attr "op_type"  "RRE")
6545    (set_attr "type"     "fsimps")])
6546   
6547 (define_insn "*negabssf2"
6548   [(set (match_operand:SF 0 "register_operand" "=f")
6549         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6550    (clobber (reg:CC 33))]
6551   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6552   "lnebr\t%0,%1"
6553   [(set_attr "op_type"  "RRE")
6554    (set_attr "type"     "fsimps")])
6555
6556 ;;
6557 ;;- Square root instructions.
6558 ;;
6559
6560 ;
6561 ; sqrtdf2 instruction pattern(s).
6562 ;
6563
6564 (define_insn "sqrtdf2"
6565   [(set (match_operand:DF 0 "register_operand" "=f,f")
6566         (sqrt:DF (match_operand:DF 1 "general_operand" "f,R")))]
6567   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6568   "@
6569    sqdbr\t%0,%1
6570    sqdb\t%0,%1"
6571   [(set_attr "op_type" "RRE,RXE")
6572    (set_attr "type" "fsqrtd")])
6573
6574 ;
6575 ; sqrtsf2 instruction pattern(s).
6576 ;
6577
6578 (define_insn "sqrtsf2"
6579   [(set (match_operand:SF 0 "register_operand" "=f,f")
6580         (sqrt:SF (match_operand:SF 1 "general_operand" "f,R")))]
6581   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6582   "@
6583    sqebr\t%0,%1
6584    sqeb\t%0,%1"
6585   [(set_attr "op_type" "RRE,RXE")
6586    (set_attr "type" "fsqrts")])
6587
6588 ;;
6589 ;;- One complement instructions.
6590 ;;
6591
6592 ;
6593 ; one_cmpl(di|si|hi|qi)2 instruction pattern(s).
6594 ;
6595
6596 (define_expand "one_cmpl<mode>2"
6597   [(parallel
6598     [(set (match_operand:INT 0 "register_operand" "")
6599           (xor:INT (match_operand:INT 1 "register_operand" "")
6600                    (const_int -1)))
6601      (clobber (reg:CC 33))])]
6602   ""
6603   "")
6604
6605
6606 ;;
6607 ;;- Rotate instructions.
6608 ;;
6609
6610 ;
6611 ; rotldi3 instruction pattern(s).
6612 ;
6613
6614 (define_insn "rotldi3"
6615   [(set (match_operand:DI 0 "register_operand" "=d")
6616         (rotate:DI (match_operand:DI 1 "register_operand" "d")
6617                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6618   "TARGET_64BIT"
6619   "rllg\t%0,%1,%Y2"
6620   [(set_attr "op_type"  "RSE")
6621    (set_attr "atype"    "reg")])
6622
6623 ;
6624 ; rotlsi3 instruction pattern(s).
6625 ;
6626
6627 (define_insn "rotlsi3"
6628   [(set (match_operand:SI 0 "register_operand" "=d")
6629         (rotate:SI (match_operand:SI 1 "register_operand" "d")
6630                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6631   "TARGET_CPU_ZARCH"
6632   "rll\t%0,%1,%Y2"
6633   [(set_attr "op_type"  "RSE")
6634    (set_attr "atype"    "reg")])
6635
6636
6637 ;;
6638 ;;- Arithmetic shift instructions.
6639 ;;
6640
6641 ;
6642 ; ashldi3 instruction pattern(s).
6643 ;
6644
6645 (define_expand "ashldi3"
6646   [(set (match_operand:DI 0 "register_operand" "")
6647         (ashift:DI (match_operand:DI 1 "register_operand" "")
6648                    (match_operand:SI 2 "shift_count_operand" "")))]
6649   ""
6650   "")
6651
6652 (define_insn "*ashldi3_31"
6653   [(set (match_operand:DI 0 "register_operand" "=d")
6654         (ashift:DI (match_operand:DI 1 "register_operand" "0")
6655                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6656   "!TARGET_64BIT"
6657   "sldl\t%0,%Y2"
6658   [(set_attr "op_type"  "RS")
6659    (set_attr "atype"    "reg")])
6660
6661 (define_insn "*ashldi3_64"
6662   [(set (match_operand:DI 0 "register_operand" "=d")
6663         (ashift:DI (match_operand:DI 1 "register_operand" "d")
6664                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6665   "TARGET_64BIT"
6666   "sllg\t%0,%1,%Y2"
6667   [(set_attr "op_type"  "RSE")
6668    (set_attr "atype"    "reg")])
6669
6670 ;
6671 ; ashrdi3 instruction pattern(s).
6672 ;
6673
6674 (define_expand "ashrdi3"
6675   [(parallel
6676     [(set (match_operand:DI 0 "register_operand" "")
6677           (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6678                        (match_operand:SI 2 "shift_count_operand" "")))
6679      (clobber (reg:CC 33))])]
6680   ""
6681   "")
6682
6683 (define_insn "*ashrdi3_cc_31"
6684   [(set (reg 33)
6685         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6686                               (match_operand:SI 2 "shift_count_operand" "Y"))
6687                  (const_int 0)))
6688    (set (match_operand:DI 0 "register_operand" "=d")
6689         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6690   "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
6691   "srda\t%0,%Y2"
6692   [(set_attr "op_type"  "RS")
6693    (set_attr "atype"    "reg")])
6694
6695 (define_insn "*ashrdi3_cconly_31"
6696   [(set (reg 33)
6697         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6698                               (match_operand:SI 2 "shift_count_operand" "Y"))
6699                  (const_int 0)))
6700    (clobber (match_scratch:DI 0 "=d"))]
6701   "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
6702   "srda\t%0,%Y2"
6703   [(set_attr "op_type"  "RS")
6704    (set_attr "atype"    "reg")])
6705
6706 (define_insn "*ashrdi3_31"
6707   [(set (match_operand:DI 0 "register_operand" "=d")
6708         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6709                      (match_operand:SI 2 "shift_count_operand" "Y")))
6710    (clobber (reg:CC 33))]
6711   "!TARGET_64BIT"
6712   "srda\t%0,%Y2"
6713   [(set_attr "op_type"  "RS")
6714    (set_attr "atype"    "reg")])
6715
6716 (define_insn "*ashrdi3_cc_64"
6717   [(set (reg 33)
6718         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6719                               (match_operand:SI 2 "shift_count_operand" "Y"))
6720                  (const_int 0)))
6721    (set (match_operand:DI 0 "register_operand" "=d")
6722         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6723   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
6724   "srag\t%0,%1,%Y2"
6725   [(set_attr "op_type"  "RSE")
6726    (set_attr "atype"    "reg")])
6727
6728 (define_insn "*ashrdi3_cconly_64"
6729   [(set (reg 33)
6730         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6731                               (match_operand:SI 2 "shift_count_operand" "Y"))
6732                  (const_int 0)))
6733    (clobber (match_scratch:DI 0 "=d"))]
6734   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
6735   "srag\t%0,%1,%Y2"
6736   [(set_attr "op_type"  "RSE")
6737    (set_attr "atype"    "reg")])
6738
6739 (define_insn "*ashrdi3_64"
6740   [(set (match_operand:DI 0 "register_operand" "=d")
6741         (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6742                      (match_operand:SI 2 "shift_count_operand" "Y")))
6743    (clobber (reg:CC 33))]
6744   "TARGET_64BIT"
6745   "srag\t%0,%1,%Y2"
6746   [(set_attr "op_type"  "RSE")
6747    (set_attr "atype"    "reg")])
6748
6749
6750 ;
6751 ; ashlsi3 instruction pattern(s).
6752 ;
6753
6754 (define_insn "ashlsi3"
6755   [(set (match_operand:SI 0 "register_operand" "=d")
6756         (ashift:SI (match_operand:SI 1 "register_operand" "0")
6757                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6758   ""
6759   "sll\t%0,%Y2"
6760   [(set_attr "op_type"  "RS")
6761    (set_attr "atype"    "reg")])
6762
6763 ;
6764 ; ashrsi3 instruction pattern(s).
6765 ;
6766
6767 (define_insn "*ashrsi3_cc"
6768   [(set (reg 33)
6769         (compare (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6770                               (match_operand:SI 2 "shift_count_operand" "Y"))
6771                  (const_int 0)))
6772    (set (match_operand:SI 0 "register_operand" "=d")
6773         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
6774   "s390_match_ccmode(insn, CCSmode)"
6775   "sra\t%0,%Y2"
6776   [(set_attr "op_type"  "RS")
6777    (set_attr "atype"    "reg")])
6778
6779
6780 (define_insn "*ashrsi3_cconly"
6781   [(set (reg 33)
6782         (compare (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6783                               (match_operand:SI 2 "shift_count_operand" "Y"))
6784                  (const_int 0)))
6785    (clobber (match_scratch:SI 0 "=d"))]
6786   "s390_match_ccmode(insn, CCSmode)"
6787   "sra\t%0,%Y2"
6788   [(set_attr "op_type"  "RS")
6789    (set_attr "atype"    "reg")])
6790
6791 (define_insn "ashrsi3"
6792   [(set (match_operand:SI 0 "register_operand" "=d")
6793         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6794                      (match_operand:SI 2 "shift_count_operand" "Y")))
6795    (clobber (reg:CC 33))]
6796   ""
6797   "sra\t%0,%Y2"
6798   [(set_attr "op_type"  "RS")
6799    (set_attr "atype"    "reg")])
6800
6801
6802 ;;
6803 ;;- logical shift instructions.
6804 ;;
6805
6806 ;
6807 ; lshrdi3 instruction pattern(s).
6808 ;
6809
6810 (define_expand "lshrdi3"
6811   [(set (match_operand:DI 0 "register_operand" "")
6812         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
6813                      (match_operand:SI 2 "shift_count_operand" "")))]
6814   ""
6815   "")
6816
6817 (define_insn "*lshrdi3_31"
6818   [(set (match_operand:DI 0 "register_operand" "=d")
6819         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
6820                      (match_operand:SI 2 "shift_count_operand" "Y")))]
6821   "!TARGET_64BIT"
6822   "srdl\t%0,%Y2"
6823    [(set_attr "op_type"  "RS")
6824     (set_attr "atype"    "reg")])
6825
6826 (define_insn "*lshrdi3_64"
6827   [(set (match_operand:DI 0 "register_operand" "=d")
6828         (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6829                      (match_operand:SI 2 "shift_count_operand" "Y")))]
6830   "TARGET_64BIT"
6831   "srlg\t%0,%1,%Y2"
6832   [(set_attr "op_type"  "RSE")
6833    (set_attr "atype"    "reg")])
6834
6835 ;
6836 ; lshrsi3 instruction pattern(s).
6837 ;
6838
6839 (define_insn "lshrsi3"
6840   [(set (match_operand:SI 0 "register_operand" "=d")
6841         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
6842                      (match_operand:SI 2 "shift_count_operand" "Y")))]
6843   ""
6844   "srl\t%0,%Y2"
6845   [(set_attr "op_type"  "RS")
6846    (set_attr "atype"    "reg")])
6847
6848
6849 ;;
6850 ;; Branch instruction patterns.
6851 ;;
6852
6853 (define_expand "b<code>"
6854   [(set (pc)
6855         (if_then_else (COMPARE (match_operand 0 "" "")
6856                                (const_int 0))
6857                       (match_dup 0)
6858                       (pc)))]
6859   ""
6860   "s390_emit_jump (operands[0],
6861     s390_emit_compare (<CODE>, s390_compare_op0, s390_compare_op1)); DONE;")
6862
6863
6864 ;;
6865 ;;- Conditional jump instructions.
6866 ;;
6867
6868 (define_insn "*cjump_64"
6869   [(set (pc)
6870         (if_then_else
6871           (match_operator 1 "s390_comparison" [(reg 33) (const_int 0)])
6872           (label_ref (match_operand 0 "" ""))
6873           (pc)))]
6874   "TARGET_CPU_ZARCH"
6875 {
6876   if (get_attr_length (insn) == 4)
6877     return "j%C1\t%l0";
6878   else
6879     return "jg%C1\t%l0";
6880 }
6881   [(set_attr "op_type" "RI")
6882    (set_attr "type"    "branch")
6883    (set (attr "length")
6884         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6885                       (const_int 4) (const_int 6)))])
6886
6887 (define_insn "*cjump_31"
6888   [(set (pc)
6889         (if_then_else
6890           (match_operator 1 "s390_comparison" [(reg 33) (const_int 0)])
6891           (label_ref (match_operand 0 "" ""))
6892           (pc)))]
6893   "!TARGET_CPU_ZARCH"
6894 {
6895   if (get_attr_length (insn) == 4)
6896     return "j%C1\t%l0";
6897   else
6898     abort ();
6899 }
6900   [(set_attr "op_type" "RI")
6901    (set_attr "type"    "branch")
6902    (set (attr "length")
6903         (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
6904           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6905                         (const_int 4) (const_int 6))
6906           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6907                         (const_int 4) (const_int 8))))])
6908
6909 (define_insn "*cjump_long"
6910   [(set (pc)
6911         (if_then_else
6912           (match_operator 1 "s390_comparison" [(reg 33) (const_int 0)])
6913           (match_operand 0 "address_operand" "U")
6914           (pc)))]
6915   ""
6916 {
6917   if (get_attr_op_type (insn) == OP_TYPE_RR)
6918     return "b%C1r\t%0";
6919   else
6920     return "b%C1\t%a0";
6921 }
6922   [(set (attr "op_type")
6923         (if_then_else (match_operand 0 "register_operand" "")
6924                       (const_string "RR") (const_string "RX")))
6925    (set_attr "type"  "branch")
6926    (set_attr "atype" "agen")])
6927
6928
6929 ;;
6930 ;;- Negated conditional jump instructions.
6931 ;;
6932
6933 (define_insn "*icjump_64"
6934   [(set (pc)
6935         (if_then_else
6936           (match_operator 1 "s390_comparison" [(reg 33) (const_int 0)])
6937           (pc)
6938           (label_ref (match_operand 0 "" ""))))]
6939   "TARGET_CPU_ZARCH"
6940 {
6941   if (get_attr_length (insn) == 4)
6942     return "j%D1\t%l0";
6943   else
6944     return "jg%D1\t%l0";
6945 }
6946   [(set_attr "op_type" "RI")
6947    (set_attr "type"    "branch")
6948    (set (attr "length")
6949         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6950                       (const_int 4) (const_int 6)))])
6951
6952 (define_insn "*icjump_31"
6953   [(set (pc)
6954         (if_then_else
6955           (match_operator 1 "s390_comparison" [(reg 33) (const_int 0)])
6956           (pc)
6957           (label_ref (match_operand 0 "" ""))))]
6958   "!TARGET_CPU_ZARCH"
6959 {
6960   if (get_attr_length (insn) == 4)
6961     return "j%D1\t%l0";
6962   else
6963     abort ();
6964 }
6965   [(set_attr "op_type" "RI")
6966    (set_attr "type"    "branch")
6967    (set (attr "length")
6968         (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
6969           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6970                         (const_int 4) (const_int 6))
6971           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6972                         (const_int 4) (const_int 8))))])
6973
6974 (define_insn "*icjump_long"
6975   [(set (pc)
6976         (if_then_else
6977           (match_operator 1 "s390_comparison" [(reg 33) (const_int 0)])
6978           (pc)
6979           (match_operand 0 "address_operand" "U")))]
6980   ""
6981 {
6982   if (get_attr_op_type (insn) == OP_TYPE_RR)
6983     return "b%D1r\t%0";
6984   else
6985     return "b%D1\t%a0";
6986 }
6987   [(set (attr "op_type")
6988         (if_then_else (match_operand 0 "register_operand" "")
6989                       (const_string "RR") (const_string "RX")))
6990    (set_attr "type"  "branch")
6991    (set_attr "atype" "agen")])
6992
6993 ;;
6994 ;;- Trap instructions.
6995 ;;
6996
6997 (define_insn "trap"
6998   [(trap_if (const_int 1) (const_int 0))]
6999   ""
7000   "j\t.+2"
7001   [(set_attr "op_type" "RI")
7002    (set_attr "type"  "branch")])
7003
7004 (define_expand "conditional_trap"
7005   [(trap_if (match_operand 0 "comparison_operator" "")
7006             (match_operand 1 "general_operand" ""))]
7007   ""
7008 {
7009   if (operands[1] != const0_rtx) FAIL;
7010   operands[0] = s390_emit_compare (GET_CODE (operands[0]), 
7011                                    s390_compare_op0, s390_compare_op1);
7012 })
7013
7014 (define_insn "*trap"
7015   [(trap_if (match_operator 0 "s390_comparison" [(reg 33) (const_int 0)])
7016             (const_int 0))]
7017   ""
7018   "j%C0\t.+2";
7019   [(set_attr "op_type" "RI")
7020    (set_attr "type"  "branch")])
7021
7022 ;;
7023 ;;- Loop instructions.
7024 ;;
7025 ;;  This is all complicated by the fact that since this is a jump insn
7026 ;;  we must handle our own output reloads.
7027
7028 (define_expand "doloop_end"
7029   [(use (match_operand 0 "" ""))        ; loop pseudo
7030    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
7031    (use (match_operand 2 "" ""))        ; max iterations
7032    (use (match_operand 3 "" ""))        ; loop level
7033    (use (match_operand 4 "" ""))]       ; label
7034   ""
7035 {
7036   if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
7037     emit_jump_insn (gen_doloop_si31 (operands[4], operands[0], operands[0]));
7038   else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
7039     emit_jump_insn (gen_doloop_si64 (operands[4], operands[0], operands[0]));
7040   else if (GET_MODE (operands[0]) == DImode && TARGET_64BIT)
7041     emit_jump_insn (gen_doloop_di (operands[4], operands[0], operands[0]));
7042   else
7043     FAIL;
7044
7045   DONE;
7046 })
7047
7048 (define_insn_and_split "doloop_si64"
7049   [(set (pc)
7050         (if_then_else
7051           (ne (match_operand:SI 1 "register_operand" "d,d")
7052               (const_int 1))
7053           (label_ref (match_operand 0 "" ""))
7054           (pc)))
7055    (set (match_operand:SI 2 "nonimmediate_operand" "=1,?*m*d")
7056         (plus:SI (match_dup 1) (const_int -1)))
7057    (clobber (match_scratch:SI 3 "=X,&1"))
7058    (clobber (reg:CC 33))]
7059   "TARGET_CPU_ZARCH"
7060 {
7061   if (which_alternative != 0)
7062     return "#";
7063   else if (get_attr_length (insn) == 4)
7064     return "brct\t%1,%l0";
7065   else
7066     return "ahi\t%1,-1\;jgne\t%l0";
7067 }
7068   "&& reload_completed
7069    && (! REG_P (operands[2])
7070        || ! rtx_equal_p (operands[1], operands[2]))"
7071   [(parallel [(set (reg:CCAN 33)
7072                    (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
7073                                  (const_int 0)))
7074               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
7075    (set (match_dup 2) (match_dup 3))
7076    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
7077                            (label_ref (match_dup 0))
7078                            (pc)))]
7079   ""
7080   [(set_attr "op_type"  "RI")
7081    (set_attr "type"  "branch")
7082    (set (attr "length")
7083         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7084                       (const_int 4) (const_int 10)))])
7085
7086 (define_insn_and_split "doloop_si31"
7087   [(set (pc)
7088         (if_then_else
7089           (ne (match_operand:SI 1 "register_operand" "d,d")
7090               (const_int 1))
7091           (label_ref (match_operand 0 "" ""))
7092           (pc)))
7093    (set (match_operand:SI 2 "nonimmediate_operand" "=1,?*m*d")
7094         (plus:SI (match_dup 1) (const_int -1)))
7095    (clobber (match_scratch:SI 3 "=X,&1"))
7096    (clobber (reg:CC 33))]
7097   "!TARGET_CPU_ZARCH"
7098 {
7099   if (which_alternative != 0)
7100     return "#";
7101   else if (get_attr_length (insn) == 4)
7102     return "brct\t%1,%l0";
7103   else
7104     abort ();
7105 }
7106   "&& reload_completed
7107    && (! REG_P (operands[2])
7108        || ! rtx_equal_p (operands[1], operands[2]))"
7109   [(parallel [(set (reg:CCAN 33)
7110                    (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
7111                                  (const_int 0)))
7112               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
7113    (set (match_dup 2) (match_dup 3))
7114    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
7115                            (label_ref (match_dup 0))
7116                            (pc)))]
7117   ""
7118   [(set_attr "op_type"  "RI")
7119    (set_attr "type"  "branch")
7120    (set (attr "length")
7121         (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7122           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7123                         (const_int 4) (const_int 6))
7124           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7125                         (const_int 4) (const_int 8))))])
7126
7127 (define_insn "*doloop_si_long"
7128   [(set (pc)
7129         (if_then_else
7130           (ne (match_operand:SI 1 "register_operand" "d,d")
7131               (const_int 1))
7132           (match_operand 0 "address_operand" "U,U")
7133           (pc)))
7134    (set (match_operand:SI 2 "register_operand" "=1,?*m*d")
7135         (plus:SI (match_dup 1) (const_int -1)))
7136    (clobber (match_scratch:SI 3 "=X,&1"))
7137    (clobber (reg:CC 33))]
7138   "!TARGET_CPU_ZARCH"
7139 {
7140   if (get_attr_op_type (insn) == OP_TYPE_RR)
7141     return "bctr\t%1,%0";
7142   else
7143     return "bct\t%1,%a0";
7144 }
7145   [(set (attr "op_type")
7146         (if_then_else (match_operand 0 "register_operand" "")
7147                       (const_string "RR") (const_string "RX")))
7148    (set_attr "type"  "branch")
7149    (set_attr "atype" "agen")])
7150
7151 (define_insn_and_split "doloop_di"
7152   [(set (pc)
7153         (if_then_else
7154           (ne (match_operand:DI 1 "register_operand" "d,d")
7155               (const_int 1))
7156           (label_ref (match_operand 0 "" ""))
7157           (pc)))
7158    (set (match_operand:DI 2 "nonimmediate_operand" "=1,?*m*d")
7159         (plus:DI (match_dup 1) (const_int -1)))
7160    (clobber (match_scratch:DI 3 "=X,&1"))
7161    (clobber (reg:CC 33))]
7162   "TARGET_64BIT"
7163 {
7164   if (which_alternative != 0)
7165     return "#";
7166   else if (get_attr_length (insn) == 4)
7167     return "brctg\t%1,%l0";
7168   else
7169     return "aghi\t%1,-1\;jgne\t%l0";
7170 }
7171   "&& reload_completed
7172    && (! REG_P (operands[2])
7173        || ! rtx_equal_p (operands[1], operands[2]))"
7174   [(parallel [(set (reg:CCAN 33)
7175                    (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
7176                                  (const_int 0)))
7177               (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
7178    (set (match_dup 2) (match_dup 3))
7179    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
7180                            (label_ref (match_dup 0))
7181                            (pc)))]
7182   ""
7183   [(set_attr "op_type"  "RI")
7184    (set_attr "type"  "branch")
7185    (set (attr "length")
7186         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7187                       (const_int 4) (const_int 10)))])
7188
7189 ;;
7190 ;;- Unconditional jump instructions.
7191 ;;
7192
7193 ;
7194 ; jump instruction pattern(s).
7195 ;
7196
7197 (define_expand "jump"
7198   [(match_operand 0 "" "")]
7199   ""
7200   "s390_emit_jump (operands[0], NULL_RTX); DONE;")
7201
7202 (define_insn "*jump64"
7203   [(set (pc) (label_ref (match_operand 0 "" "")))]
7204   "TARGET_CPU_ZARCH"
7205 {
7206   if (get_attr_length (insn) == 4)
7207     return "j\t%l0";
7208   else
7209     return "jg\t%l0";
7210 }
7211   [(set_attr "op_type" "RI")
7212    (set_attr "type"  "branch")
7213    (set (attr "length")
7214         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7215                       (const_int 4) (const_int 6)))])
7216
7217 (define_insn "*jump31"
7218   [(set (pc) (label_ref (match_operand 0 "" "")))]
7219   "!TARGET_CPU_ZARCH"
7220 {
7221   if (get_attr_length (insn) == 4)
7222     return "j\t%l0";
7223   else
7224     abort ();
7225 }
7226   [(set_attr "op_type" "RI")
7227    (set_attr "type"  "branch")
7228    (set (attr "length")
7229         (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7230           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7231                         (const_int 4) (const_int 6))
7232           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7233                         (const_int 4) (const_int 8))))])
7234
7235 ;
7236 ; indirect-jump instruction pattern(s).
7237 ;
7238
7239 (define_insn "indirect_jump"
7240  [(set (pc) (match_operand 0 "address_operand" "U"))]
7241   ""
7242 {
7243   if (get_attr_op_type (insn) == OP_TYPE_RR)
7244     return "br\t%0";
7245   else
7246     return "b\t%a0";
7247 }
7248   [(set (attr "op_type")
7249         (if_then_else (match_operand 0 "register_operand" "")
7250                       (const_string "RR") (const_string "RX")))
7251    (set_attr "type"  "branch")
7252    (set_attr "atype" "agen")])
7253
7254 ;
7255 ; casesi instruction pattern(s).
7256 ;
7257
7258 (define_insn "casesi_jump"
7259  [(set (pc) (match_operand 0 "address_operand" "U"))
7260    (use (label_ref (match_operand 1 "" "")))]
7261   ""
7262 {
7263   if (get_attr_op_type (insn) == OP_TYPE_RR)
7264     return "br\t%0";
7265   else
7266     return "b\t%a0";
7267 }
7268   [(set (attr "op_type")
7269         (if_then_else (match_operand 0 "register_operand" "")
7270                       (const_string "RR") (const_string "RX")))
7271    (set_attr "type"  "branch")
7272    (set_attr "atype" "agen")])
7273
7274 (define_expand "casesi"
7275   [(match_operand:SI 0 "general_operand" "")
7276    (match_operand:SI 1 "general_operand" "")
7277    (match_operand:SI 2 "general_operand" "")
7278    (label_ref (match_operand 3 "" ""))
7279    (label_ref (match_operand 4 "" ""))]
7280   ""
7281 {
7282    rtx index  = gen_reg_rtx (SImode);
7283    rtx base   = gen_reg_rtx (Pmode);
7284    rtx target = gen_reg_rtx (Pmode);
7285
7286    emit_move_insn (index, operands[0]);
7287    emit_insn (gen_subsi3 (index, index, operands[1]));
7288    emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
7289                             operands[4]);
7290
7291    if (Pmode != SImode)
7292      index = convert_to_mode (Pmode, index, 1);
7293    if (GET_CODE (index) != REG)
7294      index = copy_to_mode_reg (Pmode, index);
7295
7296    if (TARGET_64BIT)
7297        emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
7298    else
7299        emit_insn (gen_ashlsi3 (index, index, const2_rtx));
7300
7301    emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
7302
7303    index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
7304    emit_move_insn (target, index);
7305
7306    if (flag_pic)
7307      target = gen_rtx_PLUS (Pmode, base, target);
7308    emit_jump_insn (gen_casesi_jump (target, operands[3]));
7309
7310    DONE;
7311 })
7312
7313
7314 ;;
7315 ;;- Jump to subroutine.
7316 ;;
7317 ;;
7318
7319 ;
7320 ; untyped call instruction pattern(s).
7321 ;
7322
7323 ;; Call subroutine returning any type.
7324 (define_expand "untyped_call"
7325   [(parallel [(call (match_operand 0 "" "")
7326                     (const_int 0))
7327               (match_operand 1 "" "")
7328               (match_operand 2 "" "")])]
7329   ""
7330 {
7331   int i;
7332
7333   emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
7334
7335   for (i = 0; i < XVECLEN (operands[2], 0); i++)
7336     {
7337       rtx set = XVECEXP (operands[2], 0, i);
7338       emit_move_insn (SET_DEST (set), SET_SRC (set));
7339     }
7340
7341   /* The optimizer does not know that the call sets the function value
7342      registers we stored in the result block.  We avoid problems by
7343      claiming that all hard registers are used and clobbered at this
7344      point.  */
7345   emit_insn (gen_blockage ());
7346
7347   DONE;
7348 })
7349
7350 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
7351 ;; all of memory.  This blocks insns from being moved across this point.
7352
7353 (define_insn "blockage"
7354   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
7355   ""
7356   ""
7357   [(set_attr "type"    "none")
7358    (set_attr "length"  "0")])
7359
7360 ;
7361 ; sibcall patterns
7362 ;
7363
7364 (define_expand "sibcall"
7365   [(call (match_operand 0 "" "")
7366          (match_operand 1 "" ""))]
7367   ""
7368 {
7369   s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
7370   DONE;
7371 })
7372
7373 (define_insn "*sibcall_br"
7374   [(call (mem:QI (reg 1))
7375          (match_operand 0 "const_int_operand" "n"))]
7376   "SIBLING_CALL_P (insn)
7377    && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
7378   "br\t%%r1"
7379   [(set_attr "op_type" "RR")
7380    (set_attr "type"  "branch")
7381    (set_attr "atype" "agen")])
7382
7383 (define_insn "*sibcall_brc"
7384   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7385          (match_operand 1 "const_int_operand" "n"))]
7386   "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
7387   "j\t%0"
7388   [(set_attr "op_type" "RI")
7389    (set_attr "type"    "branch")])
7390
7391 (define_insn "*sibcall_brcl"
7392   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7393          (match_operand 1 "const_int_operand" "n"))]
7394   "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
7395   "jg\t%0"
7396   [(set_attr "op_type" "RIL")
7397    (set_attr "type"    "branch")])
7398
7399 ;
7400 ; sibcall_value patterns
7401 ;
7402
7403 (define_expand "sibcall_value"
7404   [(set (match_operand 0 "" "")
7405         (call (match_operand 1 "" "")
7406               (match_operand 2 "" "")))]
7407   ""
7408 {
7409   s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
7410   DONE;
7411 })
7412
7413 (define_insn "*sibcall_value_br"
7414   [(set (match_operand 0 "" "")
7415         (call (mem:QI (reg 1))
7416               (match_operand 1 "const_int_operand" "n")))]
7417   "SIBLING_CALL_P (insn)
7418    && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
7419   "br\t%%r1"
7420   [(set_attr "op_type" "RR")
7421    (set_attr "type"  "branch")
7422    (set_attr "atype" "agen")])
7423
7424 (define_insn "*sibcall_value_brc"
7425   [(set (match_operand 0 "" "")
7426         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7427               (match_operand 2 "const_int_operand" "n")))]
7428   "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
7429   "j\t%1"
7430   [(set_attr "op_type" "RI")
7431    (set_attr "type"    "branch")])
7432
7433 (define_insn "*sibcall_value_brcl"
7434   [(set (match_operand 0 "" "")
7435         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7436               (match_operand 2 "const_int_operand" "n")))]
7437   "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
7438   "jg\t%1"
7439   [(set_attr "op_type" "RIL")
7440    (set_attr "type"    "branch")])
7441
7442
7443 ;
7444 ; call instruction pattern(s).
7445 ;
7446
7447 (define_expand "call"
7448   [(call (match_operand 0 "" "")
7449          (match_operand 1 "" ""))
7450    (use (match_operand 2 "" ""))]
7451   ""
7452 {
7453   s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
7454                   gen_rtx_REG (Pmode, RETURN_REGNUM));
7455   DONE;
7456 })
7457
7458 (define_insn "*bras"
7459   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7460          (match_operand 1 "const_int_operand" "n"))
7461    (clobber (match_operand 2 "register_operand" "=r"))]
7462   "!SIBLING_CALL_P (insn)
7463    && TARGET_SMALL_EXEC
7464    && GET_MODE (operands[2]) == Pmode"
7465   "bras\t%2,%0"
7466   [(set_attr "op_type" "RI")
7467    (set_attr "type"    "jsr")])
7468
7469 (define_insn "*brasl"
7470   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7471          (match_operand 1 "const_int_operand" "n"))
7472    (clobber (match_operand 2 "register_operand" "=r"))]
7473   "!SIBLING_CALL_P (insn)
7474    && TARGET_CPU_ZARCH
7475    && GET_MODE (operands[2]) == Pmode"
7476   "brasl\t%2,%0"
7477   [(set_attr "op_type" "RIL")
7478    (set_attr "type"    "jsr")])
7479
7480 (define_insn "*basr"
7481   [(call (mem:QI (match_operand 0 "address_operand" "U"))
7482          (match_operand 1 "const_int_operand" "n"))
7483    (clobber (match_operand 2 "register_operand" "=r"))]
7484   "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
7485 {
7486   if (get_attr_op_type (insn) == OP_TYPE_RR)
7487     return "basr\t%2,%0";
7488   else
7489     return "bas\t%2,%a0";
7490 }
7491   [(set (attr "op_type")
7492         (if_then_else (match_operand 0 "register_operand" "")
7493                       (const_string "RR") (const_string "RX")))
7494    (set_attr "type"  "jsr")
7495    (set_attr "atype" "agen")])
7496
7497 ;
7498 ; call_value instruction pattern(s).
7499 ;
7500
7501 (define_expand "call_value"
7502   [(set (match_operand 0 "" "")
7503         (call (match_operand 1 "" "")
7504               (match_operand 2 "" "")))
7505    (use (match_operand 3 "" ""))]
7506   ""
7507 {
7508   s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
7509                   gen_rtx_REG (Pmode, RETURN_REGNUM));
7510   DONE;
7511 })
7512
7513 (define_insn "*bras_r"
7514   [(set (match_operand 0 "" "")
7515         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7516               (match_operand:SI 2 "const_int_operand" "n")))
7517    (clobber (match_operand 3 "register_operand" "=r"))]
7518   "!SIBLING_CALL_P (insn)
7519    && TARGET_SMALL_EXEC
7520    && GET_MODE (operands[3]) == Pmode"
7521   "bras\t%3,%1"
7522   [(set_attr "op_type" "RI")
7523    (set_attr "type"    "jsr")])
7524
7525 (define_insn "*brasl_r"
7526   [(set (match_operand 0 "" "")
7527         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7528               (match_operand 2 "const_int_operand" "n")))
7529    (clobber (match_operand 3 "register_operand" "=r"))]
7530   "!SIBLING_CALL_P (insn)
7531    && TARGET_CPU_ZARCH
7532    && GET_MODE (operands[3]) == Pmode"
7533   "brasl\t%3,%1"
7534   [(set_attr "op_type" "RIL")
7535    (set_attr "type"    "jsr")])
7536
7537 (define_insn "*basr_r"
7538   [(set (match_operand 0 "" "")
7539         (call (mem:QI (match_operand 1 "address_operand" "U"))
7540               (match_operand 2 "const_int_operand" "n")))
7541    (clobber (match_operand 3 "register_operand" "=r"))]
7542   "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
7543 {
7544   if (get_attr_op_type (insn) == OP_TYPE_RR)
7545     return "basr\t%3,%1";
7546   else
7547     return "bas\t%3,%a1";
7548 }
7549   [(set (attr "op_type")
7550         (if_then_else (match_operand 1 "register_operand" "")
7551                       (const_string "RR") (const_string "RX")))
7552    (set_attr "type"  "jsr")
7553    (set_attr "atype" "agen")])
7554
7555 ;;
7556 ;;- Thread-local storage support.
7557 ;;
7558
7559 (define_expand "get_tp_64"
7560   [(set (match_operand:DI 0 "nonimmediate_operand" "") (reg:DI 36))]
7561   "TARGET_64BIT"
7562   "")
7563
7564 (define_expand "get_tp_31"
7565   [(set (match_operand:SI 0 "nonimmediate_operand" "") (reg:SI 36))]
7566   "!TARGET_64BIT"
7567   "")
7568
7569 (define_expand "set_tp_64"
7570   [(set (reg:DI 36) (match_operand:DI 0 "nonimmediate_operand" ""))
7571    (set (reg:DI 36) (unspec_volatile:DI [(reg:DI 36)] UNSPECV_SET_TP))]
7572   "TARGET_64BIT"
7573   "")
7574
7575 (define_expand "set_tp_31"
7576   [(set (reg:SI 36) (match_operand:SI 0 "nonimmediate_operand" ""))
7577    (set (reg:SI 36) (unspec_volatile:SI [(reg:SI 36)] UNSPECV_SET_TP))]
7578   "!TARGET_64BIT"
7579   "")
7580
7581 (define_insn "*set_tp"
7582   [(set (reg 36) (unspec_volatile [(reg 36)] UNSPECV_SET_TP))]
7583   ""
7584   ""
7585   [(set_attr "type" "none")
7586    (set_attr "length" "0")])
7587
7588 (define_insn "*tls_load_64"
7589   [(set (match_operand:DI 0 "register_operand" "=d")
7590         (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
7591                     (match_operand:DI 2 "" "")]
7592                    UNSPEC_TLS_LOAD))]
7593   "TARGET_64BIT"
7594   "lg\t%0,%1%J2"
7595   [(set_attr "op_type" "RXE")])
7596
7597 (define_insn "*tls_load_31"
7598   [(set (match_operand:SI 0 "register_operand" "=d,d")
7599         (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
7600                     (match_operand:SI 2 "" "")]
7601                    UNSPEC_TLS_LOAD))]
7602   "!TARGET_64BIT"
7603   "@
7604    l\t%0,%1%J2
7605    ly\t%0,%1%J2"
7606   [(set_attr "op_type" "RX,RXY")])
7607
7608 (define_insn "*bras_tls"
7609   [(set (match_operand 0 "" "")
7610         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7611               (match_operand 2 "const_int_operand" "n")))
7612    (clobber (match_operand 3 "register_operand" "=r"))
7613    (use (match_operand 4 "" ""))]
7614   "!SIBLING_CALL_P (insn)
7615    && TARGET_SMALL_EXEC
7616    && GET_MODE (operands[3]) == Pmode"
7617   "bras\t%3,%1%J4"
7618   [(set_attr "op_type" "RI")
7619    (set_attr "type"    "jsr")])
7620
7621 (define_insn "*brasl_tls"
7622   [(set (match_operand 0 "" "")
7623         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7624               (match_operand 2 "const_int_operand" "n")))
7625    (clobber (match_operand 3 "register_operand" "=r"))
7626    (use (match_operand 4 "" ""))]
7627   "!SIBLING_CALL_P (insn)
7628    && TARGET_CPU_ZARCH
7629    && GET_MODE (operands[3]) == Pmode"
7630   "brasl\t%3,%1%J4"
7631   [(set_attr "op_type" "RIL")
7632    (set_attr "type"    "jsr")])
7633
7634 (define_insn "*basr_tls"
7635   [(set (match_operand 0 "" "")
7636         (call (mem:QI (match_operand 1 "address_operand" "U"))
7637               (match_operand 2 "const_int_operand" "n")))
7638    (clobber (match_operand 3 "register_operand" "=r"))
7639    (use (match_operand 4 "" ""))]
7640   "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
7641 {
7642   if (get_attr_op_type (insn) == OP_TYPE_RR)
7643     return "basr\t%3,%1%J4";
7644   else
7645     return "bas\t%3,%a1%J4";
7646 }
7647   [(set (attr "op_type")
7648         (if_then_else (match_operand 1 "register_operand" "")
7649                       (const_string "RR") (const_string "RX")))
7650    (set_attr "type"  "jsr")
7651    (set_attr "atype" "agen")])
7652
7653 ;;
7654 ;;- Miscellaneous instructions.
7655 ;;
7656
7657 ;
7658 ; allocate stack instruction pattern(s).
7659 ;
7660
7661 (define_expand "allocate_stack"
7662   [(match_operand 0 "general_operand" "")
7663    (match_operand 1 "general_operand" "")]
7664  "TARGET_BACKCHAIN"
7665 {
7666   rtx temp = gen_reg_rtx (Pmode);
7667
7668   emit_move_insn (temp, s390_back_chain_rtx ());
7669   anti_adjust_stack (operands[1]);
7670   emit_move_insn (s390_back_chain_rtx (), temp);
7671
7672   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
7673   DONE;
7674 })
7675
7676
7677 ;
7678 ; setjmp instruction pattern.
7679 ;
7680
7681 (define_expand "builtin_setjmp_receiver"
7682   [(match_operand 0 "" "")]
7683   "flag_pic"
7684 {
7685   emit_insn (s390_load_got ());
7686   emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
7687   DONE;
7688 })
7689
7690 ;; These patterns say how to save and restore the stack pointer.  We need not
7691 ;; save the stack pointer at function level since we are careful to
7692 ;; preserve the backchain.  At block level, we have to restore the backchain
7693 ;; when we restore the stack pointer.
7694 ;;
7695 ;; For nonlocal gotos, we must save both the stack pointer and its
7696 ;; backchain and restore both.  Note that in the nonlocal case, the
7697 ;; save area is a memory location.
7698
7699 (define_expand "save_stack_function"
7700   [(match_operand 0 "general_operand" "")
7701    (match_operand 1 "general_operand" "")]
7702   ""
7703   "DONE;")
7704
7705 (define_expand "restore_stack_function"
7706   [(match_operand 0 "general_operand" "")
7707    (match_operand 1 "general_operand" "")]
7708   ""
7709   "DONE;")
7710
7711 (define_expand "restore_stack_block"
7712   [(match_operand 0 "register_operand" "")
7713    (match_operand 1 "register_operand" "")]
7714   "TARGET_BACKCHAIN"
7715 {
7716   rtx temp = gen_reg_rtx (Pmode);
7717
7718   emit_move_insn (temp, s390_back_chain_rtx ());
7719   emit_move_insn (operands[0], operands[1]);
7720   emit_move_insn (s390_back_chain_rtx (), temp);
7721
7722   DONE;
7723 })
7724
7725 (define_expand "save_stack_nonlocal"
7726   [(match_operand 0 "memory_operand" "")
7727    (match_operand 1 "register_operand" "")]
7728   ""
7729 {
7730   enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
7731   rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
7732
7733   /* Copy the backchain to the first word, sp to the second and the
7734      literal pool base to the third.  */
7735
7736   if (TARGET_BACKCHAIN)
7737     {
7738       rtx temp = force_reg (Pmode, s390_back_chain_rtx ());
7739       emit_move_insn (operand_subword (operands[0], 0, 0, mode), temp);
7740     }
7741
7742   emit_move_insn (operand_subword (operands[0], 1, 0, mode), operands[1]);
7743   emit_move_insn (operand_subword (operands[0], 2, 0, mode), base);
7744
7745   DONE;
7746 })
7747
7748 (define_expand "restore_stack_nonlocal"
7749   [(match_operand 0 "register_operand" "")
7750    (match_operand 1 "memory_operand" "")]
7751   ""
7752 {
7753   enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
7754   rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
7755   rtx temp = NULL_RTX;
7756
7757   /* Restore the backchain from the first word, sp from the second and the
7758      literal pool base from the third.  */
7759
7760   if (TARGET_BACKCHAIN)
7761     temp = force_reg (Pmode, operand_subword (operands[1], 0, 0, mode));
7762     
7763   emit_move_insn (base, operand_subword (operands[1], 2, 0, mode));
7764   emit_move_insn (operands[0], operand_subword (operands[1], 1, 0, mode));
7765
7766   if (temp)
7767     emit_move_insn (s390_back_chain_rtx (), temp);
7768
7769   emit_insn (gen_rtx_USE (VOIDmode, base));
7770   DONE;
7771 })
7772
7773
7774 ;
7775 ; nop instruction pattern(s).
7776 ;
7777
7778 (define_insn "nop"
7779   [(const_int 0)]
7780   ""
7781   "lr\t0,0"
7782   [(set_attr "op_type" "RR")])
7783
7784
7785 ;
7786 ; Special literal pool access instruction pattern(s).
7787 ;
7788
7789 (define_insn "*pool_entry"
7790   [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
7791                     UNSPECV_POOL_ENTRY)]
7792   ""
7793 {
7794   enum machine_mode mode = GET_MODE (PATTERN (insn));
7795   unsigned int align = GET_MODE_BITSIZE (mode);
7796   s390_output_pool_entry (operands[0], mode, align);
7797   return "";
7798 }
7799   [(set (attr "length")
7800         (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
7801
7802 (define_insn "pool_align"
7803   [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
7804                     UNSPECV_POOL_ALIGN)]
7805   ""
7806   ".align\t%0"
7807   [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
7808
7809 (define_insn "pool_section_start"
7810   [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
7811   ""
7812   ".section\t.rodata"
7813   [(set_attr "length" "0")])
7814
7815 (define_insn "pool_section_end"
7816   [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
7817   ""
7818   ".previous"
7819   [(set_attr "length" "0")])
7820
7821 (define_insn "main_base_31_small"
7822   [(set (match_operand 0 "register_operand" "=a")
7823         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
7824   "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7825   "basr\t%0,0"
7826   [(set_attr "op_type" "RR")
7827    (set_attr "type"    "la")])
7828
7829 (define_insn "main_base_31_large"
7830   [(set (match_operand 0 "register_operand" "=a")
7831         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
7832    (set (pc) (label_ref (match_operand 2 "" "")))]
7833   "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7834   "bras\t%0,%2"
7835   [(set_attr "op_type" "RI")])
7836
7837 (define_insn "main_base_64"
7838   [(set (match_operand 0 "register_operand" "=a")
7839         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
7840   "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7841   "larl\t%0,%1"
7842   [(set_attr "op_type" "RIL")
7843    (set_attr "type"    "larl")])
7844
7845 (define_insn "main_pool"
7846   [(set (match_operand 0 "register_operand" "=a")
7847         (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
7848   "GET_MODE (operands[0]) == Pmode"
7849   "* abort ();"
7850   [(set (attr "type") 
7851         (if_then_else (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
7852                       (const_string "larl") (const_string "la")))])
7853
7854 (define_insn "reload_base_31"
7855   [(set (match_operand 0 "register_operand" "=a")
7856         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
7857   "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7858   "basr\t%0,0\;la\t%0,%1-.(%0)"
7859   [(set_attr "length" "6")
7860    (set_attr "type" "la")])
7861
7862 (define_insn "reload_base_64"
7863   [(set (match_operand 0 "register_operand" "=a")
7864         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
7865   "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7866   "larl\t%0,%1"
7867   [(set_attr "op_type" "RIL")
7868    (set_attr "type"    "larl")])
7869
7870 (define_insn "pool"
7871   [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
7872   ""
7873   "* abort ();"
7874   [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
7875
7876 ;;
7877 ;; Insns related to generating the function prologue and epilogue.
7878 ;;
7879
7880
7881 (define_expand "prologue"
7882   [(use (const_int 0))]
7883   ""
7884   "s390_emit_prologue (); DONE;")
7885
7886 (define_insn "prologue_tpf"
7887   [(unspec_volatile [(const_int 0)] UNSPECV_TPF_PROLOGUE)
7888    (clobber (reg:DI 1))]
7889   "TARGET_TPF_PROFILING"
7890   "larl\t%%r1,.+14\;tm\t4065,255\;bnz\t4064"
7891   [(set_attr "length"   "14")])
7892
7893 (define_expand "epilogue"
7894   [(use (const_int 1))]
7895   ""
7896   "s390_emit_epilogue (false); DONE;")
7897
7898 (define_insn "epilogue_tpf"
7899   [(unspec_volatile [(const_int 0)] UNSPECV_TPF_EPILOGUE)
7900    (clobber (reg:DI 1))]
7901   "TARGET_TPF_PROFILING"
7902   "larl\t%%r1,.+14\;tm\t4071,255\;bnz\t4070"
7903   [(set_attr "length"   "14")])
7904
7905 (define_expand "sibcall_epilogue"
7906   [(use (const_int 0))]
7907   ""
7908   "s390_emit_epilogue (true); DONE;")
7909
7910 (define_insn "*return"
7911   [(return)
7912    (use (match_operand 0 "register_operand" "a"))]
7913   "GET_MODE (operands[0]) == Pmode"
7914   "br\t%0"
7915   [(set_attr "op_type" "RR")
7916    (set_attr "type"    "jsr")
7917    (set_attr "atype"   "agen")])
7918
7919
7920 ;; Instruction definition to extend a 31-bit pointer into a 64-bit
7921 ;; pointer. This is used for compatibility.
7922
7923 (define_expand "ptr_extend"
7924   [(set (match_operand:DI 0 "register_operand" "=r")
7925         (match_operand:SI 1 "register_operand" "r"))]
7926   "TARGET_64BIT"
7927 {
7928   emit_insn (gen_anddi3 (operands[0],
7929                          gen_lowpart (DImode, operands[1]),
7930                          GEN_INT (0x7fffffff)));
7931   DONE;
7932 })
7933
7934 ;; Instruction definition to expand eh_return macro to support
7935 ;; swapping in special linkage return addresses.
7936
7937 (define_expand "eh_return"
7938   [(use (match_operand 0 "register_operand" ""))]
7939   "TARGET_TPF"
7940 {
7941   s390_emit_tpf_eh_return (operands[0]);
7942   DONE;
7943 })
7944