OSDN Git Service

PR target/20754
[pf3gnuchains/gcc-fork.git] / gcc / config / pa / pa.md
1 ;;- Machine description for HP PA-RISC architecture for GCC compiler
2 ;;   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3 ;;   2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 ;;   Contributed by the Center for Software Science at the University
5 ;;   of Utah.
6
7 ;; This file is part of GCC.
8
9 ;; GCC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GCC is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING.  If not, write to
21 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
23
24 ;; This gcc Version 2 machine description is inspired by sparc.md and
25 ;; mips.md.
26
27 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
28
29 ;; Uses of UNSPEC in this file:
30
31 (define_constants
32   [(UNSPEC_CFFC         0)      ; canonicalize_funcptr_for_compare
33    (UNSPEC_GOTO         1)      ; indirect_goto
34    (UNSPEC_DLTIND14R    2)      ; 
35    (UNSPEC_TP           3)
36    (UNSPEC_TLSGD        4)
37    (UNSPEC_TLSLDM       5)
38    (UNSPEC_TLSLDO       6)
39    (UNSPEC_TLSLDBASE    7)
40    (UNSPEC_TLSIE        8)
41    (UNSPEC_TLSLE        9)
42   ])
43
44 ;; UNSPEC_VOLATILE:
45
46 (define_constants
47   [(UNSPECV_BLOCKAGE    0)      ; blockage
48    (UNSPECV_DCACHE      1)      ; dcacheflush
49    (UNSPECV_ICACHE      2)      ; icacheflush
50    (UNSPECV_OPC         3)      ; outline_prologue_call
51    (UNSPECV_OEC         4)      ; outline_epilogue_call
52    (UNSPECV_LONGJMP     5)      ; builtin_longjmp
53   ])
54
55 ;; Insn type.  Used to default other attribute values.
56
57 ;; type "unary" insns have one input operand (1) and one output operand (0)
58 ;; type "binary" insns have two input operands (1,2) and one output (0)
59
60 (define_attr "type"
61   "move,unary,binary,shift,nullshift,compare,load,store,uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,fpload,fpstore,fpalu,fpcc,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,multi,milli,parallel_branch"
62   (const_string "binary"))
63
64 (define_attr "pa_combine_type"
65   "fmpy,faddsub,uncond_branch,addmove,none"
66   (const_string "none"))
67
68 ;; Processor type (for scheduling, not code generation) -- this attribute
69 ;; must exactly match the processor_type enumeration in pa.h.
70 ;;
71 ;; FIXME: Add 800 scheduling for completeness?
72
73 (define_attr "cpu" "700,7100,7100LC,7200,7300,8000" (const (symbol_ref "pa_cpu_attr")))
74
75 ;; Length (in # of bytes).
76 (define_attr "length" ""
77   (cond [(eq_attr "type" "load,fpload")
78          (if_then_else (match_operand 1 "symbolic_memory_operand" "")
79                        (const_int 8) (const_int 4))
80
81          (eq_attr "type" "store,fpstore")
82          (if_then_else (match_operand 0 "symbolic_memory_operand" "")
83                        (const_int 8) (const_int 4))
84
85          (eq_attr "type" "binary,shift,nullshift")
86          (if_then_else (match_operand 2 "arith_operand" "")
87                        (const_int 4) (const_int 12))
88
89          (eq_attr "type" "move,unary,shift,nullshift")
90          (if_then_else (match_operand 1 "arith_operand" "")
91                        (const_int 4) (const_int 8))]
92
93         (const_int 4)))
94
95 (define_asm_attributes
96   [(set_attr "length" "4")
97    (set_attr "type" "multi")])
98
99 ;; Attributes for instruction and branch scheduling
100
101 ;; For conditional branches.
102 (define_attr "in_branch_delay" "false,true"
103   (if_then_else (and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
104                      (eq_attr "length" "4"))
105                 (const_string "true")
106                 (const_string "false")))
107
108 ;; Disallow instructions which use the FPU since they will tie up the FPU
109 ;; even if the instruction is nullified.
110 (define_attr "in_nullified_branch_delay" "false,true"
111   (if_then_else (and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,parallel_branch")
112                      (eq_attr "length" "4"))
113                 (const_string "true")
114                 (const_string "false")))
115
116 ;; For calls and millicode calls.  Allow unconditional branches in the
117 ;; delay slot.
118 (define_attr "in_call_delay" "false,true"
119   (cond [(and (eq_attr "type" "!uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
120               (eq_attr "length" "4"))
121            (const_string "true")
122          (eq_attr "type" "uncond_branch")
123            (if_then_else (ne (symbol_ref "TARGET_JUMP_IN_DELAY")
124                              (const_int 0))
125                          (const_string "true")
126                          (const_string "false"))]
127         (const_string "false")))
128
129
130 ;; Call delay slot description.
131 (define_delay (eq_attr "type" "call")
132   [(eq_attr "in_call_delay" "true") (nil) (nil)])
133
134 ;; Millicode call delay slot description.
135 (define_delay (eq_attr "type" "milli")
136   [(eq_attr "in_call_delay" "true") (nil) (nil)])
137
138 ;; Return and other similar instructions.
139 (define_delay (eq_attr "type" "btable_branch,branch,parallel_branch")
140   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
141
142 ;; Floating point conditional branch delay slot description and
143 (define_delay (eq_attr "type" "fbranch")
144   [(eq_attr "in_branch_delay" "true")
145    (eq_attr "in_nullified_branch_delay" "true")
146    (nil)])
147
148 ;; Integer conditional branch delay slot description.
149 ;; Nullification of conditional branches on the PA is dependent on the
150 ;; direction of the branch.  Forward branches nullify true and
151 ;; backward branches nullify false.  If the direction is unknown
152 ;; then nullification is not allowed.
153 (define_delay (eq_attr "type" "cbranch")
154   [(eq_attr "in_branch_delay" "true")
155    (and (eq_attr "in_nullified_branch_delay" "true")
156         (attr_flag "forward"))
157    (and (eq_attr "in_nullified_branch_delay" "true")
158         (attr_flag "backward"))])
159
160 (define_delay (and (eq_attr "type" "uncond_branch")
161                    (eq (symbol_ref "following_call (insn)")
162                        (const_int 0)))
163   [(eq_attr "in_branch_delay" "true") (nil) (nil)])
164
165 ;; Memory. Disregarding Cache misses, the Mustang memory times are:
166 ;; load: 2, fpload: 3
167 ;; store, fpstore: 3, no D-cache operations should be scheduled.
168
169 ;; The Timex (aka 700) has two floating-point units: ALU, and MUL/DIV/SQRT.
170 ;; Timings:
171 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
172 ;; fcpy         3       ALU     2
173 ;; fabs         3       ALU     2
174 ;; fadd         3       ALU     2
175 ;; fsub         3       ALU     2
176 ;; fcmp         3       ALU     2
177 ;; fcnv         3       ALU     2
178 ;; fmpyadd      3       ALU,MPY 2
179 ;; fmpysub      3       ALU,MPY 2
180 ;; fmpycfxt     3       ALU,MPY 2
181 ;; fmpy         3       MPY     2
182 ;; fmpyi        3       MPY     2
183 ;; fdiv,sgl     10      MPY     10
184 ;; fdiv,dbl     12      MPY     12
185 ;; fsqrt,sgl    14      MPY     14
186 ;; fsqrt,dbl    18      MPY     18
187 ;;
188 ;; We don't model fmpyadd/fmpysub properly as those instructions
189 ;; keep both the FP ALU and MPY units busy.  Given that these
190 ;; processors are obsolete, I'm not going to spend the time to
191 ;; model those instructions correctly.
192
193 (define_automaton "pa700")
194 (define_cpu_unit "dummy_700,mem_700,fpalu_700,fpmpy_700" "pa700")
195
196 (define_insn_reservation "W0" 4
197   (and (eq_attr "type" "fpcc")
198        (eq_attr "cpu" "700"))
199   "fpalu_700*2")
200
201 (define_insn_reservation "W1" 3
202   (and (eq_attr "type" "fpalu")
203        (eq_attr "cpu" "700"))
204   "fpalu_700*2")
205
206 (define_insn_reservation "W2" 3
207   (and (eq_attr "type" "fpmulsgl,fpmuldbl")
208        (eq_attr "cpu" "700"))
209   "fpmpy_700*2")
210
211 (define_insn_reservation "W3" 10
212   (and (eq_attr "type" "fpdivsgl")
213        (eq_attr "cpu" "700"))
214   "fpmpy_700*10")
215
216 (define_insn_reservation "W4" 12
217   (and (eq_attr "type" "fpdivdbl")
218        (eq_attr "cpu" "700"))
219   "fpmpy_700*12")
220
221 (define_insn_reservation "W5" 14
222   (and (eq_attr "type" "fpsqrtsgl")
223        (eq_attr "cpu" "700"))
224   "fpmpy_700*14")
225
226 (define_insn_reservation "W6" 18
227   (and (eq_attr "type" "fpsqrtdbl")
228        (eq_attr "cpu" "700"))
229   "fpmpy_700*18")
230
231 (define_insn_reservation "W7" 2
232   (and (eq_attr "type" "load")
233        (eq_attr "cpu" "700"))
234   "mem_700")
235
236 (define_insn_reservation "W8" 2
237   (and (eq_attr "type" "fpload")
238        (eq_attr "cpu" "700"))
239   "mem_700")
240
241 (define_insn_reservation "W9" 3
242   (and (eq_attr "type" "store")
243        (eq_attr "cpu" "700"))
244   "mem_700*3")
245
246 (define_insn_reservation "W10" 3
247   (and (eq_attr "type" "fpstore")
248        (eq_attr "cpu" "700"))
249   "mem_700*3")
250
251 (define_insn_reservation "W11" 1
252   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpdivdbl,fpsqrtsgl,fpsqrtdbl,load,fpload,store,fpstore")
253        (eq_attr "cpu" "700"))
254   "dummy_700")
255
256 ;; We have a bypass for all computations in the FP unit which feed an
257 ;; FP store as long as the sizes are the same.
258 (define_bypass 2 "W1,W2" "W10" "hppa_fpstore_bypass_p")
259 (define_bypass 9 "W3" "W10" "hppa_fpstore_bypass_p")
260 (define_bypass 11 "W4" "W10" "hppa_fpstore_bypass_p")
261 (define_bypass 13 "W5" "W10" "hppa_fpstore_bypass_p")
262 (define_bypass 17 "W6" "W10" "hppa_fpstore_bypass_p")
263
264 ;; We have an "anti-bypass" for FP loads which feed an FP store.
265 (define_bypass 4 "W8" "W10" "hppa_fpstore_bypass_p")
266
267 ;; Function units for the 7100 and 7150.  The 7100/7150 can dual-issue
268 ;; floating point computations with non-floating point computations (fp loads
269 ;; and stores are not fp computations).
270 ;;
271 ;; Memory. Disregarding Cache misses, memory loads take two cycles; stores also
272 ;; take two cycles, during which no Dcache operations should be scheduled.
273 ;; Any special cases are handled in pa_adjust_cost.  The 7100, 7150 and 7100LC
274 ;; all have the same memory characteristics if one disregards cache misses.
275 ;;
276 ;; The 7100/7150 has three floating-point units: ALU, MUL, and DIV.
277 ;; There's no value in modeling the ALU and MUL separately though
278 ;; since there can never be a functional unit conflict given the
279 ;; latency and issue rates for those units.
280 ;;
281 ;; Timings:
282 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
283 ;; fcpy         2       ALU     1
284 ;; fabs         2       ALU     1
285 ;; fadd         2       ALU     1
286 ;; fsub         2       ALU     1
287 ;; fcmp         2       ALU     1
288 ;; fcnv         2       ALU     1
289 ;; fmpyadd      2       ALU,MPY 1
290 ;; fmpysub      2       ALU,MPY 1
291 ;; fmpycfxt     2       ALU,MPY 1
292 ;; fmpy         2       MPY     1
293 ;; fmpyi        2       MPY     1
294 ;; fdiv,sgl     8       DIV     8
295 ;; fdiv,dbl     15      DIV     15
296 ;; fsqrt,sgl    8       DIV     8
297 ;; fsqrt,dbl    15      DIV     15
298
299 (define_automaton "pa7100")
300 (define_cpu_unit "i_7100, f_7100,fpmac_7100,fpdivsqrt_7100,mem_7100" "pa7100")
301
302 (define_insn_reservation "X0" 2
303   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
304        (eq_attr "cpu" "7100"))
305   "f_7100,fpmac_7100")
306
307 (define_insn_reservation "X1" 8
308   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl")
309        (eq_attr "cpu" "7100"))
310   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*7")
311
312 (define_insn_reservation "X2" 15
313   (and (eq_attr "type" "fpdivdbl,fpsqrtdbl")
314        (eq_attr "cpu" "7100"))
315   "f_7100+fpdivsqrt_7100,fpdivsqrt_7100*14")
316
317 (define_insn_reservation "X3" 2
318   (and (eq_attr "type" "load")
319        (eq_attr "cpu" "7100"))
320   "i_7100+mem_7100")
321
322 (define_insn_reservation "X4" 2
323   (and (eq_attr "type" "fpload")
324        (eq_attr "cpu" "7100"))
325   "i_7100+mem_7100")
326
327 (define_insn_reservation "X5" 2
328   (and (eq_attr "type" "store")
329        (eq_attr "cpu" "7100"))
330   "i_7100+mem_7100,mem_7100")
331
332 (define_insn_reservation "X6" 2
333   (and (eq_attr "type" "fpstore")
334        (eq_attr "cpu" "7100"))
335   "i_7100+mem_7100,mem_7100")
336
337 (define_insn_reservation "X7" 1
338   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore")
339        (eq_attr "cpu" "7100"))
340   "i_7100")
341
342 ;; We have a bypass for all computations in the FP unit which feed an
343 ;; FP store as long as the sizes are the same.
344 (define_bypass 1 "X0" "X6" "hppa_fpstore_bypass_p")
345 (define_bypass 7 "X1" "X6" "hppa_fpstore_bypass_p")
346 (define_bypass 14 "X2" "X6" "hppa_fpstore_bypass_p")
347
348 ;; We have an "anti-bypass" for FP loads which feed an FP store.
349 (define_bypass 3 "X4" "X6" "hppa_fpstore_bypass_p")
350
351 ;; The 7100LC has three floating-point units: ALU, MUL, and DIV.
352 ;; There's no value in modeling the ALU and MUL separately though
353 ;; since there can never be a functional unit conflict that
354 ;; can be avoided given the latency, issue rates and mandatory
355 ;; one cycle cpu-wide lock for a double precision fp multiply.
356 ;;
357 ;; Timings:
358 ;; Instruction  Time    Unit    Minimum Distance (unit contention)
359 ;; fcpy         2       ALU     1
360 ;; fabs         2       ALU     1
361 ;; fadd         2       ALU     1
362 ;; fsub         2       ALU     1
363 ;; fcmp         2       ALU     1
364 ;; fcnv         2       ALU     1
365 ;; fmpyadd,sgl  2       ALU,MPY 1
366 ;; fmpyadd,dbl  3       ALU,MPY 2
367 ;; fmpysub,sgl  2       ALU,MPY 1
368 ;; fmpysub,dbl  3       ALU,MPY 2
369 ;; fmpycfxt,sgl 2       ALU,MPY 1
370 ;; fmpycfxt,dbl 3       ALU,MPY 2
371 ;; fmpy,sgl     2       MPY     1
372 ;; fmpy,dbl     3       MPY     2
373 ;; fmpyi        3       MPY     2
374 ;; fdiv,sgl     8       DIV     8
375 ;; fdiv,dbl     15      DIV     15
376 ;; fsqrt,sgl    8       DIV     8
377 ;; fsqrt,dbl    15      DIV     15
378 ;;
379 ;; The PA7200 is just like the PA7100LC except that there is
380 ;; no store-store penalty.
381 ;;
382 ;; The PA7300 is just like the PA7200 except that there is
383 ;; no store-load penalty.
384 ;;
385 ;; Note there are some aspects of the 7100LC we are not modeling
386 ;; at the moment.  I'll be reviewing the 7100LC scheduling info
387 ;; shortly and updating this description.
388 ;;
389 ;;   load-load pairs
390 ;;   store-store pairs
391 ;;   other issue modeling
392
393 (define_automaton "pa7100lc")
394 (define_cpu_unit "i0_7100lc, i1_7100lc, f_7100lc" "pa7100lc")
395 (define_cpu_unit "fpmac_7100lc" "pa7100lc")
396 (define_cpu_unit "mem_7100lc" "pa7100lc")
397
398 ;; Double precision multiplies lock the entire CPU for one
399 ;; cycle.  There is no way to avoid this lock and trying to
400 ;; schedule around the lock is pointless and thus there is no
401 ;; value in trying to model this lock.
402 ;;
403 ;; Not modeling the lock allows us to treat fp multiplies just
404 ;; like any other FP alu instruction.  It allows for a smaller
405 ;; DFA and may reduce register pressure.
406 (define_insn_reservation "Y0" 2
407   (and (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
408        (eq_attr "cpu" "7100LC,7200,7300"))
409   "f_7100lc,fpmac_7100lc")
410
411 ;; fp division and sqrt instructions lock the entire CPU for
412 ;; 7 cycles (single precision) or 14 cycles (double precision).
413 ;; There is no way to avoid this lock and trying to schedule
414 ;; around the lock is pointless and thus there is no value in
415 ;; trying to model this lock.  Not modeling the lock allows
416 ;; for a smaller DFA and may reduce register pressure.
417 (define_insn_reservation "Y1" 1
418   (and (eq_attr "type" "fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl")
419        (eq_attr "cpu" "7100LC,7200,7300"))
420   "f_7100lc")
421
422 (define_insn_reservation "Y2" 2
423   (and (eq_attr "type" "load")
424        (eq_attr "cpu" "7100LC,7200,7300"))
425   "i1_7100lc+mem_7100lc")
426
427 (define_insn_reservation "Y3" 2
428   (and (eq_attr "type" "fpload")
429        (eq_attr "cpu" "7100LC,7200,7300"))
430   "i1_7100lc+mem_7100lc")
431
432 (define_insn_reservation "Y4" 2
433   (and (eq_attr "type" "store")
434        (eq_attr "cpu" "7100LC"))
435   "i1_7100lc+mem_7100lc,mem_7100lc")
436
437 (define_insn_reservation "Y5" 2
438   (and (eq_attr "type" "fpstore")
439        (eq_attr "cpu" "7100LC"))
440   "i1_7100lc+mem_7100lc,mem_7100lc")
441
442 (define_insn_reservation "Y6" 1
443   (and (eq_attr "type" "shift,nullshift")
444        (eq_attr "cpu" "7100LC,7200,7300"))
445   "i1_7100lc")
446
447 (define_insn_reservation "Y7" 1
448   (and (eq_attr "type" "!fpcc,fpalu,fpmulsgl,fpmuldbl,fpdivsgl,fpsqrtsgl,fpdivdbl,fpsqrtdbl,load,fpload,store,fpstore,shift,nullshift")
449        (eq_attr "cpu" "7100LC,7200,7300"))
450   "(i0_7100lc|i1_7100lc)")
451
452 ;; The 7200 has a store-load penalty
453 (define_insn_reservation "Y8" 2
454   (and (eq_attr "type" "store")
455        (eq_attr "cpu" "7200"))
456   "i1_7100lc,mem_7100lc")
457
458 (define_insn_reservation "Y9" 2
459   (and (eq_attr "type" "fpstore")
460        (eq_attr "cpu" "7200"))
461   "i1_7100lc,mem_7100lc")
462
463 ;; The 7300 has no penalty for store-store or store-load
464 (define_insn_reservation "Y10" 2
465   (and (eq_attr "type" "store")
466        (eq_attr "cpu" "7300"))
467   "i1_7100lc")
468
469 (define_insn_reservation "Y11" 2
470   (and (eq_attr "type" "fpstore")
471        (eq_attr "cpu" "7300"))
472   "i1_7100lc")
473
474 ;; We have an "anti-bypass" for FP loads which feed an FP store.
475 (define_bypass 3 "Y3" "Y5,Y9,Y11" "hppa_fpstore_bypass_p")
476
477 ;; Scheduling for the PA8000 is somewhat different than scheduling for a
478 ;; traditional architecture.
479 ;;
480 ;; The PA8000 has a large (56) entry reorder buffer that is split between
481 ;; memory and non-memory operations.
482 ;;
483 ;; The PA8000 can issue two memory and two non-memory operations per cycle to
484 ;; the function units, with the exception of branches and multi-output
485 ;; instructions.  The PA8000 can retire two non-memory operations per cycle
486 ;; and two memory operations per cycle, only one of which may be a store.
487 ;;
488 ;; Given the large reorder buffer, the processor can hide most latencies.
489 ;; According to HP, they've got the best results by scheduling for retirement
490 ;; bandwidth with limited latency scheduling for floating point operations.
491 ;; Latency for integer operations and memory references is ignored.
492 ;;
493 ;;
494 ;; We claim floating point operations have a 2 cycle latency and are
495 ;; fully pipelined, except for div and sqrt which are not pipelined and
496 ;; take from 17 to 31 cycles to complete.
497 ;;
498 ;; It's worth noting that there is no way to saturate all the functional
499 ;; units on the PA8000 as there is not enough issue bandwidth.
500
501 (define_automaton "pa8000")
502 (define_cpu_unit "inm0_8000, inm1_8000, im0_8000, im1_8000" "pa8000")
503 (define_cpu_unit "rnm0_8000, rnm1_8000, rm0_8000, rm1_8000" "pa8000")
504 (define_cpu_unit "store_8000" "pa8000")
505 (define_cpu_unit "f0_8000, f1_8000" "pa8000")
506 (define_cpu_unit "fdivsqrt0_8000, fdivsqrt1_8000" "pa8000")
507 (define_reservation "inm_8000" "inm0_8000 | inm1_8000")
508 (define_reservation "im_8000" "im0_8000 | im1_8000")
509 (define_reservation "rnm_8000" "rnm0_8000 | rnm1_8000")
510 (define_reservation "rm_8000" "rm0_8000 | rm1_8000")
511 (define_reservation "f_8000" "f0_8000 | f1_8000")
512 (define_reservation "fdivsqrt_8000" "fdivsqrt0_8000 | fdivsqrt1_8000")
513
514 ;; We can issue any two memops per cycle, but we can only retire
515 ;; one memory store per cycle.  We assume that the reorder buffer
516 ;; will hide any memory latencies per HP's recommendation.
517 (define_insn_reservation "Z0" 0
518   (and
519     (eq_attr "type" "load,fpload")
520     (eq_attr "cpu" "8000"))
521   "im_8000,rm_8000")
522
523 (define_insn_reservation "Z1" 0
524   (and
525     (eq_attr "type" "store,fpstore")
526     (eq_attr "cpu" "8000"))
527   "im_8000,rm_8000+store_8000")
528
529 ;; We can issue and retire two non-memory operations per cycle with
530 ;; a few exceptions (branches).  This group catches those we want
531 ;; to assume have zero latency.
532 (define_insn_reservation "Z2" 0
533   (and
534     (eq_attr "type" "!load,fpload,store,fpstore,uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch,fpcc,fpalu,fpmulsgl,fpmuldbl,fpsqrtsgl,fpsqrtdbl,fpdivsgl,fpdivdbl")
535     (eq_attr "cpu" "8000"))
536   "inm_8000,rnm_8000")
537
538 ;; Branches use both slots in the non-memory issue and
539 ;; retirement unit.
540 (define_insn_reservation "Z3" 0
541   (and
542     (eq_attr "type" "uncond_branch,btable_branch,branch,cbranch,fbranch,call,dyncall,multi,milli,parallel_branch")
543     (eq_attr "cpu" "8000"))
544   "inm0_8000+inm1_8000,rnm0_8000+rnm1_8000")
545
546 ;; We partial latency schedule the floating point units.
547 ;; They can issue/retire two at a time in the non-memory
548 ;; units.  We fix their latency at 2 cycles and they
549 ;; are fully pipelined.
550 (define_insn_reservation "Z4" 1
551  (and
552    (eq_attr "type" "fpcc,fpalu,fpmulsgl,fpmuldbl")
553    (eq_attr "cpu" "8000"))
554  "inm_8000,f_8000,rnm_8000")
555
556 ;; The fdivsqrt units are not pipelined and have a very long latency.  
557 ;; To keep the DFA from exploding, we do not show all the
558 ;; reservations for the divsqrt unit.
559 (define_insn_reservation "Z5" 17
560  (and
561    (eq_attr "type" "fpdivsgl,fpsqrtsgl")
562    (eq_attr "cpu" "8000"))
563  "inm_8000,fdivsqrt_8000*6,rnm_8000")
564
565 (define_insn_reservation "Z6" 31
566  (and
567    (eq_attr "type" "fpdivdbl,fpsqrtdbl")
568    (eq_attr "cpu" "8000"))
569  "inm_8000,fdivsqrt_8000*6,rnm_8000")
570
571 (include "predicates.md")
572 \f
573 ;; Compare instructions.
574 ;; This controls RTL generation and register allocation.
575
576 ;; We generate RTL for comparisons and branches by having the cmpxx
577 ;; patterns store away the operands.  Then, the scc and bcc patterns
578 ;; emit RTL for both the compare and the branch.
579 ;;
580
581 (define_expand "cmpdi"
582   [(set (reg:CC 0)
583         (compare:CC (match_operand:DI 0 "reg_or_0_operand" "")
584                     (match_operand:DI 1 "register_operand" "")))]
585   "TARGET_64BIT"
586
587   "
588 {
589  hppa_compare_op0 = operands[0];
590  hppa_compare_op1 = operands[1];
591  hppa_branch_type = CMP_SI;
592  DONE;
593 }")
594
595 (define_expand "cmpsi"
596   [(set (reg:CC 0)
597         (compare:CC (match_operand:SI 0 "reg_or_0_operand" "")
598                     (match_operand:SI 1 "arith5_operand" "")))]
599   ""
600   "
601 {
602  hppa_compare_op0 = operands[0];
603  hppa_compare_op1 = operands[1];
604  hppa_branch_type = CMP_SI;
605  DONE;
606 }")
607
608 (define_expand "cmpsf"
609   [(set (reg:CCFP 0)
610         (compare:CCFP (match_operand:SF 0 "reg_or_0_operand" "")
611                       (match_operand:SF 1 "reg_or_0_operand" "")))]
612   "! TARGET_SOFT_FLOAT"
613   "
614 {
615   hppa_compare_op0 = operands[0];
616   hppa_compare_op1 = operands[1];
617   hppa_branch_type = CMP_SF;
618   DONE;
619 }")
620
621 (define_expand "cmpdf"
622   [(set (reg:CCFP 0)
623       (compare:CCFP (match_operand:DF 0 "reg_or_0_operand" "")
624                     (match_operand:DF 1 "reg_or_0_operand" "")))]
625   "! TARGET_SOFT_FLOAT"
626   "
627 {
628   hppa_compare_op0 = operands[0];
629   hppa_compare_op1 = operands[1];
630   hppa_branch_type = CMP_DF;
631   DONE;
632 }")
633
634 (define_insn ""
635   [(set (reg:CCFP 0)
636         (match_operator:CCFP 2 "comparison_operator"
637                              [(match_operand:SF 0 "reg_or_0_operand" "fG")
638                               (match_operand:SF 1 "reg_or_0_operand" "fG")]))]
639   "! TARGET_SOFT_FLOAT"
640   "fcmp,sgl,%Y2 %f0,%f1"
641   [(set_attr "length" "4")
642    (set_attr "type" "fpcc")])
643
644 (define_insn ""
645   [(set (reg:CCFP 0)
646         (match_operator:CCFP 2 "comparison_operator"
647                              [(match_operand:DF 0 "reg_or_0_operand" "fG")
648                               (match_operand:DF 1 "reg_or_0_operand" "fG")]))]
649   "! TARGET_SOFT_FLOAT"
650   "fcmp,dbl,%Y2 %f0,%f1"
651   [(set_attr "length" "4")
652    (set_attr "type" "fpcc")])
653
654 ;; Provide a means to emit the movccfp0 and movccfp1 optimization
655 ;; placeholders.  This is necessary in rare situations when a
656 ;; placeholder is re-emitted (see PR 8705).
657
658 (define_expand "movccfp"
659   [(set (reg:CCFP 0)
660         (match_operand 0 "const_int_operand" ""))]
661   "! TARGET_SOFT_FLOAT"
662   "
663 {
664   if ((unsigned HOST_WIDE_INT) INTVAL (operands[0]) > 1)
665     FAIL;
666 }")
667
668 ;; The following patterns are optimization placeholders.  In almost
669 ;; all cases, the user of the condition code will be simplified and the
670 ;; original condition code setting insn should be eliminated.
671
672 (define_insn "*movccfp0"
673   [(set (reg:CCFP 0)
674         (const_int 0))]
675   "! TARGET_SOFT_FLOAT"
676   "fcmp,dbl,= %%fr0,%%fr0"
677   [(set_attr "length" "4")
678    (set_attr "type" "fpcc")])
679
680 (define_insn "*movccfp1"
681   [(set (reg:CCFP 0)
682         (const_int 1))]
683   "! TARGET_SOFT_FLOAT"
684   "fcmp,dbl,!= %%fr0,%%fr0"
685   [(set_attr "length" "4")
686    (set_attr "type" "fpcc")])
687
688 ;; scc insns.
689
690 (define_expand "seq"
691   [(set (match_operand:SI 0 "register_operand" "")
692         (eq:SI (match_dup 1)
693                (match_dup 2)))]
694   "!TARGET_64BIT"
695   "
696 {
697   /* fp scc patterns rarely match, and are not a win on the PA.  */
698   if (hppa_branch_type != CMP_SI)
699     FAIL;
700   /* set up operands from compare.  */
701   operands[1] = hppa_compare_op0;
702   operands[2] = hppa_compare_op1;
703   /* fall through and generate default code */
704 }")
705
706 (define_expand "sne"
707   [(set (match_operand:SI 0 "register_operand" "")
708         (ne:SI (match_dup 1)
709                (match_dup 2)))]
710   "!TARGET_64BIT"
711   "
712 {
713   /* fp scc patterns rarely match, and are not a win on the PA.  */
714   if (hppa_branch_type != CMP_SI)
715     FAIL;
716   operands[1] = hppa_compare_op0;
717   operands[2] = hppa_compare_op1;
718 }")
719
720 (define_expand "slt"
721   [(set (match_operand:SI 0 "register_operand" "")
722         (lt:SI (match_dup 1)
723                (match_dup 2)))]
724   "!TARGET_64BIT"
725   "
726 {
727   /* fp scc patterns rarely match, and are not a win on the PA.  */
728   if (hppa_branch_type != CMP_SI)
729     FAIL;
730   operands[1] = hppa_compare_op0;
731   operands[2] = hppa_compare_op1;
732 }")
733
734 (define_expand "sgt"
735   [(set (match_operand:SI 0 "register_operand" "")
736         (gt:SI (match_dup 1)
737                (match_dup 2)))]
738   "!TARGET_64BIT"
739   "
740 {
741   /* fp scc patterns rarely match, and are not a win on the PA.  */
742   if (hppa_branch_type != CMP_SI)
743     FAIL;
744   operands[1] = hppa_compare_op0;
745   operands[2] = hppa_compare_op1;
746 }")
747
748 (define_expand "sle"
749   [(set (match_operand:SI 0 "register_operand" "")
750         (le:SI (match_dup 1)
751                (match_dup 2)))]
752   "!TARGET_64BIT"
753   "
754 {
755   /* fp scc patterns rarely match, and are not a win on the PA.  */
756   if (hppa_branch_type != CMP_SI)
757     FAIL;
758   operands[1] = hppa_compare_op0;
759   operands[2] = hppa_compare_op1;
760 }")
761
762 (define_expand "sge"
763   [(set (match_operand:SI 0 "register_operand" "")
764         (ge:SI (match_dup 1)
765                (match_dup 2)))]
766   "!TARGET_64BIT"
767   "
768 {
769   /* fp scc patterns rarely match, and are not a win on the PA.  */
770   if (hppa_branch_type != CMP_SI)
771     FAIL;
772   operands[1] = hppa_compare_op0;
773   operands[2] = hppa_compare_op1;
774 }")
775
776 (define_expand "sltu"
777   [(set (match_operand:SI 0 "register_operand" "")
778         (ltu:SI (match_dup 1)
779                 (match_dup 2)))]
780   "!TARGET_64BIT"
781   "
782 {
783   if (hppa_branch_type != CMP_SI)
784     FAIL;
785   operands[1] = hppa_compare_op0;
786   operands[2] = hppa_compare_op1;
787 }")
788
789 (define_expand "sgtu"
790   [(set (match_operand:SI 0 "register_operand" "")
791         (gtu:SI (match_dup 1)
792                 (match_dup 2)))]
793   "!TARGET_64BIT"
794   "
795 {
796   if (hppa_branch_type != CMP_SI)
797     FAIL;
798   operands[1] = hppa_compare_op0;
799   operands[2] = hppa_compare_op1;
800 }")
801
802 (define_expand "sleu"
803   [(set (match_operand:SI 0 "register_operand" "")
804         (leu:SI (match_dup 1)
805                 (match_dup 2)))]
806   "!TARGET_64BIT"
807   "
808 {
809   if (hppa_branch_type != CMP_SI)
810     FAIL;
811   operands[1] = hppa_compare_op0;
812   operands[2] = hppa_compare_op1;
813 }")
814
815 (define_expand "sgeu"
816   [(set (match_operand:SI 0 "register_operand" "")
817         (geu:SI (match_dup 1)
818                 (match_dup 2)))]
819   "!TARGET_64BIT"
820   "
821 {
822   if (hppa_branch_type != CMP_SI)
823     FAIL;
824   operands[1] = hppa_compare_op0;
825   operands[2] = hppa_compare_op1;
826 }")
827
828 ;; Instruction canonicalization puts immediate operands second, which
829 ;; is the reverse of what we want.
830
831 (define_insn "scc"
832   [(set (match_operand:SI 0 "register_operand" "=r")
833         (match_operator:SI 3 "comparison_operator"
834                            [(match_operand:SI 1 "register_operand" "r")
835                             (match_operand:SI 2 "arith11_operand" "rI")]))]
836   ""
837   "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi 1,%0"
838   [(set_attr "type" "binary")
839    (set_attr "length" "8")])
840
841 (define_insn ""
842   [(set (match_operand:DI 0 "register_operand" "=r")
843         (match_operator:DI 3 "comparison_operator"
844                            [(match_operand:DI 1 "register_operand" "r")
845                             (match_operand:DI 2 "arith11_operand" "rI")]))]
846   "TARGET_64BIT"
847   "cmp%I2clr,*%B3 %2,%1,%0\;ldi 1,%0"
848   [(set_attr "type" "binary")
849    (set_attr "length" "8")])
850
851 (define_insn "iorscc"
852   [(set (match_operand:SI 0 "register_operand" "=r")
853         (ior:SI (match_operator:SI 3 "comparison_operator"
854                                    [(match_operand:SI 1 "register_operand" "r")
855                                     (match_operand:SI 2 "arith11_operand" "rI")])
856                 (match_operator:SI 6 "comparison_operator"
857                                    [(match_operand:SI 4 "register_operand" "r")
858                                     (match_operand:SI 5 "arith11_operand" "rI")])))]
859   ""
860   "{com%I2clr|cmp%I2clr},%S3 %2,%1,%%r0\;{com%I5clr|cmp%I5clr},%B6 %5,%4,%0\;ldi 1,%0"
861   [(set_attr "type" "binary")
862    (set_attr "length" "12")])
863
864 (define_insn ""
865   [(set (match_operand:DI 0 "register_operand" "=r")
866         (ior:DI (match_operator:DI 3 "comparison_operator"
867                                    [(match_operand:DI 1 "register_operand" "r")
868                                     (match_operand:DI 2 "arith11_operand" "rI")])
869                 (match_operator:DI 6 "comparison_operator"
870                                    [(match_operand:DI 4 "register_operand" "r")
871                                     (match_operand:DI 5 "arith11_operand" "rI")])))]
872   "TARGET_64BIT"
873   "cmp%I2clr,*%S3 %2,%1,%%r0\;cmp%I5clr,*%B6 %5,%4,%0\;ldi 1,%0"
874   [(set_attr "type" "binary")
875    (set_attr "length" "12")])
876
877 ;; Combiner patterns for common operations performed with the output
878 ;; from an scc insn (negscc and incscc).
879 (define_insn "negscc"
880   [(set (match_operand:SI 0 "register_operand" "=r")
881         (neg:SI (match_operator:SI 3 "comparison_operator"
882                [(match_operand:SI 1 "register_operand" "r")
883                 (match_operand:SI 2 "arith11_operand" "rI")])))]
884   ""
885   "{com%I2clr|cmp%I2clr},%B3 %2,%1,%0\;ldi -1,%0"
886   [(set_attr "type" "binary")
887    (set_attr "length" "8")])
888
889 (define_insn ""
890   [(set (match_operand:DI 0 "register_operand" "=r")
891         (neg:DI (match_operator:DI 3 "comparison_operator"
892                [(match_operand:DI 1 "register_operand" "r")
893                 (match_operand:DI 2 "arith11_operand" "rI")])))]
894   "TARGET_64BIT"
895   "cmp%I2clr,*%B3 %2,%1,%0\;ldi -1,%0"
896   [(set_attr "type" "binary")
897    (set_attr "length" "8")])
898
899 ;; Patterns for adding/subtracting the result of a boolean expression from
900 ;; a register.  First we have special patterns that make use of the carry
901 ;; bit, and output only two instructions.  For the cases we can't in
902 ;; general do in two instructions, the incscc pattern at the end outputs
903 ;; two or three instructions.
904
905 (define_insn ""
906   [(set (match_operand:SI 0 "register_operand" "=r")
907         (plus:SI (leu:SI (match_operand:SI 2 "register_operand" "r")
908                          (match_operand:SI 3 "arith11_operand" "rI"))
909                  (match_operand:SI 1 "register_operand" "r")))]
910   ""
911   "sub%I3 %3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
912   [(set_attr "type" "binary")
913    (set_attr "length" "8")])
914
915 (define_insn ""
916   [(set (match_operand:DI 0 "register_operand" "=r")
917         (plus:DI (leu:DI (match_operand:DI 2 "register_operand" "r")
918                          (match_operand:DI 3 "arith11_operand" "rI"))
919                  (match_operand:DI 1 "register_operand" "r")))]
920   "TARGET_64BIT"
921   "sub%I3 %3,%2,%%r0\;add,dc %%r0,%1,%0"
922   [(set_attr "type" "binary")
923    (set_attr "length" "8")])
924
925 ; This need only accept registers for op3, since canonicalization
926 ; replaces geu with gtu when op3 is an integer.
927 (define_insn ""
928   [(set (match_operand:SI 0 "register_operand" "=r")
929         (plus:SI (geu:SI (match_operand:SI 2 "register_operand" "r")
930                          (match_operand:SI 3 "register_operand" "r"))
931                  (match_operand:SI 1 "register_operand" "r")))]
932   ""
933   "sub %2,%3,%%r0\;{addc|add,c} %%r0,%1,%0"
934   [(set_attr "type" "binary")
935    (set_attr "length" "8")])
936
937 (define_insn ""
938   [(set (match_operand:DI 0 "register_operand" "=r")
939         (plus:DI (geu:DI (match_operand:DI 2 "register_operand" "r")
940                          (match_operand:DI 3 "register_operand" "r"))
941                  (match_operand:DI 1 "register_operand" "r")))]
942   "TARGET_64BIT"
943   "sub %2,%3,%%r0\;add,dc %%r0,%1,%0"
944   [(set_attr "type" "binary")
945    (set_attr "length" "8")])
946
947 ; Match only integers for op3 here.  This is used as canonical form of the
948 ; geu pattern when op3 is an integer.  Don't match registers since we can't
949 ; make better code than the general incscc pattern.
950 (define_insn ""
951   [(set (match_operand:SI 0 "register_operand" "=r")
952         (plus:SI (gtu:SI (match_operand:SI 2 "register_operand" "r")
953                          (match_operand:SI 3 "int11_operand" "I"))
954                  (match_operand:SI 1 "register_operand" "r")))]
955   ""
956   "addi %k3,%2,%%r0\;{addc|add,c} %%r0,%1,%0"
957   [(set_attr "type" "binary")
958    (set_attr "length" "8")])
959
960 (define_insn ""
961   [(set (match_operand:DI 0 "register_operand" "=r")
962         (plus:DI (gtu:DI (match_operand:DI 2 "register_operand" "r")
963                          (match_operand:DI 3 "int11_operand" "I"))
964                  (match_operand:DI 1 "register_operand" "r")))]
965   "TARGET_64BIT"
966   "addi %k3,%2,%%r0\;add,dc %%r0,%1,%0"
967   [(set_attr "type" "binary")
968    (set_attr "length" "8")])
969
970 (define_insn "incscc"
971   [(set (match_operand:SI 0 "register_operand" "=r,r")
972         (plus:SI (match_operator:SI 4 "comparison_operator"
973                     [(match_operand:SI 2 "register_operand" "r,r")
974                      (match_operand:SI 3 "arith11_operand" "rI,rI")])
975                  (match_operand:SI 1 "register_operand" "0,?r")))]
976   ""
977   "@
978    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi 1,%0,%0
979    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
980   [(set_attr "type" "binary,binary")
981    (set_attr "length" "8,12")])
982
983 (define_insn ""
984   [(set (match_operand:DI 0 "register_operand" "=r,r")
985         (plus:DI (match_operator:DI 4 "comparison_operator"
986                     [(match_operand:DI 2 "register_operand" "r,r")
987                      (match_operand:DI 3 "arith11_operand" "rI,rI")])
988                  (match_operand:DI 1 "register_operand" "0,?r")))]
989   "TARGET_64BIT"
990   "@
991    cmp%I3clr,*%B4 %3,%2,%%r0\;addi 1,%0,%0
992    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr 1,%1,%0\;copy %1,%0"
993   [(set_attr "type" "binary,binary")
994    (set_attr "length" "8,12")])
995
996 (define_insn ""
997   [(set (match_operand:SI 0 "register_operand" "=r")
998         (minus:SI (match_operand:SI 1 "register_operand" "r")
999                   (gtu:SI (match_operand:SI 2 "register_operand" "r")
1000                           (match_operand:SI 3 "arith11_operand" "rI"))))]
1001   ""
1002   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1003   [(set_attr "type" "binary")
1004    (set_attr "length" "8")])
1005
1006 (define_insn ""
1007   [(set (match_operand:DI 0 "register_operand" "=r")
1008         (minus:DI (match_operand:DI 1 "register_operand" "r")
1009                   (gtu:DI (match_operand:DI 2 "register_operand" "r")
1010                           (match_operand:DI 3 "arith11_operand" "rI"))))]
1011   "TARGET_64BIT"
1012   "sub%I3 %3,%2,%%r0\;sub,db %1,%%r0,%0"
1013   [(set_attr "type" "binary")
1014    (set_attr "length" "8")])
1015
1016 (define_insn ""
1017   [(set (match_operand:SI 0 "register_operand" "=r")
1018         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1019                             (gtu:SI (match_operand:SI 2 "register_operand" "r")
1020                                     (match_operand:SI 3 "arith11_operand" "rI")))
1021                   (match_operand:SI 4 "register_operand" "r")))]
1022   ""
1023   "sub%I3 %3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1024   [(set_attr "type" "binary")
1025    (set_attr "length" "8")])
1026
1027 (define_insn ""
1028   [(set (match_operand:DI 0 "register_operand" "=r")
1029         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1030                             (gtu:DI (match_operand:DI 2 "register_operand" "r")
1031                                     (match_operand:DI 3 "arith11_operand" "rI")))
1032                   (match_operand:DI 4 "register_operand" "r")))]
1033   "TARGET_64BIT"
1034   "sub%I3 %3,%2,%%r0\;sub,db %1,%4,%0"
1035   [(set_attr "type" "binary")
1036    (set_attr "length" "8")])
1037
1038 ; This need only accept registers for op3, since canonicalization
1039 ; replaces ltu with leu when op3 is an integer.
1040 (define_insn ""
1041   [(set (match_operand:SI 0 "register_operand" "=r")
1042         (minus:SI (match_operand:SI 1 "register_operand" "r")
1043                   (ltu:SI (match_operand:SI 2 "register_operand" "r")
1044                           (match_operand:SI 3 "register_operand" "r"))))]
1045   ""
1046   "sub %2,%3,%%r0\;{subb|sub,b} %1,%%r0,%0"
1047   [(set_attr "type" "binary")
1048    (set_attr "length" "8")])
1049
1050 (define_insn ""
1051   [(set (match_operand:DI 0 "register_operand" "=r")
1052         (minus:DI (match_operand:DI 1 "register_operand" "r")
1053                   (ltu:DI (match_operand:DI 2 "register_operand" "r")
1054                           (match_operand:DI 3 "register_operand" "r"))))]
1055   "TARGET_64BIT"
1056   "sub %2,%3,%%r0\;sub,db %1,%%r0,%0"
1057   [(set_attr "type" "binary")
1058    (set_attr "length" "8")])
1059
1060 (define_insn ""
1061   [(set (match_operand:SI 0 "register_operand" "=r")
1062         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1063                             (ltu:SI (match_operand:SI 2 "register_operand" "r")
1064                                     (match_operand:SI 3 "register_operand" "r")))
1065                   (match_operand:SI 4 "register_operand" "r")))]
1066   ""
1067   "sub %2,%3,%%r0\;{subb|sub,b} %1,%4,%0"
1068   [(set_attr "type" "binary")
1069    (set_attr "length" "8")])
1070
1071 (define_insn ""
1072   [(set (match_operand:DI 0 "register_operand" "=r")
1073         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1074                             (ltu:DI (match_operand:DI 2 "register_operand" "r")
1075                                     (match_operand:DI 3 "register_operand" "r")))
1076                   (match_operand:DI 4 "register_operand" "r")))]
1077   "TARGET_64BIT"
1078   "sub %2,%3,%%r0\;sub,db %1,%4,%0"
1079   [(set_attr "type" "binary")
1080    (set_attr "length" "8")])
1081
1082 ; Match only integers for op3 here.  This is used as canonical form of the
1083 ; ltu pattern when op3 is an integer.  Don't match registers since we can't
1084 ; make better code than the general incscc pattern.
1085 (define_insn ""
1086   [(set (match_operand:SI 0 "register_operand" "=r")
1087         (minus:SI (match_operand:SI 1 "register_operand" "r")
1088                   (leu:SI (match_operand:SI 2 "register_operand" "r")
1089                           (match_operand:SI 3 "int11_operand" "I"))))]
1090   ""
1091   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%%r0,%0"
1092   [(set_attr "type" "binary")
1093    (set_attr "length" "8")])
1094
1095 (define_insn ""
1096   [(set (match_operand:DI 0 "register_operand" "=r")
1097         (minus:DI (match_operand:DI 1 "register_operand" "r")
1098                   (leu:DI (match_operand:DI 2 "register_operand" "r")
1099                           (match_operand:DI 3 "int11_operand" "I"))))]
1100   "TARGET_64BIT"
1101   "addi %k3,%2,%%r0\;sub,db %1,%%r0,%0"
1102   [(set_attr "type" "binary")
1103    (set_attr "length" "8")])
1104
1105 (define_insn ""
1106   [(set (match_operand:SI 0 "register_operand" "=r")
1107         (minus:SI (minus:SI (match_operand:SI 1 "register_operand" "r")
1108                             (leu:SI (match_operand:SI 2 "register_operand" "r")
1109                                     (match_operand:SI 3 "int11_operand" "I")))
1110                   (match_operand:SI 4 "register_operand" "r")))]
1111   ""
1112   "addi %k3,%2,%%r0\;{subb|sub,b} %1,%4,%0"
1113   [(set_attr "type" "binary")
1114    (set_attr "length" "8")])
1115
1116 (define_insn ""
1117   [(set (match_operand:DI 0 "register_operand" "=r")
1118         (minus:DI (minus:DI (match_operand:DI 1 "register_operand" "r")
1119                             (leu:DI (match_operand:DI 2 "register_operand" "r")
1120                                     (match_operand:DI 3 "int11_operand" "I")))
1121                   (match_operand:DI 4 "register_operand" "r")))]
1122   "TARGET_64BIT"
1123   "addi %k3,%2,%%r0\;sub,db %1,%4,%0"
1124   [(set_attr "type" "binary")
1125    (set_attr "length" "8")])
1126
1127 (define_insn "decscc"
1128   [(set (match_operand:SI 0 "register_operand" "=r,r")
1129         (minus:SI (match_operand:SI 1 "register_operand" "0,?r")
1130                   (match_operator:SI 4 "comparison_operator"
1131                      [(match_operand:SI 2 "register_operand" "r,r")
1132                       (match_operand:SI 3 "arith11_operand" "rI,rI")])))]
1133   ""
1134   "@
1135    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi -1,%0,%0
1136    {com%I3clr|cmp%I3clr},%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1137   [(set_attr "type" "binary,binary")
1138    (set_attr "length" "8,12")])
1139
1140 (define_insn ""
1141   [(set (match_operand:DI 0 "register_operand" "=r,r")
1142         (minus:DI (match_operand:DI 1 "register_operand" "0,?r")
1143                   (match_operator:DI 4 "comparison_operator"
1144                      [(match_operand:DI 2 "register_operand" "r,r")
1145                       (match_operand:DI 3 "arith11_operand" "rI,rI")])))]
1146   "TARGET_64BIT"
1147   "@
1148    cmp%I3clr,*%B4 %3,%2,%%r0\;addi -1,%0,%0
1149    cmp%I3clr,*%B4 %3,%2,%%r0\;addi,tr -1,%1,%0\;copy %1,%0"
1150   [(set_attr "type" "binary,binary")
1151    (set_attr "length" "8,12")])
1152
1153 ; Patterns for max and min.  (There is no need for an earlyclobber in the
1154 ; last alternative since the middle alternative will match if op0 == op1.)
1155
1156 (define_insn "sminsi3"
1157   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1158         (smin:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1159                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1160   ""
1161   "@
1162   {comclr|cmpclr},> %2,%0,%%r0\;copy %2,%0
1163   {comiclr|cmpiclr},> %2,%0,%%r0\;ldi %2,%0
1164   {comclr|cmpclr},> %1,%r2,%0\;copy %1,%0"
1165 [(set_attr "type" "multi,multi,multi")
1166  (set_attr "length" "8,8,8")])
1167
1168 (define_insn "smindi3"
1169   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1170         (smin:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1171                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1172   "TARGET_64BIT"
1173   "@
1174   cmpclr,*> %2,%0,%%r0\;copy %2,%0
1175   cmpiclr,*> %2,%0,%%r0\;ldi %2,%0
1176   cmpclr,*> %1,%r2,%0\;copy %1,%0"
1177 [(set_attr "type" "multi,multi,multi")
1178  (set_attr "length" "8,8,8")])
1179
1180 (define_insn "uminsi3"
1181   [(set (match_operand:SI 0 "register_operand" "=r,r")
1182         (umin:SI (match_operand:SI 1 "register_operand" "%0,0")
1183                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1184   ""
1185   "@
1186   {comclr|cmpclr},>> %2,%0,%%r0\;copy %2,%0
1187   {comiclr|cmpiclr},>> %2,%0,%%r0\;ldi %2,%0"
1188 [(set_attr "type" "multi,multi")
1189  (set_attr "length" "8,8")])
1190
1191 (define_insn "umindi3"
1192   [(set (match_operand:DI 0 "register_operand" "=r,r")
1193         (umin:DI (match_operand:DI 1 "register_operand" "%0,0")
1194                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1195   "TARGET_64BIT"
1196   "@
1197   cmpclr,*>> %2,%0,%%r0\;copy %2,%0
1198   cmpiclr,*>> %2,%0,%%r0\;ldi %2,%0"
1199 [(set_attr "type" "multi,multi")
1200  (set_attr "length" "8,8")])
1201
1202 (define_insn "smaxsi3"
1203   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1204         (smax:SI (match_operand:SI 1 "register_operand" "%0,0,r")
1205                  (match_operand:SI 2 "arith11_operand" "r,I,M")))]
1206   ""
1207   "@
1208   {comclr|cmpclr},< %2,%0,%%r0\;copy %2,%0
1209   {comiclr|cmpiclr},< %2,%0,%%r0\;ldi %2,%0
1210   {comclr|cmpclr},< %1,%r2,%0\;copy %1,%0"
1211 [(set_attr "type" "multi,multi,multi")
1212  (set_attr "length" "8,8,8")])
1213
1214 (define_insn "smaxdi3"
1215   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
1216         (smax:DI (match_operand:DI 1 "register_operand" "%0,0,r")
1217                  (match_operand:DI 2 "arith11_operand" "r,I,M")))]
1218   "TARGET_64BIT"
1219   "@
1220   cmpclr,*< %2,%0,%%r0\;copy %2,%0
1221   cmpiclr,*< %2,%0,%%r0\;ldi %2,%0
1222   cmpclr,*< %1,%r2,%0\;copy %1,%0"
1223 [(set_attr "type" "multi,multi,multi")
1224  (set_attr "length" "8,8,8")])
1225
1226 (define_insn "umaxsi3"
1227   [(set (match_operand:SI 0 "register_operand" "=r,r")
1228         (umax:SI (match_operand:SI 1 "register_operand" "%0,0")
1229                  (match_operand:SI 2 "arith11_operand" "r,I")))]
1230   ""
1231   "@
1232   {comclr|cmpclr},<< %2,%0,%%r0\;copy %2,%0
1233   {comiclr|cmpiclr},<< %2,%0,%%r0\;ldi %2,%0"
1234 [(set_attr "type" "multi,multi")
1235  (set_attr "length" "8,8")])
1236
1237 (define_insn "umaxdi3"
1238   [(set (match_operand:DI 0 "register_operand" "=r,r")
1239         (umax:DI (match_operand:DI 1 "register_operand" "%0,0")
1240                  (match_operand:DI 2 "arith11_operand" "r,I")))]
1241   "TARGET_64BIT"
1242   "@
1243   cmpclr,*<< %2,%0,%%r0\;copy %2,%0
1244   cmpiclr,*<< %2,%0,%%r0\;ldi %2,%0"
1245 [(set_attr "type" "multi,multi")
1246  (set_attr "length" "8,8")])
1247
1248 (define_insn "abssi2"
1249   [(set (match_operand:SI 0 "register_operand" "=r")
1250         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
1251   ""
1252   "or,>= %%r0,%1,%0\;subi 0,%0,%0"
1253   [(set_attr "type" "multi")
1254    (set_attr "length" "8")])
1255
1256 (define_insn "absdi2"
1257   [(set (match_operand:DI 0 "register_operand" "=r")
1258         (abs:DI (match_operand:DI 1 "register_operand" "r")))]
1259   "TARGET_64BIT"
1260   "or,*>= %%r0,%1,%0\;subi 0,%0,%0"
1261   [(set_attr "type" "multi")
1262    (set_attr "length" "8")])
1263
1264 ;;; Experimental conditional move patterns
1265
1266 (define_expand "movsicc"
1267   [(set (match_operand:SI 0 "register_operand" "")
1268         (if_then_else:SI
1269          (match_operator 1 "comparison_operator"
1270             [(match_dup 4)
1271              (match_dup 5)])
1272          (match_operand:SI 2 "reg_or_cint_move_operand" "")
1273          (match_operand:SI 3 "reg_or_cint_move_operand" "")))]
1274   ""
1275   "
1276 {
1277   enum rtx_code code = GET_CODE (operands[1]);
1278
1279   if (hppa_branch_type != CMP_SI)
1280     FAIL;
1281
1282   if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1283       || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1284     FAIL;
1285
1286   /* operands[1] is currently the result of compare_from_rtx.  We want to
1287      emit a compare of the original operands.  */
1288   operands[1] = gen_rtx_fmt_ee (code, SImode, hppa_compare_op0, hppa_compare_op1);
1289   operands[4] = hppa_compare_op0;
1290   operands[5] = hppa_compare_op1;
1291 }")
1292
1293 ;; We used to accept any register for op1.
1294 ;;
1295 ;; However, it loses sometimes because the compiler will end up using
1296 ;; different registers for op0 and op1 in some critical cases.  local-alloc
1297 ;; will  not tie op0 and op1 because op0 is used in multiple basic blocks.
1298 ;;
1299 ;; If/when global register allocation supports tying we should allow any
1300 ;; register for op1 again.
1301 (define_insn ""
1302   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1303         (if_then_else:SI
1304          (match_operator 2 "comparison_operator"
1305             [(match_operand:SI 3 "register_operand" "r,r,r,r")
1306              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI")])
1307          (match_operand:SI 1 "reg_or_cint_move_operand" "0,J,N,K")
1308          (const_int 0)))]
1309   ""
1310   "@
1311    {com%I4clr|cmp%I4clr},%S2 %4,%3,%%r0\;ldi 0,%0
1312    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldi %1,%0
1313    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;ldil L'%1,%0
1314    {com%I4clr|cmp%I4clr},%B2 %4,%3,%0\;{zdepi|depwi,z} %Z1,%0"
1315   [(set_attr "type" "multi,multi,multi,nullshift")
1316    (set_attr "length" "8,8,8,8")])
1317
1318 (define_insn ""
1319   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1320         (if_then_else:SI
1321          (match_operator 5 "comparison_operator"
1322             [(match_operand:SI 3 "register_operand" "r,r,r,r,r,r,r,r")
1323              (match_operand:SI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1324          (match_operand:SI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1325          (match_operand:SI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1326   ""
1327   "@
1328    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;copy %2,%0
1329    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldi %2,%0
1330    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;ldil L'%2,%0
1331    {com%I4clr|cmp%I4clr},%S5 %4,%3,%%r0\;{zdepi|depwi,z} %Z2,%0
1332    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;copy %1,%0
1333    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldi %1,%0
1334    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;ldil L'%1,%0
1335    {com%I4clr|cmp%I4clr},%B5 %4,%3,%%r0\;{zdepi|depwi,z} %Z1,%0"
1336   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1337    (set_attr "length" "8,8,8,8,8,8,8,8")])
1338
1339 (define_expand "movdicc"
1340   [(set (match_operand:DI 0 "register_operand" "")
1341         (if_then_else:DI
1342          (match_operator 1 "comparison_operator"
1343             [(match_dup 4)
1344              (match_dup 5)])
1345          (match_operand:DI 2 "reg_or_cint_move_operand" "")
1346          (match_operand:DI 3 "reg_or_cint_move_operand" "")))]
1347   "TARGET_64BIT"
1348   "
1349 {
1350   enum rtx_code code = GET_CODE (operands[1]);
1351
1352   if (hppa_branch_type != CMP_SI)
1353     FAIL;
1354
1355   if (GET_MODE (hppa_compare_op0) != GET_MODE (hppa_compare_op1)
1356       || GET_MODE (hppa_compare_op0) != GET_MODE (operands[0]))
1357     FAIL;
1358
1359   /* operands[1] is currently the result of compare_from_rtx.  We want to
1360      emit a compare of the original operands.  */
1361   operands[1] = gen_rtx_fmt_ee (code, DImode, hppa_compare_op0, hppa_compare_op1);
1362   operands[4] = hppa_compare_op0;
1363   operands[5] = hppa_compare_op1;
1364 }")
1365
1366 ; We need the first constraint alternative in order to avoid
1367 ; earlyclobbers on all other alternatives.
1368 (define_insn ""
1369   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r")
1370         (if_then_else:DI
1371          (match_operator 2 "comparison_operator"
1372             [(match_operand:DI 3 "register_operand" "r,r,r,r,r")
1373              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI")])
1374          (match_operand:DI 1 "reg_or_cint_move_operand" "0,r,J,N,K")
1375          (const_int 0)))]
1376   "TARGET_64BIT"
1377   "@
1378    cmp%I4clr,*%S2 %4,%3,%%r0\;ldi 0,%0
1379    cmp%I4clr,*%B2 %4,%3,%0\;copy %1,%0
1380    cmp%I4clr,*%B2 %4,%3,%0\;ldi %1,%0
1381    cmp%I4clr,*%B2 %4,%3,%0\;ldil L'%1,%0
1382    cmp%I4clr,*%B2 %4,%3,%0\;depdi,z %z1,%0"
1383   [(set_attr "type" "multi,multi,multi,multi,nullshift")
1384    (set_attr "length" "8,8,8,8,8")])
1385
1386 (define_insn ""
1387   [(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1388         (if_then_else:DI
1389          (match_operator 5 "comparison_operator"
1390             [(match_operand:DI 3 "register_operand" "r,r,r,r,r,r,r,r")
1391              (match_operand:DI 4 "arith11_operand" "rI,rI,rI,rI,rI,rI,rI,rI")])
1392          (match_operand:DI 1 "reg_or_cint_move_operand" "0,0,0,0,r,J,N,K")
1393          (match_operand:DI 2 "reg_or_cint_move_operand" "r,J,N,K,0,0,0,0")))]
1394   "TARGET_64BIT"
1395   "@
1396    cmp%I4clr,*%S5 %4,%3,%%r0\;copy %2,%0
1397    cmp%I4clr,*%S5 %4,%3,%%r0\;ldi %2,%0
1398    cmp%I4clr,*%S5 %4,%3,%%r0\;ldil L'%2,%0
1399    cmp%I4clr,*%S5 %4,%3,%%r0\;depdi,z %z2,%0
1400    cmp%I4clr,*%B5 %4,%3,%%r0\;copy %1,%0
1401    cmp%I4clr,*%B5 %4,%3,%%r0\;ldi %1,%0
1402    cmp%I4clr,*%B5 %4,%3,%%r0\;ldil L'%1,%0
1403    cmp%I4clr,*%B5 %4,%3,%%r0\;depdi,z %z1,%0"
1404   [(set_attr "type" "multi,multi,multi,nullshift,multi,multi,multi,nullshift")
1405    (set_attr "length" "8,8,8,8,8,8,8,8")])
1406
1407 ;; Conditional Branches
1408
1409 (define_expand "beq"
1410   [(set (pc)
1411         (if_then_else (eq (match_dup 1) (match_dup 2))
1412                       (label_ref (match_operand 0 "" ""))
1413                       (pc)))]
1414   ""
1415   "
1416 {
1417   if (hppa_branch_type != CMP_SI)
1418     {
1419       emit_insn (gen_cmp_fp (EQ, hppa_compare_op0, hppa_compare_op1));
1420       emit_bcond_fp (NE, operands[0]);
1421       DONE;
1422     }
1423   /* set up operands from compare.  */
1424   operands[1] = hppa_compare_op0;
1425   operands[2] = hppa_compare_op1;
1426   /* fall through and generate default code */
1427 }")
1428
1429 (define_expand "bne"
1430   [(set (pc)
1431         (if_then_else (ne (match_dup 1) (match_dup 2))
1432                       (label_ref (match_operand 0 "" ""))
1433                       (pc)))]
1434   ""
1435   "
1436 {
1437   if (hppa_branch_type != CMP_SI)
1438     {
1439       emit_insn (gen_cmp_fp (NE, hppa_compare_op0, hppa_compare_op1));
1440       emit_bcond_fp (NE, operands[0]);
1441       DONE;
1442     }
1443   operands[1] = hppa_compare_op0;
1444   operands[2] = hppa_compare_op1;
1445 }")
1446
1447 (define_expand "bgt"
1448   [(set (pc)
1449         (if_then_else (gt (match_dup 1) (match_dup 2))
1450                       (label_ref (match_operand 0 "" ""))
1451                       (pc)))]
1452   ""
1453   "
1454 {
1455   if (hppa_branch_type != CMP_SI)
1456     {
1457       emit_insn (gen_cmp_fp (GT, hppa_compare_op0, hppa_compare_op1));
1458       emit_bcond_fp (NE, operands[0]);
1459       DONE;
1460     }
1461   operands[1] = hppa_compare_op0;
1462   operands[2] = hppa_compare_op1;
1463 }")
1464
1465 (define_expand "blt"
1466   [(set (pc)
1467         (if_then_else (lt (match_dup 1) (match_dup 2))
1468                       (label_ref (match_operand 0 "" ""))
1469                       (pc)))]
1470   ""
1471   "
1472 {
1473   if (hppa_branch_type != CMP_SI)
1474     {
1475       emit_insn (gen_cmp_fp (LT, hppa_compare_op0, hppa_compare_op1));
1476       emit_bcond_fp (NE, operands[0]);
1477       DONE;
1478     }
1479   operands[1] = hppa_compare_op0;
1480   operands[2] = hppa_compare_op1;
1481 }")
1482
1483 (define_expand "bge"
1484   [(set (pc)
1485         (if_then_else (ge (match_dup 1) (match_dup 2))
1486                       (label_ref (match_operand 0 "" ""))
1487                       (pc)))]
1488   ""
1489   "
1490 {
1491   if (hppa_branch_type != CMP_SI)
1492     {
1493       emit_insn (gen_cmp_fp (GE, hppa_compare_op0, hppa_compare_op1));
1494       emit_bcond_fp (NE, operands[0]);
1495       DONE;
1496     }
1497   operands[1] = hppa_compare_op0;
1498   operands[2] = hppa_compare_op1;
1499 }")
1500
1501 (define_expand "ble"
1502   [(set (pc)
1503         (if_then_else (le (match_dup 1) (match_dup 2))
1504                       (label_ref (match_operand 0 "" ""))
1505                       (pc)))]
1506   ""
1507   "
1508 {
1509   if (hppa_branch_type != CMP_SI)
1510     {
1511       emit_insn (gen_cmp_fp (LE, hppa_compare_op0, hppa_compare_op1));
1512       emit_bcond_fp (NE, operands[0]);
1513       DONE;
1514     }
1515   operands[1] = hppa_compare_op0;
1516   operands[2] = hppa_compare_op1;
1517 }")
1518
1519 (define_expand "bgtu"
1520   [(set (pc)
1521         (if_then_else (gtu (match_dup 1) (match_dup 2))
1522                       (label_ref (match_operand 0 "" ""))
1523                       (pc)))]
1524   ""
1525   "
1526 {
1527   if (hppa_branch_type != CMP_SI)
1528     FAIL;
1529   operands[1] = hppa_compare_op0;
1530   operands[2] = hppa_compare_op1;
1531 }")
1532
1533 (define_expand "bltu"
1534   [(set (pc)
1535         (if_then_else (ltu (match_dup 1) (match_dup 2))
1536                       (label_ref (match_operand 0 "" ""))
1537                       (pc)))]
1538   ""
1539   "
1540 {
1541   if (hppa_branch_type != CMP_SI)
1542     FAIL;
1543   operands[1] = hppa_compare_op0;
1544   operands[2] = hppa_compare_op1;
1545 }")
1546
1547 (define_expand "bgeu"
1548   [(set (pc)
1549         (if_then_else (geu (match_dup 1) (match_dup 2))
1550                       (label_ref (match_operand 0 "" ""))
1551                       (pc)))]
1552   ""
1553   "
1554 {
1555   if (hppa_branch_type != CMP_SI)
1556     FAIL;
1557   operands[1] = hppa_compare_op0;
1558   operands[2] = hppa_compare_op1;
1559 }")
1560
1561 (define_expand "bleu"
1562   [(set (pc)
1563         (if_then_else (leu (match_dup 1) (match_dup 2))
1564                       (label_ref (match_operand 0 "" ""))
1565                       (pc)))]
1566   ""
1567   "
1568 {
1569   if (hppa_branch_type != CMP_SI)
1570     FAIL;
1571   operands[1] = hppa_compare_op0;
1572   operands[2] = hppa_compare_op1;
1573 }")
1574
1575 (define_expand "bltgt"
1576   [(set (pc)
1577         (if_then_else (ltgt (match_dup 1) (match_dup 2))
1578                       (label_ref (match_operand 0 "" ""))
1579                       (pc)))]
1580   ""
1581   "
1582 {
1583   if (hppa_branch_type == CMP_SI)
1584     FAIL;
1585   emit_insn (gen_cmp_fp (LTGT, hppa_compare_op0, hppa_compare_op1));
1586   emit_bcond_fp (NE, operands[0]);
1587   DONE;
1588 }")
1589
1590 (define_expand "bunle"
1591   [(set (pc)
1592         (if_then_else (unle (match_dup 1) (match_dup 2))
1593                       (label_ref (match_operand 0 "" ""))
1594                       (pc)))]
1595   ""
1596   "
1597 {
1598   if (hppa_branch_type == CMP_SI)
1599     FAIL;
1600   emit_insn (gen_cmp_fp (UNLE, hppa_compare_op0, hppa_compare_op1));
1601   emit_bcond_fp (NE, operands[0]);
1602   DONE;
1603 }")
1604
1605 (define_expand "bunlt"
1606   [(set (pc)
1607         (if_then_else (unlt (match_dup 1) (match_dup 2))
1608                       (label_ref (match_operand 0 "" ""))
1609                       (pc)))]
1610   ""
1611   "
1612 {
1613   if (hppa_branch_type == CMP_SI)
1614     FAIL;
1615   emit_insn (gen_cmp_fp (UNLT, hppa_compare_op0, hppa_compare_op1));
1616   emit_bcond_fp (NE, operands[0]);
1617   DONE;
1618 }")
1619
1620 (define_expand "bunge"
1621   [(set (pc)
1622         (if_then_else (unge (match_dup 1) (match_dup 2))
1623                       (label_ref (match_operand 0 "" ""))
1624                       (pc)))]
1625   ""
1626   "
1627 {
1628   if (hppa_branch_type == CMP_SI)
1629     FAIL;
1630   emit_insn (gen_cmp_fp (UNGE, hppa_compare_op0, hppa_compare_op1));
1631   emit_bcond_fp (NE, operands[0]);
1632   DONE;
1633 }")
1634
1635 (define_expand "bungt"
1636   [(set (pc)
1637         (if_then_else (ungt (match_dup 1) (match_dup 2))
1638                       (label_ref (match_operand 0 "" ""))
1639                       (pc)))]
1640   ""
1641   "
1642 {
1643   if (hppa_branch_type == CMP_SI)
1644     FAIL;
1645   emit_insn (gen_cmp_fp (UNGT, hppa_compare_op0, hppa_compare_op1));
1646   emit_bcond_fp (NE, operands[0]);
1647   DONE;
1648 }")
1649
1650 (define_expand "buneq"
1651   [(set (pc)
1652         (if_then_else (uneq (match_dup 1) (match_dup 2))
1653                       (label_ref (match_operand 0 "" ""))
1654                       (pc)))]
1655   ""
1656   "
1657 {
1658   if (hppa_branch_type == CMP_SI)
1659     FAIL;
1660   emit_insn (gen_cmp_fp (UNEQ, hppa_compare_op0, hppa_compare_op1));
1661   emit_bcond_fp (NE, operands[0]);
1662   DONE;
1663 }")
1664
1665 (define_expand "bunordered"
1666   [(set (pc)
1667         (if_then_else (unordered (match_dup 1) (match_dup 2))
1668                       (label_ref (match_operand 0 "" ""))
1669                       (pc)))]
1670   ""
1671   "
1672 {
1673   if (hppa_branch_type == CMP_SI)
1674     FAIL;
1675   emit_insn (gen_cmp_fp (UNORDERED, hppa_compare_op0, hppa_compare_op1));
1676   emit_bcond_fp (NE, operands[0]);
1677   DONE;
1678 }")
1679
1680 (define_expand "bordered"
1681   [(set (pc)
1682         (if_then_else (ordered (match_dup 1) (match_dup 2))
1683                       (label_ref (match_operand 0 "" ""))
1684                       (pc)))]
1685   ""
1686   "
1687 {
1688   if (hppa_branch_type == CMP_SI)
1689     FAIL;
1690   emit_insn (gen_cmp_fp (ORDERED, hppa_compare_op0, hppa_compare_op1));
1691   emit_bcond_fp (NE, operands[0]);
1692   DONE;
1693 }")
1694
1695 ;; Match the branch patterns.
1696
1697
1698 ;; Note a long backward conditional branch with an annulled delay slot
1699 ;; has a length of 12.
1700 (define_insn ""
1701   [(set (pc)
1702         (if_then_else
1703          (match_operator 3 "comparison_operator"
1704                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1705                           (match_operand:SI 2 "arith5_operand" "rL")])
1706          (label_ref (match_operand 0 "" ""))
1707          (pc)))]
1708   ""
1709   "*
1710 {
1711   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1712                          get_attr_length (insn), 0, insn);
1713 }"
1714 [(set_attr "type" "cbranch")
1715  (set (attr "length")
1716     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1717                (const_int 8184))
1718            (const_int 4)
1719            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1720                (const_int 262100))
1721            (const_int 8)
1722            (eq (symbol_ref "flag_pic") (const_int 0))
1723            (const_int 20)]
1724           (const_int 28)))])
1725
1726 ;; Match the negated branch.
1727
1728 (define_insn ""
1729   [(set (pc)
1730         (if_then_else
1731          (match_operator 3 "comparison_operator"
1732                          [(match_operand:SI 1 "reg_or_0_operand" "rM")
1733                           (match_operand:SI 2 "arith5_operand" "rL")])
1734          (pc)
1735          (label_ref (match_operand 0 "" ""))))]
1736   ""
1737   "*
1738 {
1739   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1740                          get_attr_length (insn), 1, insn);
1741 }"
1742 [(set_attr "type" "cbranch")
1743  (set (attr "length")
1744     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1745                (const_int 8184))
1746            (const_int 4)
1747            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1748                (const_int 262100))
1749            (const_int 8)
1750            (eq (symbol_ref "flag_pic") (const_int 0))
1751            (const_int 20)]
1752           (const_int 28)))])
1753
1754 (define_insn ""
1755   [(set (pc)
1756         (if_then_else
1757          (match_operator 3 "comparison_operator"
1758                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1759                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1760          (label_ref (match_operand 0 "" ""))
1761          (pc)))]
1762   "TARGET_64BIT"
1763   "*
1764 {
1765   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1766                          get_attr_length (insn), 0, insn);
1767 }"
1768 [(set_attr "type" "cbranch")
1769  (set (attr "length")
1770     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1771                (const_int 8184))
1772            (const_int 4)
1773            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1774                (const_int 262100))
1775            (const_int 8)
1776            (eq (symbol_ref "flag_pic") (const_int 0))
1777            (const_int 20)]
1778           (const_int 28)))])
1779
1780 ;; Match the negated branch.
1781
1782 (define_insn ""
1783   [(set (pc)
1784         (if_then_else
1785          (match_operator 3 "comparison_operator"
1786                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1787                           (match_operand:DI 2 "reg_or_0_operand" "rM")])
1788          (pc)
1789          (label_ref (match_operand 0 "" ""))))]
1790   "TARGET_64BIT"
1791   "*
1792 {
1793   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1794                          get_attr_length (insn), 1, insn);
1795 }"
1796 [(set_attr "type" "cbranch")
1797  (set (attr "length")
1798     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1799                (const_int 8184))
1800            (const_int 4)
1801            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1802                (const_int 262100))
1803            (const_int 8)
1804            (eq (symbol_ref "flag_pic") (const_int 0))
1805            (const_int 20)]
1806           (const_int 28)))])
1807 (define_insn ""
1808   [(set (pc)
1809         (if_then_else
1810          (match_operator 3 "cmpib_comparison_operator"
1811                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1812                           (match_operand:DI 2 "arith5_operand" "rL")])
1813          (label_ref (match_operand 0 "" ""))
1814          (pc)))]
1815   "TARGET_64BIT"
1816   "*
1817 {
1818   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1819                          get_attr_length (insn), 0, insn);
1820 }"
1821 [(set_attr "type" "cbranch")
1822  (set (attr "length")
1823     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1824                (const_int 8184))
1825            (const_int 4)
1826            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1827                (const_int 262100))
1828            (const_int 8)
1829            (eq (symbol_ref "flag_pic") (const_int 0))
1830            (const_int 20)]
1831           (const_int 28)))])
1832
1833 ;; Match the negated branch.
1834
1835 (define_insn ""
1836   [(set (pc)
1837         (if_then_else
1838          (match_operator 3 "cmpib_comparison_operator"
1839                          [(match_operand:DI 1 "reg_or_0_operand" "rM")
1840                           (match_operand:DI 2 "arith5_operand" "rL")])
1841          (pc)
1842          (label_ref (match_operand 0 "" ""))))]
1843   "TARGET_64BIT"
1844   "*
1845 {
1846   return output_cbranch (operands, INSN_ANNULLED_BRANCH_P (insn),
1847                          get_attr_length (insn), 1, insn);
1848 }"
1849 [(set_attr "type" "cbranch")
1850  (set (attr "length")
1851     (cond [(lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1852                (const_int 8184))
1853            (const_int 4)
1854            (lt (abs (minus (match_dup 0) (plus (pc) (const_int 8))))
1855                (const_int 262100))
1856            (const_int 8)
1857            (eq (symbol_ref "flag_pic") (const_int 0))
1858            (const_int 20)]
1859           (const_int 28)))])
1860
1861 ;; Branch on Bit patterns.
1862 (define_insn ""
1863   [(set (pc)
1864         (if_then_else
1865          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1866                               (const_int 1)
1867                               (match_operand:SI 1 "uint5_operand" ""))
1868              (const_int 0))
1869          (label_ref (match_operand 2 "" ""))
1870          (pc)))]
1871   ""
1872   "*
1873 {
1874   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1875                          get_attr_length (insn), 0, insn, 0);
1876 }"
1877 [(set_attr "type" "cbranch")
1878  (set (attr "length")
1879     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1880                       (const_int 8184))
1881            (const_int 4)
1882            (const_int 8)))])
1883
1884 (define_insn ""
1885   [(set (pc)
1886         (if_then_else
1887          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1888                               (const_int 1)
1889                               (match_operand:DI 1 "uint32_operand" ""))
1890              (const_int 0))
1891          (label_ref (match_operand 2 "" ""))
1892          (pc)))]
1893   "TARGET_64BIT"
1894   "*
1895 {
1896   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1897                          get_attr_length (insn), 0, insn, 0);
1898 }"
1899 [(set_attr "type" "cbranch")
1900  (set (attr "length")
1901     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1902                       (const_int 8184))
1903            (const_int 4)
1904            (const_int 8)))])
1905
1906 (define_insn ""
1907   [(set (pc)
1908         (if_then_else
1909          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1910                               (const_int 1)
1911                               (match_operand:SI 1 "uint5_operand" ""))
1912              (const_int 0))
1913          (pc)
1914          (label_ref (match_operand 2 "" ""))))]
1915   ""
1916   "*
1917 {
1918   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1919                          get_attr_length (insn), 1, insn, 0);
1920 }"
1921 [(set_attr "type" "cbranch")
1922  (set (attr "length")
1923     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1924                       (const_int 8184))
1925            (const_int 4)
1926            (const_int 8)))])
1927
1928 (define_insn ""
1929   [(set (pc)
1930         (if_then_else
1931          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1932                               (const_int 1)
1933                               (match_operand:DI 1 "uint32_operand" ""))
1934              (const_int 0))
1935          (pc)
1936          (label_ref (match_operand 2 "" ""))))]
1937   "TARGET_64BIT"
1938   "*
1939 {
1940   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1941                          get_attr_length (insn), 1, insn, 0);
1942 }"
1943 [(set_attr "type" "cbranch")
1944  (set (attr "length")
1945     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1946                       (const_int 8184))
1947            (const_int 4)
1948            (const_int 8)))])
1949
1950 (define_insn ""
1951   [(set (pc)
1952         (if_then_else
1953          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1954                               (const_int 1)
1955                               (match_operand:SI 1 "uint5_operand" ""))
1956              (const_int 0))
1957          (label_ref (match_operand 2 "" ""))
1958          (pc)))]
1959   ""
1960   "*
1961 {
1962   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1963                          get_attr_length (insn), 0, insn, 1);
1964 }"
1965 [(set_attr "type" "cbranch")
1966  (set (attr "length")
1967     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1968                       (const_int 8184))
1969            (const_int 4)
1970            (const_int 8)))])
1971
1972 (define_insn ""
1973   [(set (pc)
1974         (if_then_else
1975          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
1976                               (const_int 1)
1977                               (match_operand:DI 1 "uint32_operand" ""))
1978              (const_int 0))
1979          (label_ref (match_operand 2 "" ""))
1980          (pc)))]
1981   "TARGET_64BIT"
1982   "*
1983 {
1984   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
1985                          get_attr_length (insn), 0, insn, 1);
1986 }"
1987 [(set_attr "type" "cbranch")
1988  (set (attr "length")
1989     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
1990                       (const_int 8184))
1991            (const_int 4)
1992            (const_int 8)))])
1993
1994 (define_insn ""
1995   [(set (pc)
1996         (if_then_else
1997          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1998                               (const_int 1)
1999                               (match_operand:SI 1 "uint5_operand" ""))
2000              (const_int 0))
2001          (pc)
2002          (label_ref (match_operand 2 "" ""))))]
2003   ""
2004   "*
2005 {
2006   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
2007                          get_attr_length (insn), 1, insn, 1);
2008 }"
2009 [(set_attr "type" "cbranch")
2010  (set (attr "length")
2011     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2012                       (const_int 8184))
2013            (const_int 4)
2014            (const_int 8)))])
2015
2016 (define_insn ""
2017   [(set (pc)
2018         (if_then_else
2019          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2020                               (const_int 1)
2021                               (match_operand:DI 1 "uint32_operand" ""))
2022              (const_int 0))
2023          (pc)
2024          (label_ref (match_operand 2 "" ""))))]
2025   "TARGET_64BIT"
2026   "*
2027 {
2028   return output_bb (operands, INSN_ANNULLED_BRANCH_P (insn),
2029                          get_attr_length (insn), 1, insn, 1);
2030 }"
2031 [(set_attr "type" "cbranch")
2032  (set (attr "length")
2033     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2034                       (const_int 8184))
2035            (const_int 4)
2036            (const_int 8)))])
2037
2038 ;; Branch on Variable Bit patterns.
2039 (define_insn ""
2040   [(set (pc)
2041         (if_then_else
2042          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2043                               (const_int 1)
2044                               (match_operand:SI 1 "register_operand" "q"))
2045              (const_int 0))
2046          (label_ref (match_operand 2 "" ""))
2047          (pc)))]
2048   ""
2049   "*
2050 {
2051   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2052                      get_attr_length (insn), 0, insn, 0);
2053 }"
2054 [(set_attr "type" "cbranch")
2055  (set (attr "length")
2056     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2057                       (const_int 8184))
2058            (const_int 4)
2059            (const_int 8)))])
2060
2061 (define_insn ""
2062   [(set (pc)
2063         (if_then_else
2064          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2065                               (const_int 1)
2066                               (match_operand:DI 1 "register_operand" "q"))
2067              (const_int 0))
2068          (label_ref (match_operand 2 "" ""))
2069          (pc)))]
2070   "TARGET_64BIT"
2071   "*
2072 {
2073   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2074                      get_attr_length (insn), 0, insn, 0);
2075 }"
2076 [(set_attr "type" "cbranch")
2077  (set (attr "length")
2078     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2079                       (const_int 8184))
2080            (const_int 4)
2081            (const_int 8)))])
2082
2083 (define_insn ""
2084   [(set (pc)
2085         (if_then_else
2086          (ne (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2087                               (const_int 1)
2088                               (match_operand:SI 1 "register_operand" "q"))
2089              (const_int 0))
2090          (pc)
2091          (label_ref (match_operand 2 "" ""))))]
2092   ""
2093   "*
2094 {
2095   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2096                      get_attr_length (insn), 1, insn, 0);
2097 }"
2098 [(set_attr "type" "cbranch")
2099  (set (attr "length")
2100     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2101                       (const_int 8184))
2102            (const_int 4)
2103            (const_int 8)))])
2104
2105 (define_insn ""
2106   [(set (pc)
2107         (if_then_else
2108          (ne (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2109                               (const_int 1)
2110                               (match_operand:DI 1 "register_operand" "q"))
2111              (const_int 0))
2112          (pc)
2113          (label_ref (match_operand 2 "" ""))))]
2114   "TARGET_64BIT"
2115   "*
2116 {
2117   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2118                      get_attr_length (insn), 1, insn, 0);
2119 }"
2120 [(set_attr "type" "cbranch")
2121  (set (attr "length")
2122     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2123                       (const_int 8184))
2124            (const_int 4)
2125            (const_int 8)))])
2126
2127 (define_insn ""
2128   [(set (pc)
2129         (if_then_else
2130          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2131                               (const_int 1)
2132                               (match_operand:SI 1 "register_operand" "q"))
2133              (const_int 0))
2134          (label_ref (match_operand 2 "" ""))
2135          (pc)))]
2136   ""
2137   "*
2138 {
2139   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2140                      get_attr_length (insn), 0, insn, 1);
2141 }"
2142 [(set_attr "type" "cbranch")
2143  (set (attr "length")
2144     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2145                       (const_int 8184))
2146            (const_int 4)
2147            (const_int 8)))])
2148
2149 (define_insn ""
2150   [(set (pc)
2151         (if_then_else
2152          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2153                               (const_int 1)
2154                               (match_operand:DI 1 "register_operand" "q"))
2155              (const_int 0))
2156          (label_ref (match_operand 2 "" ""))
2157          (pc)))]
2158   "TARGET_64BIT"
2159   "*
2160 {
2161   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2162                      get_attr_length (insn), 0, insn, 1);
2163 }"
2164 [(set_attr "type" "cbranch")
2165  (set (attr "length")
2166     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2167                       (const_int 8184))
2168            (const_int 4)
2169            (const_int 8)))])
2170
2171 (define_insn ""
2172   [(set (pc)
2173         (if_then_else
2174          (eq (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
2175                               (const_int 1)
2176                               (match_operand:SI 1 "register_operand" "q"))
2177              (const_int 0))
2178          (pc)
2179          (label_ref (match_operand 2 "" ""))))]
2180   ""
2181   "*
2182 {
2183   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2184                      get_attr_length (insn), 1, insn, 1);
2185 }"
2186 [(set_attr "type" "cbranch")
2187  (set (attr "length")
2188     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2189                       (const_int 8184))
2190            (const_int 4)
2191            (const_int 8)))])
2192
2193 (define_insn ""
2194   [(set (pc)
2195         (if_then_else
2196          (eq (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
2197                               (const_int 1)
2198                               (match_operand:DI 1 "register_operand" "q"))
2199              (const_int 0))
2200          (pc)
2201          (label_ref (match_operand 2 "" ""))))]
2202   "TARGET_64BIT"
2203   "*
2204 {
2205   return output_bvb (operands, INSN_ANNULLED_BRANCH_P (insn),
2206                      get_attr_length (insn), 1, insn, 1);
2207 }"
2208 [(set_attr "type" "cbranch")
2209  (set (attr "length")
2210     (if_then_else (lt (abs (minus (match_dup 2) (plus (pc) (const_int 8))))
2211                       (const_int 8184))
2212            (const_int 4)
2213            (const_int 8)))])
2214
2215 ;; Floating point branches
2216 (define_insn ""
2217   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2218                            (label_ref (match_operand 0 "" ""))
2219                            (pc)))]
2220   "! TARGET_SOFT_FLOAT"
2221   "*
2222 {
2223   if (INSN_ANNULLED_BRANCH_P (insn))
2224     return \"ftest\;b,n %0\";
2225   else
2226     return \"ftest\;b%* %0\";
2227 }"
2228   [(set_attr "type" "fbranch")
2229    (set_attr "length" "8")])
2230
2231 (define_insn ""
2232   [(set (pc) (if_then_else (ne (reg:CCFP 0) (const_int 0))
2233                            (pc)
2234                            (label_ref (match_operand 0 "" ""))))]
2235   "! TARGET_SOFT_FLOAT"
2236   "*
2237 {
2238   if (INSN_ANNULLED_BRANCH_P (insn))
2239     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b,n %0\";
2240   else
2241     return \"ftest\;add,tr %%r0,%%r0,%%r0\;b%* %0\";
2242 }"
2243   [(set_attr "type" "fbranch")
2244    (set_attr "length" "12")])
2245
2246 ;; Move instructions
2247
2248 (define_expand "movsi"
2249   [(set (match_operand:SI 0 "general_operand" "")
2250         (match_operand:SI 1 "general_operand" ""))]
2251   ""
2252   "
2253 {
2254   if (emit_move_sequence (operands, SImode, 0))
2255     DONE;
2256 }")
2257
2258 ;; Handle SImode input reloads requiring %r1 as a scratch register.
2259 (define_expand "reload_insi_r1"
2260   [(set (match_operand:SI 0 "register_operand" "=Z")
2261         (match_operand:SI 1 "non_hard_reg_operand" ""))
2262    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
2263   ""
2264   "
2265 {
2266   if (emit_move_sequence (operands, SImode, operands[2]))
2267     DONE;
2268
2269   /* We don't want the clobber emitted, so handle this ourselves.  */
2270   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2271   DONE;
2272 }")
2273
2274 ;; Handle SImode input reloads requiring a general register as a
2275 ;; scratch register.
2276 (define_expand "reload_insi"
2277   [(set (match_operand:SI 0 "register_operand" "=Z")
2278         (match_operand:SI 1 "non_hard_reg_operand" ""))
2279    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2280   ""
2281   "
2282 {
2283   if (emit_move_sequence (operands, SImode, operands[2]))
2284     DONE;
2285
2286   /* We don't want the clobber emitted, so handle this ourselves.  */
2287   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2288   DONE;
2289 }")
2290
2291 ;; Handle SImode output reloads requiring a general register as a
2292 ;; scratch register.
2293 (define_expand "reload_outsi"
2294   [(set (match_operand:SI 0 "non_hard_reg_operand" "")
2295         (match_operand:SI 1  "register_operand" "Z"))
2296    (clobber (match_operand:SI 2 "register_operand" "=&r"))]
2297   ""
2298   "
2299 {
2300   if (emit_move_sequence (operands, SImode, operands[2]))
2301     DONE;
2302
2303   /* We don't want the clobber emitted, so handle this ourselves.  */
2304   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
2305   DONE;
2306 }")
2307
2308 (define_insn ""
2309   [(set (match_operand:SI 0 "move_dest_operand"
2310                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T,r,f")
2311         (match_operand:SI 1 "move_src_operand"
2312                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f,f,r"))]
2313   "(register_operand (operands[0], SImode)
2314     || reg_or_0_operand (operands[1], SImode))
2315    && !TARGET_SOFT_FLOAT
2316    && !TARGET_64BIT"
2317   "@
2318    ldw RT'%A1,%0
2319    copy %1,%0
2320    ldi %1,%0
2321    ldil L'%1,%0
2322    {zdepi|depwi,z} %Z1,%0
2323    ldw%M1 %1,%0
2324    stw%M0 %r1,%0
2325    mtsar %r1
2326    {mfctl|mfctl,w} %%sar,%0
2327    fcpy,sgl %f1,%0
2328    fldw%F1 %1,%0
2329    fstw%F0 %1,%0
2330    {fstws|fstw} %1,-16(%%sp)\n\t{ldws|ldw} -16(%%sp),%0
2331    {stws|stw} %1,-16(%%sp)\n\t{fldws|fldw} -16(%%sp),%0"
2332   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore,move,move")
2333    (set_attr "pa_combine_type" "addmove")
2334    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,8,8")])
2335
2336 (define_insn ""
2337   [(set (match_operand:SI 0 "move_dest_operand"
2338                           "=r,r,r,r,r,r,Q,!*q,!r,!*f,*f,T")
2339         (match_operand:SI 1 "move_src_operand"
2340                           "A,r,J,N,K,RQ,rM,!rM,!*q,!*fM,RT,*f"))]
2341   "(register_operand (operands[0], SImode)
2342     || reg_or_0_operand (operands[1], SImode))
2343    && !TARGET_SOFT_FLOAT
2344    && TARGET_64BIT"
2345   "@
2346    ldw RT'%A1,%0
2347    copy %1,%0
2348    ldi %1,%0
2349    ldil L'%1,%0
2350    {zdepi|depwi,z} %Z1,%0
2351    ldw%M1 %1,%0
2352    stw%M0 %r1,%0
2353    mtsar %r1
2354    {mfctl|mfctl,w} %%sar,%0
2355    fcpy,sgl %f1,%0
2356    fldw%F1 %1,%0
2357    fstw%F0 %1,%0"
2358   [(set_attr "type" "load,move,move,move,shift,load,store,move,move,fpalu,fpload,fpstore")
2359    (set_attr "pa_combine_type" "addmove")
2360    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4")])
2361
2362 (define_insn ""
2363   [(set (match_operand:SI 0 "indexed_memory_operand" "=R")
2364         (match_operand:SI 1 "register_operand" "f"))]
2365   "!TARGET_SOFT_FLOAT
2366    && !TARGET_DISABLE_INDEXING
2367    && reload_completed"
2368   "fstw%F0 %1,%0"
2369   [(set_attr "type" "fpstore")
2370    (set_attr "pa_combine_type" "addmove")
2371    (set_attr "length" "4")])
2372
2373 ; Rewrite RTL using an indexed store.  This will allow the insn that
2374 ; computes the address to be deleted if the register it sets is dead.
2375 (define_peephole2
2376   [(set (match_operand:SI 0 "register_operand" "")
2377         (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
2378                           (const_int 4))
2379                  (match_operand:SI 2 "register_operand" "")))
2380    (set (mem:SI (match_dup 0))
2381         (match_operand:SI 3 "register_operand" ""))]
2382   "!TARGET_SOFT_FLOAT
2383    && !TARGET_DISABLE_INDEXING
2384    && REG_OK_FOR_BASE_P (operands[2])
2385    && FP_REGNO_P (REGNO (operands[3]))"
2386   [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2387         (match_dup 3))
2388    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
2389                                (match_dup 2)))]
2390   "")
2391
2392 (define_peephole2
2393   [(set (match_operand:SI 0 "register_operand" "")
2394         (plus:SI (match_operand:SI 2 "register_operand" "")
2395                  (mult:SI (match_operand:SI 1 "register_operand" "")
2396                           (const_int 4))))
2397    (set (mem:SI (match_dup 0))
2398         (match_operand:SI 3 "register_operand" ""))]
2399   "!TARGET_SOFT_FLOAT
2400    && !TARGET_DISABLE_INDEXING
2401    && REG_OK_FOR_BASE_P (operands[2])
2402    && FP_REGNO_P (REGNO (operands[3]))"
2403   [(set (mem:SI (plus:SI (mult:SI (match_dup 1) (const_int 4)) (match_dup 2)))
2404         (match_dup 3))
2405    (set (match_dup 0) (plus:SI (mult:SI (match_dup 1) (const_int 4))
2406                                (match_dup 2)))]
2407   "")
2408
2409 (define_peephole2
2410   [(set (match_operand:DI 0 "register_operand" "")
2411         (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
2412                           (const_int 4))
2413                  (match_operand:DI 2 "register_operand" "")))
2414    (set (mem:SI (match_dup 0))
2415         (match_operand:SI 3 "register_operand" ""))]
2416   "!TARGET_SOFT_FLOAT
2417    && !TARGET_DISABLE_INDEXING
2418    && TARGET_64BIT
2419    && REG_OK_FOR_BASE_P (operands[2])
2420    && FP_REGNO_P (REGNO (operands[3]))"
2421   [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2422         (match_dup 3))
2423    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
2424                                (match_dup 2)))]
2425   "")
2426
2427 (define_peephole2
2428   [(set (match_operand:DI 0 "register_operand" "")
2429         (plus:DI (match_operand:DI 2 "register_operand" "")
2430                  (mult:DI (match_operand:DI 1 "register_operand" "")
2431                           (const_int 4))))
2432    (set (mem:SI (match_dup 0))
2433         (match_operand:SI 3 "register_operand" ""))]
2434   "!TARGET_SOFT_FLOAT
2435    && !TARGET_DISABLE_INDEXING
2436    && TARGET_64BIT
2437    && REG_OK_FOR_BASE_P (operands[2])
2438    && FP_REGNO_P (REGNO (operands[3]))"
2439   [(set (mem:SI (plus:DI (mult:DI (match_dup 1) (const_int 4)) (match_dup 2)))
2440         (match_dup 3))
2441    (set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (const_int 4))
2442                                (match_dup 2)))]
2443   "")
2444
2445 (define_peephole2
2446   [(set (match_operand:SI 0 "register_operand" "")
2447         (plus:SI (match_operand:SI 1 "register_operand" "")
2448                  (match_operand:SI 2 "register_operand" "")))
2449    (set (mem:SI (match_dup 0))
2450         (match_operand:SI 3 "register_operand" ""))]
2451   "!TARGET_SOFT_FLOAT
2452    && !TARGET_DISABLE_INDEXING
2453    && TARGET_NO_SPACE_REGS
2454    && REG_OK_FOR_INDEX_P (operands[1])
2455    && REG_OK_FOR_BASE_P (operands[2])
2456    && FP_REGNO_P (REGNO (operands[3]))"
2457   [(set (mem:SI (plus:SI (match_dup 1) (match_dup 2)))
2458         (match_dup 3))
2459    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2460   "")
2461
2462 (define_peephole2
2463   [(set (match_operand:SI 0 "register_operand" "")
2464         (plus:SI (match_operand:SI 1 "register_operand" "")
2465                  (match_operand:SI 2 "register_operand" "")))
2466    (set (mem:SI (match_dup 0))
2467         (match_operand:SI 3 "register_operand" ""))]
2468   "!TARGET_SOFT_FLOAT
2469    && !TARGET_DISABLE_INDEXING
2470    && TARGET_NO_SPACE_REGS
2471    && REG_OK_FOR_BASE_P (operands[1])
2472    && REG_OK_FOR_INDEX_P (operands[2])
2473    && FP_REGNO_P (REGNO (operands[3]))"
2474   [(set (mem:SI (plus:SI (match_dup 2) (match_dup 1)))
2475         (match_dup 3))
2476    (set (match_dup 0) (plus:SI (match_dup 2) (match_dup 1)))]
2477   "")
2478
2479 (define_peephole2
2480   [(set (match_operand:DI 0 "register_operand" "")
2481         (plus:DI (match_operand:DI 1 "register_operand" "")
2482                  (match_operand:DI 2 "register_operand" "")))
2483    (set (mem:SI (match_dup 0))
2484         (match_operand:SI 3 "register_operand" ""))]
2485   "!TARGET_SOFT_FLOAT
2486    && !TARGET_DISABLE_INDEXING
2487    && TARGET_64BIT
2488    && TARGET_NO_SPACE_REGS
2489    && REG_OK_FOR_INDEX_P (operands[1])
2490    && REG_OK_FOR_BASE_P (operands[2])
2491    && FP_REGNO_P (REGNO (operands[3]))"
2492   [(set (mem:SI (plus:DI (match_dup 1) (match_dup 2)))
2493         (match_dup 3))
2494    (set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
2495   "")
2496
2497 (define_peephole2
2498   [(set (match_operand:DI 0 "register_operand" "")
2499         (plus:DI (match_operand:DI 1 "register_operand" "")
2500                  (match_operand:DI 2 "register_operand" "")))
2501    (set (mem:SI (match_dup 0))
2502         (match_operand:SI 3 "register_operand" ""))]
2503   "!TARGET_SOFT_FLOAT
2504    && !TARGET_DISABLE_INDEXING
2505    && TARGET_64BIT
2506    && TARGET_NO_SPACE_REGS
2507    && REG_OK_FOR_BASE_P (operands[1])
2508    && REG_OK_FOR_INDEX_P (operands[2])
2509    && FP_REGNO_P (REGNO (operands[3]))"
2510   [(set (mem:SI (plus:DI (match_dup 2) (match_dup 1)))
2511         (match_dup 3))
2512    (set (match_dup 0) (plus:DI (match_dup 2) (match_dup 1)))]
2513   "")
2514
2515 (define_insn ""
2516   [(set (match_operand:SI 0 "move_dest_operand"
2517                           "=r,r,r,r,r,r,Q,!*q,!r")
2518         (match_operand:SI 1 "move_src_operand"
2519                           "A,r,J,N,K,RQ,rM,!rM,!*q"))]
2520   "(register_operand (operands[0], SImode)
2521     || reg_or_0_operand (operands[1], SImode))
2522    && TARGET_SOFT_FLOAT"
2523   "@
2524    ldw RT'%A1,%0
2525    copy %1,%0
2526    ldi %1,%0
2527    ldil L'%1,%0
2528    {zdepi|depwi,z} %Z1,%0
2529    ldw%M1 %1,%0
2530    stw%M0 %r1,%0
2531    mtsar %r1
2532    {mfctl|mfctl,w} %%sar,%0"
2533   [(set_attr "type" "load,move,move,move,move,load,store,move,move")
2534    (set_attr "pa_combine_type" "addmove")
2535    (set_attr "length" "4,4,4,4,4,4,4,4,4")])
2536
2537 ;; Load or store with base-register modification.
2538 (define_insn ""
2539   [(set (match_operand:SI 0 "register_operand" "=r")
2540         (mem:SI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2541                          (match_operand:DI 2 "int5_operand" "L"))))
2542    (set (match_dup 1)
2543         (plus:DI (match_dup 1) (match_dup 2)))]
2544   "TARGET_64BIT"
2545   "ldw,mb %2(%1),%0"
2546   [(set_attr "type" "load")
2547    (set_attr "length" "4")])
2548
2549 ; And a zero extended variant.
2550 (define_insn ""
2551   [(set (match_operand:DI 0 "register_operand" "=r")
2552         (zero_extend:DI (mem:SI
2553                           (plus:DI
2554                             (match_operand:DI 1 "register_operand" "+r")
2555                             (match_operand:DI 2 "int5_operand" "L")))))
2556    (set (match_dup 1)
2557         (plus:DI (match_dup 1) (match_dup 2)))]
2558   "TARGET_64BIT"
2559   "ldw,mb %2(%1),%0"
2560   [(set_attr "type" "load")
2561    (set_attr "length" "4")])
2562
2563 (define_expand "pre_load"
2564   [(parallel [(set (match_operand:SI 0 "register_operand" "")
2565               (mem (plus (match_operand 1 "register_operand" "")
2566                                (match_operand 2 "pre_cint_operand" ""))))
2567               (set (match_dup 1)
2568                    (plus (match_dup 1) (match_dup 2)))])]
2569   ""
2570   "
2571 {
2572   if (TARGET_64BIT)
2573     {
2574       emit_insn (gen_pre_ldd (operands[0], operands[1], operands[2]));
2575       DONE;
2576     }
2577   emit_insn (gen_pre_ldw (operands[0], operands[1], operands[2]));
2578   DONE;
2579 }")
2580
2581 (define_insn "pre_ldw"
2582   [(set (match_operand:SI 0 "register_operand" "=r")
2583         (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2584                          (match_operand:SI 2 "pre_cint_operand" ""))))
2585    (set (match_dup 1)
2586         (plus:SI (match_dup 1) (match_dup 2)))]
2587   ""
2588   "*
2589 {
2590   if (INTVAL (operands[2]) < 0)
2591     return \"{ldwm|ldw,mb} %2(%1),%0\";
2592   return \"{ldws|ldw},mb %2(%1),%0\";
2593 }"
2594   [(set_attr "type" "load")
2595    (set_attr "length" "4")])
2596
2597 (define_insn "pre_ldd"
2598   [(set (match_operand:DI 0 "register_operand" "=r")
2599         (mem:DI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2600                          (match_operand:DI 2 "pre_cint_operand" ""))))
2601    (set (match_dup 1)
2602         (plus:DI (match_dup 1) (match_dup 2)))]
2603   "TARGET_64BIT"
2604   "ldd,mb %2(%1),%0"
2605   [(set_attr "type" "load")
2606    (set_attr "length" "4")])
2607
2608 (define_insn ""
2609   [(set (mem:SI (plus:SI (match_operand:SI 0 "register_operand" "+r")
2610                          (match_operand:SI 1 "pre_cint_operand" "")))
2611         (match_operand:SI 2 "reg_or_0_operand" "rM"))
2612    (set (match_dup 0)
2613         (plus:SI (match_dup 0) (match_dup 1)))]
2614   ""
2615   "*
2616 {
2617   if (INTVAL (operands[1]) < 0)
2618     return \"{stwm|stw,mb} %r2,%1(%0)\";
2619   return \"{stws|stw},mb %r2,%1(%0)\";
2620 }"
2621   [(set_attr "type" "store")
2622    (set_attr "length" "4")])
2623
2624 (define_insn ""
2625   [(set (match_operand:SI 0 "register_operand" "=r")
2626         (mem:SI (match_operand:SI 1 "register_operand" "+r")))
2627    (set (match_dup 1)
2628         (plus:SI (match_dup 1)
2629                  (match_operand:SI 2 "post_cint_operand" "")))]
2630   ""
2631   "*
2632 {
2633   if (INTVAL (operands[2]) > 0)
2634     return \"{ldwm|ldw,ma} %2(%1),%0\";
2635   return \"{ldws|ldw},ma %2(%1),%0\";
2636 }"
2637   [(set_attr "type" "load")
2638    (set_attr "length" "4")])
2639
2640 (define_expand "post_store"
2641   [(parallel [(set (mem (match_operand 0 "register_operand" ""))
2642                    (match_operand 1 "reg_or_0_operand" ""))
2643               (set (match_dup 0)
2644                    (plus (match_dup 0)
2645                          (match_operand 2 "post_cint_operand" "")))])]
2646   ""
2647   "
2648 {
2649   if (TARGET_64BIT)
2650     {
2651       emit_insn (gen_post_std (operands[0], operands[1], operands[2]));
2652       DONE;
2653     }
2654   emit_insn (gen_post_stw (operands[0], operands[1], operands[2]));
2655   DONE;
2656 }")
2657
2658 (define_insn "post_stw"
2659   [(set (mem:SI (match_operand:SI 0 "register_operand" "+r"))
2660         (match_operand:SI 1 "reg_or_0_operand" "rM"))
2661    (set (match_dup 0)
2662         (plus:SI (match_dup 0)
2663                  (match_operand:SI 2 "post_cint_operand" "")))]
2664   ""
2665   "*
2666 {
2667   if (INTVAL (operands[2]) > 0)
2668     return \"{stwm|stw,ma} %r1,%2(%0)\";
2669   return \"{stws|stw},ma %r1,%2(%0)\";
2670 }"
2671   [(set_attr "type" "store")
2672    (set_attr "length" "4")])
2673
2674 (define_insn "post_std"
2675   [(set (mem:DI (match_operand:DI 0 "register_operand" "+r"))
2676         (match_operand:DI 1 "reg_or_0_operand" "rM"))
2677    (set (match_dup 0)
2678         (plus:DI (match_dup 0)
2679                  (match_operand:DI 2 "post_cint_operand" "")))]
2680   "TARGET_64BIT"
2681   "std,ma %r1,%2(%0)"
2682   [(set_attr "type" "store")
2683    (set_attr "length" "4")])
2684
2685 ;; For loading the address of a label while generating PIC code.
2686 ;; Note since this pattern can be created at reload time (via movsi), all
2687 ;; the same rules for movsi apply here.  (no new pseudos, no temporaries).
2688 (define_insn ""
2689   [(set (match_operand 0 "pmode_register_operand" "=a")
2690         (match_operand 1 "pic_label_operand" ""))]
2691   "TARGET_PA_20"
2692   "*
2693 {
2694   rtx xoperands[3];
2695
2696   xoperands[0] = operands[0];
2697   xoperands[1] = operands[1];
2698   xoperands[2] = gen_label_rtx ();
2699
2700   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2701                                      CODE_LABEL_NUMBER (xoperands[2]));
2702   output_asm_insn (\"mfia %0\", xoperands);
2703
2704   /* If we're trying to load the address of a label that happens to be
2705      close, then we can use a shorter sequence.  */
2706   if (GET_CODE (operands[1]) == LABEL_REF
2707       && !LABEL_REF_NONLOCAL_P (operands[1])
2708       && INSN_ADDRESSES_SET_P ()
2709       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2710                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2711     output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2712   else
2713     {
2714       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2715       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2716     }
2717   return \"\";
2718 }"
2719   [(set_attr "type" "multi")
2720    (set_attr "length" "12")])           ; 8 or 12
2721
2722 (define_insn ""
2723   [(set (match_operand 0 "pmode_register_operand" "=a")
2724         (match_operand 1 "pic_label_operand" ""))]
2725   "!TARGET_PA_20"
2726   "*
2727 {
2728   rtx xoperands[3];
2729
2730   xoperands[0] = operands[0];
2731   xoperands[1] = operands[1];
2732   xoperands[2] = gen_label_rtx ();
2733
2734   output_asm_insn (\"bl .+8,%0\", xoperands);
2735   output_asm_insn (\"depi 0,31,2,%0\", xoperands);
2736   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2737                                      CODE_LABEL_NUMBER (xoperands[2]));
2738
2739   /* If we're trying to load the address of a label that happens to be
2740      close, then we can use a shorter sequence.  */
2741   if (GET_CODE (operands[1]) == LABEL_REF
2742       && !LABEL_REF_NONLOCAL_P (operands[1])
2743       && INSN_ADDRESSES_SET_P ()
2744       && abs (INSN_ADDRESSES (INSN_UID (XEXP (operands[1], 0)))
2745                 - INSN_ADDRESSES (INSN_UID (insn))) < 8100)
2746     output_asm_insn (\"ldo %1-%2(%0),%0\", xoperands);
2747   else
2748     {
2749       output_asm_insn (\"addil L%%%1-%2,%0\", xoperands);
2750       output_asm_insn (\"ldo R%%%1-%2(%0),%0\", xoperands);
2751     }
2752   return \"\";
2753 }"
2754   [(set_attr "type" "multi")
2755    (set_attr "length" "16")])           ; 12 or 16
2756
2757 (define_insn ""
2758   [(set (match_operand:SI 0 "register_operand" "=a")
2759         (plus:SI (match_operand:SI 1 "register_operand" "r")
2760                  (high:SI (match_operand 2 "" ""))))]
2761   "symbolic_operand (operands[2], Pmode)
2762    && ! function_label_operand (operands[2], Pmode)
2763    && flag_pic"
2764   "addil LT'%G2,%1"
2765   [(set_attr "type" "binary")
2766    (set_attr "length" "4")])
2767
2768 (define_insn ""
2769   [(set (match_operand:DI 0 "register_operand" "=a")
2770         (plus:DI (match_operand:DI 1 "register_operand" "r")
2771                  (high:DI (match_operand 2 "" ""))))]
2772   "symbolic_operand (operands[2], Pmode)
2773    && ! function_label_operand (operands[2], Pmode)
2774    && TARGET_64BIT
2775    && flag_pic"
2776   "addil LT'%G2,%1"
2777   [(set_attr "type" "binary")
2778    (set_attr "length" "4")])
2779
2780 ;; Always use addil rather than ldil;add sequences.  This allows the
2781 ;; HP linker to eliminate the dp relocation if the symbolic operand
2782 ;; lives in the TEXT space.
2783 (define_insn ""
2784   [(set (match_operand:SI 0 "register_operand" "=a")
2785         (high:SI (match_operand 1 "" "")))]
2786   "symbolic_operand (operands[1], Pmode)
2787    && ! function_label_operand (operands[1], Pmode)
2788    && ! read_only_operand (operands[1], Pmode)
2789    && ! flag_pic"
2790   "*
2791 {
2792   if (TARGET_LONG_LOAD_STORE)
2793     return \"addil NLR'%H1,%%r27\;ldo N'%H1(%%r1),%%r1\";
2794   else
2795     return \"addil LR'%H1,%%r27\";
2796 }"
2797   [(set_attr "type" "binary")
2798    (set (attr "length")
2799       (if_then_else (eq (symbol_ref "TARGET_LONG_LOAD_STORE") (const_int 0))
2800                     (const_int 4)
2801                     (const_int 8)))])
2802
2803
2804 ;; This is for use in the prologue/epilogue code.  We need it
2805 ;; to add large constants to a stack pointer or frame pointer.
2806 ;; Because of the additional %r1 pressure, we probably do not
2807 ;; want to use this in general code, so make it available
2808 ;; only after reload.
2809 (define_insn ""
2810   [(set (match_operand:SI 0 "register_operand" "=!a,*r")
2811         (plus:SI (match_operand:SI 1 "register_operand" "r,r")
2812                  (high:SI (match_operand 2 "const_int_operand" ""))))]
2813   "reload_completed"
2814   "@
2815    addil L'%G2,%1
2816    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2817   [(set_attr "type" "binary,binary")
2818    (set_attr "length" "4,8")])
2819
2820 (define_insn ""
2821   [(set (match_operand:DI 0 "register_operand" "=!a,*r")
2822         (plus:DI (match_operand:DI 1 "register_operand" "r,r")
2823                  (high:DI (match_operand 2 "const_int_operand" ""))))]
2824   "reload_completed && TARGET_64BIT"
2825   "@
2826    addil L'%G2,%1
2827    ldil L'%G2,%0\;{addl|add,l} %0,%1,%0"
2828   [(set_attr "type" "binary,binary")
2829    (set_attr "length" "4,8")])
2830
2831 (define_insn ""
2832   [(set (match_operand:SI 0 "register_operand" "=r")
2833         (high:SI (match_operand 1 "" "")))]
2834   "(!flag_pic || !symbolic_operand (operands[1], Pmode))
2835     && !is_function_label_plus_const (operands[1])"
2836   "*
2837 {
2838   if (symbolic_operand (operands[1], Pmode))
2839     return \"ldil LR'%H1,%0\";
2840   else
2841     return \"ldil L'%G1,%0\";
2842 }"
2843   [(set_attr "type" "move")
2844    (set_attr "length" "4")])
2845
2846 (define_insn ""
2847   [(set (match_operand:DI 0 "register_operand" "=r")
2848         (high:DI (match_operand 1 "const_int_operand" "")))]
2849   "TARGET_64BIT"
2850   "ldil L'%G1,%0";
2851   [(set_attr "type" "move")
2852    (set_attr "length" "4")])
2853
2854 (define_insn ""
2855   [(set (match_operand:DI 0 "register_operand" "=r")
2856         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
2857                    (match_operand:DI 2 "const_int_operand" "i")))]
2858   "TARGET_64BIT"
2859   "ldo R'%G2(%1),%0";
2860   [(set_attr "type" "move")
2861    (set_attr "length" "4")])
2862
2863 (define_insn ""
2864   [(set (match_operand:SI 0 "register_operand" "=r")
2865         (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
2866                    (match_operand:SI 2 "immediate_operand" "i")))]
2867   "!is_function_label_plus_const (operands[2])"
2868   "*
2869 {
2870   gcc_assert (!flag_pic || !symbolic_operand (operands[2], Pmode));
2871   
2872   if (symbolic_operand (operands[2], Pmode))
2873     return \"ldo RR'%G2(%1),%0\";
2874   else
2875     return \"ldo R'%G2(%1),%0\";
2876 }"
2877   [(set_attr "type" "move")
2878    (set_attr "length" "4")])
2879
2880 ;; Now that a symbolic_address plus a constant is broken up early
2881 ;; in the compilation phase (for better CSE) we need a special
2882 ;; combiner pattern to load the symbolic address plus the constant
2883 ;; in only 2 instructions. (For cases where the symbolic address
2884 ;; was not a common subexpression.)
2885 (define_split
2886   [(set (match_operand:SI 0 "register_operand" "")
2887         (match_operand:SI 1 "symbolic_operand" ""))
2888    (clobber (match_operand:SI 2 "register_operand" ""))]
2889   "! (flag_pic && pic_label_operand (operands[1], SImode))"
2890   [(set (match_dup 2) (high:SI (match_dup 1)))
2891    (set (match_dup 0) (lo_sum:SI (match_dup 2) (match_dup 1)))]
2892   "")
2893
2894 ;; hppa_legitimize_address goes to a great deal of trouble to
2895 ;; create addresses which use indexing.  In some cases, this
2896 ;; is a lose because there isn't any store instructions which
2897 ;; allow indexed addresses (with integer register source).
2898 ;;
2899 ;; These define_splits try to turn a 3 insn store into
2900 ;; a 2 insn store with some creative RTL rewriting.
2901 (define_split
2902   [(set (mem:SI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2903                                (match_operand:SI 1 "shadd_operand" ""))
2904                    (plus:SI (match_operand:SI 2 "register_operand" "")
2905                             (match_operand:SI 3 "const_int_operand" ""))))
2906         (match_operand:SI 4 "register_operand" ""))
2907    (clobber (match_operand:SI 5 "register_operand" ""))]
2908   ""
2909   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2910                                (match_dup 2)))
2911    (set (mem:SI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2912   "")
2913
2914 (define_split
2915   [(set (mem:HI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2916                                (match_operand:SI 1 "shadd_operand" ""))
2917                    (plus:SI (match_operand:SI 2 "register_operand" "")
2918                             (match_operand:SI 3 "const_int_operand" ""))))
2919         (match_operand:HI 4 "register_operand" ""))
2920    (clobber (match_operand:SI 5 "register_operand" ""))]
2921   ""
2922   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2923                                (match_dup 2)))
2924    (set (mem:HI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2925   "")
2926
2927 (define_split
2928   [(set (mem:QI (plus:SI (mult:SI (match_operand:SI 0 "register_operand" "")
2929                                (match_operand:SI 1 "shadd_operand" ""))
2930                    (plus:SI (match_operand:SI 2 "register_operand" "")
2931                             (match_operand:SI 3 "const_int_operand" ""))))
2932         (match_operand:QI 4 "register_operand" ""))
2933    (clobber (match_operand:SI 5 "register_operand" ""))]
2934   ""
2935   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
2936                                (match_dup 2)))
2937    (set (mem:QI (plus:SI (match_dup 5) (match_dup 3))) (match_dup 4))]
2938   "")
2939
2940 (define_expand "movhi"
2941   [(set (match_operand:HI 0 "general_operand" "")
2942         (match_operand:HI 1 "general_operand" ""))]
2943   ""
2944   "
2945 {
2946   if (emit_move_sequence (operands, HImode, 0))
2947     DONE;
2948 }")
2949
2950 (define_insn ""
2951   [(set (match_operand:HI 0 "move_dest_operand"
2952                           "=r,r,r,r,r,Q,!*q,!r")
2953         (match_operand:HI 1 "move_src_operand"
2954                           "r,J,N,K,RQ,rM,!rM,!*q"))]
2955   "register_operand (operands[0], HImode)
2956    || reg_or_0_operand (operands[1], HImode)"
2957   "@
2958    copy %1,%0
2959    ldi %1,%0
2960    ldil L'%1,%0
2961    {zdepi|depwi,z} %Z1,%0
2962    ldh%M1 %1,%0
2963    sth%M0 %r1,%0
2964    mtsar %r1
2965    {mfctl|mfctl,w} %sar,%0"
2966   [(set_attr "type" "move,move,move,shift,load,store,move,move")
2967    (set_attr "pa_combine_type" "addmove")
2968    (set_attr "length" "4,4,4,4,4,4,4,4")])
2969
2970 (define_insn ""
2971   [(set (match_operand:HI 0 "register_operand" "=r")
2972         (mem:HI (plus:SI (match_operand:SI 1 "register_operand" "+r")
2973                          (match_operand:SI 2 "int5_operand" "L"))))
2974    (set (match_dup 1)
2975         (plus:SI (match_dup 1) (match_dup 2)))]
2976   ""
2977   "{ldhs|ldh},mb %2(%1),%0"
2978   [(set_attr "type" "load")
2979    (set_attr "length" "4")])
2980
2981 (define_insn ""
2982   [(set (match_operand:HI 0 "register_operand" "=r")
2983         (mem:HI (plus:DI (match_operand:DI 1 "register_operand" "+r")
2984                          (match_operand:DI 2 "int5_operand" "L"))))
2985    (set (match_dup 1)
2986         (plus:DI (match_dup 1) (match_dup 2)))]
2987   "TARGET_64BIT"
2988   "ldh,mb %2(%1),%0"
2989   [(set_attr "type" "load")
2990    (set_attr "length" "4")])
2991
2992 ; And a zero extended variant.
2993 (define_insn ""
2994   [(set (match_operand:DI 0 "register_operand" "=r")
2995         (zero_extend:DI (mem:HI
2996                           (plus:DI
2997                             (match_operand:DI 1 "register_operand" "+r")
2998                             (match_operand:DI 2 "int5_operand" "L")))))
2999    (set (match_dup 1)
3000         (plus:DI (match_dup 1) (match_dup 2)))]
3001   "TARGET_64BIT"
3002   "ldh,mb %2(%1),%0"
3003   [(set_attr "type" "load")
3004    (set_attr "length" "4")])
3005
3006 (define_insn ""
3007   [(set (match_operand:SI 0 "register_operand" "=r")
3008         (zero_extend:SI (mem:HI
3009                           (plus:SI
3010                             (match_operand:SI 1 "register_operand" "+r")
3011                             (match_operand:SI 2 "int5_operand" "L")))))
3012    (set (match_dup 1)
3013         (plus:SI (match_dup 1) (match_dup 2)))]
3014   ""
3015   "{ldhs|ldh},mb %2(%1),%0"
3016   [(set_attr "type" "load")
3017    (set_attr "length" "4")])
3018
3019 (define_insn ""
3020   [(set (match_operand:SI 0 "register_operand" "=r")
3021         (zero_extend:SI (mem:HI
3022                           (plus:DI
3023                             (match_operand:DI 1 "register_operand" "+r")
3024                             (match_operand:DI 2 "int5_operand" "L")))))
3025    (set (match_dup 1)
3026         (plus:DI (match_dup 1) (match_dup 2)))]
3027   "TARGET_64BIT"
3028   "ldh,mb %2(%1),%0"
3029   [(set_attr "type" "load")
3030    (set_attr "length" "4")])
3031
3032 (define_insn ""
3033   [(set (mem:HI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3034                          (match_operand:SI 1 "int5_operand" "L")))
3035         (match_operand:HI 2 "reg_or_0_operand" "rM"))
3036    (set (match_dup 0)
3037         (plus:SI (match_dup 0) (match_dup 1)))]
3038   ""
3039   "{sths|sth},mb %r2,%1(%0)"
3040   [(set_attr "type" "store")
3041    (set_attr "length" "4")])
3042
3043 (define_insn ""
3044   [(set (mem:HI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3045                          (match_operand:DI 1 "int5_operand" "L")))
3046         (match_operand:HI 2 "reg_or_0_operand" "rM"))
3047    (set (match_dup 0)
3048         (plus:DI (match_dup 0) (match_dup 1)))]
3049   "TARGET_64BIT"
3050   "sth,mb %r2,%1(%0)"
3051   [(set_attr "type" "store")
3052    (set_attr "length" "4")])
3053
3054 (define_insn ""
3055   [(set (match_operand:HI 0 "register_operand" "=r")
3056         (plus:HI (match_operand:HI 1 "register_operand" "r")
3057                  (match_operand 2 "const_int_operand" "J")))]
3058   ""
3059   "ldo %2(%1),%0"
3060   [(set_attr "type" "binary")
3061    (set_attr "pa_combine_type" "addmove")
3062    (set_attr "length" "4")])
3063
3064 (define_expand "movqi"
3065   [(set (match_operand:QI 0 "general_operand" "")
3066         (match_operand:QI 1 "general_operand" ""))]
3067   ""
3068   "
3069 {
3070   if (emit_move_sequence (operands, QImode, 0))
3071     DONE;
3072 }")
3073
3074 (define_insn ""
3075   [(set (match_operand:QI 0 "move_dest_operand"
3076                           "=r,r,r,r,r,Q,!*q,!r")
3077         (match_operand:QI 1 "move_src_operand"
3078                           "r,J,N,K,RQ,rM,!rM,!*q"))]
3079   "register_operand (operands[0], QImode)
3080    || reg_or_0_operand (operands[1], QImode)"
3081   "@
3082    copy %1,%0
3083    ldi %1,%0
3084    ldil L'%1,%0
3085    {zdepi|depwi,z} %Z1,%0
3086    ldb%M1 %1,%0
3087    stb%M0 %r1,%0
3088    mtsar %r1
3089    {mfctl|mfctl,w} %%sar,%0"
3090   [(set_attr "type" "move,move,move,shift,load,store,move,move")
3091    (set_attr "pa_combine_type" "addmove")
3092    (set_attr "length" "4,4,4,4,4,4,4,4")])
3093
3094 (define_insn ""
3095   [(set (match_operand:QI 0 "register_operand" "=r")
3096         (mem:QI (plus:SI (match_operand:SI 1 "register_operand" "+r")
3097                          (match_operand:SI 2 "int5_operand" "L"))))
3098    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3099   ""
3100   "{ldbs|ldb},mb %2(%1),%0"
3101   [(set_attr "type" "load")
3102    (set_attr "length" "4")])
3103
3104 (define_insn ""
3105   [(set (match_operand:QI 0 "register_operand" "=r")
3106         (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "+r")
3107                          (match_operand:DI 2 "int5_operand" "L"))))
3108    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3109   "TARGET_64BIT"
3110   "ldb,mb %2(%1),%0"
3111   [(set_attr "type" "load")
3112    (set_attr "length" "4")])
3113
3114 ; Now the same thing with zero extensions.
3115 (define_insn ""
3116   [(set (match_operand:DI 0 "register_operand" "=r")
3117         (zero_extend:DI (mem:QI (plus:DI
3118                                   (match_operand:DI 1 "register_operand" "+r")
3119                                   (match_operand:DI 2 "int5_operand" "L")))))
3120    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3121   "TARGET_64BIT"
3122   "ldb,mb %2(%1),%0"
3123   [(set_attr "type" "load")
3124    (set_attr "length" "4")])
3125
3126 (define_insn ""
3127   [(set (match_operand:SI 0 "register_operand" "=r")
3128         (zero_extend:SI (mem:QI (plus:SI
3129                                   (match_operand:SI 1 "register_operand" "+r")
3130                                   (match_operand:SI 2 "int5_operand" "L")))))
3131    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3132   ""
3133   "{ldbs|ldb},mb %2(%1),%0"
3134   [(set_attr "type" "load")
3135    (set_attr "length" "4")])
3136
3137 (define_insn ""
3138   [(set (match_operand:SI 0 "register_operand" "=r")
3139         (zero_extend:SI (mem:QI (plus:DI
3140                                   (match_operand:DI 1 "register_operand" "+r")
3141                                   (match_operand:DI 2 "int5_operand" "L")))))
3142    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3143   "TARGET_64BIT"
3144   "ldb,mb %2(%1),%0"
3145   [(set_attr "type" "load")
3146    (set_attr "length" "4")])
3147
3148 (define_insn ""
3149   [(set (match_operand:HI 0 "register_operand" "=r")
3150         (zero_extend:HI (mem:QI (plus:SI
3151                                   (match_operand:SI 1 "register_operand" "+r")
3152                                   (match_operand:SI 2 "int5_operand" "L")))))
3153    (set (match_dup 1) (plus:SI (match_dup 1) (match_dup 2)))]
3154   ""
3155   "{ldbs|ldb},mb %2(%1),%0"
3156   [(set_attr "type" "load")
3157    (set_attr "length" "4")])
3158
3159 (define_insn ""
3160   [(set (match_operand:HI 0 "register_operand" "=r")
3161         (zero_extend:HI (mem:QI (plus:DI
3162                                   (match_operand:DI 1 "register_operand" "+r")
3163                                   (match_operand:DI 2 "int5_operand" "L")))))
3164    (set (match_dup 1) (plus:DI (match_dup 1) (match_dup 2)))]
3165   "TARGET_64BIT"
3166   "ldb,mb %2(%1),%0"
3167   [(set_attr "type" "load")
3168    (set_attr "length" "4")])
3169
3170 (define_insn ""
3171   [(set (mem:QI (plus:SI (match_operand:SI 0 "register_operand" "+r")
3172                          (match_operand:SI 1 "int5_operand" "L")))
3173         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3174    (set (match_dup 0)
3175         (plus:SI (match_dup 0) (match_dup 1)))]
3176   ""
3177   "{stbs|stb},mb %r2,%1(%0)"
3178   [(set_attr "type" "store")
3179    (set_attr "length" "4")])
3180
3181 (define_insn ""
3182   [(set (mem:QI (plus:DI (match_operand:DI 0 "register_operand" "+r")
3183                          (match_operand:DI 1 "int5_operand" "L")))
3184         (match_operand:QI 2 "reg_or_0_operand" "rM"))
3185    (set (match_dup 0)
3186         (plus:DI (match_dup 0) (match_dup 1)))]
3187   "TARGET_64BIT"
3188   "stb,mb %r2,%1(%0)"
3189   [(set_attr "type" "store")
3190    (set_attr "length" "4")])
3191
3192 ;; The definition of this insn does not really explain what it does,
3193 ;; but it should suffice that anything generated as this insn will be
3194 ;; recognized as a movmemsi operation, and that it will not successfully
3195 ;; combine with anything.
3196 (define_expand "movmemsi"
3197   [(parallel [(set (match_operand:BLK 0 "" "")
3198                    (match_operand:BLK 1 "" ""))
3199               (clobber (match_dup 4))
3200               (clobber (match_dup 5))
3201               (clobber (match_dup 6))
3202               (clobber (match_dup 7))
3203               (clobber (match_dup 8))
3204               (use (match_operand:SI 2 "arith_operand" ""))
3205               (use (match_operand:SI 3 "const_int_operand" ""))])]
3206   "!TARGET_64BIT && optimize > 0"
3207   "
3208 {
3209   int size, align;
3210
3211   /* HP provides very fast block move library routine for the PA;
3212      this routine includes:
3213
3214         4x4 byte at a time block moves,
3215         1x4 byte at a time with alignment checked at runtime with
3216             attempts to align the source and destination as needed
3217         1x1 byte loop
3218
3219      With that in mind, here's the heuristics to try and guess when
3220      the inlined block move will be better than the library block
3221      move:
3222
3223         If the size isn't constant, then always use the library routines.
3224
3225         If the size is large in respect to the known alignment, then use
3226         the library routines.
3227
3228         If the size is small in respect to the known alignment, then open
3229         code the copy (since that will lead to better scheduling).
3230
3231         Else use the block move pattern.   */
3232
3233   /* Undetermined size, use the library routine.  */
3234   if (GET_CODE (operands[2]) != CONST_INT)
3235     FAIL;
3236
3237   size = INTVAL (operands[2]);
3238   align = INTVAL (operands[3]);
3239   align = align > 4 ? 4 : align;
3240
3241   /* If size/alignment is large, then use the library routines.  */
3242   if (size / align > 16)
3243     FAIL;
3244
3245   /* This does happen, but not often enough to worry much about.  */
3246   if (size / align < MOVE_RATIO)
3247     FAIL;
3248   
3249   /* Fall through means we're going to use our block move pattern.  */
3250   operands[0]
3251     = replace_equiv_address (operands[0],
3252                              copy_to_mode_reg (SImode, XEXP (operands[0], 0)));
3253   operands[1]
3254     = replace_equiv_address (operands[1],
3255                              copy_to_mode_reg (SImode, XEXP (operands[1], 0)));
3256   operands[4] = gen_reg_rtx (SImode);
3257   operands[5] = gen_reg_rtx (SImode);
3258   operands[6] = gen_reg_rtx (SImode);
3259   operands[7] = gen_reg_rtx (SImode);
3260   operands[8] = gen_reg_rtx (SImode);
3261 }")
3262
3263 ;; The operand constraints are written like this to support both compile-time
3264 ;; and run-time determined byte counts.  The expander and output_block_move
3265 ;; only support compile-time determined counts at this time.
3266 ;;
3267 ;; If the count is run-time determined, the register with the byte count
3268 ;; is clobbered by the copying code, and therefore it is forced to operand 2.
3269 ;;
3270 ;; We used to clobber operands 0 and 1.  However, a change to regrename.c
3271 ;; broke this semantic for pseudo registers.  We can't use match_scratch
3272 ;; as this requires two registers in the class R1_REGS when the MEMs for
3273 ;; operands 0 and 1 are both equivalent to symbolic MEMs.  Thus, we are
3274 ;; forced to internally copy operands 0 and 1 to operands 7 and 8,
3275 ;; respectively.  We then split or peephole optimize after reload.
3276 (define_insn "movmemsi_prereload"
3277   [(set (mem:BLK (match_operand:SI 0 "register_operand" "r,r"))
3278         (mem:BLK (match_operand:SI 1 "register_operand" "r,r")))
3279    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3280    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3281    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3282    (clobber (match_operand:SI 7 "register_operand" "=&r,&r"))   ;item tmp3
3283    (clobber (match_operand:SI 8 "register_operand" "=&r,&r"))   ;item tmp4
3284    (use (match_operand:SI 4 "arith_operand" "J,2"))      ;byte count
3285    (use (match_operand:SI 5 "const_int_operand" "n,n"))] ;alignment
3286   "!TARGET_64BIT"
3287   "#"
3288   [(set_attr "type" "multi,multi")])
3289
3290 (define_split
3291   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3292                    (match_operand:BLK 1 "memory_operand" ""))
3293               (clobber (match_operand:SI 2 "register_operand" ""))
3294               (clobber (match_operand:SI 3 "register_operand" ""))
3295               (clobber (match_operand:SI 6 "register_operand" ""))
3296               (clobber (match_operand:SI 7 "register_operand" ""))
3297               (clobber (match_operand:SI 8 "register_operand" ""))
3298               (use (match_operand:SI 4 "arith_operand" ""))
3299               (use (match_operand:SI 5 "const_int_operand" ""))])]
3300   "!TARGET_64BIT && reload_completed && !flag_peephole2
3301    && GET_CODE (operands[0]) == MEM
3302    && register_operand (XEXP (operands[0], 0), SImode)
3303    && GET_CODE (operands[1]) == MEM
3304    && register_operand (XEXP (operands[1], 0), SImode)"
3305   [(set (match_dup 7) (match_dup 9))
3306    (set (match_dup 8) (match_dup 10))
3307    (parallel [(set (match_dup 0) (match_dup 1))
3308               (clobber (match_dup 2))
3309               (clobber (match_dup 3))
3310               (clobber (match_dup 6))
3311               (clobber (match_dup 7))
3312               (clobber (match_dup 8))
3313               (use (match_dup 4))
3314               (use (match_dup 5))
3315               (const_int 0)])]
3316   "
3317 {
3318   operands[9] = XEXP (operands[0], 0);
3319   operands[10] = XEXP (operands[1], 0);
3320   operands[0] = replace_equiv_address (operands[0], operands[7]);
3321   operands[1] = replace_equiv_address (operands[1], operands[8]);
3322 }")
3323
3324 (define_peephole2
3325   [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
3326                    (match_operand:BLK 1 "memory_operand" ""))
3327               (clobber (match_operand:SI 2 "register_operand" ""))
3328               (clobber (match_operand:SI 3 "register_operand" ""))
3329               (clobber (match_operand:SI 6 "register_operand" ""))
3330               (clobber (match_operand:SI 7 "register_operand" ""))
3331               (clobber (match_operand:SI 8 "register_operand" ""))
3332               (use (match_operand:SI 4 "arith_operand" ""))
3333               (use (match_operand:SI 5 "const_int_operand" ""))])]
3334   "!TARGET_64BIT
3335    && GET_CODE (operands[0]) == MEM
3336    && register_operand (XEXP (operands[0], 0), SImode)
3337    && GET_CODE (operands[1]) == MEM
3338    && register_operand (XEXP (operands[1], 0), SImode)"
3339   [(parallel [(set (match_dup 0) (match_dup 1))
3340               (clobber (match_dup 2))
3341               (clobber (match_dup 3))
3342               (clobber (match_dup 6))
3343               (clobber (match_dup 7))
3344               (clobber (match_dup 8))
3345               (use (match_dup 4))
3346               (use (match_dup 5))
3347               (const_int 0)])]
3348   "
3349 {
3350   rtx addr = XEXP (operands[0], 0);
3351   if (dead_or_set_p (curr_insn, addr))
3352     operands[7] = addr;
3353   else
3354     {
3355       emit_insn (gen_rtx_SET (VOIDmode, operands[7], addr));
3356       operands[0] = replace_equiv_address (operands[0], operands[7]);
3357     }
3358
3359   addr = XEXP (operands[1], 0);
3360   if (dead_or_set_p (curr_insn, addr))
3361     operands[8] = addr;
3362   else
3363     {
3364       emit_insn (gen_rtx_SET (VOIDmode, operands[8], addr));
3365       operands[1] = replace_equiv_address (operands[1], operands[8]);
3366     }
3367 }")
3368
3369 (define_insn "movmemsi_postreload"
3370   [(set (mem:BLK (match_operand:SI 0 "register_operand" "+r,r"))
3371         (mem:BLK (match_operand:SI 1 "register_operand" "+r,r")))
3372    (clobber (match_operand:SI 2 "register_operand" "=&r,&r"))   ;loop cnt/tmp
3373    (clobber (match_operand:SI 3 "register_operand" "=&r,&r"))   ;item tmp1
3374    (clobber (match_operand:SI 6 "register_operand" "=&r,&r"))   ;item tmp2
3375    (clobber (match_dup 0))
3376    (clobber (match_dup 1))
3377    (use (match_operand:SI 4 "arith_operand" "J,2"))      ;byte count
3378    (use (match_operand:SI 5 "const_int_operand" "n,n"))  ;alignment
3379    (const_int 0)]
3380   "!TARGET_64BIT && reload_completed"
3381   "* return output_block_move (operands, !which_alternative);"
3382   [(set_attr "type" "multi,multi")])
3383
3384 (define_expand "movmemdi"
3385   [(parallel [(set (match_operand:BLK 0 "" "")
3386                    (match_operand:BLK 1 "" ""))
3387               (clobber (match_dup 4))
3388               (clobber (match_dup 5))
3389               (clobber (match_dup 6))
3390               (clobber (match_dup 7))
3391               (clobber (match_dup 8))
3392               (use (match_operand:DI 2 "arith_operand" ""))
3393               (use (match_operand:DI 3 "const_int_operand" ""))])]
3394   "TARGET_64BIT && optimize > 0"
3395   "
3396 {
3397   int size, align;
3398
3399   /* HP provides very fast block move library routine for the PA;
3400      this routine includes:
3401
3402         4x4 byte at a time block moves,
3403         1x4 byte at a time with alignment checked at runtime with
3404             attempts to align the source and destination as needed
3405         1x1 byte loop
3406
3407      With that in mind, here's the heuristics to try and guess when
3408      the inlined block move will be better than the library block
3409      move:
3410
3411         If the size isn't constant, then always use the library routines.
3412
3413         If the size is large in respect to the known alignment, then use
3414         the library routines.
3415
3416         If the size is small in respect to the known alignment, then open
3417         code the copy (since that will lead to better scheduling).
3418
3419         Else use the block move pattern.   */
3420
3421   /* Undetermined size, use the library routine.  */
3422   if (GET_CODE (operands[2]) != CONST_INT)
3423     FAIL;
3424
3425   size = INTVAL (operands[2]);
3426   align = INTVAL (operands[3]);
3427   align = align > 8 ? 8 : align;
3428
3429   /* If size/alignment is large, then use the library routines.  */
3430   if (size / align > 16)
3431     FAIL;
3432
3433   /* This does happen, but not often enough to worry much about.  */
3434   if (size / align < MOVE_RATIO)
3435     FAIL;
3436   
3437   /* Fall through means we're going to use our block move pattern.  */
3438   operands[0]
3439     = replace_equiv_address (operands[0],
3440                              copy_to_mode_reg (DImode, XEXP (operands[0], 0)));
3441   operands[1]
3442     = replace_equiv_address (operands[1],
3443                              copy_to_mode_reg (DImode, XEXP (operands[1], 0)));
3444   operands[4] = gen_reg_rtx (DImode);
3445   operands[5] = gen_reg_rtx (DImode);
3446   operands[6] = gen_reg_rtx (DImode);
3447   operands[7] = gen_reg_rtx (DImode);
3448   operands[8] = gen_reg_rtx (DImode);
3449 }")
3450
3451 ;; The operand constraints are written like this to support both compile-time
3452 ;; and run-time determined by