Small data support; Windows NT attributes; windows NT call indrect fix
[official-gcc.git] / gcc / config / rs6000 / rs6000.md
blob8131d84c6277eace6fe105ecc40bf8a4bd8bbd8f
1 ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
2 ;; Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
3 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
5 ;; This file is part of GNU CC.
7 ;; GNU CC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
12 ;; GNU CC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU CC; see the file COPYING.  If not, write to
19 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
22 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
24 ;; Define an insn type attribute.  This is used in function unit delay
25 ;; computations.
26 (define_attr "type" "integer,load,fpload,imul,idiv,branch,compare,delayed_compare,fpcompare,mtjmpr,fp,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg"
27   (const_string "integer"))
29 ;; Length (in bytes).
30 (define_attr "length" ""
31   (if_then_else (eq_attr "type" "branch")
32                 (if_then_else (and (ge (minus (pc) (match_dup 0))
33                                        (const_int -32768))
34                                    (lt (minus (pc) (match_dup 0))
35                                        (const_int 32767)))
36                               (const_int 8)
37                               (const_int 12))
38                 (const_int 4)))
40 ;; Processor type -- this attribute must exactly match the processor_type
41 ;; enumeration in rs6000.h.
43 (define_attr "cpu" "rios1,rios2,mpccore,ppc403,ppc601,ppc602,ppc603,ppc604,ppc620"
44   (const (symbol_ref "rs6000_cpu_attr")))
46 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
47 ;                       TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
49 ; Load/Store Unit -- POWER/2 and pure PowerPC only
50 ; (POWER and 601 use Integer Unit)
51 (define_function_unit "lsu" 1 0
52   (and (eq_attr "type" "load")
53        (eq_attr "cpu" "mpccore,ppc602,ppc603,ppc604,ppc620"))
54   2 1)
56 (define_function_unit "lsu" 1 0
57   (and (eq_attr "type" "fpload")
58        (eq_attr "cpu" "ppc604,ppc620"))
59   3 1)
61 (define_function_unit "lsu" 1 0
62   (and (eq_attr "type" "fpload")
63        (eq_attr "cpu" "mpccore,ppc602,ppc603"))
64   2 1)
66 (define_function_unit "iu" 1 0
67   (and (eq_attr "type" "load")
68        (eq_attr "cpu" "rios1,ppc601,ppc403"))
69   2 1)
71 (define_function_unit "iu" 1 0
72   (and (eq_attr "type" "fpload")
73        (eq_attr "cpu" "rios1,ppc601"))
74   2 0)
76 ; Integer Unit (RIOS1, PPC601, PPC603)
77 ; Trivial operations take one cycle which need not be listed here.
78 (define_function_unit "iu" 1 0
79   (and (eq_attr "type" "imul")
80        (eq_attr "cpu" "rios1"))
81   3 3)
83 (define_function_unit "iu" 1 0
84   (and (eq_attr "type" "imul")
85        (eq_attr "cpu" "ppc403"))
86   4 4)
88 (define_function_unit "iu" 1 0
89   (and (eq_attr "type" "imul")
90        (eq_attr "cpu" "ppc601,ppc602,ppc603"))
91   5 5)
93 (define_function_unit "iu" 1 0
94   (and (eq_attr "type" "idiv")
95        (eq_attr "cpu" "rios1"))
96   19 19)
98 (define_function_unit "iu" 1 0
99   (and (eq_attr "type" "idiv")
100        (eq_attr "cpu" "ppc601"))
101   36 36)
103 (define_function_unit "iu" 1 0
104   (and (eq_attr "type" "idiv")
105        (eq_attr "cpu" "ppc403"))
106   33 33)
108 (define_function_unit "iu" 1 0
109   (and (eq_attr "type" "idiv")
110        (eq_attr "cpu" "ppc602,ppc603"))
111   37 36)
113 ; RIOS2 has two integer units: a primary one which can perform all
114 ; operations and a secondary one which is fed in lock step with the first
115 ; and can perform "simple" integer operations.  
116 ; To catch this we define a 'dummy' imuldiv-unit that is also needed
117 ; for the complex insns. 
118 (define_function_unit "iu2" 2 0
119   (and (eq_attr "type" "integer")
120        (eq_attr "cpu" "rios2"))
121   1 0)
123 (define_function_unit "iu2" 2 0
124   (and (eq_attr "type" "imul")
125        (eq_attr "cpu" "rios2"))
126   2 2)
128 (define_function_unit "iu2" 2 0
129   (and (eq_attr "type" "idiv")
130        (eq_attr "cpu" "rios2"))
131   13 13)
133 (define_function_unit "imuldiv" 1 0
134   (and (eq_attr "type" "imul")
135        (eq_attr "cpu" "rios2"))
136   2 2)
139 (define_function_unit "imuldiv" 1 0
140   (and (eq_attr "type" "idiv")
141        (eq_attr "cpu" "rios2"))
142   13 13)
144 ; MPCCORE has separate IMUL/IDIV unit for multicycle instructions
145 ; Divide latency varies greatly from 2-11, use 6 as average
146 (define_function_unit "imuldiv" 1 0
147   (and (eq_attr "type" "imul")
148        (eq_attr "cpu" "mpccore"))
149   2 1)
151 (define_function_unit "imuldiv" 1 0
152   (and (eq_attr "type" "idiv")
153        (eq_attr "cpu" "mpccore"))
154   6 6)
156 ; PPC604 has two units that perform integer operations
157 ; and one unit for divide/multiply operations (and move
158 ; from/to spr).
159 (define_function_unit "iu2" 2 0
160   (and (eq_attr "type" "integer")
161        (eq_attr "cpu" "ppc604,ppc620"))
162   1 1
163   [(eq_attr "type" "imul,idiv")])
165 (define_function_unit "imuldiv" 1 0
166   (and (eq_attr "type" "imul")
167        (eq_attr "cpu" "ppc604,ppc620"))
168   4 2
169   [(eq_attr "type" "integer")])
171 (define_function_unit "imuldiv" 1 0
172   (and (eq_attr "type" "idiv")
173        (eq_attr "cpu" "ppc604,ppc620"))
174   20 19
175   [(eq_attr "type" "integer")])
177 ; compare is done on integer unit, but feeds insns which
178 ; execute on the branch unit.  Ready-delay of the compare 
179 ; on the branch unit is large (3-5 cycles).  On the iu/fpu
180 ; it is 1.  One drawback is that the compare will also be 
181 ; assigned to the bpu, but this inaccuracy is worth for being
182 ; able to fill the compare-branch delay, with insns on iu/fpu.
183 (define_function_unit "iu" 1 0   
184   (and (eq_attr "type" "compare")
185        (eq_attr "cpu" "rios1,mpccore,ppc601"))
186   1 1)
188 (define_function_unit "iu2" 2 0   
189   (and (eq_attr "type" "compare")
190        (eq_attr "cpu" "rios2"))
191   1 1)
193 (define_function_unit "bpu" 1 0   
194   (and (eq_attr "type" "compare")
195        (eq_attr "cpu" "rios1,rios2,ppc403,mpccore,ppc601,ppc603,ppc604,ppc620"))
196   4 1)
198 ; different machines have different compare timings
199 ; in ppc604, compare is done on the one of the two
200 ; main integer units.
201 (define_function_unit "iu2" 2 0
202   (and (eq_attr "type" "compare")
203        (eq_attr "cpu" "ppc604,ppc620"))
204   1 1)
206 (define_function_unit "bpu" 1 0
207   (eq_attr "type" "delayed_compare")
208   5 0)
210 ; fp compare uses fp unit
211 (define_function_unit "fpu" 1 0
212   (and (eq_attr "type" "fpcompare")
213        (eq_attr "cpu" "rios1"))
214   8 1)
216 ; rios1 and rios2 have different fpcompare delays
217 (define_function_unit "fpu2" 2 0
218   (and (eq_attr "type" "fpcompare")
219        (eq_attr "cpu" "rios2"))
220   5 1)
222 ; on ppc601 and ppc603, fpcompare takes also 2 cycles from
223 ; the integer unit
224 ; here we do not define delays, just occupy the unit. The dependencies
225 ; will be signed by the fpcompare definition in the fpu.
226 (define_function_unit "iu" 1 0
227   (and (eq_attr "type" "fpcompare")
228        (eq_attr "cpu" "ppc601,ppc602,ppc603"))
229   0 2)
231 ; fp compare uses fp unit
232 (define_function_unit "fpu" 1 0
233   (and (eq_attr "type" "fpcompare")
234        (eq_attr "cpu" "ppc601,ppc602,ppc603,ppc604,ppc620"))
235   5 1)
237 (define_function_unit "fpu" 1 0
238   (and (eq_attr "type" "fpcompare")
239        (eq_attr "cpu" "mpccore"))
240   1 1)
242 (define_function_unit "bpu" 1 0
243   (and (eq_attr "type" "mtjmpr")
244        (eq_attr "cpu" "rios1,rios2"))
245   5 0)
247 (define_function_unit "bpu" 1 0
248   (and (eq_attr "type" "mtjmpr")
249        (eq_attr "cpu" "ppc403,mpccore,ppc601,ppc602,ppc603,ppc604,ppc620"))
250   4 0)
252 ; all jumps/branches are executing on the bpu, in 1 cycle, for all machines.
253 (define_function_unit "bpu" 1 0
254   (eq_attr "type" "jmpreg")
255   1 0)
257 (define_function_unit "bpu" 1 0
258   (eq_attr "type" "branch")
259   1 0)
261 ; Floating Point Unit
262 (define_function_unit "fpu" 1 0
263   (and (eq_attr "type" "fp,dmul")
264        (eq_attr "cpu" "rios1"))
265   2 0)
267 (define_function_unit "fpu" 1 0
268   (and (eq_attr "type" "fp")
269        (eq_attr "cpu" "mpccore"))
270   4 4)
272 (define_function_unit "fpu" 1 0
273   (and (eq_attr "type" "fp")
274        (eq_attr "cpu" "ppc601"))
275   4 0)
277 (define_function_unit "fpu" 1 0
278   (and (eq_attr "type" "fp")
279        (eq_attr "cpu" "ppc602,ppc603,ppc604,ppc620"))
280   3 1)
282 (define_function_unit "fpu" 1 0
283   (and (eq_attr "type" "dmul")
284        (eq_attr "cpu" "mpccore"))
285   5 5)
287 (define_function_unit "fpu" 1 0
288   (and (eq_attr "type" "dmul")
289        (eq_attr "cpu" "ppc601"))
290   5 2)
292 ; is this true?
293 (define_function_unit "fpu" 1 0
294   (and (eq_attr "type" "dmul")
295        (eq_attr "cpu" "ppc602,ppc603"))
296   4 2)
298 (define_function_unit "fpu" 1 0
299   (and (eq_attr "type" "dmul")
300        (eq_attr "cpu" "ppc604,ppc620"))
301   3 1)
303 (define_function_unit "fpu" 1 0
304   (and (eq_attr "type" "sdiv,ddiv")
305        (eq_attr "cpu" "rios1"))
306   19 19)
308 (define_function_unit "fpu" 1 0
309   (and (eq_attr "type" "sdiv")
310        (eq_attr "cpu" "ppc601"))
311   17 17)
313 (define_function_unit "fpu" 1 0
314   (and (eq_attr "type" "sdiv")
315        (eq_attr "cpu" "mpccore"))
316   10 10)
318 (define_function_unit "fpu" 1 0
319   (and (eq_attr "type" "sdiv")
320        (eq_attr "cpu" "ppc602,ppc603,ppc604,ppc620"))
321   18 18)
323 (define_function_unit "fpu" 1 0
324   (and (eq_attr "type" "ddiv")
325        (eq_attr "cpu" "mpccore"))
326   17 17)
328 (define_function_unit "fpu" 1 0
329   (and (eq_attr "type" "ddiv")
330        (eq_attr "cpu" "ppc601,ppc604,ppc620"))
331   31 31)
333 (define_function_unit "fpu" 1 0
334   (and (eq_attr "type" "ddiv")
335        (eq_attr "cpu" "ppc602,ppc603"))
336   33 33)
338 (define_function_unit "fpu" 1 0
339   (and (eq_attr "type" "ssqrt")
340        (eq_attr "cpu" "ppc620"))
341   31 31)
343 (define_function_unit "fpu" 1 0
344   (and (eq_attr "type" "dsqrt")
345        (eq_attr "cpu" "ppc620"))
346   31 31)
348 ; RIOS2 has two symmetric FPUs.
349 (define_function_unit "fpu2" 2 0
350   (and (eq_attr "type" "fp")
351        (eq_attr "cpu" "rios2"))
352   2 0)
354 (define_function_unit "fpu2" 2 0
355   (and (eq_attr "type" "dmul")
356        (eq_attr "cpu" "rios2"))
357   2 0)
359 (define_function_unit "fpu2" 2 0
360   (and (eq_attr "type" "sdiv,ddiv")
361        (eq_attr "cpu" "rios2"))
362   17 17)
364 (define_function_unit "fpu2" 2 0
365   (and (eq_attr "type" "ssqrt,dsqrt")
366        (eq_attr "cpu" "rios2"))
367   26 26)
370 ;; Start with fixed-point load and store insns.  Here we put only the more
371 ;; complex forms.  Basic data transfer is done later.
373 (define_expand "zero_extendqidi2"
374   [(set (match_operand:DI 0 "gpc_reg_operand" "")
375         (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "")))]
376   "TARGET_POWERPC64"
377   "")
379 (define_insn ""
380   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
381         (zero_extend:DI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
382   "TARGET_POWERPC64"
383   "@
384    lbz%U1%X1 %0,%1
385    rldicl %0,%1,0,56"
386   [(set_attr "type" "load,*")])
388 (define_insn ""
389   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
390         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
391                     (const_int 0)))
392    (clobber (match_scratch:DI 2 "=r"))]
393   "TARGET_POWERPC64"
394   "rldicl. %2,%1,0,56"
395   [(set_attr "type" "compare")])
397 (define_insn ""
398   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
399         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
400                     (const_int 0)))
401    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
402         (zero_extend:DI (match_dup 1)))]
403   "TARGET_POWERPC64"
404   "rldicl. %0,%1,0,56"
405   [(set_attr "type" "compare")])
407 (define_insn "extendqidi2"
408   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
409         (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
410   "TARGET_POWERPC64"
411   "extsb %0,%1")
413 (define_insn ""
414   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
415         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
416                     (const_int 0)))
417    (clobber (match_scratch:DI 2 "=r"))]
418   "TARGET_POWERPC64"
419   "extsb. %2,%1"
420   [(set_attr "type" "compare")])
422 (define_insn ""
423   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
424         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
425                     (const_int 0)))
426    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
427         (sign_extend:DI (match_dup 1)))]
428   "TARGET_POWERPC64"
429   "extsb. %0,%1"
430   [(set_attr "type" "compare")])
432 (define_expand "zero_extendhidi2"
433   [(set (match_operand:DI 0 "gpc_reg_operand" "")
434         (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
435   "TARGET_POWERPC64"
436   "")
438 (define_insn ""
439   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
440         (zero_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
441   "TARGET_POWERPC64"
442   "@
443    lhz%U1%X1 %0,%1
444    rldicl %0,%1,0,48"
445   [(set_attr "type" "load,*")])
447 (define_insn ""
448   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
449         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
450                     (const_int 0)))
451    (clobber (match_scratch:DI 2 "=r"))]
452   "TARGET_POWERPC64"
453   "rldicl. %2,%1,0,48"
454   [(set_attr "type" "compare")])
456 (define_insn ""
457   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
458         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
459                     (const_int 0)))
460    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
461         (zero_extend:DI (match_dup 1)))]
462   "TARGET_POWERPC64"
463   "rldicl. %0,%1,0,48"
464   [(set_attr "type" "compare")])
466 (define_expand "extendhidi2"
467   [(set (match_operand:DI 0 "gpc_reg_operand" "")
468         (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
469   "TARGET_POWERPC64"
470   "")
472 (define_insn ""
473   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
474         (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
475   "TARGET_POWERPC64"
476   "@
477    lha%U1%X1 %0,%1
478    extsh %0,%1"
479   [(set_attr "type" "load,*")])
481 (define_insn ""
482   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
483         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
484                     (const_int 0)))
485    (clobber (match_scratch:DI 2 "=r"))]
486   "TARGET_POWERPC64"
487   "extsh. %2,%1"
488   [(set_attr "type" "compare")])
490 (define_insn ""
491   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
492         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
493                     (const_int 0)))
494    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
495         (sign_extend:DI (match_dup 1)))]
496   "TARGET_POWERPC64"
497   "extsh. %0,%1"
498   [(set_attr "type" "compare")])
500 (define_expand "zero_extendsidi2"
501   [(set (match_operand:DI 0 "gpc_reg_operand" "")
502         (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
503   "TARGET_POWERPC64"
504   "")
506 (define_insn ""
507   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
508         (zero_extend:DI (match_operand:SI 1 "reg_or_mem_operand" "m,r")))]
509   "TARGET_POWERPC64"
510   "@
511    lwz%U1%X1 %0,%1
512    rldicl %0,%1,0,32"
513   [(set_attr "type" "load,*")])
515 (define_insn ""
516   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
517         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
518                     (const_int 0)))
519    (clobber (match_scratch:DI 2 "=r"))]
520   "TARGET_POWERPC64"
521   "rldicl. %2,%1,0,32"
522   [(set_attr "type" "compare")])
524 (define_insn ""
525   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
526         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
527                     (const_int 0)))
528    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
529         (zero_extend:DI (match_dup 1)))]
530   "TARGET_POWERPC64"
531   "rldicl. %0,%1,0,32"
532   [(set_attr "type" "compare")])
534 (define_expand "extendsidi2"
535   [(set (match_operand:DI 0 "gpc_reg_operand" "")
536         (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
537   "TARGET_POWERPC64"
538   "")
540 (define_insn ""
541   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
542         (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
543   "TARGET_POWERPC64"
544   "@
545    lwa%U1%X1 %0,%1
546    extsw %0,%1"
547   [(set_attr "type" "load,*")])
549 (define_insn ""
550   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
551         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
552                     (const_int 0)))
553    (clobber (match_scratch:DI 2 "=r"))]
554   "TARGET_POWERPC64"
555   "extsw. %2,%1"
556   [(set_attr "type" "compare")])
558 (define_insn ""
559   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
560         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
561                     (const_int 0)))
562    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
563         (sign_extend:DI (match_dup 1)))]
564   "TARGET_POWERPC64"
565   "extsw. %0,%1"
566   [(set_attr "type" "compare")])
568 (define_expand "zero_extendqisi2"
569   [(set (match_operand:SI 0 "gpc_reg_operand" "")
570         (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
571   ""
572   "")
574 (define_insn ""
575   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
576         (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
577   ""
578   "@
579    lbz%U1%X1 %0,%1
580    {rlinm|rlwinm} %0,%1,0,0xff"
581   [(set_attr "type" "load,*")])
583 (define_insn ""
584   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
585         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
586                     (const_int 0)))
587    (clobber (match_scratch:SI 2 "=r"))]
588   ""
589   "{andil.|andi.} %2,%1,0xff"
590   [(set_attr "type" "compare")])
592 (define_insn ""
593   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
594         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
595                     (const_int 0)))
596    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
597         (zero_extend:SI (match_dup 1)))]
598   ""
599   "{andil.|andi.} %0,%1,0xff"
600   [(set_attr "type" "compare")])
602 (define_expand "extendqisi2"
603   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
604    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
605   ""
606   "
608   if (TARGET_POWERPC)
609     emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
610   else if (TARGET_POWER)
611     emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
612   else
613     emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
614   DONE;
617 (define_insn "extendqisi2_ppc"
618   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
619         (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
620   "TARGET_POWERPC"
621   "extsb %0,%1")
623 (define_insn ""
624   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
625         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
626                     (const_int 0)))
627    (clobber (match_scratch:SI 2 "=r"))]
628   "TARGET_POWERPC"
629   "extsb. %2,%1"
630   [(set_attr "type" "compare")])
632 (define_insn ""
633   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
634         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
635                     (const_int 0)))
636    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
637         (sign_extend:SI (match_dup 1)))]
638   "TARGET_POWERPC"
639   "extsb. %0,%1"
640   [(set_attr "type" "compare")])
642 (define_expand "extendqisi2_power"
643   [(parallel [(set (match_dup 2)
644                    (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
645                               (const_int 24)))
646               (clobber (scratch:SI))])
647    (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
648                    (ashiftrt:SI (match_dup 2)
649                                 (const_int 24)))
650               (clobber (scratch:SI))])]
651   "TARGET_POWER"
652   "
653 { operands[1] = gen_lowpart (SImode, operands[1]);
654   operands[2] = gen_reg_rtx (SImode); }")
656 (define_expand "extendqisi2_no_power"
657   [(set (match_dup 2)
658         (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
659                    (const_int 24)))
660    (set (match_operand:SI 0 "gpc_reg_operand" "")
661         (ashiftrt:SI (match_dup 2)
662                      (const_int 24)))]
663   "! TARGET_POWER && ! TARGET_POWERPC"
664   "
665 { operands[1] = gen_lowpart (SImode, operands[1]);
666   operands[2] = gen_reg_rtx (SImode); }")
668 (define_expand "zero_extendqihi2"
669   [(set (match_operand:HI 0 "gpc_reg_operand" "")
670         (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
671   ""
672   "")
674 (define_insn ""
675   [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
676         (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
677   ""
678   "@
679    lbz%U1%X1 %0,%1
680    {rlinm|rlwinm} %0,%1,0,0xff"
681   [(set_attr "type" "load,*")])
683 (define_insn ""
684   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
685         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
686                     (const_int 0)))
687    (clobber (match_scratch:HI 2 "=r"))]
688   ""
689   "{andil.|andi.} %2,%1,0xff"
690   [(set_attr "type" "compare")])
692 (define_insn ""
693   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
694         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
695                     (const_int 0)))
696    (set (match_operand:HI 0 "gpc_reg_operand" "=r")
697         (zero_extend:HI (match_dup 1)))]
698   ""
699   "{andil.|andi.} %0,%1,0xff"
700   [(set_attr "type" "compare")])
702 (define_expand "extendqihi2"
703   [(use (match_operand:HI 0 "gpc_reg_operand" ""))
704    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
705   ""
706   "
708   if (TARGET_POWERPC)
709     emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
710   else if (TARGET_POWER)
711     emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
712   else
713     emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
714   DONE;
717 (define_insn "extendqihi2_ppc"
718   [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
719         (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
720   "TARGET_POWERPC"
721   "extsb %0,%1")
723 (define_insn ""
724   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
725         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
726                     (const_int 0)))
727    (clobber (match_scratch:HI 2 "=r"))]
728   "TARGET_POWERPC"
729   "extsb. %2,%1"
730   [(set_attr "type" "compare")])
732 (define_insn ""
733   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
734         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
735                     (const_int 0)))
736    (set (match_operand:HI 0 "gpc_reg_operand" "=r")
737         (sign_extend:HI (match_dup 1)))]
738   "TARGET_POWERPC"
739   "extsb. %0,%1"
740   [(set_attr "type" "compare")])
742 (define_expand "extendqihi2_power"
743   [(parallel [(set (match_dup 2)
744                    (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
745                               (const_int 24)))
746               (clobber (scratch:SI))])
747    (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
748                    (ashiftrt:SI (match_dup 2)
749                                 (const_int 24)))
750               (clobber (scratch:SI))])]
751   "TARGET_POWER"
752   "
753 { operands[0] = gen_lowpart (SImode, operands[0]);
754   operands[1] = gen_lowpart (SImode, operands[1]);
755   operands[2] = gen_reg_rtx (SImode); }")
757 (define_expand "extendqihi2_no_power"
758   [(set (match_dup 2)
759         (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
760                    (const_int 24)))
761    (set (match_operand:HI 0 "gpc_reg_operand" "")
762         (ashiftrt:SI (match_dup 2)
763                      (const_int 24)))]
764   "! TARGET_POWER && ! TARGET_POWERPC"
765   "
766 { operands[0] = gen_lowpart (SImode, operands[0]);
767   operands[1] = gen_lowpart (SImode, operands[1]);
768   operands[2] = gen_reg_rtx (SImode); }")
770 (define_expand "zero_extendhisi2"
771   [(set (match_operand:SI 0 "gpc_reg_operand" "")
772         (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
773   ""
774   "")
776 (define_insn ""
777   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
778         (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
779   ""
780   "@
781    lhz%U1%X1 %0,%1
782    {rlinm|rlwinm} %0,%1,0,0xffff"
783   [(set_attr "type" "load,*")])
785 (define_insn ""
786   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
787         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
788                     (const_int 0)))
789    (clobber (match_scratch:SI 2 "=r"))]
790   ""
791   "{andil.|andi.} %2,%1,0xffff"
792   [(set_attr "type" "compare")])
794 (define_insn ""
795   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
796         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
797                     (const_int 0)))
798    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
799         (zero_extend:SI (match_dup 1)))]
800   ""
801   "{andil.|andi.} %0,%1,0xffff"
802   [(set_attr "type" "compare")])
804 (define_expand "extendhisi2"
805   [(set (match_operand:SI 0 "gpc_reg_operand" "")
806         (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
807   ""
808   "")
810 (define_insn ""
811   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
812         (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
813   ""
814   "@
815    lha%U1%X1 %0,%1
816    {exts|extsh} %0,%1"
817   [(set_attr "type" "load,*")])
819 (define_insn ""
820   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
821         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
822                     (const_int 0)))
823    (clobber (match_scratch:SI 2 "=r"))]
824   ""
825   "{exts.|extsh.} %2,%1"
826   [(set_attr "type" "compare")])
828 (define_insn ""
829   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
830         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
831                     (const_int 0)))
832    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
833         (sign_extend:SI (match_dup 1)))]
834   ""
835   "{exts.|extsh.} %0,%1"
836   [(set_attr "type" "compare")])
838 ;; Fixed-point arithmetic insns.
840 ;; Discourage ai/addic because of carry but provide it in an alternative
841 ;; allowing register zero as source.
842 (define_insn "addsi3"
843   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,?r,r")
844         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,b,r,b")
845                  (match_operand:SI 2 "add_operand" "r,I,I,J")))]
846   ""
847   "@
848    {cax|add} %0,%1,%2
849    {cal %0,%2(%1)|addi %0,%1,%2}
850    {ai|addic} %0,%1,%2
851    {cau|addis} %0,%1,%u2")
853 (define_insn ""
854   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
855         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
856                              (match_operand:SI 2 "reg_or_short_operand" "r,I"))
857                     (const_int 0)))
858    (clobber (match_scratch:SI 3 "=r,r"))]
859   ""
860   "@
861    {cax.|add.} %3,%1,%2
862    {ai.|addic.} %3,%1,%2"
863   [(set_attr "type" "compare")])
865 (define_insn ""
866   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
867         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
868                              (match_operand:SI 2 "reg_or_short_operand" "r,I"))
869                     (const_int 0)))
870    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
871         (plus:SI (match_dup 1) (match_dup 2)))]
872   ""
873   "@
874    {cax.|add.} %0,%1,%2
875    {ai.|addic.} %0,%1,%2"
876   [(set_attr "type" "compare")])
878 ;; Split an add that we can't do in one insn into two insns, each of which
879 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
880 ;; add should be last in case the result gets used in an address.
882 (define_split
883   [(set (match_operand:SI 0 "gpc_reg_operand" "")
884         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
885                  (match_operand:SI 2 "non_add_cint_operand" "")))]
886   ""
887   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
888    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
891   int low = INTVAL (operands[2]) & 0xffff;
892   int high = (unsigned) INTVAL (operands[2]) >> 16;
894   if (low & 0x8000)
895     high++, low |= 0xffff0000;
897   operands[3] = gen_rtx (CONST_INT, VOIDmode, high << 16);
898   operands[4] = gen_rtx (CONST_INT, VOIDmode, low);
901 (define_insn "one_cmplsi2"
902   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
903         (not:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
904   ""
905   "nor %0,%1,%1")
907 (define_insn ""
908   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
909         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
910                     (const_int 0)))
911    (clobber (match_scratch:SI 2 "=r"))]
912   ""
913   "nor. %2,%1,%1"
914   [(set_attr "type" "compare")])
916 (define_insn ""
917   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
918         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
919                     (const_int 0)))
920    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
921         (not:SI (match_dup 1)))]
922   ""
923   "nor. %0,%2,%1"
924   [(set_attr "type" "compare")])
926 (define_insn ""
927   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
928         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
929                   (match_operand:SI 2 "gpc_reg_operand" "r")))]
930   "! TARGET_POWERPC"
931   "{sf%I1|subf%I1c} %0,%2,%1")
933 (define_insn ""
934   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
935         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "r,I")
936                   (match_operand:SI 2 "gpc_reg_operand" "r,r")))]
937   "TARGET_POWERPC"
938   "@
939    subf %0,%2,%1
940    subfic %0,%2,%1")
942 (define_insn ""
943   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
944         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
945                               (match_operand:SI 2 "gpc_reg_operand" "r"))
946                     (const_int 0)))
947    (clobber (match_scratch:SI 3 "=r"))]
948   "! TARGET_POWERPC"
949   "{sf.|subfc.} %3,%2,%1"
950   [(set_attr "type" "compare")])
952 (define_insn ""
953   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
954         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
955                               (match_operand:SI 2 "gpc_reg_operand" "r"))
956                     (const_int 0)))
957    (clobber (match_scratch:SI 3 "=r"))]
958   "TARGET_POWERPC"
959   "subf. %3,%2,%1"
960   [(set_attr "type" "compare")])
962 (define_insn ""
963   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
964         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
965                               (match_operand:SI 2 "gpc_reg_operand" "r"))
966                     (const_int 0)))
967    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
968         (minus:SI (match_dup 1) (match_dup 2)))]
969   "! TARGET_POWERPC"
970   "{sf.|subfc.} %0,%2,%1"
971   [(set_attr "type" "compare")])
973 (define_insn ""
974   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
975         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
976                               (match_operand:SI 2 "gpc_reg_operand" "r"))
977                     (const_int 0)))
978    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
979         (minus:SI (match_dup 1) (match_dup 2)))]
980   "TARGET_POWERPC"
981   "subf. %0,%2,%1"
982   [(set_attr "type" "compare")])
984 (define_expand "subsi3"
985   [(set (match_operand:SI 0 "gpc_reg_operand" "")
986         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "")
987                   (match_operand:SI 2 "reg_or_cint_operand" "")))]
988   ""
989   "
991   if (GET_CODE (operands[2]) == CONST_INT)
992     {
993       emit_insn (gen_addsi3 (operands[0], operands[1],
994                              negate_rtx (SImode, operands[2])));
995       DONE;
996     }
999 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1000 ;; instruction and some auxiliary computations.  Then we just have a single
1001 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1002 ;; combine.
1004 (define_expand "sminsi3"
1005   [(set (match_dup 3)
1006         (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1007                                 (match_operand:SI 2 "reg_or_short_operand" ""))
1008                          (const_int 0)
1009                          (minus:SI (match_dup 2) (match_dup 1))))
1010    (set (match_operand:SI 0 "gpc_reg_operand" "")
1011         (minus:SI (match_dup 2) (match_dup 3)))]
1012   "TARGET_POWER"
1013   "
1014 { operands[3] = gen_reg_rtx (SImode); }")
1016 (define_split
1017   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1018         (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1019                  (match_operand:SI 2 "reg_or_short_operand" "")))
1020    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1021   "TARGET_POWER"
1022   [(set (match_dup 3)
1023         (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1024                          (const_int 0)
1025                          (minus:SI (match_dup 2) (match_dup 1))))
1026    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1027   "")
1029 (define_expand "smaxsi3"
1030   [(set (match_dup 3)
1031         (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1032                                 (match_operand:SI 2 "reg_or_short_operand" ""))
1033                          (const_int 0)
1034                          (minus:SI (match_dup 2) (match_dup 1))))
1035    (set (match_operand:SI 0 "gpc_reg_operand" "")
1036         (plus:SI (match_dup 3) (match_dup 1)))]
1037   "TARGET_POWER"
1038   "
1039 { operands[3] = gen_reg_rtx (SImode); }")
1041 (define_split
1042   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1043         (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1044                  (match_operand:SI 2 "reg_or_short_operand" "")))
1045    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1046   "TARGET_POWER"
1047   [(set (match_dup 3)
1048         (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1049                          (const_int 0)
1050                          (minus:SI (match_dup 2) (match_dup 1))))
1051    (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1052   "")
1054 (define_expand "uminsi3"
1055   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1056                               (match_dup 5)))
1057    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1058                               (match_dup 5)))
1059    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1060                                        (const_int 0)
1061                                        (minus:SI (match_dup 4) (match_dup 3))))
1062    (set (match_operand:SI 0 "gpc_reg_operand" "")
1063         (minus:SI (match_dup 2) (match_dup 3)))]
1064   "TARGET_POWER"
1065   "
1067   operands[3] = gen_reg_rtx (SImode);
1068   operands[4] = gen_reg_rtx (SImode);
1069   operands[5] = GEN_INT (-2147483647 - 1);
1072 (define_expand "umaxsi3"
1073   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1074                               (match_dup 5)))
1075    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1076                               (match_dup 5)))
1077    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1078                                        (const_int 0)
1079                                        (minus:SI (match_dup 4) (match_dup 3))))
1080    (set (match_operand:SI 0 "gpc_reg_operand" "")
1081         (plus:SI (match_dup 3) (match_dup 1)))]
1082   "TARGET_POWER"
1083   "
1085   operands[3] = gen_reg_rtx (SImode);
1086   operands[4] = gen_reg_rtx (SImode);
1087   operands[5] = GEN_INT (-2147483647 - 1);
1090 (define_insn ""
1091   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1092         (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1093                              (match_operand:SI 2 "reg_or_short_operand" "rI"))
1094                          (const_int 0)
1095                          (minus:SI (match_dup 2) (match_dup 1))))]
1096   "TARGET_POWER"
1097   "doz%I2 %0,%1,%2")
1099 (define_insn ""
1100   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1101         (compare:CC
1102          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1103                               (match_operand:SI 2 "reg_or_short_operand" "rI"))
1104                           (const_int 0)
1105                           (minus:SI (match_dup 2) (match_dup 1)))
1106          (const_int 0)))
1107    (clobber (match_scratch:SI 3 "=r"))]
1108   "TARGET_POWER"
1109   "doz%I2. %3,%1,%2"
1110   [(set_attr "type" "delayed_compare")])
1112 (define_insn ""
1113   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1114         (compare:CC
1115          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1116                               (match_operand:SI 2 "reg_or_short_operand" "rI"))
1117                           (const_int 0)
1118                           (minus:SI (match_dup 2) (match_dup 1)))
1119          (const_int 0)))
1120    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1121         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1122                          (const_int 0)
1123                          (minus:SI (match_dup 2) (match_dup 1))))]
1124   "TARGET_POWER"
1125   "doz%I2. %0,%1,%2"
1126   [(set_attr "type" "delayed_compare")])
1128 ;; We don't need abs with condition code because such comparisons should
1129 ;; never be done.
1130 (define_expand "abssi2"
1131   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1132         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1133   ""
1134   "
1136   if (!TARGET_POWER)
1137     {
1138       emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
1139       DONE;
1140     }
1143 (define_insn "abssi2_power"
1144   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1145         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1146   "TARGET_POWER"
1147   "abs %0,%1")
1149 (define_insn "abssi2_nopower"
1150   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1151         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
1152    (clobber (match_scratch:SI 2 "=&r,&r"))]
1153   "!TARGET_POWER"
1154   "*
1156   return (TARGET_POWERPC)
1157     ? \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;subf %0,%2,%0\"
1158     : \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;{sf|subfc} %0,%2,%0\";
1160   [(set_attr "length" "12")])
1162 (define_split
1163   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1164         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
1165    (clobber (match_scratch:SI 2 "=&r,&r"))]
1166   "!TARGET_POWER && reload_completed"
1167   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1168    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1169    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
1170   "")
1172 (define_insn ""
1173   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1174         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
1175   "TARGET_POWER"
1176   "nabs %0,%1")
1178 (define_insn ""
1179   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1180         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
1181    (clobber (match_scratch:SI 2 "=&r,&r"))]
1182   "!TARGET_POWER"
1183   "*
1185   return (TARGET_POWERPC)
1186     ? \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;subf %0,%0,%2\"
1187     : \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;{sf|subfc} %0,%0,%2\";
1189   [(set_attr "length" "12")])
1191 (define_split
1192   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1193         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
1194    (clobber (match_scratch:SI 2 "=&r,&r"))]
1195   "!TARGET_POWER && reload_completed"
1196   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1197    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1198    (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
1199   "")
1201 (define_insn "negsi2"
1202   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1203         (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1204   ""
1205   "neg %0,%1")
1207 (define_insn ""
1208   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1209         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1210                     (const_int 0)))
1211    (clobber (match_scratch:SI 2 "=r"))]
1212   ""
1213   "neg. %2,%1"
1214   [(set_attr "type" "compare")])
1216 (define_insn ""
1217   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
1218         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1219                     (const_int 0)))
1220    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1221         (neg:SI (match_dup 1)))]
1222   ""
1223   "neg. %0,%1"
1224   [(set_attr "type" "compare")])
1226 (define_insn "ffssi2"
1227   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
1228         (ffs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1229   ""
1230   "neg %0,%1\;and %0,%0,%1\;{cntlz|cntlzw} %0,%0\;{sfi|subfic} %0,%0,32"
1231   [(set_attr "length" "16")])
1233 (define_expand "mulsi3"
1234   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1235    (use (match_operand:SI 1 "gpc_reg_operand" ""))
1236    (use (match_operand:SI 2 "reg_or_short_operand" ""))]
1237   ""
1238   "
1240   if (TARGET_POWER)
1241     emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
1242   else
1243     emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
1244   DONE;
1247 (define_insn "mulsi3_mq"
1248   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1249         (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1250                  (match_operand:SI 2 "reg_or_short_operand" "r,I")))
1251    (clobber (match_scratch:SI 3 "=q,q"))]
1252   "TARGET_POWER"
1253   "@
1254    {muls|mullw} %0,%1,%2
1255    {muli|mulli} %0,%1,%2"
1256    [(set_attr "type" "imul")])
1258 (define_insn "mulsi3_no_mq"
1259   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1260         (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1261                  (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
1262   "! TARGET_POWER"
1263   "@
1264    {muls|mullw} %0,%1,%2
1265    {muli|mulli} %0,%1,%2"
1266    [(set_attr "type" "imul")])
1268 (define_insn ""
1269   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1270         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1271                              (match_operand:SI 2 "gpc_reg_operand" "r"))
1272                     (const_int 0)))
1273    (clobber (match_scratch:SI 3 "=r"))
1274    (clobber (match_scratch:SI 4 "=q"))]
1275   "TARGET_POWER"
1276   "{muls.|mullw.} %3,%1,%2"
1277   [(set_attr "type" "delayed_compare")])
1279 (define_insn ""
1280   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1281         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1282                              (match_operand:SI 2 "gpc_reg_operand" "r"))
1283                     (const_int 0)))
1284    (clobber (match_scratch:SI 3 "=r"))]
1285   "! TARGET_POWER"
1286   "{muls.|mullw.} %3,%1,%2"
1287   [(set_attr "type" "delayed_compare")])
1289 (define_insn ""
1290   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1291         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1292                              (match_operand:SI 2 "gpc_reg_operand" "r"))
1293                     (const_int 0)))
1294    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1295         (mult:SI (match_dup 1) (match_dup 2)))
1296    (clobber (match_scratch:SI 4 "=q"))]
1297   "TARGET_POWER"
1298   "{muls.|mullw.} %0,%1,%2"
1299   [(set_attr "type" "delayed_compare")])
1301 (define_insn ""
1302   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1303         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1304                              (match_operand:SI 2 "gpc_reg_operand" "r"))
1305                     (const_int 0)))
1306    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1307         (mult:SI (match_dup 1) (match_dup 2)))]
1308   "! TARGET_POWER"
1309   "{muls.|mullw.} %0,%1,%2"
1310   [(set_attr "type" "delayed_compare")])
1312 ;; Operand 1 is divided by operand 2; quotient goes to operand
1313 ;; 0 and remainder to operand 3.
1314 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
1316 (define_expand "divmodsi4"
1317   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1318                    (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1319                            (match_operand:SI 2 "gpc_reg_operand" "")))
1320               (set (match_operand:SI 3 "gpc_reg_operand" "")
1321                    (mod:SI (match_dup 1) (match_dup 2)))])]
1322   "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
1323   "
1325   if (! TARGET_POWER && ! TARGET_POWERPC)
1326     {
1327       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
1328       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
1329       emit_insn (gen_divss_call ());
1330       emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
1331       emit_move_insn (operands[3], gen_rtx (REG, SImode, 4));
1332       DONE;
1333     }
1336 (define_insn ""
1337   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1338         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1339                 (match_operand:SI 2 "gpc_reg_operand" "r")))
1340    (set (match_operand:SI 3 "gpc_reg_operand" "=q")
1341         (mod:SI (match_dup 1) (match_dup 2)))]
1342   "TARGET_POWER"
1343   "divs %0,%1,%2"
1344   [(set_attr "type" "idiv")])
1346 (define_insn ""
1347   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1348         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1349                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1350   "TARGET_POWERPC"
1351   "divw %0,%1,%2"
1352   [(set_attr "type" "idiv")])
1354 (define_expand "udivsi3"
1355   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1356         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1357                  (match_operand:SI 2 "gpc_reg_operand" "")))]
1358   "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
1359   "
1361   if (! TARGET_POWER && ! TARGET_POWERPC)
1362     {
1363       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
1364       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
1365       emit_insn (gen_quous_call ());
1366       emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
1367       DONE;
1368     }
1371 (define_insn ""
1372   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1373         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1374                  (match_operand:SI 2 "gpc_reg_operand" "r")))]
1375   "TARGET_POWERPC"
1376   "divwu %0,%1,%2"
1377   [(set_attr "type" "idiv")])
1379 ;; For powers of two we can do srai/aze for divide and then adjust for
1380 ;; modulus.  If it isn't a power of two, FAIL on POWER so divmodsi4 will be
1381 ;; used; for PowerPC, force operands into register and do a normal divide;
1382 ;; for AIX common-mode, use quoss call on register operands.
1383 (define_expand "divsi3"
1384   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1385         (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1386                 (match_operand:SI 2 "reg_or_cint_operand" "")))]
1387   ""
1388   "
1390   if (GET_CODE (operands[2]) == CONST_INT
1391       && exact_log2 (INTVAL (operands[2])) >= 0)
1392     ;
1393   else if (TARGET_POWERPC)
1394     operands[2] = force_reg (SImode, operands[2]);
1395   else if (TARGET_POWER)
1396     FAIL;
1397   else
1398     {
1399       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
1400       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
1401       emit_insn (gen_quoss_call ());
1402       emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
1403       DONE;
1404     }
1407 (define_expand "modsi3"
1408   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1409    (use (match_operand:SI 1 "gpc_reg_operand" ""))
1410    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
1411   ""
1412   "
1414   int i = exact_log2 (INTVAL (operands[2]));
1415   rtx temp1;
1416   rtx temp2;
1418   if (GET_CODE (operands[2]) != CONST_INT || i < 0)
1419     FAIL;
1421   temp1 = gen_reg_rtx (SImode);
1422   temp2 = gen_reg_rtx (SImode);
1424   emit_insn (gen_divsi3 (temp1, operands[1], operands[2]));
1425   emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i)));
1426   emit_insn (gen_subsi3 (operands[0], operands[1], temp2));
1427   DONE;
1430 (define_insn ""
1431   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1432         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1433                 (match_operand:SI 2 "const_int_operand" "N")))]
1434   "exact_log2 (INTVAL (operands[2])) >= 0"
1435   "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
1436   [(set_attr "length" "8")])
1438 (define_insn ""
1439   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1440         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1441                             (match_operand:SI 2 "const_int_operand" "N"))
1442                     (const_int 0)))
1443    (clobber (match_scratch:SI 3 "=r"))]
1444   "exact_log2 (INTVAL (operands[2])) >= 0"
1445   "{srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3"
1446   [(set_attr "type" "compare")
1447    (set_attr "length" "8")])
1449 (define_insn ""
1450   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1451         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1452                             (match_operand:SI 2 "const_int_operand" "N"))
1453                     (const_int 0)))
1454    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1455         (div:SI (match_dup 1) (match_dup 2)))]
1456   "exact_log2 (INTVAL (operands[2])) >= 0"
1457   "{srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0"
1458   [(set_attr "type" "compare")
1459    (set_attr "length" "8")])
1461 (define_insn ""
1462   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1463         (udiv:SI
1464          (plus:DI (ashift:DI
1465                    (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
1466                    (const_int 32))
1467                   (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
1468          (match_operand:SI 3 "gpc_reg_operand" "r")))
1469    (set (match_operand:SI 2 "register_operand" "=*q")
1470         (umod:SI
1471          (plus:DI (ashift:DI
1472                    (zero_extend:DI (match_dup 1)) (const_int 32))
1473                   (zero_extend:DI (match_dup 4)))
1474          (match_dup 3)))]
1475   "TARGET_POWER"
1476   "div %0,%1,%3"
1477   [(set_attr "type" "idiv")])
1479 ;; To do unsigned divide we handle the cases of the divisor looking like a
1480 ;; negative number.  If it is a constant that is less than 2**31, we don't
1481 ;; have to worry about the branches.  So make a few subroutines here.
1483 ;; First comes the normal case.
1484 (define_expand "udivmodsi4_normal"
1485   [(set (match_dup 4) (const_int 0))
1486    (parallel [(set (match_operand:SI 0 "" "")
1487                    (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
1488                                                 (const_int 32))
1489                                      (zero_extend:DI (match_operand:SI 1 "" "")))
1490                             (match_operand:SI 2 "" "")))
1491               (set (match_operand:SI 3 "" "")
1492                    (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
1493                                                 (const_int 32))
1494                                      (zero_extend:DI (match_dup 1)))
1495                             (match_dup 2)))])]
1496   "TARGET_POWER"
1497   "
1498 { operands[4] = gen_reg_rtx (SImode); }")
1500 ;; This handles the branches.
1501 (define_expand "udivmodsi4_tests"
1502   [(set (match_operand:SI 0 "" "") (const_int 0))
1503    (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
1504    (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
1505    (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
1506                            (label_ref (match_operand:SI 4 "" "")) (pc)))
1507    (set (match_dup 0) (const_int 1))
1508    (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
1509    (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
1510    (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
1511                            (label_ref (match_dup 4)) (pc)))]
1512   "TARGET_POWER"
1513   "
1514 { operands[5] = gen_reg_rtx (CCUNSmode);
1515   operands[6] = gen_reg_rtx (CCmode);
1518 (define_expand "udivmodsi4"
1519   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1520                    (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1521                             (match_operand:SI 2 "reg_or_cint_operand" "")))
1522               (set (match_operand:SI 3 "gpc_reg_operand" "")
1523                    (umod:SI (match_dup 1) (match_dup 2)))])]
1524   ""
1525   "
1527   rtx label = 0;
1529   if (! TARGET_POWER)
1530     if (! TARGET_POWERPC)
1531       {
1532         emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
1533         emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
1534         emit_insn (gen_divus_call ());
1535         emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
1536         emit_move_insn (operands[3], gen_rtx (REG, SImode, 4));
1537         DONE;
1538       }
1539     else
1540       FAIL;
1542   if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
1543     {
1544       operands[2] = force_reg (SImode, operands[2]);
1545       label = gen_label_rtx ();
1546       emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
1547                                   operands[3], label));
1548     }
1549   else
1550     operands[2] = force_reg (SImode, operands[2]);
1552   emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
1553                                operands[3]));
1554   if (label)
1555     emit_label (label);
1557   DONE;
1560 ;; AIX architecture-independent common-mode multiply (DImode),
1561 ;; divide/modulus, and quotient subroutine calls.  Input operands in R3 and
1562 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
1563 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
1564 ;; assumed unused if generating common-mode, so ignore.
1565 (define_insn "mulh_call"
1566   [(set (reg:SI 3)
1567         (truncate:SI
1568          (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
1569                                (sign_extend:DI (reg:SI 4)))
1570                       (const_int 32))))
1571    (clobber (match_scratch:SI 0 "=l"))]
1572   "! TARGET_POWER && ! TARGET_POWERPC"
1573   "bla __mulh")
1575 (define_insn "mull_call"
1576   [(set (reg:DI 3)
1577         (mult:DI (sign_extend:DI (reg:SI 3))
1578                  (sign_extend:DI (reg:SI 4))))
1579    (clobber (match_scratch:SI 0 "=l"))
1580    (clobber (reg:SI 0))]
1581   "! TARGET_POWER && ! TARGET_POWERPC"
1582   "bla __mull")
1584 (define_insn "divss_call"
1585   [(set (reg:SI 3)
1586         (div:SI (reg:SI 3) (reg:SI 4)))
1587    (set (reg:SI 4)
1588         (mod:SI (reg:SI 3) (reg:SI 4)))
1589    (clobber (match_scratch:SI 0 "=l"))
1590    (clobber (reg:SI 0))]
1591   "! TARGET_POWER && ! TARGET_POWERPC"
1592   "bla __divss")
1594 (define_insn "divus_call"
1595   [(set (reg:SI 3)
1596         (udiv:SI (reg:SI 3) (reg:SI 4)))
1597    (set (reg:SI 4)
1598         (umod:SI (reg:SI 3) (reg:SI 4)))
1599    (clobber (match_scratch:SI 0 "=l"))
1600    (clobber (reg:SI 0))
1601    (clobber (match_scratch:CC 1 "=x"))
1602    (clobber (reg:CC 69))]
1603   "! TARGET_POWER && ! TARGET_POWERPC"
1604   "bla __divus")
1606 (define_insn "quoss_call"
1607   [(set (reg:SI 3)
1608         (div:SI (reg:SI 3) (reg:SI 4)))
1609    (clobber (match_scratch:SI 0 "=l"))]
1610   "! TARGET_POWER && ! TARGET_POWERPC"
1611   "bla __quoss")
1613 (define_insn "quous_call"
1614   [(set (reg:SI 3)
1615         (udiv:SI (reg:SI 3) (reg:SI 4)))
1616    (clobber (match_scratch:SI 0 "=l"))
1617    (clobber (reg:SI 0))
1618    (clobber (match_scratch:CC 1 "=x"))
1619    (clobber (reg:CC 69))]
1620   "! TARGET_POWER && ! TARGET_POWERPC"
1621   "bla __quous")
1623 (define_insn "andsi3"
1624   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1625         (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1626                 (match_operand:SI 2 "and_operand" "?r,L,K,J")))
1627    (clobber (match_scratch:CC 3 "=X,X,x,x"))]
1628   ""
1629   "@
1630    and %0,%1,%2
1631    {rlinm|rlwinm} %0,%1,0,%m2,%M2
1632    {andil.|andi.} %0,%1,%b2
1633    {andiu.|andis.} %0,%1,%u2")
1635 (define_insn ""
1636   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x")
1637         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1638                             (match_operand:SI 2 "and_operand" "r,K,J,L"))
1639                     (const_int 0)))
1640    (clobber (match_scratch:SI 3 "=r,r,r,r"))]
1641   ""
1642   "@
1643    and. %3,%1,%2
1644    {andil.|andi.} %3,%1,%b2
1645    {andiu.|andis.} %3,%1,%u2
1646    {rlinm.|rlwinm.} %3,%1,0,%m2,%M2"
1647   [(set_attr "type" "compare,compare,compare,delayed_compare")])
1649 (define_insn ""
1650   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x")
1651         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1652                             (match_operand:SI 2 "and_operand" "r,K,J,L"))
1653                     (const_int 0)))
1654    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1655         (and:SI (match_dup 1) (match_dup 2)))]
1656   ""
1657   "@
1658    and. %0,%1,%2
1659    {andil.|andi.} %0,%1,%b2
1660    {andiu.|andis.} %0,%1,%u2
1661    {rlinm.|rlwinm.} %0,%1,0,%m2,%M2"
1662   [(set_attr "type" "compare,compare,compare,delayed_compare")])
1664 ;; Take a AND with a constant that cannot be done in a single insn and try to
1665 ;; split it into two insns.  This does not verify that the insns are valid
1666 ;; since this need not be done as combine will do it.
1668 (define_split
1669   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1670         (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
1671                 (match_operand:SI 2 "non_and_cint_operand" "")))]
1672   ""
1673   [(set (match_dup 0) (and:SI (match_dup 1) (match_dup 3)))
1674    (set (match_dup 0) (and:SI (match_dup 0) (match_dup 4)))]
1675   "
1677   int maskval = INTVAL (operands[2]);
1678   int i, transitions, last_bit_value;
1679   int orig = maskval, first_c = maskval, second_c;
1681   /* We know that MASKVAL must have more than 2 bit-transitions.  Start at
1682      the low-order bit and count for the third transition.  When we get there,
1683      make a first mask that has everything to the left of that position
1684      a one.  Then make the second mask to turn off whatever else is needed.  */
1686   for (i = 1, transitions = 0, last_bit_value = maskval & 1; i < 32; i++)
1687     {
1688       if (((maskval >>= 1) & 1) != last_bit_value)
1689         last_bit_value ^= 1, transitions++;
1691       if (transitions > 2)
1692         {
1693           first_c |= (~0) << i;
1694           break;
1695         }
1696     }
1698   second_c = orig | ~ first_c;
1700   operands[3] = gen_rtx (CONST_INT, VOIDmode, first_c);
1701   operands[4] = gen_rtx (CONST_INT, VOIDmode, second_c);
1704 (define_insn "iorsi3"
1705   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
1706         (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
1707                 (match_operand:SI 2 "logical_operand" "r,K,J")))]
1708   ""
1709   "@
1710    or %0,%1,%2
1711    {oril|ori} %0,%1,%b2
1712    {oriu|oris} %0,%1,%u2")
1714 (define_insn ""
1715   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1716         (compare:CC (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1717                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1718                     (const_int 0)))
1719    (clobber (match_scratch:SI 3 "=r"))]
1720   ""
1721   "or. %3,%1,%2"
1722   [(set_attr "type" "compare")])
1724 (define_insn ""
1725   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1726         (compare:CC (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1727                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1728                     (const_int 0)))
1729    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1730         (ior:SI (match_dup 1) (match_dup 2)))]
1731   ""
1732   "or. %0,%1,%2"
1733   [(set_attr "type" "compare")])
1735 ;; Split an IOR that we can't do in one insn into two insns, each of which
1736 ;; does one 16-bit part.  This is used by combine.
1738 (define_split
1739   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1740         (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
1741                 (match_operand:SI 2 "non_logical_cint_operand" "")))]
1742   ""
1743   [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 3)))
1744    (set (match_dup 0) (ior:SI (match_dup 0) (match_dup 4)))]
1747   operands[3] = gen_rtx (CONST_INT, VOIDmode,
1748                          INTVAL (operands[2]) & 0xffff0000);
1749   operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
1752 (define_insn "xorsi3"
1753   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
1754         (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
1755                 (match_operand:SI 2 "logical_operand" "r,K,J")))]
1756   ""
1757   "@
1758    xor %0,%1,%2
1759    {xoril|xori} %0,%1,%b2
1760    {xoriu|xoris} %0,%1,%u2")
1762 (define_insn ""
1763   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1764         (compare:CC (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1765                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1766                     (const_int 0)))
1767    (clobber (match_scratch:SI 3 "=r"))]
1768   ""
1769   "xor. %3,%1,%2"
1770   [(set_attr "type" "compare")])
1772 (define_insn ""
1773   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1774         (compare:CC (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1775                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1776                     (const_int 0)))
1777    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1778         (xor:SI (match_dup 1) (match_dup 2)))]
1779   ""
1780   "xor. %0,%1,%2"
1781   [(set_attr "type" "compare")])
1783 ;; Split an XOR that we can't do in one insn into two insns, each of which
1784 ;; does one 16-bit part.  This is used by combine.
1786 (define_split
1787   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1788         (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1789                 (match_operand:SI 2 "non_logical_cint_operand" "")))]
1790   ""
1791   [(set (match_dup 0) (xor:SI (match_dup 1) (match_dup 3)))
1792    (set (match_dup 0) (xor:SI (match_dup 0) (match_dup 4)))]
1795   operands[3] = gen_rtx (CONST_INT, VOIDmode,
1796                          INTVAL (operands[2]) & 0xffff0000);
1797   operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
1800 (define_insn ""
1801   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1802         (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1803                         (match_operand:SI 2 "gpc_reg_operand" "r"))))]
1804    ""
1805    "eqv %0,%1,%2")
1807 (define_insn ""
1808   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1809         (compare:CC (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1810                                     (match_operand:SI 2 "gpc_reg_operand" "r")))
1811                     (const_int 0)))
1812    (clobber (match_scratch:SI 3 "=r"))]
1813    ""
1814    "eqv. %3,%1,%2"
1815    [(set_attr "type" "compare")])
1817 (define_insn ""
1818   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1819         (compare:CC (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1820                                     (match_operand:SI 2 "gpc_reg_operand" "r")))
1821                     (const_int 0)))
1822    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1823         (not:SI (xor:SI (match_dup 1) (match_dup 2))))]
1824    ""
1825    "eqv. %0,%1,%2"
1826    [(set_attr "type" "compare")])
1828 (define_insn ""
1829   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1830         (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1831                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1832   ""
1833   "andc %0,%2,%1")
1835 (define_insn ""
1836   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1837         (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1838                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1839                     (const_int 0)))
1840    (clobber (match_scratch:SI 3 "=r"))]
1841   ""
1842   "andc. %3,%2,%1"
1843   [(set_attr "type" "compare")])
1845 (define_insn ""
1846   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1847         (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1848                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1849                     (const_int 0)))
1850    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1851         (and:SI (not:SI (match_dup 1)) (match_dup 2)))]
1852   ""
1853   "andc. %0,%2,%1"
1854   [(set_attr "type" "compare")])
1856 (define_insn ""
1857   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1858         (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1859                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1860   ""
1861   "orc %0,%2,%1")
1863 (define_insn ""
1864   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1865         (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1866                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1867                     (const_int 0)))
1868    (clobber (match_scratch:SI 3 "=r"))]
1869   ""
1870   "orc. %3,%2,%1"
1871   [(set_attr "type" "compare")])
1873 (define_insn ""
1874   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1875         (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1876                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1877                     (const_int 0)))
1878    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1879         (ior:SI (not:SI (match_dup 1)) (match_dup 2)))]
1880   ""
1881   "orc. %0,%2,%1"
1882   [(set_attr "type" "compare")])
1884 (define_insn ""
1885   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1886         (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1887                 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
1888   ""
1889   "nand %0,%1,%2")
1891 (define_insn ""
1892   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1893         (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1894                             (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1895                     (const_int 0)))
1896    (clobber (match_scratch:SI 3 "=r"))]
1897   ""
1898   "nand. %3,%1,%2"
1899   [(set_attr "type" "compare")])
1901 (define_insn ""
1902   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1903         (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1904                             (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1905                     (const_int 0)))
1906    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1907         (ior:SI (not:SI (match_dup 1)) (not:SI (match_dup 2))))]
1908   ""
1909   "nand. %0,%1,%2"
1910   [(set_attr "type" "compare")])
1912 (define_insn ""
1913   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1914         (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1915                 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
1916   ""
1917   "nor %0,%1,%2")
1919 (define_insn ""
1920   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1921         (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1922                             (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1923                     (const_int 0)))
1924    (clobber (match_scratch:SI 3 "=r"))]
1925   ""
1926   "nor. %3,%1,%2"
1927   [(set_attr "type" "compare")])
1929 (define_insn ""
1930   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1931         (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1932                             (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1933                     (const_int 0)))
1934    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1935         (and:SI (not:SI (match_dup 1)) (not:SI (match_dup 2))))]
1936   ""
1937   "nor. %0,%1,%2"
1938   [(set_attr "type" "compare")])
1940 ;; maskir insn.  We need four forms because things might be in arbitrary
1941 ;; orders.  Don't define forms that only set CR fields because these
1942 ;; would modify an input register.
1944 (define_insn ""
1945   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1946         (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
1947                         (match_operand:SI 1 "gpc_reg_operand" "0"))
1948                 (and:SI (match_dup 2)
1949                         (match_operand:SI 3 "gpc_reg_operand" "r"))))]
1950   "TARGET_POWER"
1951   "maskir %0,%3,%2")
1953 (define_insn ""
1954   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1955         (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
1956                         (match_operand:SI 1 "gpc_reg_operand" "0"))
1957                 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
1958                         (match_dup 2))))]
1959   "TARGET_POWER"
1960   "maskir %0,%3,%2")
1962 (define_insn ""
1963   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1964         (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1965                         (match_operand:SI 3 "gpc_reg_operand" "r"))
1966                 (and:SI (not:SI (match_dup 2))
1967                         (match_operand:SI 1 "gpc_reg_operand" "0"))))]
1968   "TARGET_POWER"
1969   "maskir %0,%3,%2")
1971 (define_insn ""
1972   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1973         (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
1974                         (match_operand:SI 2 "gpc_reg_operand" "r"))
1975                 (and:SI (not:SI (match_dup 2))
1976                         (match_operand:SI 1 "gpc_reg_operand" "0"))))]
1977   "TARGET_POWER"
1978   "maskir %0,%3,%2")
1980 (define_insn ""
1981   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
1982         (compare:CC
1983          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
1984                          (match_operand:SI 1 "gpc_reg_operand" "0"))
1985                  (and:SI (match_dup 2)
1986                          (match_operand:SI 3 "gpc_reg_operand" "r")))
1987          (const_int 0)))
1988    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1989         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
1990                 (and:SI (match_dup 2) (match_dup 3))))]
1991   "TARGET_POWER"
1992   "maskir. %0,%3,%2"
1993   [(set_attr "type" "compare")])
1995 (define_insn ""
1996   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
1997         (compare:CC
1998          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
1999                          (match_operand:SI 1 "gpc_reg_operand" "0"))
2000                  (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2001                          (match_dup 2)))
2002          (const_int 0)))
2003    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2004         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2005                 (and:SI (match_dup 3) (match_dup 2))))]
2006   "TARGET_POWER"
2007   "maskir. %0,%3,%2"
2008   [(set_attr "type" "compare")])
2010 (define_insn ""
2011   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2012         (compare:CC
2013          (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2014                          (match_operand:SI 3 "gpc_reg_operand" "r"))
2015                  (and:SI (not:SI (match_dup 2))
2016                          (match_operand:SI 1 "gpc_reg_operand" "0")))
2017          (const_int 0)))
2018    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2019         (ior:SI (and:SI (match_dup 2) (match_dup 3))
2020                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2021   "TARGET_POWER"
2022   "maskir. %0,%3,%2"
2023   [(set_attr "type" "compare")])
2025 (define_insn ""
2026   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2027         (compare:CC
2028          (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2029                          (match_operand:SI 2 "gpc_reg_operand" "r"))
2030                  (and:SI (not:SI (match_dup 2))
2031                          (match_operand:SI 1 "gpc_reg_operand" "0")))
2032          (const_int 0)))
2033    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2034         (ior:SI (and:SI (match_dup 3) (match_dup 2))
2035                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2036   "TARGET_POWER"
2037   "maskir. %0,%3,%2"
2038   [(set_attr "type" "compare")])
2040 ;; Rotate and shift insns, in all their variants.  These support shifts,
2041 ;; field inserts and extracts, and various combinations thereof.
2042 (define_expand "insv"
2043   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2044                          (match_operand:SI 1 "const_int_operand" "i")
2045                          (match_operand:SI 2 "const_int_operand" "i"))
2046         (match_operand:SI 3 "gpc_reg_operand" "r"))]
2047   ""
2048   "
2050   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
2051      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
2052      compiler if the address of the structure is taken later.  */
2053   if (GET_CODE (operands[0]) == SUBREG
2054       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
2055     FAIL;
2058 (define_insn ""
2059   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2060                          (match_operand:SI 1 "const_int_operand" "i")
2061                          (match_operand:SI 2 "const_int_operand" "i"))
2062         (match_operand:SI 3 "gpc_reg_operand" "r"))]
2063   ""
2064   "*
2066   int start = INTVAL (operands[2]) & 31;
2067   int size = INTVAL (operands[1]) & 31;
2069   operands[4] = gen_rtx (CONST_INT, VOIDmode, 32 - start - size);
2070   operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
2071   return \"{rlimi|rlwimi} %0,%3,%4,%h2,%h1\";
2074 (define_insn ""
2075   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2076                          (match_operand:SI 1 "const_int_operand" "i")
2077                          (match_operand:SI 2 "const_int_operand" "i"))
2078         (ashift:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2079                    (match_operand:SI 4 "const_int_operand" "i")))]
2080   ""
2081   "*
2083   int shift = INTVAL (operands[4]) & 31;
2084   int start = INTVAL (operands[2]) & 31;
2085   int size = INTVAL (operands[1]) & 31;
2087   operands[4] = gen_rtx (CONST_INT, VOIDmode, (shift - start - size) & 31);
2088   operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
2089   return \"{rlimi|rlwimi} %0,%3,%4,%h2,%h1\";
2092 (define_insn ""
2093   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2094                          (match_operand:SI 1 "const_int_operand" "i")
2095                          (match_operand:SI 2 "const_int_operand" "i"))
2096         (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2097                      (match_operand:SI 4 "const_int_operand" "i")))]
2098   ""
2099   "*
2101   int shift = INTVAL (operands[4]) & 31;
2102   int start = INTVAL (operands[2]) & 31;
2103   int size = INTVAL (operands[1]) & 31;
2105   operands[4] = gen_rtx (CONST_INT, VOIDmode, (32 - shift - start - size) & 31);
2106   operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
2107   return \"{rlimi|rlwimi} %0,%3,%4,%h2,%h1\";
2110 (define_insn ""
2111   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2112                          (match_operand:SI 1 "const_int_operand" "i")
2113                          (match_operand:SI 2 "const_int_operand" "i"))
2114         (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2115                      (match_operand:SI 4 "const_int_operand" "i")))]
2116   ""
2117   "*
2119   int shift = INTVAL (operands[4]) & 31;
2120   int start = INTVAL (operands[2]) & 31;
2121   int size = INTVAL (operands[1]) & 31;
2123   operands[4] = gen_rtx (CONST_INT, VOIDmode, (32 - shift - start - size) & 31);
2124   operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
2125   return \"{rlimi|rlwimi} %0,%3,%4,%h2,%h1\";
2128 (define_insn ""
2129   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2130                          (match_operand:SI 1 "const_int_operand" "i")
2131                          (match_operand:SI 2 "const_int_operand" "i"))
2132         (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2133                          (match_operand:SI 4 "const_int_operand" "i")
2134                          (match_operand:SI 5 "const_int_operand" "i")))]
2135   "INTVAL (operands[4]) >= INTVAL (operands[1])"
2136   "*
2138   int extract_start = INTVAL (operands[5]) & 31;
2139   int extract_size = INTVAL (operands[4]) & 31;
2140   int insert_start = INTVAL (operands[2]) & 31;
2141   int insert_size = INTVAL (operands[1]) & 31;
2143 /* Align extract field with insert field */
2144   operands[5] = gen_rtx (CONST_INT, VOIDmode,
2145                          (extract_start + extract_size - insert_start - insert_size) & 31);
2146   operands[1] = gen_rtx (CONST_INT, VOIDmode, insert_start + insert_size - 1);
2147   return \"{rlimi|rlwimi} %0,%3,%5,%h2,%h1\";
2150 (define_expand "extzv"
2151   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2152         (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2153                          (match_operand:SI 2 "const_int_operand" "i")
2154                          (match_operand:SI 3 "const_int_operand" "i")))]
2155   ""
2156   "
2158   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
2159      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
2160      compiler if the address of the structure is taken later.  */
2161   if (GET_CODE (operands[0]) == SUBREG
2162       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
2163     FAIL;
2166 (define_insn ""
2167   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2168         (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2169                          (match_operand:SI 2 "const_int_operand" "i")
2170                          (match_operand:SI 3 "const_int_operand" "i")))]
2171   ""
2172   "*
2174   int start = INTVAL (operands[3]) & 31;
2175   int size = INTVAL (operands[2]) & 31;
2177   if (start + size >= 32)
2178     operands[3] = const0_rtx;
2179   else
2180     operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2181   return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
2184 (define_insn ""
2185   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2186         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2187                          (match_operand:SI 2 "const_int_operand" "i")
2188                          (match_operand:SI 3 "const_int_operand" "i"))
2189                     (const_int 0)))
2190    (clobber (match_scratch:SI 4 "=r"))]
2191   ""
2192   "*
2194   int start = INTVAL (operands[3]) & 31;
2195   int size = INTVAL (operands[2]) & 31;
2197   /* If the bitfield being tested fits in the upper or lower half of a
2198      word, it is possible to use andiu. or andil. to test it.  This is
2199      useful because the condition register set-use delay is smaller for
2200      andi[ul]. than for rlinm.  This doesn't work when the starting bit
2201      position is 0 because the LT and GT bits may be set wrong.  */
2203   if ((start > 0 && start + size <= 16) || start >= 16)
2204     {
2205       operands[3] = gen_rtx (CONST_INT, VOIDmode,
2206                              ((1 << (16 - (start & 15)))
2207                               - (1 << (16 - (start & 15) - size))));
2208       if (start < 16)
2209         return \"{andiu.|andis.} %4,%1,%3\";
2210       else
2211         return \"{andil.|andi.} %4,%1,%3\";
2212     }
2214   if (start + size >= 32)
2215     operands[3] = const0_rtx;
2216   else
2217     operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2218   return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
2220   [(set_attr "type" "compare")])
2222 (define_insn ""
2223   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2224         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2225                          (match_operand:SI 2 "const_int_operand" "i")
2226                          (match_operand:SI 3 "const_int_operand" "i"))
2227                     (const_int 0)))
2228    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2229         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
2230   ""
2231   "*
2233   int start = INTVAL (operands[3]) & 31;
2234   int size = INTVAL (operands[2]) & 31;
2236   if (start >= 16 && start + size == 32)
2237     {
2238       operands[3] = gen_rtx (CONST_INT, VOIDmode, (1 << (32 - start)) - 1);
2239       return \"{andil.|andi.} %0,%1,%3\";
2240     }
2242   if (start + size >= 32)
2243     operands[3] = const0_rtx;
2244   else
2245     operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2246   return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
2248   [(set_attr "type" "delayed_compare")])
2250 (define_insn "rotlsi3"
2251   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2252         (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2253                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
2254   ""
2255   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffffffff")
2257 (define_insn ""
2258   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2259         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2260                                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2261                     (const_int 0)))
2262    (clobber (match_scratch:SI 3 "=r"))]
2263   ""
2264   "{rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffffffff"
2265   [(set_attr "type" "delayed_compare")])
2267 (define_insn ""
2268   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2269         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2270                                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2271                     (const_int 0)))
2272    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2273         (rotate:SI (match_dup 1) (match_dup 2)))]
2274   ""
2275   "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffffffff"
2276   [(set_attr "type" "delayed_compare")])
2278 (define_insn ""
2279   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2280         (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2281                            (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2282                 (match_operand:SI 3 "mask_operand" "L")))]
2283   ""
2284   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,%m3,%M3")
2286 (define_insn ""
2287   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2288         (compare:CC (and:SI
2289                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2290                                 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2291                      (match_operand:SI 3 "mask_operand" "L"))
2292                     (const_int 0)))
2293    (clobber (match_scratch:SI 4 "=r"))]
2294   ""
2295   "{rl%I2nm.|rlw%I2nm.} %4,%1,%h2,%m3,%M3"
2296   [(set_attr "type" "delayed_compare")])
2298 (define_insn ""
2299   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2300         (compare:CC (and:SI
2301                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2302                                 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2303                      (match_operand:SI 3 "mask_operand" "L"))
2304                     (const_int 0)))
2305    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2306         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
2307   ""
2308   "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,%m3,%M3"
2309   [(set_attr "type" "delayed_compare")])
2311 (define_insn ""
2312   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2313         (zero_extend:SI
2314          (subreg:QI
2315           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2316                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
2317   ""
2318   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
2320 (define_insn ""
2321   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2322         (compare:CC (zero_extend:SI
2323                      (subreg:QI
2324                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2325                                  (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
2326                     (const_int 0)))
2327    (clobber (match_scratch:SI 3 "=r"))]
2328   ""
2329   "{rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xff"
2330   [(set_attr "type" "delayed_compare")])
2332 (define_insn ""
2333   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2334         (compare:CC (zero_extend:SI
2335                      (subreg:QI
2336                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2337                                  (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
2338                     (const_int 0)))
2339    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2340         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
2341   ""
2342   "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xff"
2343   [(set_attr "type" "delayed_compare")])
2345 (define_insn ""
2346   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2347         (zero_extend:SI
2348          (subreg:HI
2349           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2350                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
2351   ""
2352   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffff")
2354 (define_insn ""
2355   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2356         (compare:CC (zero_extend:SI
2357                      (subreg:HI
2358                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2359                                  (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
2360                     (const_int 0)))
2361    (clobber (match_scratch:SI 3 "=r"))]
2362   ""
2363   "{rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffff"
2364   [(set_attr "type" "delayed_compare")])
2366 (define_insn ""
2367   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2368         (compare:CC (zero_extend:SI
2369                      (subreg:HI
2370                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2371                                  (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
2372                     (const_int 0)))
2373    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2374         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
2375   ""
2376   "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffff"
2377   [(set_attr "type" "delayed_compare")])
2379 ;; Note that we use "sle." instead of "sl." so that we can set
2380 ;; SHIFT_COUNT_TRUNCATED.
2382 (define_expand "ashlsi3"
2383   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2384    (use (match_operand:SI 1 "gpc_reg_operand" ""))
2385    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
2386   ""
2387   "
2389   if (TARGET_POWER)
2390     emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
2391   else
2392     emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
2393   DONE;
2396 (define_insn "ashlsi3_power"
2397   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2398         (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2399                    (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
2400    (clobber (match_scratch:SI 3 "=q,X"))]
2401   "TARGET_POWER"
2402   "@
2403    sle %0,%1,%2
2404    {sli|slwi} %0,%1,%h2"
2405   [(set_attr "length" "8")])
2407 (define_insn "ashlsi3_no_power"
2408   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2409         (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2410                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
2411   "! TARGET_POWER"
2412   "{sl|slw}%I2 %0,%1,%h2"
2413   [(set_attr "length" "8")])
2415 (define_insn ""
2416   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
2417         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2418                                (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2419                     (const_int 0)))
2420    (clobber (match_scratch:SI 3 "=r,r"))
2421    (clobber (match_scratch:SI 4 "=q,X"))]
2422   "TARGET_POWER"
2423   "@
2424    sle. %3,%1,%2
2425    {sli.|slwi.} %3,%1,%h2"
2426   [(set_attr "type" "delayed_compare")])
2428 (define_insn ""
2429   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2430         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2431                                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2432                     (const_int 0)))
2433    (clobber (match_scratch:SI 3 "=r"))]
2434   "! TARGET_POWER"
2435   "{sl|slw}%I2. %3,%1,%h2"
2436   [(set_attr "type" "delayed_compare")])
2438 (define_insn ""
2439   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
2440         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2441                                (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2442                     (const_int 0)))
2443    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2444         (ashift:SI (match_dup 1) (match_dup 2)))
2445    (clobber (match_scratch:SI 4 "=q,X"))]
2446   "TARGET_POWER"
2447   "@
2448    sle. %0,%1,%2
2449    {sli.|slwi.} %0,%1,%h2"
2450   [(set_attr "type" "delayed_compare")])
2452 (define_insn ""
2453   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2454         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2455                                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2456                     (const_int 0)))
2457    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2458         (ashift:SI (match_dup 1) (match_dup 2)))]
2459   "! TARGET_POWER"
2460   "{sl|slw}%I2. %0,%1,%h2"
2461   [(set_attr "type" "delayed_compare")])
2463 (define_insn ""
2464   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2465         (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2466                            (match_operand:SI 2 "const_int_operand" "i"))
2467                 (match_operand:SI 3 "mask_operand" "L")))]
2468   "includes_lshift_p (operands[2], operands[3])"
2469   "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
2471 (define_insn ""
2472   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2473         (compare:CC
2474          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2475                             (match_operand:SI 2 "const_int_operand" "i"))
2476                  (match_operand:SI 3 "mask_operand" "L"))
2477          (const_int 0)))
2478    (clobber (match_scratch:SI 4 "=r"))]
2479   "includes_lshift_p (operands[2], operands[3])"
2480   "{rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3"
2481   [(set_attr "type" "delayed_compare")])
2483 (define_insn ""
2484   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2485         (compare:CC
2486          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2487                             (match_operand:SI 2 "const_int_operand" "i"))
2488                  (match_operand:SI 3 "mask_operand" "L"))
2489          (const_int 0)))
2490    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2491         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
2492   "includes_lshift_p (operands[2], operands[3])"
2493   "{rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3"
2494   [(set_attr "type" "delayed_compare")])
2496 ;; The AIX assembler mis-handles "sri x,x,0", so write that case as
2497 ;; "sli x,x,0".
2498 (define_expand "lshrsi3"
2499   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2500    (use (match_operand:SI 1 "gpc_reg_operand" ""))
2501    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
2502   ""
2503   "
2505   if (TARGET_POWER)
2506     emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
2507   else
2508     emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
2509   DONE;
2512 (define_insn "lshrsi3_power"
2513   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2514         (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2515                      (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
2516    (clobber (match_scratch:SI 3 "=q,X"))]
2517   "TARGET_POWER"
2518   "@
2519   sre %0,%1,%2
2520   {s%A2i|s%A2wi} %0,%1,%h2")
2522 (define_insn "lshrsi3_no_power"
2523   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2524         (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2525                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
2526   "! TARGET_POWER"
2527   "{sr|srw}%I2 %0,%1,%h2")
2529 (define_insn ""
2530   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
2531         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2532                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2533                     (const_int 0)))
2534    (clobber (match_scratch:SI 3 "=r,r"))
2535    (clobber (match_scratch:SI 4 "=q,X"))]
2536   "TARGET_POWER"
2537   "@
2538   sre. %3,%1,%2
2539   {s%A2i.|s%A2wi.} %3,%1,%h2"
2540   [(set_attr "type" "delayed_compare")])
2542 (define_insn ""
2543   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2544         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2545                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2546                     (const_int 0)))
2547    (clobber (match_scratch:SI 3 "=r"))]
2548   "! TARGET_POWER"
2549   "{sr|srw}%I2. %3,%1,%h2"
2550   [(set_attr "type" "delayed_compare")])
2552 (define_insn ""
2553   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
2554         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2555                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2556                     (const_int 0)))
2557    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2558         (lshiftrt:SI (match_dup 1) (match_dup 2)))
2559    (clobber (match_scratch:SI 4 "=q,X"))]
2560   "TARGET_POWER"
2561   "@
2562   sre. %0,%1,%2
2563   {s%A2i.|s%A2wi.} %0,%1,%h2"
2564   [(set_attr "type" "delayed_compare")])
2566 (define_insn ""
2567   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2568         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2569                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2570                     (const_int 0)))
2571    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2572         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
2573   "! TARGET_POWER"
2574   "{sr|srw}%I2. %0,%1,%h2"
2575   [(set_attr "type" "delayed_compare")])
2577 (define_insn ""
2578   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2579         (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2580                              (match_operand:SI 2 "const_int_operand" "i"))
2581                 (match_operand:SI 3 "mask_operand" "L")))]
2582   "includes_rshift_p (operands[2], operands[3])"
2583   "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
2585 (define_insn ""
2586   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2587         (compare:CC
2588          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2589                               (match_operand:SI 2 "const_int_operand" "i"))
2590                  (match_operand:SI 3 "mask_operand" "L"))
2591          (const_int 0)))
2592    (clobber (match_scratch:SI 4 "=r"))]
2593   "includes_rshift_p (operands[2], operands[3])"
2594   "{rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3"
2595   [(set_attr "type" "delayed_compare")])
2597 (define_insn ""
2598   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2599         (compare:CC
2600          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2601                               (match_operand:SI 2 "const_int_operand" "i"))
2602                  (match_operand:SI 3 "mask_operand" "L"))
2603          (const_int 0)))
2604    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2605         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
2606   "includes_rshift_p (operands[2], operands[3])"
2607   "{rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3"
2608   [(set_attr "type" "delayed_compare")])
2610 (define_insn ""
2611   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2612         (zero_extend:SI
2613          (subreg:QI
2614           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2615                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
2616   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
2617   "{rlinm|rlwinm} %0,%1,%s2,0xff")
2619 (define_insn ""
2620   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2621         (compare:CC
2622          (zero_extend:SI
2623           (subreg:QI
2624            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2625                         (match_operand:SI 2 "const_int_operand" "i")) 0))
2626          (const_int 0)))
2627    (clobber (match_scratch:SI 3 "=r"))]
2628   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
2629   "{rlinm.|rlwinm.} %3,%1,%s2,0xff"
2630   [(set_attr "type" "delayed_compare")])
2632 (define_insn ""
2633   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2634         (compare:CC
2635          (zero_extend:SI
2636           (subreg:QI
2637            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2638                         (match_operand:SI 2 "const_int_operand" "i")) 0))
2639          (const_int 0)))
2640    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2641         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
2642   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
2643   "{rlinm.|rlwinm.} %0,%1,%s2,0xff"
2644   [(set_attr "type" "delayed_compare")])
2646 (define_insn ""
2647   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2648         (zero_extend:SI
2649          (subreg:HI
2650           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2651                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
2652   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
2653   "{rlinm|rlwinm} %0,%1,%s2,0xffff")
2655 (define_insn ""
2656   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2657         (compare:CC
2658          (zero_extend:SI
2659           (subreg:HI
2660            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2661                         (match_operand:SI 2 "const_int_operand" "i")) 0))
2662          (const_int 0)))
2663    (clobber (match_scratch:SI 3 "=r"))]
2664   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
2665   "{rlinm.|rlwinm.} %3,%1,%s2,0xffff"
2666   [(set_attr "type" "delayed_compare")])
2668 (define_insn ""
2669   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2670         (compare:CC
2671          (zero_extend:SI
2672           (subreg:HI
2673            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2674                         (match_operand:SI 2 "const_int_operand" "i")) 0))
2675          (const_int 0)))
2676    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2677         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
2678   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
2679   "{rlinm.|rlwinm.} %0,%1,%s2,0xffff"
2680   [(set_attr "type" "delayed_compare")])
2682 (define_insn ""
2683   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2684                          (const_int 1)
2685                          (match_operand:SI 1 "gpc_reg_operand" "r"))
2686         (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2687                      (const_int 31)))]
2688   "TARGET_POWER"
2689   "rrib %0,%1,%2")
2691 (define_insn ""
2692   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2693                          (const_int 1)
2694                          (match_operand:SI 1 "gpc_reg_operand" "r"))
2695         (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2696                      (const_int 31)))]
2697   "TARGET_POWER"
2698   "rrib %0,%1,%2")
2700 (define_insn ""
2701   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2702                          (const_int 1)
2703                          (match_operand:SI 1 "gpc_reg_operand" "r"))
2704         (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2705                          (const_int 1)
2706                          (const_int 0)))]
2707   "TARGET_POWER"
2708   "rrib %0,%1,%2")
2710 (define_expand "ashrsi3"
2711   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2712         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
2713                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
2714   ""
2715   "
2717   if (TARGET_POWER)
2718     emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
2719   else
2720     emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
2721   DONE;
2724 (define_insn "ashrsi3_power"
2725   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2726         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2727                      (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
2728    (clobber (match_scratch:SI 3 "=q,X"))]
2729   "TARGET_POWER"
2730   "@
2731    srea %0,%1,%2
2732    {srai|srawi} %0,%1,%h2")
2734 (define_insn "ashrsi3_no_power"
2735   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2736         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2737                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
2738   "! TARGET_POWER"
2739   "{sra|sraw}%I2 %0,%1,%h2")
2741 (define_insn ""
2742   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
2743         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2744                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2745                     (const_int 0)))
2746    (clobber (match_scratch:SI 3 "=r,r"))
2747    (clobber (match_scratch:SI 4 "=q,X"))]
2748   "TARGET_POWER"
2749   "@
2750    srea. %3,%1,%2
2751    {srai.|srawi.} %3,%1,%h2"
2752   [(set_attr "type" "delayed_compare")])
2754 (define_insn ""
2755   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2756         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2757                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2758                     (const_int 0)))
2759    (clobber (match_scratch:SI 3 "=r"))]
2760   "! TARGET_POWER"
2761   "{sra|sraw}%I2. %3,%1,%h2"
2762   [(set_attr "type" "delayed_compare")])
2764 (define_insn ""
2765   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
2766         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2767                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2768                     (const_int 0)))
2769    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2770         (ashiftrt:SI (match_dup 1) (match_dup 2)))
2771    (clobber (match_scratch:SI 4 "=q,X"))]
2772   "TARGET_POWER"
2773   "@
2774    srea. %0,%1,%2
2775    {srai.|srawi.} %0,%1,%h2"
2776   [(set_attr "type" "delayed_compare")])
2778 (define_insn ""
2779   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2780         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2781                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2782                     (const_int 0)))
2783    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2784         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
2785   "! TARGET_POWER"
2786   "{sra|sraw}%I2. %0,%1,%h2"
2787   [(set_attr "type" "delayed_compare")])
2789 ;; Floating-point insns, excluding normal data motion.
2791 ;; PowerPC has a full set of single-precision floating point instructions.
2793 ;; For the POWER architecture, we pretend that we have both SFmode and
2794 ;; DFmode insns, while, in fact, all fp insns are actually done in double.
2795 ;; The only conversions we will do will be when storing to memory.  In that
2796 ;; case, we will use the "frsp" instruction before storing.
2798 ;; Note that when we store into a single-precision memory location, we need to
2799 ;; use the frsp insn first.  If the register being stored isn't dead, we
2800 ;; need a scratch register for the frsp.  But this is difficult when the store
2801 ;; is done by reload.  It is not incorrect to do the frsp on the register in
2802 ;; this case, we just lose precision that we would have otherwise gotten but
2803 ;; is not guaranteed.  Perhaps this should be tightened up at some point.
2805 (define_insn "extendsfdf2"
2806   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
2807         (float_extend:DF (match_operand:SF 1 "gpc_reg_operand" "f")))]
2808   "TARGET_HARD_FLOAT"
2809   "*
2811   if (REGNO (operands[0]) == REGNO (operands[1]))
2812     return \"\";
2813   else
2814     return \"fmr %0,%1\";
2816   [(set_attr "type" "fp")])
2818 (define_insn "truncdfsf2"
2819   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2820         (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
2821   "TARGET_HARD_FLOAT"
2822   "frsp %0,%1"
2823   [(set_attr "type" "fp")])
2825 (define_insn "aux_truncdfsf2"
2826   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2827         (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] 0))]
2828   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
2829   "frsp %0,%1"
2830   [(set_attr "type" "fp")])
2832 (define_insn "negsf2"
2833   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2834         (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
2835   "TARGET_HARD_FLOAT"
2836   "fneg %0,%1"
2837   [(set_attr "type" "fp")])
2839 (define_insn "abssf2"
2840   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2841         (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
2842   "TARGET_HARD_FLOAT"
2843   "fabs %0,%1"
2844   [(set_attr "type" "fp")])
2846 (define_insn ""
2847   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2848         (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
2849   "TARGET_HARD_FLOAT"
2850   "fnabs %0,%1"
2851   [(set_attr "type" "fp")])
2853 (define_expand "addsf3"
2854   [(set (match_operand:SF 0 "gpc_reg_operand" "")
2855         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
2856                  (match_operand:SF 2 "gpc_reg_operand" "")))]
2857   "TARGET_HARD_FLOAT"
2858   "")
2860 (define_insn ""
2861   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2862         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2863                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
2864   "TARGET_POWERPC && TARGET_HARD_FLOAT"
2865   "fadds %0,%1,%2"
2866   [(set_attr "type" "fp")])
2868 (define_insn ""
2869   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2870         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2871                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
2872   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
2873   "{fa|fadd} %0,%1,%2"
2874   [(set_attr "type" "fp")])
2876 (define_expand "subsf3"
2877   [(set (match_operand:SF 0 "gpc_reg_operand" "")
2878         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
2879                   (match_operand:SF 2 "gpc_reg_operand" "")))]
2880   "TARGET_HARD_FLOAT"
2881   "")
2883 (define_insn ""
2884   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2885         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
2886                   (match_operand:SF 2 "gpc_reg_operand" "f")))]
2887   "TARGET_POWERPC && TARGET_HARD_FLOAT"
2888   "fsubs %0,%1,%2"
2889   [(set_attr "type" "fp")])
2891 (define_insn ""
2892   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2893         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
2894                   (match_operand:SF 2 "gpc_reg_operand" "f")))]
2895   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
2896   "{fs|fsub} %0,%1,%2"
2897   [(set_attr "type" "fp")])
2899 (define_expand "mulsf3"
2900   [(set (match_operand:SF 0 "gpc_reg_operand" "")
2901         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
2902                  (match_operand:SF 2 "gpc_reg_operand" "")))]
2903   "TARGET_HARD_FLOAT"
2904   "")
2906 (define_insn ""
2907   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2908         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2909                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
2910   "TARGET_POWERPC && TARGET_HARD_FLOAT"
2911   "fmuls %0,%1,%2"
2912   [(set_attr "type" "fp")])
2914 (define_insn ""
2915   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2916         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2917                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
2918   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
2919   "{fm|fmul} %0,%1,%2"
2920   [(set_attr "type" "dmul")])
2922 (define_expand "divsf3"
2923   [(set (match_operand:SF 0 "gpc_reg_operand" "")
2924         (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
2925                 (match_operand:SF 2 "gpc_reg_operand" "")))]
2926   "TARGET_HARD_FLOAT"
2927   "")
2929 (define_insn ""
2930   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2931         (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
2932                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
2933   "TARGET_POWERPC && TARGET_HARD_FLOAT"
2934   "fdivs %0,%1,%2"
2935   [(set_attr "type" "sdiv")])
2937 (define_insn ""
2938   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2939         (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
2940                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
2941   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
2942   "{fd|fdiv} %0,%1,%2"
2943   [(set_attr "type" "ddiv")])
2945 (define_insn ""
2946   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2947         (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2948                           (match_operand:SF 2 "gpc_reg_operand" "f"))
2949                  (match_operand:SF 3 "gpc_reg_operand" "f")))]
2950   "TARGET_POWERPC && TARGET_HARD_FLOAT"
2951   "fmadds %0,%1,%2,%3"
2952   [(set_attr "type" "fp")])
2954 (define_insn ""
2955   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2956         (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2957                           (match_operand:SF 2 "gpc_reg_operand" "f"))
2958                  (match_operand:SF 3 "gpc_reg_operand" "f")))]
2959   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
2960   "{fma|fmadd} %0,%1,%2,%3"
2961   [(set_attr "type" "dmul")])
2963 (define_insn ""
2964   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2965         (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2966                            (match_operand:SF 2 "gpc_reg_operand" "f"))
2967                   (match_operand:SF 3 "gpc_reg_operand" "f")))]
2968   "TARGET_POWERPC && TARGET_HARD_FLOAT"
2969   "fmsubs %0,%1,%2,%3"
2970   [(set_attr "type" "fp")])
2972 (define_insn ""
2973   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2974         (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2975                            (match_operand:SF 2 "gpc_reg_operand" "f"))
2976                   (match_operand:SF 3 "gpc_reg_operand" "f")))]
2977   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
2978   "{fms|fmsub} %0,%1,%2,%3"
2979   [(set_attr "type" "dmul")])
2981 (define_insn ""
2982   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2983         (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2984                                   (match_operand:SF 2 "gpc_reg_operand" "f"))
2985                          (match_operand:SF 3 "gpc_reg_operand" "f"))))]
2986   "TARGET_POWERPC && TARGET_HARD_FLOAT"
2987   "fnmadds %0,%1,%2,%3"
2988   [(set_attr "type" "fp")])
2990 (define_insn ""
2991   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2992         (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2993                                   (match_operand:SF 2 "gpc_reg_operand" "f"))
2994                          (match_operand:SF 3 "gpc_reg_operand" "f"))))]
2995   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
2996   "{fnma|fnmadd} %0,%1,%2,%3"
2997   [(set_attr "type" "dmul")])
2999 (define_insn ""
3000   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3001         (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3002                                    (match_operand:SF 2 "gpc_reg_operand" "f"))
3003                           (match_operand:SF 3 "gpc_reg_operand" "f"))))]
3004   "TARGET_POWERPC && TARGET_HARD_FLOAT"
3005   "fnmsubs %0,%1,%2,%3"
3006   [(set_attr "type" "fp")])
3008 (define_insn ""
3009   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3010         (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3011                                    (match_operand:SF 2 "gpc_reg_operand" "f"))
3012                           (match_operand:SF 3 "gpc_reg_operand" "f"))))]
3013   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3014   "{fnms|fnmsub} %0,%1,%2,%3"
3015   [(set_attr "type" "dmul")])
3017 (define_expand "sqrtsf2"
3018   [(set (match_operand:SF 0 "gpc_reg_operand" "")
3019         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
3020   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT"
3021   "")
3023 (define_insn ""
3024   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3025         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
3026   "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT"
3027   "fsqrts %0,%1"
3028   [(set_attr "type" "ssqrt")])
3030 (define_insn ""
3031   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3032         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
3033   "TARGET_POWER2 && TARGET_HARD_FLOAT"
3034   "fsqrt %0,%1"
3035   [(set_attr "type" "dsqrt")])
3037 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
3038 ;; fsel instruction and some auxiliary computations.  Then we just have a
3039 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
3040 ;; combine.
3041 (define_expand "maxsf3"
3042   [(set (match_dup 3)
3043         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
3044                   (match_operand:SF 2 "gpc_reg_operand" "")))
3045    (set (match_operand:SF 0 "gpc_reg_operand" "")
3046         (if_then_else:SF (ge (match_dup 3)
3047                              (const_int 0))
3048                          (match_dup 1)
3049                          (match_dup 2)))]
3050   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3051   "
3052 { operands[3] = gen_reg_rtx (SFmode); }")
3054 (define_split
3055   [(set (match_operand:SF 0 "gpc_reg_operand" "")
3056         (smax:SF (match_operand:SF 1 "gpc_reg_operand" "")
3057                  (match_operand:SF 2 "gpc_reg_operand" "")))
3058    (clobber (match_operand:SF 3 "gpc_reg_operand" ""))]
3059   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3060   [(set (match_dup 3)
3061         (minus:SF (match_dup 1) (match_dup 2)))
3062    (set (match_dup 0)
3063         (if_then_else:SF (ge (match_dup 3)
3064                              (const_int 0))
3065                          (match_dup 1)
3066                          (match_dup 2)))]
3067   "")
3069 (define_expand "minsf3"
3070   [(set (match_dup 3)
3071         (minus:SF (match_operand:SF 2 "gpc_reg_operand" "")
3072                   (match_operand:SF 1 "gpc_reg_operand" "")))
3073    (set (match_operand:SF 0 "gpc_reg_operand" "")
3074         (if_then_else:SF (ge (match_dup 3)
3075                              (const_int 0))
3076                          (match_dup 1)
3077                          (match_dup 2)))]
3078   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3079   "
3080 { operands[3] = gen_reg_rtx (SFmode); }")
3082 (define_split
3083   [(set (match_operand:SF 0 "gpc_reg_operand" "")
3084         (smin:SF (match_operand:SF 1 "gpc_reg_operand" "")
3085                  (match_operand:SF 2 "gpc_reg_operand" "")))
3086    (clobber (match_operand:SF 3 "gpc_reg_operand" ""))]
3087   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3088   [(set (match_dup 3)
3089         (minus:SF (match_dup 2) (match_dup 1)))
3090    (set (match_dup 0)
3091         (if_then_else:SF (ge (match_dup 3)
3092                              (const_int 0))
3093                          (match_dup 1)
3094                          (match_dup 2)))]
3095   "")
3097 (define_expand "movsfcc"
3098    [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3099          (if_then_else:SF (match_operand 1 "comparison_operator" "")
3100                           (match_operand:SF 2 "gpc_reg_operand" "f")
3101                           (match_operand:SF 3 "gpc_reg_operand" "f")))]
3102   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3103   "
3105   rtx temp, op0, op1;
3106   enum rtx_code code = GET_CODE (operands[1]);
3107   if (! rs6000_compare_fp_p)
3108     FAIL;
3109   switch (code)
3110     {
3111     case GE: case EQ: case NE:
3112       op0 = rs6000_compare_op0;
3113       op1 = rs6000_compare_op1;
3114       break;
3115     case GT:
3116       op0 = rs6000_compare_op1;
3117       op1 = rs6000_compare_op0;
3118       temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
3119       break;
3120     case LE:
3121       op0 = rs6000_compare_op1;
3122       op1 = rs6000_compare_op0;
3123       break;
3124     case LT:
3125       op0 = rs6000_compare_op0;
3126       op1 = rs6000_compare_op1;
3127       temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
3128       break;
3129     default:
3130       FAIL;
3131     }
3132   if (GET_MODE (rs6000_compare_op0) == DFmode)
3133     {
3134       temp = gen_reg_rtx (DFmode);
3135       emit_insn (gen_subdf3 (temp, op0, op1));
3136       emit_insn (gen_fseldfsf4 (operands[0], temp, operands[2], operands[3]));
3137       if (code == EQ)
3138         {
3139           emit_insn (gen_negdf2 (temp, temp));
3140           emit_insn (gen_fseldfsf4 (operands[0], temp, operands[0], operands[3]));
3141         }
3142       if (code == NE)
3143         {
3144           emit_insn (gen_negdf2 (temp, temp));
3145           emit_insn (gen_fseldfsf4 (operands[0], temp, operands[3], operands[0]));
3146         }
3147     }
3148   else
3149     {
3150       temp = gen_reg_rtx (SFmode);
3151       emit_insn (gen_subsf3 (temp, op0, op1));
3152       emit_insn (gen_fselsfsf4 (operands[0], temp, operands[2], operands[3]));
3153       if (code == EQ)
3154         {
3155           emit_insn (gen_negsf2 (temp, temp));
3156           emit_insn (gen_fselsfsf4 (operands[0], temp, operands[0], operands[3]));
3157         }
3158       if (code == NE)
3159         {
3160           emit_insn (gen_negsf2 (temp, temp));
3161           emit_insn (gen_fselsfsf4 (operands[0], temp, operands[3], operands[0]));
3162         }
3163     }
3164   DONE;
3167 (define_insn "fselsfsf4"
3168   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3169         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
3170                              (const_int 0))
3171                          (match_operand:SF 2 "gpc_reg_operand" "f")
3172                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
3173   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3174   "fsel %0,%1,%2,%3"
3175   [(set_attr "type" "fp")])
3177 (define_insn "fseldfsf4"
3178   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3179         (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
3180                              (const_int 0))
3181                          (match_operand:SF 2 "gpc_reg_operand" "f")
3182                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
3183   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3184   "fsel %0,%1,%2,%3"
3185   [(set_attr "type" "fp")])
3187 (define_insn "negdf2"
3188   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3189         (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
3190   "TARGET_HARD_FLOAT"
3191   "fneg %0,%1"
3192   [(set_attr "type" "fp")])
3194 (define_insn "absdf2"
3195   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3196         (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
3197   "TARGET_HARD_FLOAT"
3198   "fabs %0,%1"
3199   [(set_attr "type" "fp")])
3201 (define_insn ""
3202   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3203         (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
3204   "TARGET_HARD_FLOAT"
3205   "fnabs %0,%1"
3206   [(set_attr "type" "fp")])
3208 (define_insn "adddf3"
3209   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3210         (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3211                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
3212   "TARGET_HARD_FLOAT"
3213   "{fa|fadd} %0,%1,%2"
3214   [(set_attr "type" "fp")])
3216 (define_insn "subdf3"
3217   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3218         (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
3219                   (match_operand:DF 2 "gpc_reg_operand" "f")))]
3220   "TARGET_HARD_FLOAT"
3221   "{fs|fsub} %0,%1,%2"
3222   [(set_attr "type" "fp")])
3224 (define_insn "muldf3"
3225   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3226         (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3227                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
3228   "TARGET_HARD_FLOAT"
3229   "{fm|fmul} %0,%1,%2"
3230   [(set_attr "type" "dmul")])
3232 (define_insn "divdf3"
3233   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3234         (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
3235                 (match_operand:DF 2 "gpc_reg_operand" "f")))]
3236   "TARGET_HARD_FLOAT"
3237   "{fd|fdiv} %0,%1,%2"
3238   [(set_attr "type" "ddiv")])
3240 (define_insn ""
3241   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3242         (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3243                           (match_operand:DF 2 "gpc_reg_operand" "f"))
3244                  (match_operand:DF 3 "gpc_reg_operand" "f")))]
3245   "TARGET_HARD_FLOAT"
3246   "{fma|fmadd} %0,%1,%2,%3"
3247   [(set_attr "type" "dmul")])
3249 (define_insn ""
3250   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3251         (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3252                            (match_operand:DF 2 "gpc_reg_operand" "f"))
3253                   (match_operand:DF 3 "gpc_reg_operand" "f")))]
3254   "TARGET_HARD_FLOAT"
3255   "{fms|fmsub} %0,%1,%2,%3"
3256   [(set_attr "type" "dmul")])
3258 (define_insn ""
3259   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3260         (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3261                                   (match_operand:DF 2 "gpc_reg_operand" "f"))
3262                          (match_operand:DF 3 "gpc_reg_operand" "f"))))]
3263   "TARGET_HARD_FLOAT"
3264   "{fnma|fnmadd} %0,%1,%2,%3"
3265   [(set_attr "type" "dmul")])
3267 (define_insn ""
3268   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3269         (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3270                                    (match_operand:DF 2 "gpc_reg_operand" "f"))
3271                           (match_operand:DF 3 "gpc_reg_operand" "f"))))]
3272   "TARGET_HARD_FLOAT"
3273   "{fnms|fnmsub} %0,%1,%2,%3"
3274   [(set_attr "type" "dmul")])
3276 (define_insn "sqrtdf2"
3277   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3278         (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
3279   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT"
3280   "fsqrt %0,%1"
3281   [(set_attr "type" "dsqrt")])
3283 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
3284 ;; fsel instruction and some auxiliary computations.  Then we just have a
3285 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
3286 ;; combine.
3288 (define_expand "maxdf3"
3289   [(set (match_dup 3)
3290         (minus:DF (match_operand:DF 1 "gpc_reg_operand" "")
3291                   (match_operand:DF 2 "gpc_reg_operand" "")))
3292    (set (match_operand:DF 0 "gpc_reg_operand" "")
3293         (if_then_else:DF (ge (match_dup 3)
3294                              (const_int 0))
3295                          (match_dup 1)
3296                          (match_dup 2)))]
3297   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3298   "
3299 { operands[3] = gen_reg_rtx (DFmode); }")
3301 (define_split
3302   [(set (match_operand:DF 0 "gpc_reg_operand" "")
3303         (smax:DF (match_operand:DF 1 "gpc_reg_operand" "")
3304                  (match_operand:DF 2 "gpc_reg_operand" "")))
3305    (clobber (match_operand:DF 3 "gpc_reg_operand" ""))]
3306   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3307   [(set (match_dup 3)
3308         (minus:DF (match_dup 1) (match_dup 2)))
3309    (set (match_dup 0)
3310         (if_then_else:DF (ge (match_dup 3)
3311                              (const_int 0))
3312                          (match_dup 1)
3313                          (match_dup 2)))]
3314   "")
3316 (define_expand "mindf3"
3317   [(set (match_dup 3)
3318         (minus:DF (match_operand:DF 2 "gpc_reg_operand" "")
3319                   (match_operand:DF 1 "gpc_reg_operand" "")))
3320    (set (match_operand:DF 0 "gpc_reg_operand" "")
3321         (if_then_else:DF (ge (match_dup 3)
3322                              (const_int 0))
3323                          (match_dup 1)
3324                          (match_dup 2)))]
3325   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3326   "
3327 { operands[3] = gen_reg_rtx (DFmode); }")
3329 (define_split
3330   [(set (match_operand:DF 0 "gpc_reg_operand" "")
3331         (smin:DF (match_operand:DF 1 "gpc_reg_operand" "")
3332                  (match_operand:DF 2 "gpc_reg_operand" "")))
3333    (clobber (match_operand:DF 3 "gpc_reg_operand" ""))]
3334   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3335   [(set (match_dup 3)
3336         (minus:DF (match_dup 2) (match_dup 1)))
3337    (set (match_dup 0)
3338         (if_then_else:DF (ge (match_dup 3)
3339                              (const_int 0))
3340                          (match_dup 1)
3341                          (match_dup 2)))]
3342   "")
3344 (define_expand "movdfcc"
3345    [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3346          (if_then_else:DF (match_operand 1 "comparison_operator" "")
3347                           (match_operand:DF 2 "gpc_reg_operand" "f")
3348                           (match_operand:DF 3 "gpc_reg_operand" "f")))]
3349   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3350   "
3352   rtx temp, op0, op1;
3353   enum rtx_code code = GET_CODE (operands[1]);
3354   if (! rs6000_compare_fp_p)
3355     FAIL;
3356   switch (code)
3357     {
3358     case GE: case EQ: case NE:
3359       op0 = rs6000_compare_op0;
3360       op1 = rs6000_compare_op1;
3361       break;
3362     case GT:
3363       op0 = rs6000_compare_op1;
3364       op1 = rs6000_compare_op0;
3365       temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
3366       break;
3367     case LE:
3368       op0 = rs6000_compare_op1;
3369       op1 = rs6000_compare_op0;
3370       break;
3371     case LT:
3372       op0 = rs6000_compare_op0;
3373       op1 = rs6000_compare_op1;
3374       temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
3375       break;
3376     default:
3377       FAIL;
3378     }
3379   if (GET_MODE (rs6000_compare_op0) == DFmode)
3380     {
3381       temp = gen_reg_rtx (DFmode);
3382       emit_insn (gen_subdf3 (temp, op0, op1));
3383       emit_insn (gen_fseldfdf4 (operands[0], temp, operands[2], operands[3]));
3384       if (code == EQ)
3385         {
3386           emit_insn (gen_negdf2 (temp, temp));
3387           emit_insn (gen_fseldfdf4 (operands[0], temp, operands[0], operands[3]));
3388         }
3389       if (code == NE)
3390         {
3391           emit_insn (gen_negdf2 (temp, temp));
3392           emit_insn (gen_fseldfdf4 (operands[0], temp, operands[3], operands[0]));
3393         }
3394     }
3395   else
3396     {
3397       temp = gen_reg_rtx (SFmode);
3398       emit_insn (gen_subsf3 (temp, op0, op1));
3399       emit_insn (gen_fselsfdf4 (operands[0], temp, operands[2], operands[3]));
3400       if (code == EQ)
3401         {
3402           emit_insn (gen_negsf2 (temp, temp));
3403           emit_insn (gen_fselsfdf4 (operands[0], temp, operands[0], operands[3]));
3404         }
3405       if (code == NE)
3406         {
3407           emit_insn (gen_negsf2 (temp, temp));
3408           emit_insn (gen_fselsfdf4 (operands[0], temp, operands[3], operands[0]));
3409         }
3410     }
3411   DONE;
3414 (define_insn "fseldfdf4"
3415   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3416         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
3417                              (const_int 0))
3418                          (match_operand:DF 2 "gpc_reg_operand" "f")
3419                          (match_operand:DF 3 "gpc_reg_operand" "f")))]
3420   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3421   "fsel %0,%1,%2,%3"
3422   [(set_attr "type" "fp")])
3424 (define_insn "fselsfdf4"
3425   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3426         (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
3427                              (const_int 0))
3428                          (match_operand:DF 2 "gpc_reg_operand" "f")
3429                          (match_operand:DF 3 "gpc_reg_operand" "f")))]
3430   "TARGET_PPC_GFXOPT"
3431   "fsel %0,%1,%2,%3"
3432   [(set_attr "type" "fp")])
3434 ;; Conversions to and from floating-point.
3435 (define_expand "floatsidf2"
3436   [(set (match_operand:DF 0 "gpc_reg_operand" "")
3437         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))]
3438   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3439   "
3441   if (operands[0])
3442     {                           /* prevent unused warning messages */
3443       rtx high   = force_reg (SImode, GEN_INT (0x43300000));
3444       rtx low    = gen_reg_rtx (SImode);
3445       rtx df     = gen_reg_rtx (DFmode);
3446       rtx adjust = force_reg (DFmode, rs6000_float_const (\"4503601774854144\", DFmode));
3448       emit_insn (gen_xorsi3 (low, operands[1], GEN_INT (0x80000000)));
3449       emit_insn (gen_move_to_float (df, low, high));
3450       emit_insn (gen_subdf3 (operands[0], df, adjust));
3451       DONE;
3452     }
3455 (define_expand "floatunssidf2"
3456   [(set (match_operand:DF 0 "gpc_reg_operand" "")
3457         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))]
3458   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3459   "
3461   if (operands[0])
3462     {                           /* prevent unused warning messages */
3463       rtx high   = force_reg (SImode, GEN_INT (0x43300000));
3464       rtx df     = gen_reg_rtx (DFmode);
3465       rtx adjust = force_reg (DFmode, rs6000_float_const (\"4503599627370496\", DFmode));
3467       emit_insn (gen_move_to_float (df, operands[1], high));
3468       emit_insn (gen_subdf3 (operands[0], df, adjust));
3469       DONE;
3470     }
3473 (define_expand "move_to_float"
3474   [(set (match_operand:DF 0 "gpc_reg_operand" "")
3475         (unspec [(match_operand:SI 1 "gpc_reg_operand" "")
3476                  (match_operand:SI 2 "gpc_reg_operand" "")
3477                  (match_dup 3)] 2))]
3478   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3479   "
3481   operands[3] = XEXP (rs6000_stack_temp (DFmode, 8, 1), 0);
3484 (define_split
3485   [(set (match_operand:DF 0 "gpc_reg_operand" "")
3486         (unspec [(match_operand:SI 1 "gpc_reg_operand" "")
3487                  (match_operand:SI 2 "gpc_reg_operand" "")
3488                  (match_operand:SI 3 "offsettable_addr_operand" "")] 2))]
3489   "reload_completed"
3490   [(set (match_dup 4) (match_dup 1))
3491    (set (match_dup 5) (match_dup 2))
3492    (set (match_dup 0) (mem:DF (match_dup 3)))]
3493   "
3495   rtx word1 = gen_rtx (MEM, SImode, operands[3]);
3496   rtx word2 = gen_rtx (MEM, SImode, plus_constant (operands[3], 4));
3498   MEM_IN_STRUCT_P (word1) = 1;
3499   MEM_IN_STRUCT_P (word2) = 1;
3501   if (WORDS_BIG_ENDIAN)
3502     {
3503       operands[4] = word2;
3504       operands[5] = word1;
3505     }
3506   else
3507     {
3508       operands[4] = word1;
3509       operands[5] = word2;
3510     }
3513 (define_insn ""
3514   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3515         (unspec [(match_operand:SI 1 "gpc_reg_operand" "r")
3516                  (match_operand:SI 2 "gpc_reg_operand" "r")
3517                  (match_operand:SI 3 "offsettable_addr_operand" "p")] 2))]
3518   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3519   "#"
3520   [(set_attr "length" "12")])
3522 (define_expand "fix_truncdfsi2"
3523   [(set (match_operand:SI 0 "gpc_reg_operand" "")
3524         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))]
3525   "TARGET_HARD_FLOAT"
3526   "
3528   if (TARGET_POWER2 || TARGET_POWERPC)
3529     {
3530       int endian = (WORDS_BIG_ENDIAN == 0);
3531       rtx stack_slot = rs6000_stack_temp (DImode, 8, 1);
3532       rtx temp = gen_reg_rtx (DImode);
3534       emit_insn (gen_fpcvtsi (temp, operands[1]));
3535       emit_move_insn (stack_slot, temp);
3536       emit_move_insn (operands[0],
3537                       operand_subword (stack_slot, 1 - endian, 0, DImode));
3538       DONE;
3539     }
3540   else
3541     {
3542       emit_insn (gen_trunc_call (operands[0], operands[1],
3543                                  gen_rtx (SYMBOL_REF, Pmode, RS6000_ITRUNC)));
3544       DONE;
3545     }
3548 (define_insn "fpcvtsi"
3549   [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
3550         (sign_extend:DI
3551          (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))))]
3552   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
3553   "{fcirz|fctiwz} %0,%1"
3554   [(set_attr "type" "fp")])
3556 (define_expand "fixuns_truncdfsi2"
3557   [(set (match_operand:SI 0 "gpc_reg_operand" "")
3558         (unsigned_fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))]
3559   "! TARGET_POWER2 && ! TARGET_POWERPC && TARGET_HARD_FLOAT"
3560   "
3562   emit_insn (gen_trunc_call (operands[0], operands[1],
3563                              gen_rtx (SYMBOL_REF, Pmode, RS6000_UITRUNC)));
3564   DONE;
3567 (define_expand "trunc_call"
3568   [(parallel [(set (match_operand:SI 0 "" "")
3569                    (fix:SI (match_operand:DF 1 "" "")))
3570               (use (match_operand:SI 2 "" ""))])]
3571   "TARGET_HARD_FLOAT"
3572   "
3574   rtx insns = gen_trunc_call_rtl (operands[0], operands[1], operands[2]);
3575   rtx first = XVECEXP (insns, 0, 0);
3576   rtx last = XVECEXP (insns, 0, XVECLEN (insns, 0) - 1);
3578   REG_NOTES (first) = gen_rtx (INSN_LIST, REG_LIBCALL, last,
3579                                REG_NOTES (first));
3580   REG_NOTES (last) = gen_rtx (INSN_LIST, REG_RETVAL, first, REG_NOTES (last));
3582   emit_insn (insns);
3583   DONE;
3586 (define_expand "trunc_call_rtl"
3587   [(set (reg:DF 33) (match_operand:DF 1 "gpc_reg_operand" ""))
3588    (use (reg:DF 33))
3589    (parallel [(set (reg:SI 3)
3590                    (call (mem:SI (match_operand 2 "" "")) (const_int 0)))
3591               (use (const_int 0))
3592               (clobber (scratch:SI))])
3593    (set (match_operand:SI 0 "gpc_reg_operand" "")
3594         (reg:SI 3))]
3595   "TARGET_HARD_FLOAT"
3596   "
3598   rs6000_trunc_used = 1;
3601 (define_insn "floatdidf2"
3602   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3603         (float:DF (match_operand:DI 1 "gpc_reg_operand" "f")))]
3604   "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3605   "fcfid %0,%1"
3606   [(set_attr "type" "fp")])
3608 (define_insn "fix_truncdfdi2"
3609   [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
3610         (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
3611   "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3612   "fctidz %0,%1"
3613   [(set_attr "type" "fp")])
3615 ;; Define the DImode operations that can be done in a small number
3616 ;; of instructions.  The & constraints are to prevent the register
3617 ;; allocator from allocating registers that overlap with the inputs
3618 ;; (for example, having an input in 7,8 and an output in 6,7).  We
3619 ;; also allow for the the output being the same as one of the inputs.
3621 (define_insn "*adddi3_noppc64"
3622   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
3623         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
3624                  (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
3625   "! TARGET_POWERPC64"
3626   "*
3628   if (WORDS_BIG_ENDIAN)
3629     return (GET_CODE (operands[2])) != CONST_INT
3630             ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
3631             : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
3632   else
3633     return (GET_CODE (operands[2])) != CONST_INT
3634             ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
3635             : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
3637   [(set_attr "length" "8")])
3639 (define_insn "*subdi3_noppc64"
3640   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
3641         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
3642                   (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
3643   "! TARGET_POWERPC64"
3644   "*
3646   if (WORDS_BIG_ENDIAN)
3647     return (GET_CODE (operands[1]) != CONST_INT)
3648             ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
3649             : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
3650   else
3651     return (GET_CODE (operands[1]) != CONST_INT)
3652             ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
3653             : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
3655   [(set_attr "length" "8")])
3657 (define_insn "*negdi2_noppc64"
3658   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
3659         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
3660   "! TARGET_POWERPC64"
3661   "*
3663   return (WORDS_BIG_ENDIAN)
3664     ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
3665     : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
3667   [(set_attr "length" "8")])
3669 (define_expand "mulsidi3"
3670   [(set (match_operand:DI 0 "gpc_reg_operand" "")
3671         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
3672                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
3673   ""
3674   "
3676   if (! TARGET_POWER && ! TARGET_POWERPC)
3677     {
3678       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
3679       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
3680       emit_insn (gen_mull_call ());
3681       if (WORDS_BIG_ENDIAN)
3682         emit_move_insn (operands[0], gen_rtx (REG, DImode, 3));
3683       else
3684         {
3685           emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
3686                           gen_rtx (REG, SImode, 3));
3687           emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
3688                           gen_rtx (REG, SImode, 4));
3689         }
3690       DONE;
3691     }
3692   else if (TARGET_POWER)
3693     {
3694       emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
3695       DONE;
3696     }
3699 (define_insn "mulsidi3_mq"
3700   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3701         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
3702                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
3703    (clobber (match_scratch:SI 3 "=q"))]
3704   "TARGET_POWER"
3705   "mul %0,%1,%2\;mfmq %L0"
3706   [(set_attr "type" "imul")
3707    (set_attr "length" "8")])
3709 (define_insn "*mulsidi3_powerpc"
3710   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
3711         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
3712                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
3713   "TARGET_POWERPC && ! TARGET_POWERPC64"
3714   "*
3716   return (WORDS_BIG_ENDIAN)
3717     ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
3718     : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
3720   [(set_attr "type" "imul")
3721    (set_attr "length" "8")])
3723 (define_split
3724   [(set (match_operand:DI 0 "gpc_reg_operand" "")
3725         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
3726                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
3727   "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
3728   [(set (match_dup 3)
3729         (truncate:SI
3730          (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3731                                (sign_extend:DI (match_dup 2)))
3732                       (const_int 32))))
3733    (set (match_dup 4)
3734         (mult:SI (match_dup 1)
3735                  (match_dup 2)))]
3736   "
3738   int endian = (WORDS_BIG_ENDIAN == 0);
3739   operands[3] = operand_subword (operands[0], endian, 0, DImode);
3740   operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
3743 (define_insn "umulsidi3"
3744   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
3745         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
3746                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
3747   "TARGET_POWERPC && ! TARGET_POWERPC64"
3748   "*
3750   return (WORDS_BIG_ENDIAN)
3751     ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
3752     : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
3754   [(set_attr "type" "imul")
3755    (set_attr "length" "8")])
3757 (define_split
3758   [(set (match_operand:DI 0 "gpc_reg_operand" "")
3759         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
3760                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
3761   "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
3762   [(set (match_dup 3)
3763         (truncate:SI
3764          (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3765                                (zero_extend:DI (match_dup 2)))
3766                       (const_int 32))))
3767    (set (match_dup 4)
3768         (mult:SI (match_dup 1)
3769                  (match_dup 2)))]
3770   "
3772   int endian = (WORDS_BIG_ENDIAN == 0);
3773   operands[3] = operand_subword (operands[0], endian, 0, DImode);
3774   operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
3777 (define_expand "smulsi3_highpart"
3778   [(set (match_operand:SI 0 "gpc_reg_operand" "")
3779         (truncate:SI
3780          (lshiftrt:DI (mult:DI (sign_extend:DI
3781                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
3782                                (sign_extend:DI
3783                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
3784                       (const_int 32))))]
3785   ""
3786   "
3788   if (! TARGET_POWER && ! TARGET_POWERPC)
3789     {
3790       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
3791       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
3792       emit_insn (gen_mulh_call ());
3793       emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
3794       DONE;
3795     }
3796   else if (TARGET_POWER)
3797     {
3798       emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
3799       DONE;
3800     }
3803 (define_insn "smulsi3_highpart_mq"
3804   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3805         (truncate:SI
3806          (lshiftrt:DI (mult:DI (sign_extend:DI
3807                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
3808                                (sign_extend:DI
3809                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
3810                       (const_int 32))))
3811    (clobber (match_scratch:SI 3 "=q"))]
3812   "TARGET_POWER"
3813   "mul %0,%1,%2"
3814   [(set_attr "type" "imul")])
3816 (define_insn ""
3817   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3818         (truncate:SI
3819          (lshiftrt:DI (mult:DI (sign_extend:DI
3820                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
3821                                (sign_extend:DI
3822                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
3823                       (const_int 32))))]
3824   "TARGET_POWERPC"
3825   "mulhw %0,%1,%2"
3826   [(set_attr "type" "imul")])
3828 (define_insn "umulsi3_highpart"
3829   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3830         (truncate:SI
3831          (lshiftrt:DI (mult:DI (zero_extend:DI
3832                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
3833                                (zero_extend:DI
3834                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
3835                       (const_int 32))))]
3836   "TARGET_POWERPC"
3837   "mulhwu %0,%1,%2"
3838   [(set_attr "type" "imul")])
3840 ;; If operands 0 and 2 are in the same register, we have a problem.  But
3841 ;; operands 0 and 1 (the usual case) can be in the same register.  That's
3842 ;; why we have the strange constraints below.
3843 (define_insn "ashldi3_power"
3844   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
3845         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
3846                    (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
3847    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
3848   "TARGET_POWER"
3849   "@
3850    {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
3851    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
3852    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
3853    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
3854   [(set_attr "length" "8")])
3856 (define_insn "lshrdi3_power"
3857   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r,r,&r")
3858         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
3859                      (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
3860    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
3861   "TARGET_POWER"
3862   "@
3863    {cal %0,0(0)|li %0,0}\;{s%A2i|s%A2wi} %L0,%1,%h2
3864    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
3865    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
3866    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
3867   [(set_attr "length" "8")])
3869 ;; Shift by a variable amount is too complex to be worth open-coding.  We
3870 ;; just handle shifts by constants.
3871 (define_insn "ashrdi3_power"
3872   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
3873         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
3874                      (match_operand:SI 2 "const_int_operand" "M,i")))
3875    (clobber (match_scratch:SI 3 "=X,q"))]
3876   "TARGET_POWER"
3877   "@
3878    {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
3879    sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
3880   [(set_attr "length" "8")])
3882 ;; PowerPC64 DImode operations.
3884 (define_expand "adddi3"
3885   [(set (match_operand:DI 0 "gpc_reg_operand" "")
3886         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
3887                  (match_operand:DI 2 "add_operand" "")))]
3888   ""
3889   "
3891   if (! TARGET_POWERPC64 && non_add_cint_operand (operands[2], DImode))
3892     FAIL;
3895 ;; Discourage ai/addic because of carry but provide it in an alternative
3896 ;; allowing register zero as source.
3898 (define_insn ""
3899   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,?r,r")
3900         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,b,r,b")
3901                  (match_operand:DI 2 "add_operand" "r,I,I,J")))]
3902   "TARGET_POWERPC64"
3903   "@
3904    add %0,%1,%2
3905    addi %0,%1,%2
3906    addic %0,%1,%2
3907    addis %0,%1,%u2")
3909 (define_insn ""
3910   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
3911         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
3912                              (match_operand:DI 2 "reg_or_short_operand" "r,I"))
3913                     (const_int 0)))
3914    (clobber (match_scratch:DI 3 "=r,r"))]
3915   "TARGET_POWERPC64"
3916   "@
3917    add. %3,%1,%2
3918    addic. %3,%1,%2"
3919   [(set_attr "type" "compare")])
3921 (define_insn ""
3922   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
3923         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
3924                              (match_operand:DI 2 "reg_or_short_operand" "r,I"))
3925                     (const_int 0)))
3926    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
3927         (plus:DI (match_dup 1) (match_dup 2)))]
3928   "TARGET_POWERPC64"
3929   "@
3930    add. %0,%1,%2
3931    addic. %0,%1,%2"
3932   [(set_attr "type" "compare")])
3934 ;; Split an add that we can't do in one insn into two insns, each of which
3935 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
3936 ;; add should be last in case the result gets used in an address.
3938 (define_split
3939   [(set (match_operand:DI 0 "gpc_reg_operand" "")
3940         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
3941                  (match_operand:DI 2 "non_add_cint_operand" "")))]
3942   "TARGET_POWERPC64"
3943   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
3944    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
3947   int low = INTVAL (operands[2]) & 0xffff;
3948   int high = (unsigned) INTVAL (operands[2]) >> 16;
3950   if (low & 0x8000)
3951     high++, low |= 0xffff0000;
3953   operands[3] = gen_rtx (CONST_INT, VOIDmode, high << 16);
3954   operands[4] = gen_rtx (CONST_INT, VOIDmode, low);
3957 (define_insn "one_cmpldi2"
3958   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3959         (not:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
3960   "TARGET_POWERPC64"
3961   "nor %0,%1,%1")
3963 (define_insn ""
3964   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
3965         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
3966                     (const_int 0)))
3967    (clobber (match_scratch:DI 2 "=r"))]
3968   "TARGET_POWERPC64"
3969   "nor. %2,%1,%1"
3970   [(set_attr "type" "compare")])
3972 (define_insn ""
3973   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
3974         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
3975                     (const_int 0)))
3976    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
3977         (not:DI (match_dup 1)))]
3978   "TARGET_POWERPC64"
3979   "nor. %0,%2,%1"
3980   [(set_attr "type" "compare")])
3982 (define_insn ""
3983   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
3984         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
3985                   (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
3986   "TARGET_POWERPC64"
3987   "@
3988    subf %0,%2,%1
3989    subfic %0,%2,%1")
3991 (define_insn ""
3992   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
3993         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3994                               (match_operand:DI 2 "gpc_reg_operand" "r"))
3995                     (const_int 0)))
3996    (clobber (match_scratch:DI 3 "=r"))]
3997   "TARGET_POWERPC64"
3998   "subf. %3,%2,%1"
3999   [(set_attr "type" "compare")])
4001 (define_insn ""
4002   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4003         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4004                               (match_operand:DI 2 "gpc_reg_operand" "r"))
4005                     (const_int 0)))
4006    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4007         (minus:DI (match_dup 1) (match_dup 2)))]
4008   "TARGET_POWERPC64"
4009   "subf. %0,%2,%1"
4010   [(set_attr "type" "compare")])
4012 (define_expand "subdi3"
4013   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4014         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "")
4015                   (match_operand:DI 2 "reg_or_cint_operand" "")))]
4016   ""
4017   "
4019   if (GET_CODE (operands[2]) == CONST_INT)
4020     {
4021       emit_insn (gen_adddi3 (operands[0], operands[1],
4022                              negate_rtx (DImode, operands[2])));
4023       DONE;
4024     }
4027 (define_insn "absdi2"
4028   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
4029         (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
4030    (clobber (match_scratch:DI 2 "=&r,&r"))]
4031   "TARGET_POWERPC64"
4032   "sradi %2,%1,31\;xor %0,%2,%1\;subf %0,%2,%0"
4033   [(set_attr "length" "12")])
4035 (define_split
4036   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
4037         (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
4038    (clobber (match_scratch:DI 2 "=&r,&r"))]
4039   "TARGET_POWERPC64 && reload_completed"
4040   [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 31)))
4041    (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
4042    (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
4043   "")
4045 (define_insn ""
4046   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
4047         (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
4048    (clobber (match_scratch:DI 2 "=&r,&r"))]
4049   "TARGET_POWERPC64"
4050   "sradi %2,%1,31\;xor %0,%2,%1\;subf %0,%0,%2"
4051   [(set_attr "length" "12")])
4053 (define_split
4054   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
4055         (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
4056    (clobber (match_scratch:DI 2 "=&r,&r"))]
4057   "TARGET_POWERPC64 && reload_completed"
4058   [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 31)))
4059    (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
4060    (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
4061   "")
4063 (define_expand "negdi2"
4064   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4065         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "")))]
4066   ""
4067   "")
4069 (define_insn ""
4070   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4071         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
4072   "TARGET_POWERPC64"
4073   "neg %0,%1")
4075 (define_insn ""
4076   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4077         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4078                     (const_int 0)))
4079    (clobber (match_scratch:DI 2 "=r"))]
4080   "TARGET_POWERPC64"
4081   "neg. %2,%1"
4082   [(set_attr "type" "compare")])
4084 (define_insn ""
4085   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
4086         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4087                     (const_int 0)))
4088    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4089         (neg:DI (match_dup 1)))]
4090   "TARGET_POWERPC64"
4091   "neg. %0,%1"
4092   [(set_attr "type" "compare")])
4094 (define_insn "ffsdi2"
4095   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
4096         (ffs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
4097   "TARGET_POWERPC64"
4098   "neg %0,%1\;and %0,%0,%1\;cntlzd %0,%0\;subfic %0,%0,64"
4099   [(set_attr "length" "16")])
4101 (define_insn "muldi3"
4102   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4103         (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4104                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
4105   "TARGET_POWERPC64"
4106   "mulld %0,%1,%2"
4107    [(set_attr "type" "imul")])
4109 (define_insn "smuldi3_highpart"
4110   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4111         (truncate:DI
4112          (lshiftrt:TI (mult:TI (sign_extend:TI
4113                                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
4114                                (sign_extend:TI
4115                                 (match_operand:DI 2 "gpc_reg_operand" "r")))
4116                       (const_int 64))))]
4117   "TARGET_POWERPC64"
4118   "mulhd %0,%1,%2"
4119   [(set_attr "type" "imul")])
4121 (define_insn "umuldi3_highpart"
4122   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4123         (truncate:DI
4124          (lshiftrt:TI (mult:TI (zero_extend:TI
4125                                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
4126                                (zero_extend:TI
4127                                 (match_operand:DI 2 "gpc_reg_operand" "r")))
4128                       (const_int 64))))]
4129   "TARGET_POWERPC64"
4130   "mulhdu %0,%1,%2"
4131   [(set_attr "type" "imul")])
4133 (define_expand "divdi3"
4134   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4135         (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
4136                 (match_operand:DI 2 "reg_or_cint_operand" "")))]
4137   "TARGET_POWERPC64"
4138   "
4140   if (GET_CODE (operands[2]) == CONST_INT
4141       && exact_log2 (INTVAL (operands[2])) >= 0)
4142     ;
4143   else
4144     operands[2] = force_reg (DImode, operands[2]);
4147 (define_expand "moddi3"
4148   [(use (match_operand:DI 0 "gpc_reg_operand" ""))
4149    (use (match_operand:DI 1 "gpc_reg_operand" ""))
4150    (use (match_operand:DI 2 "reg_or_cint_operand" ""))]
4151   "TARGET_POWERPC64"
4152   "
4154   int i = exact_log2 (INTVAL (operands[2]));
4155   rtx temp1;
4156   rtx temp2;
4158   if (GET_CODE (operands[2]) != CONST_INT || i < 0)
4159     FAIL;
4161   temp1 = gen_reg_rtx (DImode);
4162   temp2 = gen_reg_rtx (DImode);
4164   emit_insn (gen_divdi3 (temp1, operands[1], operands[2]));
4165   emit_insn (gen_ashldi3 (temp2, temp1, GEN_INT (i)));
4166   emit_insn (gen_subdi3 (operands[0], operands[1], temp2));
4167   DONE;
4170 (define_insn ""
4171   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4172         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4173                 (match_operand:DI 2 "const_int_operand" "N")))]
4174   "TARGET_POWERPC64 && exact_log2 (INTVAL (operands[2])) >= 0"
4175   "sradi %0,%1,%p2\;addze %0,%0"
4176   [(set_attr "length" "8")])
4178 (define_insn ""
4179   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4180         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4181                             (match_operand:DI 2 "const_int_operand" "N"))
4182                     (const_int 0)))
4183    (clobber (match_scratch:DI 3 "=r"))]
4184   "TARGET_POWERPC64 && exact_log2 (INTVAL (operands[2])) >= 0"
4185   "sradi %3,%1,%p2\;addze. %3,%3"
4186   [(set_attr "type" "compare")
4187    (set_attr "length" "8")])
4189 (define_insn ""
4190   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4191         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4192                             (match_operand:DI 2 "const_int_operand" "N"))
4193                     (const_int 0)))
4194    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4195         (div:DI (match_dup 1) (match_dup 2)))]
4196   "TARGET_POWERPC64 && exact_log2 (INTVAL (operands[2])) >= 0"
4197   "sradi %0,%1,%p2\;addze. %0,%0"
4198   [(set_attr "type" "compare")
4199    (set_attr "length" "8")])
4201 (define_insn ""
4202   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4203         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4204                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
4205   "TARGET_POWERPC64"
4206   "divd %0,%1,%2"
4207   [(set_attr "type" "idiv")])
4209 (define_insn "udivdi3"
4210   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4211         (udiv:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4212                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
4213   "TARGET_POWERPC64"
4214   "divdu %0,%1,%2"
4215   [(set_attr "type" "idiv")])
4217 (define_insn "rotldi3"
4218   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4219         (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4220                    (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
4221   "TARGET_POWERPC64"
4222   "rld%I2cl %0,%1,%h2,0")
4224 (define_insn ""
4225   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4226         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4227                                (match_operand:DI 2 "reg_or_cint_operand" "ri"))
4228                     (const_int 0)))
4229    (clobber (match_scratch:DI 3 "=r"))]
4230   "TARGET_POWERPC64"
4231   "rld%I2cl. %3,%1,%h2,0"
4232   [(set_attr "type" "delayed_compare")])
4234 (define_insn ""
4235   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4236         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4237                                (match_operand:DI 2 "reg_or_cint_operand" "ri"))
4238                     (const_int 0)))
4239    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4240         (rotate:DI (match_dup 1) (match_dup 2)))]
4241   "TARGET_POWERPC64"
4242   "rld%I2cl. %0,%1,%h2,0"
4243   [(set_attr "type" "delayed_compare")])
4245 (define_expand "ashldi3"
4246   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4247         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
4248                    (match_operand:SI 2 "reg_or_cint_operand" "")))]
4249   "TARGET_POWERPC64 || TARGET_POWER"
4250   "
4252   if (TARGET_POWERPC64)
4253     ;
4254   else if (TARGET_POWER)
4255     {
4256       emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
4257       DONE;
4258     }
4259   else
4260     FAIL;
4263 (define_insn ""
4264   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4265         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4266                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4267   "TARGET_POWERPC64"
4268   "sld%I2 %0,%1,%2"
4269   [(set_attr "length" "8")])
4270   
4271 (define_insn ""
4272   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4273         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4274                                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4275                     (const_int 0)))
4276    (clobber (match_scratch:DI 3 "=r"))]
4277   "TARGET_POWERPC64"
4278   "sld%I2. %3,%1,%2"
4279   [(set_attr "type" "delayed_compare")])
4280   
4281 (define_insn ""
4282   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4283         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4284                                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4285                     (const_int 0)))
4286    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4287         (ashift:DI (match_dup 1) (match_dup 2)))]
4288   "TARGET_POWERPC64"
4289   "sld%I2. %0,%1,%2"
4290   [(set_attr "type" "delayed_compare")])
4292 (define_expand "lshrdi3"
4293   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4294         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
4295                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
4296   "TARGET_POWERPC64 || TARGET_POWER"
4297   "
4299   if (TARGET_POWERPC64)
4300     ;
4301   else if (TARGET_POWER)
4302     {
4303       emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
4304       DONE;
4305     }
4306   else
4307     FAIL;
4310 (define_insn ""
4311   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4312         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4313                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4314   "TARGET_POWERPC64"
4315   "srd%I2 %0,%1,%2")
4317 (define_insn ""
4318   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4319         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4320                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4321                     (const_int 0)))
4322    (clobber (match_scratch:DI 3 "=r"))]
4323   "TARGET_POWERPC64"
4324   "srd%I2. %3,%1,%2"
4325   [(set_attr "type" "delayed_compare")])
4327 (define_insn ""
4328   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4329         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4330                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4331                     (const_int 0)))
4332    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4333         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
4334   "TARGET_POWERPC64"
4335   "srd%I2. %0,%1,%2"
4336   [(set_attr "type" "delayed_compare")])
4338 (define_expand "ashrdi3"
4339   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4340         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
4341                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
4342   "TARGET_POWERPC64 || TARGET_POWER"
4343   "
4345   if (TARGET_POWERPC64)
4346     ;
4347   else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
4348     {
4349       emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
4350       DONE;
4351     }
4352   else
4353     FAIL;
4356 (define_insn ""
4357   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4358         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4359                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4360   "TARGET_POWERPC64"
4361   "srad%I2 %0,%1,%2")
4363 (define_insn ""
4364   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4365         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4366                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4367                     (const_int 0)))
4368    (clobber (match_scratch:DI 3 "=r"))]
4369   "TARGET_POWERPC64"
4370   "srad%I2. %3,%1,%2"
4371   [(set_attr "type" "delayed_compare")])
4373 (define_insn ""
4374   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4375         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4376                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4377                     (const_int 0)))
4378    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4379         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
4380   "TARGET_POWERPC64"
4381   "srad%I2. %0,%1,%2"
4382   [(set_attr "type" "delayed_compare")])
4384 (define_insn "anddi3"
4385   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
4386         (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4387                 (match_operand:DI 2 "and_operand" "?r,K,J")))
4388    (clobber (match_scratch:CC 3 "=X,x,x"))]
4389   "TARGET_POWERPC64"
4390   "@
4391    and %0,%1,%2
4392    andi. %0,%1,%b2
4393    andis. %0,%1,%u2")
4395 (define_insn ""
4396   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x")
4397         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4398                             (match_operand:DI 2 "and_operand" "r,K,J"))
4399                     (const_int 0)))
4400    (clobber (match_scratch:DI 3 "=r,r,r"))]
4401   "TARGET_POWERPC64"
4402   "@
4403    and. %3,%1,%2
4404    andi. %3,%1,%b2
4405    andis. %3,%1,%u2"
4406   [(set_attr "type" "compare,compare,compare")])
4408 (define_insn ""
4409   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x")
4410         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4411                             (match_operand:DI 2 "and_operand" "r,K,J"))
4412                     (const_int 0)))
4413    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
4414         (and:DI (match_dup 1) (match_dup 2)))]
4415   "TARGET_POWERPC64"
4416   "@
4417    and. %0,%1,%2
4418    andi. %0,%1,%b2
4419    andis. %0,%1,%u2"
4420   [(set_attr "type" "compare,compare,compare")])
4422 ;; Take a AND with a constant that cannot be done in a single insn and try to
4423 ;; split it into two insns.  This does not verify that the insns are valid
4424 ;; since this need not be done as combine will do it.
4426 (define_split
4427   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4428         (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
4429                 (match_operand:DI 2 "non_and_cint_operand" "")))]
4430   "TARGET_POWERPC64"
4431   [(set (match_dup 0) (and:DI (match_dup 1) (match_dup 3)))
4432    (set (match_dup 0) (and:DI (match_dup 0) (match_dup 4)))]
4433   "
4435   int maskval = INTVAL (operands[2]);
4436   int i, transitions, last_bit_value;
4437   int orig = maskval, first_c = maskval, second_c;
4439   /* We know that MASKVAL must have more than 2 bit-transitions.  Start at
4440      the low-order bit and count for the third transition.  When we get there,
4441      make a first mask that has everything to the left of that position
4442      a one.  Then make the second mask to turn off whatever else is needed.  */
4444   for (i = 1, transitions = 0, last_bit_value = maskval & 1; i < 32; i++)
4445     {
4446       if (((maskval >>= 1) & 1) != last_bit_value)
4447         last_bit_value ^= 1, transitions++;
4449       if (transitions > 2)
4450         {
4451           first_c |= (~0) << i;
4452           break;
4453         }
4454     }
4456   second_c = orig | ~ first_c;
4458   operands[3] = gen_rtx (CONST_INT, VOIDmode, first_c);
4459   operands[4] = gen_rtx (CONST_INT, VOIDmode, second_c);
4462 (define_insn "iordi3"
4463   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
4464         (ior:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4465                 (match_operand:DI 2 "logical_operand" "r,K,J")))]
4466   "TARGET_POWERPC64"
4467   "@
4468    or %0,%1,%2
4469    ori %0,%1,%b2
4470    oris %0,%1,%u2")
4472 (define_insn ""
4473   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4474         (compare:CC (ior:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4475                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4476                     (const_int 0)))
4477    (clobber (match_scratch:DI 3 "=r"))]
4478   "TARGET_POWERPC64"
4479   "or. %3,%1,%2"
4480   [(set_attr "type" "compare")])
4482 (define_insn ""
4483   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4484         (compare:CC (ior:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4485                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4486                     (const_int 0)))
4487    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4488         (ior:DI (match_dup 1) (match_dup 2)))]
4489   "TARGET_POWERPC64"
4490   "or. %0,%1,%2"
4491   [(set_attr "type" "compare")])
4493 ;; Split an IOR that we can't do in one insn into two insns, each of which
4494 ;; does one 16-bit part.  This is used by combine.
4496 (define_split
4497   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4498         (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
4499                 (match_operand:DI 2 "non_logical_cint_operand" "")))]
4500   "TARGET_POWERPC64"
4501   [(set (match_dup 0) (ior:DI (match_dup 1) (match_dup 3)))
4502    (set (match_dup 0) (ior:DI (match_dup 0) (match_dup 4)))]
4505   operands[3] = gen_rtx (CONST_INT, VOIDmode,
4506                          INTVAL (operands[2]) & 0xffff0000);
4507   operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
4510 (define_insn "xordi3"
4511   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
4512         (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4513                 (match_operand:DI 2 "logical_operand" "r,K,J")))]
4514   "TARGET_POWERPC64"
4515   "@
4516    xor %0,%1,%2
4517    xori %0,%1,%b2
4518    xoris %0,%1,%u2")
4520 (define_insn ""
4521   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4522         (compare:CC (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4523                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4524                     (const_int 0)))
4525    (clobber (match_scratch:DI 3 "=r"))]
4526   "TARGET_POWERPC64"
4527   "xor. %3,%1,%2"
4528   [(set_attr "type" "compare")])
4530 (define_insn ""
4531   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4532         (compare:CC (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4533                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4534                     (const_int 0)))
4535    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4536         (xor:DI (match_dup 1) (match_dup 2)))]
4537   "TARGET_POWERPC64"
4538   "xor. %0,%1,%2"
4539   [(set_attr "type" "compare")])
4541 ;; Split an XOR that we can't do in one insn into two insns, each of which
4542 ;; does one 16-bit part.  This is used by combine.
4544 (define_split
4545   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4546         (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
4547                 (match_operand:DI 2 "non_logical_cint_operand" "")))]
4548   "TARGET_POWERPC64"
4549   [(set (match_dup 0) (xor:DI (match_dup 1) (match_dup 3)))
4550    (set (match_dup 0) (xor:DI (match_dup 0) (match_dup 4)))]
4553   operands[3] = gen_rtx (CONST_INT, VOIDmode,
4554                          INTVAL (operands[2]) & 0xffff0000);
4555   operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
4558 (define_insn ""
4559   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4560         (not:DI (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4561                         (match_operand:DI 2 "gpc_reg_operand" "r"))))]
4562    "TARGET_POWERPC64"
4563    "eqv %0,%1,%2")
4565 (define_insn ""
4566   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4567         (compare:CC (not:DI (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4568                                     (match_operand:DI 2 "gpc_reg_operand" "r")))
4569                     (const_int 0)))
4570    (clobber (match_scratch:DI 3 "=r"))]
4571    "TARGET_POWERPC64"
4572    "eqv. %3,%1,%2"
4573    [(set_attr "type" "compare")])
4575 (define_insn ""
4576   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4577         (compare:CC (not:DI (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4578                                     (match_operand:DI 2 "gpc_reg_operand" "r")))
4579                     (const_int 0)))
4580    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4581         (not:DI (xor:DI (match_dup 1) (match_dup 2))))]
4582    "TARGET_POWERPC64"
4583    "eqv. %0,%1,%2"
4584    [(set_attr "type" "compare")])
4586 (define_insn ""
4587   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4588         (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4589                 (match_operand:DI 2 "gpc_reg_operand" "r")))]
4590   "TARGET_POWERPC64"
4591   "andc %0,%2,%1")
4593 (define_insn ""
4594   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4595         (compare:CC (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4596                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4597                     (const_int 0)))
4598    (clobber (match_scratch:DI 3 "=r"))]
4599   "TARGET_POWERPC64"
4600   "andc. %3,%2,%1"
4601   [(set_attr "type" "compare")])
4603 (define_insn ""
4604   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4605         (compare:CC (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4606                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4607                     (const_int 0)))
4608    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4609         (and:DI (not:DI (match_dup 1)) (match_dup 2)))]
4610   "TARGET_POWERPC64"
4611   "andc. %0,%2,%1"
4612   [(set_attr "type" "compare")])
4614 (define_insn ""
4615   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4616         (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4617                 (match_operand:DI 2 "gpc_reg_operand" "r")))]
4618   "TARGET_POWERPC64"
4619   "orc %0,%2,%1")
4621 (define_insn ""
4622   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4623         (compare:CC (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4624                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4625                     (const_int 0)))
4626    (clobber (match_scratch:DI 3 "=r"))]
4627   "TARGET_POWERPC64"
4628   "orc. %3,%2,%1"
4629   [(set_attr "type" "compare")])
4631 (define_insn ""
4632   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4633         (compare:CC (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4634                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4635                     (const_int 0)))
4636    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4637         (ior:DI (not:DI (match_dup 1)) (match_dup 2)))]
4638   "TARGET_POWERPC64"
4639   "orc. %0,%2,%1"
4640   [(set_attr "type" "compare")])
4642 (define_insn ""
4643   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4644         (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4645                 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))))]
4646   "TARGET_POWERPC64"
4647   "nand %0,%1,%2")
4649 (define_insn ""
4650   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4651         (compare:CC (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4652                             (not:DI (match_operand:DI 2 "gpc_reg_operand" "r")))
4653                     (const_int 0)))
4654    (clobber (match_scratch:DI 3 "=r"))]
4655   "TARGET_POWERPC64"
4656   "nand. %3,%1,%2"
4657   [(set_attr "type" "compare")])
4659 (define_insn ""
4660   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4661         (compare:CC (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4662                             (not:DI (match_operand:DI 2 "gpc_reg_operand" "r")))
4663                     (const_int 0)))
4664    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4665         (ior:DI (not:DI (match_dup 1)) (not:DI (match_dup 2))))]
4666   "TARGET_POWERPC64"
4667   "nand. %0,%1,%2"
4668   [(set_attr "type" "compare")])
4670 (define_insn ""
4671   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4672         (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4673                 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))))]
4674   "TARGET_POWERPC64"
4675   "nor %0,%1,%2")
4677 (define_insn ""
4678   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4679         (compare:CC (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4680                             (not:DI (match_operand:DI 2 "gpc_reg_operand" "r")))
4681                     (const_int 0)))
4682    (clobber (match_scratch:DI 3 "=r"))]
4683   "TARGET_POWERPC64"
4684   "nor. %3,%1,%2"
4685   [(set_attr "type" "compare")])
4687 (define_insn ""
4688   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4689         (compare:CC (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4690                             (not:DI (match_operand:DI 2 "gpc_reg_operand" "r")))
4691                     (const_int 0)))
4692    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4693         (and:DI (not:DI (match_dup 1)) (not:DI (match_dup 2))))]
4694   "TARGET_POWERPC64"
4695   "nor. %0,%1,%2"
4696   [(set_attr "type" "compare")])
4698 ;; Now define ways of moving data around.
4700 ;; Elf specific ways of loading addresses for non-PIC code.
4701 ;; The output of this could be r0, but we limit it to base
4702 ;; registers, since almost all uses of this will need it
4703 ;; in a base register shortly.
4704 (define_insn "elf_high"
4705   [(set (match_operand:SI 0 "register_operand" "=b")
4706         (high:SI (match_operand 1 "" "")))]
4707   "TARGET_ELF && !TARGET_64BIT"
4708   "{cau|addis} %0,0,%1@ha")
4710 (define_insn "elf_low"
4711   [(set (match_operand:SI 0 "register_operand" "=r")
4712         (lo_sum:SI (match_operand:SI 1 "register_operand" "b")
4713                    (match_operand 2 "" "")))]
4714    "TARGET_ELF && !TARGET_64BIT"
4715    "{cal %0,%a2@l(%1)|addi %0,%1,%2@l}")
4717 ;; For SI, we special-case integers that can't be loaded in one insn.  We
4718 ;; do the load 16-bits at a time.  We could do this by loading from memory,
4719 ;; and this is even supposed to be faster, but it is simpler not to get
4720 ;; integers in the TOC.
4721 (define_expand "movsi"
4722   [(set (match_operand:SI 0 "general_operand" "")
4723         (match_operand:SI 1 "any_operand" ""))]
4724   ""
4725   "
4727   if (GET_CODE (operands[0]) != REG)
4728     operands[1] = force_reg (SImode, operands[1]);
4730   /* Convert a move of a CONST_DOUBLE into a CONST_INT */
4731   if (GET_CODE (operands[1]) == CONST_DOUBLE)
4732     operands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
4734   if (TARGET_ELF && TARGET_NO_TOC && !TARGET_64BIT
4735       && CONSTANT_P (operands[1])
4736       && GET_CODE (operands[1]) != HIGH
4737       && GET_CODE (operands[1]) != CONST_INT)
4738     {
4739       rtx target = (reload_completed || reload_in_progress)
4740                         ? operands[0] : gen_reg_rtx (SImode);
4742       /* If this is a function address on -mcall-aixdesc or -mcall-nt,
4743          convert it to the address of the descriptor.  */
4744       if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)
4745           && GET_CODE (operands[1]) == SYMBOL_REF
4746           && XSTR (operands[1], 0)[0] == '.')
4747         {
4748           char *name = XSTR (operands[1], 0);
4749           rtx new_ref;
4750           while (*name == '.')
4751             name++;
4752           new_ref = gen_rtx (SYMBOL_REF, Pmode, name);
4753           CONSTANT_POOL_ADDRESS_P (new_ref) = CONSTANT_POOL_ADDRESS_P (operands[1]);
4754           SYMBOL_REF_FLAG (new_ref) = SYMBOL_REF_FLAG (operands[1]);
4755           SYMBOL_REF_USED (new_ref) = SYMBOL_REF_USED (operands[1]);
4756           operands[1] = new_ref;
4757         }
4759       emit_insn (gen_elf_high (target, operands[1]));
4760       emit_insn (gen_elf_low (operands[0], target, operands[1]));
4761       DONE;
4762     }
4764   if (GET_CODE (operands[1]) == CONST
4765       && DEFAULT_ABI == ABI_NT
4766       && !side_effects_p (operands[0]))
4767     {
4768       rtx const_term = const0_rtx;
4769       rtx sym = eliminate_constant_term (XEXP (operands[1], 0), &const_term);
4770       if (sym && GET_CODE (const_term) == CONST_INT
4771           && (GET_CODE (sym) == SYMBOL_REF || GET_CODE (sym) == LABEL_REF))
4772         {
4773           emit_insn (gen_movsi (operands[0], sym));
4774           if (INTVAL (const_term) != 0)
4775             {
4776               unsigned HOST_WIDE_INT value = INTVAL (const_term);
4777               if (value + 0x8000 < 0x10000)
4778                 emit_insn (gen_addsi3 (operands[0], operands[0], GEN_INT (value)));
4779               else
4780                 {
4781                   emit_insn (gen_addsi3 (operands[0], operands[0],
4782                                          GEN_INT ((value >> 16) + ((value >> 15) & 1))));
4784                   if ((value & 0xffff) != 0)
4785                     emit_insn (gen_addsi3 (operands[0], operands[0],
4786                                            GEN_INT (value & 0xffff)));
4787                 }
4788             }
4789           DONE;
4790         }
4791       else
4792         fatal_insn (\"bad address\", operands[1]);
4793     }
4795   if ((!TARGET_WINDOWS_NT || DEFAULT_ABI != ABI_NT)
4796       && CONSTANT_P (operands[1])
4797       && GET_CODE (operands[1]) != CONST_INT
4798       && GET_CODE (operands[1]) != HIGH
4799       && ! LEGITIMATE_CONSTANT_POOL_ADDRESS_P (operands[1]))
4800     {
4801       /* If we are to limit the number of things we put in the TOC and
4802          this is a symbol plus a constant we can add in one insn,
4803          just put the symbol in the TOC and add the constant.  Don't do
4804          this if reload is in progress.  */
4805       if (GET_CODE (operands[1]) == CONST
4806           && TARGET_NO_SUM_IN_TOC && ! reload_in_progress
4807           && GET_CODE (XEXP (operands[1], 0)) == PLUS
4808           && add_operand (XEXP (XEXP (operands[1], 0), 1), SImode)
4809           && (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF
4810               || GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == SYMBOL_REF)
4811           && ! side_effects_p (operands[0]))
4812         {
4813           rtx sym = force_const_mem (SImode, XEXP (XEXP (operands[1], 0), 0));
4814           rtx other = XEXP (XEXP (operands[1], 0), 1);
4816           emit_insn (gen_addsi3 (operands[0], force_reg (SImode, sym), other));
4817           DONE;
4818         }
4820       operands[1] = force_const_mem (SImode, operands[1]);
4821       if (! memory_address_p (SImode, XEXP (operands[1], 0))
4822           && ! reload_in_progress)
4823         operands[1] = change_address (operands[1], SImode,
4824                                       XEXP (operands[1], 0));
4825     }
4828 (define_insn ""
4829   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,m,r,r,r,r,r,*q,*c*l,*h")
4830         (match_operand:SI 1 "input_operand" "r,S,T,m,r,I,J,n,R,*h,r,r,0"))]
4831   "gpc_reg_operand (operands[0], SImode)
4832    || gpc_reg_operand (operands[1], SImode)"
4833   "@
4834    mr %0,%1
4835    {l|lwz} %0,[toc]%1(2)
4836    {l|lwz} %0,[toc]%l1(2)
4837    {l%U1%X1|lwz%U1%X1} %0,%1
4838    {st%U0%X0|stw%U0%X0} %1,%0
4839    {lil|li} %0,%1
4840    {liu|lis} %0,%u1
4841    #
4842    {cal|la} %0,%1(%*)
4843    mf%1 %0
4844    mt%0 %1
4845    mt%0 %1
4846    cror 0,0,0"
4847   [(set_attr "type" "*,load,load,load,*,*,*,*,*,*,*,mtjmpr,*")
4848    (set_attr "length" "4,4,4,4,4,4,4,8,4,4,4,4,4")])
4850 ;; Split a load of a large constant into the appropriate two-insn
4851 ;; sequence.
4853 (define_split
4854   [(set (match_operand:SI 0 "gpc_reg_operand" "")
4855         (match_operand:SI 1 "const_int_operand" ""))]
4856   "(unsigned) (INTVAL (operands[1]) + 0x8000) >= 0x10000
4857    && (INTVAL (operands[1]) & 0xffff) != 0"
4858   [(set (match_dup 0)
4859         (match_dup 2))
4860    (set (match_dup 0)
4861         (ior:SI (match_dup 0)
4862                 (match_dup 3)))]
4863   "
4865   operands[2] = gen_rtx (CONST_INT, VOIDmode,
4866                          INTVAL (operands[1]) & 0xffff0000);
4867   operands[3] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) & 0xffff);
4870 (define_insn ""
4871   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
4872         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
4873                     (const_int 0)))
4874    (set (match_operand:SI 0 "gpc_reg_operand" "=r") (match_dup 1))]
4875   ""
4876   "mr. %0,%1"
4877   [(set_attr "type" "compare")])
4879 (define_expand "movhi"
4880   [(set (match_operand:HI 0 "general_operand" "")
4881         (match_operand:HI 1 "any_operand" ""))]
4882   ""
4883   "
4885   if (GET_CODE (operands[0]) != REG)
4886     operands[1] = force_reg (HImode, operands[1]);
4888   if (CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != CONST_INT)
4889     {
4890       operands[1] = force_const_mem (HImode, operands[1]);
4891       if (! memory_address_p (HImode, XEXP (operands[1], 0))
4892           && ! reload_in_progress)
4893         operands[1] = change_address (operands[1], HImode,
4894                                       XEXP (operands[1], 0));
4895     }
4898 (define_insn ""
4899   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
4900         (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
4901   "gpc_reg_operand (operands[0], HImode)
4902    || gpc_reg_operand (operands[1], HImode)"
4903   "@
4904    mr %0,%1
4905    lhz%U1%X1 %0,%1
4906    sth%U0%X0 %1,%0
4907    {lil|li} %0,%w1
4908    mf%1 %0
4909    mt%0 %1
4910    mt%0 %1
4911    cror 0,0,0"
4912   [(set_attr "type" "*,load,*,*,*,*,mtjmpr,*")])
4914 (define_expand "movqi"
4915   [(set (match_operand:QI 0 "general_operand" "")
4916         (match_operand:QI 1 "any_operand" ""))]
4917   ""
4918   "
4920   if (GET_CODE (operands[0]) != REG)
4921     operands[1] = force_reg (QImode, operands[1]);
4923   if (CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != CONST_INT)
4924     {
4925       operands[1] = force_const_mem (QImode, operands[1]);
4926       if (! memory_address_p (QImode, XEXP (operands[1], 0))
4927           && ! reload_in_progress)
4928         operands[1] = change_address (operands[1], QImode,
4929                                       XEXP (operands[1], 0));
4930     }
4933 (define_insn ""
4934   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
4935         (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
4936   "gpc_reg_operand (operands[0], QImode)
4937    || gpc_reg_operand (operands[1], QImode)"
4938   "@
4939    mr %0,%1
4940    lbz%U1%X1 %0,%1
4941    stb%U0%X0 %1,%0
4942    {lil|li} %0,%1
4943    mf%1 %0
4944    mt%0 %1
4945    mt%0 %1
4946    cror 0,0,0"
4947   [(set_attr "type" "*,load,*,*,*,*,mtjmpr,*")])
4949 ;; Here is how to move condition codes around.  When we store CC data in
4950 ;; an integer register or memory, we store just the high-order 4 bits.
4951 ;; This lets us not shift in the most common case of CR0.
4952 (define_expand "movcc"
4953   [(set (match_operand:CC 0 "nonimmediate_operand" "")
4954         (match_operand:CC 1 "nonimmediate_operand" ""))]
4955   ""
4956   "")
4958 (define_insn ""
4959   [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,y,r,r,r,r,m")
4960         (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,m,r"))]
4961   "register_operand (operands[0], CCmode)
4962    || register_operand (operands[1], CCmode)"
4963   "@
4964    mcrf %0,%1
4965    mtcrf 128,%1
4966    {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
4967    mfcr %0
4968    mfcr %0\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
4969    mr %0,%1
4970    {l%U1%X1|lwz%U1%X1} %0,%1
4971    {st%U0%U1|stw%U0%U1} %1,%0"
4972   [(set_attr "type" "*,*,*,compare,*,*,load,*")
4973    (set_attr "length" "*,*,12,*,8,*,*,*")])
4975 ;; For floating-point, we normally deal with the floating-point registers
4976 ;; unless -msoft-float is used.  The sole exception is that parameter passing
4977 ;; can produce floating-point values in fixed-point registers.  Unless the
4978 ;; value is a simple constant or already in memory, we deal with this by
4979 ;; allocating memory and copying the value explicitly via that memory location.
4980 (define_expand "movsf"
4981   [(set (match_operand:SF 0 "nonimmediate_operand" "")
4982         (match_operand:SF 1 "any_operand" ""))]
4983   ""
4984   "
4986   /* If we are called from reload, we might be getting a SUBREG of a hard
4987      reg.  So expand it.  */
4988   if (GET_CODE (operands[0]) == SUBREG
4989       && GET_CODE (SUBREG_REG (operands[0])) == REG
4990       && REGNO (SUBREG_REG (operands[0])) < FIRST_PSEUDO_REGISTER)
4991     operands[0] = alter_subreg (operands[0]);
4992   if (GET_CODE (operands[1]) == SUBREG
4993       && GET_CODE (SUBREG_REG (operands[1])) == REG
4994       && REGNO (SUBREG_REG (operands[1])) < FIRST_PSEUDO_REGISTER)
4995     operands[1] = alter_subreg (operands[1]);
4997   if (TARGET_SOFT_FLOAT && GET_CODE (operands[0]) == MEM)
4998     operands[1] = force_reg (SFmode, operands[1]);
5000   else if (TARGET_HARD_FLOAT)
5001     {
5002       if (GET_CODE (operands[1]) == REG && REGNO (operands[1]) < 32)
5003         {
5004           /* If this is a store to memory or another integer register do the
5005              move directly.  Otherwise store to a temporary stack slot and
5006              load from there into a floating point register.  */
5008           if (GET_CODE (operands[0]) == MEM
5009               || (GET_CODE (operands[0]) == REG
5010                   && (REGNO (operands[0]) < 32
5011                       || (reload_in_progress
5012                           && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))))
5013             {
5014               emit_move_insn (operand_subword (operands[0], 0, 0, SFmode),
5015                               operand_subword (operands[1], 0, 0, SFmode));
5016               DONE;
5017             }
5018           else
5019             {
5020               rtx stack_slot = assign_stack_temp (SFmode, 4, 0);
5022               emit_move_insn (stack_slot, operands[1]);
5023               emit_move_insn (operands[0], stack_slot);
5024               DONE;
5025             }
5026         }
5028       if (GET_CODE (operands[0]) == MEM)
5029         {
5030           /* If operands[1] is a register, it may have double-precision data
5031              in it, so truncate it to single precision.  We need not do
5032              this for POWERPC.  */
5033           if (! TARGET_POWERPC && TARGET_HARD_FLOAT
5034               && GET_CODE (operands[1]) == REG)
5035             {
5036               rtx newreg
5037                 = reload_in_progress ? operands[1] : gen_reg_rtx (SFmode);
5038               emit_insn (gen_aux_truncdfsf2 (newreg, operands[1]));
5039               operands[1] = newreg;
5040             }
5042           operands[1] = force_reg (SFmode, operands[1]);
5043         }
5045       if (GET_CODE (operands[0]) == REG && REGNO (operands[0]) < 32)
5046         {
5047           if (GET_CODE (operands[1]) == MEM
5048 #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT && ! defined(REAL_IS_NOT_DOUBLE)
5049               || GET_CODE (operands[1]) == CONST_DOUBLE
5050 #endif
5051               || (GET_CODE (operands[1]) == REG
5052                   && (REGNO (operands[1]) < 32
5053                       || (reload_in_progress
5054                           && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER))))
5055             {
5056               emit_move_insn (operand_subword (operands[0], 0, 0, SFmode),
5057                               operand_subword (operands[1], 0, 0, SFmode));
5058               DONE;
5059             }
5060           else
5061             {
5062               rtx stack_slot = assign_stack_temp (SFmode, 4, 0);
5064               emit_move_insn (stack_slot, operands[1]);
5065               emit_move_insn (operands[0], stack_slot);
5066               DONE;
5067             }
5068         }
5069     }
5071   if (CONSTANT_P (operands[1]))
5072     {
5073       operands[1] = force_const_mem (SFmode, operands[1]);
5074       if (! memory_address_p (SFmode, XEXP (operands[1], 0))
5075           && ! reload_in_progress)
5076         operands[1] = change_address (operands[1], SFmode,
5077                                       XEXP (operands[1], 0));
5078     }
5081 (define_split
5082   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5083         (match_operand:SF 1 "easy_fp_constant" ""))]
5084   "reload_completed && REGNO (operands[0]) <= 31"
5085   [(set (match_dup 2) (match_dup 3))]
5086   "
5087 { operands[2] = operand_subword (operands[0], 0, 0, SFmode);
5088   operands[3] = operand_subword (operands[1], 0, 0, SFmode); }")
5090 (define_insn ""
5091   [(set (match_operand:SF 0 "fp_reg_or_mem_operand" "=f,f,m")
5092         (match_operand:SF 1 "input_operand" "f,m,f"))]
5093   "(gpc_reg_operand (operands[0], SFmode)
5094    || gpc_reg_operand (operands[1], SFmode)) && TARGET_HARD_FLOAT"
5095   "@
5096    fmr %0,%1
5097    lfs%U1%X1 %0,%1
5098    stfs%U0%X0 %1,%0"
5099   [(set_attr "type" "fp,fpload,*")])
5101 (define_insn ""
5102   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
5103         (match_operand:SF 1 "input_operand" "r,m,r,I,J,R"))]
5104   "(gpc_reg_operand (operands[0], SFmode)
5105    || gpc_reg_operand (operands[1], SFmode)) && TARGET_SOFT_FLOAT"
5106   "@
5107    mr %0,%1
5108    {l%U1%X1|lwz%U1%X1} %0,%1
5109    {st%U0%X0|stw%U0%X0} %1,%0
5110    {lil|li} %0,%1
5111    {liu|lis} %0,%u1
5112    {cal|la} %0,%1(%*)"
5113   [(set_attr "type" "*,load,*,*,*,*")])
5116 (define_expand "movdf"
5117   [(set (match_operand:DF 0 "nonimmediate_operand" "")
5118         (match_operand:DF 1 "any_operand" ""))]
5119   ""
5120   "
5122   if (GET_CODE (operands[0]) != REG)
5123     operands[1] = force_reg (DFmode, operands[1]);
5125   if (CONSTANT_P (operands[1]) && ! easy_fp_constant (operands[1], DFmode))
5126     {
5127       operands[1] = force_const_mem (DFmode, operands[1]);
5128       if (! memory_address_p (DFmode, XEXP (operands[1], 0))
5129           && ! reload_in_progress)
5130         operands[1] = change_address (operands[1], DFmode,
5131                                       XEXP (operands[1], 0));
5132     }
5135 (define_split
5136   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5137         (match_operand:DF 1 "easy_fp_constant" ""))]
5138   "reload_completed && REGNO (operands[0]) <= 31"
5139   [(set (match_dup 2) (match_dup 3))
5140    (set (match_dup 4) (match_dup 5))]
5141   "
5142 { operands[2] = operand_subword (operands[0], 0, 0, DFmode);
5143   operands[3] = operand_subword (operands[1], 0, 0, DFmode);
5144   operands[4] = operand_subword (operands[0], 1, 0, DFmode);
5145   operands[5] = operand_subword (operands[1], 1, 0, DFmode); }")
5147 ;; Don't have reload use general registers to load a constant.  First,
5148 ;; it might not work if the output operand has is the equivalent of
5149 ;; a non-offsettable memref, but also it is less efficient than loading
5150 ;; the constant into an FP register, since it will probably be used there.
5151 ;; The "??" is a kludge until we can figure out a more reasonable way
5152 ;; of handling these non-offsettable values.
5153 (define_insn ""
5154   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,o,!r,f,f,m")
5155         (match_operand:DF 1 "input_operand" "r,o,r,G,f,m,f"))]
5156   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT
5157    && (register_operand (operands[0], DFmode)
5158        || register_operand (operands[1], DFmode))"
5159   "*
5161   switch (which_alternative)
5162     {
5163     case 0:
5164       /* We normally copy the low-numbered register first.  However, if
5165          the first register operand 0 is the same as the second register of
5166          operand 1, we must copy in the opposite order.  */
5167       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
5168         return \"mr %L0,%L1\;mr %0,%1\";
5169       else
5170         return \"mr %0,%1\;mr %L0,%L1\";
5171     case 1:
5172       /* If the low-address word is used in the address, we must load it
5173          last.  Otherwise, load it first.  Note that we cannot have
5174          auto-increment in that case since the address register is known to be
5175          dead.  */
5176       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5177                              operands [1], 0))
5178         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
5179       else
5180         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
5181     case 2:
5182       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
5183     case 3:
5184       return \"#\";
5185     case 4:
5186       return \"fmr %0,%1\";
5187     case 5:
5188       return \"lfd%U1%X1 %0,%1\";
5189     case 6:
5190       return \"stfd%U0%X0 %1,%0\";
5191     }
5193   [(set_attr "type" "*,load,*,*,fp,fpload,*")
5194    (set_attr "length" "8,8,8,8,*,*,*")])
5196 (define_insn ""
5197   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,o,r")
5198         (match_operand:DF 1 "input_operand" "r,o,r,G"))]
5199   "! TARGET_POWERPC64 && TARGET_SOFT_FLOAT
5200    && (register_operand (operands[0], DFmode)
5201        || register_operand (operands[1], DFmode))"
5202   "*
5204   switch (which_alternative)
5205     {
5206     case 0:
5207       /* We normally copy the low-numbered register first.  However, if
5208          the first register operand 0 is the same as the second register of
5209          operand 1, we must copy in the opposite order.  */
5210       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
5211         return \"mr %L0,%L1\;mr %0,%1\";
5212       else
5213         return \"mr %0,%1\;mr %L0,%L1\";
5214     case 1:
5215       /* If the low-address word is used in the address, we must load it
5216          last.  Otherwise, load it first.  Note that we cannot have
5217          auto-increment in that case since the address register is known to be
5218          dead.  */
5219       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5220                              operands [1], 0))
5221         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
5222       else
5223         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
5224     case 2:
5225       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
5226     case 3:
5227       return \"#\";
5228     }
5230   [(set_attr "type" "*,load,*,*")
5231    (set_attr "length" "8,8,8,8")])
5233 (define_insn ""
5234   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,o,!r,f,f,m")
5235         (match_operand:DF 1 "input_operand" "r,o,r,G,f,m,f"))]
5236   "TARGET_POWERPC64 && TARGET_HARD_FLOAT
5237    && (register_operand (operands[0], DFmode)
5238        || register_operand (operands[1], DFmode))"
5239   "@
5240    mr %0,%1
5241    ld%U1%X1 %0,%1
5242    sd%U0%X0 %1,%0
5243    #
5244    fmr %0,%1
5245    lfd%U1%X1 %0,%1
5246    stfd%U0%X0 %1,%0"
5247   [(set_attr "type" "*,load,*,*,fp,fpload,*")])
5249 (define_insn ""
5250   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,o,r")
5251         (match_operand:DF 1 "input_operand" "r,o,r,G"))]
5252   "TARGET_POWERPC64 && TARGET_SOFT_FLOAT
5253    && (register_operand (operands[0], DFmode)
5254        || register_operand (operands[1], DFmode))"
5255   "@
5256    mr %0,%1
5257    ld%U1%X1 %0,%1
5258    sd%U0%X0 %1,%0
5259    #"
5260   [(set_attr "type" "*,load,*,*")])
5262 ;; Next come the multi-word integer load and store and the load and store
5263 ;; multiple insns.
5264 (define_expand "movdi"
5265   [(set (match_operand:DI 0 "general_operand" "")
5266         (match_operand:DI 1 "general_operand" ""))]
5267   ""
5268   "
5270   if (GET_CODE (operands[0]) == MEM)
5271     operands[1] = force_reg (DImode, operands[1]);
5273   if (GET_CODE (operands[1]) == CONST_DOUBLE
5274       || GET_CODE (operands[1]) == CONST_INT)
5275     {
5276       HOST_WIDE_INT low;
5277       HOST_WIDE_INT high;
5279       if (GET_CODE (operands[1]) == CONST_DOUBLE)
5280         {
5281           low = CONST_DOUBLE_LOW (operands[1]);
5282           high = CONST_DOUBLE_HIGH (operands[1]);
5283         }
5284       else
5285         {
5286           low = INTVAL (operands[1]);
5287           high = (low < 0) ? ~0 : 0;
5288         }
5290       emit_move_insn (gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN),
5291                       GEN_INT (low));
5293       emit_move_insn (gen_rtx (SUBREG, SImode, operands[0], !WORDS_BIG_ENDIAN),
5294                       GEN_INT (high));
5295       DONE;
5296     }
5298       /* Stores between FPR and any non-FPR registers must go through a
5299          temporary stack slot.  */
5301   if (GET_CODE (operands[0]) == REG && GET_CODE (operands[1]) == REG
5302       && ((FP_REGNO_P (REGNO (operands[0]))
5303            && ! FP_REGNO_P (REGNO (operands[1])))
5304           || (FP_REGNO_P (REGNO (operands[1]))
5305               && ! FP_REGNO_P (REGNO (operands[0])))))
5306     {
5307       rtx stack_slot = assign_stack_temp (DImode, 8, 0);
5309       emit_move_insn (stack_slot, operands[1]);
5310       emit_move_insn (operands[0], stack_slot);
5311       DONE;
5312     }
5315 (define_insn ""
5316   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,f,f,m")
5317         (match_operand:DI 1 "input_operand" "r,m,r,f,m,f"))]
5318   "! TARGET_POWERPC64 && (gpc_reg_operand (operands[0], DImode)
5319    || gpc_reg_operand (operands[1], DImode))"
5320   "*
5322   switch (which_alternative)
5323     {
5324     case 0:
5325       /* We normally copy the low-numbered register first.  However, if
5326          the first register operand 0 is the same as the second register of
5327          operand 1, we must copy in the opposite order.  */
5328       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
5329         return \"mr %L0,%L1\;mr %0,%1\";
5330       else
5331         return \"mr %0,%1\;mr %L0,%L1\";
5332     case 1:
5333       /* If the low-address word is used in the address, we must load it
5334          last.  Otherwise, load it first.  Note that we cannot have
5335          auto-increment in that case since the address register is known to be
5336          dead.  */
5337       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5338                              operands [1], 0))
5339         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
5340       else
5341         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
5342     case 2:
5343       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
5344     case 3:
5345       return \"fmr %0,%1\";
5346     case 4:
5347       return \"lfd%U1%X1 %0,%1\";
5348     case 5:
5349       return \"stfd%U0%X0 %1,%0\";
5350     }
5352   [(set_attr "type" "*,load,*,fp,fpload,*")
5353    (set_attr "length" "8,8,8,*,*,*")])
5355 (define_insn ""
5356   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,f,f,m,r,*h")
5357         (match_operand:DI 1 "input_operand" "r,m,r,I,J,R,f,m,f,*h,r"))]
5358   "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], DImode)
5359    || gpc_reg_operand (operands[1], DImode))"
5360   "@
5361    mr %0,%1
5362    ld%U1%X1 %0,%1
5363    sd%U0%X0 %1,%0
5364    li %0,%1
5365    lis %0,%u1
5366    {cal|la} %0,%1(%*)
5367    fmr %0,%1
5368    lfd%U1%X1 %0,%1
5369    stfd%U0%X0 %1,%0
5370    mf%1 %0
5371    mt%0 %1"
5372   [(set_attr "type" "*,load,*,*,*,*,fp,fpload,*,*,mtjmpr")])
5374 ;; TImode is similar, except that we usually want to compute the address into
5375 ;; a register and use lsi/stsi (the exception is during reload).  MQ is also
5376 ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
5377 (define_expand "movti"
5378   [(parallel [(set (match_operand:TI 0 "general_operand" "")
5379                    (match_operand:TI 1 "general_operand" ""))
5380               (clobber (scratch:SI))])]
5381   "TARGET_STRING || TARGET_POWERPC64"
5382   "
5384   if (GET_CODE (operands[0]) == MEM)
5385     operands[1] = force_reg (TImode, operands[1]);
5387   if (GET_CODE (operands[0]) == MEM
5388       && GET_CODE (XEXP (operands[0], 0)) != REG
5389       && ! reload_in_progress)
5390     operands[0] = change_address (operands[0], TImode,
5391                                   copy_addr_to_reg (XEXP (operands[0], 0)));
5393   if (GET_CODE (operands[1]) == MEM
5394       && GET_CODE (XEXP (operands[1], 0)) != REG
5395       && ! reload_in_progress)
5396     operands[1] = change_address (operands[1], TImode,
5397                                   copy_addr_to_reg (XEXP (operands[1], 0)));
5400 ;; We say that MQ is clobbered in the last alternative because the first
5401 ;; alternative would never get used otherwise since it would need a reload
5402 ;; while the 2nd alternative would not.  We put memory cases first so they
5403 ;; are preferred.  Otherwise, we'd try to reload the output instead of
5404 ;; giving the SCRATCH mq.
5405 (define_insn ""
5406   [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
5407         (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))
5408    (clobber (match_scratch:SI 2 "=q,q#X,X,X,X"))]
5409   "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
5410    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
5411   "*
5413   switch (which_alternative)
5414     {
5415     default:
5416       abort ();
5418     case 0:
5419       return \"{stsi|stswi} %1,%P0,16\";
5421     case 1:
5422       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
5424     case 2:
5425       /* Normally copy registers with lowest numbered register copied first.
5426          But copy in the other order if the first register of the output
5427          is the second, third, or fourth register in the input.  */
5428       if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
5429           && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
5430         return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
5431       else
5432         return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
5433     case 3:
5434       /* If the address is not used in the output, we can use lsi.  Otherwise,
5435          fall through to generating four loads.  */
5436       if (! reg_overlap_mentioned_p (operands[0], operands[1]))
5437         return \"{lsi|lswi} %0,%P1,16\";
5438       /* ... fall through ... */
5439     case 4:
5440       /* If the address register is the same as the register for the lowest-
5441          addressed word, load it last.  Similarly for the next two words.
5442          Otherwise load lowest address to highest.  */
5443       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5444                              operands[1], 0))
5445         return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
5446       else if (refers_to_regno_p (REGNO (operands[0]) + 1,
5447                                   REGNO (operands[0]) + 2, operands[1], 0))
5448         return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
5449       else if (refers_to_regno_p (REGNO (operands[0]) + 2,
5450                                   REGNO (operands[0]) + 3, operands[1], 0))
5451         return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
5452       else
5453         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
5454     }
5456   [(set_attr "type" "*,load,load,*,*")
5457    (set_attr "length" "*,16,16,*,16")])
5459 (define_insn ""
5460   [(set (match_operand:TI 0 "reg_or_mem_operand" "=m,????r,????r")
5461         (match_operand:TI 1 "reg_or_mem_operand" "r,r,m"))
5462    (clobber (match_scratch:SI 2 "=X,X,X"))]
5463   "TARGET_STRING && !TARGET_POWER && ! TARGET_POWERPC64
5464    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
5465   "*
5467   switch (which_alternative)
5468     {
5469     default:
5470       abort ();
5472     case 0:
5473       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
5475     case 1:
5476       /* Normally copy registers with lowest numbered register copied first.
5477          But copy in the other order if the first register of the output
5478          is the second, third, or fourth register in the input.  */
5479       if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
5480           && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
5481         return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
5482       else
5483         return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
5484     case 2:
5485       /* If the address register is the same as the register for the lowest-
5486          addressed word, load it last.  Similarly for the next two words.
5487          Otherwise load lowest address to highest.  */
5488       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5489                              operands[1], 0))
5490         return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
5491       else if (refers_to_regno_p (REGNO (operands[0]) + 1,
5492                                   REGNO (operands[0]) + 2, operands[1], 0))
5493         return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
5494       else if (refers_to_regno_p (REGNO (operands[0]) + 2,
5495                                   REGNO (operands[0]) + 3, operands[1], 0))
5496         return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
5497       else
5498         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
5499     }
5501   [(set_attr "type" "load,*,*")
5502    (set_attr "length" "16,16,16")])
5504 (define_insn ""
5505   [(set (match_operand:TI 0 "nonimmediate_operand" "=r,r,m")
5506         (match_operand:TI 1 "input_operand" "r,m,r"))]
5507   "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
5508    || gpc_reg_operand (operands[1], TImode))"
5509   "*
5511   switch (which_alternative)
5512     {
5513     case 0:
5514       /* We normally copy the low-numbered register first.  However, if
5515          the first register operand 0 is the same as the second register of
5516          operand 1, we must copy in the opposite order.  */
5517       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
5518         return \"mr %L0,%L1\;mr %0,%1\";
5519       else
5520         return \"mr %0,%1\;mr %L0,%L1\";
5521     case 1:
5522       /* If the low-address word is used in the address, we must load it
5523          last.  Otherwise, load it first.  Note that we cannot have
5524          auto-increment in that case since the address register is known to be
5525          dead.  */
5526       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5527                              operands [1], 0))
5528         return \"ld %L0,%L1\;ld %0,%1\";
5529       else
5530         return \"ld%U1 %0,%1\;ld %L0,%L1\";
5531     case 2:
5532       return \"std%U0 %1,%0\;std %L1,%L0\";
5533     }
5535   [(set_attr "type" "*,load,*")
5536    (set_attr "length" "8,8,8")])
5538 (define_expand "load_multiple"
5539   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
5540                           (match_operand:SI 1 "" ""))
5541                      (use (match_operand:SI 2 "" ""))])]
5542   "TARGET_STRING"
5543   "
5545   int regno;
5546   int count;
5547   rtx from;
5548   int i;
5550   /* Support only loading a constant number of fixed-point registers from
5551      memory and only bother with this if more than two; the machine
5552      doesn't support more than eight.  */
5553   if (GET_CODE (operands[2]) != CONST_INT
5554       || INTVAL (operands[2]) <= 2
5555       || INTVAL (operands[2]) > 8
5556       || GET_CODE (operands[1]) != MEM
5557       || GET_CODE (operands[0]) != REG
5558       || REGNO (operands[0]) >= 32)
5559     FAIL;
5561   count = INTVAL (operands[2]);
5562   regno = REGNO (operands[0]);
5564   operands[3] = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (count));
5565   from = force_reg (SImode, XEXP (operands[1], 0));
5567   for (i = 0; i < count; i++)
5568     XVECEXP (operands[3], 0, i)
5569       = gen_rtx (SET, VOIDmode, gen_rtx (REG, SImode, regno + i),
5570                  gen_rtx (MEM, SImode, plus_constant (from, i * 4)));
5573 (define_insn ""
5574   [(match_parallel 0 "load_multiple_operation"
5575                    [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
5576                          (mem:SI (match_operand:SI 2 "register_operand" "b")))])]
5577   "TARGET_STRING"
5578   "*
5580   /* We have to handle the case where the pseudo used to contain the address
5581      is assigned to one of the output registers.  */
5582   int i, j;
5583   int words = XVECLEN (operands[0], 0);
5584   rtx xop[10];
5586   if (XVECLEN (operands[0], 0) == 1)
5587     return \"{l|lwz} %1,0(%2)\";
5589   for (i = 0; i < words; i++)
5590     if (refers_to_regno_p (REGNO (operands[1]) + i,
5591                            REGNO (operands[1]) + i + 1, operands[2], 0))
5592       {
5593         if (i == words-1)
5594           {
5595             xop[0] = operands[1];
5596             xop[1] = operands[2];
5597             xop[2] = GEN_INT (4 * (words-1));
5598             output_asm_insn (\"{lsi|lswi} %0,%1,%2\;{l|lwz} %1,%2(%1)\", xop);
5599             return \"\";
5600           }
5601         else if (i == 0)
5602           {
5603             xop[0] = operands[1];
5604             xop[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
5605             xop[2] = GEN_INT (4 * (words-1));
5606             output_asm_insn (\"{cal %0,4(%0)|addi %0,%0,4}\;{lsi|lswi} %1,%0,%2\;{l|lwz} %0,-4(%0)\", xop);
5607             return \"\";
5608           }
5609         else
5610           {
5611             for (j = 0; j < words; j++)
5612               if (j != i)
5613                 {
5614                   xop[0] = gen_rtx (REG, SImode, REGNO (operands[1]) + j);
5615                   xop[1] = operands[2];
5616                   xop[2] = GEN_INT (j * 4);
5617                   output_asm_insn (\"{l|lwz} %0,%2(%1)\", xop);
5618                 }
5619             xop[0] = operands[2];
5620             xop[1] = GEN_INT (i * 4);
5621             output_asm_insn (\"{l|lwz} %0,%1(%0)\", xop);
5622             return \"\";
5623           }
5624       }
5626   return \"{lsi|lswi} %1,%2,%N0\";
5628   [(set_attr "type" "load")
5629    (set_attr "length" "32")])
5632 (define_expand "store_multiple"
5633   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
5634                           (match_operand:SI 1 "" ""))
5635                      (clobber (scratch:SI))
5636                      (use (match_operand:SI 2 "" ""))])]
5637   "TARGET_STRING"
5638   "
5640   int regno;
5641   int count;
5642   rtx to;
5643   int i;
5645   /* Support only storing a constant number of fixed-point registers to
5646      memory and only bother with this if more than two; the machine
5647      doesn't support more than eight.  */
5648   if (GET_CODE (operands[2]) != CONST_INT
5649       || INTVAL (operands[2]) <= 2
5650       || INTVAL (operands[2]) > 8
5651       || GET_CODE (operands[0]) != MEM
5652       || GET_CODE (operands[1]) != REG
5653       || REGNO (operands[1]) >= 32)
5654     FAIL;
5656   count = INTVAL (operands[2]);
5657   regno = REGNO (operands[1]);
5659   operands[3] = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (count + 1));
5660   to = force_reg (SImode, XEXP (operands[0], 0));
5662   XVECEXP (operands[3], 0, 0)
5663     = gen_rtx (SET, VOIDmode, gen_rtx (MEM, SImode, to), operands[1]);
5664   XVECEXP (operands[3], 0, 1) = gen_rtx (CLOBBER, VOIDmode,
5665                                                   gen_rtx (SCRATCH, SImode));
5667   for (i = 1; i < count; i++)
5668     XVECEXP (operands[3], 0, i + 1)
5669       = gen_rtx (SET, VOIDmode,
5670                  gen_rtx (MEM, SImode, plus_constant (to, i * 4)),
5671                  gen_rtx (REG, SImode, regno + i));
5674 (define_insn ""
5675   [(match_parallel 0 "store_multiple_operation"
5676                    [(set (match_operand:SI 1 "indirect_operand" "=Q")
5677                          (match_operand:SI 2 "gpc_reg_operand" "r"))
5678                     (clobber (match_scratch:SI 3 "=q"))])]
5679   "TARGET_STRING && TARGET_POWER"
5680   "{stsi|stswi} %2,%P1,%O0")
5682 (define_insn ""
5683   [(match_parallel 0 "store_multiple_operation"
5684                    [(set (mem:SI (match_operand:SI 1 "register_operand" "b"))
5685                          (match_operand:SI 2 "gpc_reg_operand" "r"))
5686                     (clobber (match_scratch:SI 3 "X"))])]
5687   "TARGET_STRING && !TARGET_POWER"
5688   "{stsi|stswi} %2,%1,%O0")
5691 ;; String/block move insn.
5692 ;; Argument 0 is the destination
5693 ;; Argument 1 is the source
5694 ;; Argument 2 is the length
5695 ;; Argument 3 is the alignment
5697 (define_expand "movstrsi"
5698   [(parallel [(set (match_operand:BLK 0 "" "")
5699                    (match_operand:BLK 1 "" ""))
5700               (use (match_operand:SI 2 "" ""))
5701               (use (match_operand:SI 3 "" ""))])]
5702   ""
5703   "
5705   if (expand_block_move (operands))
5706     DONE;
5707   else
5708     FAIL;
5711 ;; Move up to 32 bytes at a time.  The fixed registers are needed because the
5712 ;; register allocator doesn't have a clue about allocating 8 word registers
5713 (define_expand "movstrsi_8reg"
5714   [(parallel [(set (match_operand 0 "" "")
5715                    (match_operand 1 "" ""))
5716               (use (match_operand 2 "" ""))
5717               (use (match_operand 3 "" ""))
5718               (clobber (reg:SI  5))
5719               (clobber (reg:SI  6))
5720               (clobber (reg:SI  7))
5721               (clobber (reg:SI  8))
5722               (clobber (reg:SI  9))
5723               (clobber (reg:SI 10))
5724               (clobber (reg:SI 11))
5725               (clobber (reg:SI 12))
5726               (clobber (match_scratch:SI 4 ""))])]
5727   "TARGET_STRING"
5728   "")
5730 (define_insn ""
5731   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
5732         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
5733    (use (match_operand:SI 2 "immediate_operand" "i"))
5734    (use (match_operand:SI 3 "immediate_operand" "i"))
5735    (clobber (match_operand:SI 4 "register_operand" "=r"))
5736    (clobber (reg:SI  6))
5737    (clobber (reg:SI  7))
5738    (clobber (reg:SI  8))
5739    (clobber (reg:SI  9))
5740    (clobber (reg:SI 10))
5741    (clobber (reg:SI 11))
5742    (clobber (reg:SI 12))
5743    (clobber (match_scratch:SI 5 "=q"))]
5744   "TARGET_STRING && TARGET_POWER
5745    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32) || INTVAL (operands[2]) == 0)
5746    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
5747    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
5748    && REGNO (operands[4]) == 5"
5749   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
5750   [(set_attr "length" "8")])
5752 (define_insn ""
5753   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
5754         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
5755    (use (match_operand:SI 2 "immediate_operand" "i"))
5756    (use (match_operand:SI 3 "immediate_operand" "i"))
5757    (clobber (match_operand:SI 4 "register_operand" "=r"))
5758    (clobber (reg:SI  6))
5759    (clobber (reg:SI  7))
5760    (clobber (reg:SI  8))
5761    (clobber (reg:SI  9))
5762    (clobber (reg:SI 10))
5763    (clobber (reg:SI 11))
5764    (clobber (reg:SI 12))
5765    (clobber (match_scratch:SI 5 "X"))]
5766   "TARGET_STRING && !TARGET_POWER
5767    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32) || INTVAL (operands[2]) == 0)
5768    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
5769    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
5770    && REGNO (operands[4]) == 5"
5771   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
5772   [(set_attr "length" "8")])
5774 ;; Move up to 24 bytes at a time.  The fixed registers are needed because the
5775 ;; register allocator doesn't have a clue about allocating 6 word registers
5776 (define_expand "movstrsi_6reg"
5777   [(parallel [(set (match_operand 0 "" "")
5778                    (match_operand 1 "" ""))
5779               (use (match_operand 2 "" ""))
5780               (use (match_operand 3 "" ""))
5781               (clobber (reg:SI  7))
5782               (clobber (reg:SI  8))
5783               (clobber (reg:SI  9))
5784               (clobber (reg:SI 10))
5785               (clobber (reg:SI 11))
5786               (clobber (reg:SI 12))
5787               (clobber (match_scratch:SI 4 ""))])]
5788   "TARGET_STRING"
5789   "")
5791 (define_insn ""
5792   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
5793         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
5794    (use (match_operand:SI 2 "immediate_operand" "i"))
5795    (use (match_operand:SI 3 "immediate_operand" "i"))
5796    (clobber (match_operand:SI 4 "register_operand" "=r"))
5797    (clobber (reg:SI  8))
5798    (clobber (reg:SI  9))
5799    (clobber (reg:SI 10))
5800    (clobber (reg:SI 11))
5801    (clobber (reg:SI 12))
5802    (clobber (match_scratch:SI 5 "=q"))]
5803   "TARGET_STRING && TARGET_POWER
5804    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
5805    && (REGNO (operands[0]) < 7 || REGNO (operands[0]) > 12)
5806    && (REGNO (operands[1]) < 7 || REGNO (operands[1]) > 12)
5807    && REGNO (operands[4]) == 7"
5808   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
5809   [(set_attr "length" "8")])
5811 (define_insn ""
5812   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
5813         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
5814    (use (match_operand:SI 2 "immediate_operand" "i"))
5815    (use (match_operand:SI 3 "immediate_operand" "i"))
5816    (clobber (match_operand:SI 4 "register_operand" "=r"))
5817    (clobber (reg:SI  8))
5818    (clobber (reg:SI  9))
5819    (clobber (reg:SI 10))
5820    (clobber (reg:SI 11))
5821    (clobber (reg:SI 12))
5822    (clobber (match_scratch:SI 5 "X"))]
5823   "TARGET_STRING && !TARGET_POWER
5824    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
5825    && (REGNO (operands[0]) < 7 || REGNO (operands[0]) > 12)
5826    && (REGNO (operands[1]) < 7 || REGNO (operands[1]) > 12)
5827    && REGNO (operands[4]) == 7"
5828   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
5829   [(set_attr "length" "8")])
5831 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill problems
5832 ;; with TImode
5833 (define_expand "movstrsi_4reg"
5834   [(parallel [(set (match_operand 0 "" "")
5835                    (match_operand 1 "" ""))
5836               (use (match_operand 2 "" ""))
5837               (use (match_operand 3 "" ""))
5838               (clobber (reg:SI  9))
5839               (clobber (reg:SI 10))
5840               (clobber (reg:SI 11))
5841               (clobber (reg:SI 12))
5842               (clobber (match_scratch:SI 4 ""))])]
5843   "TARGET_STRING"
5844   "")
5846 (define_insn ""
5847   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
5848         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
5849    (use (match_operand:SI 2 "immediate_operand" "i"))
5850    (use (match_operand:SI 3 "immediate_operand" "i"))
5851    (clobber (match_operand:SI 4 "register_operand" "=r"))
5852    (clobber (reg:SI 10))
5853    (clobber (reg:SI 11))
5854    (clobber (reg:SI 12))
5855    (clobber (match_scratch:SI 5 "=q"))]
5856   "TARGET_STRING && TARGET_POWER
5857    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
5858    && (REGNO (operands[0]) < 9 || REGNO (operands[0]) > 12)
5859    && (REGNO (operands[1]) < 9 || REGNO (operands[1]) > 12)
5860    && REGNO (operands[4]) == 9"
5861   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
5862   [(set_attr "length" "8")])
5864 (define_insn ""
5865   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
5866         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
5867    (use (match_operand:SI 2 "immediate_operand" "i"))
5868    (use (match_operand:SI 3 "immediate_operand" "i"))
5869    (clobber (match_operand:SI 4 "register_operand" "=r"))
5870    (clobber (reg:SI 10))
5871    (clobber (reg:SI 11))
5872    (clobber (reg:SI 12))
5873    (clobber (match_scratch:SI 5 "X"))]
5874   "TARGET_STRING && !TARGET_POWER
5875    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
5876    && (REGNO (operands[0]) < 9 || REGNO (operands[0]) > 12)
5877    && (REGNO (operands[1]) < 9 || REGNO (operands[1]) > 12)
5878    && REGNO (operands[4]) == 9"
5879   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
5880   [(set_attr "length" "8")])
5882 ;; Move up to 8 bytes at a time.
5883 (define_expand "movstrsi_2reg"
5884   [(parallel [(set (match_operand 0 "" "")
5885                    (match_operand 1 "" ""))
5886               (use (match_operand 2 "" ""))
5887               (use (match_operand 3 "" ""))
5888               (clobber (match_scratch:DI 4 ""))
5889               (clobber (match_scratch:SI 5 ""))])]
5890   "TARGET_STRING && !TARGET_64BIT"
5891   "")
5893 (define_insn ""
5894   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
5895         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
5896    (use (match_operand:SI 2 "immediate_operand" "i"))
5897    (use (match_operand:SI 3 "immediate_operand" "i"))
5898    (clobber (match_scratch:DI 4 "=&r"))
5899    (clobber (match_scratch:SI 5 "=q"))]
5900   "TARGET_STRING && TARGET_POWER && !TARGET_64BIT
5901    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
5902   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
5903   [(set_attr "length" "8")])
5905 (define_insn ""
5906   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
5907         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
5908    (use (match_operand:SI 2 "immediate_operand" "i"))
5909    (use (match_operand:SI 3 "immediate_operand" "i"))
5910    (clobber (match_scratch:DI 4 "=&r"))
5911    (clobber (match_scratch:SI 5 "X"))]
5912   "TARGET_STRING && !TARGET_POWER && !TARGET_64BIT
5913    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
5914   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
5915   [(set_attr "length" "8")])
5917 ;; Move up to 4 bytes at a time.
5918 (define_expand "movstrsi_1reg"
5919   [(parallel [(set (match_operand 0 "" "")
5920                    (match_operand 1 "" ""))
5921               (use (match_operand 2 "" ""))
5922               (use (match_operand 3 "" ""))
5923               (clobber (match_scratch:SI 4 ""))
5924               (clobber (match_scratch:SI 5 ""))])]
5925   "TARGET_STRING"
5926   "")
5928 (define_insn ""
5929   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
5930         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
5931    (use (match_operand:SI 2 "immediate_operand" "i"))
5932    (use (match_operand:SI 3 "immediate_operand" "i"))
5933    (clobber (match_scratch:SI 4 "=&r"))
5934    (clobber (match_scratch:SI 5 "=q"))]
5935   "TARGET_STRING && TARGET_POWER
5936    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
5937   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
5938   [(set_attr "length" "8")])
5940 (define_insn ""
5941   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
5942         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
5943    (use (match_operand:SI 2 "immediate_operand" "i"))
5944    (use (match_operand:SI 3 "immediate_operand" "i"))
5945    (clobber (match_scratch:SI 4 "=&r"))
5946    (clobber (match_scratch:SI 5 "X"))]
5947   "TARGET_STRING && !TARGET_POWER
5948    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
5949   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
5950   [(set_attr "length" "8")])
5953 ;; Define insns that do load or store with update.  Some of these we can
5954 ;; get by using pre-decrement or pre-increment, but the hardware can also
5955 ;; do cases where the increment is not the size of the object.
5957 ;; In all these cases, we use operands 0 and 1 for the register being
5958 ;; incremented because those are the operands that local-alloc will
5959 ;; tie and these are the pair most likely to be tieable (and the ones
5960 ;; that will benefit the most).
5962 (define_insn ""
5963   [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
5964         (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
5965                          (match_operand:DI 2 "reg_or_short_operand" "r,I"))))
5966    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
5967         (plus:DI (match_dup 1) (match_dup 2)))]
5968   "TARGET_POWERPC64"
5969   "@
5970    ldux %3,%0,%2
5971    ldu %3,%2(%0)"
5972   [(set_attr "type" "load")])
5974 (define_insn ""
5975   [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
5976         (sign_extend:DI
5977          (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
5978                           (match_operand:DI 2 "gpc_reg_operand" "r")))))
5979    (set (match_operand:DI 0 "gpc_reg_operand" "=b")
5980         (plus:DI (match_dup 1) (match_dup 2)))]
5981   "TARGET_POWERPC64"
5982   "lwaux %3,%0,%2"
5983   [(set_attr "type" "load")])
5985 (define_insn "movdi_update"
5986   [(set (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
5987                          (match_operand:DI 2 "reg_or_short_operand" "r,I")))
5988         (match_operand:DI 3 "gpc_reg_operand" "r,r"))
5989    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
5990         (plus:DI (match_dup 1) (match_dup 2)))]
5991   "TARGET_POWERPC64"
5992   "@
5993    stdux %3,%0,%2
5994    stdu %3,%2(%0)")
5996 (define_insn ""
5997   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
5998         (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
5999                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6000    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6001         (plus:SI (match_dup 1) (match_dup 2)))]
6002   ""
6003   "@
6004    {lux|lwzux} %3,%0,%2
6005    {lu|lwzu} %3,%2(%0)"
6006   [(set_attr "type" "load")])
6008 (define_insn "movsi_update"
6009   [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6010                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6011         (match_operand:SI 3 "gpc_reg_operand" "r,r"))
6012    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6013         (plus:SI (match_dup 1) (match_dup 2)))]
6014   ""
6015   "@
6016    {stux|stwux} %3,%0,%2
6017    {stu|stwu} %3,%2(%0)")
6019 (define_insn ""
6020   [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
6021         (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6022                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6023    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6024         (plus:SI (match_dup 1) (match_dup 2)))]
6025   ""
6026   "@
6027    lhzux %3,%0,%2
6028    lhzu %3,%2(%0)"
6029   [(set_attr "type" "load")])
6031 (define_insn ""
6032   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
6033         (zero_extend:SI
6034          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6035                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
6036    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6037         (plus:SI (match_dup 1) (match_dup 2)))]
6038   ""
6039   "@
6040    lhzux %3,%0,%2
6041    lhzu %3,%2(%0)"
6042   [(set_attr "type" "load")])
6044 (define_insn ""
6045   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
6046         (sign_extend:SI
6047          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6048                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
6049    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6050         (plus:SI (match_dup 1) (match_dup 2)))]
6051   ""
6052   "@
6053    lhaux %3,%0,%2
6054    lhau %3,%2(%0)"
6055   [(set_attr "type" "load")])
6057 (define_insn ""
6058   [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6059                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6060         (match_operand:HI 3 "gpc_reg_operand" "r,r"))
6061    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6062         (plus:SI (match_dup 1) (match_dup 2)))]
6063   ""
6064   "@
6065    sthux %3,%0,%2
6066    sthu %3,%2(%0)")
6068 (define_insn ""
6069   [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
6070         (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6071                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6072    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6073         (plus:SI (match_dup 1) (match_dup 2)))]
6074   ""
6075   "@
6076    lbzux %3,%0,%2
6077    lbzu %3,%2(%0)"
6078   [(set_attr "type" "load")])
6080 (define_insn ""
6081   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
6082         (zero_extend:SI
6083          (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6084                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
6085    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6086         (plus:SI (match_dup 1) (match_dup 2)))]
6087   ""
6088   "@
6089    lbzux %3,%0,%2
6090    lbzu %3,%2(%0)"
6091   [(set_attr "type" "load")])
6093 (define_insn ""
6094   [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6095                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6096         (match_operand:QI 3 "gpc_reg_operand" "r,r"))
6097    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6098         (plus:SI (match_dup 1) (match_dup 2)))]
6099   ""
6100   "@
6101    stbux %3,%0,%2
6102    stbu %3,%2(%0)")
6104 (define_insn ""
6105   [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
6106         (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6107                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6108    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6109         (plus:SI (match_dup 1) (match_dup 2)))]
6110   "TARGET_HARD_FLOAT"
6111   "@
6112    lfsux %3,%0,%2
6113    lfsu %3,%2(%0)"
6114   [(set_attr "type" "fpload")])
6116 (define_insn ""
6117   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6118                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6119         (match_operand:SF 3 "gpc_reg_operand" "f,f"))
6120    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6121         (plus:SI (match_dup 1) (match_dup 2)))]
6122   "TARGET_HARD_FLOAT"
6123   "@
6124    stfsux %3,%0,%2
6125    stfsu %3,%2(%0)")
6127 (define_insn ""
6128   [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
6129         (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6130                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6131    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6132         (plus:SI (match_dup 1) (match_dup 2)))]
6133   "TARGET_HARD_FLOAT"
6134   "@
6135    lfdux %3,%0,%2
6136    lfdu %3,%2(%0)"
6137   [(set_attr "type" "fpload")])
6139 (define_insn ""
6140   [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6141                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6142         (match_operand:DF 3 "gpc_reg_operand" "f,f"))
6143    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6144         (plus:SI (match_dup 1) (match_dup 2)))]
6145   "TARGET_HARD_FLOAT"
6146   "@
6147    stfdux %3,%0,%2
6148    stfdu %3,%2(%0)")
6150 ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
6152 (define_peephole
6153   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6154         (match_operand:DF 1 "memory_operand" ""))
6155    (set (match_operand:DF 2 "gpc_reg_operand" "=f")
6156         (match_operand:DF 3 "memory_operand" ""))]
6157   "TARGET_POWER2
6158    && TARGET_HARD_FLOAT
6159    && registers_ok_for_quad_peep (operands[0], operands[2])
6160    && ! MEM_VOLATILE_P (operands[1]) && ! MEM_VOLATILE_P (operands[3])
6161    && addrs_ok_for_quad_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
6162   "lfq%U1%X1 %0,%1")
6164 (define_peephole
6165   [(set (match_operand:DF 0 "memory_operand" "")
6166         (match_operand:DF 1 "gpc_reg_operand" "f"))
6167    (set (match_operand:DF 2 "memory_operand" "")
6168         (match_operand:DF 3 "gpc_reg_operand" "f"))]
6169   "TARGET_POWER2
6170    && TARGET_HARD_FLOAT
6171    && registers_ok_for_quad_peep (operands[1], operands[3])
6172    && ! MEM_VOLATILE_P (operands[0]) && ! MEM_VOLATILE_P (operands[2])
6173    && addrs_ok_for_quad_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
6174   "stfq%U0%X0 %1,%0")
6176 ;; Next come insns related to the calling sequence.
6178 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
6179 ;; We move the back-chain and decrement the stack pointer.
6181 (define_expand "allocate_stack"
6182   [(set (reg:SI 1)
6183         (minus:SI (reg:SI 1) (match_operand:SI 0 "reg_or_short_operand" "")))]
6184   ""
6185   "
6186 { rtx chain = gen_reg_rtx (Pmode);
6187   rtx stack_bot = gen_rtx (MEM, Pmode, stack_pointer_rtx);
6188   rtx neg_op0;
6190   emit_move_insn (chain, stack_bot);
6192   if (GET_CODE (operands[0]) != CONST_INT
6193       || INTVAL (operands[0]) < -32767
6194       || INTVAL (operands[0]) > 32768)
6195     {
6196       neg_op0 = gen_reg_rtx (Pmode);
6197       if (TARGET_POWERPC64)
6198         emit_insn (gen_negdi2 (neg_op0, operands[0]));
6199       else
6200         emit_insn (gen_negsi2 (neg_op0, operands[0]));
6201     }
6202   else
6203     neg_op0 = GEN_INT (- INTVAL (operands[0]));
6205   if (TARGET_POWERPC64)
6206     emit_insn (gen_movdi_update (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
6207   else
6208     emit_insn (gen_movsi_update (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
6210   DONE;
6213 ;; These patterns say how to save and restore the stack pointer.  We need not
6214 ;; save the stack pointer at function level since we are careful to
6215 ;; preserve the backchain.  At block level, we have to restore the backchain
6216 ;; when we restore the stack pointer.
6218 ;; For nonlocal gotos, we must save both the stack pointer and its
6219 ;; backchain and restore both.  Note that in the nonlocal case, the
6220 ;; save area is a memory location.
6222 (define_expand "save_stack_function"
6223   [(use (const_int 0))]
6224   ""
6225   "")
6227 (define_expand "restore_stack_function"
6228   [(use (const_int 0))]
6229   ""
6230   "")
6232 (define_expand "restore_stack_block"
6233   [(set (match_dup 2) (mem:SI (match_operand:SI 0 "register_operand" "")))
6234    (set (match_dup 0) (match_operand:SI 1 "register_operand" ""))
6235    (set (mem:SI (match_dup 0)) (match_dup 2))]
6236   ""
6237   "
6238 { operands[2] = gen_reg_rtx (SImode); }")
6240 (define_expand "save_stack_nonlocal"
6241   [(match_operand:DI 0 "memory_operand" "")
6242    (match_operand:SI 1 "register_operand" "")]
6243   ""
6244   "
6246   rtx temp = gen_reg_rtx (SImode);
6248   /* Copy the backchain to the first word, sp to the second.  */
6249   emit_move_insn (temp, gen_rtx (MEM, SImode, operands[1]));
6250   emit_move_insn (operand_subword (operands[0], 0, 0, DImode), temp);
6251   emit_move_insn (operand_subword (operands[0], 1, 0, DImode), operands[1]);
6252   DONE;
6255 (define_expand "restore_stack_nonlocal"
6256   [(match_operand:SI 0 "register_operand" "")
6257    (match_operand:DI 1 "memory_operand" "")]
6258   ""
6259   "
6261   rtx temp = gen_reg_rtx (SImode);
6263   /* Restore the backchain from the first word, sp from the second.  */
6264   emit_move_insn (temp, operand_subword (operands[1], 0, 0, DImode));
6265   emit_move_insn (operands[0], operand_subword (operands[1], 1, 0, DImode));
6266   emit_move_insn (gen_rtx (MEM, SImode, operands[0]), temp);
6267   DONE;
6271 ;; A function pointer under AIX is a pointer to a data area whose first word
6272 ;; contains the actual address of the function, whose second word contains a
6273 ;; pointer to its TOC, and whose third word contains a value to place in the
6274 ;; static chain register (r11).  Note that if we load the static chain, our
6275 ;; "trampoline" need not have any executable code.
6277 ;; operands[0] is a register pointing to the 3 word descriptor (aka, the function address)
6278 ;; operands[1] is the stack size to clean up
6279 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument (must be 0 for AIX)
6280 ;; operands[3] is location to store the TOC
6281 ;; operands[4] is the TOC register
6282 ;; operands[5] is the static chain register
6284 ;; We do not break this into separate insns, so that the scheduler will not try
6285 ;; to move the load of the new TOC before any loads from the TOC.
6287 (define_insn "call_indirect_aix"
6288   [(call (mem:SI (match_operand:SI 0 "register_operand" "b"))
6289          (match_operand 1 "const_int_operand" "n"))
6290    (use (match_operand 2 "const_int_operand" "O"))
6291    (use (match_operand 3 "offsettable_addr_operand" "p"))
6292    (use (match_operand 4 "register_operand" "r"))
6293    (clobber (match_operand 5 "register_operand" "=r"))
6294    (clobber (match_scratch:SI 6 "=&r"))
6295    (clobber (match_scratch:SI 7 "=l"))]
6296   "DEFAULT_ABI == ABI_AIX"
6297   "{st|stw} %4,%a3\;{l|lwz} %6,0(%0)\;{l|lwz} %4,4(%0);\;mt%7 %6\;{l|lwz} %5,8(%0)\;{brl|blrl}\;{l|lwz} %4,%a3"
6298   [(set_attr "length" "28")])
6300 (define_insn "call_value_indirect_aix"
6301   [(set (match_operand 0 "register_operand" "fg")
6302         (call (mem:SI (match_operand:SI 1 "register_operand" "b"))
6303               (match_operand 2 "const_int_operand" "n")))
6304    (use (match_operand 3 "const_int_operand" "O"))
6305    (use (match_operand 4 "offsettable_addr_operand" "p"))
6306    (use (match_operand 5 "register_operand" "r"))
6307    (clobber (match_operand 6 "register_operand" "=r"))
6308    (clobber (match_scratch:SI 7 "=&r"))
6309    (clobber (match_scratch:SI 8 "=l"))]
6310   "DEFAULT_ABI == ABI_AIX"
6311   "{st|stw} %5,%a4\;{l|lwz} %7,0(%1)\;{l|lwz} %5,4(%1);\;mt%8 %7\;{l|lwz} %6,8(%1)\;{brl|blrl}\;{l|lwz} %5,%a4"
6312   [(set_attr "length" "28")])
6314 ;; A function pointer undef NT is a pointer to a data area whose first word
6315 ;; contains the actual address of the function, whose second word contains a
6316 ;; pointer to its TOC.  The static chain is not stored under NT, which means
6317 ;; that we need a trampoline.
6319 ;; operands[0] is an SImode pseudo in which we place the address of the function.
6320 ;; operands[1] is the stack size to clean up
6321 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument (must be 0 for NT)
6322 ;; operands[3] is location to store the TOC
6323 ;; operands[4] is the TOC register
6325 ;; We do not break this into separate insns, so that the scheduler will not try
6326 ;; to move the load of the new TOC before any loads from the TOC.
6328 (define_insn "call_indirect_nt"
6329   [(call (mem:SI (match_operand:SI 0 "register_operand" "b"))
6330          (match_operand 1 "const_int_operand" "n"))
6331    (use (match_operand 2 "const_int_operand" "O"))
6332    (use (match_operand 3 "offsettable_addr_operand" "p"))
6333    (use (match_operand 4 "register_operand" "r"))
6334    (clobber (match_scratch:SI 5 "=&r"))
6335    (clobber (match_scratch:SI 6 "=l"))]
6336   "DEFAULT_ABI == ABI_NT"
6337   "{st|stw} %4,%a3\;{l|lwz} %5,0(%0)\;{l|lwz} %4,4(%0)\;mt%6 %5\;{brl|blrl}\;{l|lwz} %4,%a3"
6338   [(set_attr "length" "24")])
6340 (define_insn "call_value_indirect_nt"
6341   [(set (match_operand 0 "register_operand" "fg")
6342         (call (mem:SI (match_operand:SI 1 "register_operand" "b"))
6343               (match_operand 2 "const_int_operand" "n")))
6344    (use (match_operand 3 "const_int_operand" "O"))
6345    (use (match_operand 4 "offsettable_addr_operand" "p"))
6346    (use (match_operand 5 "register_operand" "r"))
6347    (clobber (match_scratch:SI 6 "=&r"))
6348    (clobber (match_scratch:SI 7 "=l"))]
6349   "DEFAULT_ABI == ABI_NT"
6350   "{st|stw} %5,%a4\;{l|lwz} %6,0(%1)\;{l|lwz} %5,4(%1)\;mt%7 %6\;{brl|blrl}\;{l|lwz} %5,%a4"
6351   [(set_attr "length" "24")])
6353 ;; A function pointer under System V is just a normal pointer
6354 ;; operands[0] is the function pointer
6355 ;; operands[1] is the stack size to clean up
6356 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument which indicates how to set cr1
6358 (define_insn "call_indirect_sysv"
6359   [(call (mem:SI (match_operand:SI 0 "register_operand" "l,l"))
6360          (match_operand 1 "const_int_operand" "n,n"))
6361    (use (match_operand 2 "const_int_operand" "O,n"))
6362    (clobber (match_scratch:SI 3 "=l,l"))]
6363   "DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_AIX_NODESC"
6364   "*
6366   if (INTVAL (operands[2]) > 0)
6367     return \"creqv 6,6,6\;{brl|blrl}\";
6369   else if (INTVAL (operands[2]) < 0)
6370     return \"crxor 6,6,6\;{brl|blrl}\";
6372   return \"{brl|blrl}\";
6374   [(set_attr "length" "4,8")])
6376 (define_insn "call_value_indirect_sysv"
6377   [(set (match_operand 0 "register_operand" "=fg,fg")
6378         (call (mem:SI (match_operand:SI 1 "register_operand" "l,l"))
6379               (match_operand 2 "const_int_operand" "n,n")))
6380    (use (match_operand 3 "const_int_operand" "O,n"))
6381    (clobber (match_scratch:SI 4 "=l,l"))]
6382   "DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_AIX_NODESC"
6383   "*
6385   if (INTVAL (operands[3]) > 0)
6386     return \"creqv 6,6,6\;{brl|blrl}\";
6388   else if (INTVAL (operands[3]) < 0)
6389     return \"crxor 6,6,6\;{brl|blrl}\";
6391   return \"{brl|blrl}\";
6393   [(set_attr "length" "4,8")])
6395 ;; Now the definitions for the call and call_value insns
6396 (define_expand "call"
6397   [(parallel [(call (mem:SI (match_operand:SI 0 "address_operand" ""))
6398                     (match_operand 1 "" ""))
6399               (use (match_operand 2 "" ""))
6400               (clobber (scratch:SI))])]
6401   ""
6402   "
6404   if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
6405     abort ();
6407   operands[0] = XEXP (operands[0], 0);
6409   /* Convert NT DLL imports into an indirect call.  */
6410   if (GET_CODE (operands[0]) == SYMBOL_REF
6411       && INTVAL (operands[2]) == (int)CALL_NT_DLLIMPORT)
6412     {
6413       operands[0] = rs6000_dll_import_ref (operands[0]);
6414       operands[2] = GEN_INT ((int)CALL_NORMAL);
6415     }
6417   if (GET_CODE (operands[0]) != SYMBOL_REF)
6418     {
6419       if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_AIX_NODESC)
6420         emit_call_insn (gen_call_indirect_sysv (force_reg (Pmode, operands[0]),
6421                                                 operands[1], operands[2]));
6422       else
6423         {
6424           rtx toc_reg = gen_rtx (REG, Pmode, 2);
6425           rtx toc_addr = RS6000_SAVE_TOC;
6427           if (DEFAULT_ABI == ABI_AIX)
6428             {
6429               /* AIX function pointers are really pointers to a three word area */
6430               rtx static_chain = gen_rtx (REG, Pmode, STATIC_CHAIN_REGNUM);
6431               emit_call_insn (gen_call_indirect_aix (force_reg (Pmode, operands[0]),
6432                                                      operands[1], operands[2],
6433                                                      toc_addr, toc_reg, static_chain));
6434             }
6435           else if (DEFAULT_ABI == ABI_NT)
6436             {
6437               /* NT function pointers are really pointers to a two word area */
6438               rs6000_save_toc_p = 1;
6439               emit_call_insn (gen_call_indirect_nt (force_reg (Pmode, operands[0]),
6440                                                     operands[1], operands[2],
6441                                                     toc_addr, toc_reg));
6442             }
6443           else
6444             abort ();
6445         }
6446       DONE;
6447     }
6450 (define_expand "call_value"
6451   [(parallel [(set (match_operand 0 "" "")
6452                    (call (mem:SI (match_operand:SI 1 "address_operand" ""))
6453                          (match_operand 2 "" "")))
6454               (use (match_operand 3 "" ""))
6455               (clobber (scratch:SI))])]
6456   ""
6457   "
6459   if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
6460     abort ();
6462   operands[1] = XEXP (operands[1], 0);
6464   /* Convert NT DLL imports into an indirect call.  */
6465   if (GET_CODE (operands[1]) == SYMBOL_REF
6466       && INTVAL (operands[3]) == (int)CALL_NT_DLLIMPORT)
6467     {
6468       operands[1] = rs6000_dll_import_ref (operands[1]);
6469       operands[3] = GEN_INT ((int)CALL_NORMAL);
6470     }
6472   if (GET_CODE (operands[1]) != SYMBOL_REF)
6473     {
6474       if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_AIX_NODESC)
6475         emit_call_insn (gen_call_value_indirect_sysv (operands[0], operands[1],
6476                                                       operands[2], operands[3]));
6477       else
6478         {
6479           rtx toc_reg = gen_rtx (REG, Pmode, 2);
6480           rtx toc_addr = RS6000_SAVE_TOC;
6482           if (DEFAULT_ABI == ABI_AIX)
6483             {
6484               /* AIX function pointers are really pointers to a three word area */
6485               rtx static_chain = gen_rtx (REG, Pmode, STATIC_CHAIN_REGNUM);
6486               emit_call_insn (gen_call_value_indirect_aix (operands[0],
6487                                                            force_reg (Pmode, operands[1]),
6488                                                            operands[2], operands[3],
6489                                                            toc_addr, toc_reg, static_chain));
6490             }
6491           else if (DEFAULT_ABI == ABI_NT)
6492             {
6493               /* NT function pointers are really pointers to a two word area */
6494               rs6000_save_toc_p = 1;
6495               emit_call_insn (gen_call_value_indirect_nt (operands[0],
6496                                                           force_reg (Pmode, operands[1]),
6497                                                           operands[2], operands[3],
6498                                                           toc_addr, toc_reg));
6499             }
6500           else
6501             abort ();
6502         }
6503       DONE;
6504     }
6507 ;; Call to function in current module.  No TOC pointer reload needed.
6508 ;; Operand2 is non-zero if we are using the V.4 calling sequence and
6509 ;; either the function was not prototyped, or it was prototyped as a
6510 ;; variable argument function.  It is > 0 if FP registers were passed
6511 ;; and < 0 if they were not.
6513 (define_insn ""
6514   [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
6515          (match_operand 1 "" "g,g"))
6516    (use (match_operand:SI 2 "immediate_operand" "O,n"))
6517    (clobber (match_scratch:SI 3 "=l,l"))]
6518   ""
6519   "*
6521   switch ((enum rs6000_call_cookie)INTVAL (operands[2]))
6522     {
6523     case CALL_V4_SET_FP_ARGS:   output_asm_insn (\"crxor 6,6,6\", operands); break;
6524     case CALL_V4_CLEAR_FP_ARGS: output_asm_insn (\"creqv 6,6,6\", operands); break;
6525     }
6527   return \"bl %z0\";
6529   [(set_attr "length" "4,8")])
6531 ;; Call to function which may be in another module.  Restore the TOC
6532 ;; pointer (r2) after the call unless this is System V.
6533 ;; Operand2 is non-zero if we are using the V.4 calling sequence and
6534 ;; either the function was not prototyped, or it was prototyped as a
6535 ;; variable argument function.  It is > 0 if FP registers were passed
6536 ;; and < 0 if they were not.
6538 (define_insn ""
6539   [(call (mem:SI (match_operand:SI 0 "call_operand" "s,s"))
6540          (match_operand 1 "" "fg,fg"))
6541    (use (match_operand:SI 2 "immediate_operand" "O,n"))
6542    (clobber (match_scratch:SI 3 "=l,l"))]
6543   "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT"
6544   "*
6546   /* Indirect calls should go through call_indirect */
6547   if (GET_CODE (operands[0]) == REG)
6548     abort ();
6550   switch ((enum rs6000_call_cookie)INTVAL (operands[2]))
6551     {
6552     case CALL_V4_SET_FP_ARGS:   output_asm_insn (\"crxor 6,6,6\", operands); break;
6553     case CALL_V4_CLEAR_FP_ARGS: output_asm_insn (\"creqv 6,6,6\", operands); break;
6554     }
6556   return (TARGET_WINDOWS_NT) ? \"bl %z0\;.znop %z0\" : \"bl %z0\;%.\";
6558   [(set_attr "length" "8,12")])
6560 (define_insn ""
6561   [(call (mem:SI (match_operand:SI 0 "call_operand" "s,s"))
6562          (match_operand 1 "" "fg,fg"))
6563    (use (match_operand:SI 2 "immediate_operand" "O,n"))
6564    (clobber (match_scratch:SI 3 "=l,l"))]
6565   "DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_V4"
6566   "*
6568   /* Indirect calls should go through call_indirect */
6569   if (GET_CODE (operands[0]) == REG)
6570     abort ();
6572   switch ((enum rs6000_call_cookie)INTVAL (operands[2]))
6573     {
6574     case CALL_V4_SET_FP_ARGS:   output_asm_insn (\"crxor 6,6,6\", operands); break;
6575     case CALL_V4_CLEAR_FP_ARGS: output_asm_insn (\"creqv 6,6,6\", operands); break;
6576     }
6578   return \"bl %z0\";
6580   [(set_attr "length" "4,8")])
6582 (define_insn ""
6583   [(set (match_operand 0 "" "=fg,fg")
6584         (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
6585               (match_operand 2 "" "g,g")))
6586    (use (match_operand:SI 3 "immediate_operand" "O,n"))
6587    (clobber (match_scratch:SI 4 "=l,l"))]
6588   ""
6589   "*
6591   switch ((enum rs6000_call_cookie)INTVAL (operands[3]))
6592     {
6593     case CALL_V4_SET_FP_ARGS:   output_asm_insn (\"crxor 6,6,6\", operands); break;
6594     case CALL_V4_CLEAR_FP_ARGS: output_asm_insn (\"creqv 6,6,6\", operands); break;
6595     }
6597   return \"bl %z1\";
6599   [(set_attr "length" "4,8")])
6601 (define_insn ""
6602   [(set (match_operand 0 "" "=fg,fg")
6603         (call (mem:SI (match_operand:SI 1 "call_operand" "s,s"))
6604               (match_operand 2 "" "fg,fg")))
6605    (use (match_operand:SI 3 "immediate_operand" "O,n"))
6606    (clobber (match_scratch:SI 4 "=l,l"))]
6607   "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT"
6608   "*
6610   /* This should be handled by call_value_indirect */
6611   if (GET_CODE (operands[1]) == REG)
6612     abort ();
6614   switch ((enum rs6000_call_cookie)INTVAL (operands[3]))
6615     {
6616     case CALL_V4_SET_FP_ARGS:   output_asm_insn (\"crxor 6,6,6\", operands); break;
6617     case CALL_V4_CLEAR_FP_ARGS: output_asm_insn (\"creqv 6,6,6\", operands); break;
6618     }
6620   return (TARGET_WINDOWS_NT) ? \"bl %z1\;.znop %z1\" : \"bl %z1\;%.\";
6622   [(set_attr "length" "8,12")])
6624 (define_insn ""
6625   [(set (match_operand 0 "" "=fg,fg")
6626         (call (mem:SI (match_operand:SI 1 "call_operand" "s,s"))
6627               (match_operand 2 "" "fg,fg")))
6628    (use (match_operand:SI 3 "immediate_operand" "O,n"))
6629    (clobber (match_scratch:SI 4 "=l,l"))]
6630   "DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_V4"
6631   "*
6633   /* This should be handled by call_value_indirect */
6634   if (GET_CODE (operands[1]) == REG)
6635     abort ();
6637   switch ((enum rs6000_call_cookie)INTVAL (operands[3]))
6638     {
6639     case CALL_V4_SET_FP_ARGS:   output_asm_insn (\"crxor 6,6,6\", operands); break;
6640     case CALL_V4_CLEAR_FP_ARGS: output_asm_insn (\"creqv 6,6,6\", operands); break;
6641     }
6643   return \"bl %z1\";
6645   [(set_attr "length" "4,8")])
6648 ;; Call subroutine returning any type.
6650 (define_expand "untyped_call"
6651   [(parallel [(call (match_operand 0 "" "")
6652                     (const_int 0))
6653               (match_operand 1 "" "")
6654               (match_operand 2 "" "")])]
6655   ""
6656   "
6658   int i;
6660   emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx, const0_rtx));
6662   for (i = 0; i < XVECLEN (operands[2], 0); i++)
6663     {
6664       rtx set = XVECEXP (operands[2], 0, i);
6665       emit_move_insn (SET_DEST (set), SET_SRC (set));
6666     }
6668   /* The optimizer does not know that the call sets the function value
6669      registers we stored in the result block.  We avoid problems by
6670      claiming that all hard registers are used and clobbered at this
6671      point.  */
6672   emit_insn (gen_blockage ());
6674   DONE;
6677 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6678 ;; all of memory.  This blocks insns from being moved across this point.
6680 (define_insn "blockage"
6681   [(unspec_volatile [(const_int 0)] 0)]
6682   ""
6683   "")
6685 ;; Synchronize instructions/data caches for V.4 trampolines
6686 ;; The extra memory_operand is to prevent the optimizer from
6687 ;; deleting insns with "no" effect.
6688 (define_insn "icbi"
6689   [(unspec [(match_operand 0 "memory_operand" "=m")
6690             (match_operand 1 "register_operand" "b")
6691             (match_operand 2 "register_operand" "r")] 3)]
6692   "TARGET_POWERPC"
6693   "icbi %1,%2")
6695 (define_insn "dcbst"
6696   [(unspec [(match_operand 0 "memory_operand" "=m")
6697             (match_operand 1 "register_operand" "b")
6698             (match_operand 2 "register_operand" "r")] 4)]
6699   "TARGET_POWERPC"
6700   "dcbst %1,%2")
6702 (define_insn "sync"
6703   [(unspec [(match_operand 0 "memory_operand" "=m")] 5)]
6704   ""
6705   "{dcs|sync}")
6707 (define_insn "isync"
6708   [(unspec [(match_operand 0 "memory_operand" "=m")] 6)]
6709   ""
6710   "{ics|isync}")
6713 ;; Compare insns are next.  Note that the RS/6000 has two types of compares,
6714 ;; signed & unsigned, and one type of branch.
6716 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
6717 ;; insns, and branches.  We store the operands of compares until we see
6718 ;; how it is used.
6719 (define_expand "cmpsi"
6720   [(set (cc0)
6721         (compare (match_operand:SI 0 "gpc_reg_operand" "")
6722                  (match_operand:SI 1 "reg_or_short_operand" "")))]
6723   ""
6724   "
6726   /* Take care of the possibility that operands[1] might be negative but
6727      this might be a logical operation.  That insn doesn't exist.  */
6728   if (GET_CODE (operands[1]) == CONST_INT
6729       && INTVAL (operands[1]) < 0)
6730     operands[1] = force_reg (SImode, operands[1]);
6732   rs6000_compare_op0 = operands[0];
6733   rs6000_compare_op1 = operands[1];
6734   rs6000_compare_fp_p = 0;
6735   DONE;
6738 (define_expand "cmpdi"
6739   [(set (cc0)
6740         (compare (match_operand:DI 0 "gpc_reg_operand" "")
6741                  (match_operand:DI 1 "reg_or_short_operand" "")))]
6742   "TARGET_POWERPC64"
6743   "
6745   /* Take care of the possibility that operands[1] might be negative but
6746      this might be a logical operation.  That insn doesn't exist.  */
6747   if (GET_CODE (operands[1]) == CONST_INT
6748       && INTVAL (operands[1]) < 0)
6749     operands[1] = force_reg (DImode, operands[1]);
6751   rs6000_compare_op0 = operands[0];
6752   rs6000_compare_op1 = operands[1];
6753   rs6000_compare_fp_p = 0;
6754   DONE;
6757 (define_expand "cmpsf"
6758   [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
6759                        (match_operand:SF 1 "gpc_reg_operand" "")))]
6760   "TARGET_HARD_FLOAT"
6761   "
6763   rs6000_compare_op0 = operands[0];
6764   rs6000_compare_op1 = operands[1];
6765   rs6000_compare_fp_p = 1;
6766   DONE;
6769 (define_expand "cmpdf"
6770   [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
6771                        (match_operand:DF 1 "gpc_reg_operand" "")))]
6772   "TARGET_HARD_FLOAT"
6773   "
6775   rs6000_compare_op0 = operands[0];
6776   rs6000_compare_op1 = operands[1];
6777   rs6000_compare_fp_p = 1;
6778   DONE;
6781 (define_expand "beq"
6782   [(set (match_dup 2) (match_dup 1))
6783    (set (pc)
6784         (if_then_else (eq (match_dup 2)
6785                           (const_int 0))
6786                       (label_ref (match_operand 0 "" ""))
6787                       (pc)))]
6788   ""
6789   "
6790 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
6791   operands[1] = gen_rtx (COMPARE, mode,
6792                          rs6000_compare_op0, rs6000_compare_op1);
6793   operands[2] = gen_reg_rtx (mode);
6796 (define_expand "bne"
6797   [(set (match_dup 2) (match_dup 1))
6798    (set (pc)
6799         (if_then_else (ne (match_dup 2)
6800                           (const_int 0))
6801                       (label_ref (match_operand 0 "" ""))
6802                       (pc)))]
6803   ""
6804   "
6805 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
6806   operands[1] = gen_rtx (COMPARE, mode,
6807                          rs6000_compare_op0, rs6000_compare_op1);
6808   operands[2] = gen_reg_rtx (mode);
6811 (define_expand "blt"
6812   [(set (match_dup 2) (match_dup 1))
6813    (set (pc)
6814         (if_then_else (lt (match_dup 2)
6815                           (const_int 0))
6816                       (label_ref (match_operand 0 "" ""))
6817                       (pc)))]
6818   ""
6819   "
6820 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
6821   operands[1] = gen_rtx (COMPARE, mode,
6822                          rs6000_compare_op0, rs6000_compare_op1);
6823   operands[2] = gen_reg_rtx (mode);
6826 (define_expand "bgt"
6827   [(set (match_dup 2) (match_dup 1))
6828    (set (pc)
6829         (if_then_else (gt (match_dup 2)
6830                           (const_int 0))
6831                       (label_ref (match_operand 0 "" ""))
6832                       (pc)))]
6833   ""
6834   "
6835 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
6836   operands[1] = gen_rtx (COMPARE, mode,
6837                          rs6000_compare_op0, rs6000_compare_op1);
6838   operands[2] = gen_reg_rtx (mode);
6841 (define_expand "ble"
6842   [(set (match_dup 2) (match_dup 1))
6843    (set (pc)
6844         (if_then_else (le (match_dup 2)
6845                           (const_int 0))
6846                       (label_ref (match_operand 0 "" ""))
6847                       (pc)))]
6848   ""
6849   "
6850 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
6851   operands[1] = gen_rtx (COMPARE, mode,
6852                          rs6000_compare_op0, rs6000_compare_op1);
6853   operands[2] = gen_reg_rtx (mode);
6856 (define_expand "bge"
6857   [(set (match_dup 2) (match_dup 1))
6858    (set (pc)
6859         (if_then_else (ge (match_dup 2)
6860                           (const_int 0))
6861                       (label_ref (match_operand 0 "" ""))
6862                       (pc)))]
6863   ""
6864   "
6865 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
6866   operands[1] = gen_rtx (COMPARE, mode,
6867                          rs6000_compare_op0, rs6000_compare_op1);
6868   operands[2] = gen_reg_rtx (mode);
6871 (define_expand "bgtu"
6872   [(set (match_dup 2) (match_dup 1))
6873    (set (pc)
6874         (if_then_else (gtu (match_dup 2)
6875                            (const_int 0))
6876                       (label_ref (match_operand 0 "" ""))
6877                       (pc)))]
6878   ""
6879   "
6880 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
6881                          rs6000_compare_op0, rs6000_compare_op1);
6882   operands[2] = gen_reg_rtx (CCUNSmode);
6885 (define_expand "bltu"
6886   [(set (match_dup 2) (match_dup 1))
6887    (set (pc)
6888         (if_then_else (ltu (match_dup 2)
6889                            (const_int 0))
6890                       (label_ref (match_operand 0 "" ""))
6891                       (pc)))]
6892   ""
6893   "
6894 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
6895                          rs6000_compare_op0, rs6000_compare_op1);
6896   operands[2] = gen_reg_rtx (CCUNSmode);
6899 (define_expand "bgeu"
6900   [(set (match_dup 2) (match_dup 1))
6901    (set (pc)
6902         (if_then_else (geu (match_dup 2)
6903                            (const_int 0))
6904                       (label_ref (match_operand 0 "" ""))
6905                       (pc)))]
6906   ""
6907   "
6908 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
6909                          rs6000_compare_op0, rs6000_compare_op1);
6910   operands[2] = gen_reg_rtx (CCUNSmode);
6913 (define_expand "bleu"
6914   [(set (match_dup 2) (match_dup 1))
6915    (set (pc)
6916         (if_then_else (leu (match_dup 2)
6917                            (const_int 0))
6918                       (label_ref (match_operand 0 "" ""))
6919                       (pc)))]
6920   ""
6921   "
6922 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
6923                          rs6000_compare_op0, rs6000_compare_op1);
6924   operands[2] = gen_reg_rtx (CCUNSmode);
6927 ;; For SNE, we would prefer that the xor/abs sequence be used for integers.
6928 ;; For SEQ, likewise, except that comparisons with zero should be done
6929 ;; with an scc insns.  However, due to the order that combine see the
6930 ;; resulting insns, we must, in fact, allow SEQ for integers.  Fail in
6931 ;; the cases we don't want to handle.
6932 (define_expand "seq"
6933   [(set (match_dup 2) (match_dup 1))
6934    (set (match_operand:SI 0 "gpc_reg_operand" "")
6935         (eq:SI (match_dup 2) (const_int 0)))]
6936   ""
6937   "
6938 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
6939   operands[1] = gen_rtx (COMPARE, mode,
6940                          rs6000_compare_op0, rs6000_compare_op1);
6941   operands[2] = gen_reg_rtx (mode);
6944 (define_expand "sne"
6945   [(set (match_dup 2) (match_dup 1))
6946    (set (match_operand:SI 0 "gpc_reg_operand" "")
6947         (ne:SI (match_dup 2) (const_int 0)))]
6948   ""
6949   "
6950 { if (! rs6000_compare_fp_p)
6951     FAIL;
6953   operands[1] = gen_rtx (COMPARE, CCFPmode,
6954                          rs6000_compare_op0, rs6000_compare_op1);
6955   operands[2] = gen_reg_rtx (CCFPmode);
6958 ;; A > 0 is best done using the portable sequence, so fail in that case.
6959 (define_expand "sgt"
6960   [(set (match_dup 2) (match_dup 1))
6961    (set (match_operand:SI 0 "gpc_reg_operand" "")
6962         (gt:SI (match_dup 2) (const_int 0)))]
6963   ""
6964   "
6965 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
6967   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
6968     FAIL;
6970   operands[1] = gen_rtx (COMPARE, mode,
6971                          rs6000_compare_op0, rs6000_compare_op1);
6972   operands[2] = gen_reg_rtx (mode);
6975 ;; A < 0 is best done in the portable way for A an integer.
6976 (define_expand "slt"
6977   [(set (match_dup 2) (match_dup 1))
6978    (set (match_operand:SI 0 "gpc_reg_operand" "")
6979         (lt:SI (match_dup 2) (const_int 0)))]
6980   ""
6981   "
6982 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
6984   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
6985     FAIL;
6987   operands[1] = gen_rtx (COMPARE, mode,
6988                          rs6000_compare_op0, rs6000_compare_op1);
6989   operands[2] = gen_reg_rtx (mode);
6992 (define_expand "sge"
6993   [(set (match_dup 2) (match_dup 1))
6994    (set (match_operand:SI 0 "gpc_reg_operand" "")
6995         (ge:SI (match_dup 2) (const_int 0)))]
6996   ""
6997   "
6998 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
6999   operands[1] = gen_rtx (COMPARE, mode,
7000                          rs6000_compare_op0, rs6000_compare_op1);
7001   operands[2] = gen_reg_rtx (mode);
7004 ;; A <= 0 is best done the portable way for A an integer.
7005 (define_expand "sle"
7006   [(set (match_dup 2) (match_dup 1))
7007    (set (match_operand:SI 0 "gpc_reg_operand" "")
7008         (le:SI (match_dup 2) (const_int 0)))]
7009   ""
7010   "
7011 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7013   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
7014     FAIL;
7016   operands[1] = gen_rtx (COMPARE, mode,
7017                          rs6000_compare_op0, rs6000_compare_op1);
7018   operands[2] = gen_reg_rtx (mode);
7021 (define_expand "sgtu"
7022   [(set (match_dup 2) (match_dup 1))
7023    (set (match_operand:SI 0 "gpc_reg_operand" "")
7024         (gtu:SI (match_dup 2) (const_int 0)))]
7025   ""
7026   "
7027 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7028                          rs6000_compare_op0, rs6000_compare_op1);
7029   operands[2] = gen_reg_rtx (CCUNSmode);
7032 (define_expand "sltu"
7033   [(set (match_dup 2) (match_dup 1))
7034    (set (match_operand:SI 0 "gpc_reg_operand" "")
7035         (ltu:SI (match_dup 2) (const_int 0)))]
7036   ""
7037   "
7038 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7039                          rs6000_compare_op0, rs6000_compare_op1);
7040   operands[2] = gen_reg_rtx (CCUNSmode);
7043 (define_expand "sgeu"
7044   [(set (match_dup 2) (match_dup 1))
7045    (set (match_operand:SI 0 "gpc_reg_operand" "")
7046         (geu:SI (match_dup 2) (const_int 0)))]
7047   ""
7048   "
7049 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7050                          rs6000_compare_op0, rs6000_compare_op1);
7051   operands[2] = gen_reg_rtx (CCUNSmode);
7054 (define_expand "sleu"
7055   [(set (match_dup 2) (match_dup 1))
7056    (set (match_operand:SI 0 "gpc_reg_operand" "")
7057         (leu:SI (match_dup 2) (const_int 0)))]
7058   ""
7059   "
7060 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7061                          rs6000_compare_op0, rs6000_compare_op1);
7062   operands[2] = gen_reg_rtx (CCUNSmode);
7065 ;; Here are the actual compare insns.
7066 (define_insn ""
7067   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
7068         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
7069                     (match_operand:SI 2 "reg_or_short_operand" "rI")))]
7070   ""
7071   "{cmp%I2|cmpw%I2} %0,%1,%2"
7072   [(set_attr "type" "compare")])
7074 (define_insn ""
7075   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
7076         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
7077                     (match_operand:DI 2 "reg_or_short_operand" "rI")))]
7078   "TARGET_POWERPC64"
7079   "cmpd%I2 %0,%1,%2"
7080   [(set_attr "type" "compare")])
7082 ;; If we are comparing a register for equality with a large constant,
7083 ;; we can do this with an XOR followed by a compare.  But we need a scratch
7084 ;; register for the result of the XOR.
7086 (define_split
7087   [(set (match_operand:CC 0 "cc_reg_operand" "")
7088         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
7089                     (match_operand:SI 2 "non_short_cint_operand" "")))
7090    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
7091   "find_single_use (operands[0], insn, 0)
7092    && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
7093        || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
7094   [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
7095    (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
7096   "
7098   /* Get the constant we are comparing against, C,  and see what it looks like
7099      sign-extended to 16 bits.  Then see what constant could be XOR'ed
7100      with C to get the sign-extended value.  */
7102   int c = INTVAL (operands[2]);
7103   int sextc = (c << 16) >> 16;
7104   int xorv = c ^ sextc;
7106   operands[4] = gen_rtx (CONST_INT, VOIDmode, xorv);
7107   operands[5] = gen_rtx (CONST_INT, VOIDmode, sextc);
7110 (define_insn ""
7111   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
7112         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
7113                        (match_operand:SI 2 "reg_or_u_short_operand" "rI")))]
7114   ""
7115   "{cmpl%I2|cmplw%I2} %0,%1,%W2"
7116   [(set_attr "type" "compare")])
7118 (define_insn ""
7119   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
7120         (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
7121                        (match_operand:DI 2 "reg_or_u_short_operand" "rI")))]
7122   ""
7123   "cmpld%I2 %0,%1,%W2"
7124   [(set_attr "type" "compare")])
7126 ;; The following two insns don't exist as single insns, but if we provide
7127 ;; them, we can swap an add and compare, which will enable us to overlap more
7128 ;; of the required delay between a compare and branch.  We generate code for
7129 ;; them by splitting.
7131 (define_insn ""
7132   [(set (match_operand:CC 3 "cc_reg_operand" "=y")
7133         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
7134                     (match_operand:SI 2 "short_cint_operand" "i")))
7135    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7136         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
7137   ""
7138   "#"
7139   [(set_attr "length" "8")])
7141 (define_insn ""
7142   [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
7143         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
7144                        (match_operand:SI 2 "u_short_cint_operand" "i")))
7145    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7146         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
7147   ""
7148   "#"
7149   [(set_attr "length" "8")])
7151 (define_split
7152   [(set (match_operand:CC 3 "cc_reg_operand" "")
7153         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
7154                     (match_operand:SI 2 "short_cint_operand" "")))
7155    (set (match_operand:SI 0 "gpc_reg_operand" "")
7156         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
7157   ""
7158   [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
7159    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
7161 (define_split
7162   [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
7163         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
7164                        (match_operand:SI 2 "u_short_cint_operand" "")))
7165    (set (match_operand:SI 0 "gpc_reg_operand" "")
7166         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
7167   ""
7168   [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
7169    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
7171 (define_insn ""
7172   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
7173         (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
7174                       (match_operand:SF 2 "gpc_reg_operand" "f")))]
7175   "TARGET_HARD_FLOAT"
7176   "fcmpu %0,%1,%2"
7177   [(set_attr "type" "fpcompare")])
7179 (define_insn ""
7180   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
7181         (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
7182                       (match_operand:DF 2 "gpc_reg_operand" "f")))]
7183   "TARGET_HARD_FLOAT"
7184   "fcmpu %0,%1,%2"
7185   [(set_attr "type" "fpcompare")])
7187 ;; Now we have the scc insns.  We can do some combinations because of the
7188 ;; way the machine works.
7190 ;; Note that this is probably faster if we can put an insn between the
7191 ;; mfcr and rlinm, but this is tricky.  Let's leave it for now.  In most
7192 ;; cases the insns below which don't use an intermediate CR field will
7193 ;; be used instead.
7194 (define_insn ""
7195   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7196         (match_operator:SI 1 "scc_comparison_operator"
7197                            [(match_operand 2 "cc_reg_operand" "y")
7198                             (const_int 0)]))]
7199   ""
7200   "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%J1,1"
7201   [(set_attr "length" "12")])
7203 (define_insn ""
7204   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
7205         (compare:CC (match_operator:SI 1 "scc_comparison_operator"
7206                                        [(match_operand 2 "cc_reg_operand" "y")
7207                                         (const_int 0)])
7208                     (const_int 0)))
7209    (set (match_operand:SI 3 "gpc_reg_operand" "=r")
7210         (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
7211   ""
7212   "%D1mfcr %3\;{rlinm.|rlwinm.} %3,%3,%J1,1"
7213   [(set_attr "type" "delayed_compare")
7214    (set_attr "length" "12")])
7216 (define_insn ""
7217   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7218         (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
7219                                       [(match_operand 2 "cc_reg_operand" "y")
7220                                        (const_int 0)])
7221                    (match_operand:SI 3 "const_int_operand" "n")))]
7222   ""
7223   "*
7225   int is_bit = ccr_bit (operands[1], 1);
7226   int put_bit = 31 - (INTVAL (operands[3]) & 31);
7227   int count;
7229   if (is_bit >= put_bit)
7230     count = is_bit - put_bit;
7231   else
7232     count = 32 - (put_bit - is_bit);
7234   operands[4] = gen_rtx (CONST_INT, VOIDmode, count);
7235   operands[5] = gen_rtx (CONST_INT, VOIDmode, put_bit);
7237   return \"%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
7239  [(set_attr "length" "12")])
7241 (define_insn ""
7242   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
7243         (compare:CC
7244          (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
7245                                        [(match_operand 2 "cc_reg_operand" "y")
7246                                         (const_int 0)])
7247                     (match_operand:SI 3 "const_int_operand" "n"))
7248          (const_int 0)))
7249    (set (match_operand:SI 4 "gpc_reg_operand" "=r")
7250         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
7251                    (match_dup 3)))]
7252   ""
7253   "*
7255   int is_bit = ccr_bit (operands[1], 1);
7256   int put_bit = 31 - (INTVAL (operands[3]) & 31);
7257   int count;
7259   if (is_bit >= put_bit)
7260     count = is_bit - put_bit;
7261   else
7262     count = 32 - (put_bit - is_bit);
7264   operands[5] = gen_rtx (CONST_INT, VOIDmode, count);
7265   operands[6] = gen_rtx (CONST_INT, VOIDmode, put_bit);
7267   return \"%D1mfcr %4\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
7269   [(set_attr "type" "delayed_compare")
7270    (set_attr "length" "12")])
7272 ;; If we are comparing the result of two comparisons, this can be done
7273 ;; using creqv or crxor.
7275 (define_insn ""
7276   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
7277         (compare:CCEQ (match_operator 1 "scc_comparison_operator"
7278                               [(match_operand 2 "cc_reg_operand" "y")
7279                                (const_int 0)])
7280                       (match_operator 3 "scc_comparison_operator"
7281                               [(match_operand 4 "cc_reg_operand" "y")
7282                                (const_int 0)])))]
7283   "REGNO (operands[2]) != REGNO (operands[4])"
7284   "*
7286   enum rtx_code code1, code2;
7288   code1 = GET_CODE (operands[1]);
7289   code2 = GET_CODE (operands[3]);
7291   if ((code1 == EQ || code1 == LT || code1 == GT
7292        || code1 == LTU || code1 == GTU
7293        || (code1 != NE && GET_MODE (operands[2]) == CCFPmode))
7294       !=
7295       (code2 == EQ || code2 == LT || code2 == GT
7296        || code2 == LTU || code2 == GTU
7297        || (code2 != NE && GET_MODE (operands[4]) == CCFPmode)))
7298     return \"%C1%C3crxor %E0,%j1,%j3\";
7299   else
7300     return \"%C1%C3creqv %E0,%j1,%j3\";
7302   [(set_attr "length" "12")])
7304 ;; There is a 3 cycle delay between consecutive mfcr instructions
7305 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
7307 (define_peephole
7308   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7309         (match_operator:SI 1 "scc_comparison_operator"
7310                            [(match_operand 2 "cc_reg_operand" "y")
7311                             (const_int 0)]))
7312    (set (match_operand:SI 3 "gpc_reg_operand" "=r")
7313         (match_operator:SI 4 "scc_comparison_operator"
7314                            [(match_operand 5 "cc_reg_operand" "y")
7315                             (const_int 0)]))]
7316    "REGNO (operands[2]) != REGNO (operands[5])"
7317    "%D1%D4mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
7318    [(set_attr "length" "20")])
7320 ;; There are some scc insns that can be done directly, without a compare.
7321 ;; These are faster because they don't involve the communications between
7322 ;; the FXU and branch units.   In fact, we will be replacing all of the
7323 ;; integer scc insns here or in the portable methods in emit_store_flag.
7325 ;; Also support (neg (scc ..)) since that construct is used to replace
7326 ;; branches, (plus (scc ..) ..) since that construct is common and
7327 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
7328 ;; cases where it is no more expensive than (neg (scc ..)).
7330 ;; Have reload force a constant into a register for the simple insns that
7331 ;; otherwise won't accept constants.  We do this because it is faster than
7332 ;; the cmp/mfcr sequence we would otherwise generate.
7334 (define_insn ""
7335   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
7336         (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
7337                (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I")))
7338    (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
7339   ""
7340   "@
7341    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
7342    {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
7343    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
7344    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
7345    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
7346   [(set_attr "length" "12,8,12,12,12")])
7348 (define_insn ""
7349   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x")
7350         (compare:CC
7351          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
7352                 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
7353          (const_int 0)))
7354    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
7355         (eq:SI (match_dup 1) (match_dup 2)))
7356    (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
7357   ""
7358   "@
7359    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
7360    {sfi|subfic} %3,%1,0\;{ae.|adde.} %0,%3,%1
7361    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
7362    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
7363    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0"
7364   [(set_attr "type" "compare")
7365    (set_attr "length" "12,8,12,12,12")])
7367 ;; We have insns of the form shown by the first define_insn below.  If
7368 ;; there is something inside the comparison operation, we must split it.
7369 (define_split
7370   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7371         (plus:SI (match_operator 1 "comparison_operator"
7372                                  [(match_operand:SI 2 "" "")
7373                                   (match_operand:SI 3
7374                                                     "reg_or_cint_operand" "")])
7375                  (match_operand:SI 4 "gpc_reg_operand" "")))
7376    (clobber (match_operand:SI 5 "register_operand" ""))]
7377   "! gpc_reg_operand (operands[2], SImode)"
7378   [(set (match_dup 5) (match_dup 2))
7379    (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
7380                                (match_dup 4)))])
7382 (define_insn ""
7383   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
7384         (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
7385                         (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
7386                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))
7387    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
7388   ""
7389   "@
7390    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
7391    {sfi|subfic} %4,%1,0\;{aze|addze} %0,%3
7392    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
7393    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
7394    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3"
7395   [(set_attr "length" "12,8,12,12,12")])
7397 (define_insn ""
7398   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x")
7399         (compare:CC
7400          (plus:SI
7401           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
7402                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
7403           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r"))
7404          (const_int 0)))
7405    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
7406   ""
7407   "@
7408    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
7409    {sfi|subfic} %4,%1,0\;{aze.|addze.} %0,%3
7410    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
7411    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
7412    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3"
7413   [(set_attr "type" "compare")
7414    (set_attr "length" "12,8,12,12,12")])
7416 (define_insn ""
7417   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,x,x,x")
7418         (compare:CC
7419          (plus:SI
7420           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
7421                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
7422           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r"))
7423          (const_int 0)))
7424    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
7425         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
7426    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
7427   ""
7428   "@
7429    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
7430    {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
7431    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
7432    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
7433    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3"
7434   [(set_attr "type" "compare")
7435    (set_attr "length" "12,8,12,12,12")])
7437 (define_insn ""
7438   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
7439         (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
7440                        (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))))]
7441   ""
7442   "@
7443    xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
7444    {ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0
7445    {xoril|xori} %0,%1,%b2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
7446    {xoriu|xoris} %0,%1,%u2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
7447    {sfi|subfic} %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
7448    [(set_attr "length" "12,8,12,12,12")])
7450 ;; Simplify (ne X (const_int 0)) on the PowerPC.  No need to on the Power,
7451 ;; since it nabs/sr is just as fast.
7452 (define_insn ""
7453   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7454         (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
7455                      (const_int 31)))
7456    (clobber (match_scratch:SI 2 "=&r"))]
7457   "!TARGET_POWER"
7458   "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
7459   [(set_attr "length" "8")])
7461 ;; This is what (plus (ne X (const_int 0)) Y) looks like.
7462 (define_insn ""
7463   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7464         (plus:SI (lshiftrt:SI
7465                   (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
7466                   (const_int 31))
7467                  (match_operand:SI 2 "gpc_reg_operand" "r")))
7468    (clobber (match_scratch:SI 3 "=&r"))]
7469   ""
7470   "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
7471   [(set_attr "length" "8")])
7473 (define_insn ""
7474   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
7475         (compare:CC
7476          (plus:SI (lshiftrt:SI
7477                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
7478                    (const_int 31))
7479                   (match_operand:SI 2 "gpc_reg_operand" "r"))
7480          (const_int 0)))
7481    (clobber (match_scratch:SI 3 "=&r"))]
7482   ""
7483   "{ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2"
7484   [(set_attr "type" "compare")
7485    (set_attr "length" "8")])
7487 (define_insn ""
7488   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
7489         (compare:CC
7490          (plus:SI (lshiftrt:SI
7491                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
7492                    (const_int 31))
7493                   (match_operand:SI 2 "gpc_reg_operand" "r"))
7494          (const_int 0)))
7495    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7496         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
7497                  (match_dup 2)))
7498    (clobber (match_scratch:SI 3 "=&r"))]
7499   ""
7500   "{ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2"
7501   [(set_attr "type" "compare")
7502    (set_attr "length" "8")])
7504 (define_insn ""
7505   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7506         (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7507                (match_operand:SI 2 "reg_or_short_operand" "r,O")))
7508    (clobber (match_scratch:SI 3 "=r,X"))]
7509   "TARGET_POWER"
7510   "@
7511    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
7512    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
7513   [(set_attr "length" "12")])
7515 (define_insn ""
7516   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x")
7517         (compare:CC
7518          (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7519                 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
7520          (const_int 0)))
7521    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7522         (le:SI (match_dup 1) (match_dup 2)))
7523    (clobber (match_scratch:SI 3 "=r,X"))]
7524   "TARGET_POWER"
7525   "@
7526    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
7527    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31"
7528   [(set_attr "type" "compare,delayed_compare")
7529    (set_attr "length" "12")])
7531 (define_insn ""
7532   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7533         (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7534                         (match_operand:SI 2 "reg_or_short_operand" "r,O"))
7535                  (match_operand:SI 3 "gpc_reg_operand" "r,r")))
7536    (clobber (match_scratch:SI 4 "=&r,&r"))]
7537   "TARGET_POWER"
7538   "@
7539    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
7540    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze|addze} %0,%3"
7541   [(set_attr "length" "12")])
7543 (define_insn ""
7544   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
7545         (compare:CC
7546          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7547                          (match_operand:SI 2 "reg_or_short_operand" "r,O"))
7548                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
7549          (const_int 0)))
7550    (clobber (match_scratch:SI 4 "=&r,&r"))]
7551   "TARGET_POWER"
7552   "@
7553    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
7554    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3"
7555   [(set_attr "type" "compare")
7556    (set_attr "length" "12")])
7558 (define_insn ""
7559   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
7560         (compare:CC
7561          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7562                          (match_operand:SI 2 "reg_or_short_operand" "r,O"))
7563                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
7564          (const_int 0)))
7565    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7566         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
7567    (clobber (match_scratch:SI 4 "=&r,&r"))]
7568   "TARGET_POWER"
7569   "@
7570    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
7571    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %0,%3"
7572   [(set_attr "type" "compare")
7573    (set_attr "length" "12")])
7575 (define_insn ""
7576   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7577         (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7578                        (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
7579   "TARGET_POWER"
7580   "@
7581    doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
7582    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
7583   [(set_attr "length" "12")])
7585 (define_insn ""
7586   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7587         (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7588                 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
7589   ""
7590   "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
7591   [(set_attr "length" "12")])
7593 (define_insn ""
7594   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
7595         (compare:CC
7596          (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7597                  (match_operand:SI 2 "reg_or_short_operand" "rI"))
7598          (const_int 0)))
7599    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7600         (leu:SI (match_dup 1) (match_dup 2)))]
7601    ""
7602   "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0"
7603   [(set_attr "type" "compare")
7604    (set_attr "length" "12")])
7606 (define_insn ""
7607   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7608         (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7609                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
7610                  (match_operand:SI 3 "gpc_reg_operand" "r")))
7611    (clobber (match_scratch:SI 4 "=&r"))]
7612   ""
7613   "{sf%I2|subf%I2c} %4,%1,%2\;{aze|addze} %0,%3"
7614   [(set_attr "length" "8")])
7616 (define_insn ""
7617   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
7618         (compare:CC
7619          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7620                           (match_operand:SI 2 "reg_or_short_operand" "rI"))
7621                   (match_operand:SI 3 "gpc_reg_operand" "r"))
7622          (const_int 0)))
7623    (clobber (match_scratch:SI 4 "=&r"))]
7624   ""
7625   "{sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3"
7626   [(set_attr "type" "compare")
7627    (set_attr "length" "8")])
7629 (define_insn ""
7630   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
7631         (compare:CC
7632          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7633                           (match_operand:SI 2 "reg_or_short_operand" "rI"))
7634                   (match_operand:SI 3 "gpc_reg_operand" "r"))
7635          (const_int 0)))
7636    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7637         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
7638    (clobber (match_scratch:SI 4 "=&r"))]
7639   ""
7640   "{sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %0,%3"
7641   [(set_attr "type" "compare")
7642    (set_attr "length" "8")])
7644 (define_insn ""
7645   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7646         (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7647                         (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
7648   ""
7649   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
7650    [(set_attr "length" "12")])
7652 (define_insn ""
7653   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7654         (and:SI (neg:SI
7655                  (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7656                          (match_operand:SI 2 "reg_or_short_operand" "rI")))
7657                 (match_operand:SI 3 "gpc_reg_operand" "r")))
7658    (clobber (match_scratch:SI 4 "=&r"))]
7659   ""
7660   "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4"
7661   [(set_attr "length" "12")])
7663 (define_insn ""
7664   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
7665         (compare:CC
7666          (and:SI (neg:SI
7667                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7668                           (match_operand:SI 2 "reg_or_short_operand" "rI")))
7669                  (match_operand:SI 3 "gpc_reg_operand" "r"))
7670          (const_int 0)))
7671    (clobber (match_scratch:SI 4 "=&r"))]
7672   ""
7673   "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4"
7674   [(set_attr "type" "compare")
7675    (set_attr "length" "12")])
7677 (define_insn ""
7678   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
7679         (compare:CC
7680          (and:SI (neg:SI
7681                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7682                           (match_operand:SI 2 "reg_or_short_operand" "rI")))
7683                  (match_operand:SI 3 "gpc_reg_operand" "r"))
7684          (const_int 0)))
7685    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7686         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
7687    (clobber (match_scratch:SI 4 "=&r"))]
7688   ""
7689   "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4"
7690   [(set_attr "type" "compare")
7691    (set_attr "length" "12")])
7693 (define_insn ""
7694   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7695         (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7696                (match_operand:SI 2 "reg_or_short_operand" "rI")))]
7697   "TARGET_POWER"
7698   "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
7699    [(set_attr "length" "12")])
7701 (define_insn ""
7702   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
7703         (compare:CC
7704          (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7705                 (match_operand:SI 2 "reg_or_short_operand" "rI"))
7706          (const_int 0)))
7707    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7708         (lt:SI (match_dup 1) (match_dup 2)))]
7709   "TARGET_POWER"
7710   "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31"
7711   [(set_attr "type" "delayed_compare")
7712    (set_attr "length" "12")])
7714 (define_insn ""
7715   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7716         (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7717                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
7718                  (match_operand:SI 3 "gpc_reg_operand" "r")))
7719    (clobber (match_scratch:SI 4 "=&r"))]
7720   "TARGET_POWER"
7721   "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze|addze} %0,%3"
7722   [(set_attr "length" "12")])
7724 (define_insn ""
7725   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
7726         (compare:CC
7727          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7728                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
7729                   (match_operand:SI 3 "gpc_reg_operand" "r"))
7730          (const_int 0)))
7731    (clobber (match_scratch:SI 4 "=&r"))]
7732   "TARGET_POWER"
7733   "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3"
7734   [(set_attr "type" "compare")
7735    (set_attr "length" "12")])
7737 (define_insn ""
7738   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
7739         (compare:CC
7740          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7741                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
7742                   (match_operand:SI 3 "gpc_reg_operand" "r"))
7743          (const_int 0)))
7744    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7745         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
7746    (clobber (match_scratch:SI 4 "=&r"))]
7747   "TARGET_POWER"
7748   "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %0,%3"
7749   [(set_attr "type" "compare")
7750    (set_attr "length" "12")])
7752 (define_insn ""
7753   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7754         (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7755                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
7756   "TARGET_POWER"
7757   "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
7758   [(set_attr "length" "12")])
7760 (define_insn ""
7761   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7762         (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7763                 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
7764   ""
7765   "@
7766    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg %0,%0
7767    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
7768   [(set_attr "length" "12")])
7770 (define_insn ""
7771   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
7772         (compare:CC
7773          (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7774                  (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
7775          (const_int 0)))
7776    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7777         (ltu:SI (match_dup 1) (match_dup 2)))]
7778   ""
7779   "@
7780    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
7781    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0"
7782   [(set_attr "type" "compare")
7783    (set_attr "length" "12")])
7785 (define_insn ""
7786   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
7787         (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
7788                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,r,P,P"))
7789                  (match_operand:SI 3 "reg_or_short_operand" "r,I,r,I")))
7790    (clobber (match_scratch:SI 4 "=&r,r,&r,r"))]
7791   ""
7792   "@
7793   {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
7794   {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
7795   {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
7796   {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3"
7797  [(set_attr "length" "12")])
7799 (define_insn ""
7800   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
7801         (compare:CC
7802          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7803                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
7804                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
7805          (const_int 0)))
7806    (clobber (match_scratch:SI 4 "=&r,&r"))]
7807   ""
7808   "@
7809    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
7810    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3"
7811   [(set_attr "type" "compare")
7812    (set_attr "length" "12")])
7814 (define_insn ""
7815   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
7816         (compare:CC
7817          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7818                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
7819                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
7820          (const_int 0)))
7821    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7822         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
7823    (clobber (match_scratch:SI 4 "=&r,&r"))]
7824   ""
7825   "@
7826    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3
7827    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3"
7828   [(set_attr "type" "compare")
7829    (set_attr "length" "12")])
7831 (define_insn ""
7832   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7833         (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7834                         (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
7835   ""
7836   "@
7837    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
7838    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
7839   [(set_attr "length" "8")])
7841 (define_insn ""
7842   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7843         (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7844                (match_operand:SI 2 "reg_or_short_operand" "rI")))
7845    (clobber (match_scratch:SI 3 "=r"))]
7846   "TARGET_POWER"
7847   "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
7848    [(set_attr "length" "12")])
7850 (define_insn ""
7851   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
7852         (compare:CC
7853          (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7854                 (match_operand:SI 2 "reg_or_short_operand" "rI"))
7855          (const_int 0)))
7856    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7857         (ge:SI (match_dup 1) (match_dup 2)))
7858    (clobber (match_scratch:SI 3 "=r"))]
7859   "TARGET_POWER"
7860   "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3"
7861   [(set_attr "type" "compare")
7862    (set_attr "length" "12")])
7864 (define_insn ""
7865   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7866         (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7867                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
7868                  (match_operand:SI 3 "gpc_reg_operand" "r")))
7869    (clobber (match_scratch:SI 4 "=&r"))]
7870   "TARGET_POWER"
7871   "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3"
7872   [(set_attr "length" "12")])
7874 (define_insn ""
7875   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
7876         (compare:CC
7877          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7878                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
7879                   (match_operand:SI 3 "gpc_reg_operand" "r"))
7880          (const_int 0)))
7881    (clobber (match_scratch:SI 4 "=&r"))]
7882   "TARGET_POWER"
7883   "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3"
7884   [(set_attr "type" "compare")
7885    (set_attr "length" "12")])
7887 (define_insn ""
7888   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
7889         (compare:CC
7890          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7891                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
7892                   (match_operand:SI 3 "gpc_reg_operand" "r"))
7893          (const_int 0)))
7894    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7895         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
7896    (clobber (match_scratch:SI 4 "=&r"))]
7897   "TARGET_POWER"
7898   "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3"
7899   [(set_attr "type" "compare")
7900    (set_attr "length" "12")])
7902 (define_insn ""
7903   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7904         (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
7905                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
7906   "TARGET_POWER"
7907   "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
7908   [(set_attr "length" "12")])
7910 ;; This is (and (neg (ge X (const_int 0))) Y).
7911 (define_insn ""
7912   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7913         (and:SI (neg:SI
7914                  (lshiftrt:SI
7915                   (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
7916                   (const_int 31)))
7917                 (match_operand:SI 2 "gpc_reg_operand" "r")))
7918    (clobber (match_scratch:SI 3 "=&r"))]
7919   ""
7920   "{srai|srawi} %3,%1,31\;andc %0,%2,%3"
7921   [(set_attr "length" "8")])
7923 (define_insn ""
7924   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
7925         (compare:CC
7926          (and:SI (neg:SI
7927                   (lshiftrt:SI
7928                    (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
7929                    (const_int 31)))
7930                  (match_operand:SI 2 "gpc_reg_operand" "r"))
7931          (const_int 0)))
7932    (clobber (match_scratch:SI 3 "=&r"))]
7933   ""
7934   "{srai|srawi} %3,%1,31\;andc. %3,%2,%3"
7935   [(set_attr "type" "compare")
7936    (set_attr "length" "8")])
7938 (define_insn ""
7939   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
7940         (compare:CC
7941          (and:SI (neg:SI
7942                   (lshiftrt:SI
7943                    (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
7944                    (const_int 31)))
7945                  (match_operand:SI 2 "gpc_reg_operand" "r"))
7946          (const_int 0)))
7947    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7948         (and:SI (neg:SI (lshiftrt:SI (not:SI (match_dup 1))
7949                                      (const_int 31)))
7950                 (match_dup 2)))
7951    (clobber (match_scratch:SI 3 "=&r"))]
7952   ""
7953   "{srai|srawi} %3,%1,31\;andc. %0,%2,%3"
7954   [(set_attr "type" "compare")
7955    (set_attr "length" "8")])
7957 (define_insn ""
7958   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7959         (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7960                 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
7961   ""
7962   "@
7963    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
7964    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
7965   [(set_attr "length" "12")])
7967 (define_insn ""
7968   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
7969         (compare:CC
7970          (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7971                  (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
7972          (const_int 0)))
7973    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7974         (geu:SI (match_dup 1) (match_dup 2)))]
7975   ""
7976   "@
7977    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
7978    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0"
7979   [(set_attr "type" "compare")
7980    (set_attr "length" "12")])
7982 (define_insn ""
7983   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7984         (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7985                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
7986                  (match_operand:SI 3 "gpc_reg_operand" "r,r")))
7987    (clobber (match_scratch:SI 4 "=&r,&r"))]
7988   ""
7989   "@
7990    {sf|subfc} %4,%2,%1\;{aze|addze} %0,%3
7991    {ai|addic} %4,%1,%n2\;{aze|addze} %0,%3"
7992   [(set_attr "length" "8")])
7994 (define_insn ""
7995   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
7996         (compare:CC
7997          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
7998                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
7999                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8000          (const_int 0)))
8001    (clobber (match_scratch:SI 4 "=&r,&r"))]
8002   ""
8003   "@
8004    {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
8005    {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3"
8006   [(set_attr "type" "compare")
8007    (set_attr "length" "8")])
8009 (define_insn ""
8010   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
8011         (compare:CC
8012          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8013                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8014                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8015          (const_int 0)))
8016    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8017         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8018    (clobber (match_scratch:SI 4 "=&r,&r"))]
8019   ""
8020   "@
8021    {sf|subfc} %4,%2,%1\;{aze.|addze.} %0,%3
8022    {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3"
8023   [(set_attr "type" "compare")
8024    (set_attr "length" "8")])
8026 (define_insn ""
8027   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8028         (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8029                         (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
8030   ""
8031   "@
8032    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
8033    {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
8034   [(set_attr "length" "12")])
8036 (define_insn ""
8037   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8038         (and:SI (neg:SI
8039                  (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8040                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
8041                 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
8042    (clobber (match_scratch:SI 4 "=&r,&r"))]
8043   ""
8044   "@
8045    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4
8046    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4"
8047   [(set_attr "length" "12")])
8049 (define_insn ""
8050   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
8051         (compare:CC
8052          (and:SI (neg:SI
8053                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8054                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
8055                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8056          (const_int 0)))
8057    (clobber (match_scratch:SI 4 "=&r,&r"))]
8058   ""
8059   "@
8060    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
8061    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4"
8062   [(set_attr "type" "compare")
8063    (set_attr "length" "12")])
8065 (define_insn ""
8066   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
8067         (compare:CC
8068          (and:SI (neg:SI
8069                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8070                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
8071                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8072          (const_int 0)))
8073    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8074         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
8075    (clobber (match_scratch:SI 4 "=&r,&r"))]
8076   ""
8077   "@
8078    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4
8079    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4"
8080   [(set_attr "type" "compare")
8081    (set_attr "length" "12")])
8083 (define_insn ""
8084   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8085         (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8086                (const_int 0)))]
8087   ""
8088   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri|srwi} %0,%0,31"
8089   [(set_attr "length" "12")])
8091 (define_insn ""
8092   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
8093         (compare:CC
8094          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8095                 (const_int 0))
8096          (const_int 0)))
8097    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8098         (gt:SI (match_dup 1) (const_int 0)))]
8099   ""
8100   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri.|srwi.} %0,%0,31"
8101   [(set_attr "type" "delayed_compare")
8102    (set_attr "length" "12")])
8104 (define_insn ""
8105   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8106         (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8107                (match_operand:SI 2 "reg_or_short_operand" "r")))]
8108   "TARGET_POWER"
8109   "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
8110   [(set_attr "length" "12")])
8112 (define_insn ""
8113   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
8114         (compare:CC
8115          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8116                 (match_operand:SI 2 "reg_or_short_operand" "r"))
8117          (const_int 0)))
8118    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8119         (gt:SI (match_dup 1) (match_dup 2)))]
8120   "TARGET_POWER"
8121   "doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31"
8122   [(set_attr "type" "delayed_compare")
8123    (set_attr "length" "12")])
8125 (define_insn ""
8126   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8127         (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8128                         (const_int 0))
8129                  (match_operand:SI 2 "gpc_reg_operand" "r")))
8130    (clobber (match_scratch:SI 3 "=&r"))]
8131   ""
8132   "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze|addze} %0,%2"
8133   [(set_attr "length" "12")])
8135 (define_insn ""
8136   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8137         (compare:CC
8138          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8139                          (const_int 0))
8140                   (match_operand:SI 2 "gpc_reg_operand" "r"))
8141          (const_int 0)))
8142    (clobber (match_scratch:SI 3 "=&r"))]
8143   ""
8144   "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %0,%2"
8145   [(set_attr "type" "compare")
8146    (set_attr "length" "12")])
8148 (define_insn ""
8149   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
8150         (compare:CC
8151          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8152                          (const_int 0))
8153                   (match_operand:SI 2 "gpc_reg_operand" "r"))
8154          (const_int 0)))
8155    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8156         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
8157    (clobber (match_scratch:SI 3 "=&r"))]
8158   ""
8159   "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2"
8160   [(set_attr "type" "compare")
8161    (set_attr "length" "12")])
8163 (define_insn ""
8164   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8165         (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8166                         (match_operand:SI 2 "reg_or_short_operand" "r"))
8167                  (match_operand:SI 3 "gpc_reg_operand" "r")))
8168    (clobber (match_scratch:SI 4 "=&r"))]
8169   "TARGET_POWER"
8170   "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze|addze} %0,%3"
8171   [(set_attr "length" "12")])
8173 (define_insn ""
8174   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8175         (compare:CC
8176          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8177                          (match_operand:SI 2 "reg_or_short_operand" "r"))
8178                   (match_operand:SI 3 "gpc_reg_operand" "r"))
8179          (const_int 0)))
8180    (clobber (match_scratch:SI 4 "=&r"))]
8181   "TARGET_POWER"
8182   "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3"
8183   [(set_attr "type" "compare")
8184    (set_attr "length" "12")])
8186 (define_insn ""
8187   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
8188         (compare:CC
8189          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8190                          (match_operand:SI 2 "reg_or_short_operand" "r"))
8191                   (match_operand:SI 3 "gpc_reg_operand" "r"))
8192          (const_int 0)))
8193    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8194         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8195    (clobber (match_scratch:SI 4 "=&r"))]
8196   "TARGET_POWER"
8197   "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %0,%3"
8198   [(set_attr "type" "compare")
8199    (set_attr "length" "12")])
8201 (define_insn ""
8202   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8203         (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8204                        (const_int 0))))]
8205   ""
8206   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{srai|srawi} %0,%0,31"
8207   [(set_attr "length" "12")])
8209 (define_insn ""
8210   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8211         (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8212                        (match_operand:SI 2 "reg_or_short_operand" "r"))))]
8213   "TARGET_POWER"
8214   "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
8215   [(set_attr "length" "12")])
8217 (define_insn ""
8218   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8219         (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8220                 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
8221   ""
8222   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
8223   [(set_attr "length" "12")])
8225 (define_insn ""
8226   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
8227         (compare:CC
8228          (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8229                  (match_operand:SI 2 "reg_or_short_operand" "rI"))
8230          (const_int 0)))
8231    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8232         (gtu:SI (match_dup 1) (match_dup 2)))]
8233   ""
8234   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0"
8235   [(set_attr "type" "compare")
8236    (set_attr "length" "12")])
8238 (define_insn ""
8239   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
8240         (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
8241                          (match_operand:SI 2 "reg_or_short_operand" "I,r,rI"))
8242                  (match_operand:SI 3 "reg_or_short_operand" "r,r,I")))
8243    (clobber (match_scratch:SI 4 "=&r,&r,&r"))]
8244   ""
8245   "@
8246    {ai|addic} %4,%1,%k2\;{aze|addze} %0,%3
8247    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
8248    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3"
8249   [(set_attr "length" "8,12,12")])
8251 (define_insn ""
8252   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
8253         (compare:CC
8254          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8255                           (match_operand:SI 2 "reg_or_short_operand" "I,r"))
8256                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8257          (const_int 0)))
8258    (clobber (match_scratch:SI 4 "=&r,&r"))]
8259   ""
8260   "@
8261    {ai|addic} %4,%1,%k2\;{aze.|addze.} %0,%3
8262    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3"
8263   [(set_attr "type" "compare")
8264    (set_attr "length" "8,12")])
8266 (define_insn ""
8267   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
8268         (compare:CC
8269          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8270                           (match_operand:SI 2 "reg_or_short_operand" "I,r"))
8271                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8272          (const_int 0)))
8273    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8274         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8275    (clobber (match_scratch:SI 4 "=&r,&r"))]
8276   ""
8277   "@
8278    {ai|addic} %4,%1,%k2\;{aze.|addze.} %0,%3
8279    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3"
8280   [(set_attr "type" "compare")
8281    (set_attr "length" "8,12")])
8283 (define_insn ""
8284   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8285         (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8286                         (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
8287   ""
8288   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
8289   [(set_attr "length" "8")])
8291 ;; Define both directions of branch and return.  If we need a reload
8292 ;; register, we'd rather use CR0 since it is much easier to copy a
8293 ;; register CC value to there.
8295 (define_insn ""
8296   [(set (pc)
8297         (if_then_else (match_operator 1 "branch_comparison_operator"
8298                                       [(match_operand 2
8299                                                       "cc_reg_operand" "x,?y")
8300                                        (const_int 0)])
8301                       (label_ref (match_operand 0 "" ""))
8302                       (pc)))]
8303   ""
8304   "*
8306   if (get_attr_length (insn) == 8)
8307     return \"%C1bc %t1,%j1,%l0\";
8308   else
8309     return \"%C1bc %T1,%j1,$+8\;b %l0\";
8311   [(set_attr "type" "branch")])
8313 (define_insn ""
8314   [(set (pc)
8315         (if_then_else (match_operator 0 "branch_comparison_operator"
8316                                       [(match_operand 1
8317                                                       "cc_reg_operand" "x,?y")
8318                                        (const_int 0)])
8319                       (return)
8320                       (pc)))]
8321   "direct_return ()"
8322   "{%C0bcr|%C0bclr} %t0,%j0"
8323   [(set_attr "length" "8")])
8325 (define_insn ""
8326   [(set (pc)
8327         (if_then_else (match_operator 1 "branch_comparison_operator"
8328                                       [(match_operand 2
8329                                                       "cc_reg_operand" "x,?y")
8330                                        (const_int 0)])
8331                       (pc)
8332                       (label_ref (match_operand 0 "" ""))))]
8333   ""
8334   "*
8336   if (get_attr_length (insn) == 8)
8337     return \"%C1bc %T1,%j1,%l0\";
8338   else
8339     return \"%C1bc %t1,%j1,$+8\;b %l0\";
8341   [(set_attr "type" "branch")])
8343 (define_insn ""
8344   [(set (pc)
8345         (if_then_else (match_operator 0 "branch_comparison_operator"
8346                                       [(match_operand 1
8347                                                       "cc_reg_operand" "x,?y")
8348                                        (const_int 0)])
8349                       (pc)
8350                       (return)))]
8351   "direct_return ()"
8352   "{%C0bcr|%C0bclr} %T0,%j0"
8353   [(set_attr "length" "8")])
8355 ;; Unconditional branch and return.
8357 (define_insn "jump"
8358   [(set (pc)
8359         (label_ref (match_operand 0 "" "")))]
8360   ""
8361   "b %l0")
8363 (define_insn "return"
8364   [(return)]
8365   "direct_return ()"
8366   "{br|blr}"
8367   [(set_attr "type" "jmpreg")])
8369 (define_insn "indirect_jump"
8370   [(set (pc) (match_operand:SI 0 "register_operand" "c,l"))]
8371   ""
8372   "@
8373    bctr
8374    {br|blr}"
8375   [(set_attr "type" "jmpreg")])
8377 (define_insn ""
8378   [(set (pc) (match_operand:DI 0 "register_operand" "c,l"))]
8379   "TARGET_POWERPC64"
8380   "@
8381    bctr
8382    {br|blr}"
8383   [(set_attr "type" "jmpreg")])
8385 ;; Table jump for switch statements:
8386 (define_expand "tablejump"
8387   [(set (match_dup 3)
8388         (plus:SI (match_operand:SI 0 "" "")
8389                  (match_dup 2)))
8390    (parallel [(set (pc) (match_dup 3))
8391               (use (label_ref (match_operand 1 "" "")))])]
8392   ""
8393   "
8394 { operands[0] = force_reg (SImode, operands[0]);
8395   operands[2] = force_reg (SImode, gen_rtx (LABEL_REF, VOIDmode, operands[1]));
8396   operands[3] = gen_reg_rtx (SImode);
8399 (define_insn ""
8400   [(set (pc)
8401         (match_operand:SI 0 "register_operand" "c,l"))
8402    (use (label_ref (match_operand 1 "" "")))]
8403   ""
8404   "@
8405    bctr
8406    {br|blr}"
8407   [(set_attr "type" "jmpreg")])
8409 (define_insn ""
8410   [(set (pc)
8411         (match_operand:DI 0 "register_operand" "c,l"))
8412    (use (label_ref (match_operand 1 "" "")))]
8413   "TARGET_POWERPC64"
8414   "@
8415    bctr
8416    {br|blr}"
8417   [(set_attr "type" "jmpreg")])
8419 (define_insn "nop"
8420   [(const_int 0)]
8421   ""
8422   "{cror 0,0,0|nop}")
8424 ;; Define the subtract-one-and-jump insns, starting with the template
8425 ;; so loop.c knows what to generate.
8427 (define_expand "decrement_and_branch_on_count"
8428   [(parallel [(set (pc) (if_then_else (ne (match_operand:SI 0 "register_operand" "")
8429                                           (const_int 1))
8430                                       (label_ref (match_operand 1 "" ""))
8431                                       (pc)))
8432               (set (match_dup 0)
8433                    (plus:SI (match_dup 0)
8434                             (const_int -1)))
8435               (clobber (match_scratch:CC 2 ""))
8436               (clobber (match_scratch:SI 3 ""))])]
8437   ""
8438   "")
8440 ;; We need to be able to do this for any operand, including MEM, or we
8441 ;; will cause reload to blow up since we don't allow output reloads on
8442 ;; JUMP_INSNs.
8443 ;; In order that the length attribute is calculated correctly, the
8444 ;; label MUST be operand 0.
8446 (define_insn ""
8447   [(set (pc)
8448         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
8449                           (const_int 1))
8450                       (label_ref (match_operand 0 "" ""))
8451                       (pc)))
8452    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
8453         (plus:SI (match_dup 1)
8454                  (const_int -1)))
8455    (clobber (match_scratch:CC 3 "=X,&x,&x"))
8456    (clobber (match_scratch:SI 4 "=X,X,r"))]
8457   ""
8458   "*
8460   if (which_alternative != 0)
8461     return \"#\";
8462   else if (get_attr_length (insn) == 8)
8463     return \"{bdn|bdnz} %l0\";
8464   else
8465     return \"bdz $+8\;b %l0\";
8467   [(set_attr "type" "branch")
8468    (set_attr "length" "*,12,16")])
8470 (define_insn ""
8471   [(set (pc)
8472         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
8473                           (const_int 1))
8474                       (pc)
8475                       (label_ref (match_operand 0 "" ""))))
8476    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
8477         (plus:SI (match_dup 1)
8478                  (const_int -1)))
8479    (clobber (match_scratch:CC 3 "=X,&x,&x"))
8480    (clobber (match_scratch:SI 4 "=X,X,r"))]
8481   ""
8482   "*
8484   if (which_alternative != 0)
8485     return \"#\";
8486   else if (get_attr_length (insn) == 8)
8487     return \"bdz %l0\";
8488   else
8489     return \"{bdn|bdnz} $+8\;b %l0\";
8491   [(set_attr "type" "branch")
8492    (set_attr "length" "*,12,16")])
8494 ;; Similar, but we can use GE since we have a REG_NONNEG.
8495 (define_insn ""
8496   [(set (pc)
8497         (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
8498                           (const_int 0))
8499                       (label_ref (match_operand 0 "" ""))
8500                       (pc)))
8501    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
8502         (plus:SI (match_dup 1)
8503                  (const_int -1)))
8504    (clobber (match_scratch:CC 3 "=X,&x,&X"))
8505    (clobber (match_scratch:SI 4 "=X,X,r"))]
8506   "find_reg_note (insn, REG_NONNEG, 0)"
8507   "*
8509   if (which_alternative != 0)
8510     return \"#\";
8511   else if (get_attr_length (insn) == 8)
8512     return \"{bdn|bdnz} %l0\";
8513   else
8514     return \"bdz $+8\;b %l0\";
8516   [(set_attr "type" "branch")
8517    (set_attr "length" "*,12,16")])
8519 (define_insn ""
8520   [(set (pc)
8521         (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
8522                           (const_int 0))
8523                       (pc)
8524                       (label_ref (match_operand 0 "" ""))))
8525    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
8526         (plus:SI (match_dup 1)
8527                  (const_int -1)))
8528    (clobber (match_scratch:CC 3 "=X,&x,&X"))
8529    (clobber (match_scratch:SI 4 "=X,X,r"))]
8530   "find_reg_note (insn, REG_NONNEG, 0)"
8531   "*
8533   if (which_alternative != 0)
8534     return \"#\";
8535   else if (get_attr_length (insn) == 8)
8536     return \"bdz %l0\";
8537   else
8538     return \"{bdn|bdnz} $+8\;b %l0\";
8540   [(set_attr "type" "branch")
8541    (set_attr "length" "*,12,16")])
8543 (define_insn ""
8544   [(set (pc)
8545         (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
8546                           (const_int 1))
8547                       (label_ref (match_operand 0 "" ""))
8548                       (pc)))
8549    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
8550         (plus:SI (match_dup 1)
8551                  (const_int -1)))
8552    (clobber (match_scratch:CC 3 "=X,&x,&x"))
8553    (clobber (match_scratch:SI 4 "=X,X,r"))]
8554   ""
8555   "*
8557   if (which_alternative != 0)
8558     return \"#\";
8559   else if (get_attr_length (insn) == 8)
8560     return \"bdz %l0\";
8561   else
8562     return \"{bdn|bdnz} $+8\;b %l0\";
8564   [(set_attr "type" "branch")
8565    (set_attr "length" "*,12,16")])
8567 (define_insn ""
8568   [(set (pc)
8569         (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
8570                           (const_int 1))
8571                       (pc)
8572                       (label_ref (match_operand 0 "" ""))))
8573    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
8574         (plus:SI (match_dup 1)
8575                  (const_int -1)))
8576    (clobber (match_scratch:CC 3 "=X,&x,&x"))
8577    (clobber (match_scratch:SI 4 "=X,X,r"))]
8578   ""
8579   "*
8581   if (which_alternative != 0)
8582     return \"#\";
8583   else if (get_attr_length (insn) == 8)
8584     return \"{bdn|bdnz} %l0\";
8585   else
8586     return \"bdz $+8\;b %l0\";
8588   [(set_attr "type" "branch")
8589    (set_attr "length" "*,12,16")])
8591 (define_split
8592   [(set (pc)
8593         (if_then_else (match_operator 2 "comparison_operator"
8594                                       [(match_operand:SI 1 "gpc_reg_operand" "")
8595                                        (const_int 1)])
8596                       (match_operand 5 "" "")
8597                       (match_operand 6 "" "")))
8598    (set (match_operand:SI 0 "gpc_reg_operand" "")
8599         (plus:SI (match_dup 1)
8600                  (const_int -1)))
8601    (clobber (match_scratch:CC 3 ""))
8602    (clobber (match_scratch:SI 4 ""))]
8603   "reload_completed"
8604   [(parallel [(set (match_dup 3)
8605                    (compare:CC (plus:SI (match_dup 1)
8606                                         (const_int -1))
8607                                (const_int 0)))
8608               (set (match_dup 0)
8609                    (plus:SI (match_dup 1)
8610                             (const_int -1)))])
8611    (set (pc) (if_then_else (match_dup 7)
8612                            (match_dup 5)
8613                            (match_dup 6)))]
8614   "
8615 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
8616                          const0_rtx); }")
8618 (define_split
8619   [(set (pc)
8620         (if_then_else (match_operator 2 "comparison_operator"
8621                                       [(match_operand:SI 1 "gpc_reg_operand" "")
8622                                        (const_int 1)])
8623                       (match_operand 5 "" "")
8624                       (match_operand 6 "" "")))
8625    (set (match_operand:SI 0 "general_operand" "")
8626         (plus:SI (match_dup 1) (const_int -1)))
8627    (clobber (match_scratch:CC 3 ""))
8628    (clobber (match_scratch:SI 4 ""))]
8629   "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
8630   [(parallel [(set (match_dup 3)
8631                    (compare:CC (plus:SI (match_dup 1)
8632                                         (const_int -1))
8633                                (const_int 0)))
8634               (set (match_dup 4)
8635                    (plus:SI (match_dup 1)
8636                             (const_int -1)))])
8637    (set (match_dup 0)
8638         (match_dup 4))
8639    (set (pc) (if_then_else (match_dup 7)
8640                            (match_dup 5)
8641                            (match_dup 6)))]
8642   "
8643 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
8644                          const0_rtx); }")