OSDN Git Service

2005-05-10 Adrian Straetling <straetling@de.ibm.com>
[pf3gnuchains/gcc-fork.git] / gcc / config / s390 / s390.md
1 ;;- Machine description for GNU compiler -- S/390 / zSeries version.
2 ;;  Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;;  Free Software Foundation, Inc.
4 ;;  Contributed by Hartmut Penner (hpenner@de.ibm.com) and
5 ;;                 Ulrich Weigand (uweigand@de.ibm.com).
6
7 ;; This file is part of GCC.
8
9 ;; GCC is free software; you can redistribute it and/or modify it under
10 ;; the terms of the GNU General Public License as published by the Free
11 ;; Software Foundation; either version 2, or (at your option) any later
12 ;; version.
13
14 ;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 ;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17 ;; for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING.  If not, write to the Free
21 ;; Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 ;; 02111-1307, USA.
23
24 ;;
25 ;; Special constraints for s/390 machine description:
26 ;;
27 ;;    a -- Any address register from 1 to 15.
28 ;;    c -- Condition code register 33.
29 ;;    d -- Any register from 0 to 15.
30 ;;    I -- An 8-bit constant (0..255).
31 ;;    J -- A 12-bit constant (0..4095).
32 ;;    K -- A 16-bit constant (-32768..32767).
33 ;;    L -- Value appropriate as displacement.
34 ;;         (0..4095) for short displacement
35 ;;         (-524288..524287) for long displacement
36 ;;    M -- Constant integer with a value of 0x7fffffff.
37 ;;    N -- Multiple letter constraint followed by 4 parameter letters.
38 ;;         0..9,x:  number of the part counting from most to least significant
39 ;;         H,Q:     mode of the part
40 ;;         D,S,H:   mode of the containing operand
41 ;;         0,F:     value of the other parts (F - all bits set)
42 ;;
43 ;;         The constraint matches if the specified part of a constant
44 ;;         has a value different from its other parts.  If the letter x
45 ;;         is specified instead of a part number, the constraint matches
46 ;;         if there is any single part with non-default value.
47 ;;    Q -- Memory reference without index register and with short displacement.
48 ;;    R -- Memory reference with index register and short displacement.
49 ;;    S -- Memory reference without index register but with long displacement.
50 ;;    T -- Memory reference with index register and long displacement.
51 ;;    A -- Multiple letter constraint followed by Q, R, S, or T:
52 ;;         Offsettable memory reference of type specified by second letter.
53 ;;    B -- Multiple letter constraint followed by Q, R, S, or T:
54 ;;         Memory reference of the type specified by second letter that
55 ;;         does *not* refer to a literal pool entry.
56 ;;    U -- Pointer with short displacement.
57 ;;    W -- Pointer with long displacement.
58 ;;    Y -- Shift count operand.
59 ;;
60 ;; Special formats used for outputting 390 instructions.
61 ;;
62 ;;     %C: print opcode suffix for branch condition.
63 ;;     %D: print opcode suffix for inverse branch condition.
64 ;;     %J: print tls_load/tls_gdcall/tls_ldcall suffix
65 ;;     %O: print only the displacement of a memory reference.
66 ;;     %R: print only the base register of a memory reference.
67 ;;     %S: print S-type memory reference (base+displacement).
68 ;;     %N: print the second word of a DImode operand.
69 ;;     %M: print the second word of a TImode operand.
70
71 ;;     %b: print integer X as if it's an unsigned byte.
72 ;;     %x: print integer X as if it's an unsigned word.
73 ;;     %h: print integer X as if it's a signed word.
74 ;;     %i: print the first nonzero HImode part of X
75 ;;     %j: print the first HImode part unequal to 0xffff of X
76
77 ;;
78 ;; We have a special constraint for pattern matching.
79 ;;
80 ;;   s_operand -- Matches a valid S operand in a RS, SI or SS type instruction.
81 ;;
82
83 ;;
84 ;; UNSPEC usage
85 ;;
86
87 (define_constants
88   [; Miscellaneous
89    (UNSPEC_ROUND                1)
90    (UNSPEC_CMPINT               2)
91    (UNSPEC_SETHIGH              10)
92
93    ; GOT/PLT and lt-relative accesses
94    (UNSPEC_LTREL_OFFSET         100)
95    (UNSPEC_LTREL_BASE           101)
96    (UNSPEC_GOTENT               110)
97    (UNSPEC_GOT                  111)
98    (UNSPEC_GOTOFF               112)
99    (UNSPEC_PLT                  113)
100    (UNSPEC_PLTOFF               114)
101
102    ; Literal pool
103    (UNSPEC_RELOAD_BASE          210)
104    (UNSPEC_MAIN_BASE            211)
105    (UNSPEC_LTREF                212)
106    (UNSPEC_INSN                 213)
107    (UNSPEC_EXECUTE              214)
108
109    ; TLS relocation specifiers
110    (UNSPEC_TLSGD                500)
111    (UNSPEC_TLSLDM               501)
112    (UNSPEC_NTPOFF               502)
113    (UNSPEC_DTPOFF               503)
114    (UNSPEC_GOTNTPOFF            504)
115    (UNSPEC_INDNTPOFF            505)
116
117    ; TLS support
118    (UNSPEC_TLSLDM_NTPOFF        511)
119    (UNSPEC_TLS_LOAD             512)
120
121    ; String Functions
122    (UNSPEC_SRST         600)
123  ])
124
125 ;;
126 ;; UNSPEC_VOLATILE usage
127 ;;
128
129 (define_constants
130   [; Blockage
131    (UNSPECV_BLOCKAGE            0)
132
133    ; TPF Support
134    (UNSPECV_TPF_PROLOGUE        20)
135    (UNSPECV_TPF_EPILOGUE        21)
136
137    ; Literal pool
138    (UNSPECV_POOL                200)
139    (UNSPECV_POOL_SECTION        201)
140    (UNSPECV_POOL_ALIGN          202)
141    (UNSPECV_POOL_ENTRY          203)
142    (UNSPECV_MAIN_POOL           300)
143
144    ; TLS support
145    (UNSPECV_SET_TP              500)
146   ])
147
148 ;;
149 ;; Registers
150 ;;
151
152 (define_constants
153   [
154    ; Sibling call register.
155    (SIBCALL_REGNUM               1)
156    ; Literal pool base register.
157    (BASE_REGNUM                 13)
158    ; Return address register.
159    (RETURN_REGNUM               14)
160    ; Condition code register.
161    (CC_REGNUM                   33)
162    ; Thread local storage pointer register. 
163    (TP_REGNUM                   36)
164   ])
165
166
167 ;; Instruction operand type as used in the Principles of Operation.
168 ;; Used to determine defaults for length and other attribute values.
169
170 (define_attr "op_type"
171   "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY"
172   (const_string "NN"))
173
174 ;; Instruction type attribute used for scheduling.
175
176 (define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
177                      cs,vs,store,idiv,
178                      imulhi,imulsi,imuldi,
179                      branch,jsr,fsimpdf,fsimpsf,
180                      floaddf,floadsf,fstoredf,fstoresf,
181                      fmuldf,fmulsf,fdivdf,fdivsf,
182                      ftoi,itof,fsqrtdf,fsqrtsf,
183                      other"
184   (cond [(eq_attr "op_type" "NN")  (const_string "other")
185          (eq_attr "op_type" "SS")  (const_string "cs")]
186     (const_string "integer")))
187
188 ;; Another attribute used for scheduling purposes:
189 ;;   agen: Instruction uses the address generation unit
190 ;;   reg: Instruction does not use the agen unit
191
192 (define_attr "atype" "agen,reg"
193   (cond [(eq_attr "op_type" "E")   (const_string "reg")
194          (eq_attr "op_type" "RR")  (const_string "reg")
195          (eq_attr "op_type" "RX")  (const_string "agen")
196          (eq_attr "op_type" "RI")  (const_string "reg")
197          (eq_attr "op_type" "RRE") (const_string "reg")
198          (eq_attr "op_type" "RS")  (const_string "agen")
199          (eq_attr "op_type" "RSI") (const_string "agen")
200          (eq_attr "op_type" "S")   (const_string "agen")
201          (eq_attr "op_type" "SI")  (const_string "agen")
202          (eq_attr "op_type" "SS")  (const_string "agen")
203          (eq_attr "op_type" "SSE") (const_string "agen")
204          (eq_attr "op_type" "RXE") (const_string "agen")
205          (eq_attr "op_type" "RSE") (const_string "agen")
206          (eq_attr "op_type" "RIL") (const_string "agen")
207          (eq_attr "op_type" "RXY") (const_string "agen")
208          (eq_attr "op_type" "RSY") (const_string "agen")
209          (eq_attr "op_type" "SIY") (const_string "agen")]
210     (const_string "agen")))
211
212 ;; Length in bytes.
213
214 (define_attr "length" ""
215   (cond [(eq_attr "op_type" "E")   (const_int 2)
216          (eq_attr "op_type" "RR")  (const_int 2)
217          (eq_attr "op_type" "RX")  (const_int 4)
218          (eq_attr "op_type" "RI")  (const_int 4)
219          (eq_attr "op_type" "RRE") (const_int 4)
220          (eq_attr "op_type" "RS")  (const_int 4)
221          (eq_attr "op_type" "RSI") (const_int 4)
222          (eq_attr "op_type" "S")   (const_int 4)
223          (eq_attr "op_type" "SI")  (const_int 4)
224          (eq_attr "op_type" "SS")  (const_int 6)
225          (eq_attr "op_type" "SSE") (const_int 6)
226          (eq_attr "op_type" "RXE") (const_int 6)
227          (eq_attr "op_type" "RSE") (const_int 6)
228          (eq_attr "op_type" "RIL") (const_int 6)
229          (eq_attr "op_type" "RXY") (const_int 6)
230          (eq_attr "op_type" "RSY") (const_int 6)
231          (eq_attr "op_type" "SIY") (const_int 6)]
232     (const_int 6)))
233
234
235 ;; Processor type.  This attribute must exactly match the processor_type
236 ;; enumeration in s390.h.  The current machine description does not
237 ;; distinguish between g5 and g6, but there are differences between the two
238 ;; CPUs could in theory be modeled.
239
240 (define_attr "cpu" "g5,g6,z900,z990"
241   (const (symbol_ref "s390_tune")))
242
243 ;; Pipeline description for z900.  For lack of anything better,
244 ;; this description is also used for the g5 and g6.
245 (include "2064.md")
246
247 ;; Pipeline description for z990. 
248 (include "2084.md")
249
250 ;; Predicates
251 (include "predicates.md")
252
253
254 ;; Macros
255
256 ;; This mode macro allows DF and SF patterns to be generated from the
257 ;; same template.
258 (define_mode_macro FPR     [DF SF])
259
260 ;; These mode macros allow 31-bit and 64-bit GPR patterns to be generated
261 ;; from the same template.
262 (define_mode_macro GPR [(DI "TARGET_64BIT") SI])
263 (define_mode_macro DSI [DI SI])
264
265 ;; This mode macro allows :P to be used for patterns that operate on
266 ;; pointer-sized quantities.  Exactly one of the two alternatives will match.
267 (define_mode_macro P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
268
269 ;; This mode macro allows the QI and HI patterns to be defined from
270 ;; the same template.
271 (define_mode_macro HQI [HI QI])
272
273 ;; This mode macro allows the integer patterns to be defined from the
274 ;; same template.
275 (define_mode_macro INT [(DI "TARGET_64BIT") SI HI QI])
276
277 ;; This macro allows to unify all 'bCOND' expander patterns.
278 (define_code_macro COMPARE [eq ne gt gtu lt ltu ge geu le leu unordered 
279                             ordered uneq unlt ungt unle unge ltgt])
280
281 ;; This macro allows to unify all 'sCOND' patterns.
282 (define_code_macro SCOND [ltu gtu leu geu])
283
284 ;; This macro allows some 'ashift' and 'lshiftrt' pattern to be defined from
285 ;; the same template.
286 (define_code_macro SHIFT [ashift lshiftrt])
287
288
289 ;; In FPR templates, a string like "lt<de>br" will expand to "ltdbr" in DFmode
290 ;; and "ltebr" in SFmode.
291 (define_mode_attr de [(DF "d") (SF "e")])
292
293 ;; In FPR templates, a string like "m<dee>br" will expand to "mdbr" in DFmode
294 ;; and "meebr" in SFmode.  This is needed for the 'mul<mode>3' pattern. 
295 (define_mode_attr dee [(DF "d") (SF "ee")])
296
297 ;; In SHIFT templates, a string like "s<lr>dl" will expand to "sldl" in 
298 ;; 'ashift' and "srdl" in 'lshiftrt'.
299 (define_code_attr lr [(ashift "l") (lshiftrt "r")])
300
301 ;; In SHIFT templates, this attribute holds the correct standard name for the
302 ;; pattern itself and the corresponding function calls. 
303 (define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
304
305 ;; This attribute handles differences in the instruction 'type' and will result
306 ;; in "RRE" for DImode and "RR" for SImode.
307 (define_mode_attr E [(DI "E") (SI "")])
308
309 ;; In GPR templates, a string like "lc<g>r" will expand to "lcgr" in DImode
310 ;; and "lcr" in SImode.
311 (define_mode_attr g [(DI "g") (SI "")])
312
313 ;; In GPR templates, a string like "c<gf>dbr" will expand to "cgdbr" in DImode
314 ;; and "cfdbr" in SImode.
315 (define_mode_attr gf [(DI "g") (SI "f")])
316
317 ;; ICM mask required to load MODE value into the highest subreg
318 ;; of a SImode register.
319 (define_mode_attr icm_hi [(HI "12") (QI "8")])
320
321 ;; ICM mask required to load MODE value into the lowest subreg
322 ;; of a SImode register.
323 (define_mode_attr icm_lo [(HI "3") (QI "1")])
324
325 ;; In HQI templates, a string like "llg<hc>" will expand to "llgh" in
326 ;; HImode and "llgc" in QImode.
327 (define_mode_attr hc [(HI "h") (QI "c")])
328
329 ;; Maximum unsigned integer that fits in MODE.
330 (define_mode_attr max_uint [(HI "65535") (QI "255")])
331
332
333 ;;
334 ;;- Compare instructions.
335 ;;
336
337 (define_expand "cmp<mode>"
338   [(set (reg:CC CC_REGNUM)
339         (compare:CC (match_operand:GPR 0 "register_operand" "")
340                     (match_operand:GPR 1 "general_operand" "")))]
341   ""
342 {
343   s390_compare_op0 = operands[0];
344   s390_compare_op1 = operands[1];
345   DONE;
346 })
347
348 (define_expand "cmp<mode>"
349   [(set (reg:CC CC_REGNUM)
350         (compare:CC (match_operand:FPR 0 "register_operand" "")
351                     (match_operand:FPR 1 "general_operand" "")))]
352   "TARGET_HARD_FLOAT"
353 {
354   s390_compare_op0 = operands[0];
355   s390_compare_op1 = operands[1];
356   DONE;
357 })
358
359
360 ; Test-under-Mask instructions
361
362 (define_insn "*tmqi_mem"
363   [(set (reg CC_REGNUM)
364         (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
365                          (match_operand:QI 1 "immediate_operand" "n,n"))
366                  (match_operand:QI 2 "immediate_operand" "n,n")))]
367   "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
368   "@
369    tm\t%S0,%b1
370    tmy\t%S0,%b1"
371   [(set_attr "op_type" "SI,SIY")])
372
373 (define_insn "*tmdi_reg"
374   [(set (reg CC_REGNUM)
375         (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
376                          (match_operand:DI 1 "immediate_operand"
377                                              "N0HD0,N1HD0,N2HD0,N3HD0"))
378                  (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
379   "TARGET_64BIT
380    && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
381    && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
382   "@
383    tmhh\t%0,%i1
384    tmhl\t%0,%i1
385    tmlh\t%0,%i1
386    tmll\t%0,%i1"
387   [(set_attr "op_type" "RI")])
388
389 (define_insn "*tmsi_reg"
390   [(set (reg CC_REGNUM)
391         (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
392                          (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
393                  (match_operand:SI 2 "immediate_operand" "n,n")))]
394   "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
395    && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
396   "@
397    tmh\t%0,%i1
398    tml\t%0,%i1"
399   [(set_attr "op_type" "RI")])
400
401 (define_insn "*tm<mode>_full"
402   [(set (reg CC_REGNUM)
403         (compare (match_operand:HQI 0 "register_operand" "d")
404                  (match_operand:HQI 1 "immediate_operand" "n")))]
405   "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
406   "tml\t%0,<max_uint>"
407   [(set_attr "op_type" "RI")])
408
409
410 ; Load-and-Test instructions
411
412 (define_insn "*tstdi_sign"
413   [(set (reg CC_REGNUM)
414         (compare (ashiftrt:DI (ashift:DI (subreg:DI (match_operand:SI 0 "register_operand" "d") 0)
415                                          (const_int 32)) (const_int 32))
416                  (match_operand:DI 1 "const0_operand" "")))
417    (set (match_operand:DI 2 "register_operand" "=d")
418         (sign_extend:DI (match_dup 0)))]
419   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
420   "ltgfr\t%2,%0"
421   [(set_attr "op_type" "RRE")])
422
423 (define_insn "*tstdi"
424   [(set (reg CC_REGNUM)
425         (compare (match_operand:DI 0 "register_operand" "d")
426                  (match_operand:DI 1 "const0_operand" "")))
427    (set (match_operand:DI 2 "register_operand" "=d")
428         (match_dup 0))]
429   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
430   "ltgr\t%2,%0"
431   [(set_attr "op_type" "RRE")])
432
433 (define_insn "*tstdi_cconly"
434   [(set (reg CC_REGNUM)
435         (compare (match_operand:DI 0 "register_operand" "d")
436                  (match_operand:DI 1 "const0_operand" "")))]
437   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
438   "ltgr\t%0,%0"
439   [(set_attr "op_type" "RRE")])
440
441 (define_insn "*tstdi_cconly_31"
442   [(set (reg CC_REGNUM)
443         (compare (match_operand:DI 0 "register_operand" "d")
444                  (match_operand:DI 1 "const0_operand" "")))]
445   "s390_match_ccmode(insn, CCSmode) && !TARGET_64BIT"
446   "srda\t%0,0"
447   [(set_attr "op_type" "RS")
448    (set_attr "atype"   "reg")])
449
450
451 (define_insn "*tstsi"
452   [(set (reg CC_REGNUM)
453         (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
454                  (match_operand:SI 1 "const0_operand" "")))
455    (set (match_operand:SI 2 "register_operand" "=d,d,d")
456         (match_dup 0))]
457   "s390_match_ccmode(insn, CCSmode)"
458   "@
459    ltr\t%2,%0
460    icm\t%2,15,%S0
461    icmy\t%2,15,%S0"
462   [(set_attr "op_type" "RR,RS,RSY")])
463
464 (define_insn "*tstsi_cconly"
465   [(set (reg CC_REGNUM)
466         (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
467                  (match_operand:SI 1 "const0_operand" "")))
468    (clobber (match_scratch:SI 2 "=X,d,d"))]
469   "s390_match_ccmode(insn, CCSmode)"
470   "@
471    ltr\t%0,%0
472    icm\t%2,15,%S0
473    icmy\t%2,15,%S0"
474   [(set_attr "op_type" "RR,RS,RSY")])
475
476 (define_insn "*tstsi_cconly2"
477   [(set (reg CC_REGNUM)
478         (compare (match_operand:SI 0 "register_operand" "d")
479                  (match_operand:SI 1 "const0_operand" "")))]
480   "s390_match_ccmode(insn, CCSmode)"
481   "ltr\t%0,%0"
482   [(set_attr "op_type" "RR")])
483
484 (define_insn "*tst<mode>CCT"
485   [(set (reg CC_REGNUM)
486         (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
487                  (match_operand:HQI 1 "const0_operand" "")))
488    (set (match_operand:HQI 2 "register_operand" "=d,d,0")
489         (match_dup 0))]
490   "s390_match_ccmode(insn, CCTmode)"
491   "@
492    icm\t%2,<icm_lo>,%S0
493    icmy\t%2,<icm_lo>,%S0
494    tml\t%0,<max_uint>"
495   [(set_attr "op_type" "RS,RSY,RI")])
496
497 (define_insn "*tsthiCCT_cconly"
498   [(set (reg CC_REGNUM)
499         (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
500                  (match_operand:HI 1 "const0_operand" "")))
501    (clobber (match_scratch:HI 2 "=d,d,X"))]
502   "s390_match_ccmode(insn, CCTmode)"
503   "@
504    icm\t%2,3,%S0
505    icmy\t%2,3,%S0
506    tml\t%0,65535"
507   [(set_attr "op_type" "RS,RSY,RI")])
508
509 (define_insn "*tstqiCCT_cconly"
510   [(set (reg CC_REGNUM)
511         (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
512                  (match_operand:QI 1 "const0_operand" "")))]
513   "s390_match_ccmode(insn, CCTmode)"
514   "@
515    cli\t%S0,0
516    cliy\t%S0,0
517    tml\t%0,255"
518   [(set_attr "op_type" "SI,SIY,RI")])
519
520 (define_insn "*tst<mode>"
521   [(set (reg CC_REGNUM)
522         (compare (match_operand:HQI 0 "s_operand" "Q,S")
523                  (match_operand:HQI 1 "const0_operand" "")))
524    (set (match_operand:HQI 2 "register_operand" "=d,d")
525         (match_dup 0))]
526   "s390_match_ccmode(insn, CCSmode)"
527   "@
528    icm\t%2,<icm_lo>,%S0
529    icmy\t%2,<icm_lo>,%S0"
530   [(set_attr "op_type" "RS,RSY")])
531
532 (define_insn "*tst<mode>_cconly"
533   [(set (reg CC_REGNUM)
534         (compare (match_operand:HQI 0 "s_operand" "Q,S")
535                  (match_operand:HQI 1 "const0_operand" "")))
536    (clobber (match_scratch:HQI 2 "=d,d"))]
537   "s390_match_ccmode(insn, CCSmode)"
538   "@
539    icm\t%2,<icm_lo>,%S0
540    icmy\t%2,<icm_lo>,%S0"
541   [(set_attr "op_type" "RS,RSY")])
542
543
544 ; Compare (equality) instructions
545
546 (define_insn "*cmpdi_cct"
547   [(set (reg CC_REGNUM)
548         (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,Q")
549                  (match_operand:DI 1 "general_operand" "d,K,m,BQ")))]
550   "s390_match_ccmode (insn, CCTmode) && TARGET_64BIT"
551   "@
552    cgr\t%0,%1
553    cghi\t%0,%h1
554    cg\t%0,%1
555    #"
556   [(set_attr "op_type" "RRE,RI,RXY,SS")])
557
558 (define_insn "*cmpsi_cct"
559   [(set (reg CC_REGNUM)
560         (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,Q")
561                  (match_operand:SI 1 "general_operand" "d,K,R,T,BQ")))]
562   "s390_match_ccmode (insn, CCTmode)"
563   "@
564    cr\t%0,%1
565    chi\t%0,%h1
566    c\t%0,%1
567    cy\t%0,%1
568    #"
569   [(set_attr "op_type" "RR,RI,RX,RXY,SS")])
570
571
572 ; Compare (signed) instructions
573
574 (define_insn "*cmpdi_ccs_sign"
575   [(set (reg CC_REGNUM)
576         (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m"))
577                  (match_operand:DI 0 "register_operand" "d,d")))]
578   "s390_match_ccmode(insn, CCSRmode) && TARGET_64BIT"
579   "@
580    cgfr\t%0,%1
581    cgf\t%0,%1"
582   [(set_attr "op_type" "RRE,RXY")])
583
584 (define_insn "*cmpdi_ccs"
585   [(set (reg CC_REGNUM)
586         (compare (match_operand:DI 0 "register_operand" "d,d,d")
587                  (match_operand:DI 1 "general_operand" "d,K,m")))]
588   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
589   "@
590    cgr\t%0,%1
591    cghi\t%0,%h1
592    cg\t%0,%1"
593   [(set_attr "op_type" "RRE,RI,RXY")])
594
595 (define_insn "*cmpsi_ccs_sign"
596   [(set (reg CC_REGNUM)
597         (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T"))
598                  (match_operand:SI 0 "register_operand" "d,d")))]
599   "s390_match_ccmode(insn, CCSRmode)"
600   "@
601    ch\t%0,%1
602    chy\t%0,%1"
603   [(set_attr "op_type" "RX,RXY")])
604
605 (define_insn "*cmpsi_ccs"
606   [(set (reg CC_REGNUM)
607         (compare (match_operand:SI 0 "register_operand" "d,d,d,d")
608                  (match_operand:SI 1 "general_operand" "d,K,R,T")))]
609   "s390_match_ccmode(insn, CCSmode)"
610   "@
611    cr\t%0,%1
612    chi\t%0,%h1
613    c\t%0,%1
614    cy\t%0,%1"
615   [(set_attr "op_type" "RR,RI,RX,RXY")])
616
617
618 ; Compare (unsigned) instructions
619
620 (define_insn "*cmpdi_ccu_zero"
621   [(set (reg CC_REGNUM)
622         (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m"))
623                  (match_operand:DI 0 "register_operand" "d,d")))]
624   "s390_match_ccmode (insn, CCURmode) && TARGET_64BIT"
625   "@
626    clgfr\t%0,%1
627    clgf\t%0,%1"
628   [(set_attr "op_type" "RRE,RXY")])
629
630 (define_insn "*cmpdi_ccu"
631   [(set (reg CC_REGNUM)
632         (compare (match_operand:DI 0 "nonimmediate_operand" "d,d,Q,BQ")
633                  (match_operand:DI 1 "general_operand" "d,m,BQ,Q")))]
634   "s390_match_ccmode (insn, CCUmode) && TARGET_64BIT"
635   "@
636    clgr\t%0,%1
637    clg\t%0,%1
638    #
639    #"
640   [(set_attr "op_type" "RRE,RXY,SS,SS")])
641
642 (define_insn "*cmpsi_ccu"
643   [(set (reg CC_REGNUM)
644         (compare (match_operand:SI 0 "nonimmediate_operand" "d,d,d,Q,BQ")
645                  (match_operand:SI 1 "general_operand" "d,R,T,BQ,Q")))]
646   "s390_match_ccmode (insn, CCUmode)"
647   "@
648    clr\t%0,%1
649    cl\t%0,%1
650    cly\t%0,%1
651    #
652    #"
653   [(set_attr "op_type" "RR,RX,RXY,SS,SS")])
654
655 (define_insn "*cmphi_ccu"
656   [(set (reg CC_REGNUM)
657         (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,BQ")
658                  (match_operand:HI 1 "general_operand" "Q,S,BQ,Q")))]
659   "s390_match_ccmode (insn, CCUmode)
660    && !register_operand (operands[1], HImode)"
661   "@
662    clm\t%0,3,%S1
663    clmy\t%0,3,%S1
664    #
665    #"
666   [(set_attr "op_type" "RS,RSY,SS,SS")])
667
668 (define_insn "*cmpqi_ccu"
669   [(set (reg CC_REGNUM)
670         (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
671                  (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
672   "s390_match_ccmode (insn, CCUmode)
673    && !register_operand (operands[1], QImode)"
674   "@
675    clm\t%0,1,%S1
676    clmy\t%0,1,%S1
677    cli\t%S0,%b1
678    cliy\t%S0,%b1
679    #
680    #"
681   [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")])
682
683
684 ; Block compare (CLC) instruction patterns.
685
686 (define_insn "*clc"
687   [(set (reg CC_REGNUM)
688         (compare (match_operand:BLK 0 "memory_operand" "Q")
689                  (match_operand:BLK 1 "memory_operand" "Q")))
690    (use (match_operand 2 "const_int_operand" "n"))]
691   "s390_match_ccmode (insn, CCUmode)
692    && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
693   "clc\t%O0(%2,%R0),%S1"
694   [(set_attr "op_type" "SS")])
695
696 (define_split
697   [(set (reg CC_REGNUM)
698         (compare (match_operand 0 "memory_operand" "")
699                  (match_operand 1 "memory_operand" "")))]
700   "reload_completed
701    && s390_match_ccmode (insn, CCUmode)
702    && GET_MODE (operands[0]) == GET_MODE (operands[1])
703    && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
704   [(parallel
705     [(set (match_dup 0) (match_dup 1))
706      (use (match_dup 2))])]
707 {
708   operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
709   operands[0] = adjust_address (operands[0], BLKmode, 0);
710   operands[1] = adjust_address (operands[1], BLKmode, 0);
711
712   operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
713                                  operands[0], operands[1]);
714   operands[0] = SET_DEST (PATTERN (curr_insn));
715 })
716
717
718 ; (DF|SF) instructions
719
720 (define_insn "*cmp<mode>_ccs_0"
721   [(set (reg CC_REGNUM)
722         (compare (match_operand:FPR 0 "register_operand" "f")
723                  (match_operand:FPR 1 "const0_operand" "")))]
724   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
725   "lt<de>br\t%0,%0"
726    [(set_attr "op_type" "RRE")
727     (set_attr "type"  "fsimp<mode>")])
728
729 (define_insn "*cmp<mode>_ccs_0_ibm"
730   [(set (reg CC_REGNUM)
731         (compare (match_operand:FPR 0 "register_operand" "f")
732                  (match_operand:FPR 1 "const0_operand" "")))]
733   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
734   "lt<de>r\t%0,%0"
735    [(set_attr "op_type" "RR")
736     (set_attr "type"  "fsimp<mode>")])
737
738 (define_insn "*cmp<mode>_ccs"
739   [(set (reg CC_REGNUM)
740         (compare (match_operand:FPR 0 "register_operand" "f,f")
741                  (match_operand:FPR 1 "general_operand" "f,R")))]
742   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
743   "@
744    c<de>br\t%0,%1
745    c<de>b\t%0,%1"
746    [(set_attr "op_type" "RRE,RXE")
747     (set_attr "type"  "fsimp<mode>")])
748
749 (define_insn "*cmp<mode>_ccs_ibm"
750   [(set (reg CC_REGNUM)
751         (compare (match_operand:FPR 0 "register_operand" "f,f")
752                  (match_operand:FPR 1 "general_operand" "f,R")))]
753   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
754   "@
755    c<de>r\t%0,%1
756    c<de>\t%0,%1"
757    [(set_attr "op_type" "RR,RX")
758     (set_attr "type"  "fsimp<mode>")])
759
760
761 ;;
762 ;;- Move instructions.
763 ;;
764
765 ;
766 ; movti instruction pattern(s).
767 ;
768
769 (define_insn "movti"
770   [(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o,Q")
771         (match_operand:TI 1 "general_operand" "QS,d,dKm,d,Q"))]
772   "TARGET_64BIT"
773   "@
774    lmg\t%0,%N0,%S1
775    stmg\t%1,%N1,%S0
776    #
777    #
778    #"
779   [(set_attr "op_type" "RSY,RSY,*,*,SS")
780    (set_attr "type" "lm,stm,*,*,*")])
781
782 (define_split
783   [(set (match_operand:TI 0 "nonimmediate_operand" "")
784         (match_operand:TI 1 "general_operand" ""))]
785   "TARGET_64BIT && reload_completed
786    && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
787   [(set (match_dup 2) (match_dup 4))
788    (set (match_dup 3) (match_dup 5))]
789 {
790   operands[2] = operand_subword (operands[0], 0, 0, TImode);
791   operands[3] = operand_subword (operands[0], 1, 0, TImode);
792   operands[4] = operand_subword (operands[1], 0, 0, TImode);
793   operands[5] = operand_subword (operands[1], 1, 0, TImode);
794 })
795
796 (define_split
797   [(set (match_operand:TI 0 "nonimmediate_operand" "")
798         (match_operand:TI 1 "general_operand" ""))]
799   "TARGET_64BIT && reload_completed
800    && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
801   [(set (match_dup 2) (match_dup 4))
802    (set (match_dup 3) (match_dup 5))]
803 {
804   operands[2] = operand_subword (operands[0], 1, 0, TImode);
805   operands[3] = operand_subword (operands[0], 0, 0, TImode);
806   operands[4] = operand_subword (operands[1], 1, 0, TImode);
807   operands[5] = operand_subword (operands[1], 0, 0, TImode);
808 })
809
810 (define_split
811   [(set (match_operand:TI 0 "register_operand" "")
812         (match_operand:TI 1 "memory_operand" ""))]
813   "TARGET_64BIT && reload_completed
814    && !s_operand (operands[1], VOIDmode)"
815   [(set (match_dup 0) (match_dup 1))]
816 {
817   rtx addr = operand_subword (operands[0], 1, 0, TImode);
818   s390_load_address (addr, XEXP (operands[1], 0));
819   operands[1] = replace_equiv_address (operands[1], addr);
820 })
821
822 (define_expand "reload_outti"
823   [(parallel [(match_operand:TI 0 "" "")
824               (match_operand:TI 1 "register_operand" "d")
825               (match_operand:DI 2 "register_operand" "=&a")])]
826   "TARGET_64BIT"
827 {
828   gcc_assert (MEM_P (operands[0]));
829   s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
830   operands[0] = replace_equiv_address (operands[0], operands[2]);
831   emit_move_insn (operands[0], operands[1]);
832   DONE;
833 })
834
835 ;
836 ; movdi instruction pattern(s).
837 ;
838
839 (define_expand "movdi"
840   [(set (match_operand:DI 0 "general_operand" "")
841         (match_operand:DI 1 "general_operand" ""))]
842   ""
843 {
844   /* Handle symbolic constants.  */
845   if (TARGET_64BIT && SYMBOLIC_CONST (operands[1]))
846     emit_symbolic_move (operands);
847 })
848
849 (define_insn "*movdi_larl"
850   [(set (match_operand:DI 0 "register_operand" "=d")
851         (match_operand:DI 1 "larl_operand" "X"))]
852   "TARGET_64BIT
853    && !FP_REG_P (operands[0])"
854   "larl\t%0,%1"
855    [(set_attr "op_type" "RIL")
856     (set_attr "type"    "larl")])
857
858 (define_insn "*movdi_64"
859   [(set (match_operand:DI 0 "nonimmediate_operand"
860                             "=d,d,d,d,d,d,d,d,m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
861         (match_operand:DI 1 "general_operand"
862                             "K,N0HD0,N1HD0,N2HD0,N3HD0,L,d,m,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
863   "TARGET_64BIT"
864   "@
865    lghi\t%0,%h1
866    llihh\t%0,%i1
867    llihl\t%0,%i1
868    llilh\t%0,%i1
869    llill\t%0,%i1
870    lay\t%0,%a1
871    lgr\t%0,%1
872    lg\t%0,%1
873    stg\t%1,%0
874    ldr\t%0,%1
875    ld\t%0,%1
876    ldy\t%0,%1
877    std\t%1,%0
878    stdy\t%1,%0
879    #
880    #
881    stam\t%1,%N1,%S0
882    lam\t%0,%N0,%S1
883    #"
884   [(set_attr "op_type" "RI,RI,RI,RI,RI,RXY,RRE,RXY,RXY,
885                         RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
886    (set_attr "type" "*,*,*,*,*,la,lr,load,store,
887                      floaddf,floaddf,floaddf,fstoredf,fstoredf,*,*,*,*,*")])
888
889 (define_split
890   [(set (match_operand:DI 0 "register_operand" "")
891         (match_operand:DI 1 "register_operand" ""))]
892   "TARGET_64BIT && ACCESS_REG_P (operands[1])"
893   [(set (match_dup 2) (match_dup 3))
894    (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
895    (set (strict_low_part (match_dup 2)) (match_dup 4))]
896   "operands[2] = gen_lowpart (SImode, operands[0]);
897    s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
898
899 (define_split
900   [(set (match_operand:DI 0 "register_operand" "")
901         (match_operand:DI 1 "register_operand" ""))]
902   "TARGET_64BIT && ACCESS_REG_P (operands[0])
903    && dead_or_set_p (insn, operands[1])"
904   [(set (match_dup 3) (match_dup 2))
905    (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
906    (set (match_dup 4) (match_dup 2))]
907   "operands[2] = gen_lowpart (SImode, operands[1]);
908    s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
909
910 (define_split
911   [(set (match_operand:DI 0 "register_operand" "")
912         (match_operand:DI 1 "register_operand" ""))]
913   "TARGET_64BIT && ACCESS_REG_P (operands[0])
914    && !dead_or_set_p (insn, operands[1])"
915   [(set (match_dup 3) (match_dup 2))
916    (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
917    (set (match_dup 4) (match_dup 2))
918    (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
919   "operands[2] = gen_lowpart (SImode, operands[1]);
920    s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
921
922 (define_insn "*movdi_31"
923   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,Q,d,o,!*f,!*f,!*f,!R,!T,Q")
924         (match_operand:DI 1 "general_operand" "Q,d,dKm,d,*f,R,T,*f,*f,Q"))]
925   "!TARGET_64BIT"
926   "@
927    lm\t%0,%N0,%S1
928    stm\t%1,%N1,%S0
929    #
930    #
931    ldr\t%0,%1
932    ld\t%0,%1
933    ldy\t%0,%1
934    std\t%1,%0
935    stdy\t%1,%0
936    #"
937   [(set_attr "op_type" "RS,RS,*,*,RR,RX,RXY,RX,RXY,SS")
938    (set_attr "type" "lm,stm,*,*,floaddf,floaddf,floaddf,fstoredf,fstoredf,*")])
939
940 (define_split
941   [(set (match_operand:DI 0 "nonimmediate_operand" "")
942         (match_operand:DI 1 "general_operand" ""))]
943   "!TARGET_64BIT && reload_completed
944    && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
945   [(set (match_dup 2) (match_dup 4))
946    (set (match_dup 3) (match_dup 5))]
947 {
948   operands[2] = operand_subword (operands[0], 0, 0, DImode);
949   operands[3] = operand_subword (operands[0], 1, 0, DImode);
950   operands[4] = operand_subword (operands[1], 0, 0, DImode);
951   operands[5] = operand_subword (operands[1], 1, 0, DImode);
952 })
953
954 (define_split
955   [(set (match_operand:DI 0 "nonimmediate_operand" "")
956         (match_operand:DI 1 "general_operand" ""))]
957   "!TARGET_64BIT && reload_completed
958    && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
959   [(set (match_dup 2) (match_dup 4))
960    (set (match_dup 3) (match_dup 5))]
961 {
962   operands[2] = operand_subword (operands[0], 1, 0, DImode);
963   operands[3] = operand_subword (operands[0], 0, 0, DImode);
964   operands[4] = operand_subword (operands[1], 1, 0, DImode);
965   operands[5] = operand_subword (operands[1], 0, 0, DImode);
966 })
967
968 (define_split
969   [(set (match_operand:DI 0 "register_operand" "")
970         (match_operand:DI 1 "memory_operand" ""))]
971   "!TARGET_64BIT && reload_completed
972    && !FP_REG_P (operands[0])
973    && !s_operand (operands[1], VOIDmode)"
974   [(set (match_dup 0) (match_dup 1))]
975 {
976   rtx addr = operand_subword (operands[0], 1, 0, DImode);
977   s390_load_address (addr, XEXP (operands[1], 0));
978   operands[1] = replace_equiv_address (operands[1], addr);
979 })
980
981 (define_expand "reload_outdi"
982   [(parallel [(match_operand:DI 0 "" "")
983               (match_operand:DI 1 "register_operand" "d")
984               (match_operand:SI 2 "register_operand" "=&a")])]
985   "!TARGET_64BIT"
986 {
987   gcc_assert (MEM_P (operands[0]));
988   s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
989   operands[0] = replace_equiv_address (operands[0], operands[2]);
990   emit_move_insn (operands[0], operands[1]);
991   DONE;
992 })
993
994 (define_peephole2
995   [(set (match_operand:DI 0 "register_operand" "")
996         (mem:DI (match_operand 1 "address_operand" "")))]
997   "TARGET_64BIT
998    && !FP_REG_P (operands[0])
999    && GET_CODE (operands[1]) == SYMBOL_REF
1000    && CONSTANT_POOL_ADDRESS_P (operands[1])
1001    && get_pool_mode (operands[1]) == DImode
1002    && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1003   [(set (match_dup 0) (match_dup 2))]
1004   "operands[2] = get_pool_constant (operands[1]);")
1005
1006 (define_insn "*la_64"
1007   [(set (match_operand:DI 0 "register_operand" "=d,d")
1008         (match_operand:QI 1 "address_operand" "U,W"))]
1009   "TARGET_64BIT"
1010   "@
1011    la\t%0,%a1
1012    lay\t%0,%a1"
1013   [(set_attr "op_type" "RX,RXY")
1014    (set_attr "type"    "la")])
1015
1016 (define_peephole2
1017   [(parallel
1018     [(set (match_operand:DI 0 "register_operand" "")
1019           (match_operand:QI 1 "address_operand" ""))
1020      (clobber (reg:CC CC_REGNUM))])]
1021   "TARGET_64BIT
1022    && preferred_la_operand_p (operands[1], const0_rtx)"
1023   [(set (match_dup 0) (match_dup 1))]
1024   "")
1025
1026 (define_peephole2
1027   [(set (match_operand:DI 0 "register_operand" "")
1028         (match_operand:DI 1 "register_operand" ""))
1029    (parallel
1030     [(set (match_dup 0)
1031           (plus:DI (match_dup 0)
1032                    (match_operand:DI 2 "nonmemory_operand" "")))
1033      (clobber (reg:CC CC_REGNUM))])]
1034   "TARGET_64BIT
1035    && !reg_overlap_mentioned_p (operands[0], operands[2])
1036    && preferred_la_operand_p (operands[1], operands[2])"
1037   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1038   "")
1039
1040 (define_expand "reload_indi"
1041   [(parallel [(match_operand:DI 0 "register_operand" "=a")
1042               (match_operand:DI 1 "s390_plus_operand" "")
1043               (match_operand:DI 2 "register_operand" "=&a")])]
1044   "TARGET_64BIT"
1045 {
1046   s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1047   DONE;
1048 })
1049
1050 ;
1051 ; movsi instruction pattern(s).
1052 ;
1053
1054 (define_expand "movsi"
1055   [(set (match_operand:SI 0 "general_operand" "")
1056         (match_operand:SI 1 "general_operand" ""))]
1057   ""
1058 {
1059   /* Handle symbolic constants.  */
1060   if (!TARGET_64BIT && SYMBOLIC_CONST (operands[1]))
1061     emit_symbolic_move (operands);
1062 })
1063
1064 (define_insn "*movsi_larl"
1065   [(set (match_operand:SI 0 "register_operand" "=d")
1066         (match_operand:SI 1 "larl_operand" "X"))]
1067   "!TARGET_64BIT && TARGET_CPU_ZARCH
1068    && !FP_REG_P (operands[0])"
1069   "larl\t%0,%1"
1070    [(set_attr "op_type" "RIL")
1071     (set_attr "type"    "larl")])
1072
1073 (define_insn "*movsi_zarch"
1074   [(set (match_operand:SI 0 "nonimmediate_operand"
1075                             "=d,d,d,d,d,d,d,R,T,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
1076         (match_operand:SI 1 "general_operand"
1077                             "K,N0HS0,N1HS0,L,d,R,T,d,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
1078   "TARGET_ZARCH"
1079   "@
1080    lhi\t%0,%h1
1081    llilh\t%0,%i1
1082    llill\t%0,%i1
1083    lay\t%0,%a1
1084    lr\t%0,%1
1085    l\t%0,%1
1086    ly\t%0,%1
1087    st\t%1,%0
1088    sty\t%1,%0
1089    ler\t%0,%1
1090    le\t%0,%1
1091    ley\t%0,%1
1092    ste\t%1,%0
1093    stey\t%1,%0
1094    ear\t%0,%1
1095    sar\t%0,%1
1096    stam\t%1,%1,%S0
1097    lam\t%0,%0,%S1
1098    #"
1099   [(set_attr "op_type" "RI,RI,RI,RXY,RR,RX,RXY,RX,RXY,
1100                         RR,RX,RXY,RX,RXY,RRE,RRE,RS,RS,SS")
1101    (set_attr "type" "*,*,*,la,lr,load,load,store,store,
1102                      floadsf,floadsf,floadsf,fstoresf,fstoresf,*,*,*,*,*")])
1103
1104 (define_insn "*movsi_esa"
1105   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!R,d,t,Q,t,?Q")
1106         (match_operand:SI 1 "general_operand" "K,d,R,d,*f,R,*f,t,d,t,Q,?Q"))]
1107   "!TARGET_ZARCH"
1108   "@
1109    lhi\t%0,%h1
1110    lr\t%0,%1
1111    l\t%0,%1
1112    st\t%1,%0
1113    ler\t%0,%1
1114    le\t%0,%1
1115    ste\t%1,%0
1116    ear\t%0,%1
1117    sar\t%0,%1
1118    stam\t%1,%1,%S0
1119    lam\t%0,%0,%S1
1120    #"
1121   [(set_attr "op_type" "RI,RR,RX,RX,RR,RX,RX,RRE,RRE,RS,RS,SS")
1122    (set_attr "type" "*,lr,load,store,floadsf,floadsf,fstoresf,*,*,*,*,*")])
1123
1124 (define_peephole2
1125   [(set (match_operand:SI 0 "register_operand" "")
1126         (mem:SI (match_operand 1 "address_operand" "")))]
1127   "!FP_REG_P (operands[0])
1128    && GET_CODE (operands[1]) == SYMBOL_REF
1129    && CONSTANT_POOL_ADDRESS_P (operands[1])
1130    && get_pool_mode (operands[1]) == SImode
1131    && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1132   [(set (match_dup 0) (match_dup 2))]
1133   "operands[2] = get_pool_constant (operands[1]);")
1134
1135 (define_insn "*la_31"
1136   [(set (match_operand:SI 0 "register_operand" "=d,d")
1137         (match_operand:QI 1 "address_operand" "U,W"))]
1138   "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
1139   "@
1140    la\t%0,%a1
1141    lay\t%0,%a1"
1142   [(set_attr "op_type"  "RX,RXY")
1143    (set_attr "type"     "la")])
1144
1145 (define_peephole2
1146   [(parallel
1147     [(set (match_operand:SI 0 "register_operand" "")
1148           (match_operand:QI 1 "address_operand" ""))
1149      (clobber (reg:CC CC_REGNUM))])]
1150   "!TARGET_64BIT
1151    && preferred_la_operand_p (operands[1], const0_rtx)"
1152   [(set (match_dup 0) (match_dup 1))]
1153   "")
1154
1155 (define_peephole2
1156   [(set (match_operand:SI 0 "register_operand" "")
1157         (match_operand:SI 1 "register_operand" ""))
1158    (parallel
1159     [(set (match_dup 0)
1160           (plus:SI (match_dup 0)
1161                    (match_operand:SI 2 "nonmemory_operand" "")))
1162      (clobber (reg:CC CC_REGNUM))])]
1163   "!TARGET_64BIT
1164    && !reg_overlap_mentioned_p (operands[0], operands[2])
1165    && preferred_la_operand_p (operands[1], operands[2])"
1166   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
1167   "")
1168
1169 (define_insn "*la_31_and"
1170   [(set (match_operand:SI 0 "register_operand" "=d,d")
1171         (and:SI (match_operand:QI 1 "address_operand" "U,W")
1172                 (const_int 2147483647)))]
1173   "!TARGET_64BIT"
1174   "@
1175    la\t%0,%a1
1176    lay\t%0,%a1"
1177   [(set_attr "op_type"  "RX,RXY")
1178    (set_attr "type"     "la")])
1179
1180 (define_insn_and_split "*la_31_and_cc"
1181   [(set (match_operand:SI 0 "register_operand" "=d")
1182         (and:SI (match_operand:QI 1 "address_operand" "p")
1183                 (const_int 2147483647)))
1184    (clobber (reg:CC CC_REGNUM))]
1185   "!TARGET_64BIT"
1186   "#"
1187   "&& reload_completed"
1188   [(set (match_dup 0)
1189         (and:SI (match_dup 1) (const_int 2147483647)))]
1190   ""
1191   [(set_attr "op_type"  "RX")
1192    (set_attr "type"     "la")])
1193
1194 (define_insn "force_la_31"
1195   [(set (match_operand:SI 0 "register_operand" "=d,d")
1196         (match_operand:QI 1 "address_operand" "U,W"))
1197    (use (const_int 0))]
1198   "!TARGET_64BIT"
1199   "@
1200    la\t%0,%a1
1201    lay\t%0,%a1"
1202   [(set_attr "op_type"  "RX")
1203    (set_attr "type"     "la")])
1204
1205 (define_expand "reload_insi"
1206   [(parallel [(match_operand:SI 0 "register_operand" "=a")
1207               (match_operand:SI 1 "s390_plus_operand" "")
1208               (match_operand:SI 2 "register_operand" "=&a")])]
1209   "!TARGET_64BIT"
1210 {
1211   s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1212   DONE;
1213 })
1214
1215 ;
1216 ; movhi instruction pattern(s).
1217 ;
1218
1219 (define_expand "movhi"
1220   [(set (match_operand:HI 0 "nonimmediate_operand" "")
1221         (match_operand:HI 1 "general_operand" ""))]
1222   ""
1223 {
1224   /* Make it explicit that loading a register from memory
1225      always sign-extends (at least) to SImode.  */
1226   if (optimize && !no_new_pseudos
1227       && register_operand (operands[0], VOIDmode)
1228       && GET_CODE (operands[1]) == MEM)
1229     {
1230       rtx tmp = gen_reg_rtx (SImode);
1231       rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
1232       emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1233       operands[1] = gen_lowpart (HImode, tmp);
1234     }
1235 })
1236
1237 (define_insn "*movhi"
1238   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,R,T,?Q")
1239         (match_operand:HI 1 "general_operand" "d,n,R,T,d,d,?Q"))]
1240   ""
1241   "@
1242    lr\t%0,%1
1243    lhi\t%0,%h1
1244    lh\t%0,%1
1245    lhy\t%0,%1
1246    sth\t%1,%0
1247    sthy\t%1,%0
1248    #"
1249   [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SS")
1250    (set_attr "type" "lr,*,*,*,store,store,*")])
1251
1252 (define_peephole2
1253   [(set (match_operand:HI 0 "register_operand" "")
1254         (mem:HI (match_operand 1 "address_operand" "")))]
1255   "GET_CODE (operands[1]) == SYMBOL_REF
1256    && CONSTANT_POOL_ADDRESS_P (operands[1])
1257    && get_pool_mode (operands[1]) == HImode
1258    && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1259   [(set (match_dup 0) (match_dup 2))]
1260   "operands[2] = get_pool_constant (operands[1]);")
1261
1262 ;
1263 ; movqi instruction pattern(s).
1264 ;
1265
1266 (define_expand "movqi"
1267   [(set (match_operand:QI 0 "nonimmediate_operand" "")
1268         (match_operand:QI 1 "general_operand" ""))]
1269   ""
1270 {
1271   /* On z/Architecture, zero-extending from memory to register
1272      is just as fast as a QImode load.  */
1273   if (TARGET_ZARCH && optimize && !no_new_pseudos
1274       && register_operand (operands[0], VOIDmode)
1275       && GET_CODE (operands[1]) == MEM)
1276     {
1277       rtx tmp = gen_reg_rtx (word_mode);
1278       rtx ext = gen_rtx_ZERO_EXTEND (word_mode, operands[1]);
1279       emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1280       operands[1] = gen_lowpart (QImode, tmp);
1281     }
1282 })
1283
1284 (define_insn "*movqi"
1285   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q")
1286         (match_operand:QI 1 "general_operand" "d,n,R,T,d,d,n,n,?Q"))]
1287   ""
1288   "@
1289    lr\t%0,%1
1290    lhi\t%0,%b1
1291    ic\t%0,%1
1292    icy\t%0,%1
1293    stc\t%1,%0
1294    stcy\t%1,%0
1295    mvi\t%S0,%b1
1296    mviy\t%S0,%b1
1297    #"
1298   [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS")
1299    (set_attr "type" "lr,*,*,*,store,store,store,store,*")])
1300
1301 (define_peephole2
1302   [(set (match_operand:QI 0 "nonimmediate_operand" "")
1303         (mem:QI (match_operand 1 "address_operand" "")))]
1304   "GET_CODE (operands[1]) == SYMBOL_REF
1305    && CONSTANT_POOL_ADDRESS_P (operands[1])
1306    && get_pool_mode (operands[1]) == QImode
1307    && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1308   [(set (match_dup 0) (match_dup 2))]
1309   "operands[2] = get_pool_constant (operands[1]);")
1310
1311 ;
1312 ; movstrictqi instruction pattern(s).
1313 ;
1314
1315 (define_insn "*movstrictqi"
1316   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
1317                          (match_operand:QI 1 "memory_operand" "R,T"))]
1318   ""
1319   "@
1320    ic\t%0,%1
1321    icy\t%0,%1"
1322   [(set_attr "op_type"  "RX,RXY")])
1323
1324 ;
1325 ; movstricthi instruction pattern(s).
1326 ;
1327
1328 (define_insn "*movstricthi"
1329   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
1330                          (match_operand:HI 1 "memory_operand" "Q,S"))
1331    (clobber (reg:CC CC_REGNUM))]
1332   ""
1333   "@
1334    icm\t%0,3,%S1
1335    icmy\t%0,3,%S1"
1336   [(set_attr "op_type" "RS,RSY")])
1337
1338 ;
1339 ; movstrictsi instruction pattern(s).
1340 ;
1341
1342 (define_insn "movstrictsi"
1343   [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
1344                          (match_operand:SI 1 "general_operand" "d,R,T,t"))]
1345   "TARGET_64BIT"
1346   "@
1347    lr\t%0,%1
1348    l\t%0,%1
1349    ly\t%0,%1
1350    ear\t%0,%1"
1351   [(set_attr "op_type" "RR,RX,RXY,RRE")
1352    (set_attr "type" "lr,load,load,*")])
1353
1354 ;
1355 ; movdf instruction pattern(s).
1356 ;
1357
1358 (define_expand "movdf"
1359   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1360         (match_operand:DF 1 "general_operand"  ""))]
1361   ""
1362   "")
1363
1364 (define_insn "*movdf_64"
1365   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,R,T,d,d,m,?Q")
1366         (match_operand:DF 1 "general_operand" "f,R,T,f,f,d,m,d,?Q"))]
1367   "TARGET_64BIT"
1368   "@
1369    ldr\t%0,%1
1370    ld\t%0,%1
1371    ldy\t%0,%1
1372    std\t%1,%0
1373    stdy\t%1,%0
1374    lgr\t%0,%1
1375    lg\t%0,%1
1376    stg\t%1,%0
1377    #"
1378   [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RRE,RXY,RXY,SS")
1379    (set_attr "type" "floaddf,floaddf,floaddf,fstoredf,fstoredf,lr,load,store,*")])
1380
1381 (define_insn "*movdf_31"
1382   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,R,T,d,Q,d,o,Q")
1383         (match_operand:DF 1 "general_operand" "f,R,T,f,f,Q,d,dKm,d,Q"))]
1384   "!TARGET_64BIT"
1385   "@
1386    ldr\t%0,%1
1387    ld\t%0,%1
1388    ldy\t%0,%1
1389    std\t%1,%0
1390    stdy\t%1,%0
1391    lm\t%0,%N0,%S1
1392    stm\t%1,%N1,%S0
1393    #
1394    #
1395    #"
1396   [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RS,RS,*,*,SS")
1397    (set_attr "type" "floaddf,floaddf,floaddf,fstoredf,fstoredf,lm,stm,*,*,*")])
1398
1399 (define_split
1400   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1401         (match_operand:DF 1 "general_operand" ""))]
1402   "!TARGET_64BIT && reload_completed
1403    && s390_split_ok_p (operands[0], operands[1], DFmode, 0)"
1404   [(set (match_dup 2) (match_dup 4))
1405    (set (match_dup 3) (match_dup 5))]
1406 {
1407   operands[2] = operand_subword (operands[0], 0, 0, DFmode);
1408   operands[3] = operand_subword (operands[0], 1, 0, DFmode);
1409   operands[4] = operand_subword (operands[1], 0, 0, DFmode);
1410   operands[5] = operand_subword (operands[1], 1, 0, DFmode);
1411 })
1412
1413 (define_split
1414   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1415         (match_operand:DF 1 "general_operand" ""))]
1416   "!TARGET_64BIT && reload_completed
1417    && s390_split_ok_p (operands[0], operands[1], DFmode, 1)"
1418   [(set (match_dup 2) (match_dup 4))
1419    (set (match_dup 3) (match_dup 5))]
1420 {
1421   operands[2] = operand_subword (operands[0], 1, 0, DFmode);
1422   operands[3] = operand_subword (operands[0], 0, 0, DFmode);
1423   operands[4] = operand_subword (operands[1], 1, 0, DFmode);
1424   operands[5] = operand_subword (operands[1], 0, 0, DFmode);
1425 })
1426
1427 (define_split
1428   [(set (match_operand:DF 0 "register_operand" "")
1429         (match_operand:DF 1 "memory_operand" ""))]
1430   "!TARGET_64BIT && reload_completed
1431    && !FP_REG_P (operands[0])
1432    && !s_operand (operands[1], VOIDmode)"
1433   [(set (match_dup 0) (match_dup 1))]
1434 {
1435   rtx addr = operand_subword (operands[0], 1, 0, DFmode);
1436   s390_load_address (addr, XEXP (operands[1], 0));
1437   operands[1] = replace_equiv_address (operands[1], addr);
1438 })
1439
1440 (define_expand "reload_outdf"
1441   [(parallel [(match_operand:DF 0 "" "")
1442               (match_operand:DF 1 "register_operand" "d")
1443               (match_operand:SI 2 "register_operand" "=&a")])]
1444   "!TARGET_64BIT"
1445 {
1446   gcc_assert (MEM_P (operands[0]));
1447   s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
1448   operands[0] = replace_equiv_address (operands[0], operands[2]);
1449   emit_move_insn (operands[0], operands[1]);
1450   DONE;
1451 })
1452
1453 ;
1454 ; movsf instruction pattern(s).
1455 ;
1456
1457 (define_insn "movsf"
1458   [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,R,T,d,d,d,R,T,?Q")
1459         (match_operand:SF 1 "general_operand" "f,R,T,f,f,d,R,T,d,d,?Q"))]
1460   ""
1461   "@
1462    ler\t%0,%1
1463    le\t%0,%1
1464    ley\t%0,%1
1465    ste\t%1,%0
1466    stey\t%1,%0
1467    lr\t%0,%1
1468    l\t%0,%1
1469    ly\t%0,%1
1470    st\t%1,%0
1471    sty\t%1,%0
1472    #"
1473   [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RR,RX,RXY,RX,RXY,SS")
1474    (set_attr "type" "floadsf,floadsf,floadsf,fstoresf,fstoresf,
1475                      lr,load,load,store,store,*")])
1476
1477 ;
1478 ; movcc instruction pattern
1479 ;
1480
1481 (define_insn "movcc"
1482   [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
1483         (match_operand:CC 1 "nonimmediate_operand" "d,d,c,R,T,d,d"))]
1484   ""
1485   "@
1486    lr\t%0,%1
1487    tmh\t%1,12288
1488    ipm\t%0
1489    st\t%0,%1
1490    sty\t%0,%1
1491    l\t%1,%0
1492    ly\t%1,%0"
1493   [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
1494    (set_attr "type" "lr,*,*,store,store,load,load")])
1495
1496 ;
1497 ; Block move (MVC) patterns.
1498 ;
1499
1500 (define_insn "*mvc"
1501   [(set (match_operand:BLK 0 "memory_operand" "=Q")
1502         (match_operand:BLK 1 "memory_operand" "Q"))
1503    (use (match_operand 2 "const_int_operand" "n"))]
1504   "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
1505   "mvc\t%O0(%2,%R0),%S1"
1506   [(set_attr "op_type" "SS")])
1507
1508 (define_split
1509   [(set (match_operand 0 "memory_operand" "")
1510         (match_operand 1 "memory_operand" ""))]
1511   "reload_completed
1512    && GET_MODE (operands[0]) == GET_MODE (operands[1])
1513    && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
1514   [(parallel
1515     [(set (match_dup 0) (match_dup 1))
1516      (use (match_dup 2))])]
1517 {
1518   operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
1519   operands[0] = adjust_address (operands[0], BLKmode, 0);
1520   operands[1] = adjust_address (operands[1], BLKmode, 0);
1521 })
1522
1523 (define_peephole2
1524   [(parallel
1525     [(set (match_operand:BLK 0 "memory_operand" "")
1526           (match_operand:BLK 1 "memory_operand" ""))
1527      (use (match_operand 2 "const_int_operand" ""))])
1528    (parallel
1529     [(set (match_operand:BLK 3 "memory_operand" "")
1530           (match_operand:BLK 4 "memory_operand" ""))
1531      (use (match_operand 5 "const_int_operand" ""))])]
1532   "s390_offset_p (operands[0], operands[3], operands[2])
1533    && s390_offset_p (operands[1], operands[4], operands[2])
1534    && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
1535   [(parallel
1536     [(set (match_dup 6) (match_dup 7))
1537      (use (match_dup 8))])]
1538   "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
1539    operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
1540    operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
1541
1542
1543 ;
1544 ; load_multiple pattern(s).
1545 ;
1546 ; ??? Due to reload problems with replacing registers inside match_parallel
1547 ; we currently support load_multiple/store_multiple only after reload.
1548 ;
1549
1550 (define_expand "load_multiple"
1551   [(match_par_dup 3 [(set (match_operand 0 "" "")
1552                           (match_operand 1 "" ""))
1553                      (use (match_operand 2 "" ""))])]
1554   "reload_completed"
1555 {
1556   enum machine_mode mode;
1557   int regno;
1558   int count;
1559   rtx from;
1560   int i, off;
1561
1562   /* Support only loading a constant number of fixed-point registers from
1563      memory and only bother with this if more than two */
1564   if (GET_CODE (operands[2]) != CONST_INT
1565       || INTVAL (operands[2]) < 2
1566       || INTVAL (operands[2]) > 16
1567       || GET_CODE (operands[1]) != MEM
1568       || GET_CODE (operands[0]) != REG
1569       || REGNO (operands[0]) >= 16)
1570     FAIL;
1571
1572   count = INTVAL (operands[2]);
1573   regno = REGNO (operands[0]);
1574   mode = GET_MODE (operands[0]);
1575   if (mode != SImode && mode != word_mode)
1576     FAIL;
1577
1578   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
1579   if (no_new_pseudos)
1580     {
1581       if (GET_CODE (XEXP (operands[1], 0)) == REG)
1582         {
1583           from = XEXP (operands[1], 0);
1584           off = 0;
1585         }
1586       else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
1587                && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
1588                && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
1589         {
1590           from = XEXP (XEXP (operands[1], 0), 0);
1591           off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
1592         }
1593       else
1594         FAIL;
1595     }
1596   else
1597     {
1598       from = force_reg (Pmode, XEXP (operands[1], 0));
1599       off = 0;
1600     }
1601
1602   for (i = 0; i < count; i++)
1603     XVECEXP (operands[3], 0, i)
1604       = gen_rtx_SET (VOIDmode, gen_rtx_REG (mode, regno + i),
1605                      change_address (operands[1], mode,
1606                        plus_constant (from, off + i * GET_MODE_SIZE (mode))));
1607 })
1608
1609 (define_insn "*load_multiple_di"
1610   [(match_parallel 0 "load_multiple_operation"
1611                    [(set (match_operand:DI 1 "register_operand" "=r")
1612                          (match_operand:DI 2 "s_operand" "QS"))])]
1613   "reload_completed && word_mode == DImode"
1614 {
1615   int words = XVECLEN (operands[0], 0);
1616   operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
1617   return "lmg\t%1,%0,%S2";
1618 }
1619    [(set_attr "op_type" "RSY")
1620     (set_attr "type"    "lm")])
1621
1622 (define_insn "*load_multiple_si"
1623   [(match_parallel 0 "load_multiple_operation"
1624                    [(set (match_operand:SI 1 "register_operand" "=r,r")
1625                          (match_operand:SI 2 "s_operand" "Q,S"))])]
1626   "reload_completed"
1627 {
1628   int words = XVECLEN (operands[0], 0);
1629   operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
1630   return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
1631 }
1632    [(set_attr "op_type" "RS,RSY")
1633     (set_attr "type"    "lm")])
1634
1635 ;
1636 ; store multiple pattern(s).
1637 ;
1638
1639 (define_expand "store_multiple"
1640   [(match_par_dup 3 [(set (match_operand 0 "" "")
1641                           (match_operand 1 "" ""))
1642                      (use (match_operand 2 "" ""))])]
1643   "reload_completed"
1644 {
1645   enum machine_mode mode;
1646   int regno;
1647   int count;
1648   rtx to;
1649   int i, off;
1650
1651   /* Support only storing a constant number of fixed-point registers to
1652      memory and only bother with this if more than two.  */
1653   if (GET_CODE (operands[2]) != CONST_INT
1654       || INTVAL (operands[2]) < 2
1655       || INTVAL (operands[2]) > 16
1656       || GET_CODE (operands[0]) != MEM
1657       || GET_CODE (operands[1]) != REG
1658       || REGNO (operands[1]) >= 16)
1659     FAIL;
1660
1661   count = INTVAL (operands[2]);
1662   regno = REGNO (operands[1]);
1663   mode = GET_MODE (operands[1]);
1664   if (mode != SImode && mode != word_mode)
1665     FAIL;
1666
1667   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
1668
1669   if (no_new_pseudos)
1670     {
1671       if (GET_CODE (XEXP (operands[0], 0)) == REG)
1672         {
1673           to = XEXP (operands[0], 0);
1674           off = 0;
1675         }
1676       else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
1677                && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
1678                && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
1679         {
1680           to = XEXP (XEXP (operands[0], 0), 0);
1681           off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
1682         }
1683       else
1684         FAIL;
1685     }
1686   else
1687     {
1688       to = force_reg (Pmode, XEXP (operands[0], 0));
1689       off = 0;
1690     }
1691
1692   for (i = 0; i < count; i++)
1693     XVECEXP (operands[3], 0, i)
1694       = gen_rtx_SET (VOIDmode,
1695                      change_address (operands[0], mode,
1696                        plus_constant (to, off + i * GET_MODE_SIZE (mode))),
1697                      gen_rtx_REG (mode, regno + i));
1698 })
1699
1700 (define_insn "*store_multiple_di"
1701   [(match_parallel 0 "store_multiple_operation"
1702                    [(set (match_operand:DI 1 "s_operand" "=QS")
1703                          (match_operand:DI 2 "register_operand" "r"))])]
1704   "reload_completed && word_mode == DImode"
1705 {
1706   int words = XVECLEN (operands[0], 0);
1707   operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
1708   return "stmg\t%2,%0,%S1";
1709 }
1710    [(set_attr "op_type" "RSY")
1711     (set_attr "type"    "stm")])
1712
1713
1714 (define_insn "*store_multiple_si"
1715   [(match_parallel 0 "store_multiple_operation"
1716                    [(set (match_operand:SI 1 "s_operand" "=Q,S")
1717                          (match_operand:SI 2 "register_operand" "r,r"))])]
1718   "reload_completed"
1719 {
1720   int words = XVECLEN (operands[0], 0);
1721   operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
1722   return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
1723 }
1724    [(set_attr "op_type" "RS,RSY")
1725     (set_attr "type"    "stm")])
1726
1727 ;;
1728 ;; String instructions.
1729 ;;
1730
1731 (define_insn "*execute"
1732   [(match_parallel 0 ""
1733     [(unspec [(match_operand 1 "register_operand" "a")
1734               (match_operand:BLK 2 "memory_operand" "R")
1735               (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
1736   "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
1737    && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
1738   "ex\t%1,%2"
1739   [(set_attr "op_type" "RX")
1740    (set_attr "type" "cs")])
1741
1742
1743 ;
1744 ; strlenM instruction pattern(s).
1745 ;
1746
1747 (define_expand "strlen<mode>"
1748   [(set (reg:QI 0) (match_operand:QI 2 "immediate_operand" ""))
1749    (parallel
1750     [(set (match_dup 4)
1751           (unspec:P [(const_int 0)
1752                       (match_operand:BLK 1 "memory_operand" "")
1753                       (reg:QI 0)
1754                       (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
1755      (clobber (scratch:P))
1756      (clobber (reg:CC CC_REGNUM))])
1757    (parallel
1758     [(set (match_operand:P 0 "register_operand" "")
1759           (minus:P (match_dup 4) (match_dup 5)))
1760      (clobber (reg:CC CC_REGNUM))])]
1761   ""
1762 {
1763   operands[4] = gen_reg_rtx (Pmode);
1764   operands[5] = gen_reg_rtx (Pmode);
1765   emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
1766   operands[1] = replace_equiv_address (operands[1], operands[5]);
1767 })
1768
1769 (define_insn "*strlen<mode>"
1770   [(set (match_operand:P 0 "register_operand" "=a")
1771         (unspec:P [(match_operand:P 2 "general_operand" "0")
1772                     (mem:BLK (match_operand:P 3 "register_operand" "1"))
1773                     (reg:QI 0)
1774                     (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
1775    (clobber (match_scratch:P 1 "=a"))
1776    (clobber (reg:CC CC_REGNUM))]
1777   ""
1778   "srst\t%0,%1\;jo\t.-4"
1779   [(set_attr "length" "8")
1780    (set_attr "type" "vs")])
1781
1782 ;
1783 ; movmemM instruction pattern(s).
1784 ;
1785
1786 (define_expand "movmem<mode>"
1787   [(set (match_operand:BLK 0 "memory_operand" "")
1788         (match_operand:BLK 1 "memory_operand" ""))
1789    (use (match_operand:GPR 2 "general_operand" ""))
1790    (match_operand 3 "" "")]
1791   ""
1792   "s390_expand_movmem (operands[0], operands[1], operands[2]); DONE;")
1793
1794 ; Move a block that is up to 256 bytes in length.
1795 ; The block length is taken as (operands[2] % 256) + 1.
1796
1797 (define_expand "movmem_short"
1798   [(parallel
1799     [(set (match_operand:BLK 0 "memory_operand" "")
1800           (match_operand:BLK 1 "memory_operand" ""))
1801      (use (match_operand 2 "nonmemory_operand" ""))
1802      (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
1803      (clobber (match_dup 3))])]
1804   ""
1805   "operands[3] = gen_rtx_SCRATCH (Pmode);")
1806
1807 (define_insn "*movmem_short"
1808   [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q")
1809         (match_operand:BLK 1 "memory_operand" "Q,Q,Q"))
1810    (use (match_operand 2 "nonmemory_operand" "n,a,a"))
1811    (use (match_operand 3 "immediate_operand" "X,R,X"))
1812    (clobber (match_scratch 4 "=X,X,&a"))]
1813   "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
1814    && GET_MODE (operands[4]) == Pmode"
1815   "#"
1816   [(set_attr "type" "cs")])
1817
1818 (define_split
1819   [(set (match_operand:BLK 0 "memory_operand" "")
1820         (match_operand:BLK 1 "memory_operand" ""))
1821    (use (match_operand 2 "const_int_operand" ""))
1822    (use (match_operand 3 "immediate_operand" ""))
1823    (clobber (scratch))]
1824   "reload_completed"
1825   [(parallel
1826     [(set (match_dup 0) (match_dup 1))
1827      (use (match_dup 2))])]
1828   "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
1829
1830 (define_split
1831   [(set (match_operand:BLK 0 "memory_operand" "")
1832         (match_operand:BLK 1 "memory_operand" ""))
1833    (use (match_operand 2 "register_operand" ""))
1834    (use (match_operand 3 "memory_operand" ""))
1835    (clobber (scratch))]
1836   "reload_completed"
1837   [(parallel
1838     [(unspec [(match_dup 2) (match_dup 3)
1839               (const_int 0)] UNSPEC_EXECUTE)
1840      (set (match_dup 0) (match_dup 1))
1841      (use (const_int 1))])]
1842   "")
1843
1844 (define_split
1845   [(set (match_operand:BLK 0 "memory_operand" "")
1846         (match_operand:BLK 1 "memory_operand" ""))
1847    (use (match_operand 2 "register_operand" ""))
1848    (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
1849    (clobber (match_operand 3 "register_operand" ""))]
1850   "reload_completed && TARGET_CPU_ZARCH"
1851   [(set (match_dup 3) (label_ref (match_dup 4)))
1852    (parallel
1853     [(unspec [(match_dup 2) (mem:BLK (match_dup 3)) 
1854               (label_ref (match_dup 4))] UNSPEC_EXECUTE)
1855      (set (match_dup 0) (match_dup 1))
1856      (use (const_int 1))])]
1857   "operands[4] = gen_label_rtx ();")
1858
1859 ; Move a block of arbitrary length.
1860
1861 (define_expand "movmem_long"
1862   [(parallel
1863     [(clobber (match_dup 2))
1864      (clobber (match_dup 3))
1865      (set (match_operand:BLK 0 "memory_operand" "")
1866           (match_operand:BLK 1 "memory_operand" ""))
1867      (use (match_operand 2 "general_operand" ""))
1868      (use (match_dup 3))
1869      (clobber (reg:CC CC_REGNUM))])]
1870   ""
1871 {
1872   enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
1873   rtx reg0 = gen_reg_rtx (dword_mode);
1874   rtx reg1 = gen_reg_rtx (dword_mode);
1875   rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
1876   rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
1877   rtx len0 = gen_lowpart (Pmode, reg0);
1878   rtx len1 = gen_lowpart (Pmode, reg1);
1879
1880   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
1881   emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
1882   emit_move_insn (len0, operands[2]);
1883
1884   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
1885   emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
1886   emit_move_insn (len1, operands[2]);
1887
1888   operands[0] = replace_equiv_address_nv (operands[0], addr0);
1889   operands[1] = replace_equiv_address_nv (operands[1], addr1);
1890   operands[2] = reg0;
1891   operands[3] = reg1;
1892 })
1893
1894 (define_insn "*movmem_long_64"
1895   [(clobber (match_operand:TI 0 "register_operand" "=d"))
1896    (clobber (match_operand:TI 1 "register_operand" "=d"))
1897    (set (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
1898         (mem:BLK (subreg:DI (match_operand:TI 3 "register_operand" "1") 0)))
1899    (use (match_dup 2))
1900    (use (match_dup 3))
1901    (clobber (reg:CC CC_REGNUM))]
1902   "TARGET_64BIT"
1903   "mvcle\t%0,%1,0\;jo\t.-4"
1904   [(set_attr "length" "8")
1905    (set_attr "type" "vs")])
1906
1907 (define_insn "*movmem_long_31"
1908   [(clobber (match_operand:DI 0 "register_operand" "=d"))
1909    (clobber (match_operand:DI 1 "register_operand" "=d"))
1910    (set (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
1911         (mem:BLK (subreg:SI (match_operand:DI 3 "register_operand" "1") 0)))
1912    (use (match_dup 2))
1913    (use (match_dup 3))
1914    (clobber (reg:CC CC_REGNUM))]
1915   "!TARGET_64BIT"
1916   "mvcle\t%0,%1,0\;jo\t.-4"
1917   [(set_attr "length" "8")
1918    (set_attr "type" "vs")])
1919
1920 ;
1921 ; clrmemM instruction pattern(s).
1922 ;
1923
1924 (define_expand "clrmem<mode>"
1925   [(set (match_operand:BLK 0 "memory_operand" "")
1926         (const_int 0))
1927    (use (match_operand:GPR 1 "general_operand" ""))
1928    (match_operand 2 "" "")]
1929   ""
1930   "s390_expand_clrmem (operands[0], operands[1]); DONE;")
1931
1932 ; Clear a block that is up to 256 bytes in length.
1933 ; The block length is taken as (operands[1] % 256) + 1.
1934
1935 (define_expand "clrmem_short"
1936   [(parallel
1937     [(set (match_operand:BLK 0 "memory_operand" "")
1938           (const_int 0))
1939      (use (match_operand 1 "nonmemory_operand" ""))
1940      (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
1941      (clobber (match_dup 2))
1942      (clobber (reg:CC CC_REGNUM))])]
1943   ""
1944   "operands[2] = gen_rtx_SCRATCH (Pmode);")
1945
1946 (define_insn "*clrmem_short"
1947   [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q")
1948         (const_int 0))
1949    (use (match_operand 1 "nonmemory_operand" "n,a,a"))
1950    (use (match_operand 2 "immediate_operand" "X,R,X"))
1951    (clobber (match_scratch 3 "=X,X,&a"))
1952    (clobber (reg:CC CC_REGNUM))]
1953   "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)
1954    && GET_MODE (operands[3]) == Pmode"
1955   "#"
1956   [(set_attr "type" "cs")])
1957
1958 (define_split
1959   [(set (match_operand:BLK 0 "memory_operand" "")
1960         (const_int 0))
1961    (use (match_operand 1 "const_int_operand" ""))
1962    (use (match_operand 2 "immediate_operand" ""))
1963    (clobber (scratch))
1964    (clobber (reg:CC CC_REGNUM))]
1965   "reload_completed"
1966   [(parallel
1967     [(set (match_dup 0) (const_int 0))
1968      (use (match_dup 1))
1969      (clobber (reg:CC CC_REGNUM))])]
1970   "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
1971
1972 (define_split
1973   [(set (match_operand:BLK 0 "memory_operand" "")
1974         (const_int 0))
1975    (use (match_operand 1 "register_operand" ""))
1976    (use (match_operand 2 "memory_operand" ""))
1977    (clobber (scratch))
1978    (clobber (reg:CC CC_REGNUM))]
1979   "reload_completed"
1980   [(parallel
1981     [(unspec [(match_dup 1) (match_dup 2)
1982               (const_int 0)] UNSPEC_EXECUTE)
1983      (set (match_dup 0) (const_int 0))
1984      (use (const_int 1))
1985      (clobber (reg:CC CC_REGNUM))])]
1986   "")
1987
1988 (define_split
1989   [(set (match_operand:BLK 0 "memory_operand" "")
1990         (const_int 0))
1991    (use (match_operand 1 "register_operand" ""))
1992    (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
1993    (clobber (match_operand 2 "register_operand" ""))
1994    (clobber (reg:CC CC_REGNUM))]
1995   "reload_completed && TARGET_CPU_ZARCH"
1996   [(set (match_dup 2) (label_ref (match_dup 3)))
1997    (parallel
1998     [(unspec [(match_dup 1) (mem:BLK (match_dup 2)) 
1999               (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2000      (set (match_dup 0) (const_int 0))
2001      (use (const_int 1))
2002      (clobber (reg:CC CC_REGNUM))])]
2003   "operands[3] = gen_label_rtx ();")
2004
2005 ; Clear a block of arbitrary length.
2006
2007 (define_expand "clrmem_long"
2008   [(parallel
2009     [(clobber (match_dup 1))
2010      (set (match_operand:BLK 0 "memory_operand" "")
2011           (const_int 0))
2012      (use (match_operand 1 "general_operand" ""))
2013      (use (match_dup 2))
2014      (clobber (reg:CC CC_REGNUM))])]
2015   ""
2016 {
2017   enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2018   rtx reg0 = gen_reg_rtx (dword_mode);
2019   rtx reg1 = gen_reg_rtx (dword_mode);
2020   rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2021   rtx len0 = gen_lowpart (Pmode, reg0);
2022
2023   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2024   emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2025   emit_move_insn (len0, operands[1]);
2026
2027   emit_move_insn (reg1, const0_rtx);
2028
2029   operands[0] = replace_equiv_address_nv (operands[0], addr0);
2030   operands[1] = reg0;
2031   operands[2] = reg1;
2032 })
2033
2034 (define_insn "*clrmem_long_64"
2035   [(clobber (match_operand:TI 0 "register_operand" "=d"))
2036    (set (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
2037         (const_int 0))
2038    (use (match_dup 2))
2039    (use (match_operand:TI 1 "register_operand" "d"))
2040    (clobber (reg:CC CC_REGNUM))]
2041   "TARGET_64BIT"
2042   "mvcle\t%0,%1,0\;jo\t.-4"
2043   [(set_attr "length" "8")
2044    (set_attr "type" "vs")])
2045
2046 (define_insn "*clrmem_long_31"
2047   [(clobber (match_operand:DI 0 "register_operand" "=d"))
2048    (set (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
2049         (const_int 0))
2050    (use (match_dup 2))
2051    (use (match_operand:DI 1 "register_operand" "d"))
2052    (clobber (reg:CC CC_REGNUM))]
2053   "!TARGET_64BIT"
2054   "mvcle\t%0,%1,0\;jo\t.-4"
2055   [(set_attr "length" "8")
2056    (set_attr "type" "vs")])
2057
2058 ;
2059 ; cmpmemM instruction pattern(s).
2060 ;
2061
2062 (define_expand "cmpmemsi"
2063   [(set (match_operand:SI 0 "register_operand" "")
2064         (compare:SI (match_operand:BLK 1 "memory_operand" "")
2065                     (match_operand:BLK 2 "memory_operand" "") ) )
2066    (use (match_operand:SI 3 "general_operand" ""))
2067    (use (match_operand:SI 4 "" ""))]
2068   ""
2069   "s390_expand_cmpmem (operands[0], operands[1],
2070                        operands[2], operands[3]); DONE;")
2071
2072 ; Compare a block that is up to 256 bytes in length.
2073 ; The block length is taken as (operands[2] % 256) + 1.
2074
2075 (define_expand "cmpmem_short"
2076   [(parallel
2077     [(set (reg:CCU CC_REGNUM)
2078           (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2079                        (match_operand:BLK 1 "memory_operand" "")))
2080      (use (match_operand 2 "nonmemory_operand" ""))
2081      (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2082      (clobber (match_dup 3))])]
2083   ""
2084   "operands[3] = gen_rtx_SCRATCH (Pmode);")
2085
2086 (define_insn "*cmpmem_short"
2087   [(set (reg:CCU CC_REGNUM)
2088         (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q")
2089                      (match_operand:BLK 1 "memory_operand" "Q,Q,Q")))
2090    (use (match_operand 2 "nonmemory_operand" "n,a,a"))
2091    (use (match_operand 3 "immediate_operand" "X,R,X"))
2092    (clobber (match_scratch 4 "=X,X,&a"))]
2093   "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2094    && GET_MODE (operands[4]) == Pmode"
2095   "#"
2096   [(set_attr "type" "cs")])
2097
2098 (define_split
2099   [(set (reg:CCU CC_REGNUM)
2100         (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2101                      (match_operand:BLK 1 "memory_operand" "")))
2102    (use (match_operand 2 "const_int_operand" ""))
2103    (use (match_operand 3 "immediate_operand" ""))
2104    (clobber (scratch))]
2105   "reload_completed"
2106   [(parallel
2107     [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2108      (use (match_dup 2))])]
2109   "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2110
2111 (define_split
2112   [(set (reg:CCU CC_REGNUM)
2113         (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2114                      (match_operand:BLK 1 "memory_operand" "")))
2115    (use (match_operand 2 "register_operand" ""))
2116    (use (match_operand 3 "memory_operand" ""))
2117    (clobber (scratch))]
2118   "reload_completed"
2119   [(parallel
2120     [(unspec [(match_dup 2) (match_dup 3)
2121               (const_int 0)] UNSPEC_EXECUTE)
2122      (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2123      (use (const_int 1))])]
2124   "")
2125
2126 (define_split
2127   [(set (reg:CCU CC_REGNUM)
2128         (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2129                      (match_operand:BLK 1 "memory_operand" "")))
2130    (use (match_operand 2 "register_operand" ""))
2131    (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2132    (clobber (match_operand 3 "register_operand" ""))]
2133   "reload_completed && TARGET_CPU_ZARCH"
2134   [(set (match_dup 3) (label_ref (match_dup 4)))
2135    (parallel
2136     [(unspec [(match_dup 2) (mem:BLK (match_dup 3)) 
2137               (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2138      (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2139      (use (const_int 1))])]
2140   "operands[4] = gen_label_rtx ();")
2141
2142 ; Compare a block of arbitrary length.
2143
2144 (define_expand "cmpmem_long"
2145   [(parallel
2146     [(clobber (match_dup 2))
2147      (clobber (match_dup 3))
2148      (set (reg:CCU CC_REGNUM)
2149           (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2150                        (match_operand:BLK 1 "memory_operand" "")))
2151      (use (match_operand 2 "general_operand" ""))
2152      (use (match_dup 3))])]
2153   ""
2154 {
2155   enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2156   rtx reg0 = gen_reg_rtx (dword_mode);
2157   rtx reg1 = gen_reg_rtx (dword_mode);
2158   rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2159   rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
2160   rtx len0 = gen_lowpart (Pmode, reg0);
2161   rtx len1 = gen_lowpart (Pmode, reg1);
2162
2163   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2164   emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2165   emit_move_insn (len0, operands[2]);
2166
2167   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
2168   emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2169   emit_move_insn (len1, operands[2]);
2170
2171   operands[0] = replace_equiv_address_nv (operands[0], addr0);
2172   operands[1] = replace_equiv_address_nv (operands[1], addr1);
2173   operands[2] = reg0;
2174   operands[3] = reg1;
2175 })
2176
2177 (define_insn "*cmpmem_long_64"
2178   [(clobber (match_operand:TI 0 "register_operand" "=d"))
2179    (clobber (match_operand:TI 1 "register_operand" "=d"))
2180    (set (reg:CCU CC_REGNUM)
2181         (compare:CCU (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
2182                      (mem:BLK (subreg:DI (match_operand:TI 3 "register_operand" "1") 0))))
2183    (use (match_dup 2))
2184    (use (match_dup 3))]
2185   "TARGET_64BIT"
2186   "clcle\t%0,%1,0\;jo\t.-4"
2187   [(set_attr "length" "8")
2188    (set_attr "type" "vs")])
2189
2190 (define_insn "*cmpmem_long_31"
2191   [(clobber (match_operand:DI 0 "register_operand" "=d"))
2192    (clobber (match_operand:DI 1 "register_operand" "=d"))
2193    (set (reg:CCU CC_REGNUM)
2194         (compare:CCU (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
2195                      (mem:BLK (subreg:SI (match_operand:DI 3 "register_operand" "1") 0))))
2196    (use (match_dup 2))
2197    (use (match_dup 3))]
2198   "!TARGET_64BIT"
2199   "clcle\t%0,%1,0\;jo\t.-4"
2200   [(set_attr "length" "8")
2201    (set_attr "type" "vs")])
2202
2203 ; Convert CCUmode condition code to integer.
2204 ; Result is zero if EQ, positive if LTU, negative if GTU.
2205
2206 (define_insn_and_split "cmpint"
2207   [(set (match_operand:SI 0 "register_operand" "=d")
2208         (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2209                    UNSPEC_CMPINT))
2210    (clobber (reg:CC CC_REGNUM))]
2211   ""
2212   "#"
2213   "reload_completed"
2214   [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
2215    (parallel
2216     [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
2217      (clobber (reg:CC CC_REGNUM))])])
2218
2219 (define_insn_and_split "*cmpint_cc"
2220   [(set (reg CC_REGNUM)
2221         (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2222                             UNSPEC_CMPINT)
2223                  (const_int 0)))
2224    (set (match_operand:SI 0 "register_operand" "=d")
2225         (unspec:SI [(match_dup 1)] UNSPEC_CMPINT))]
2226   "s390_match_ccmode (insn, CCSmode)"
2227   "#"
2228   "&& reload_completed"
2229   [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
2230    (parallel
2231     [(set (match_dup 2) (match_dup 3))
2232      (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
2233 {
2234   rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
2235   operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
2236   operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
2237 })
2238
2239 (define_insn_and_split "*cmpint_sign"
2240   [(set (match_operand:DI 0 "register_operand" "=d")
2241         (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2242                                    UNSPEC_CMPINT)))
2243    (clobber (reg:CC CC_REGNUM))]
2244   "TARGET_64BIT"
2245   "#"
2246   "&& reload_completed"
2247   [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
2248    (parallel
2249     [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
2250      (clobber (reg:CC CC_REGNUM))])])
2251
2252 (define_insn_and_split "*cmpint_sign_cc"
2253   [(set (reg CC_REGNUM)
2254         (compare (ashiftrt:DI (ashift:DI (subreg:DI 
2255                    (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2256                               UNSPEC_CMPINT) 0)
2257                    (const_int 32)) (const_int 32))
2258                  (const_int 0)))
2259    (set (match_operand:DI 0 "register_operand" "=d")
2260         (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_CMPINT)))]
2261   "s390_match_ccmode (insn, CCSmode) && TARGET_64BIT"
2262   "#"
2263   "&& reload_completed"
2264   [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
2265    (parallel
2266     [(set (match_dup 2) (match_dup 3))
2267      (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
2268 {
2269   rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
2270   operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
2271   operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
2272 })
2273
2274
2275 ;;
2276 ;;- Conversion instructions.
2277 ;;
2278
2279
2280 (define_insn "*sethigh<mode>si"
2281   [(set (match_operand:SI 0 "register_operand" "=d,d")
2282         (unspec:SI [(match_operand:HQI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
2283    (clobber (reg:CC CC_REGNUM))]
2284   ""
2285   "@
2286    icm\t%0,<icm_hi>,%S1
2287    icmy\t%0,<icm_hi>,%S1"
2288   [(set_attr "op_type" "RS,RSY")])
2289
2290 (define_insn "*sethighqidi_64"
2291   [(set (match_operand:DI 0 "register_operand" "=d")
2292         (unspec:DI [(match_operand:QI 1 "s_operand" "QS")] UNSPEC_SETHIGH))
2293    (clobber (reg:CC CC_REGNUM))]
2294   "TARGET_64BIT"
2295   "icmh\t%0,8,%S1"
2296   [(set_attr "op_type" "RSY")])
2297
2298 (define_insn "*sethighqidi_31"
2299   [(set (match_operand:DI 0 "register_operand" "=d,d")
2300         (unspec:DI [(match_operand:QI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
2301    (clobber (reg:CC CC_REGNUM))]
2302   "!TARGET_64BIT"
2303   "@
2304    icm\t%0,8,%S1
2305    icmy\t%0,8,%S1"
2306   [(set_attr "op_type" "RS,RSY")])
2307
2308 (define_insn_and_split "*extractqi"
2309   [(set (match_operand:SI 0 "register_operand" "=d")
2310         (zero_extract:SI (match_operand:QI 1 "s_operand" "Q")
2311                          (match_operand 2 "const_int_operand" "n")
2312                          (const_int 0)))
2313    (clobber (reg:CC CC_REGNUM))]
2314   "!TARGET_64BIT
2315    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 8"
2316   "#"
2317   "&& reload_completed"
2318   [(parallel
2319     [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
2320      (clobber (reg:CC CC_REGNUM))])
2321     (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
2322 {
2323   operands[2] = GEN_INT (32 - INTVAL (operands[2]));
2324   operands[1] = change_address (operands[1], QImode, 0);
2325 })
2326
2327 (define_insn_and_split "*extracthi"
2328   [(set (match_operand:SI 0 "register_operand" "=d")
2329         (zero_extract:SI (match_operand:QI 1 "s_operand" "Q")
2330                          (match_operand 2 "const_int_operand" "n")
2331                          (const_int 0)))
2332    (clobber (reg:CC CC_REGNUM))]
2333   "!TARGET_64BIT
2334    && INTVAL (operands[2]) >= 8 && INTVAL (operands[2]) < 16"
2335   "#"
2336   "&& reload_completed"
2337   [(parallel
2338     [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
2339      (clobber (reg:CC CC_REGNUM))])
2340     (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
2341 {
2342   operands[2] = GEN_INT (32 - INTVAL (operands[2]));
2343   operands[1] = change_address (operands[1], HImode, 0);
2344 })
2345
2346 ;
2347 ; extendsidi2 instruction pattern(s).
2348 ;
2349
2350 (define_expand "extendsidi2"
2351   [(set (match_operand:DI 0 "register_operand" "")
2352         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2353   ""
2354   "
2355 {
2356   if (!TARGET_64BIT)
2357     {
2358       emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2359       emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
2360       emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
2361       emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
2362       DONE;
2363     }
2364 }
2365 ")
2366
2367 (define_insn "*extendsidi2"
2368   [(set (match_operand:DI 0 "register_operand" "=d,d")
2369         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2370   "TARGET_64BIT"
2371   "@
2372    lgfr\t%0,%1
2373    lgf\t%0,%1"
2374   [(set_attr "op_type" "RRE,RXY")])
2375
2376 ;
2377 ; extend(hi|qi)di2 instruction pattern(s).
2378 ;
2379
2380 (define_expand "extend<mode>di2"
2381   [(set (match_operand:DI 0 "register_operand" "")
2382         (sign_extend:DI (match_operand:HQI 1 "register_operand" "")))]
2383   ""
2384   "
2385 {
2386   if (!TARGET_64BIT)
2387     {
2388       rtx tmp = gen_reg_rtx (SImode);
2389       emit_insn (gen_extend<mode>si2 (tmp, operands[1]));
2390       emit_insn (gen_extendsidi2 (operands[0], tmp));
2391       DONE;
2392     }
2393   else
2394     {
2395       rtx bitcount = GEN_INT (GET_MODE_BITSIZE (DImode) - 
2396                               GET_MODE_BITSIZE (<MODE>mode));
2397       operands[1] = gen_lowpart (DImode, operands[1]);
2398       emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
2399       emit_insn (gen_ashrdi3 (operands[0], operands[0], bitcount));
2400       DONE;
2401     }
2402 }
2403 ")
2404
2405 (define_insn "*extendhidi2"
2406   [(set (match_operand:DI 0 "register_operand" "=d")
2407         (sign_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
2408   "TARGET_64BIT"
2409   "lgh\t%0,%1"
2410   [(set_attr "op_type" "RXY")])
2411
2412 (define_insn "*extendqidi2"
2413   [(set (match_operand:DI 0 "register_operand" "=d")
2414         (sign_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
2415   "TARGET_64BIT && TARGET_LONG_DISPLACEMENT"
2416   "lgb\t%0,%1"
2417   [(set_attr "op_type" "RXY")])
2418
2419 (define_insn_and_split "*extendqidi2_short_displ"
2420   [(set (match_operand:DI 0 "register_operand" "=d")
2421         (sign_extend:DI (match_operand:QI 1 "s_operand" "Q")))
2422    (clobber (reg:CC CC_REGNUM))]
2423   "TARGET_64BIT && !TARGET_LONG_DISPLACEMENT"
2424   "#"
2425   "&& reload_completed"
2426   [(parallel
2427     [(set (match_dup 0) (unspec:DI [(match_dup 1)] UNSPEC_SETHIGH))
2428      (clobber (reg:CC CC_REGNUM))])
2429    (parallel
2430     [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 56)))
2431      (clobber (reg:CC CC_REGNUM))])]
2432   "")
2433
2434 ;
2435 ; extend(hi|qi)si2 instruction pattern(s).
2436 ;
2437
2438 (define_expand "extend<mode>si2"
2439   [(set (match_operand:SI 0 "register_operand" "")
2440         (sign_extend:SI (match_operand:HQI 1 "register_operand" "")))]
2441   ""
2442   "
2443 {
2444   rtx bitcount = GEN_INT (GET_MODE_BITSIZE(SImode) - 
2445                           GET_MODE_BITSIZE(<MODE>mode));
2446   operands[1] = gen_lowpart (SImode, operands[1]);
2447   emit_insn (gen_ashlsi3 (operands[0], operands[1], bitcount));
2448   emit_insn (gen_ashrsi3 (operands[0], operands[0], bitcount));
2449   DONE;
2450 }
2451 ")
2452
2453 (define_insn "*extendhisi2"
2454   [(set (match_operand:SI 0 "register_operand" "=d,d")
2455         (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
2456   ""
2457   "@
2458    lh\t%0,%1
2459    lhy\t%0,%1"
2460   [(set_attr "op_type" "RX,RXY")])
2461
2462 (define_insn "*extendqisi2"
2463   [(set (match_operand:SI 0 "register_operand" "=d")
2464         (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
2465   "TARGET_LONG_DISPLACEMENT"
2466   "lb\t%0,%1"
2467   [(set_attr "op_type" "RXY")])
2468
2469 (define_insn_and_split "*extendqisi2_short_displ"
2470   [(set (match_operand:SI 0 "register_operand" "=d")
2471         (sign_extend:SI (match_operand:QI 1 "s_operand" "Q")))
2472    (clobber (reg:CC CC_REGNUM))]
2473   "!TARGET_LONG_DISPLACEMENT"
2474   "#"
2475   "&& reload_completed"
2476   [(parallel
2477     [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
2478      (clobber (reg:CC CC_REGNUM))])
2479    (parallel
2480     [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 24)))
2481      (clobber (reg:CC CC_REGNUM))])]
2482   "")
2483
2484 ;
2485 ; extendqihi2 instruction pattern(s).
2486 ;
2487
2488
2489 ;
2490 ; zero_extendsidi2 instruction pattern(s).
2491 ;
2492
2493 (define_expand "zero_extendsidi2"
2494   [(set (match_operand:DI 0 "register_operand" "")
2495         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2496   ""
2497   "
2498 {
2499   if (!TARGET_64BIT)
2500     {
2501       emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2502       emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
2503       emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
2504       DONE;
2505     }
2506 }
2507 ")
2508
2509 (define_insn "*zero_extendsidi2"
2510   [(set (match_operand:DI 0 "register_operand" "=d,d")
2511         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2512   "TARGET_64BIT"
2513   "@
2514    llgfr\t%0,%1
2515    llgf\t%0,%1"
2516   [(set_attr "op_type" "RRE,RXY")])
2517
2518 ;
2519 ; zero_extend(hi|qi)di2 instruction pattern(s).
2520 ;
2521
2522 (define_expand "zero_extend<mode>di2"
2523   [(set (match_operand:DI 0 "register_operand" "")
2524         (zero_extend:DI (match_operand:HQI 1 "register_operand" "")))]
2525   ""
2526   "
2527 {
2528   if (!TARGET_64BIT)
2529     {
2530       rtx tmp = gen_reg_rtx (SImode);
2531       emit_insn (gen_zero_extend<mode>si2 (tmp, operands[1]));
2532       emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
2533       DONE;
2534     }
2535   else
2536     {
2537       rtx bitcount = GEN_INT (GET_MODE_BITSIZE(DImode) - 
2538                               GET_MODE_BITSIZE(<MODE>mode));
2539       operands[1] = gen_lowpart (DImode, operands[1]);
2540       emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
2541       emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
2542       DONE;
2543     }
2544 }
2545 ")
2546
2547 (define_insn "*zero_extend<mode>di2"
2548   [(set (match_operand:DI 0 "register_operand" "=d")
2549         (zero_extend:DI (match_operand:HQI 1 "memory_operand" "m")))]
2550   "TARGET_64BIT"
2551   "llg<hc>\t%0,%1"
2552   [(set_attr "op_type" "RXY")])
2553
2554 ;
2555 ; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
2556 ;
2557
2558 (define_insn "*llgt_sidi"
2559   [(set (match_operand:DI 0 "register_operand" "=d")
2560         (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
2561                 (const_int 2147483647)))]
2562   "TARGET_64BIT"
2563   "llgt\t%0,%1"
2564   [(set_attr "op_type"  "RXE")])
2565
2566 (define_insn_and_split "*llgt_sidi_split"
2567   [(set (match_operand:DI 0 "register_operand" "=d")
2568         (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
2569                 (const_int 2147483647)))
2570    (clobber (reg:CC CC_REGNUM))]
2571   "TARGET_64BIT"
2572   "#"
2573   "&& reload_completed"
2574   [(set (match_dup 0)
2575         (and:DI (subreg:DI (match_dup 1) 0)
2576                 (const_int 2147483647)))]
2577   "")
2578
2579 (define_insn "*llgt_sisi"
2580   [(set (match_operand:SI 0 "register_operand" "=d,d")
2581         (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,m")
2582                 (const_int 2147483647)))]
2583   "TARGET_64BIT"
2584   "@
2585    llgtr\t%0,%1
2586    llgt\t%0,%1"
2587   [(set_attr "op_type"  "RRE,RXE")])
2588
2589 (define_insn "*llgt_didi"
2590   [(set (match_operand:DI 0 "register_operand" "=d,d")
2591         (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
2592                 (const_int 2147483647)))]
2593   "TARGET_64BIT"
2594   "@
2595    llgtr\t%0,%1
2596    llgt\t%0,%N1"
2597   [(set_attr "op_type"  "RRE,RXE")])
2598
2599 (define_split
2600   [(set (match_operand:GPR 0 "register_operand" "")
2601         (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
2602                  (const_int 2147483647)))
2603    (clobber (reg:CC CC_REGNUM))]
2604   "TARGET_64BIT && reload_completed"
2605   [(set (match_dup 0)
2606         (and:GPR (match_dup 1)
2607                  (const_int 2147483647)))]
2608   "")
2609
2610 ;
2611 ; zero_extend(hi|qi)si2 instruction pattern(s).
2612 ;
2613
2614 (define_expand "zero_extend<mode>si2"
2615   [(set (match_operand:SI 0 "register_operand" "")
2616         (zero_extend:SI (match_operand:HQI 1 "register_operand" "")))]
2617   ""
2618   "
2619 {
2620   operands[1] = gen_lowpart (SImode, operands[1]);
2621   emit_insn (gen_andsi3 (operands[0], operands[1], 
2622     GEN_INT ((1 << GET_MODE_BITSIZE(<MODE>mode)) - 1)));
2623   DONE;
2624 }
2625 ")
2626
2627 (define_insn "*zero_extend<mode>si2_64"
2628   [(set (match_operand:SI 0 "register_operand" "=d")
2629         (zero_extend:SI (match_operand:HQI 1 "memory_operand" "m")))]
2630   "TARGET_ZARCH"
2631   "llg<hc>\t%0,%1"
2632   [(set_attr "op_type" "RXY")])
2633
2634 (define_insn_and_split "*zero_extendhisi2_31"
2635   [(set (match_operand:SI 0 "register_operand" "=&d")
2636         (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
2637    (clobber (reg:CC CC_REGNUM))]
2638   "!TARGET_ZARCH"
2639   "#"
2640   "&& reload_completed"
2641   [(set (match_dup 0) (const_int 0))
2642    (parallel
2643     [(set (strict_low_part (match_dup 2)) (match_dup 1))
2644      (clobber (reg:CC CC_REGNUM))])]
2645   "operands[2] = gen_lowpart (HImode, operands[0]);")
2646
2647 (define_insn_and_split "*zero_extendqisi2_31"
2648   [(set (match_operand:SI 0 "register_operand" "=&d")
2649         (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
2650   "!TARGET_ZARCH"
2651   "#"
2652   "&& reload_completed"
2653   [(set (match_dup 0) (const_int 0))
2654    (set (strict_low_part (match_dup 2)) (match_dup 1))]
2655   "operands[2] = gen_lowpart (QImode, operands[0]);")
2656
2657 ;
2658 ; zero_extendqihi2 instruction pattern(s).
2659 ;
2660
2661 (define_expand "zero_extendqihi2"
2662   [(set (match_operand:HI 0 "register_operand" "")
2663         (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
2664   "TARGET_ZARCH"
2665   "
2666 {
2667   operands[1] = gen_lowpart (HImode, operands[1]);
2668   emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
2669   DONE;
2670 }
2671 ")
2672
2673 (define_insn "*zero_extendqihi2_64"
2674   [(set (match_operand:HI 0 "register_operand" "=d")
2675         (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
2676   "TARGET_ZARCH"
2677   "llgc\t%0,%1"
2678   [(set_attr "op_type" "RXY")])
2679
2680 (define_insn_and_split "*zero_extendqihi2_31"
2681   [(set (match_operand:HI 0 "register_operand" "=&d")
2682         (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
2683   "!TARGET_ZARCH"
2684   "#"
2685   "&& reload_completed"
2686   [(set (match_dup 0) (const_int 0))
2687    (set (strict_low_part (match_dup 2)) (match_dup 1))]
2688   "operands[2] = gen_lowpart (QImode, operands[0]);")
2689
2690
2691 ;
2692 ; fixuns_trunc(sf|df)(si|di)2 and fix_trunc(sf|df)(si|di)2 instruction pattern(s).
2693 ;
2694
2695 (define_expand "fixuns_trunc<FPR:mode><GPR:mode>2"
2696   [(set (match_operand:GPR 0 "register_operand" "")
2697         (unsigned_fix:GPR (match_operand:FPR 1 "register_operand" "")))]
2698   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2699 {
2700   rtx label1 = gen_label_rtx ();
2701   rtx label2 = gen_label_rtx ();
2702   rtx temp = gen_reg_rtx (<FPR:MODE>mode);
2703   REAL_VALUE_TYPE cmp, sub;
2704   
2705   operands[1] = force_reg (<FPR:MODE>mode, operands[1]);
2706   real_2expN (&cmp, GET_MODE_BITSIZE(<GPR:MODE>mode) - 1);
2707   real_2expN (&sub, GET_MODE_BITSIZE(<GPR:MODE>mode));
2708   
2709   emit_insn (gen_cmp<FPR:mode> (operands[1],
2710         CONST_DOUBLE_FROM_REAL_VALUE (cmp, <FPR:MODE>mode)));
2711   emit_jump_insn (gen_blt (label1));
2712   emit_insn (gen_sub<FPR:mode>3 (temp, operands[1],
2713         CONST_DOUBLE_FROM_REAL_VALUE (sub, <FPR:MODE>mode)));
2714   emit_insn (gen_fix_trunc<FPR:mode><GPR:mode>2_ieee (operands[0], temp,
2715         GEN_INT(7)));
2716   emit_jump (label2);
2717
2718   emit_label (label1);
2719   emit_insn (gen_fix_trunc<FPR:mode><GPR:mode>2_ieee (operands[0],
2720         operands[1], GEN_INT(5)));
2721   emit_label (label2);
2722   DONE;
2723 })
2724
2725 (define_expand "fix_trunc<FPR:mode>di2"
2726   [(set (match_operand:DI 0 "register_operand" "")
2727         (fix:DI (match_operand:FPR 1 "nonimmediate_operand" "")))]
2728   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2729 {
2730   operands[1] = force_reg (<FPR:MODE>mode, operands[1]);
2731   emit_insn (gen_fix_trunc<FPR:mode>di2_ieee (operands[0], operands[1],
2732       GEN_INT(5)));
2733   DONE;
2734 })
2735
2736 (define_insn "fix_trunc<FPR:mode><GPR:mode>2_ieee"
2737   [(set (match_operand:GPR 0 "register_operand" "=d")
2738         (fix:GPR (match_operand:FPR 1 "register_operand" "f")))
2739    (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
2740    (clobber (reg:CC CC_REGNUM))]
2741   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2742   "c<GPR:gf><FPR:de>br\t%0,%h2,%1"
2743   [(set_attr "op_type" "RRE")
2744    (set_attr "type"    "ftoi")])
2745
2746 ;
2747 ; fix_truncdfsi2 instruction pattern(s).
2748 ;
2749
2750 (define_expand "fix_truncdfsi2"
2751   [(set (match_operand:SI 0 "register_operand" "")
2752         (fix:SI (match_operand:DF 1 "nonimmediate_operand" "")))]
2753   "TARGET_HARD_FLOAT"
2754 {
2755   if (TARGET_IBM_FLOAT)
2756     {
2757       /* This is the algorithm from POP chapter A.5.7.2.  */
2758
2759       rtx temp   = assign_stack_local (BLKmode, 8, BITS_PER_WORD);
2760       rtx two31r = s390_gen_rtx_const_DI (0x4f000000, 0x08000000);
2761       rtx two32  = s390_gen_rtx_const_DI (0x4e000001, 0x00000000);
2762
2763       operands[1] = force_reg (DFmode, operands[1]);
2764       emit_insn (gen_fix_truncdfsi2_ibm (operands[0], operands[1],
2765                                          two31r, two32, temp));
2766     }
2767   else
2768     {
2769       operands[1] = force_reg (DFmode, operands[1]);
2770       emit_insn (gen_fix_truncdfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2771     }
2772
2773   DONE;
2774 })
2775
2776 (define_insn "fix_truncdfsi2_ibm"
2777   [(set (match_operand:SI 0 "register_operand" "=d")
2778         (fix:SI (match_operand:DF 1 "nonimmediate_operand" "+f")))
2779    (use (match_operand:DI 2 "immediate_operand" "m"))
2780    (use (match_operand:DI 3 "immediate_operand" "m"))
2781    (use (match_operand:BLK 4 "memory_operand" "m"))
2782    (clobber (reg:CC CC_REGNUM))]
2783   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
2784 {
2785    output_asm_insn ("sd\t%1,%2", operands);
2786    output_asm_insn ("aw\t%1,%3", operands);
2787    output_asm_insn ("std\t%1,%4", operands);
2788    output_asm_insn ("xi\t%N4,128", operands);
2789    return "l\t%0,%N4";
2790 }
2791   [(set_attr "length" "20")])
2792
2793 ;
2794 ; fix_truncsfsi2 instruction pattern(s).
2795 ;
2796
2797 (define_expand "fix_truncsfsi2"
2798   [(set (match_operand:SI 0 "register_operand" "")
2799         (fix:SI (match_operand:SF 1 "nonimmediate_operand" "")))]
2800   "TARGET_HARD_FLOAT"
2801 {
2802   if (TARGET_IBM_FLOAT)
2803     {
2804       /* Convert to DFmode and then use the POP algorithm.  */
2805       rtx temp = gen_reg_rtx (DFmode);
2806       emit_insn (gen_extendsfdf2 (temp, operands[1]));
2807       emit_insn (gen_fix_truncdfsi2 (operands[0], temp));
2808     }
2809   else
2810     {
2811       operands[1] = force_reg (SFmode, operands[1]);
2812       emit_insn (gen_fix_truncsfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2813     }
2814
2815   DONE;
2816 })
2817
2818 ;
2819 ; floatdi(df|sf)2 instruction pattern(s).
2820 ;
2821
2822 (define_insn "floatdi<mode>2"
2823   [(set (match_operand:FPR 0 "register_operand" "=f")
2824         (float:FPR (match_operand:DI 1 "register_operand" "d")))]
2825   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2826   "c<de>gbr\t%0,%1"
2827   [(set_attr "op_type" "RRE")
2828    (set_attr "type"    "itof" )])
2829
2830 ;
2831 ; floatsidf2 instruction pattern(s).
2832 ;
2833
2834 (define_expand "floatsidf2"
2835   [(set (match_operand:DF 0 "register_operand" "")
2836         (float:DF (match_operand:SI 1 "register_operand" "")))]
2837   "TARGET_HARD_FLOAT"
2838 {
2839   if (TARGET_IBM_FLOAT)
2840     {
2841       /* This is the algorithm from POP chapter A.5.7.1.  */
2842
2843       rtx temp  = assign_stack_local (BLKmode, 8, BITS_PER_WORD);
2844       rtx two31 = s390_gen_rtx_const_DI (0x4e000000, 0x80000000);
2845
2846       emit_insn (gen_floatsidf2_ibm (operands[0], operands[1], two31, temp));
2847       DONE;
2848     }
2849 })
2850
2851 (define_insn "floatsidf2_ieee"
2852   [(set (match_operand:DF 0 "register_operand" "=f")
2853         (float:DF (match_operand:SI 1 "register_operand" "d")))]
2854   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2855   "cdfbr\t%0,%1"
2856   [(set_attr "op_type" "RRE")
2857    (set_attr "type"   "itof" )])
2858
2859 (define_insn "floatsidf2_ibm"
2860   [(set (match_operand:DF 0 "register_operand" "=f")
2861         (float:DF (match_operand:SI 1 "register_operand" "d")))
2862    (use (match_operand:DI 2 "immediate_operand" "m"))
2863    (use (match_operand:BLK 3 "memory_operand" "m"))
2864    (clobber (reg:CC CC_REGNUM))]
2865   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
2866 {
2867    output_asm_insn ("st\t%1,%N3", operands);
2868    output_asm_insn ("xi\t%N3,128", operands);
2869    output_asm_insn ("mvc\t%O3(4,%R3),%2", operands);
2870    output_asm_insn ("ld\t%0,%3", operands);
2871    return "sd\t%0,%2";
2872 }
2873   [(set_attr "length" "20")])
2874
2875 ;
2876 ; floatsisf2 instruction pattern(s).
2877 ;
2878
2879 (define_expand "floatsisf2"
2880   [(set (match_operand:SF 0 "register_operand" "")
2881         (float:SF (match_operand:SI 1 "register_operand" "")))]
2882   "TARGET_HARD_FLOAT"
2883 {
2884   if (TARGET_IBM_FLOAT)
2885     {
2886       /* Use the POP algorithm to convert to DFmode and then truncate.  */
2887       rtx temp = gen_reg_rtx (DFmode);
2888       emit_insn (gen_floatsidf2 (temp, operands[1]));
2889       emit_insn (gen_truncdfsf2 (operands[0], temp));
2890       DONE;
2891     }
2892 })
2893
2894 (define_insn "floatsisf2_ieee"
2895   [(set (match_operand:SF 0 "register_operand" "=f")
2896         (float:SF (match_operand:SI 1 "register_operand" "d")))]
2897   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2898   "cefbr\t%0,%1"
2899   [(set_attr "op_type" "RRE")
2900    (set_attr "type"    "itof" )])
2901
2902 ;
2903 ; truncdfsf2 instruction pattern(s).
2904 ;
2905
2906 (define_expand "truncdfsf2"
2907   [(set (match_operand:SF 0 "register_operand" "")
2908         (float_truncate:SF (match_operand:DF 1 "register_operand" "")))]
2909   "TARGET_HARD_FLOAT"
2910   "")
2911
2912 (define_insn "truncdfsf2_ieee"
2913   [(set (match_operand:SF 0 "register_operand" "=f")
2914         (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
2915   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2916   "ledbr\t%0,%1"
2917   [(set_attr "op_type"  "RRE")])
2918
2919 (define_insn "truncdfsf2_ibm"
2920   [(set (match_operand:SF 0 "register_operand" "=f,f")
2921         (float_truncate:SF (match_operand:DF 1 "nonimmediate_operand" "f,R")))]
2922   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
2923   "@
2924    ler\t%0,%1
2925    le\t%0,%1"
2926   [(set_attr "op_type"  "RR,RX")
2927    (set_attr "type"   "floadsf")])
2928
2929 ;
2930 ; extendsfdf2 instruction pattern(s).
2931 ;
2932
2933 (define_expand "extendsfdf2"
2934   [(set (match_operand:DF 0 "register_operand" "")
2935         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "")))]
2936   "TARGET_HARD_FLOAT"
2937 {
2938   if (TARGET_IBM_FLOAT)
2939     {
2940       emit_insn (gen_extendsfdf2_ibm (operands[0], operands[1]));
2941       DONE;
2942     }
2943 })
2944
2945 (define_insn "extendsfdf2_ieee"
2946   [(set (match_operand:DF 0 "register_operand" "=f,f")
2947         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand"  "f,R")))]
2948   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2949   "@
2950    ldebr\t%0,%1
2951    ldeb\t%0,%1"
2952   [(set_attr "op_type"  "RRE,RXE")
2953    (set_attr "type"   "floadsf")])
2954
2955 (define_insn "extendsfdf2_ibm"
2956   [(set (match_operand:DF 0 "register_operand" "=f,f")
2957         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,R")))
2958    (clobber (reg:CC CC_REGNUM))]
2959   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
2960   "@
2961    sdr\t%0,%0\;ler\t%0,%1
2962    sdr\t%0,%0\;le\t%0,%1"
2963   [(set_attr "length"   "4,6")
2964    (set_attr "type"     "floadsf")])
2965
2966
2967 ;;
2968 ;; ARITHMETIC OPERATIONS
2969 ;;
2970 ;  arithmetic operations set the ConditionCode,
2971 ;  because of unpredictable Bits in Register for Halfword and Byte
2972 ;  the ConditionCode can be set wrong in operations for Halfword and Byte
2973
2974 ;;
2975 ;;- Add instructions.
2976 ;;
2977
2978 ;
2979 ; addti3 instruction pattern(s).
2980 ;
2981
2982 (define_insn_and_split "addti3"
2983   [(set (match_operand:TI 0 "register_operand" "=&d")
2984         (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
2985                  (match_operand:TI 2 "general_operand" "do") ) )
2986    (clobber (reg:CC CC_REGNUM))]
2987   "TARGET_64BIT"
2988   "#"
2989   "&& reload_completed"
2990   [(parallel
2991     [(set (reg:CCL1 CC_REGNUM)
2992           (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
2993                         (match_dup 7)))
2994      (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
2995    (parallel
2996     [(set (match_dup 3) (plus:DI (plus:DI (match_dup 4) (match_dup 5))
2997                                  (ltu:DI (reg:CCL1 CC_REGNUM) (const_int 0))))
2998      (clobber (reg:CC CC_REGNUM))])]
2999   "operands[3] = operand_subword (operands[0], 0, 0, TImode);
3000    operands[4] = operand_subword (operands[1], 0, 0, TImode);
3001    operands[5] = operand_subword (operands[2], 0, 0, TImode);
3002    operands[6] = operand_subword (operands[0], 1, 0, TImode);
3003    operands[7] = operand_subword (operands[1], 1, 0, TImode);
3004    operands[8] = operand_subword (operands[2], 1, 0, TImode);")
3005
3006 ;
3007 ; adddi3 instruction pattern(s).
3008 ;
3009
3010 (define_insn "*adddi3_sign"
3011   [(set (match_operand:DI 0 "register_operand" "=d,d")
3012         (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3013                  (match_operand:DI 1 "register_operand" "0,0")))
3014    (clobber (reg:CC CC_REGNUM))]
3015   "TARGET_64BIT"
3016   "@
3017    agfr\t%0,%2
3018    agf\t%0,%2"
3019   [(set_attr "op_type"  "RRE,RXY")])
3020
3021 (define_insn "*adddi3_zero_cc"
3022   [(set (reg CC_REGNUM)
3023         (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3024                           (match_operand:DI 1 "register_operand" "0,0"))
3025                  (const_int 0)))
3026    (set (match_operand:DI 0 "register_operand" "=d,d")
3027         (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
3028   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3029   "@
3030    algfr\t%0,%2
3031    algf\t%0,%2"
3032   [(set_attr "op_type"  "RRE,RXY")])
3033
3034 (define_insn "*adddi3_zero_cconly"
3035   [(set (reg CC_REGNUM)
3036         (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3037                           (match_operand:DI 1 "register_operand" "0,0"))
3038                  (const_int 0)))
3039    (clobber (match_scratch:DI 0 "=d,d"))]
3040   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3041   "@
3042    algfr\t%0,%2
3043    algf\t%0,%2"
3044   [(set_attr "op_type"  "RRE,RXY")])
3045
3046 (define_insn "*adddi3_zero"
3047   [(set (match_operand:DI 0 "register_operand" "=d,d")
3048         (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3049                  (match_operand:DI 1 "register_operand" "0,0")))
3050    (clobber (reg:CC CC_REGNUM))]
3051   "TARGET_64BIT"
3052   "@
3053    algfr\t%0,%2
3054    algf\t%0,%2"
3055   [(set_attr "op_type"  "RRE,RXY")])
3056
3057 (define_insn "*adddi3_imm_cc"
3058   [(set (reg CC_REGNUM)
3059         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "0")
3060                           (match_operand:DI 2 "const_int_operand" "K"))
3061                  (const_int 0)))
3062    (set (match_operand:DI 0 "register_operand" "=d")
3063         (plus:DI (match_dup 1) (match_dup 2)))]
3064   "TARGET_64BIT
3065    && s390_match_ccmode (insn, CCAmode)
3066    && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")"
3067   "aghi\t%0,%h2"
3068   [(set_attr "op_type"  "RI")])
3069
3070 (define_insn "*adddi3_carry1_cc"
3071   [(set (reg CC_REGNUM)
3072         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3073                           (match_operand:DI 2 "general_operand" "d,m"))
3074                  (match_dup 1)))
3075    (set (match_operand:DI 0 "register_operand" "=d,d")
3076         (plus:DI (match_dup 1) (match_dup 2)))]
3077   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3078   "@
3079    algr\t%0,%2
3080    alg\t%0,%2"
3081   [(set_attr "op_type"  "RRE,RXY")])
3082
3083 (define_insn "*adddi3_carry1_cconly"
3084   [(set (reg CC_REGNUM)
3085         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3086                           (match_operand:DI 2 "general_operand" "d,m"))
3087                  (match_dup 1)))
3088    (clobber (match_scratch:DI 0 "=d,d"))]
3089   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3090   "@
3091    algr\t%0,%2
3092    alg\t%0,%2"
3093   [(set_attr "op_type"  "RRE,RXY")])
3094
3095 (define_insn "*adddi3_carry2_cc"
3096   [(set (reg CC_REGNUM)
3097         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3098                           (match_operand:DI 2 "general_operand" "d,m"))
3099                  (match_dup 2)))
3100    (set (match_operand:DI 0 "register_operand" "=d,d")
3101         (plus:DI (match_dup 1) (match_dup 2)))]
3102   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3103   "@
3104    algr\t%0,%2
3105    alg\t%0,%2"
3106   [(set_attr "op_type"  "RRE,RXY")])
3107
3108 (define_insn "*adddi3_carry2_cconly"
3109   [(set (reg CC_REGNUM)
3110         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3111                           (match_operand:DI 2 "general_operand" "d,m"))
3112                  (match_dup 2)))
3113    (clobber (match_scratch:DI 0 "=d,d"))]
3114   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3115   "@
3116    algr\t%0,%2
3117    alg\t%0,%2"
3118   [(set_attr "op_type"  "RRE,RXY")])
3119
3120 (define_insn "*adddi3_cc"
3121   [(set (reg CC_REGNUM)
3122         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3123                           (match_operand:DI 2 "general_operand" "d,m"))
3124                  (const_int 0)))
3125    (set (match_operand:DI 0 "register_operand" "=d,d")
3126         (plus:DI (match_dup 1) (match_dup 2)))]
3127   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3128   "@
3129    algr\t%0,%2
3130    alg\t%0,%2"
3131   [(set_attr "op_type"  "RRE,RXY")])
3132
3133 (define_insn "*adddi3_cconly"
3134   [(set (reg CC_REGNUM)
3135         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3136                           (match_operand:DI 2 "general_operand" "d,m"))
3137                  (const_int 0)))
3138    (clobber (match_scratch:DI 0 "=d,d"))]
3139   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3140   "@
3141    algr\t%0,%2
3142    alg\t%0,%2"
3143   [(set_attr "op_type"  "RRE,RXY")])
3144
3145 (define_insn "*adddi3_cconly2"
3146   [(set (reg CC_REGNUM)
3147         (compare (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3148                  (neg:SI (match_operand:DI 2 "general_operand" "d,m"))))
3149    (clobber (match_scratch:DI 0 "=d,d"))]
3150   "s390_match_ccmode(insn, CCLmode) && TARGET_64BIT"
3151   "@
3152    algr\t%0,%2
3153    alg\t%0,%2"
3154   [(set_attr "op_type"  "RRE,RXY")])
3155
3156 (define_insn "*adddi3_64"
3157   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3158         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
3159                  (match_operand:DI 2 "general_operand" "d,K,m") ) )
3160    (clobber (reg:CC CC_REGNUM))]
3161   "TARGET_64BIT"
3162   "@
3163    agr\t%0,%2
3164    aghi\t%0,%h2
3165    ag\t%0,%2"
3166   [(set_attr "op_type"  "RRE,RI,RXY")])
3167
3168 (define_insn_and_split "*adddi3_31z"
3169   [(set (match_operand:DI 0 "register_operand" "=&d")
3170         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
3171                  (match_operand:DI 2 "general_operand" "do") ) )
3172    (clobber (reg:CC CC_REGNUM))]
3173   "!TARGET_64BIT && TARGET_CPU_ZARCH"
3174   "#"
3175   "&& reload_completed"
3176   [(parallel
3177     [(set (reg:CCL1 CC_REGNUM)
3178           (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
3179                         (match_dup 7)))
3180      (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
3181    (parallel
3182     [(set (match_dup 3) (plus:SI (plus:SI (match_dup 4) (match_dup 5))
3183                                  (ltu:SI (reg:CCL1 CC_REGNUM) (const_int 0))))
3184      (clobber (reg:CC CC_REGNUM))])]
3185   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3186    operands[4] = operand_subword (operands[1], 0, 0, DImode);
3187    operands[5] = operand_subword (operands[2], 0, 0, DImode);
3188    operands[6] = operand_subword (operands[0], 1, 0, DImode);
3189    operands[7] = operand_subword (operands[1], 1, 0, DImode);
3190    operands[8] = operand_subword (operands[2], 1, 0, DImode);")
3191
3192 (define_insn_and_split "*adddi3_31"
3193   [(set (match_operand:DI 0 "register_operand" "=&d")
3194         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
3195                  (match_operand:DI 2 "general_operand" "do") ) )
3196    (clobber (reg:CC CC_REGNUM))]
3197   "!TARGET_CPU_ZARCH"
3198   "#"
3199   "&& reload_completed"
3200   [(parallel
3201     [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
3202      (clobber (reg:CC CC_REGNUM))])
3203    (parallel
3204     [(set (reg:CCL1 CC_REGNUM)
3205           (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
3206                         (match_dup 7)))
3207      (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
3208    (set (pc)
3209         (if_then_else (ltu (reg:CCL1 CC_REGNUM) (const_int 0))
3210                       (pc)
3211                       (label_ref (match_dup 9))))
3212    (parallel
3213     [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
3214      (clobber (reg:CC CC_REGNUM))])
3215    (match_dup 9)]
3216   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3217    operands[4] = operand_subword (operands[1], 0, 0, DImode);
3218    operands[5] = operand_subword (operands[2], 0, 0, DImode);
3219    operands[6] = operand_subword (operands[0], 1, 0, DImode);
3220    operands[7] = operand_subword (operands[1], 1, 0, DImode);
3221    operands[8] = operand_subword (operands[2], 1, 0, DImode);
3222    operands[9] = gen_label_rtx ();")
3223
3224 (define_expand "adddi3"
3225   [(parallel
3226     [(set (match_operand:DI 0 "register_operand" "")
3227           (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
3228                    (match_operand:DI 2 "general_operand" "")))
3229      (clobber (reg:CC CC_REGNUM))])]
3230   ""
3231   "")
3232
3233 ;
3234 ; addsi3 instruction pattern(s).
3235 ;
3236
3237 (define_insn "*addsi3_imm_cc"
3238   [(set (reg CC_REGNUM)
3239         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "0")
3240                           (match_operand:SI 2 "const_int_operand" "K"))
3241                  (const_int 0)))
3242    (set (match_operand:SI 0 "register_operand" "=d")
3243         (plus:SI (match_dup 1) (match_dup 2)))]
3244   "s390_match_ccmode (insn, CCAmode)
3245    && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")"
3246   "ahi\t%0,%h2"
3247   [(set_attr "op_type"  "RI")])
3248
3249 (define_insn "*addsi3_carry1_cc"
3250   [(set (reg CC_REGNUM)
3251         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3252                           (match_operand:SI 2 "general_operand" "d,R,T"))
3253                  (match_dup 1)))
3254    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3255         (plus:SI (match_dup 1) (match_dup 2)))]
3256   "s390_match_ccmode (insn, CCL1mode)"
3257   "@
3258    alr\t%0,%2
3259    al\t%0,%2
3260    aly\t%0,%2"
3261   [(set_attr "op_type"  "RR,RX,RXY")])
3262
3263 (define_insn "*addsi3_carry1_cconly"
3264   [(set (reg CC_REGNUM)
3265         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3266                           (match_operand:SI 2 "general_operand" "d,R,T"))
3267                  (match_dup 1)))
3268    (clobber (match_scratch:SI 0 "=d,d,d"))]
3269   "s390_match_ccmode (insn, CCL1mode)"
3270   "@
3271    alr\t%0,%2
3272    al\t%0,%2
3273    aly\t%0,%2"
3274   [(set_attr "op_type"  "RR,RX,RXY")])
3275
3276 (define_insn "*addsi3_carry2_cc"
3277   [(set (reg CC_REGNUM)
3278         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3279                           (match_operand:SI 2 "general_operand" "d,R,T"))
3280                  (match_dup 2)))
3281    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3282         (plus:SI (match_dup 1) (match_dup 2)))]
3283   "s390_match_ccmode (insn, CCL1mode)"
3284   "@
3285    alr\t%0,%2
3286    al\t%0,%2
3287    aly\t%0,%2"
3288   [(set_attr "op_type"  "RR,RX,RXY")])
3289
3290 (define_insn "*addsi3_carry2_cconly"
3291   [(set (reg CC_REGNUM)
3292         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3293                           (match_operand:SI 2 "general_operand" "d,R,T"))
3294                  (match_dup 2)))
3295    (clobber (match_scratch:SI 0 "=d,d,d"))]
3296   "s390_match_ccmode (insn, CCL1mode)"
3297   "@
3298    alr\t%0,%2
3299    al\t%0,%2
3300    aly\t%0,%2"
3301   [(set_attr "op_type"  "RR,RX,RXY")])
3302
3303 (define_insn "*addsi3_cc"
3304   [(set (reg CC_REGNUM)
3305         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3306                           (match_operand:SI 2 "general_operand" "d,R,T"))
3307                  (const_int 0)))
3308    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3309         (plus:SI (match_dup 1) (match_dup 2)))]
3310   "s390_match_ccmode (insn, CCLmode)"
3311   "@
3312    alr\t%0,%2
3313    al\t%0,%2
3314    aly\t%0,%2"
3315   [(set_attr "op_type"  "RR,RX,RXY")])
3316
3317 (define_insn "*addsi3_cconly"
3318   [(set (reg CC_REGNUM)
3319         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3320                           (match_operand:SI 2 "general_operand" "d,R,T"))
3321                  (const_int 0)))
3322    (clobber (match_scratch:SI 0 "=d,d,d"))]
3323   "s390_match_ccmode (insn, CCLmode)"
3324   "@
3325    alr\t%0,%2
3326    al\t%0,%2
3327    aly\t%0,%2"
3328   [(set_attr "op_type"  "RR,RX,RXY")])
3329
3330 (define_insn "*addsi3_cconly2"
3331   [(set (reg CC_REGNUM)
3332         (compare (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3333                  (neg:SI (match_operand:SI 2 "general_operand" "d,R,T"))))
3334    (clobber (match_scratch:SI 0 "=d,d,d"))]
3335   "s390_match_ccmode (insn, CCLmode)"
3336   "@
3337    alr\t%0,%2
3338    al\t%0,%2
3339    aly\t%0,%2"
3340   [(set_attr "op_type"  "RR,RX,RXY")])
3341
3342 (define_insn "*addsi3_sign"
3343   [(set (match_operand:SI 0 "register_operand" "=d,d")
3344         (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
3345                  (match_operand:SI 1 "register_operand" "0,0")))
3346    (clobber (reg:CC CC_REGNUM))]
3347   ""
3348   "@
3349    ah\t%0,%2
3350    ahy\t%0,%2"
3351   [(set_attr "op_type"  "RX,RXY")])
3352
3353 (define_insn "addsi3"
3354   [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
3355         (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
3356                  (match_operand:SI 2 "general_operand" "d,K,R,T")))
3357    (clobber (reg:CC CC_REGNUM))]
3358   ""
3359   "@
3360    ar\t%0,%2
3361    ahi\t%0,%h2
3362    a\t%0,%2
3363    ay\t%0,%2"
3364   [(set_attr "op_type"  "RR,RI,RX,RXY")])
3365
3366 ;
3367 ; add(df|sf)3 instruction pattern(s).
3368 ;
3369
3370 (define_expand "add<mode>3"
3371   [(parallel
3372     [(set (match_operand:FPR 0 "register_operand" "=f,f")
3373           (plus:FPR (match_operand:FPR 1 "nonimmediate_operand" "%0,0")
3374                     (match_operand:FPR 2 "general_operand" "f,R")))
3375      (clobber (reg:CC CC_REGNUM))])]
3376   "TARGET_HARD_FLOAT"
3377   "")
3378
3379 (define_insn "*add<mode>3"
3380   [(set (match_operand:FPR 0 "register_operand" "=f,f")
3381         (plus:FPR (match_operand:FPR 1 "nonimmediate_operand" "%0,0")
3382                   (match_operand:FPR 2 "general_operand" "f,R")))
3383    (clobber (reg:CC CC_REGNUM))]
3384   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3385   "@
3386    a<de>br\t%0,%2
3387    a<de>b\t%0,%2"
3388   [(set_attr "op_type"  "RRE,RXE")
3389    (set_attr "type"     "fsimp<mode>")])
3390
3391 (define_insn "*add<mode>3_cc"
3392   [(set (reg CC_REGNUM)
3393         (compare (plus:FPR (match_operand:FPR 1 "nonimmediate_operand" "%0,0")
3394                            (match_operand:FPR 2 "general_operand" "f,R"))
3395                  (match_operand:FPR 3 "const0_operand" "")))
3396    (set (match_operand:FPR 0 "register_operand" "=f,f")
3397         (plus:FPR (match_dup 1) (match_dup 2)))]
3398   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3399   "@
3400    a<de>br\t%0,%2
3401    a<de>b\t%0,%2"
3402   [(set_attr "op_type"  "RRE,RXE")
3403    (set_attr "type"     "fsimp<mode>")])
3404
3405 (define_insn "*add<mode>3_cconly"
3406   [(set (reg CC_REGNUM)
3407         (compare (plus:FPR (match_operand:FPR 1 "nonimmediate_operand" "%0,0")
3408                            (match_operand:FPR 2 "general_operand" "f,R"))
3409                  (match_operand:FPR 3 "const0_operand" "")))
3410    (clobber (match_scratch:FPR 0 "=f,f"))]
3411   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3412   "@
3413    a<de>br\t%0,%2
3414    a<de>b\t%0,%2"
3415   [(set_attr "op_type"  "RRE,RXE")
3416    (set_attr "type"     "fsimp<mode>")])
3417
3418 (define_insn "*add<mode>3_ibm"
3419   [(set (match_operand:FPR 0 "register_operand" "=f,f")
3420         (plus:FPR (match_operand:FPR 1 "nonimmediate_operand" "%0,0")
3421                   (match_operand:FPR 2 "general_operand" "f,R")))
3422    (clobber (reg:CC CC_REGNUM))]
3423   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3424   "@
3425    a<de>r\t%0,%2
3426    a<de>\t%0,%2"
3427   [(set_attr "op_type"  "RR,RX")
3428    (set_attr "type"     "fsimp<mode>")])
3429
3430
3431 ;;
3432 ;;- Subtract instructions.
3433 ;;
3434
3435 ;
3436 ; subti3 instruction pattern(s).
3437 ;
3438
3439 (define_insn_and_split "subti3"
3440   [(set (match_operand:TI 0 "register_operand" "=&d")
3441         (minus:TI (match_operand:TI 1 "register_operand" "0")
3442                   (match_operand:TI 2 "general_operand" "do") ) )
3443    (clobber (reg:CC CC_REGNUM))]
3444   "TARGET_64BIT"
3445   "#"
3446   "&& reload_completed"
3447   [(parallel
3448     [(set (reg:CCL2 CC_REGNUM)
3449           (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
3450                         (match_dup 7)))
3451      (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
3452    (parallel
3453     [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
3454                                   (gtu:DI (reg:CCL2 CC_REGNUM) (const_int 0))))
3455      (clobber (reg:CC CC_REGNUM))])]
3456   "operands[3] = operand_subword (operands[0], 0, 0, TImode);
3457    operands[4] = operand_subword (operands[1], 0, 0, TImode);
3458    operands[5] = operand_subword (operands[2], 0, 0, TImode);
3459    operands[6] = operand_subword (operands[0], 1, 0, TImode);
3460    operands[7] = operand_subword (operands[1], 1, 0, TImode);
3461    operands[8] = operand_subword (operands[2], 1, 0, TImode);")
3462
3463 ;
3464 ; subdi3 instruction pattern(s).
3465 ;
3466
3467 (define_insn "*subdi3_sign"
3468   [(set (match_operand:DI 0 "register_operand" "=d,d")
3469         (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3470                   (sign_extend:DI (match_operand:SI 2 "general_operand" "d,m"))))
3471    (clobber (reg:CC CC_REGNUM))]
3472   "TARGET_64BIT"
3473   "@
3474    sgfr\t%0,%2
3475    sgf\t%0,%2"
3476   [(set_attr "op_type"  "RRE,RXY")])
3477
3478 (define_insn "*subdi3_zero_cc"
3479   [(set (reg CC_REGNUM)
3480         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3481                            (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m")))
3482                  (const_int 0)))
3483    (set (match_operand:DI 0 "register_operand" "=d,d")
3484         (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
3485   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3486   "@
3487    slgfr\t%0,%2
3488    slgf\t%0,%2"
3489   [(set_attr "op_type"  "RRE,RXY")])
3490
3491 (define_insn "*subdi3_zero_cconly"
3492   [(set (reg CC_REGNUM)
3493         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3494                            (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m")))
3495                  (const_int 0)))
3496    (clobber (match_scratch:DI 0 "=d,d"))]
3497   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3498   "@
3499    slgfr\t%0,%2
3500    slgf\t%0,%2"
3501   [(set_attr "op_type"  "RRE,RXY")])
3502
3503 (define_insn "*subdi3_zero"
3504   [(set (match_operand:DI 0 "register_operand" "=d,d")
3505         (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3506                   (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))))
3507    (clobber (reg:CC CC_REGNUM))]
3508   "TARGET_64BIT"
3509   "@
3510    slgfr\t%0,%2
3511    slgf\t%0,%2"
3512   [(set_attr "op_type"  "RRE,RXY")])
3513
3514 (define_insn "*subdi3_borrow_cc"
3515   [(set (reg CC_REGNUM)
3516         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3517                            (match_operand:DI 2 "general_operand" "d,m"))
3518                  (match_dup 1)))
3519    (set (match_operand:DI 0 "register_operand" "=d,d")
3520         (minus:DI (match_dup 1) (match_dup 2)))]
3521   "s390_match_ccmode (insn, CCL2mode) && TARGET_64BIT"
3522   "@
3523    slgr\t%0,%2
3524    slg\t%0,%2"
3525   [(set_attr "op_type"  "RRE,RXY")])
3526
3527 (define_insn "*subdi3_borrow_cconly"