OSDN Git Service

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