OSDN Git Service

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