OSDN Git Service

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