OSDN Git Service

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