OSDN Git Service

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