OSDN Git Service

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