OSDN Git Service

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