OSDN Git Service

2004-06-12 Eric Christopher <echristo@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / config / s390 / s390.md
1 ;;- Machine description for GNU compiler -- S/390 / zSeries version.
2 ;;  Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
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_cconly"
3980   [(set (reg 33)
3981         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3982                            (match_operand:DI 2 "general_operand" "d,m"))
3983                  (const_int 0)))
3984    (clobber (match_scratch:DI 0 "=d,d"))]
3985   "s390_match_ccmode (insn, CCLmode) && 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_64"
3992   [(set (match_operand:DI 0 "register_operand" "=d,d")
3993         (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3994                   (match_operand:DI 2 "general_operand" "d,m") ) )
3995    (clobber (reg:CC 33))]
3996   "TARGET_64BIT"
3997   "@
3998    sgr\t%0,%2
3999    sg\t%0,%2"
4000   [(set_attr "op_type"  "RRE,RRE")])
4001
4002 (define_insn_and_split "*subdi3_31z"
4003   [(set (match_operand:DI 0 "register_operand" "=&d")
4004         (minus:DI (match_operand:DI 1 "register_operand" "0")
4005                   (match_operand:DI 2 "general_operand" "do") ) )
4006    (clobber (reg:CC 33))]
4007   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4008   "#"
4009   "&& reload_completed"
4010   [(parallel
4011     [(set (reg:CCL2 33)
4012           (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
4013                         (match_dup 7)))
4014      (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
4015    (parallel
4016     [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
4017                                   (gtu:SI (reg:CCL2 33) (const_int 0))))
4018      (clobber (reg:CC 33))])]
4019   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4020    operands[4] = operand_subword (operands[1], 0, 0, DImode);
4021    operands[5] = operand_subword (operands[2], 0, 0, DImode);
4022    operands[6] = operand_subword (operands[0], 1, 0, DImode);
4023    operands[7] = operand_subword (operands[1], 1, 0, DImode);
4024    operands[8] = operand_subword (operands[2], 1, 0, DImode);"
4025   [(set_attr "op_type"  "NN")])
4026
4027 (define_insn_and_split "*subdi3_31"
4028   [(set (match_operand:DI 0 "register_operand" "=&d")
4029         (minus:DI (match_operand:DI 1 "register_operand" "0")
4030                   (match_operand:DI 2 "general_operand" "do") ) )
4031    (clobber (reg:CC 33))]
4032   "!TARGET_CPU_ZARCH"
4033   "#"
4034   "&& reload_completed"
4035   [(parallel
4036     [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
4037      (clobber (reg:CC 33))])
4038    (parallel
4039     [(set (reg:CCL2 33)
4040           (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
4041                         (match_dup 7)))
4042      (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
4043    (set (pc)
4044         (if_then_else (gtu (reg:CCL2 33) (const_int 0))
4045                       (pc)
4046                       (label_ref (match_dup 9))))
4047    (parallel
4048     [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
4049      (clobber (reg:CC 33))])
4050    (match_dup 9)]
4051   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4052    operands[4] = operand_subword (operands[1], 0, 0, DImode);
4053    operands[5] = operand_subword (operands[2], 0, 0, DImode);
4054    operands[6] = operand_subword (operands[0], 1, 0, DImode);
4055    operands[7] = operand_subword (operands[1], 1, 0, DImode);
4056    operands[8] = operand_subword (operands[2], 1, 0, DImode);
4057    operands[9] = gen_label_rtx ();"
4058   [(set_attr "op_type"  "NN")])
4059
4060 (define_expand "subdi3"
4061   [(parallel
4062     [(set (match_operand:DI 0 "register_operand" "")
4063           (minus:DI (match_operand:DI 1 "register_operand" "")
4064                     (match_operand:DI 2 "general_operand" "")))
4065      (clobber (reg:CC 33))])]
4066   ""
4067   "")
4068
4069 ;
4070 ; subsi3 instruction pattern(s).
4071 ;
4072
4073 (define_insn "*subsi3_borrow_cc"
4074   [(set (reg 33)
4075         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4076                            (match_operand:SI 2 "general_operand" "d,R,T"))
4077                  (match_dup 1)))
4078    (set (match_operand:SI 0 "register_operand" "=d,d,d")
4079         (minus:SI (match_dup 1) (match_dup 2)))]
4080   "s390_match_ccmode (insn, CCL2mode)"
4081   "@
4082    slr\t%0,%2
4083    sl\t%0,%2
4084    sly\t%0,%2"
4085   [(set_attr "op_type"  "RR,RX,RXY")])
4086
4087 (define_insn "*subsi3_borrow_cconly"
4088   [(set (reg 33)
4089         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4090                            (match_operand:SI 2 "general_operand" "d,R,T"))
4091                  (match_dup 1)))
4092    (clobber (match_scratch:SI 0 "=d,d,d"))]
4093   "s390_match_ccmode (insn, CCL2mode)"
4094   "@
4095    slr\t%0,%2
4096    sl\t%0,%2
4097    sly\t%0,%2"
4098   [(set_attr "op_type"  "RR,RX,RXY")])
4099
4100 (define_insn "*subsi3_cc"
4101   [(set (reg 33)
4102         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4103                            (match_operand:SI 2 "general_operand" "d,R,T"))
4104                  (const_int 0)))
4105    (set (match_operand:SI 0 "register_operand" "=d,d,d")
4106         (minus:SI (match_dup 1) (match_dup 2)))]
4107   "s390_match_ccmode (insn, CCLmode)"
4108   "@
4109    slr\t%0,%2
4110    sl\t%0,%2
4111    sly\t%0,%2"
4112   [(set_attr "op_type"  "RR,RX,RXY")])
4113
4114 (define_insn "*subsi3_cconly"
4115   [(set (reg 33)
4116         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4117                            (match_operand:SI 2 "general_operand" "d,R,T"))
4118                  (const_int 0)))
4119    (clobber (match_scratch:SI 0 "=d,d,d"))]
4120   "s390_match_ccmode (insn, CCLmode)"
4121   "@
4122    slr\t%0,%2
4123    sl\t%0,%2
4124    sly\t%0,%2"
4125   [(set_attr "op_type"  "RR,RX,RXY")])
4126
4127 (define_insn "*subsi3_sign"
4128   [(set (match_operand:SI 0 "register_operand" "=d,d")
4129         (minus:SI (match_operand:SI 1 "register_operand" "0,0")
4130                   (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
4131    (clobber (reg:CC 33))]
4132   ""
4133   "@
4134    sh\t%0,%2
4135    shy\t%0,%2"
4136   [(set_attr "op_type"  "RX,RXY")])
4137
4138 (define_insn "subsi3"
4139   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
4140         (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4141                   (match_operand:SI 2 "general_operand" "d,R,T")))
4142    (clobber (reg:CC 33))]
4143   ""
4144   "@
4145    sr\t%0,%2
4146    s\t%0,%2
4147    sy\t%0,%2"
4148   [(set_attr "op_type"  "RR,RX,RXY")])
4149
4150
4151 ;
4152 ; subdf3 instruction pattern(s).
4153 ;
4154
4155 (define_expand "subdf3"
4156   [(parallel
4157     [(set (match_operand:DF 0 "register_operand" "=f,f")
4158           (minus:DF (match_operand:DF 1 "register_operand" "0,0")
4159                     (match_operand:DF 2 "general_operand" "f,R")))
4160      (clobber (reg:CC 33))])]
4161   "TARGET_HARD_FLOAT"
4162   "")
4163
4164 (define_insn "*subdf3"
4165   [(set (match_operand:DF 0 "register_operand" "=f,f")
4166         (minus:DF (match_operand:DF 1 "register_operand" "0,0")
4167                   (match_operand:DF 2 "general_operand" "f,R")))
4168    (clobber (reg:CC 33))]
4169   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4170   "@
4171    sdbr\t%0,%2
4172    sdb\t%0,%2"
4173   [(set_attr "op_type"  "RRE,RXE")
4174    (set_attr "type"     "fsimpd,fsimpd")])
4175
4176 (define_insn "*subdf3_cc"
4177   [(set (reg 33)
4178         (compare (minus:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")
4179                            (match_operand:DF 2 "general_operand" "f,R"))
4180                  (match_operand:DF 3 "const0_operand" "")))
4181    (set (match_operand:DF 0 "register_operand" "=f,f")
4182         (plus:DF (match_dup 1) (match_dup 2)))]
4183   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4184   "@
4185    sdbr\t%0,%2
4186    sdb\t%0,%2"
4187   [(set_attr "op_type"  "RRE,RXE")
4188    (set_attr "type"     "fsimpd,fsimpd")])
4189
4190 (define_insn "*subdf3_cconly"
4191   [(set (reg 33)
4192         (compare (minus:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")
4193                            (match_operand:DF 2 "general_operand" "f,R"))
4194                  (match_operand:DF 3 "const0_operand" "")))
4195    (clobber (match_scratch:DF 0 "=f,f"))]
4196   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4197   "@
4198    sdbr\t%0,%2
4199    sdb\t%0,%2"
4200   [(set_attr "op_type"  "RRE,RXE")
4201    (set_attr "type"     "fsimpd,fsimpd")])
4202
4203 (define_insn "*subdf3_ibm"
4204   [(set (match_operand:DF 0 "register_operand" "=f,f")
4205         (minus:DF (match_operand:DF 1 "register_operand" "0,0")
4206                   (match_operand:DF 2 "general_operand" "f,R")))
4207    (clobber (reg:CC 33))]
4208   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4209   "@
4210    sdr\t%0,%2
4211    sd\t%0,%2"
4212   [(set_attr "op_type"  "RR,RX")
4213    (set_attr "type"     "fsimpd,fsimpd")])
4214
4215 ;
4216 ; subsf3 instruction pattern(s).
4217 ;
4218
4219 (define_expand "subsf3"
4220   [(parallel
4221     [(set (match_operand:SF 0 "register_operand" "=f,f")
4222           (minus:SF (match_operand:SF 1 "register_operand" "0,0")
4223                     (match_operand:SF 2 "general_operand" "f,R")))
4224      (clobber (reg:CC 33))])]
4225   "TARGET_HARD_FLOAT"
4226   "")
4227
4228 (define_insn "*subsf3"
4229   [(set (match_operand:SF 0 "register_operand" "=f,f")
4230         (minus:SF (match_operand:SF 1 "register_operand" "0,0")
4231                   (match_operand:SF 2 "general_operand" "f,R")))
4232    (clobber (reg:CC 33))]
4233   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4234   "@
4235    sebr\t%0,%2
4236    seb\t%0,%2"
4237   [(set_attr "op_type"  "RRE,RXE")
4238    (set_attr "type"     "fsimps,fsimps")])
4239
4240 (define_insn "*subsf3_cc"
4241   [(set (reg 33)
4242         (compare (minus:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")
4243                            (match_operand:SF 2 "general_operand" "f,R"))
4244                  (match_operand:SF 3 "const0_operand" "")))
4245    (set (match_operand:SF 0 "register_operand" "=f,f")
4246         (minus:SF (match_dup 1) (match_dup 2)))]
4247   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4248   "@
4249    sebr\t%0,%2
4250    seb\t%0,%2"
4251   [(set_attr "op_type"  "RRE,RXE")
4252    (set_attr "type"     "fsimps,fsimps")])
4253
4254 (define_insn "*subsf3_cconly"
4255   [(set (reg 33)
4256         (compare (minus:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")
4257                            (match_operand:SF 2 "general_operand" "f,R"))
4258                  (match_operand:SF 3 "const0_operand" "")))
4259    (clobber (match_scratch:SF 0 "=f,f"))]
4260   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4261   "@
4262    sebr\t%0,%2
4263    seb\t%0,%2"
4264   [(set_attr "op_type"  "RRE,RXE")
4265    (set_attr "type"     "fsimps,fsimps")])
4266
4267 (define_insn "*subsf3_ibm"
4268   [(set (match_operand:SF 0 "register_operand" "=f,f")
4269         (minus:SF (match_operand:SF 1 "register_operand" "0,0")
4270                   (match_operand:SF 2 "general_operand" "f,R")))
4271    (clobber (reg:CC 33))]
4272   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4273   "@
4274    ser\t%0,%2
4275    se\t%0,%2"
4276   [(set_attr "op_type"  "RR,RX")
4277    (set_attr "type"     "fsimps,fsimps")])
4278
4279
4280 ;;
4281 ;;- Conditional add/subtract instructions.
4282 ;;
4283
4284 ;
4285 ; adddicc instruction pattern(s).
4286 ;
4287
4288 (define_insn "*adddi3_alc_cc"
4289   [(set (reg 33)
4290         (compare
4291           (plus:DI (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4292                             (match_operand:DI 2 "general_operand" "d,m"))
4293                    (match_operand:DI 3 "s390_alc_comparison" ""))
4294           (const_int 0)))
4295    (set (match_operand:DI 0 "register_operand" "=d,d")
4296         (plus:DI (plus:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4297   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4298   "@
4299    alcgr\\t%0,%2
4300    alcg\\t%0,%2"
4301   [(set_attr "op_type"  "RRE,RXY")])
4302
4303 (define_insn "*adddi3_alc"
4304   [(set (match_operand:DI 0 "register_operand" "=d,d")
4305         (plus:DI (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4306                           (match_operand:DI 2 "general_operand" "d,m"))
4307                  (match_operand:DI 3 "s390_alc_comparison" "")))
4308    (clobber (reg:CC 33))]
4309   "TARGET_64BIT"
4310   "@
4311    alcgr\\t%0,%2
4312    alcg\\t%0,%2"
4313   [(set_attr "op_type"  "RRE,RXY")])
4314
4315 (define_insn "*subdi3_slb_cc"
4316   [(set (reg 33)
4317         (compare
4318           (minus:DI (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
4319                               (match_operand:DI 2 "general_operand" "d,m"))
4320                     (match_operand:DI 3 "s390_slb_comparison" ""))
4321           (const_int 0)))
4322    (set (match_operand:DI 0 "register_operand" "=d,d")
4323         (minus:DI (minus:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4324   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4325   "@
4326    slbgr\\t%0,%2
4327    slbg\\t%0,%2"
4328   [(set_attr "op_type"  "RRE,RXY")])
4329
4330 (define_insn "*subdi3_slb"
4331   [(set (match_operand:DI 0 "register_operand" "=d,d")
4332         (minus:DI (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
4333                             (match_operand:DI 2 "general_operand" "d,m"))
4334                   (match_operand:DI 3 "s390_slb_comparison" "")))
4335    (clobber (reg:CC 33))]
4336   "TARGET_64BIT"
4337   "@
4338    slbgr\\t%0,%2
4339    slbg\\t%0,%2"
4340   [(set_attr "op_type"  "RRE,RXY")])
4341
4342 ;
4343 ; addsicc instruction pattern(s).
4344 ;
4345
4346 (define_insn "*addsi3_alc_cc"
4347   [(set (reg 33)
4348         (compare
4349           (plus:SI (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
4350                             (match_operand:SI 2 "general_operand" "d,m"))
4351                    (match_operand:SI 3 "s390_alc_comparison" ""))
4352           (const_int 0)))
4353    (set (match_operand:SI 0 "register_operand" "=d,d")
4354         (plus:SI (plus:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4355   "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
4356   "@
4357    alcr\\t%0,%2
4358    alc\\t%0,%2"
4359   [(set_attr "op_type"  "RRE,RXY")])
4360
4361 (define_insn "*addsi3_alc"
4362   [(set (match_operand:SI 0 "register_operand" "=d,d")
4363         (plus:SI (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
4364                           (match_operand:SI 2 "general_operand" "d,m"))
4365                  (match_operand:SI 3 "s390_alc_comparison" "")))
4366    (clobber (reg:CC 33))]
4367   "TARGET_CPU_ZARCH"
4368   "@
4369    alcr\\t%0,%2
4370    alc\\t%0,%2"
4371   [(set_attr "op_type"  "RRE,RXY")])
4372
4373 (define_insn "*subsi3_slb_cc"
4374   [(set (reg 33)
4375         (compare
4376           (minus:SI (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
4377                               (match_operand:SI 2 "general_operand" "d,m"))
4378                     (match_operand:SI 3 "s390_slb_comparison" ""))
4379           (const_int 0)))
4380    (set (match_operand:SI 0 "register_operand" "=d,d")
4381         (minus:SI (minus:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4382   "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
4383   "@
4384    slbr\\t%0,%2
4385    slb\\t%0,%2"
4386   [(set_attr "op_type"  "RRE,RXY")])
4387
4388 (define_insn "*subsi3_slb"
4389   [(set (match_operand:SI 0 "register_operand" "=d,d")
4390         (minus:SI (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
4391                             (match_operand:SI 2 "general_operand" "d,m"))
4392                   (match_operand:SI 3 "s390_slb_comparison" "")))
4393    (clobber (reg:CC 33))]
4394   "TARGET_CPU_ZARCH"
4395   "@
4396    slbr\\t%0,%2
4397    slb\\t%0,%2"
4398   [(set_attr "op_type"  "RRE,RXY")])
4399
4400
4401 ;;
4402 ;;- Multiply instructions.
4403 ;;
4404
4405 ;
4406 ; muldi3 instruction pattern(s).
4407 ;
4408
4409 (define_insn "*muldi3_sign"
4410   [(set (match_operand:DI 0 "register_operand" "=d,d")
4411         (mult:DI (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "d,m"))
4412                  (match_operand:DI 1 "register_operand" "0,0")))]
4413   "TARGET_64BIT"
4414   "@
4415    msgfr\t%0,%2
4416    msgf\t%0,%2"
4417   [(set_attr "op_type"  "RRE,RXY")
4418    (set_attr "type"     "imul")])
4419
4420 (define_insn "muldi3"
4421   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
4422         (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
4423                  (match_operand:DI 2 "general_operand" "d,K,m")))]
4424   "TARGET_64BIT"
4425   "@
4426    msgr\t%0,%2
4427    mghi\t%0,%h2
4428    msg\t%0,%2"
4429   [(set_attr "op_type"  "RRE,RI,RXY")
4430    (set_attr "type"     "imul")])
4431
4432 ;
4433 ; mulsi3 instruction pattern(s).
4434 ;
4435
4436 (define_insn "*mulsi3_sign"
4437   [(set (match_operand:SI 0 "register_operand" "=d")
4438         (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R"))
4439                  (match_operand:SI 1 "register_operand" "0")))]
4440   ""
4441   "mh\t%0,%2"
4442   [(set_attr "op_type"  "RX")
4443    (set_attr "type"     "imul")])
4444
4445 (define_insn "mulsi3"
4446   [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
4447         (mult:SI  (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
4448                   (match_operand:SI 2 "general_operand" "d,K,R,T")))]
4449   ""
4450   "@
4451    msr\t%0,%2
4452    mhi\t%0,%h2
4453    ms\t%0,%2
4454    msy\t%0,%2"
4455   [(set_attr "op_type"  "RRE,RI,RX,RXY")
4456    (set_attr "type"     "imul")])
4457
4458 ;
4459 ; mulsidi3 instruction pattern(s).
4460 ;
4461
4462 (define_insn "mulsidi3"
4463   [(set (match_operand:DI 0 "register_operand" "=d,d")
4464         (mult:DI (sign_extend:DI
4465                    (match_operand:SI 1 "register_operand" "%0,0"))
4466                  (sign_extend:DI
4467                    (match_operand:SI 2 "nonimmediate_operand" "d,R"))))]
4468   "!TARGET_64BIT"
4469   "@
4470    mr\t%0,%2
4471    m\t%0,%2"
4472   [(set_attr "op_type"  "RR,RX")
4473    (set_attr "type"     "imul")])
4474
4475 ;
4476 ; umulsidi3 instruction pattern(s).
4477 ;
4478
4479 (define_insn "umulsidi3"
4480   [(set (match_operand:DI 0 "register_operand" "=d,d")
4481         (mult:DI (zero_extend:DI
4482                    (match_operand:SI 1 "register_operand" "%0,0"))
4483                  (zero_extend:DI
4484                    (match_operand:SI 2 "nonimmediate_operand" "d,m"))))]
4485   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4486   "@
4487    mlr\t%0,%2
4488    ml\t%0,%2"
4489   [(set_attr "op_type"  "RRE,RXY")
4490    (set_attr "type"     "imul")])
4491
4492 ;
4493 ; muldf3 instruction pattern(s).
4494 ;
4495
4496 (define_expand "muldf3"
4497   [(set (match_operand:DF 0 "register_operand" "=f,f")
4498         (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4499                  (match_operand:DF 2 "general_operand" "f,R")))]
4500   "TARGET_HARD_FLOAT"
4501   "")
4502
4503 (define_insn "*muldf3"
4504   [(set (match_operand:DF 0 "register_operand" "=f,f")
4505         (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4506                  (match_operand:DF 2 "general_operand" "f,R")))]
4507   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4508   "@
4509    mdbr\t%0,%2
4510    mdb\t%0,%2"
4511   [(set_attr "op_type"  "RRE,RXE")
4512    (set_attr "type"     "fmuld")])
4513
4514 (define_insn "*muldf3_ibm"
4515   [(set (match_operand:DF 0 "register_operand" "=f,f")
4516         (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4517                  (match_operand:DF 2 "general_operand" "f,R")))]
4518   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4519   "@
4520    mdr\t%0,%2
4521    md\t%0,%2"
4522   [(set_attr "op_type"  "RR,RX")
4523    (set_attr "type"    "fmuld")])
4524
4525 (define_insn "*fmadddf"
4526   [(set (match_operand:DF 0 "register_operand" "=f,f")
4527         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "%f,f")
4528                           (match_operand:DF 2 "nonimmediate_operand"  "f,R"))
4529                  (match_operand:DF 3 "register_operand" "0,0")))]
4530   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4531   "@
4532    madbr\t%0,%1,%2
4533    madb\t%0,%1,%2"
4534   [(set_attr "op_type"  "RRE,RXE")
4535    (set_attr "type" "fmuld")])
4536
4537 (define_insn "*fmsubdf"
4538   [(set (match_operand:DF 0 "register_operand" "=f,f")
4539         (minus:DF (mult:DF (match_operand:DF 1 "register_operand" "f,f")
4540                            (match_operand:DF 2 "nonimmediate_operand"  "f,R"))
4541                  (match_operand:DF 3 "register_operand" "0,0")))]
4542   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4543   "@
4544    msdbr\t%0,%1,%2
4545    msdb\t%0,%1,%2"
4546   [(set_attr "op_type"  "RRE,RXE")
4547    (set_attr "type" "fmuld")])
4548
4549 ;
4550 ; mulsf3 instruction pattern(s).
4551 ;
4552
4553 (define_expand "mulsf3"
4554   [(set (match_operand:SF 0 "register_operand" "=f,f")
4555         (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4556                  (match_operand:SF 2 "general_operand" "f,R")))]
4557   "TARGET_HARD_FLOAT"
4558   "")
4559
4560 (define_insn "*mulsf3"
4561   [(set (match_operand:SF 0 "register_operand" "=f,f")
4562         (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4563                  (match_operand:SF 2 "general_operand" "f,R")))]
4564   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4565   "@
4566    meebr\t%0,%2
4567    meeb\t%0,%2"
4568   [(set_attr "op_type"  "RRE,RXE")
4569    (set_attr "type"     "fmuls")])
4570
4571 (define_insn "*mulsf3_ibm"
4572   [(set (match_operand:SF 0 "register_operand" "=f,f")
4573         (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4574                  (match_operand:SF 2 "general_operand" "f,R")))]
4575   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4576   "@
4577    mer\t%0,%2
4578    me\t%0,%2"
4579   [(set_attr "op_type"  "RR,RX")
4580    (set_attr "type"     "fmuls")])
4581
4582 (define_insn "*fmaddsf"
4583   [(set (match_operand:SF 0 "register_operand" "=f,f")
4584         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f,f")
4585                           (match_operand:SF 2 "nonimmediate_operand"  "f,R"))
4586                  (match_operand:SF 3 "register_operand" "0,0")))]
4587   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4588   "@
4589    maebr\t%0,%1,%2
4590    maeb\t%0,%1,%2"
4591   [(set_attr "op_type"  "RRE,RXE")
4592    (set_attr "type" "fmuls")])
4593
4594 (define_insn "*fmsubsf"
4595   [(set (match_operand:SF 0 "register_operand" "=f,f")
4596         (minus:SF (mult:SF (match_operand:SF 1 "register_operand" "f,f")
4597                            (match_operand:SF 2 "nonimmediate_operand"  "f,R"))
4598                   (match_operand:SF 3 "register_operand" "0,0")))]
4599   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4600   "@
4601    msebr\t%0,%1,%2
4602    mseb\t%0,%1,%2"
4603   [(set_attr "op_type"  "RRE,RXE")
4604    (set_attr "type" "fmuls")])
4605
4606 ;;
4607 ;;- Divide and modulo instructions.
4608 ;;
4609
4610 ;
4611 ; divmoddi4 instruction pattern(s).
4612 ;
4613
4614 (define_expand "divmoddi4"
4615   [(parallel [(set (match_operand:DI 0 "general_operand" "")
4616                    (div:DI (match_operand:DI 1 "register_operand" "")
4617                            (match_operand:DI 2 "general_operand" "")))
4618               (set (match_operand:DI 3 "general_operand" "")
4619                    (mod:DI (match_dup 1) (match_dup 2)))])
4620    (clobber (match_dup 4))]
4621   "TARGET_64BIT"
4622 {
4623   rtx insn, div_equal, mod_equal;
4624
4625   div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
4626   mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
4627
4628   operands[4] = gen_reg_rtx(TImode);
4629   emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
4630
4631   insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
4632   REG_NOTES (insn) =
4633         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4634
4635   insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
4636   REG_NOTES (insn) =
4637         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4638
4639   DONE;
4640 })
4641
4642 (define_insn "divmodtidi3"
4643   [(set (match_operand:TI 0 "register_operand" "=d,d")
4644         (ior:TI
4645           (ashift:TI
4646             (zero_extend:TI
4647               (mod:DI (match_operand:DI 1 "register_operand" "0,0")
4648                       (match_operand:DI 2 "general_operand" "d,m")))
4649             (const_int 64))
4650           (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
4651   "TARGET_64BIT"
4652   "@
4653    dsgr\t%0,%2
4654    dsg\t%0,%2"
4655   [(set_attr "op_type"  "RRE,RXY")
4656    (set_attr "type"     "idiv")])
4657
4658 (define_insn "divmodtisi3"
4659   [(set (match_operand:TI 0 "register_operand" "=d,d")
4660         (ior:TI
4661           (ashift:TI
4662             (zero_extend:TI
4663               (mod:DI (match_operand:DI 1 "register_operand" "0,0")
4664                       (sign_extend:DI
4665                         (match_operand:SI 2 "nonimmediate_operand" "d,m"))))
4666             (const_int 64))
4667           (zero_extend:TI
4668             (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
4669   "TARGET_64BIT"
4670   "@
4671    dsgfr\t%0,%2
4672    dsgf\t%0,%2"
4673   [(set_attr "op_type"  "RRE,RXY")
4674    (set_attr "type"     "idiv")])
4675
4676 ;
4677 ; udivmoddi4 instruction pattern(s).
4678 ;
4679
4680 (define_expand "udivmoddi4"
4681   [(parallel [(set (match_operand:DI 0 "general_operand" "")
4682                    (udiv:DI (match_operand:DI 1 "general_operand" "")
4683                             (match_operand:DI 2 "nonimmediate_operand" "")))
4684               (set (match_operand:DI 3 "general_operand" "")
4685                    (umod:DI (match_dup 1) (match_dup 2)))])
4686    (clobber (match_dup 4))]
4687   "TARGET_64BIT"
4688 {
4689   rtx insn, div_equal, mod_equal, equal;
4690
4691   div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
4692   mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
4693   equal = gen_rtx_IOR (TImode,
4694                        gen_rtx_ASHIFT (TImode,
4695                                        gen_rtx_ZERO_EXTEND (TImode, mod_equal),
4696                                        GEN_INT (64)),
4697                        gen_rtx_ZERO_EXTEND (TImode, div_equal));
4698
4699   operands[4] = gen_reg_rtx(TImode);
4700   emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4]));
4701   emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
4702   emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
4703   insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
4704   REG_NOTES (insn) =
4705         gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4706
4707   insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
4708   REG_NOTES (insn) =
4709         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4710
4711   insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
4712   REG_NOTES (insn) =
4713         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4714
4715   DONE;
4716 })
4717
4718 (define_insn "udivmodtidi3"
4719   [(set (match_operand:TI 0 "register_operand" "=d,d")
4720         (ior:TI
4721           (ashift:TI
4722             (zero_extend:TI
4723               (truncate:DI
4724                 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
4725                          (zero_extend:TI
4726                            (match_operand:DI 2 "nonimmediate_operand" "d,m")))))
4727             (const_int 64))
4728           (zero_extend:TI
4729             (truncate:DI
4730               (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
4731   "TARGET_64BIT"
4732   "@
4733    dlgr\t%0,%2
4734    dlg\t%0,%2"
4735   [(set_attr "op_type"  "RRE,RXY")
4736    (set_attr "type"     "idiv")])
4737
4738 ;
4739 ; divmodsi4 instruction pattern(s).
4740 ;
4741
4742 (define_expand "divmodsi4"
4743   [(parallel [(set (match_operand:SI 0 "general_operand" "")
4744                    (div:SI (match_operand:SI 1 "general_operand" "")
4745                            (match_operand:SI 2 "nonimmediate_operand" "")))
4746               (set (match_operand:SI 3 "general_operand" "")
4747                    (mod:SI (match_dup 1) (match_dup 2)))])
4748    (clobber (match_dup 4))]
4749   "!TARGET_64BIT"
4750 {
4751   rtx insn, div_equal, mod_equal, equal;
4752
4753   div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
4754   mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
4755   equal = gen_rtx_IOR (DImode,
4756                        gen_rtx_ASHIFT (DImode,
4757                                        gen_rtx_ZERO_EXTEND (DImode, mod_equal),
4758                                        GEN_INT (32)),
4759                        gen_rtx_ZERO_EXTEND (DImode, div_equal));
4760
4761   operands[4] = gen_reg_rtx(DImode);
4762   emit_insn (gen_extendsidi2 (operands[4], operands[1]));
4763   insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
4764   REG_NOTES (insn) =
4765         gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4766
4767   insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
4768   REG_NOTES (insn) =
4769         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4770
4771   insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
4772   REG_NOTES (insn) =
4773         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4774
4775   DONE;
4776 })
4777
4778 (define_insn "divmoddisi3"
4779   [(set (match_operand:DI 0 "register_operand" "=d,d")
4780         (ior:DI
4781           (ashift:DI
4782             (zero_extend:DI
4783               (truncate:SI
4784                 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
4785                         (sign_extend:DI
4786                           (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
4787             (const_int 32))
4788           (zero_extend:DI
4789             (truncate:SI
4790               (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
4791   "!TARGET_64BIT"
4792   "@
4793    dr\t%0,%2
4794    d\t%0,%2"
4795   [(set_attr "op_type"  "RR,RX")
4796    (set_attr "type"     "idiv")])
4797
4798 ;
4799 ; udivsi3 and umodsi3 instruction pattern(s).
4800 ;
4801
4802 (define_expand "udivmodsi4"
4803   [(parallel [(set (match_operand:SI 0 "general_operand" "")
4804                    (udiv:SI (match_operand:SI 1 "general_operand" "")
4805                             (match_operand:SI 2 "nonimmediate_operand" "")))
4806               (set (match_operand:SI 3 "general_operand" "")
4807                    (umod:SI (match_dup 1) (match_dup 2)))])
4808    (clobber (match_dup 4))]
4809   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4810 {
4811   rtx insn, div_equal, mod_equal, equal;
4812
4813   div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4814   mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4815   equal = gen_rtx_IOR (DImode,
4816                        gen_rtx_ASHIFT (DImode,
4817                                        gen_rtx_ZERO_EXTEND (DImode, mod_equal),
4818                                        GEN_INT (32)),
4819                        gen_rtx_ZERO_EXTEND (DImode, div_equal));
4820
4821   operands[4] = gen_reg_rtx(DImode);
4822   emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4]));
4823   emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
4824   emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
4825   insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
4826   REG_NOTES (insn) =
4827         gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4828
4829   insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
4830   REG_NOTES (insn) =
4831         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4832
4833   insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
4834   REG_NOTES (insn) =
4835         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4836
4837   DONE;
4838 })
4839
4840 (define_insn "udivmoddisi3"
4841   [(set (match_operand:DI 0 "register_operand" "=d,d")
4842         (ior:DI
4843           (ashift:DI
4844             (zero_extend:DI
4845               (truncate:SI
4846                 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
4847                          (zero_extend:DI
4848                            (match_operand:SI 2 "nonimmediate_operand" "d,m")))))
4849             (const_int 32))
4850           (zero_extend:DI
4851             (truncate:SI
4852               (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
4853   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4854   "@
4855    dlr\t%0,%2
4856    dl\t%0,%2"
4857   [(set_attr "op_type"  "RRE,RXY")
4858    (set_attr "type"     "idiv")])
4859
4860 (define_expand "udivsi3"
4861   [(set (match_operand:SI 0 "register_operand" "=d")
4862         (udiv:SI (match_operand:SI 1 "general_operand" "")
4863                  (match_operand:SI 2 "general_operand" "")))
4864    (clobber (match_dup 3))]
4865   "!TARGET_64BIT && !TARGET_CPU_ZARCH"
4866 {
4867   rtx insn, udiv_equal, umod_equal, equal;
4868
4869   udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4870   umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4871   equal = gen_rtx_IOR (DImode,
4872                        gen_rtx_ASHIFT (DImode,
4873                                        gen_rtx_ZERO_EXTEND (DImode, umod_equal),
4874                                        GEN_INT (32)),
4875                        gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
4876
4877   operands[3] = gen_reg_rtx (DImode);
4878
4879   if (CONSTANT_P (operands[2]))
4880     {
4881       if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
4882         {
4883           rtx label1 = gen_label_rtx ();
4884
4885           operands[1] = make_safe_from (operands[1], operands[0]);
4886           emit_move_insn (operands[0], const0_rtx);
4887           emit_insn (gen_cmpsi (operands[1], operands[2]));
4888           emit_jump_insn (gen_bltu (label1));
4889           emit_move_insn (operands[0], const1_rtx);
4890           emit_label (label1);
4891         }
4892       else
4893         {
4894           operands[2] = force_reg (SImode, operands[2]);
4895           operands[2] = make_safe_from (operands[2], operands[0]);
4896
4897           emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4898           insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4899                                              operands[2]));
4900           REG_NOTES (insn) =
4901             gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4902
4903           insn = emit_move_insn (operands[0],
4904                                  gen_lowpart (SImode, operands[3]));
4905           REG_NOTES (insn) =
4906             gen_rtx_EXPR_LIST (REG_EQUAL,
4907                                udiv_equal, REG_NOTES (insn));
4908         }
4909     }
4910   else
4911     {
4912       rtx label1 = gen_label_rtx ();
4913       rtx label2 = gen_label_rtx ();
4914       rtx label3 = gen_label_rtx ();
4915
4916       operands[1] = force_reg (SImode, operands[1]);
4917       operands[1] = make_safe_from (operands[1], operands[0]);
4918       operands[2] = force_reg (SImode, operands[2]);
4919       operands[2] = make_safe_from (operands[2], operands[0]);
4920
4921       emit_move_insn (operands[0], const0_rtx);
4922       emit_insn (gen_cmpsi (operands[2], operands[1]));
4923       emit_jump_insn (gen_bgtu (label3));
4924       emit_insn (gen_cmpsi (operands[2], const1_rtx));
4925       emit_jump_insn (gen_blt (label2));
4926       emit_insn (gen_cmpsi (operands[2], const1_rtx));
4927       emit_jump_insn (gen_beq (label1));
4928       emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4929       insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4930                                          operands[2]));
4931       REG_NOTES (insn) =
4932       gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4933
4934       insn = emit_move_insn (operands[0],
4935                              gen_lowpart (SImode, operands[3]));
4936       REG_NOTES (insn) =
4937       gen_rtx_EXPR_LIST (REG_EQUAL,
4938                                udiv_equal, REG_NOTES (insn));
4939       emit_jump (label3);
4940       emit_label (label1);
4941       emit_move_insn (operands[0], operands[1]);
4942       emit_jump (label3);
4943       emit_label (label2);
4944       emit_move_insn (operands[0], const1_rtx);
4945       emit_label (label3);
4946     }
4947   emit_move_insn (operands[0], operands[0]);
4948   DONE;
4949 })
4950
4951 (define_expand "umodsi3"
4952   [(set (match_operand:SI 0 "register_operand" "=d")
4953         (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
4954                  (match_operand:SI 2 "nonimmediate_operand" "")))
4955    (clobber (match_dup 3))]
4956   "!TARGET_64BIT && !TARGET_CPU_ZARCH"
4957 {
4958   rtx insn, udiv_equal, umod_equal, equal;
4959
4960   udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4961   umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4962   equal = gen_rtx_IOR (DImode,
4963                        gen_rtx_ASHIFT (DImode,
4964                                        gen_rtx_ZERO_EXTEND (DImode, umod_equal),
4965                                        GEN_INT (32)),
4966                        gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
4967
4968   operands[3] = gen_reg_rtx (DImode);
4969
4970   if (CONSTANT_P (operands[2]))
4971     {
4972       if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
4973         {
4974           rtx label1 = gen_label_rtx ();
4975
4976           operands[1] = make_safe_from (operands[1], operands[0]);
4977           emit_move_insn (operands[0], operands[1]);
4978           emit_insn (gen_cmpsi (operands[0], operands[2]));
4979           emit_jump_insn (gen_bltu (label1));
4980           emit_insn (gen_abssi2 (operands[0], operands[2]));
4981           emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
4982           emit_label (label1);
4983         }
4984       else
4985         {
4986           operands[2] = force_reg (SImode, operands[2]);
4987           operands[2] = make_safe_from (operands[2], operands[0]);
4988
4989           emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4990           insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4991                                              operands[2]));
4992           REG_NOTES (insn) =
4993             gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4994
4995           insn = emit_move_insn (operands[0],
4996                                  gen_highpart (SImode, operands[3]));
4997           REG_NOTES (insn) =
4998             gen_rtx_EXPR_LIST (REG_EQUAL,
4999                                umod_equal, REG_NOTES (insn));
5000         }
5001     }
5002   else
5003     {
5004       rtx label1 = gen_label_rtx ();
5005       rtx label2 = gen_label_rtx ();
5006       rtx label3 = gen_label_rtx ();
5007
5008       operands[1] = force_reg (SImode, operands[1]);
5009       operands[1] = make_safe_from (operands[1], operands[0]);
5010       operands[2] = force_reg (SImode, operands[2]);
5011       operands[2] = make_safe_from (operands[2], operands[0]);
5012
5013       emit_move_insn(operands[0], operands[1]);
5014       emit_insn (gen_cmpsi (operands[2], operands[1]));
5015       emit_jump_insn (gen_bgtu (label3));
5016       emit_insn (gen_cmpsi (operands[2], const1_rtx));
5017       emit_jump_insn (gen_blt (label2));
5018       emit_insn (gen_cmpsi (operands[2], const1_rtx));
5019       emit_jump_insn (gen_beq (label1));
5020       emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5021       insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5022                                          operands[2]));
5023       REG_NOTES (insn) =
5024       gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
5025
5026       insn = emit_move_insn (operands[0],
5027                              gen_highpart (SImode, operands[3]));
5028       REG_NOTES (insn) =
5029       gen_rtx_EXPR_LIST (REG_EQUAL,
5030                          umod_equal, REG_NOTES (insn));
5031       emit_jump (label3);
5032       emit_label (label1);
5033       emit_move_insn (operands[0], const0_rtx);
5034       emit_jump (label3);
5035       emit_label (label2);
5036       emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
5037       emit_label (label3);
5038     }
5039   DONE;
5040 })
5041
5042 ;
5043 ; divdf3 instruction pattern(s).
5044 ;
5045
5046 (define_expand "divdf3"
5047   [(set (match_operand:DF 0 "register_operand" "=f,f")
5048         (div:DF (match_operand:DF 1 "register_operand" "0,0")
5049                 (match_operand:DF 2 "general_operand" "f,R")))]
5050   "TARGET_HARD_FLOAT"
5051   "")
5052
5053 (define_insn "*divdf3"
5054   [(set (match_operand:DF 0 "register_operand" "=f,f")
5055         (div:DF (match_operand:DF 1 "register_operand" "0,0")
5056                 (match_operand:DF 2 "general_operand" "f,R")))]
5057   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5058   "@
5059    ddbr\t%0,%2
5060    ddb\t%0,%2"
5061   [(set_attr "op_type"  "RRE,RXE")
5062    (set_attr "type"     "fdivd")])
5063
5064 (define_insn "*divdf3_ibm"
5065   [(set (match_operand:DF 0 "register_operand" "=f,f")
5066         (div:DF (match_operand:DF 1 "register_operand" "0,0")
5067                 (match_operand:DF 2 "general_operand" "f,R")))]
5068   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5069   "@
5070    ddr\t%0,%2
5071    dd\t%0,%2"
5072   [(set_attr "op_type"  "RR,RX")
5073    (set_attr "type"     "fdivd")])
5074
5075 ;
5076 ; divsf3 instruction pattern(s).
5077 ;
5078
5079 (define_expand "divsf3"
5080   [(set (match_operand:SF 0 "register_operand" "=f,f")
5081         (div:SF (match_operand:SF 1 "register_operand" "0,0")
5082                 (match_operand:SF 2 "general_operand" "f,R")))]
5083   "TARGET_HARD_FLOAT"
5084   "")
5085
5086 (define_insn "*divsf3"
5087   [(set (match_operand:SF 0 "register_operand" "=f,f")
5088         (div:SF (match_operand:SF 1 "register_operand" "0,0")
5089                 (match_operand:SF 2 "general_operand" "f,R")))]
5090   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5091   "@
5092    debr\t%0,%2
5093    deb\t%0,%2"
5094   [(set_attr "op_type"  "RRE,RXE")
5095    (set_attr "type"     "fdivs")])
5096
5097 (define_insn "*divsf3"
5098   [(set (match_operand:SF 0 "register_operand" "=f,f")
5099         (div:SF (match_operand:SF 1 "register_operand" "0,0")
5100                 (match_operand:SF 2 "general_operand" "f,R")))]
5101   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5102   "@
5103    der\t%0,%2
5104    de\t%0,%2"
5105   [(set_attr "op_type"  "RR,RX")
5106    (set_attr "type"     "fdivs")])
5107
5108
5109 ;;
5110 ;;- And instructions.
5111 ;;
5112
5113 ;
5114 ; anddi3 instruction pattern(s).
5115 ;
5116
5117 (define_insn "*anddi3_cc"
5118   [(set (reg 33)
5119         (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5120                          (match_operand:DI 2 "general_operand" "d,m"))
5121                  (const_int 0)))
5122    (set (match_operand:DI 0 "register_operand" "=d,d")
5123         (and:DI (match_dup 1) (match_dup 2)))]
5124   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5125   "@
5126    ngr\t%0,%2
5127    ng\t%0,%2"
5128   [(set_attr "op_type"  "RRE,RXY")])
5129
5130 (define_insn "*anddi3_cconly"
5131   [(set (reg 33)
5132         (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5133                          (match_operand:DI 2 "general_operand" "d,m"))
5134                  (const_int 0)))
5135    (clobber (match_scratch:DI 0 "=d,d"))]
5136   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5137   "@
5138    ngr\t%0,%2
5139    ng\t%0,%2"
5140   [(set_attr "op_type"  "RRE,RXY")])
5141
5142 (define_insn "anddi3"
5143   [(set (match_operand:DI 0 "register_operand" "=d,d,d,d,d,d,d,d")
5144         (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o,0,0,0,0,0,0")
5145                 (match_operand:DI 2 "general_operand"
5146                                     "M,M,N0HDF,N1HDF,N2HDF,N3HDF,d,m")))
5147      (clobber (reg:CC 33))]
5148    "TARGET_64BIT"
5149    "@
5150     #
5151     #
5152     nihh\t%0,%j2
5153     nihl\t%0,%j2
5154     nilh\t%0,%j2
5155     nill\t%0,%j2
5156     ngr\t%0,%2
5157     ng\t%0,%2"
5158  [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RRE,RXY")])
5159
5160 (define_insn "*anddi3_ss"
5161   [(set (match_operand:DI 0 "s_operand" "=Q")
5162         (and:DI (match_dup 0)
5163                 (match_operand:DI 1 "s_imm_operand" "Q")))
5164    (clobber (reg:CC 33))]
5165   ""
5166   "nc\t%O0(8,%R0),%1"
5167   [(set_attr "op_type"  "SS")])
5168
5169 (define_insn "*anddi3_ss_inv"
5170   [(set (match_operand:DI 0 "s_operand" "=Q")
5171         (and:DI (match_operand:DI 1 "s_imm_operand" "Q")
5172                 (match_dup 0)))
5173    (clobber (reg:CC 33))]
5174   ""
5175   "nc\t%O0(8,%R0),%1"
5176   [(set_attr "op_type"  "SS")])
5177
5178 ;
5179 ; andsi3 instruction pattern(s).
5180 ;
5181
5182 (define_insn "*andsi3_cc"
5183   [(set (reg 33)
5184         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5185                          (match_operand:SI 2 "general_operand" "d,R,T"))
5186                  (const_int 0)))
5187    (set (match_operand:SI 0 "register_operand" "=d,d,d")
5188         (and:SI (match_dup 1) (match_dup 2)))]
5189   "s390_match_ccmode(insn, CCTmode)"
5190   "@
5191    nr\t%0,%2
5192    n\t%0,%2
5193    ny\t%0,%2"
5194   [(set_attr "op_type"  "RR,RX,RXY")])
5195
5196 (define_insn "*andsi3_cconly"
5197   [(set (reg 33)
5198         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5199                          (match_operand:SI 2 "general_operand" "d,R,T"))
5200                  (const_int 0)))
5201    (clobber (match_scratch:SI 0 "=d,d,d"))]
5202   "s390_match_ccmode(insn, CCTmode)"
5203   "@
5204    nr\t%0,%2
5205    n\t%0,%2
5206    ny\t%0,%2"
5207   [(set_attr "op_type"  "RR,RX,RXY")])
5208
5209 (define_expand "andsi3"
5210   [(parallel
5211     [(set (match_operand:SI 0 "register_operand" "")
5212           (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
5213                   (match_operand:SI 2 "general_operand" "")))
5214      (clobber (reg:CC 33))])]
5215   ""
5216   "")
5217
5218 (define_insn "*andsi3_zarch"
5219   [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d,d,d")
5220         (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,o,0,0,0,0,0")
5221                 (match_operand:SI 2 "general_operand" "M,M,N0HSF,N1HSF,d,R,T")))
5222    (clobber (reg:CC 33))]
5223   "TARGET_ZARCH"
5224   "@
5225    #
5226    #
5227    nilh\t%0,%j2
5228    nill\t%0,%j2
5229    nr\t%0,%2
5230    n\t%0,%2
5231    ny\t%0,%2"
5232   [(set_attr "op_type"  "RRE,RXE,RI,RI,RR,RX,RXY")])
5233
5234 (define_insn "*andsi3_esa"
5235   [(set (match_operand:SI 0 "register_operand" "=d,d")
5236         (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
5237                 (match_operand:SI 2 "general_operand" "d,R")))
5238    (clobber (reg:CC 33))]
5239   "!TARGET_ZARCH"
5240   "@
5241    nr\t%0,%2
5242    n\t%0,%2"
5243   [(set_attr "op_type"  "RR,RX")])
5244
5245 (define_insn "*andsi3_ss"
5246   [(set (match_operand:SI 0 "s_operand" "=Q")
5247         (and:SI (match_dup 0)
5248                 (match_operand:SI 1 "s_imm_operand" "Q")))
5249    (clobber (reg:CC 33))]
5250   ""
5251   "nc\t%O0(4,%R0),%1"
5252   [(set_attr "op_type"  "SS")])
5253
5254 (define_insn "*andsi3_ss_inv"
5255   [(set (match_operand:SI 0 "s_operand" "=Q")
5256         (and:SI (match_operand:SI 1 "s_imm_operand" "Q")
5257                 (match_dup 0)))
5258    (clobber (reg:CC 33))]
5259   ""
5260   "nc\t%O0(4,%R0),%1"
5261   [(set_attr "op_type"  "SS")])
5262
5263 ;
5264 ; andhi3 instruction pattern(s).
5265 ;
5266
5267 (define_insn "*andhi3_ni"
5268   [(set (match_operand:HI 0 "register_operand" "=d,d")
5269         (and:HI (match_operand:HI 1 "register_operand" "%0,0")
5270                 (match_operand:HI 2 "nonmemory_operand" "d,n")))
5271    (clobber (reg:CC 33))]
5272   "TARGET_ZARCH"
5273   "@
5274    nr\t%0,%2
5275    nill\t%0,%x2"
5276   [(set_attr "op_type"  "RR,RI")])
5277
5278 (define_insn "andhi3"
5279   [(set (match_operand:HI 0 "register_operand" "=d")
5280         (and:HI (match_operand:HI 1 "register_operand" "%0")
5281                 (match_operand:HI 2 "nonmemory_operand" "d")))
5282    (clobber (reg:CC 33))]
5283   ""
5284   "nr\t%0,%2"
5285   [(set_attr "op_type"  "RR")])
5286
5287 (define_insn "*andhi3_ss"
5288   [(set (match_operand:HI 0 "s_operand" "=Q")
5289         (and:HI (match_dup 0)
5290                 (match_operand:HI 1 "s_imm_operand" "Q")))
5291    (clobber (reg:CC 33))]
5292   ""
5293   "nc\t%O0(2,%R0),%1"
5294   [(set_attr "op_type"  "SS")])
5295
5296 (define_insn "*andhi3_ss_inv"
5297   [(set (match_operand:HI 0 "s_operand" "=Q")
5298         (and:HI (match_operand:HI 1 "s_imm_operand" "Q")
5299                 (match_dup 0)))
5300    (clobber (reg:CC 33))]
5301   ""
5302   "nc\t%O0(2,%R0),%1"
5303   [(set_attr "op_type"  "SS")])
5304
5305 ;
5306 ; andqi3 instruction pattern(s).
5307 ;
5308
5309 (define_insn "*andqi3_ni"
5310   [(set (match_operand:QI 0 "register_operand" "=d,d")
5311         (and:QI (match_operand:QI 1 "register_operand" "%0,0")
5312                 (match_operand:QI 2 "nonmemory_operand" "d,n")))
5313    (clobber (reg:CC 33))]
5314   "TARGET_ZARCH"
5315   "@
5316    nr\t%0,%2
5317    nill\t%0,%b2"
5318   [(set_attr "op_type"  "RR,RI")])
5319
5320 (define_insn "andqi3"
5321   [(set (match_operand:QI 0 "register_operand" "=d")
5322         (and:QI (match_operand:QI 1 "register_operand" "%0")
5323                 (match_operand:QI 2 "nonmemory_operand" "d")))
5324    (clobber (reg:CC 33))]
5325   ""
5326   "nr\t%0,%2"
5327   [(set_attr "op_type"  "RR")])
5328
5329 (define_insn "*andqi3_ss"
5330   [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5331         (and:QI (match_dup 0)
5332                 (match_operand:QI 1 "s_imm_operand" "n,n,Q")))
5333    (clobber (reg:CC 33))]
5334   ""
5335   "@
5336    ni\t%0,%b1
5337    niy\t%0,%b1
5338    nc\t%O0(1,%R0),%1"
5339   [(set_attr "op_type"  "SI,SIY,SS")])
5340
5341 (define_insn "*andqi3_ss_inv"
5342   [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5343         (and:QI (match_operand:QI 1 "s_imm_operand" "n,n,Q")
5344                 (match_dup 0)))
5345    (clobber (reg:CC 33))]
5346   ""
5347   "@
5348    ni\t%0,%b1
5349    niy\t%0,%b1
5350    nc\t%O0(1,%R0),%1"
5351   [(set_attr "op_type"  "SI,SIY,SS")])
5352
5353
5354 ;;
5355 ;;- Bit set (inclusive or) instructions.
5356 ;;
5357
5358 ;
5359 ; iordi3 instruction pattern(s).
5360 ;
5361
5362 (define_insn "*iordi3_cc"
5363   [(set (reg 33)
5364         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5365                          (match_operand:DI 2 "general_operand" "d,m"))
5366                  (const_int 0)))
5367    (set (match_operand:DI 0 "register_operand" "=d,d")
5368         (ior:DI (match_dup 1) (match_dup 2)))]
5369   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5370   "@
5371    ogr\t%0,%2
5372    og\t%0,%2"
5373   [(set_attr "op_type"  "RRE,RXY")])
5374
5375 (define_insn "*iordi3_cconly"
5376   [(set (reg 33)
5377         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5378                          (match_operand:DI 2 "general_operand" "d,m"))
5379                  (const_int 0)))
5380    (clobber (match_scratch:DI 0 "=d,d"))]
5381   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5382   "@
5383    ogr\t%0,%2
5384    og\t%0,%2"
5385   [(set_attr "op_type"  "RRE,RXY")])
5386
5387 (define_insn "iordi3"
5388   [(set (match_operand:DI 0 "register_operand" "=d,d,d,d,d,d")
5389         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "0,0,0,0,0,0")
5390                 (match_operand:DI 2 "general_operand" "N0HD0,N1HD0,N2HD0,N3HD0,d,m")))
5391    (clobber (reg:CC 33))]
5392   "TARGET_64BIT"
5393   "@
5394    oihh\t%0,%i2
5395    oihl\t%0,%i2
5396    oilh\t%0,%i2
5397    oill\t%0,%i2
5398    ogr\t%0,%2
5399    og\t%0,%2"
5400   [(set_attr "op_type"  "RI,RI,RI,RI,RRE,RXY")])
5401
5402 (define_insn "*iordi3_ss"
5403   [(set (match_operand:DI 0 "s_operand" "=Q")
5404         (ior:DI (match_dup 0)
5405                 (match_operand:DI 1 "s_imm_operand" "Q")))
5406    (clobber (reg:CC 33))]
5407   ""
5408   "oc\t%O0(8,%R0),%1"
5409   [(set_attr "op_type"  "SS")])
5410
5411 (define_insn "*iordi3_ss_inv"
5412   [(set (match_operand:DI 0 "s_operand" "=Q")
5413         (ior:DI (match_operand:DI 1 "s_imm_operand" "Q")
5414                 (match_dup 0)))
5415    (clobber (reg:CC 33))]
5416   ""
5417   "oc\t%O0(8,%R0),%1"
5418   [(set_attr "op_type"  "SS")])
5419
5420 ;
5421 ; iorsi3 instruction pattern(s).
5422 ;
5423
5424 (define_insn "*iorsi3_cc"
5425   [(set (reg 33)
5426         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5427                          (match_operand:SI 2 "general_operand" "d,R,T"))
5428                  (const_int 0)))
5429    (set (match_operand:SI 0 "register_operand" "=d,d,d")
5430         (ior:SI (match_dup 1) (match_dup 2)))]
5431   "s390_match_ccmode(insn, CCTmode)"
5432   "@
5433    or\t%0,%2
5434    o\t%0,%2
5435    oy\t%0,%2"
5436   [(set_attr "op_type"  "RR,RX,RXY")])
5437
5438 (define_insn "*iorsi3_cconly"
5439   [(set (reg 33)
5440         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5441                          (match_operand:SI 2 "general_operand" "d,R,T"))
5442                  (const_int 0)))
5443    (clobber (match_scratch:SI 0 "=d,d,d"))]
5444   "s390_match_ccmode(insn, CCTmode)"
5445   "@
5446    or\t%0,%2
5447    o\t%0,%2
5448    oy\t%0,%2"
5449   [(set_attr "op_type"  "RR,RX,RXY")])
5450
5451 (define_expand "iorsi3"
5452   [(parallel
5453     [(set (match_operand:SI 0 "register_operand" "")
5454           (ior:SI (match_operand:SI 1 "nonimmediate_operand" "")
5455                   (match_operand:SI 2 "general_operand" "")))
5456      (clobber (reg:CC 33))])]
5457   ""
5458   "")
5459
5460 (define_insn "iorsi3_zarch"
5461   [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
5462         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "0,0,0,0,0")
5463                 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,d,R,T")))
5464    (clobber (reg:CC 33))]
5465   "TARGET_ZARCH"
5466   "@
5467    oilh\t%0,%i2
5468    oill\t%0,%i2
5469    or\t%0,%2
5470    o\t%0,%2
5471    oy\t%0,%2"
5472   [(set_attr "op_type"  "RI,RI,RR,RX,RXY")])
5473
5474 (define_insn "iorsi3_esa"
5475   [(set (match_operand:SI 0 "register_operand" "=d,d")
5476         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
5477                 (match_operand:SI 2 "general_operand" "d,R")))
5478    (clobber (reg:CC 33))]
5479   "!TARGET_ZARCH"
5480   "@
5481    or\t%0,%2
5482    o\t%0,%2"
5483   [(set_attr "op_type"  "RR,RX")])
5484
5485 (define_insn "*iorsi3_ss"
5486   [(set (match_operand:SI 0 "s_operand" "=Q")
5487         (ior:SI (match_dup 0)
5488                 (match_operand:SI 1 "s_imm_operand" "Q")))
5489    (clobber (reg:CC 33))]
5490   ""
5491   "oc\t%O0(4,%R0),%1"
5492   [(set_attr "op_type"  "SS")])
5493
5494 (define_insn "*iorsi3_ss_inv"
5495   [(set (match_operand:SI 0 "s_operand" "=Q")
5496         (ior:SI (match_operand:SI 1 "s_imm_operand" "Q")
5497                 (match_dup 0)))
5498    (clobber (reg:CC 33))]
5499   ""
5500   "oc\t%O0(4,%R0),%1"
5501   [(set_attr "op_type"  "SS")])
5502
5503 ;
5504 ; iorhi3 instruction pattern(s).
5505 ;
5506
5507 (define_insn "*iorhi3_oi"
5508   [(set (match_operand:HI 0 "register_operand" "=d,d")
5509         (ior:HI (match_operand:HI 1 "register_operand" "%0,0")
5510                 (match_operand:HI 2 "nonmemory_operand" "d,n")))
5511    (clobber (reg:CC 33))]
5512   "TARGET_ZARCH"
5513   "@
5514    or\t%0,%2
5515    oill\t%0,%x2"
5516   [(set_attr "op_type"  "RR,RI")])
5517
5518 (define_insn "iorhi3"
5519   [(set (match_operand:HI 0 "register_operand" "=d")
5520         (ior:HI (match_operand:HI 1 "register_operand" "%0")
5521                 (match_operand:HI 2 "nonmemory_operand" "d")))
5522    (clobber (reg:CC 33))]
5523   ""
5524   "or\t%0,%2"
5525   [(set_attr "op_type"  "RR")])
5526
5527 (define_insn "*iorhi3_ss"
5528   [(set (match_operand:HI 0 "s_operand" "=Q")
5529         (ior:HI (match_dup 0)
5530                 (match_operand:HI 1 "s_imm_operand" "Q")))
5531    (clobber (reg:CC 33))]
5532   ""
5533   "oc\t%O0(2,%R0),%1"
5534   [(set_attr "op_type"  "SS")])
5535
5536 (define_insn "*iorhi3_ss_inv"
5537   [(set (match_operand:HI 0 "s_operand" "=Q")
5538         (ior:HI (match_operand:HI 1 "s_imm_operand" "Q")
5539                 (match_dup 0)))
5540    (clobber (reg:CC 33))]
5541   ""
5542   "oc\t%O0(2,%R0),%1"
5543   [(set_attr "op_type"  "SS")])
5544
5545 ;
5546 ; iorqi3 instruction pattern(s).
5547 ;
5548
5549 (define_insn "*iorqi3_oi"
5550   [(set (match_operand:QI 0 "register_operand" "=d,d")
5551         (ior:QI (match_operand:QI 1 "register_operand" "%0,0")
5552                 (match_operand:QI 2 "nonmemory_operand" "d,n")))
5553    (clobber (reg:CC 33))]
5554   "TARGET_ZARCH"
5555   "@
5556    or\t%0,%2
5557    oill\t%0,%b2"
5558   [(set_attr "op_type"  "RR,RI")])
5559
5560 (define_insn "iorqi3"
5561   [(set (match_operand:QI 0 "register_operand" "=d")
5562         (ior:QI (match_operand:QI 1 "register_operand" "%0")
5563                 (match_operand:QI 2 "nonmemory_operand" "d")))
5564    (clobber (reg:CC 33))]
5565   ""
5566   "or\t%0,%2"
5567   [(set_attr "op_type"  "RR")])
5568
5569 (define_insn "*iorqi3_ss"
5570   [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5571         (ior:QI (match_dup 0)
5572                 (match_operand:QI 1 "s_imm_operand" "n,n,Q")))
5573    (clobber (reg:CC 33))]
5574   ""
5575   "@
5576    oi\t%0,%b1
5577    oiy\t%0,%b1
5578    oc\t%O0(1,%R0),%1"
5579   [(set_attr "op_type"  "SI,SIY,SS")])
5580
5581 (define_insn "*iorqi3_ss_inv"
5582   [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5583         (ior:QI (match_operand:QI 1 "s_imm_operand" "n,n,Q")
5584                 (match_dup 0)))
5585    (clobber (reg:CC 33))]
5586   ""
5587   "@
5588    oi\t%0,%b1
5589    oiy\t%0,%b1
5590    oc\t%O0(1,%R0),%1"
5591   [(set_attr "op_type"  "SI,SIY,SS")])
5592
5593
5594 ;;
5595 ;;- Xor instructions.
5596 ;;
5597
5598 ;
5599 ; xordi3 instruction pattern(s).
5600 ;
5601
5602 (define_insn "*xordi3_cc"
5603   [(set (reg 33)
5604         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5605                          (match_operand:DI 2 "general_operand" "d,m"))
5606                  (const_int 0)))
5607    (set (match_operand:DI 0 "register_operand" "=d,d")
5608         (xor:DI (match_dup 1) (match_dup 2)))]
5609   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5610   "@
5611    xgr\t%0,%2
5612    xg\t%0,%2"
5613   [(set_attr "op_type"  "RRE,RXY")])
5614
5615 (define_insn "*xordi3_cconly"
5616   [(set (reg 33)
5617         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5618                          (match_operand:DI 2 "general_operand" "d,m"))
5619                  (const_int 0)))
5620    (clobber (match_scratch:DI 0 "=d,d"))]
5621   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5622   "@
5623    xgr\t%0,%2
5624    xr\t%0,%2"
5625   [(set_attr "op_type"  "RRE,RXY")])
5626
5627 (define_insn "xordi3"
5628   [(set (match_operand:DI 0 "register_operand" "=d,d")
5629         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5630                 (match_operand:DI 2 "general_operand" "d,m")))
5631    (clobber (reg:CC 33))]
5632   "TARGET_64BIT"
5633   "@
5634    xgr\t%0,%2
5635    xg\t%0,%2"
5636   [(set_attr "op_type"  "RRE,RXY")])
5637
5638 (define_insn "*xordi3_ss"
5639   [(set (match_operand:DI 0 "s_operand" "=Q")
5640         (xor:DI (match_dup 0)
5641                 (match_operand:DI 1 "s_imm_operand" "Q")))
5642    (clobber (reg:CC 33))]
5643   ""
5644   "xc\t%O0(8,%R0),%1"
5645   [(set_attr "op_type"  "SS")])
5646
5647 (define_insn "*xordi3_ss_inv"
5648   [(set (match_operand:DI 0 "s_operand" "=Q")
5649         (xor:DI (match_operand:DI 1 "s_imm_operand" "Q")
5650                 (match_dup 0)))
5651    (clobber (reg:CC 33))]
5652   ""
5653   "xc\t%O0(8,%R0),%1"
5654   [(set_attr "op_type"  "SS")])
5655
5656 ;
5657 ; xorsi3 instruction pattern(s).
5658 ;
5659
5660 (define_insn "*xorsi3_cc"
5661   [(set (reg 33)
5662         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5663                          (match_operand:SI 2 "general_operand" "d,R,T"))
5664                  (const_int 0)))
5665    (set (match_operand:SI 0 "register_operand" "=d,d,d")
5666         (xor:SI (match_dup 1) (match_dup 2)))]
5667   "s390_match_ccmode(insn, CCTmode)"
5668   "@
5669    xr\t%0,%2
5670    x\t%0,%2
5671    xy\t%0,%2"
5672   [(set_attr "op_type"  "RR,RX,RXY")])
5673
5674 (define_insn "*xorsi3_cconly"
5675   [(set (reg 33)
5676         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5677                          (match_operand:SI 2 "general_operand" "d,R,T"))
5678                  (const_int 0)))
5679    (clobber (match_scratch:SI 0 "=d,d,d"))]
5680   "s390_match_ccmode(insn, CCTmode)"
5681   "@
5682    xr\t%0,%2
5683    x\t%0,%2
5684    xy\t%0,%2"
5685   [(set_attr "op_type"  "RR,RX,RXY")])
5686
5687 (define_insn "xorsi3"
5688   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
5689         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5690                 (match_operand:SI 2 "general_operand" "d,R,T")))
5691    (clobber (reg:CC 33))]
5692   ""
5693   "@
5694    xr\t%0,%2
5695    x\t%0,%2
5696    xy\t%0,%2"
5697   [(set_attr "op_type"  "RR,RX,RXY")])
5698
5699 (define_insn "*xorsi3_ss"
5700   [(set (match_operand:SI 0 "s_operand" "=Q")
5701         (xor:SI (match_dup 0)
5702                 (match_operand:SI 1 "s_imm_operand" "Q")))
5703    (clobber (reg:CC 33))]
5704   ""
5705   "xc\t%O0(4,%R0),%1"
5706   [(set_attr "op_type"  "SS")])
5707
5708 (define_insn "*xorsi3_ss_inv"
5709   [(set (match_operand:SI 0 "s_operand" "=Q")
5710         (xor:SI (match_operand:SI 1 "s_imm_operand" "Q")
5711                 (match_dup 0)))
5712    (clobber (reg:CC 33))]
5713   ""
5714   "xc\t%O0(4,%R0),%1"
5715   [(set_attr "op_type"  "SS")])
5716
5717 ;
5718 ; xorhi3 instruction pattern(s).
5719 ;
5720
5721 (define_insn "xorhi3"
5722   [(set (match_operand:HI 0 "register_operand" "=d")
5723         (xor:HI (match_operand:HI 1 "register_operand" "%0")
5724                 (match_operand:HI 2 "nonmemory_operand" "d")))
5725    (clobber (reg:CC 33))]
5726   ""
5727   "xr\t%0,%2"
5728   [(set_attr "op_type"  "RR")])
5729
5730 (define_insn "*xorhi3_ss"
5731   [(set (match_operand:HI 0 "s_operand" "=Q")
5732         (xor:HI (match_dup 0)
5733                 (match_operand:HI 1 "s_imm_operand" "Q")))
5734    (clobber (reg:CC 33))]
5735   ""
5736   "xc\t%O0(2,%R0),%1"
5737   [(set_attr "op_type"  "SS")])
5738
5739 (define_insn "*xorhi3_ss_inv"
5740   [(set (match_operand:HI 0 "s_operand" "=Q")
5741         (xor:HI (match_operand:HI 1 "s_imm_operand" "Q")
5742                 (match_dup 0)))
5743    (clobber (reg:CC 33))]
5744   ""
5745   "xc\t%O0(2,%R0),%1"
5746   [(set_attr "op_type"  "SS")])
5747
5748 ;
5749 ; xorqi3 instruction pattern(s).
5750 ;
5751
5752 (define_insn "xorqi3"
5753   [(set (match_operand:QI 0 "register_operand" "=d")
5754         (xor:QI (match_operand:QI 1 "register_operand" "%0")
5755                 (match_operand:QI 2 "nonmemory_operand" "d")))
5756    (clobber (reg:CC 33))]
5757   ""
5758   "xr\t%0,%2"
5759   [(set_attr "op_type"  "RR")])
5760
5761 (define_insn "*xorqi3_ss"
5762   [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5763         (xor:QI (match_dup 0)
5764                 (match_operand:QI 1 "s_imm_operand" "n,n,Q")))
5765    (clobber (reg:CC 33))]
5766   ""
5767   "@
5768    xi\t%0,%b1
5769    xiy\t%0,%b1
5770    xc\t%O0(1,%R0),%1"
5771   [(set_attr "op_type"  "SI,SIY,SS")])
5772
5773 (define_insn "*xorqi3_ss_inv"
5774   [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5775         (xor:QI (match_operand:QI 1 "s_imm_operand" "n,n,Q")
5776                 (match_dup 0)))
5777    (clobber (reg:CC 33))]
5778   ""
5779   "@
5780    xi\t%0,%b1
5781    xiy\t%0,%b1
5782    xc\t%O0(1,%R0),%1"
5783   [(set_attr "op_type"  "SI,SIY,SS")])
5784
5785
5786 ;;
5787 ;;- Negate instructions.
5788 ;;
5789
5790 ;
5791 ; negdi2 instruction pattern(s).
5792 ;
5793
5794 (define_expand "negdi2"
5795   [(parallel
5796     [(set (match_operand:DI 0 "register_operand" "=d")
5797           (neg:DI (match_operand:DI 1 "register_operand" "d")))
5798      (clobber (reg:CC 33))])]
5799   ""
5800   "")
5801
5802 (define_insn "*negdi2_64"
5803   [(set (match_operand:DI 0 "register_operand" "=d")
5804         (neg:DI (match_operand:DI 1 "register_operand" "d")))
5805    (clobber (reg:CC 33))]
5806   "TARGET_64BIT"
5807   "lcgr\t%0,%1"
5808   [(set_attr "op_type"  "RR")])
5809
5810 (define_insn "*negdi2_31"
5811   [(set (match_operand:DI 0 "register_operand" "=d")
5812         (neg:DI (match_operand:DI 1 "register_operand" "d")))
5813    (clobber (reg:CC 33))]
5814   "!TARGET_64BIT"
5815 {
5816   rtx xop[1];
5817   xop[0] = gen_label_rtx ();
5818   output_asm_insn ("lcr\t%0,%1", operands);
5819   output_asm_insn ("lcr\t%N0,%N1", operands);
5820   output_asm_insn ("je\t%l0", xop);
5821   output_asm_insn ("bctr\t%0,0", operands);
5822   targetm.asm_out.internal_label (asm_out_file, "L",
5823                              CODE_LABEL_NUMBER (xop[0]));
5824   return "";
5825 }
5826   [(set_attr "op_type"  "NN")
5827    (set_attr "type"     "other")
5828    (set_attr "length"   "10")])
5829
5830 ;
5831 ; negsi2 instruction pattern(s).
5832 ;
5833
5834 (define_insn "negsi2"
5835   [(set (match_operand:SI 0 "register_operand" "=d")
5836         (neg:SI (match_operand:SI 1 "register_operand" "d")))
5837    (clobber (reg:CC 33))]
5838   ""
5839   "lcr\t%0,%1"
5840   [(set_attr "op_type"  "RR")])
5841
5842 ;
5843 ; negdf2 instruction pattern(s).
5844 ;
5845
5846 (define_expand "negdf2"
5847   [(parallel
5848     [(set (match_operand:DF 0 "register_operand" "=f")
5849           (neg:DF (match_operand:DF 1 "register_operand" "f")))
5850      (clobber (reg:CC 33))])]
5851   "TARGET_HARD_FLOAT"
5852   "")
5853
5854 (define_insn "*negdf2"
5855   [(set (match_operand:DF 0 "register_operand" "=f")
5856         (neg:DF (match_operand:DF 1 "register_operand" "f")))
5857    (clobber (reg:CC 33))]
5858   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5859   "lcdbr\t%0,%1"
5860   [(set_attr "op_type"  "RRE")
5861    (set_attr "type"     "fsimpd")])
5862
5863 (define_insn "*negdf2_ibm"
5864   [(set (match_operand:DF 0 "register_operand" "=f")
5865         (neg:DF (match_operand:DF 1 "register_operand" "f")))
5866    (clobber (reg:CC 33))]
5867   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5868   "lcdr\t%0,%1"
5869   [(set_attr "op_type"  "RR")
5870    (set_attr "type"     "fsimpd")])
5871
5872 ;
5873 ; negsf2 instruction pattern(s).
5874 ;
5875
5876 (define_expand "negsf2"
5877   [(parallel
5878     [(set (match_operand:SF 0 "register_operand" "=f")
5879           (neg:SF (match_operand:SF 1 "register_operand" "f")))
5880      (clobber (reg:CC 33))])]
5881   "TARGET_HARD_FLOAT"
5882   "")
5883
5884 (define_insn "*negsf2"
5885   [(set (match_operand:SF 0 "register_operand" "=f")
5886         (neg:SF (match_operand:SF 1 "register_operand" "f")))
5887    (clobber (reg:CC 33))]
5888   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5889   "lcebr\t%0,%1"
5890   [(set_attr "op_type"  "RRE")
5891    (set_attr "type"     "fsimps")])
5892
5893 (define_insn "*negsf2"
5894   [(set (match_operand:SF 0 "register_operand" "=f")
5895         (neg:SF (match_operand:SF 1 "register_operand" "f")))
5896    (clobber (reg:CC 33))]
5897   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5898   "lcer\t%0,%1"
5899   [(set_attr "op_type"  "RR")
5900    (set_attr "type"     "fsimps")])
5901
5902
5903 ;;
5904 ;;- Absolute value instructions.
5905 ;;
5906
5907 ;
5908 ; absdi2 instruction pattern(s).
5909 ;
5910
5911 (define_insn "absdi2"
5912   [(set (match_operand:DI 0 "register_operand" "=d")
5913         (abs:DI (match_operand:DI 1 "register_operand" "d")))
5914    (clobber (reg:CC 33))]
5915   "TARGET_64BIT"
5916   "lpgr\t%0,%1"
5917   [(set_attr "op_type"  "RRE")])
5918
5919 ;
5920 ; abssi2 instruction pattern(s).
5921 ;
5922
5923 (define_insn "abssi2"
5924   [(set (match_operand:SI 0 "register_operand" "=d")
5925         (abs:SI (match_operand:SI 1 "register_operand" "d")))
5926    (clobber (reg:CC 33))]
5927   ""
5928   "lpr\t%0,%1"
5929   [(set_attr "op_type"  "RR")])
5930
5931 ;
5932 ; absdf2 instruction pattern(s).
5933 ;
5934
5935 (define_expand "absdf2"
5936   [(parallel
5937     [(set (match_operand:DF 0 "register_operand" "=f")
5938           (abs:DF (match_operand:DF 1 "register_operand" "f")))
5939      (clobber (reg:CC 33))])]
5940   "TARGET_HARD_FLOAT"
5941   "")
5942
5943 (define_insn "*absdf2"
5944   [(set (match_operand:DF 0 "register_operand" "=f")
5945         (abs:DF (match_operand:DF 1 "register_operand" "f")))
5946    (clobber (reg:CC 33))]
5947   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5948   "lpdbr\t%0,%1"
5949   [(set_attr "op_type"  "RRE")
5950    (set_attr "type"     "fsimpd")])
5951
5952 (define_insn "*absdf2_ibm"
5953   [(set (match_operand:DF 0 "register_operand" "=f")
5954         (abs:DF (match_operand:DF 1 "register_operand" "f")))
5955    (clobber (reg:CC 33))]
5956   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5957   "lpdr\t%0,%1"
5958   [(set_attr "op_type"  "RR")
5959    (set_attr "type"     "fsimpd")])
5960
5961 ;
5962 ; abssf2 instruction pattern(s).
5963 ;
5964
5965 (define_expand "abssf2"
5966   [(parallel
5967     [(set (match_operand:SF 0 "register_operand" "=f")
5968           (abs:SF (match_operand:SF 1 "register_operand" "f")))
5969      (clobber (reg:CC 33))])]
5970   "TARGET_HARD_FLOAT"
5971   "")
5972
5973 (define_insn "*abssf2"
5974   [(set (match_operand:SF 0 "register_operand" "=f")
5975         (abs:SF (match_operand:SF 1 "register_operand" "f")))
5976    (clobber (reg:CC 33))]
5977   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5978   "lpebr\t%0,%1"
5979   [(set_attr "op_type"  "RRE")
5980    (set_attr "type"     "fsimps")])
5981
5982 (define_insn "*abssf2_ibm"
5983   [(set (match_operand:SF 0 "register_operand" "=f")
5984         (abs:SF (match_operand:SF 1 "register_operand" "f")))
5985    (clobber (reg:CC 33))]
5986   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5987   "lper\t%0,%1"
5988   [(set_attr "op_type"  "RR")
5989    (set_attr "type"     "fsimps")])
5990
5991 ;;
5992 ;;- Negated absolute value instructions
5993 ;;
5994
5995 ;
5996 ; Integer
5997 ;
5998
5999 (define_insn "*negabssi2"
6000   [(set (match_operand:SI 0 "register_operand" "=d")
6001         (neg:SI (abs:SI (match_operand:SI 1 "register_operand" "d"))))
6002    (clobber (reg:CC 33))]
6003   ""
6004   "lnr\t%0,%1"
6005   [(set_attr "op_type" "RR")])
6006
6007 (define_insn "*negabsdi2"
6008   [(set (match_operand:DI 0 "register_operand" "=d")
6009         (neg:DI (abs:DI (match_operand:DI 1 "register_operand" "d"))))
6010    (clobber (reg:CC 33))]
6011   "TARGET_64BIT"
6012   "lngr\t%0,%1"
6013   [(set_attr "op_type" "RRE")])
6014
6015 ;
6016 ; Floating point
6017 ;
6018
6019 (define_insn "*negabssf2"
6020   [(set (match_operand:SF 0 "register_operand" "=f")
6021         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6022    (clobber (reg:CC 33))]
6023   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6024   "lnebr\t%0,%1"
6025   [(set_attr "op_type"  "RRE")
6026    (set_attr "type"     "fsimps")])
6027
6028 (define_insn "*negabsdf2"
6029   [(set (match_operand:DF 0 "register_operand" "=f")
6030         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6031    (clobber (reg:CC 33))]
6032   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6033   "lndbr\t%0,%1"
6034   [(set_attr "op_type"  "RRE")
6035    (set_attr "type"     "fsimpd")])
6036
6037 ;;
6038 ;;- Square root instructions.
6039 ;;
6040
6041 ;
6042 ; sqrtdf2 instruction pattern(s).
6043 ;
6044
6045 (define_insn "sqrtdf2"
6046   [(set (match_operand:DF 0 "register_operand" "=f,f")
6047         (sqrt:DF (match_operand:DF 1 "general_operand" "f,R")))]
6048   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6049   "@
6050    sqdbr\t%0,%1
6051    sqdb\t%0,%1"
6052   [(set_attr "op_type"  "RRE,RXE")])
6053
6054 ;
6055 ; sqrtsf2 instruction pattern(s).
6056 ;
6057
6058 (define_insn "sqrtsf2"
6059   [(set (match_operand:SF 0 "register_operand" "=f,f")
6060         (sqrt:SF (match_operand:SF 1 "general_operand" "f,R")))]
6061   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6062   "@
6063    sqebr\t%0,%1
6064    sqeb\t%0,%1"
6065   [(set_attr "op_type"  "RRE,RXE")])
6066
6067 ;;
6068 ;;- One complement instructions.
6069 ;;
6070
6071 ;
6072 ; one_cmpldi2 instruction pattern(s).
6073 ;
6074
6075 (define_expand "one_cmpldi2"
6076   [(parallel
6077     [(set (match_operand:DI 0 "register_operand" "")
6078           (xor:DI (match_operand:DI 1 "register_operand" "")
6079                   (const_int -1)))
6080      (clobber (reg:CC 33))])]
6081   "TARGET_64BIT"
6082   "")
6083
6084 ;
6085 ; one_cmplsi2 instruction pattern(s).
6086 ;
6087
6088 (define_expand "one_cmplsi2"
6089   [(parallel
6090     [(set (match_operand:SI 0 "register_operand" "")
6091           (xor:SI (match_operand:SI 1 "register_operand" "")
6092                   (const_int -1)))
6093      (clobber (reg:CC 33))])]
6094   ""
6095   "")
6096
6097 ;
6098 ; one_cmplhi2 instruction pattern(s).
6099 ;
6100
6101 (define_expand "one_cmplhi2"
6102   [(parallel
6103     [(set (match_operand:HI 0 "register_operand" "")
6104           (xor:HI (match_operand:HI 1 "register_operand" "")
6105                   (const_int -1)))
6106      (clobber (reg:CC 33))])]
6107   ""
6108   "")
6109
6110 ;
6111 ; one_cmplqi2 instruction pattern(s).
6112 ;
6113
6114 (define_expand "one_cmplqi2"
6115   [(parallel
6116     [(set (match_operand:QI 0 "register_operand" "")
6117           (xor:QI (match_operand:QI 1 "register_operand" "")
6118                   (const_int -1)))
6119      (clobber (reg:CC 33))])]
6120   ""
6121   "")
6122
6123
6124 ;;
6125 ;;- Rotate instructions.
6126 ;;
6127
6128 ;
6129 ; rotldi3 instruction pattern(s).
6130 ;
6131
6132 (define_insn "rotldi3"
6133   [(set (match_operand:DI 0 "register_operand" "=d")
6134         (rotate:DI (match_operand:DI 1 "register_operand" "d")
6135                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6136   "TARGET_64BIT"
6137   "rllg\t%0,%1,%Y2"
6138   [(set_attr "op_type"  "RSE")
6139    (set_attr "atype"    "reg")])
6140
6141 ;
6142 ; rotlsi3 instruction pattern(s).
6143 ;
6144
6145 (define_insn "rotlsi3"
6146   [(set (match_operand:SI 0 "register_operand" "=d")
6147         (rotate:SI (match_operand:SI 1 "register_operand" "d")
6148                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6149   "TARGET_CPU_ZARCH"
6150   "rll\t%0,%1,%Y2"
6151   [(set_attr "op_type"  "RSE")
6152    (set_attr "atype"    "reg")])
6153
6154
6155 ;;
6156 ;;- Arithmetic shift instructions.
6157 ;;
6158
6159 ;
6160 ; ashldi3 instruction pattern(s).
6161 ;
6162
6163 (define_expand "ashldi3"
6164   [(set (match_operand:DI 0 "register_operand" "")
6165         (ashift:DI (match_operand:DI 1 "register_operand" "")
6166                    (match_operand:SI 2 "shift_count_operand" "")))]
6167   ""
6168   "")
6169
6170 (define_insn "*ashldi3_31"
6171   [(set (match_operand:DI 0 "register_operand" "=d")
6172         (ashift:DI (match_operand:DI 1 "register_operand" "0")
6173                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6174   "!TARGET_64BIT"
6175   "sldl\t%0,%Y2"
6176   [(set_attr "op_type"  "RS")
6177    (set_attr "atype"    "reg")])
6178
6179 (define_insn "*ashldi3_64"
6180   [(set (match_operand:DI 0 "register_operand" "=d")
6181         (ashift:DI (match_operand:DI 1 "register_operand" "d")
6182                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6183   "TARGET_64BIT"
6184   "sllg\t%0,%1,%Y2"
6185   [(set_attr "op_type"  "RSE")
6186    (set_attr "atype"    "reg")])
6187
6188 ;
6189 ; ashrdi3 instruction pattern(s).
6190 ;
6191
6192 (define_expand "ashrdi3"
6193   [(parallel
6194     [(set (match_operand:DI 0 "register_operand" "")
6195           (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6196                        (match_operand:SI 2 "shift_count_operand" "")))
6197      (clobber (reg:CC 33))])]
6198   ""
6199   "")
6200
6201 (define_insn "*ashrdi3_cc_31"
6202   [(set (reg 33)
6203         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6204                               (match_operand:SI 2 "shift_count_operand" "Y"))
6205                  (const_int 0)))
6206    (set (match_operand:DI 0 "register_operand" "=d")
6207         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6208   "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
6209   "srda\t%0,%Y2"
6210   [(set_attr "op_type"  "RS")
6211    (set_attr "atype"    "reg")])
6212
6213 (define_insn "*ashrdi3_cconly_31"
6214   [(set (reg 33)
6215         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6216                               (match_operand:SI 2 "shift_count_operand" "Y"))
6217                  (const_int 0)))
6218    (clobber (match_scratch:DI 0 "=d"))]
6219   "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
6220   "srda\t%0,%Y2"
6221   [(set_attr "op_type"  "RS")
6222    (set_attr "atype"    "reg")])
6223
6224 (define_insn "*ashrdi3_31"
6225   [(set (match_operand:DI 0 "register_operand" "=d")
6226         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6227                      (match_operand:SI 2 "shift_count_operand" "Y")))
6228    (clobber (reg:CC 33))]
6229   "!TARGET_64BIT"
6230   "srda\t%0,%Y2"
6231   [(set_attr "op_type"  "RS")
6232    (set_attr "atype"    "reg")])
6233
6234 (define_insn "*ashrdi3_cc_64"
6235   [(set (reg 33)
6236         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6237                               (match_operand:SI 2 "shift_count_operand" "Y"))
6238                  (const_int 0)))
6239    (set (match_operand:DI 0 "register_operand" "=d")
6240         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6241   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
6242   "srag\t%0,%1,%Y2"
6243   [(set_attr "op_type"  "RSE")
6244    (set_attr "atype"    "reg")])
6245
6246 (define_insn "*ashrdi3_cconly_64"
6247   [(set (reg 33)
6248         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6249                               (match_operand:SI 2 "shift_count_operand" "Y"))
6250                  (const_int 0)))
6251    (clobber (match_scratch:DI 0 "=d"))]
6252   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
6253   "srag\t%0,%1,%Y2"
6254   [(set_attr "op_type"  "RSE")
6255    (set_attr "atype"    "reg")])
6256
6257 (define_insn "*ashrdi3_64"
6258   [(set (match_operand:DI 0 "register_operand" "=d")
6259         (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6260                      (match_operand:SI 2 "shift_count_operand" "Y")))
6261    (clobber (reg:CC 33))]
6262   "TARGET_64BIT"
6263   "srag\t%0,%1,%Y2"
6264   [(set_attr "op_type"  "RSE")
6265    (set_attr "atype"    "reg")])
6266
6267
6268 ;
6269 ; ashlsi3 instruction pattern(s).
6270 ;
6271
6272 (define_insn "ashlsi3"
6273   [(set (match_operand:SI 0 "register_operand" "=d")
6274         (ashift:SI (match_operand:SI 1 "register_operand" "0")
6275                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6276   ""
6277   "sll\t%0,%Y2"
6278   [(set_attr "op_type"  "RS")
6279    (set_attr "atype"    "reg")])
6280
6281 ;
6282 ; ashrsi3 instruction pattern(s).
6283 ;
6284
6285 (define_insn "*ashrsi3_cc"
6286   [(set (reg 33)
6287         (compare (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6288                               (match_operand:SI 2 "shift_count_operand" "Y"))
6289                  (const_int 0)))
6290    (set (match_operand:SI 0 "register_operand" "=d")
6291         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
6292   "s390_match_ccmode(insn, CCSmode)"
6293   "sra\t%0,%Y2"
6294   [(set_attr "op_type"  "RS")
6295    (set_attr "atype"    "reg")])
6296
6297
6298 (define_insn "*ashrsi3_cconly"
6299   [(set (reg 33)
6300         (compare (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6301                               (match_operand:SI 2 "shift_count_operand" "Y"))
6302                  (const_int 0)))
6303    (clobber (match_scratch:SI 0 "=d"))]
6304   "s390_match_ccmode(insn, CCSmode)"
6305   "sra\t%0,%Y2"
6306   [(set_attr "op_type"  "RS")
6307    (set_attr "atype"    "reg")])
6308
6309 (define_insn "ashrsi3"
6310   [(set (match_operand:SI 0 "register_operand" "=d")
6311         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6312                      (match_operand:SI 2 "shift_count_operand" "Y")))
6313    (clobber (reg:CC 33))]
6314   ""
6315   "sra\t%0,%Y2"
6316   [(set_attr "op_type"  "RS")
6317    (set_attr "atype"    "reg")])
6318
6319
6320 ;;
6321 ;;- logical shift instructions.
6322 ;;
6323
6324 ;
6325 ; lshrdi3 instruction pattern(s).
6326 ;
6327
6328 (define_expand "lshrdi3"
6329   [(set (match_operand:DI 0 "register_operand" "")
6330         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
6331                      (match_operand:SI 2 "shift_count_operand" "")))]
6332   ""
6333   "")
6334
6335 (define_insn "*lshrdi3_31"
6336   [(set (match_operand:DI 0 "register_operand" "=d")
6337         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
6338                      (match_operand:SI 2 "shift_count_operand" "Y")))]
6339   "!TARGET_64BIT"
6340   "srdl\t%0,%Y2"
6341    [(set_attr "op_type"  "RS")
6342     (set_attr "atype"    "reg")])
6343
6344 (define_insn "*lshrdi3_64"
6345   [(set (match_operand:DI 0 "register_operand" "=d")
6346         (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6347                      (match_operand:SI 2 "shift_count_operand" "Y")))]
6348   "TARGET_64BIT"
6349   "srlg\t%0,%1,%Y2"
6350   [(set_attr "op_type"  "RSE")
6351    (set_attr "atype"    "reg")])
6352
6353 ;
6354 ; lshrsi3 instruction pattern(s).
6355 ;
6356
6357 (define_insn "lshrsi3"
6358   [(set (match_operand:SI 0 "register_operand" "=d")
6359         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
6360                      (match_operand:SI 2 "shift_count_operand" "Y")))]
6361   ""
6362   "srl\t%0,%Y2"
6363   [(set_attr "op_type"  "RS")
6364    (set_attr "atype"    "reg")])
6365
6366
6367 ;;
6368 ;; Branch instruction patterns.
6369 ;;
6370
6371 (define_expand "beq"
6372   [(set (reg:CCZ 33) (compare:CCZ (match_dup 1) (match_dup 2)))
6373    (set (pc)
6374         (if_then_else (eq (reg:CCZ 33) (const_int 0))
6375                       (label_ref (match_operand 0 "" ""))
6376                       (pc)))]
6377   ""
6378   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6379
6380 (define_expand "bne"
6381   [(set (reg:CCZ 33) (compare:CCZ (match_dup 1) (match_dup 2)))
6382    (set (pc)
6383         (if_then_else (ne (reg:CCZ 33) (const_int 0))
6384                       (label_ref (match_operand 0 "" ""))
6385                       (pc)))]
6386   ""
6387   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6388
6389 (define_expand "bgt"
6390   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6391    (set (pc)
6392         (if_then_else (gt (reg:CCS 33) (const_int 0))
6393                       (label_ref (match_operand 0 "" ""))
6394                       (pc)))]
6395   ""
6396   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6397
6398 (define_expand "bgtu"
6399   [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
6400    (set (pc)
6401         (if_then_else (gtu (reg:CCU 33) (const_int 0))
6402                       (label_ref (match_operand 0 "" ""))
6403                       (pc)))]
6404   ""
6405   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6406
6407 (define_expand "blt"
6408   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6409    (set (pc)
6410         (if_then_else (lt (reg:CCS 33) (const_int 0))
6411                       (label_ref (match_operand 0 "" ""))
6412                       (pc)))]
6413   ""
6414   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6415
6416 (define_expand "bltu"
6417   [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
6418    (set (pc)
6419         (if_then_else (ltu (reg:CCU 33) (const_int 0))
6420                       (label_ref (match_operand 0 "" ""))
6421                       (pc)))]
6422   ""
6423   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6424
6425 (define_expand "bge"
6426   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6427    (set (pc)
6428         (if_then_else (ge (reg:CCS 33) (const_int 0))
6429                       (label_ref (match_operand 0 "" ""))
6430                       (pc)))]
6431   ""
6432   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6433
6434 (define_expand "bgeu"
6435   [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
6436    (set (pc)
6437         (if_then_else (geu (reg:CCU 33) (const_int 0))
6438                       (label_ref (match_operand 0 "" ""))
6439                       (pc)))]
6440   ""
6441   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6442
6443 (define_expand "ble"
6444   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6445    (set (pc)
6446         (if_then_else (le (reg:CCS 33) (const_int 0))
6447                       (label_ref (match_operand 0 "" ""))
6448                       (pc)))]
6449   ""
6450   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6451
6452 (define_expand "bleu"
6453   [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
6454    (set (pc)
6455         (if_then_else (leu (reg:CCU 33) (const_int 0))
6456                       (label_ref (match_operand 0 "" ""))
6457                       (pc)))]
6458   ""
6459   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6460
6461 (define_expand "bunordered"
6462   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6463    (set (pc)
6464         (if_then_else (unordered (reg:CCS 33) (const_int 0))
6465                       (label_ref (match_operand 0 "" ""))
6466                       (pc)))]
6467   ""
6468   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6469
6470 (define_expand "bordered"
6471   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6472    (set (pc)
6473         (if_then_else (ordered (reg:CCS 33) (const_int 0))
6474                       (label_ref (match_operand 0 "" ""))
6475                       (pc)))]
6476   ""
6477   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6478
6479 (define_expand "buneq"
6480   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6481    (set (pc)
6482         (if_then_else (uneq (reg:CCS 33) (const_int 0))
6483                       (label_ref (match_operand 0 "" ""))
6484                       (pc)))]
6485   ""
6486   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6487
6488 (define_expand "bungt"
6489   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6490    (set (pc)
6491         (if_then_else (ungt (reg:CCS 33) (const_int 0))
6492                       (label_ref (match_operand 0 "" ""))
6493                       (pc)))]
6494   ""
6495   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6496
6497 (define_expand "bunlt"
6498   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6499    (set (pc)
6500         (if_then_else (unlt (reg:CCS 33) (const_int 0))
6501                       (label_ref (match_operand 0 "" ""))
6502                       (pc)))]
6503   ""
6504   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6505
6506 (define_expand "bunge"
6507   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6508    (set (pc)
6509         (if_then_else (unge (reg:CCS 33) (const_int 0))
6510                       (label_ref (match_operand 0 "" ""))
6511                       (pc)))]
6512   ""
6513   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6514
6515 (define_expand "bunle"
6516   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6517    (set (pc)
6518         (if_then_else (unle (reg:CCS 33) (const_int 0))
6519                       (label_ref (match_operand 0 "" ""))
6520                       (pc)))]
6521   ""
6522   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6523
6524 (define_expand "bltgt"
6525   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6526    (set (pc)
6527         (if_then_else (ltgt (reg:CCS 33) (const_int 0))
6528                       (label_ref (match_operand 0 "" ""))
6529                       (pc)))]
6530   ""
6531   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6532
6533
6534 ;;
6535 ;;- Conditional jump instructions.
6536 ;;
6537
6538 (define_insn "cjump"
6539  [(set (pc)
6540        (if_then_else
6541          (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
6542          (label_ref (match_operand 0 "" ""))
6543          (pc)))]
6544   ""
6545 {
6546   if (get_attr_length (insn) == 4)
6547     return "j%C1\t%l0";
6548   else if (TARGET_CPU_ZARCH)
6549     return "jg%C1\t%l0";
6550   else
6551     abort ();
6552 }
6553   [(set_attr "op_type" "RI")
6554    (set_attr "type"    "branch")
6555    (set (attr "length")
6556         (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6557                 (const_int 4)
6558                (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
6559                  (const_int 6)
6560                (eq (symbol_ref "flag_pic") (const_int 0))
6561                  (const_int 6)] (const_int 8)))])
6562
6563 (define_insn "*cjump_long"
6564  [(set (pc)
6565        (if_then_else
6566          (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
6567          (match_operand 0 "address_operand" "U")
6568          (pc)))]
6569   ""
6570 {
6571   if (get_attr_op_type (insn) == OP_TYPE_RR)
6572     return "b%C1r\t%0";
6573   else
6574     return "b%C1\t%a0";
6575 }
6576   [(set (attr "op_type")
6577         (if_then_else (match_operand 0 "register_operand" "")
6578                       (const_string "RR") (const_string "RX")))
6579    (set_attr "type"    "branch")
6580    (set_attr "atype" "agen")])
6581
6582
6583 ;;
6584 ;;- Negated conditional jump instructions.
6585 ;;
6586
6587 (define_insn "icjump"
6588  [(set (pc)
6589        (if_then_else
6590          (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
6591          (pc)
6592          (label_ref (match_operand 0 "" ""))))]
6593   ""
6594 {
6595   if (get_attr_length (insn) == 4)
6596     return "j%D1\t%l0";
6597   else if (TARGET_CPU_ZARCH)
6598     return "jg%D1\t%l0";
6599   else
6600     abort ();
6601 }
6602   [(set_attr "op_type" "RI")
6603    (set_attr "type"    "branch")
6604    (set (attr "length")
6605         (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6606                 (const_int 4)
6607                (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
6608                  (const_int 6)
6609                (eq (symbol_ref "flag_pic") (const_int 0))
6610                  (const_int 6)] (const_int 8)))])
6611
6612 (define_insn "*icjump_long"
6613  [(set (pc)
6614        (if_then_else
6615          (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
6616          (pc)
6617          (match_operand 0 "address_operand" "U")))]
6618   ""
6619 {
6620   if (get_attr_op_type (insn) == OP_TYPE_RR)
6621     return "b%D1r\t%0";
6622   else
6623     return "b%D1\t%a0";
6624 }
6625   [(set (attr "op_type")
6626         (if_then_else (match_operand 0 "register_operand" "")
6627                       (const_string "RR") (const_string "RX")))
6628    (set_attr "type"  "branch")
6629    (set_attr "atype" "agen")])
6630
6631 ;;
6632 ;;- Trap instructions.
6633 ;;
6634
6635 (define_insn "trap"
6636   [(trap_if (const_int 1) (const_int 0))]
6637   ""
6638   "j\t.+2"
6639   [(set_attr "op_type" "RX")
6640    (set_attr "type"  "branch")])
6641
6642 (define_expand "conditional_trap"
6643   [(set (match_dup 2) (match_dup 3))
6644    (trap_if (match_operator 0 "comparison_operator"
6645                             [(match_dup 2) (const_int 0)])
6646             (match_operand:SI 1 "general_operand" ""))]
6647   ""
6648 {
6649    enum machine_mode ccmode;
6650
6651    if (operands[1] != const0_rtx) FAIL;
6652
6653    ccmode = s390_select_ccmode (GET_CODE (operands[0]),
6654                                 s390_compare_op0, s390_compare_op1);
6655    operands[2] = gen_rtx_REG (ccmode, 33);
6656    operands[3] = gen_rtx_COMPARE (ccmode, s390_compare_op0, s390_compare_op1);
6657 })
6658
6659 (define_insn "*trap"
6660   [(trap_if (match_operator 0 "comparison_operator" [(reg 33) (const_int 0)])
6661             (const_int 0))]
6662   ""
6663   "j%C0\t.+2";
6664   [(set_attr "op_type" "RI")
6665    (set_attr "type"  "branch")])
6666
6667 ;;
6668 ;;- Loop instructions.
6669 ;;
6670 ;;  This is all complicated by the fact that since this is a jump insn
6671 ;;  we must handle our own output reloads.
6672
6673 (define_expand "doloop_end"
6674   [(use (match_operand 0 "" ""))        ; loop pseudo
6675    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
6676    (use (match_operand 2 "" ""))        ; max iterations
6677    (use (match_operand 3 "" ""))        ; loop level
6678    (use (match_operand 4 "" ""))]       ; label
6679   ""
6680 {
6681   if (GET_MODE (operands[0]) == SImode)
6682     emit_jump_insn (gen_doloop_si (operands[4], operands[0], operands[0]));
6683   else if (GET_MODE (operands[0]) == DImode && TARGET_64BIT)
6684     emit_jump_insn (gen_doloop_di (operands[4], operands[0], operands[0]));
6685   else
6686     FAIL;
6687
6688   DONE;
6689 })
6690
6691 (define_insn "doloop_si"
6692   [(set (pc)
6693         (if_then_else
6694           (ne (match_operand:SI 1 "register_operand" "d,d")
6695               (const_int 1))
6696           (label_ref (match_operand 0 "" ""))
6697           (pc)))
6698    (set (match_operand:SI 2 "nonimmediate_operand" "=1,?*m*d")
6699         (plus:SI (match_dup 1) (const_int -1)))
6700    (clobber (match_scratch:SI 3 "=X,&d"))
6701    (clobber (reg:CC 33))]
6702   ""
6703 {
6704   if (which_alternative != 0)
6705     return "#";
6706   else if (get_attr_length (insn) == 4)
6707     return "brct\t%1,%l0";
6708   else if (TARGET_CPU_ZARCH)
6709     return "ahi\t%1,-1\;jgne\t%l0";
6710   else
6711     abort ();
6712 }
6713   [(set_attr "op_type"  "RI")
6714    (set_attr "type"  "branch")
6715    (set (attr "length")
6716         (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6717                 (const_int 4)
6718                (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
6719                  (const_int 10)
6720                (eq (symbol_ref "flag_pic") (const_int 0))
6721                  (const_int 6)] (const_int 8)))])
6722
6723 (define_insn "*doloop_si_long"
6724   [(set (pc)
6725         (if_then_else
6726           (ne (match_operand:SI 1 "register_operand" "d,d")
6727               (const_int 1))
6728           (match_operand 0 "address_operand" "U,U")
6729           (pc)))
6730    (set (match_operand:SI 2 "register_operand" "=1,?*m*d")
6731         (plus:SI (match_dup 1) (const_int -1)))
6732    (clobber (match_scratch:SI 3 "=X,&d"))
6733    (clobber (reg:CC 33))]
6734   ""
6735 {
6736   if (get_attr_op_type (insn) == OP_TYPE_RR)
6737     return "bctr\t%1,%0";
6738   else
6739     return "bct\t%1,%a0";
6740 }
6741   [(set (attr "op_type")
6742         (if_then_else (match_operand 0 "register_operand" "")
6743                       (const_string "RR") (const_string "RX")))
6744    (set_attr "type"  "branch")
6745    (set_attr "atype" "agen")])
6746
6747 (define_split
6748   [(set (pc)
6749         (if_then_else (ne (match_operand:SI 1 "register_operand" "")
6750                           (const_int 1))
6751                       (match_operand 0 "" "")
6752                       (pc)))
6753    (set (match_operand:SI 2 "nonimmediate_operand" "")
6754         (plus:SI (match_dup 1) (const_int -1)))
6755    (clobber (match_scratch:SI 3 ""))
6756    (clobber (reg:CC 33))]
6757   "reload_completed
6758    && (! REG_P (operands[2])
6759        || ! rtx_equal_p (operands[1], operands[2]))"
6760   [(set (match_dup 3) (match_dup 1))
6761    (parallel [(set (reg:CCAN 33)
6762                    (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
6763                                  (const_int 0)))
6764               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
6765    (set (match_dup 2) (match_dup 3))
6766    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
6767                            (match_dup 0)
6768                            (pc)))]
6769   "")
6770
6771 (define_insn "doloop_di"
6772   [(set (pc)
6773         (if_then_else
6774           (ne (match_operand:DI 1 "register_operand" "d,d")
6775               (const_int 1))
6776           (label_ref (match_operand 0 "" ""))
6777           (pc)))
6778    (set (match_operand:DI 2 "nonimmediate_operand" "=1,?*m*r")
6779         (plus:DI (match_dup 1) (const_int -1)))
6780    (clobber (match_scratch:DI 3 "=X,&d"))
6781    (clobber (reg:CC 33))]
6782   "TARGET_64BIT"
6783 {
6784   if (which_alternative != 0)
6785     return "#";
6786   else if (get_attr_length (insn) == 4)
6787     return "brctg\t%1,%l0";
6788   else
6789     return "aghi\t%1,-1\;jgne\t%l0";
6790 }
6791   [(set_attr "op_type"  "RI")
6792    (set_attr "type"  "branch")
6793    (set (attr "length")
6794         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6795                       (const_int 4) (const_int 10)))])
6796
6797 (define_split
6798   [(set (pc)
6799         (if_then_else (ne (match_operand:DI 1 "register_operand" "")
6800                           (const_int 1))
6801                       (match_operand 0 "" "")
6802                       (pc)))
6803    (set (match_operand:DI 2 "nonimmediate_operand" "")
6804         (plus:DI (match_dup 1) (const_int -1)))
6805    (clobber (match_scratch:DI 3 ""))
6806    (clobber (reg:CC 33))]
6807   "reload_completed
6808    && (! REG_P (operands[2])
6809        || ! rtx_equal_p (operands[1], operands[2]))"
6810   [(set (match_dup 3) (match_dup 1))
6811    (parallel [(set (reg:CCAN 33)
6812                    (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
6813                                  (const_int 0)))
6814               (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
6815    (set (match_dup 2) (match_dup 3))
6816    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
6817                            (match_dup 0)
6818                            (pc)))]
6819   "")
6820
6821 ;;
6822 ;;- Unconditional jump instructions.
6823 ;;
6824
6825 ;
6826 ; jump instruction pattern(s).
6827 ;
6828
6829 (define_insn "jump"
6830   [(set (pc) (label_ref (match_operand 0 "" "")))]
6831   ""
6832 {
6833   if (get_attr_length (insn) == 4)
6834     return "j\t%l0";
6835   else if (TARGET_CPU_ZARCH)
6836     return "jg\t%l0";
6837   else
6838     abort ();
6839 }
6840   [(set_attr "op_type" "RI")
6841    (set_attr "type"  "branch")
6842    (set (attr "length")
6843         (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6844                 (const_int 4)
6845                (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
6846                  (const_int 6)
6847                (eq (symbol_ref "flag_pic") (const_int 0))
6848                  (const_int 6)] (const_int 8)))])
6849
6850 ;
6851 ; indirect-jump instruction pattern(s).
6852 ;
6853
6854 (define_insn "indirect_jump"
6855  [(set (pc) (match_operand 0 "address_operand" "U"))]
6856   ""
6857 {
6858   if (get_attr_op_type (insn) == OP_TYPE_RR)
6859     return "br\t%0";
6860   else
6861     return "b\t%a0";
6862 }
6863   [(set (attr "op_type")
6864         (if_then_else (match_operand 0 "register_operand" "")
6865                       (const_string "RR") (const_string "RX")))
6866    (set_attr "type"  "branch")
6867    (set_attr "atype" "agen")])
6868
6869 ;
6870 ; casesi instruction pattern(s).
6871 ;
6872
6873 (define_insn "casesi_jump"
6874  [(set (pc) (match_operand 0 "address_operand" "U"))
6875    (use (label_ref (match_operand 1 "" "")))]
6876   ""
6877 {
6878   if (get_attr_op_type (insn) == OP_TYPE_RR)
6879     return "br\t%0";
6880   else
6881     return "b\t%a0";
6882 }
6883   [(set (attr "op_type")
6884         (if_then_else (match_operand 0 "register_operand" "")
6885                       (const_string "RR") (const_string "RX")))
6886    (set_attr "type"  "branch")
6887    (set_attr "atype" "agen")])
6888
6889 (define_expand "casesi"
6890   [(match_operand:SI 0 "general_operand" "")
6891    (match_operand:SI 1 "general_operand" "")
6892    (match_operand:SI 2 "general_operand" "")
6893    (label_ref (match_operand 3 "" ""))
6894    (label_ref (match_operand 4 "" ""))]
6895   ""
6896 {
6897    rtx index  = gen_reg_rtx (SImode);
6898    rtx base   = gen_reg_rtx (Pmode);
6899    rtx target = gen_reg_rtx (Pmode);
6900
6901    emit_move_insn (index, operands[0]);
6902    emit_insn (gen_subsi3 (index, index, operands[1]));
6903    emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
6904                             operands[4]);
6905
6906    if (Pmode != SImode)
6907      index = convert_to_mode (Pmode, index, 1);
6908    if (GET_CODE (index) != REG)
6909      index = copy_to_mode_reg (Pmode, index);
6910
6911    if (TARGET_64BIT)
6912        emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
6913    else
6914        emit_insn (gen_ashlsi3 (index, index, const2_rtx));
6915
6916    emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
6917
6918    index = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, base, index));
6919    RTX_UNCHANGING_P (index) = 1;
6920    MEM_NOTRAP_P (index) = 1;
6921    emit_move_insn (target, index);
6922
6923    if (flag_pic)
6924      target = gen_rtx_PLUS (Pmode, base, target);
6925    emit_jump_insn (gen_casesi_jump (target, operands[3]));
6926
6927    DONE;
6928 })
6929
6930
6931 ;;
6932 ;;- Jump to subroutine.
6933 ;;
6934 ;;
6935
6936 ;
6937 ; untyped call instruction pattern(s).
6938 ;
6939
6940 ;; Call subroutine returning any type.
6941 (define_expand "untyped_call"
6942   [(parallel [(call (match_operand 0 "" "")
6943                     (const_int 0))
6944               (match_operand 1 "" "")
6945               (match_operand 2 "" "")])]
6946   ""
6947 {
6948   int i;
6949
6950   emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
6951
6952   for (i = 0; i < XVECLEN (operands[2], 0); i++)
6953     {
6954       rtx set = XVECEXP (operands[2], 0, i);
6955       emit_move_insn (SET_DEST (set), SET_SRC (set));
6956     }
6957
6958   /* The optimizer does not know that the call sets the function value
6959      registers we stored in the result block.  We avoid problems by
6960      claiming that all hard registers are used and clobbered at this
6961      point.  */
6962   emit_insn (gen_blockage ());
6963
6964   DONE;
6965 })
6966
6967 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6968 ;; all of memory.  This blocks insns from being moved across this point.
6969
6970 (define_insn "blockage"
6971   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6972   ""
6973   ""
6974   [(set_attr "type"    "none")
6975    (set_attr "length"  "0")])
6976
6977 ;
6978 ; sibcall patterns
6979 ;
6980
6981 (define_expand "sibcall"
6982   [(call (match_operand 0 "" "")
6983          (match_operand 1 "" ""))]
6984   ""
6985 {
6986   s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
6987   DONE;
6988 })
6989
6990 (define_insn "*sibcall_br"
6991   [(call (mem:QI (reg 1))
6992          (match_operand 0 "const_int_operand" "n"))]
6993   "SIBLING_CALL_P (insn)
6994    && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
6995   "br\t%%r1"
6996   [(set_attr "op_type" "RR")
6997    (set_attr "type"  "branch")
6998    (set_attr "atype" "agen")])
6999
7000 (define_insn "*sibcall_brc"
7001   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7002          (match_operand 1 "const_int_operand" "n"))]
7003   "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
7004   "j\t%0"
7005   [(set_attr "op_type" "RI")
7006    (set_attr "type"    "branch")])
7007
7008 (define_insn "*sibcall_brcl"
7009   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7010          (match_operand 1 "const_int_operand" "n"))]
7011   "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
7012   "jg\t%0"
7013   [(set_attr "op_type" "RIL")
7014    (set_attr "type"    "branch")])
7015
7016 ;
7017 ; sibcall_value patterns
7018 ;
7019
7020 (define_expand "sibcall_value"
7021   [(set (match_operand 0 "" "")
7022         (call (match_operand 1 "" "")
7023               (match_operand 2 "" "")))]
7024   ""
7025 {
7026   s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
7027   DONE;
7028 })
7029
7030 (define_insn "*sibcall_value_br"
7031   [(set (match_operand 0 "" "")
7032         (call (mem:QI (reg 1))
7033               (match_operand 1 "const_int_operand" "n")))]
7034   "SIBLING_CALL_P (insn)
7035    && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
7036   "br\t%%r1"
7037   [(set_attr "op_type" "RR")
7038    (set_attr "type"  "branch")
7039    (set_attr "atype" "agen")])
7040
7041 (define_insn "*sibcall_value_brc"
7042   [(set (match_operand 0 "" "")
7043         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7044               (match_operand 2 "const_int_operand" "n")))]
7045   "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
7046   "j\t%1"
7047   [(set_attr "op_type" "RI")
7048    (set_attr "type"    "branch")])
7049
7050 (define_insn "*sibcall_value_brcl"
7051   [(set (match_operand 0 "" "")
7052         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7053               (match_operand 2 "const_int_operand" "n")))]
7054   "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
7055   "jg\t%1"
7056   [(set_attr "op_type" "RIL")
7057    (set_attr "type"    "branch")])
7058
7059
7060 ;
7061 ; call instruction pattern(s).
7062 ;
7063
7064 (define_expand "call"
7065   [(call (match_operand 0 "" "")
7066          (match_operand 1 "" ""))
7067    (use (match_operand 2 "" ""))]
7068   ""
7069 {
7070   s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
7071                   gen_rtx_REG (Pmode, RETURN_REGNUM));
7072   DONE;
7073 })
7074
7075 (define_insn "*bras"
7076   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7077          (match_operand 1 "const_int_operand" "n"))
7078    (clobber (match_operand 2 "register_operand" "=r"))]
7079   "!SIBLING_CALL_P (insn)
7080    && TARGET_SMALL_EXEC
7081    && GET_MODE (operands[2]) == Pmode"
7082   "bras\t%2,%0"
7083   [(set_attr "op_type" "RI")
7084    (set_attr "type"    "jsr")])
7085
7086 (define_insn "*brasl"
7087   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7088          (match_operand 1 "const_int_operand" "n"))
7089    (clobber (match_operand 2 "register_operand" "=r"))]
7090   "!SIBLING_CALL_P (insn)
7091    && TARGET_CPU_ZARCH
7092    && GET_MODE (operands[2]) == Pmode"
7093   "brasl\t%2,%0"
7094   [(set_attr "op_type" "RIL")
7095    (set_attr "type"    "jsr")])
7096
7097 (define_insn "*basr"
7098   [(call (mem:QI (match_operand 0 "address_operand" "U"))
7099          (match_operand 1 "const_int_operand" "n"))
7100    (clobber (match_operand 2 "register_operand" "=r"))]
7101   "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
7102 {
7103   if (get_attr_op_type (insn) == OP_TYPE_RR)
7104     return "basr\t%2,%0";
7105   else
7106     return "bas\t%2,%a0";
7107 }
7108   [(set (attr "op_type")
7109         (if_then_else (match_operand 0 "register_operand" "")
7110                       (const_string "RR") (const_string "RX")))
7111    (set_attr "type"  "jsr")
7112    (set_attr "atype" "agen")])
7113
7114 ;
7115 ; call_value instruction pattern(s).
7116 ;
7117
7118 (define_expand "call_value"
7119   [(set (match_operand 0 "" "")
7120         (call (match_operand 1 "" "")
7121               (match_operand 2 "" "")))
7122    (use (match_operand 3 "" ""))]
7123   ""
7124 {
7125   s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
7126                   gen_rtx_REG (Pmode, RETURN_REGNUM));
7127   DONE;
7128 })
7129
7130 (define_insn "*bras_r"
7131   [(set (match_operand 0 "" "")
7132         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7133               (match_operand:SI 2 "const_int_operand" "n")))
7134    (clobber (match_operand 3 "register_operand" "=r"))]
7135   "!SIBLING_CALL_P (insn)
7136    && TARGET_SMALL_EXEC
7137    && GET_MODE (operands[3]) == Pmode"
7138   "bras\t%3,%1"
7139   [(set_attr "op_type" "RI")
7140    (set_attr "type"    "jsr")])
7141
7142 (define_insn "*brasl_r"
7143   [(set (match_operand 0 "" "")
7144         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7145               (match_operand 2 "const_int_operand" "n")))
7146    (clobber (match_operand 3 "register_operand" "=r"))]
7147   "!SIBLING_CALL_P (insn)
7148    && TARGET_CPU_ZARCH
7149    && GET_MODE (operands[3]) == Pmode"
7150   "brasl\t%3,%1"
7151   [(set_attr "op_type" "RIL")
7152    (set_attr "type"    "jsr")])
7153
7154 (define_insn "*basr_r"
7155   [(set (match_operand 0 "" "")
7156         (call (mem:QI (match_operand 1 "address_operand" "U"))
7157               (match_operand 2 "const_int_operand" "n")))
7158    (clobber (match_operand 3 "register_operand" "=r"))]
7159   "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
7160 {
7161   if (get_attr_op_type (insn) == OP_TYPE_RR)
7162     return "basr\t%3,%1";
7163   else
7164     return "bas\t%3,%a1";
7165 }
7166   [(set (attr "op_type")
7167         (if_then_else (match_operand 1 "register_operand" "")
7168                       (const_string "RR") (const_string "RX")))
7169    (set_attr "type"  "jsr")
7170    (set_attr "atype" "agen")])
7171
7172 ;;
7173 ;;- Thread-local storage support.
7174 ;;
7175
7176 (define_insn "get_tp_64"
7177   [(set (match_operand:DI 0 "nonimmediate_operand" "=??d,Q")
7178         (unspec:DI [(const_int 0)] UNSPEC_TP))]
7179   "TARGET_64BIT"
7180   "@
7181    ear\t%0,%%a0\;sllg\t%0,%0,32\;ear\t%0,%%a1
7182    stam\t%%a0,%%a1,%0"
7183   [(set_attr "op_type" "NN,RS")
7184    (set_attr "atype"   "reg,*")
7185    (set_attr "type"    "o3,*")
7186    (set_attr "length"  "14,*")])
7187
7188 (define_insn "get_tp_31"
7189   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,Q")
7190         (unspec:SI [(const_int 0)] UNSPEC_TP))]
7191   "!TARGET_64BIT"
7192   "@
7193    ear\t%0,%%a0
7194    stam\t%%a0,%%a0,%0"
7195   [(set_attr "op_type" "RRE,RS")])
7196
7197 (define_insn "set_tp_64"
7198   [(unspec_volatile [(match_operand:DI 0 "general_operand" "??d,Q")] UNSPECV_SET_TP)
7199    (clobber (match_scratch:SI 1 "=d,X"))]
7200   "TARGET_64BIT"
7201   "@
7202    sar\t%%a1,%0\;srlg\t%1,%0,32\;sar\t%%a0,%1
7203    lam\t%%a0,%%a1,%0"
7204   [(set_attr "op_type" "NN,RS")
7205    (set_attr "atype"   "reg,*")
7206    (set_attr "type"    "o3,*")
7207    (set_attr "length"  "14,*")])
7208
7209 (define_insn "set_tp_31"
7210   [(unspec_volatile [(match_operand:SI 0 "general_operand" "d,Q")] UNSPECV_SET_TP)]
7211   "!TARGET_64BIT"
7212   "@
7213    sar\t%%a0,%0
7214    lam\t%%a0,%%a0,%0"
7215   [(set_attr "op_type" "RRE,RS")])
7216
7217 (define_insn "*tls_load_64"
7218   [(set (match_operand:DI 0 "register_operand" "=d")
7219         (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
7220                     (match_operand:DI 2 "" "")]
7221                    UNSPEC_TLS_LOAD))]
7222   "TARGET_64BIT"
7223   "lg\t%0,%1%J2"
7224   [(set_attr "op_type" "RXE")])
7225
7226 (define_insn "*tls_load_31"
7227   [(set (match_operand:SI 0 "register_operand" "=d,d")
7228         (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
7229                     (match_operand:SI 2 "" "")]
7230                    UNSPEC_TLS_LOAD))]
7231   "!TARGET_64BIT"
7232   "@
7233    l\t%0,%1%J2
7234    ly\t%0,%1%J2"
7235   [(set_attr "op_type" "RX,RXY")])
7236
7237 (define_insn "*bras_tls"
7238   [(set (match_operand 0 "" "")
7239         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7240               (match_operand 2 "const_int_operand" "n")))
7241    (clobber (match_operand 3 "register_operand" "=r"))
7242    (use (match_operand 4 "" ""))]
7243   "!SIBLING_CALL_P (insn)
7244    && TARGET_SMALL_EXEC
7245    && GET_MODE (operands[3]) == Pmode"
7246   "bras\t%3,%1%J4"
7247   [(set_attr "op_type" "RI")
7248    (set_attr "type"    "jsr")])
7249
7250 (define_insn "*brasl_tls"
7251   [(set (match_operand 0 "" "")
7252         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7253               (match_operand 2 "const_int_operand" "n")))
7254    (clobber (match_operand 3 "register_operand" "=r"))
7255    (use (match_operand 4 "" ""))]
7256   "!SIBLING_CALL_P (insn)
7257    && TARGET_CPU_ZARCH
7258    && GET_MODE (operands[3]) == Pmode"
7259   "brasl\t%3,%1%J4"
7260   [(set_attr "op_type" "RIL")
7261    (set_attr "type"    "jsr")])
7262
7263 (define_insn "*basr_tls"
7264   [(set (match_operand 0 "" "")
7265         (call (mem:QI (match_operand 1 "address_operand" "U"))
7266               (match_operand 2 "const_int_operand" "n")))
7267    (clobber (match_operand 3 "register_operand" "=r"))
7268    (use (match_operand 4 "" ""))]
7269   "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
7270 {
7271   if (get_attr_op_type (insn) == OP_TYPE_RR)
7272     return "basr\t%3,%1%J4";
7273   else
7274     return "bas\t%3,%a1%J4";
7275 }
7276   [(set (attr "op_type")
7277         (if_then_else (match_operand 1 "register_operand" "")
7278                       (const_string "RR") (const_string "RX")))
7279    (set_attr "type"  "jsr")
7280    (set_attr "atype" "agen")])
7281
7282 ;;
7283 ;;- Miscellaneous instructions.
7284 ;;
7285
7286 ;
7287 ; allocate stack instruction pattern(s).
7288 ;
7289
7290 (define_expand "allocate_stack"
7291   [(set (reg 15)
7292         (plus (reg 15) (match_operand 1 "general_operand" "")))
7293    (set (match_operand 0 "general_operand" "")
7294         (reg 15))]
7295  "TARGET_BACKCHAIN"
7296 {
7297     rtx stack = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);
7298     rtx chain = gen_rtx_MEM (Pmode, stack);
7299     rtx temp = gen_reg_rtx (Pmode);
7300
7301     emit_move_insn (temp, chain);
7302
7303     if (TARGET_64BIT)
7304       emit_insn (gen_adddi3 (stack, stack, negate_rtx (Pmode, operands[1])));
7305     else
7306       emit_insn (gen_addsi3 (stack, stack, negate_rtx (Pmode, operands[1])));
7307
7308     emit_move_insn (chain, temp);
7309
7310     emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
7311     DONE;
7312 })
7313
7314
7315 ;
7316 ; setjmp instruction pattern.
7317 ;
7318
7319 (define_expand "builtin_setjmp_receiver"
7320   [(match_operand 0 "" "")]
7321   "flag_pic"
7322 {
7323   s390_load_got (false);
7324   emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
7325   DONE;
7326 })
7327
7328 ;; These patterns say how to save and restore the stack pointer.  We need not
7329 ;; save the stack pointer at function level since we are careful to
7330 ;; preserve the backchain.  At block level, we have to restore the backchain
7331 ;; when we restore the stack pointer.
7332 ;;
7333 ;; For nonlocal gotos, we must save both the stack pointer and its
7334 ;; backchain and restore both.  Note that in the nonlocal case, the
7335 ;; save area is a memory location.
7336
7337 (define_expand "save_stack_function"
7338   [(match_operand 0 "general_operand" "")
7339    (match_operand 1 "general_operand" "")]
7340   ""
7341   "DONE;")
7342
7343 (define_expand "restore_stack_function"
7344   [(match_operand 0 "general_operand" "")
7345    (match_operand 1 "general_operand" "")]
7346   ""
7347   "DONE;")
7348
7349 (define_expand "restore_stack_block"
7350   [(use (match_operand 0 "register_operand" ""))
7351    (set (match_dup 2) (match_dup 3))
7352    (set (match_dup 0) (match_operand 1 "register_operand" ""))
7353    (set (match_dup 3) (match_dup 2))]
7354   ""
7355 {
7356   operands[2] = gen_reg_rtx (Pmode);
7357   operands[3] = gen_rtx_MEM (Pmode, operands[0]);
7358 })
7359
7360 (define_expand "save_stack_nonlocal"
7361   [(match_operand 0 "memory_operand" "")
7362    (match_operand 1 "register_operand" "")]
7363   ""
7364 {
7365   rtx temp = gen_reg_rtx (Pmode);
7366
7367   /* Copy the backchain to the first word, sp to the second and the literal pool
7368      base to the third.  */
7369   emit_move_insn (operand_subword (operands[0], 2, 0,
7370                   TARGET_64BIT ? OImode : TImode),
7371                   gen_rtx_REG (Pmode, BASE_REGISTER));
7372   emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
7373   emit_move_insn (operand_subword (operands[0], 0, 0,
7374                  TARGET_64BIT ? OImode : TImode),
7375                  temp);
7376   emit_move_insn (operand_subword (operands[0], 1, 0,
7377                  TARGET_64BIT ? OImode : TImode),
7378                  operands[1]);
7379   DONE;
7380 })
7381
7382 (define_expand "restore_stack_nonlocal"
7383   [(match_operand 0 "register_operand" "")
7384    (match_operand 1 "memory_operand" "")]
7385   ""
7386 {
7387   rtx temp = gen_reg_rtx (Pmode);
7388   rtx base = gen_rtx_REG (Pmode, BASE_REGISTER);
7389
7390   /* Restore the backchain from the first word, sp from the second and the
7391      literal pool base from the third.  */
7392   emit_move_insn (temp,
7393                  operand_subword (operands[1], 0, 0,
7394                  TARGET_64BIT ? OImode : TImode));
7395   emit_move_insn (operands[0],
7396                  operand_subword (operands[1], 1, 0,
7397                  TARGET_64BIT ? OImode : TImode));
7398   emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
7399   emit_move_insn (base,
7400                   operand_subword (operands[1], 2, 0,
7401                   TARGET_64BIT ? OImode : TImode));
7402   emit_insn (gen_rtx_USE (VOIDmode, base));
7403
7404   DONE;
7405 })
7406
7407
7408 ;
7409 ; nop instruction pattern(s).
7410 ;
7411
7412 (define_insn "nop"
7413   [(const_int 0)]
7414   ""
7415   "lr\t0,0"
7416   [(set_attr "op_type" "RR")])
7417
7418
7419 ;
7420 ; Special literal pool access instruction pattern(s).
7421 ;
7422
7423 (define_insn "*pool_entry"
7424   [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
7425                     UNSPECV_POOL_ENTRY)]
7426   ""
7427 {
7428   enum machine_mode mode = GET_MODE (PATTERN (insn));
7429   unsigned int align = GET_MODE_BITSIZE (mode);
7430   s390_output_pool_entry (operands[0], mode, align);
7431   return "";
7432 }
7433   [(set_attr "op_type" "NN")
7434    (set (attr "length")
7435         (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
7436
7437 (define_insn "pool_start_31"
7438   [(unspec_volatile [(const_int 0)] UNSPECV_POOL_START)]
7439   "!TARGET_CPU_ZARCH"
7440   ".align\t4"
7441   [(set_attr "op_type"  "NN")
7442    (set_attr "length"   "2")])
7443
7444 (define_insn "pool_end_31"
7445   [(unspec_volatile [(const_int 0)] UNSPECV_POOL_END)]
7446   "!TARGET_CPU_ZARCH"
7447   ".align\t2"
7448   [(set_attr "op_type"  "NN")
7449    (set_attr "length"   "2")])
7450
7451 (define_insn "pool_start_64"
7452   [(unspec_volatile [(const_int 0)] UNSPECV_POOL_START)]
7453   "TARGET_CPU_ZARCH"
7454   ".section\t.rodata\;.align\t8"
7455   [(set_attr "op_type"  "NN")
7456    (set_attr "length"   "0")])
7457
7458 (define_insn "pool_end_64"
7459   [(unspec_volatile [(const_int 0)] UNSPECV_POOL_END)]
7460   "TARGET_CPU_ZARCH"
7461   ".previous"
7462   [(set_attr "op_type"  "NN")
7463    (set_attr "length"   "0")])
7464
7465 (define_insn "main_base_31_small"
7466   [(set (match_operand 0 "register_operand" "=a")
7467         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
7468   "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7469   "basr\t%0,0"
7470   [(set_attr "op_type" "RR")
7471    (set_attr "type"    "la")])
7472
7473 (define_insn "main_base_31_large"
7474   [(set (match_operand 0 "register_operand" "=a")
7475         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
7476    (set (pc) (label_ref (match_operand 2 "" "")))]
7477   "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7478   "bras\t%0,%2"
7479   [(set_attr "op_type" "RI")])
7480
7481 (define_insn "main_base_64"
7482   [(set (match_operand 0 "register_operand" "=a")
7483         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
7484   "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7485   "larl\t%0,%1"
7486   [(set_attr "op_type" "RIL")
7487    (set_attr "type"    "larl")])
7488
7489 (define_insn "main_pool"
7490   [(unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL)]
7491   ""
7492   "* abort ();"
7493   [(set_attr "op_type" "NN")])
7494
7495 (define_insn "reload_base_31"
7496   [(set (match_operand 0 "register_operand" "=a")
7497         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
7498   "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7499   "basr\t%0,0\;la\t%0,%1-.(%0)"
7500   [(set_attr "op_type" "NN")
7501    (set_attr "type"    "la")
7502    (set_attr "length"  "6")])
7503
7504 (define_insn "reload_base_64"
7505   [(set (match_operand 0 "register_operand" "=a")
7506         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
7507   "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7508   "larl\t%0,%1"
7509   [(set_attr "op_type" "RIL")
7510    (set_attr "type"    "larl")])
7511
7512 (define_insn "pool"
7513   [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
7514   ""
7515   "* abort ();"
7516   [(set_attr "op_type" "NN")
7517    (set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
7518
7519 ;;
7520 ;; Insns related to generating the function prologue and epilogue.
7521 ;;
7522
7523
7524 (define_expand "prologue"
7525   [(use (const_int 0))]
7526   ""
7527   "s390_emit_prologue (); DONE;")
7528
7529 (define_insn "prologue_tpf"
7530   [(unspec_volatile [(const_int 0)] UNSPECV_TPF_PROLOGUE)
7531    (clobber (reg:DI 1))]
7532   "TARGET_TPF_PROFILING"
7533   "bas\t%%r1,4064"
7534   [(set_attr "type" "jsr")
7535    (set_attr "op_type" "RX")])
7536
7537 (define_expand "epilogue"
7538   [(use (const_int 1))]
7539   ""
7540   "s390_emit_epilogue (false); DONE;")
7541
7542 (define_insn "epilogue_tpf"
7543   [(unspec_volatile [(const_int 0)] UNSPECV_TPF_EPILOGUE)
7544    (clobber (reg:DI 1))]
7545   "TARGET_TPF_PROFILING"
7546   "bas\t%%r1,4070"
7547   [(set_attr "type" "jsr")
7548    (set_attr "op_type" "RX")])
7549
7550
7551 (define_expand "sibcall_epilogue"
7552   [(use (const_int 0))]
7553   ""
7554   "s390_emit_epilogue (true); DONE;")
7555
7556 (define_insn "*return"
7557   [(return)
7558    (use (match_operand 0 "register_operand" "a"))]
7559   "GET_MODE (operands[0]) == Pmode"
7560   "br\t%0"
7561   [(set_attr "op_type" "RR")
7562    (set_attr "type"    "jsr")
7563    (set_attr "atype"   "agen")])
7564
7565
7566 ;; Instruction definition to extend a 31-bit pointer into a 64-bit
7567 ;; pointer. This is used for compatibility.
7568
7569 (define_expand "ptr_extend"
7570   [(set (match_operand:DI 0 "register_operand" "=r")
7571         (match_operand:SI 1 "register_operand" "r"))]
7572   "TARGET_64BIT"
7573 {
7574   emit_insn (gen_anddi3 (operands[0],
7575                          gen_lowpart (DImode, operands[1]),
7576                          GEN_INT (0x7fffffff)));
7577   DONE;
7578 })