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