OSDN Git Service

Fix -fpic problems
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / rs6000.md
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)
4
5 ;; This file is part of GNU CC.
6
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.
11
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.
16
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.
21
22 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
23 \f
24 ;; Define an insn type attribute.  This is used in function unit delay
25 ;; computations.
26 (define_attr "type" "integer,load,store,fpload,fpstore,imul,idiv,branch,compare,delayed_compare,fpcompare,mtjmpr,fp,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg"
27   (const_string "integer"))
28
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)))
39
40 ;; Processor type -- this attribute must exactly match the processor_type
41 ;; enumeration in rs6000.h.
42
43 (define_attr "cpu" "rios1,rios2,mpccore,ppc403,ppc601,ppc603,ppc604,ppc620"
44   (const (symbol_ref "rs6000_cpu_attr")))
45
46 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
47 ;                       TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
48
49 ; Load/Store Unit -- 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,ppc603,ppc604,ppc620"))
54   2 1)
55
56 (define_function_unit "lsu" 1 0
57   (and (eq_attr "type" "store,fpstore")
58        (eq_attr "cpu" "mpccore,ppc603,ppc604,ppc620"))
59   1 1)
60
61 (define_function_unit "lsu" 1 0
62   (and (eq_attr "type" "fpload")
63        (eq_attr "cpu" "mpccore,ppc603"))
64   2 1)
65
66 (define_function_unit "lsu" 1 0
67   (and (eq_attr "type" "fpload")
68        (eq_attr "cpu" "ppc604,ppc620"))
69   3 1)
70
71 (define_function_unit "iu" 1 0
72   (and (eq_attr "type" "load")
73        (eq_attr "cpu" "rios1,ppc403,ppc601"))
74   2 1)
75
76 (define_function_unit "iu" 1 0
77   (and (eq_attr "type" "store,fpstore")
78        (eq_attr "cpu" "rios1,ppc403,ppc601"))
79   1 1)
80
81 (define_function_unit "fpu" 1 0
82   (and (eq_attr "type" "fpstore")
83        (eq_attr "cpu" "rios1,ppc601"))
84   0 1)
85
86 (define_function_unit "iu" 1 0
87   (and (eq_attr "type" "fpload")
88        (eq_attr "cpu" "rios1"))
89   2 1)
90
91 (define_function_unit "iu" 1 0
92   (and (eq_attr "type" "fpload")
93        (eq_attr "cpu" "ppc601"))
94   3 1)
95
96 (define_function_unit "iu2" 2 0
97   (and (eq_attr "type" "load,fpload")
98        (eq_attr "cpu" "rios2"))
99   2 1)
100
101 (define_function_unit "iu2" 2 0
102   (and (eq_attr "type" "store,fpstore")
103        (eq_attr "cpu" "rios2"))
104   1 1)
105
106 ; Integer Unit (RIOS1, PPC601, PPC603)
107 (define_function_unit "iu" 1 0
108   (and (eq_attr "type" "integer")
109        (eq_attr "cpu" "rios1,mpccore,ppc403,ppc601,ppc603"))
110   1 1)
111
112 (define_function_unit "iu" 1 0
113   (and (eq_attr "type" "imul")
114        (eq_attr "cpu" "ppc403"))
115   4 4)
116
117 (define_function_unit "iu" 1 0
118   (and (eq_attr "type" "imul")
119        (eq_attr "cpu" "rios1,ppc601,ppc603"))
120   5 5)
121
122 (define_function_unit "iu" 1 0
123   (and (eq_attr "type" "idiv")
124        (eq_attr "cpu" "rios1"))
125   19 19)
126
127 (define_function_unit "iu" 1 0
128   (and (eq_attr "type" "idiv")
129        (eq_attr "cpu" "ppc403"))
130   33 33)
131
132 (define_function_unit "iu" 1 0
133   (and (eq_attr "type" "idiv")
134        (eq_attr "cpu" "ppc601"))
135   36 36)
136
137 (define_function_unit "iu" 1 0
138   (and (eq_attr "type" "idiv")
139        (eq_attr "cpu" "ppc603"))
140   37 36)
141
142 ; RIOS2 has two integer units: a primary one which can perform all
143 ; operations and a secondary one which is fed in lock step with the first
144 ; and can perform "simple" integer operations.  
145 ; To catch this we define a 'dummy' imuldiv-unit that is also needed
146 ; for the complex insns. 
147 (define_function_unit "iu2" 2 0
148   (and (eq_attr "type" "integer")
149        (eq_attr "cpu" "rios2"))
150   1 1)
151
152 (define_function_unit "iu2" 2 0
153   (and (eq_attr "type" "imul")
154        (eq_attr "cpu" "rios2"))
155   2 2)
156
157 (define_function_unit "iu2" 2 0
158   (and (eq_attr "type" "idiv")
159        (eq_attr "cpu" "rios2"))
160   13 13)
161
162 (define_function_unit "imuldiv" 1 0
163   (and (eq_attr "type" "imul")
164        (eq_attr "cpu" "rios2"))
165   2 2)
166
167 (define_function_unit "imuldiv" 1 0
168   (and (eq_attr "type" "idiv")
169        (eq_attr "cpu" "rios2"))
170   13 13)
171
172 ; MPCCORE has separate IMUL/IDIV unit for multicycle instructions
173 ; Divide latency varies greatly from 2-11, use 6 as average
174 (define_function_unit "imuldiv" 1 0
175   (and (eq_attr "type" "imul")
176        (eq_attr "cpu" "mpccore"))
177   2 1)
178
179 (define_function_unit "imuldiv" 1 0
180   (and (eq_attr "type" "idiv")
181        (eq_attr "cpu" "mpccore"))
182   6 6)
183
184 ; PPC604 has two units that perform integer operations
185 ; and one unit for divide/multiply operations (and move
186 ; from/to spr).
187 (define_function_unit "iu2" 2 0
188   (and (eq_attr "type" "integer")
189        (eq_attr "cpu" "ppc604,ppc620"))
190   1 1)
191
192 (define_function_unit "imuldiv" 1 0
193   (and (eq_attr "type" "imul")
194        (eq_attr "cpu" "ppc604,ppc620"))
195   4 2)
196
197 (define_function_unit "imuldiv" 1 0
198   (and (eq_attr "type" "idiv")
199        (eq_attr "cpu" "ppc604,ppc620"))
200   20 19)
201
202 ; compare is done on integer unit, but feeds insns which
203 ; execute on the branch unit.
204 (define_function_unit "iu" 1 0   
205   (and (eq_attr "type" "compare")
206        (eq_attr "cpu" "rios1"))
207   4 1)
208
209 (define_function_unit "iu" 1 0   
210   (and (eq_attr "type" "delayed_compare")
211        (eq_attr "cpu" "rios1"))
212   5 1)
213
214 (define_function_unit "iu" 1 0
215   (and (eq_attr "type" "compare,delayed_compare")
216        (eq_attr "cpu" "mpccore,ppc403,ppc601,ppc603,ppc604,ppc620"))
217   3 1)
218
219 (define_function_unit "iu2" 2 0   
220   (and (eq_attr "type" "compare,delayed_compare")
221        (eq_attr "cpu" "rios2"))
222   3 1)
223
224 (define_function_unit "iu2" 2 0
225   (and (eq_attr "type" "compare,delayed_compare")
226        (eq_attr "cpu" "ppc604,ppc620"))
227   1 1)
228
229 ; fp compare uses fp unit
230 (define_function_unit "fpu" 1 0
231   (and (eq_attr "type" "fpcompare")
232        (eq_attr "cpu" "rios1"))
233   9 1)
234
235 ; rios1 and rios2 have different fpcompare delays
236 (define_function_unit "fpu2" 2 0
237   (and (eq_attr "type" "fpcompare")
238        (eq_attr "cpu" "rios2"))
239   5 1)
240
241 ; on ppc601 and ppc603, fpcompare takes also 2 cycles from
242 ; the integer unit
243 ; here we do not define delays, just occupy the unit. The dependencies
244 ; will be assigned by the fpcompare definition in the fpu.
245 (define_function_unit "iu" 1 0
246   (and (eq_attr "type" "fpcompare")
247        (eq_attr "cpu" "ppc601,ppc603"))
248   0 2)
249
250 ; fp compare uses fp unit
251 (define_function_unit "fpu" 1 0
252   (and (eq_attr "type" "fpcompare")
253        (eq_attr "cpu" "ppc601,ppc603,ppc604,ppc620"))
254   5 1)
255
256 (define_function_unit "fpu" 1 0
257   (and (eq_attr "type" "fpcompare")
258        (eq_attr "cpu" "mpccore"))
259   1 1)
260
261 (define_function_unit "bpu" 1 0
262   (and (eq_attr "type" "mtjmpr")
263        (eq_attr "cpu" "rios1,rios2"))
264   5 1)
265
266 (define_function_unit "bpu" 1 0
267   (and (eq_attr "type" "mtjmpr")
268        (eq_attr "cpu" "mpccore,ppc403,ppc601,ppc603,ppc604,ppc620"))
269   4 1)
270
271 ; all jumps/branches are executing on the bpu, in 1 cycle, for all machines.
272 (define_function_unit "bpu" 1 0
273   (eq_attr "type" "jmpreg")
274   1 1)
275
276 (define_function_unit "bpu" 1 0
277   (eq_attr "type" "branch")
278   1 1)
279
280 ; Floating Point Unit
281 (define_function_unit "fpu" 1 0
282   (and (eq_attr "type" "fp,dmul")
283        (eq_attr "cpu" "rios1"))
284   2 1)
285
286 (define_function_unit "fpu" 1 0
287   (and (eq_attr "type" "fp")
288        (eq_attr "cpu" "mpccore"))
289   4 4)
290
291 (define_function_unit "fpu" 1 0
292   (and (eq_attr "type" "fp")
293        (eq_attr "cpu" "ppc601"))
294   4 1)
295
296 (define_function_unit "fpu" 1 0
297   (and (eq_attr "type" "fp")
298        (eq_attr "cpu" "ppc603,ppc604,ppc620"))
299   3 1)
300
301 (define_function_unit "fpu" 1 0
302   (and (eq_attr "type" "dmul")
303        (eq_attr "cpu" "mpccore"))
304   5 5)
305
306 (define_function_unit "fpu" 1 0
307   (and (eq_attr "type" "dmul")
308        (eq_attr "cpu" "ppc601"))
309   5 2)
310
311 ; is this true?
312 (define_function_unit "fpu" 1 0
313   (and (eq_attr "type" "dmul")
314        (eq_attr "cpu" "ppc603"))
315   4 2)
316
317 (define_function_unit "fpu" 1 0
318   (and (eq_attr "type" "dmul")
319        (eq_attr "cpu" "ppc604,ppc620"))
320   3 1)
321
322 (define_function_unit "fpu" 1 0
323   (and (eq_attr "type" "sdiv,ddiv")
324        (eq_attr "cpu" "rios1"))
325   19 19)
326
327 (define_function_unit "fpu" 1 0
328   (and (eq_attr "type" "sdiv")
329        (eq_attr "cpu" "ppc601"))
330   17 17)
331
332 (define_function_unit "fpu" 1 0
333   (and (eq_attr "type" "sdiv")
334        (eq_attr "cpu" "mpccore"))
335   10 10)
336
337 (define_function_unit "fpu" 1 0
338   (and (eq_attr "type" "sdiv")
339        (eq_attr "cpu" "ppc603,ppc604,ppc620"))
340   18 18)
341
342 (define_function_unit "fpu" 1 0
343   (and (eq_attr "type" "ddiv")
344        (eq_attr "cpu" "mpccore"))
345   17 17)
346
347 (define_function_unit "fpu" 1 0
348   (and (eq_attr "type" "ddiv")
349        (eq_attr "cpu" "ppc601,ppc604,ppc620"))
350   31 31)
351
352 (define_function_unit "fpu" 1 0
353   (and (eq_attr "type" "ddiv")
354        (eq_attr "cpu" "ppc603"))
355   33 33)
356
357 (define_function_unit "fpu" 1 0
358   (and (eq_attr "type" "ssqrt")
359        (eq_attr "cpu" "ppc620"))
360   31 31)
361
362 (define_function_unit "fpu" 1 0
363   (and (eq_attr "type" "dsqrt")
364        (eq_attr "cpu" "ppc620"))
365   31 31)
366
367 ; RIOS2 has two symmetric FPUs.
368 (define_function_unit "fpu2" 2 0
369   (and (eq_attr "type" "fp")
370        (eq_attr "cpu" "rios2"))
371   2 1)
372
373 (define_function_unit "fpu2" 2 0
374   (and (eq_attr "type" "dmul")
375        (eq_attr "cpu" "rios2"))
376   2 1)
377
378 (define_function_unit "fpu2" 2 0
379   (and (eq_attr "type" "sdiv,ddiv")
380        (eq_attr "cpu" "rios2"))
381   17 17)
382
383 (define_function_unit "fpu2" 2 0
384   (and (eq_attr "type" "ssqrt,dsqrt")
385        (eq_attr "cpu" "rios2"))
386   26 26)
387
388 \f
389 ;; Start with fixed-point load and store insns.  Here we put only the more
390 ;; complex forms.  Basic data transfer is done later.
391
392 (define_expand "zero_extendqidi2"
393   [(set (match_operand:DI 0 "gpc_reg_operand" "")
394         (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "")))]
395   "TARGET_POWERPC64"
396   "")
397
398 (define_insn ""
399   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
400         (zero_extend:DI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
401   "TARGET_POWERPC64"
402   "@
403    lbz%U1%X1 %0,%1
404    rldicl %0,%1,0,56"
405   [(set_attr "type" "load,*")])
406
407 (define_insn ""
408   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
409         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
410                     (const_int 0)))
411    (clobber (match_scratch:DI 2 "=r"))]
412   "TARGET_POWERPC64"
413   "rldicl. %2,%1,0,56"
414   [(set_attr "type" "compare")])
415
416 (define_insn ""
417   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
418         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
419                     (const_int 0)))
420    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
421         (zero_extend:DI (match_dup 1)))]
422   "TARGET_POWERPC64"
423   "rldicl. %0,%1,0,56"
424   [(set_attr "type" "compare")])
425
426 (define_insn "extendqidi2"
427   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
428         (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
429   "TARGET_POWERPC64"
430   "extsb %0,%1")
431
432 (define_insn ""
433   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
434         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
435                     (const_int 0)))
436    (clobber (match_scratch:DI 2 "=r"))]
437   "TARGET_POWERPC64"
438   "extsb. %2,%1"
439   [(set_attr "type" "compare")])
440
441 (define_insn ""
442   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
443         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r"))
444                     (const_int 0)))
445    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
446         (sign_extend:DI (match_dup 1)))]
447   "TARGET_POWERPC64"
448   "extsb. %0,%1"
449   [(set_attr "type" "compare")])
450
451 (define_expand "zero_extendhidi2"
452   [(set (match_operand:DI 0 "gpc_reg_operand" "")
453         (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
454   "TARGET_POWERPC64"
455   "")
456
457 (define_insn ""
458   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
459         (zero_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
460   "TARGET_POWERPC64"
461   "@
462    lhz%U1%X1 %0,%1
463    rldicl %0,%1,0,48"
464   [(set_attr "type" "load,*")])
465
466 (define_insn ""
467   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
468         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
469                     (const_int 0)))
470    (clobber (match_scratch:DI 2 "=r"))]
471   "TARGET_POWERPC64"
472   "rldicl. %2,%1,0,48"
473   [(set_attr "type" "compare")])
474
475 (define_insn ""
476   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
477         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
478                     (const_int 0)))
479    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
480         (zero_extend:DI (match_dup 1)))]
481   "TARGET_POWERPC64"
482   "rldicl. %0,%1,0,48"
483   [(set_attr "type" "compare")])
484
485 (define_expand "extendhidi2"
486   [(set (match_operand:DI 0 "gpc_reg_operand" "")
487         (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
488   "TARGET_POWERPC64"
489   "")
490
491 (define_insn ""
492   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
493         (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
494   "TARGET_POWERPC64"
495   "@
496    lha%U1%X1 %0,%1
497    extsh %0,%1"
498   [(set_attr "type" "load,*")])
499
500 (define_insn ""
501   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
502         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
503                     (const_int 0)))
504    (clobber (match_scratch:DI 2 "=r"))]
505   "TARGET_POWERPC64"
506   "extsh. %2,%1"
507   [(set_attr "type" "compare")])
508
509 (define_insn ""
510   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
511         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r"))
512                     (const_int 0)))
513    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
514         (sign_extend:DI (match_dup 1)))]
515   "TARGET_POWERPC64"
516   "extsh. %0,%1"
517   [(set_attr "type" "compare")])
518
519 (define_expand "zero_extendsidi2"
520   [(set (match_operand:DI 0 "gpc_reg_operand" "")
521         (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
522   "TARGET_POWERPC64"
523   "")
524
525 (define_insn ""
526   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
527         (zero_extend:DI (match_operand:SI 1 "reg_or_mem_operand" "m,r")))]
528   "TARGET_POWERPC64"
529   "@
530    lwz%U1%X1 %0,%1
531    rldicl %0,%1,0,32"
532   [(set_attr "type" "load,*")])
533
534 (define_insn ""
535   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
536         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
537                     (const_int 0)))
538    (clobber (match_scratch:DI 2 "=r"))]
539   "TARGET_POWERPC64"
540   "rldicl. %2,%1,0,32"
541   [(set_attr "type" "compare")])
542
543 (define_insn ""
544   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
545         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
546                     (const_int 0)))
547    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
548         (zero_extend:DI (match_dup 1)))]
549   "TARGET_POWERPC64"
550   "rldicl. %0,%1,0,32"
551   [(set_attr "type" "compare")])
552
553 (define_expand "extendsidi2"
554   [(set (match_operand:DI 0 "gpc_reg_operand" "")
555         (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
556   "TARGET_POWERPC64"
557   "")
558
559 (define_insn ""
560   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
561         (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
562   "TARGET_POWERPC64"
563   "@
564    lwa%U1%X1 %0,%1
565    extsw %0,%1"
566   [(set_attr "type" "load,*")])
567
568 (define_insn ""
569   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
570         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
571                     (const_int 0)))
572    (clobber (match_scratch:DI 2 "=r"))]
573   "TARGET_POWERPC64"
574   "extsw. %2,%1"
575   [(set_attr "type" "compare")])
576
577 (define_insn ""
578   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
579         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
580                     (const_int 0)))
581    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
582         (sign_extend:DI (match_dup 1)))]
583   "TARGET_POWERPC64"
584   "extsw. %0,%1"
585   [(set_attr "type" "compare")])
586
587 (define_expand "zero_extendqisi2"
588   [(set (match_operand:SI 0 "gpc_reg_operand" "")
589         (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
590   ""
591   "")
592
593 (define_insn ""
594   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
595         (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
596   ""
597   "@
598    lbz%U1%X1 %0,%1
599    {rlinm|rlwinm} %0,%1,0,0xff"
600   [(set_attr "type" "load,*")])
601
602 (define_insn ""
603   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
604         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
605                     (const_int 0)))
606    (clobber (match_scratch:SI 2 "=r"))]
607   ""
608   "{andil.|andi.} %2,%1,0xff"
609   [(set_attr "type" "compare")])
610
611 (define_insn ""
612   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
613         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
614                     (const_int 0)))
615    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
616         (zero_extend:SI (match_dup 1)))]
617   ""
618   "{andil.|andi.} %0,%1,0xff"
619   [(set_attr "type" "compare")])
620
621 (define_expand "extendqisi2"
622   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
623    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
624   ""
625   "
626 {
627   if (TARGET_POWERPC)
628     emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
629   else if (TARGET_POWER)
630     emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
631   else
632     emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
633   DONE;
634 }")
635
636 (define_insn "extendqisi2_ppc"
637   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
638         (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
639   "TARGET_POWERPC"
640   "extsb %0,%1")
641
642 (define_insn ""
643   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
644         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
645                     (const_int 0)))
646    (clobber (match_scratch:SI 2 "=r"))]
647   "TARGET_POWERPC"
648   "extsb. %2,%1"
649   [(set_attr "type" "compare")])
650
651 (define_insn ""
652   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
653         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r"))
654                     (const_int 0)))
655    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
656         (sign_extend:SI (match_dup 1)))]
657   "TARGET_POWERPC"
658   "extsb. %0,%1"
659   [(set_attr "type" "compare")])
660
661 (define_expand "extendqisi2_power"
662   [(parallel [(set (match_dup 2)
663                    (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
664                               (const_int 24)))
665               (clobber (scratch:SI))])
666    (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
667                    (ashiftrt:SI (match_dup 2)
668                                 (const_int 24)))
669               (clobber (scratch:SI))])]
670   "TARGET_POWER"
671   "
672 { operands[1] = gen_lowpart (SImode, operands[1]);
673   operands[2] = gen_reg_rtx (SImode); }")
674
675 (define_expand "extendqisi2_no_power"
676   [(set (match_dup 2)
677         (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
678                    (const_int 24)))
679    (set (match_operand:SI 0 "gpc_reg_operand" "")
680         (ashiftrt:SI (match_dup 2)
681                      (const_int 24)))]
682   "! TARGET_POWER && ! TARGET_POWERPC"
683   "
684 { operands[1] = gen_lowpart (SImode, operands[1]);
685   operands[2] = gen_reg_rtx (SImode); }")
686
687 (define_expand "zero_extendqihi2"
688   [(set (match_operand:HI 0 "gpc_reg_operand" "")
689         (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
690   ""
691   "")
692
693 (define_insn ""
694   [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
695         (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
696   ""
697   "@
698    lbz%U1%X1 %0,%1
699    {rlinm|rlwinm} %0,%1,0,0xff"
700   [(set_attr "type" "load,*")])
701
702 (define_insn ""
703   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
704         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
705                     (const_int 0)))
706    (clobber (match_scratch:HI 2 "=r"))]
707   ""
708   "{andil.|andi.} %2,%1,0xff"
709   [(set_attr "type" "compare")])
710
711 (define_insn ""
712   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
713         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
714                     (const_int 0)))
715    (set (match_operand:HI 0 "gpc_reg_operand" "=r")
716         (zero_extend:HI (match_dup 1)))]
717   ""
718   "{andil.|andi.} %0,%1,0xff"
719   [(set_attr "type" "compare")])
720
721 (define_expand "extendqihi2"
722   [(use (match_operand:HI 0 "gpc_reg_operand" ""))
723    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
724   ""
725   "
726 {
727   if (TARGET_POWERPC)
728     emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
729   else if (TARGET_POWER)
730     emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
731   else
732     emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
733   DONE;
734 }")
735
736 (define_insn "extendqihi2_ppc"
737   [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
738         (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
739   "TARGET_POWERPC"
740   "extsb %0,%1")
741
742 (define_insn ""
743   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
744         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
745                     (const_int 0)))
746    (clobber (match_scratch:HI 2 "=r"))]
747   "TARGET_POWERPC"
748   "extsb. %2,%1"
749   [(set_attr "type" "compare")])
750
751 (define_insn ""
752   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
753         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r"))
754                     (const_int 0)))
755    (set (match_operand:HI 0 "gpc_reg_operand" "=r")
756         (sign_extend:HI (match_dup 1)))]
757   "TARGET_POWERPC"
758   "extsb. %0,%1"
759   [(set_attr "type" "compare")])
760
761 (define_expand "extendqihi2_power"
762   [(parallel [(set (match_dup 2)
763                    (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
764                               (const_int 24)))
765               (clobber (scratch:SI))])
766    (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
767                    (ashiftrt:SI (match_dup 2)
768                                 (const_int 24)))
769               (clobber (scratch:SI))])]
770   "TARGET_POWER"
771   "
772 { operands[0] = gen_lowpart (SImode, operands[0]);
773   operands[1] = gen_lowpart (SImode, operands[1]);
774   operands[2] = gen_reg_rtx (SImode); }")
775
776 (define_expand "extendqihi2_no_power"
777   [(set (match_dup 2)
778         (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
779                    (const_int 24)))
780    (set (match_operand:HI 0 "gpc_reg_operand" "")
781         (ashiftrt:SI (match_dup 2)
782                      (const_int 24)))]
783   "! TARGET_POWER && ! TARGET_POWERPC"
784   "
785 { operands[0] = gen_lowpart (SImode, operands[0]);
786   operands[1] = gen_lowpart (SImode, operands[1]);
787   operands[2] = gen_reg_rtx (SImode); }")
788
789 (define_expand "zero_extendhisi2"
790   [(set (match_operand:SI 0 "gpc_reg_operand" "")
791         (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
792   ""
793   "")
794
795 (define_insn ""
796   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
797         (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
798   ""
799   "@
800    lhz%U1%X1 %0,%1
801    {rlinm|rlwinm} %0,%1,0,0xffff"
802   [(set_attr "type" "load,*")])
803
804 (define_insn ""
805   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
806         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
807                     (const_int 0)))
808    (clobber (match_scratch:SI 2 "=r"))]
809   ""
810   "{andil.|andi.} %2,%1,0xffff"
811   [(set_attr "type" "compare")])
812
813 (define_insn ""
814   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
815         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
816                     (const_int 0)))
817    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
818         (zero_extend:SI (match_dup 1)))]
819   ""
820   "{andil.|andi.} %0,%1,0xffff"
821   [(set_attr "type" "compare")])
822
823 (define_expand "extendhisi2"
824   [(set (match_operand:SI 0 "gpc_reg_operand" "")
825         (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
826   ""
827   "")
828
829 (define_insn ""
830   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
831         (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
832   ""
833   "@
834    lha%U1%X1 %0,%1
835    {exts|extsh} %0,%1"
836   [(set_attr "type" "load,*")])
837
838 (define_insn ""
839   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
840         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
841                     (const_int 0)))
842    (clobber (match_scratch:SI 2 "=r"))]
843   ""
844   "{exts.|extsh.} %2,%1"
845   [(set_attr "type" "compare")])
846
847 (define_insn ""
848   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
849         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r"))
850                     (const_int 0)))
851    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
852         (sign_extend:SI (match_dup 1)))]
853   ""
854   "{exts.|extsh.} %0,%1"
855   [(set_attr "type" "compare")])
856 \f
857 ;; Fixed-point arithmetic insns.
858
859 ;; Discourage ai/addic because of carry but provide it in an alternative
860 ;; allowing register zero as source.
861 (define_insn "addsi3"
862   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,?r,r")
863         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,b,r,b")
864                  (match_operand:SI 2 "add_operand" "r,I,I,J")))]
865   ""
866   "@
867    {cax|add} %0,%1,%2
868    {cal %0,%2(%1)|addi %0,%1,%2}
869    {ai|addic} %0,%1,%2
870    {cau|addis} %0,%1,%v2")
871
872 (define_insn ""
873   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
874         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
875                              (match_operand:SI 2 "reg_or_short_operand" "r,I"))
876                     (const_int 0)))
877    (clobber (match_scratch:SI 3 "=r,r"))]
878   ""
879   "@
880    {cax.|add.} %3,%1,%2
881    {ai.|addic.} %3,%1,%2"
882   [(set_attr "type" "compare")])
883
884 (define_insn ""
885   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
886         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
887                              (match_operand:SI 2 "reg_or_short_operand" "r,I"))
888                     (const_int 0)))
889    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
890         (plus:SI (match_dup 1) (match_dup 2)))]
891   ""
892   "@
893    {cax.|add.} %0,%1,%2
894    {ai.|addic.} %0,%1,%2"
895   [(set_attr "type" "compare")])
896
897 ;; Split an add that we can't do in one insn into two insns, each of which
898 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
899 ;; add should be last in case the result gets used in an address.
900
901 (define_split
902   [(set (match_operand:SI 0 "gpc_reg_operand" "")
903         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
904                  (match_operand:SI 2 "non_add_cint_operand" "")))]
905   ""
906   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
907    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
908 "
909 {
910   HOST_WIDE_INT low = INTVAL (operands[2]) & 0xffff;
911   HOST_WIDE_INT high = INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff);
912
913   if (low & 0x8000)
914     high += 0x10000, low |= ((HOST_WIDE_INT) -1) << 16;
915
916   operands[3] = GEN_INT (high);
917   operands[4] = GEN_INT (low);
918 }")
919
920 (define_insn "one_cmplsi2"
921   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
922         (not:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
923   ""
924   "nor %0,%1,%1")
925
926 (define_insn ""
927   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
928         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
929                     (const_int 0)))
930    (clobber (match_scratch:SI 2 "=r"))]
931   ""
932   "nor. %2,%1,%1"
933   [(set_attr "type" "compare")])
934
935 (define_insn ""
936   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
937         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
938                     (const_int 0)))
939    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
940         (not:SI (match_dup 1)))]
941   ""
942   "nor. %0,%1,%1"
943   [(set_attr "type" "compare")])
944
945 (define_insn ""
946   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
947         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
948                   (match_operand:SI 2 "gpc_reg_operand" "r")))]
949   "! TARGET_POWERPC"
950   "{sf%I1|subf%I1c} %0,%2,%1")
951
952 (define_insn ""
953   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
954         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "r,I")
955                   (match_operand:SI 2 "gpc_reg_operand" "r,r")))]
956   "TARGET_POWERPC"
957   "@
958    subf %0,%2,%1
959    subfic %0,%2,%1")
960
961 (define_insn ""
962   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
963         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
964                               (match_operand:SI 2 "gpc_reg_operand" "r"))
965                     (const_int 0)))
966    (clobber (match_scratch:SI 3 "=r"))]
967   "! TARGET_POWERPC"
968   "{sf.|subfc.} %3,%2,%1"
969   [(set_attr "type" "compare")])
970
971 (define_insn ""
972   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
973         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
974                               (match_operand:SI 2 "gpc_reg_operand" "r"))
975                     (const_int 0)))
976    (clobber (match_scratch:SI 3 "=r"))]
977   "TARGET_POWERPC"
978   "subf. %3,%2,%1"
979   [(set_attr "type" "compare")])
980
981 (define_insn ""
982   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
983         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
984                               (match_operand:SI 2 "gpc_reg_operand" "r"))
985                     (const_int 0)))
986    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
987         (minus:SI (match_dup 1) (match_dup 2)))]
988   "! TARGET_POWERPC"
989   "{sf.|subfc.} %0,%2,%1"
990   [(set_attr "type" "compare")])
991
992 (define_insn ""
993   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
994         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
995                               (match_operand:SI 2 "gpc_reg_operand" "r"))
996                     (const_int 0)))
997    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
998         (minus:SI (match_dup 1) (match_dup 2)))]
999   "TARGET_POWERPC"
1000   "subf. %0,%2,%1"
1001   [(set_attr "type" "compare")])
1002
1003 (define_expand "subsi3"
1004   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1005         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "")
1006                   (match_operand:SI 2 "reg_or_cint_operand" "")))]
1007   ""
1008   "
1009 {
1010   if (GET_CODE (operands[2]) == CONST_INT)
1011     {
1012       emit_insn (gen_addsi3 (operands[0], operands[1],
1013                              negate_rtx (SImode, operands[2])));
1014       DONE;
1015     }
1016 }")
1017
1018 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1019 ;; instruction and some auxiliary computations.  Then we just have a single
1020 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1021 ;; combine.
1022
1023 (define_expand "sminsi3"
1024   [(set (match_dup 3)
1025         (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1026                                 (match_operand:SI 2 "reg_or_short_operand" ""))
1027                          (const_int 0)
1028                          (minus:SI (match_dup 2) (match_dup 1))))
1029    (set (match_operand:SI 0 "gpc_reg_operand" "")
1030         (minus:SI (match_dup 2) (match_dup 3)))]
1031   "TARGET_POWER"
1032   "
1033 { operands[3] = gen_reg_rtx (SImode); }")
1034
1035 (define_split
1036   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1037         (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1038                  (match_operand:SI 2 "reg_or_short_operand" "")))
1039    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1040   "TARGET_POWER"
1041   [(set (match_dup 3)
1042         (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1043                          (const_int 0)
1044                          (minus:SI (match_dup 2) (match_dup 1))))
1045    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1046   "")
1047
1048 (define_expand "smaxsi3"
1049   [(set (match_dup 3)
1050         (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1051                                 (match_operand:SI 2 "reg_or_short_operand" ""))
1052                          (const_int 0)
1053                          (minus:SI (match_dup 2) (match_dup 1))))
1054    (set (match_operand:SI 0 "gpc_reg_operand" "")
1055         (plus:SI (match_dup 3) (match_dup 1)))]
1056   "TARGET_POWER"
1057   "
1058 { operands[3] = gen_reg_rtx (SImode); }")
1059
1060 (define_split
1061   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1062         (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1063                  (match_operand:SI 2 "reg_or_short_operand" "")))
1064    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1065   "TARGET_POWER"
1066   [(set (match_dup 3)
1067         (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1068                          (const_int 0)
1069                          (minus:SI (match_dup 2) (match_dup 1))))
1070    (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1071   "")
1072
1073 (define_expand "uminsi3"
1074   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1075                               (match_dup 5)))
1076    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1077                               (match_dup 5)))
1078    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1079                                        (const_int 0)
1080                                        (minus:SI (match_dup 4) (match_dup 3))))
1081    (set (match_operand:SI 0 "gpc_reg_operand" "")
1082         (minus:SI (match_dup 2) (match_dup 3)))]
1083   "TARGET_POWER"
1084   "
1085 {
1086   operands[3] = gen_reg_rtx (SImode);
1087   operands[4] = gen_reg_rtx (SImode);
1088   operands[5] = GEN_INT (-2147483647 - 1);
1089 }")
1090
1091 (define_expand "umaxsi3"
1092   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1093                               (match_dup 5)))
1094    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1095                               (match_dup 5)))
1096    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1097                                        (const_int 0)
1098                                        (minus:SI (match_dup 4) (match_dup 3))))
1099    (set (match_operand:SI 0 "gpc_reg_operand" "")
1100         (plus:SI (match_dup 3) (match_dup 1)))]
1101   "TARGET_POWER"
1102   "
1103 {
1104   operands[3] = gen_reg_rtx (SImode);
1105   operands[4] = gen_reg_rtx (SImode);
1106   operands[5] = GEN_INT (-2147483647 - 1);
1107 }")
1108
1109 (define_insn ""
1110   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1111         (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1112                              (match_operand:SI 2 "reg_or_short_operand" "rI"))
1113                          (const_int 0)
1114                          (minus:SI (match_dup 2) (match_dup 1))))]
1115   "TARGET_POWER"
1116   "doz%I2 %0,%1,%2")
1117
1118 (define_insn ""
1119   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1120         (compare:CC
1121          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1122                               (match_operand:SI 2 "reg_or_short_operand" "rI"))
1123                           (const_int 0)
1124                           (minus:SI (match_dup 2) (match_dup 1)))
1125          (const_int 0)))
1126    (clobber (match_scratch:SI 3 "=r"))]
1127   "TARGET_POWER"
1128   "doz%I2. %3,%1,%2"
1129   [(set_attr "type" "delayed_compare")])
1130
1131 (define_insn ""
1132   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1133         (compare:CC
1134          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1135                               (match_operand:SI 2 "reg_or_short_operand" "rI"))
1136                           (const_int 0)
1137                           (minus:SI (match_dup 2) (match_dup 1)))
1138          (const_int 0)))
1139    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1140         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1141                          (const_int 0)
1142                          (minus:SI (match_dup 2) (match_dup 1))))]
1143   "TARGET_POWER"
1144   "doz%I2. %0,%1,%2"
1145   [(set_attr "type" "delayed_compare")])
1146
1147 ;; We don't need abs with condition code because such comparisons should
1148 ;; never be done.
1149 (define_expand "abssi2"
1150   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1151         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1152   ""
1153   "
1154 {
1155   if (!TARGET_POWER)
1156     {
1157       emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
1158       DONE;
1159     }
1160 }")
1161
1162 (define_insn "abssi2_power"
1163   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1164         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1165   "TARGET_POWER"
1166   "abs %0,%1")
1167
1168 (define_insn "abssi2_nopower"
1169   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1170         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
1171    (clobber (match_scratch:SI 2 "=&r,&r"))]
1172   "!TARGET_POWER"
1173   "*
1174 {
1175   return (TARGET_POWERPC)
1176     ? \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;subf %0,%2,%0\"
1177     : \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;{sf|subfc} %0,%2,%0\";
1178 }"
1179   [(set_attr "length" "12")])
1180
1181 (define_split
1182   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1183         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
1184    (clobber (match_scratch:SI 2 "=&r,&r"))]
1185   "!TARGET_POWER && reload_completed"
1186   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1187    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1188    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
1189   "")
1190
1191 (define_insn ""
1192   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1193         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
1194   "TARGET_POWER"
1195   "nabs %0,%1")
1196
1197 (define_insn ""
1198   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1199         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
1200    (clobber (match_scratch:SI 2 "=&r,&r"))]
1201   "!TARGET_POWER"
1202   "*
1203 {
1204   return (TARGET_POWERPC)
1205     ? \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;subf %0,%0,%2\"
1206     : \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;{sf|subfc} %0,%0,%2\";
1207 }"
1208   [(set_attr "length" "12")])
1209
1210 (define_split
1211   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1212         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
1213    (clobber (match_scratch:SI 2 "=&r,&r"))]
1214   "!TARGET_POWER && reload_completed"
1215   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1216    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1217    (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
1218   "")
1219
1220 (define_insn "negsi2"
1221   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1222         (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1223   ""
1224   "neg %0,%1")
1225
1226 (define_insn ""
1227   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1228         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1229                     (const_int 0)))
1230    (clobber (match_scratch:SI 2 "=r"))]
1231   ""
1232   "neg. %2,%1"
1233   [(set_attr "type" "compare")])
1234
1235 (define_insn ""
1236   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
1237         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1238                     (const_int 0)))
1239    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1240         (neg:SI (match_dup 1)))]
1241   ""
1242   "neg. %0,%1"
1243   [(set_attr "type" "compare")])
1244
1245 (define_insn "ffssi2"
1246   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
1247         (ffs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1248   ""
1249   "neg %0,%1\;and %0,%0,%1\;{cntlz|cntlzw} %0,%0\;{sfi|subfic} %0,%0,32"
1250   [(set_attr "length" "16")])
1251
1252 (define_expand "mulsi3"
1253   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1254    (use (match_operand:SI 1 "gpc_reg_operand" ""))
1255    (use (match_operand:SI 2 "reg_or_short_operand" ""))]
1256   ""
1257   "
1258 {
1259   if (TARGET_POWER)
1260     emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
1261   else
1262     emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
1263   DONE;
1264 }")
1265
1266 (define_insn "mulsi3_mq"
1267   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1268         (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1269                  (match_operand:SI 2 "reg_or_short_operand" "r,I")))
1270    (clobber (match_scratch:SI 3 "=q,q"))]
1271   "TARGET_POWER"
1272   "@
1273    {muls|mullw} %0,%1,%2
1274    {muli|mulli} %0,%1,%2"
1275    [(set_attr "type" "imul")])
1276
1277 (define_insn "mulsi3_no_mq"
1278   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1279         (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1280                  (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
1281   "! TARGET_POWER"
1282   "@
1283    {muls|mullw} %0,%1,%2
1284    {muli|mulli} %0,%1,%2"
1285    [(set_attr "type" "imul")])
1286
1287 (define_insn ""
1288   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1289         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1290                              (match_operand:SI 2 "gpc_reg_operand" "r"))
1291                     (const_int 0)))
1292    (clobber (match_scratch:SI 3 "=r"))
1293    (clobber (match_scratch:SI 4 "=q"))]
1294   "TARGET_POWER"
1295   "{muls.|mullw.} %3,%1,%2"
1296   [(set_attr "type" "delayed_compare")])
1297
1298 (define_insn ""
1299   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1300         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1301                              (match_operand:SI 2 "gpc_reg_operand" "r"))
1302                     (const_int 0)))
1303    (clobber (match_scratch:SI 3 "=r"))]
1304   "! TARGET_POWER"
1305   "{muls.|mullw.} %3,%1,%2"
1306   [(set_attr "type" "delayed_compare")])
1307
1308 (define_insn ""
1309   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1310         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1311                              (match_operand:SI 2 "gpc_reg_operand" "r"))
1312                     (const_int 0)))
1313    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1314         (mult:SI (match_dup 1) (match_dup 2)))
1315    (clobber (match_scratch:SI 4 "=q"))]
1316   "TARGET_POWER"
1317   "{muls.|mullw.} %0,%1,%2"
1318   [(set_attr "type" "delayed_compare")])
1319
1320 (define_insn ""
1321   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1322         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1323                              (match_operand:SI 2 "gpc_reg_operand" "r"))
1324                     (const_int 0)))
1325    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1326         (mult:SI (match_dup 1) (match_dup 2)))]
1327   "! TARGET_POWER"
1328   "{muls.|mullw.} %0,%1,%2"
1329   [(set_attr "type" "delayed_compare")])
1330
1331 ;; Operand 1 is divided by operand 2; quotient goes to operand
1332 ;; 0 and remainder to operand 3.
1333 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
1334
1335 (define_expand "divmodsi4"
1336   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1337                    (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1338                            (match_operand:SI 2 "gpc_reg_operand" "")))
1339               (set (match_operand:SI 3 "gpc_reg_operand" "")
1340                    (mod:SI (match_dup 1) (match_dup 2)))])]
1341   "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
1342   "
1343 {
1344   if (! TARGET_POWER && ! TARGET_POWERPC)
1345     {
1346       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
1347       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
1348       emit_insn (gen_divss_call ());
1349       emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
1350       emit_move_insn (operands[3], gen_rtx (REG, SImode, 4));
1351       DONE;
1352     }
1353 }")
1354
1355 (define_insn ""
1356   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1357         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1358                 (match_operand:SI 2 "gpc_reg_operand" "r")))
1359    (set (match_operand:SI 3 "gpc_reg_operand" "=q")
1360         (mod:SI (match_dup 1) (match_dup 2)))]
1361   "TARGET_POWER"
1362   "divs %0,%1,%2"
1363   [(set_attr "type" "idiv")])
1364
1365 (define_insn ""
1366   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1367         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1368                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1369   "TARGET_POWERPC"
1370   "divw %0,%1,%2"
1371   [(set_attr "type" "idiv")])
1372
1373 (define_expand "udivsi3"
1374   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1375         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1376                  (match_operand:SI 2 "gpc_reg_operand" "")))]
1377   "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
1378   "
1379 {
1380   if (! TARGET_POWER && ! TARGET_POWERPC)
1381     {
1382       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
1383       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
1384       emit_insn (gen_quous_call ());
1385       emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
1386       DONE;
1387     }
1388 }")
1389
1390 (define_insn ""
1391   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1392         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1393                  (match_operand:SI 2 "gpc_reg_operand" "r")))]
1394   "TARGET_POWERPC"
1395   "divwu %0,%1,%2"
1396   [(set_attr "type" "idiv")])
1397
1398 ;; For powers of two we can do srai/aze for divide and then adjust for
1399 ;; modulus.  If it isn't a power of two, FAIL on POWER so divmodsi4 will be
1400 ;; used; for PowerPC, force operands into register and do a normal divide;
1401 ;; for AIX common-mode, use quoss call on register operands.
1402 (define_expand "divsi3"
1403   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1404         (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1405                 (match_operand:SI 2 "reg_or_cint_operand" "")))]
1406   ""
1407   "
1408 {
1409   if (GET_CODE (operands[2]) == CONST_INT
1410       && exact_log2 (INTVAL (operands[2])) >= 0)
1411     ;
1412   else if (TARGET_POWERPC)
1413     operands[2] = force_reg (SImode, operands[2]);
1414   else if (TARGET_POWER)
1415     FAIL;
1416   else
1417     {
1418       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
1419       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
1420       emit_insn (gen_quoss_call ());
1421       emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
1422       DONE;
1423     }
1424 }")
1425
1426 (define_expand "modsi3"
1427   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1428    (use (match_operand:SI 1 "gpc_reg_operand" ""))
1429    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
1430   ""
1431   "
1432 {
1433   int i = exact_log2 (INTVAL (operands[2]));
1434   rtx temp1;
1435   rtx temp2;
1436
1437   if (GET_CODE (operands[2]) != CONST_INT || i < 0)
1438     FAIL;
1439
1440   temp1 = gen_reg_rtx (SImode);
1441   temp2 = gen_reg_rtx (SImode);
1442
1443   emit_insn (gen_divsi3 (temp1, operands[1], operands[2]));
1444   emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i)));
1445   emit_insn (gen_subsi3 (operands[0], operands[1], temp2));
1446   DONE;
1447 }")
1448
1449 (define_insn ""
1450   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1451         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1452                 (match_operand:SI 2 "const_int_operand" "N")))]
1453   "exact_log2 (INTVAL (operands[2])) >= 0"
1454   "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
1455   [(set_attr "length" "8")])
1456
1457 (define_insn ""
1458   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1459         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1460                             (match_operand:SI 2 "const_int_operand" "N"))
1461                     (const_int 0)))
1462    (clobber (match_scratch:SI 3 "=r"))]
1463   "exact_log2 (INTVAL (operands[2])) >= 0"
1464   "{srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3"
1465   [(set_attr "type" "compare")
1466    (set_attr "length" "8")])
1467
1468 (define_insn ""
1469   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1470         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1471                             (match_operand:SI 2 "const_int_operand" "N"))
1472                     (const_int 0)))
1473    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1474         (div:SI (match_dup 1) (match_dup 2)))]
1475   "exact_log2 (INTVAL (operands[2])) >= 0"
1476   "{srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0"
1477   [(set_attr "type" "compare")
1478    (set_attr "length" "8")])
1479
1480 (define_insn ""
1481   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1482         (udiv:SI
1483          (plus:DI (ashift:DI
1484                    (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
1485                    (const_int 32))
1486                   (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
1487          (match_operand:SI 3 "gpc_reg_operand" "r")))
1488    (set (match_operand:SI 2 "register_operand" "=*q")
1489         (umod:SI
1490          (plus:DI (ashift:DI
1491                    (zero_extend:DI (match_dup 1)) (const_int 32))
1492                   (zero_extend:DI (match_dup 4)))
1493          (match_dup 3)))]
1494   "TARGET_POWER"
1495   "div %0,%1,%3"
1496   [(set_attr "type" "idiv")])
1497
1498 ;; To do unsigned divide we handle the cases of the divisor looking like a
1499 ;; negative number.  If it is a constant that is less than 2**31, we don't
1500 ;; have to worry about the branches.  So make a few subroutines here.
1501 ;;
1502 ;; First comes the normal case.
1503 (define_expand "udivmodsi4_normal"
1504   [(set (match_dup 4) (const_int 0))
1505    (parallel [(set (match_operand:SI 0 "" "")
1506                    (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
1507                                                 (const_int 32))
1508                                      (zero_extend:DI (match_operand:SI 1 "" "")))
1509                             (match_operand:SI 2 "" "")))
1510               (set (match_operand:SI 3 "" "")
1511                    (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
1512                                                 (const_int 32))
1513                                      (zero_extend:DI (match_dup 1)))
1514                             (match_dup 2)))])]
1515   "TARGET_POWER"
1516   "
1517 { operands[4] = gen_reg_rtx (SImode); }")
1518
1519 ;; This handles the branches.
1520 (define_expand "udivmodsi4_tests"
1521   [(set (match_operand:SI 0 "" "") (const_int 0))
1522    (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
1523    (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
1524    (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
1525                            (label_ref (match_operand:SI 4 "" "")) (pc)))
1526    (set (match_dup 0) (const_int 1))
1527    (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
1528    (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
1529    (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
1530                            (label_ref (match_dup 4)) (pc)))]
1531   "TARGET_POWER"
1532   "
1533 { operands[5] = gen_reg_rtx (CCUNSmode);
1534   operands[6] = gen_reg_rtx (CCmode);
1535 }")
1536
1537 (define_expand "udivmodsi4"
1538   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1539                    (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1540                             (match_operand:SI 2 "reg_or_cint_operand" "")))
1541               (set (match_operand:SI 3 "gpc_reg_operand" "")
1542                    (umod:SI (match_dup 1) (match_dup 2)))])]
1543   ""
1544   "
1545 {
1546   rtx label = 0;
1547
1548   if (! TARGET_POWER)
1549     if (! TARGET_POWERPC)
1550       {
1551         emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
1552         emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
1553         emit_insn (gen_divus_call ());
1554         emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
1555         emit_move_insn (operands[3], gen_rtx (REG, SImode, 4));
1556         DONE;
1557       }
1558     else
1559       FAIL;
1560
1561   if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
1562     {
1563       operands[2] = force_reg (SImode, operands[2]);
1564       label = gen_label_rtx ();
1565       emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
1566                                   operands[3], label));
1567     }
1568   else
1569     operands[2] = force_reg (SImode, operands[2]);
1570
1571   emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
1572                                operands[3]));
1573   if (label)
1574     emit_label (label);
1575
1576   DONE;
1577 }")
1578
1579 ;; AIX architecture-independent common-mode multiply (DImode),
1580 ;; divide/modulus, and quotient subroutine calls.  Input operands in R3 and
1581 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
1582 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
1583 ;; assumed unused if generating common-mode, so ignore.
1584 (define_insn "mulh_call"
1585   [(set (reg:SI 3)
1586         (truncate:SI
1587          (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
1588                                (sign_extend:DI (reg:SI 4)))
1589                       (const_int 32))))
1590    (clobber (match_scratch:SI 0 "=l"))]
1591   "! TARGET_POWER && ! TARGET_POWERPC"
1592   "bla __mulh"
1593   [(set_attr "type" "imul")])
1594
1595 (define_insn "mull_call"
1596   [(set (reg:DI 3)
1597         (mult:DI (sign_extend:DI (reg:SI 3))
1598                  (sign_extend:DI (reg:SI 4))))
1599    (clobber (match_scratch:SI 0 "=l"))
1600    (clobber (reg:SI 0))]
1601   "! TARGET_POWER && ! TARGET_POWERPC"
1602   "bla __mull"
1603   [(set_attr "type" "imul")])
1604
1605 (define_insn "divss_call"
1606   [(set (reg:SI 3)
1607         (div:SI (reg:SI 3) (reg:SI 4)))
1608    (set (reg:SI 4)
1609         (mod:SI (reg:SI 3) (reg:SI 4)))
1610    (clobber (match_scratch:SI 0 "=l"))
1611    (clobber (reg:SI 0))]
1612   "! TARGET_POWER && ! TARGET_POWERPC"
1613   "bla __divss"
1614   [(set_attr "type" "idiv")])
1615
1616 (define_insn "divus_call"
1617   [(set (reg:SI 3)
1618         (udiv:SI (reg:SI 3) (reg:SI 4)))
1619    (set (reg:SI 4)
1620         (umod:SI (reg:SI 3) (reg:SI 4)))
1621    (clobber (match_scratch:SI 0 "=l"))
1622    (clobber (reg:SI 0))
1623    (clobber (match_scratch:CC 1 "=x"))
1624    (clobber (reg:CC 69))]
1625   "! TARGET_POWER && ! TARGET_POWERPC"
1626   "bla __divus"
1627   [(set_attr "type" "idiv")])
1628
1629 (define_insn "quoss_call"
1630   [(set (reg:SI 3)
1631         (div:SI (reg:SI 3) (reg:SI 4)))
1632    (clobber (match_scratch:SI 0 "=l"))]
1633   "! TARGET_POWER && ! TARGET_POWERPC"
1634   "bla __quoss"
1635   [(set_attr "type" "idiv")])
1636
1637 (define_insn "quous_call"
1638   [(set (reg:SI 3)
1639         (udiv:SI (reg:SI 3) (reg:SI 4)))
1640    (clobber (match_scratch:SI 0 "=l"))
1641    (clobber (reg:SI 0))
1642    (clobber (match_scratch:CC 1 "=x"))
1643    (clobber (reg:CC 69))]
1644   "! TARGET_POWER && ! TARGET_POWERPC"
1645   "bla __quous"
1646   [(set_attr "type" "idiv")])
1647 \f
1648 (define_insn "andsi3"
1649   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1650         (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1651                 (match_operand:SI 2 "and_operand" "?r,L,K,J")))
1652    (clobber (match_scratch:CC 3 "=X,X,x,x"))]
1653   ""
1654   "@
1655    and %0,%1,%2
1656    {rlinm|rlwinm} %0,%1,0,%m2,%M2
1657    {andil.|andi.} %0,%1,%b2
1658    {andiu.|andis.} %0,%1,%u2")
1659
1660 (define_insn ""
1661   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x")
1662         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1663                             (match_operand:SI 2 "and_operand" "r,K,J,L"))
1664                     (const_int 0)))
1665    (clobber (match_scratch:SI 3 "=r,r,r,r"))]
1666   ""
1667   "@
1668    and. %3,%1,%2
1669    {andil.|andi.} %3,%1,%b2
1670    {andiu.|andis.} %3,%1,%u2
1671    {rlinm.|rlwinm.} %3,%1,0,%m2,%M2"
1672   [(set_attr "type" "compare,compare,compare,delayed_compare")])
1673
1674 (define_insn ""
1675   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x")
1676         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1677                             (match_operand:SI 2 "and_operand" "r,K,J,L"))
1678                     (const_int 0)))
1679    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1680         (and:SI (match_dup 1) (match_dup 2)))]
1681   ""
1682   "@
1683    and. %0,%1,%2
1684    {andil.|andi.} %0,%1,%b2
1685    {andiu.|andis.} %0,%1,%u2
1686    {rlinm.|rlwinm.} %0,%1,0,%m2,%M2"
1687   [(set_attr "type" "compare,compare,compare,delayed_compare")])
1688
1689 ;; Take a AND with a constant that cannot be done in a single insn and try to
1690 ;; split it into two insns.  This does not verify that the insns are valid
1691 ;; since this need not be done as combine will do it.
1692
1693 (define_split
1694   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1695         (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
1696                 (match_operand:SI 2 "non_and_cint_operand" "")))]
1697   ""
1698   [(set (match_dup 0) (and:SI (match_dup 1) (match_dup 3)))
1699    (set (match_dup 0) (and:SI (match_dup 0) (match_dup 4)))]
1700   "
1701 {
1702   int maskval = INTVAL (operands[2]);
1703   int i, transitions, last_bit_value;
1704   int orig = maskval, first_c = maskval, second_c;
1705
1706   /* We know that MASKVAL must have more than 2 bit-transitions.  Start at
1707      the low-order bit and count for the third transition.  When we get there,
1708      make a first mask that has everything to the left of that position
1709      a one.  Then make the second mask to turn off whatever else is needed.  */
1710
1711   for (i = 1, transitions = 0, last_bit_value = maskval & 1; i < 32; i++)
1712     {
1713       if (((maskval >>= 1) & 1) != last_bit_value)
1714         last_bit_value ^= 1, transitions++;
1715
1716       if (transitions > 2)
1717         {
1718           first_c |= (~0) << i;
1719           break;
1720         }
1721     }
1722
1723   second_c = orig | ~ first_c;
1724
1725   operands[3] = gen_rtx (CONST_INT, VOIDmode, first_c);
1726   operands[4] = gen_rtx (CONST_INT, VOIDmode, second_c);
1727 }")
1728
1729 (define_insn "iorsi3"
1730   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
1731         (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
1732                 (match_operand:SI 2 "logical_operand" "r,K,J")))]
1733   ""
1734   "@
1735    or %0,%1,%2
1736    {oril|ori} %0,%1,%b2
1737    {oriu|oris} %0,%1,%u2")
1738
1739 (define_insn ""
1740   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1741         (compare:CC (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1742                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1743                     (const_int 0)))
1744    (clobber (match_scratch:SI 3 "=r"))]
1745   ""
1746   "or. %3,%1,%2"
1747   [(set_attr "type" "compare")])
1748
1749 (define_insn ""
1750   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1751         (compare:CC (ior:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1752                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1753                     (const_int 0)))
1754    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1755         (ior:SI (match_dup 1) (match_dup 2)))]
1756   ""
1757   "or. %0,%1,%2"
1758   [(set_attr "type" "compare")])
1759
1760 ;; Split an IOR that we can't do in one insn into two insns, each of which
1761 ;; does one 16-bit part.  This is used by combine.
1762
1763 (define_split
1764   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1765         (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
1766                 (match_operand:SI 2 "non_logical_cint_operand" "")))]
1767   ""
1768   [(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 3)))
1769    (set (match_dup 0) (ior:SI (match_dup 0) (match_dup 4)))]
1770 "
1771 {
1772   operands[3] = gen_rtx (CONST_INT, VOIDmode,
1773                          INTVAL (operands[2]) & 0xffff0000);
1774   operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
1775 }")
1776
1777 (define_insn "xorsi3"
1778   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
1779         (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
1780                 (match_operand:SI 2 "logical_operand" "r,K,J")))]
1781   ""
1782   "@
1783    xor %0,%1,%2
1784    {xoril|xori} %0,%1,%b2
1785    {xoriu|xoris} %0,%1,%u2")
1786
1787 (define_insn ""
1788   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1789         (compare:CC (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1790                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1791                     (const_int 0)))
1792    (clobber (match_scratch:SI 3 "=r"))]
1793   ""
1794   "xor. %3,%1,%2"
1795   [(set_attr "type" "compare")])
1796
1797 (define_insn ""
1798   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1799         (compare:CC (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1800                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1801                     (const_int 0)))
1802    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1803         (xor:SI (match_dup 1) (match_dup 2)))]
1804   ""
1805   "xor. %0,%1,%2"
1806   [(set_attr "type" "compare")])
1807
1808 ;; Split an XOR that we can't do in one insn into two insns, each of which
1809 ;; does one 16-bit part.  This is used by combine.
1810
1811 (define_split
1812   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1813         (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1814                 (match_operand:SI 2 "non_logical_cint_operand" "")))]
1815   ""
1816   [(set (match_dup 0) (xor:SI (match_dup 1) (match_dup 3)))
1817    (set (match_dup 0) (xor:SI (match_dup 0) (match_dup 4)))]
1818 "
1819 {
1820   operands[3] = gen_rtx (CONST_INT, VOIDmode,
1821                          INTVAL (operands[2]) & 0xffff0000);
1822   operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
1823 }")
1824
1825 (define_insn ""
1826   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1827         (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1828                         (match_operand:SI 2 "gpc_reg_operand" "r"))))]
1829    ""
1830    "eqv %0,%1,%2")
1831
1832 (define_insn ""
1833   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1834         (compare:CC (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1835                                     (match_operand:SI 2 "gpc_reg_operand" "r")))
1836                     (const_int 0)))
1837    (clobber (match_scratch:SI 3 "=r"))]
1838    ""
1839    "eqv. %3,%1,%2"
1840    [(set_attr "type" "compare")])
1841
1842 (define_insn ""
1843   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1844         (compare:CC (not:SI (xor:SI (match_operand:SI 1 "gpc_reg_operand" "%r")
1845                                     (match_operand:SI 2 "gpc_reg_operand" "r")))
1846                     (const_int 0)))
1847    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1848         (not:SI (xor:SI (match_dup 1) (match_dup 2))))]
1849    ""
1850    "eqv. %0,%1,%2"
1851    [(set_attr "type" "compare")])
1852
1853 (define_insn ""
1854   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1855         (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1856                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1857   ""
1858   "andc %0,%2,%1")
1859
1860 (define_insn ""
1861   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1862         (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1863                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1864                     (const_int 0)))
1865    (clobber (match_scratch:SI 3 "=r"))]
1866   ""
1867   "andc. %3,%2,%1"
1868   [(set_attr "type" "compare")])
1869
1870 (define_insn ""
1871   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1872         (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1873                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1874                     (const_int 0)))
1875    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1876         (and:SI (not:SI (match_dup 1)) (match_dup 2)))]
1877   ""
1878   "andc. %0,%2,%1"
1879   [(set_attr "type" "compare")])
1880
1881 (define_insn ""
1882   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1883         (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1884                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1885   ""
1886   "orc %0,%2,%1")
1887
1888 (define_insn ""
1889   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1890         (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1891                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1892                     (const_int 0)))
1893    (clobber (match_scratch:SI 3 "=r"))]
1894   ""
1895   "orc. %3,%2,%1"
1896   [(set_attr "type" "compare")])
1897
1898 (define_insn ""
1899   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1900         (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
1901                             (match_operand:SI 2 "gpc_reg_operand" "r"))
1902                     (const_int 0)))
1903    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1904         (ior:SI (not:SI (match_dup 1)) (match_dup 2)))]
1905   ""
1906   "orc. %0,%2,%1"
1907   [(set_attr "type" "compare")])
1908
1909 (define_insn ""
1910   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1911         (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1912                 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
1913   ""
1914   "nand %0,%1,%2")
1915
1916 (define_insn ""
1917   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1918         (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1919                             (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1920                     (const_int 0)))
1921    (clobber (match_scratch:SI 3 "=r"))]
1922   ""
1923   "nand. %3,%1,%2"
1924   [(set_attr "type" "compare")])
1925
1926 (define_insn ""
1927   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1928         (compare:CC (ior:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1929                             (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1930                     (const_int 0)))
1931    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1932         (ior:SI (not:SI (match_dup 1)) (not:SI (match_dup 2))))]
1933   ""
1934   "nand. %0,%1,%2"
1935   [(set_attr "type" "compare")])
1936
1937 (define_insn ""
1938   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1939         (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1940                 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
1941   ""
1942   "nor %0,%1,%2")
1943
1944 (define_insn ""
1945   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
1946         (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1947                             (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1948                     (const_int 0)))
1949    (clobber (match_scratch:SI 3 "=r"))]
1950   ""
1951   "nor. %3,%1,%2"
1952   [(set_attr "type" "compare")])
1953
1954 (define_insn ""
1955   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1956         (compare:CC (and:SI (not:SI (match_operand:SI 1 "gpc_reg_operand" "%r"))
1957                             (not:SI (match_operand:SI 2 "gpc_reg_operand" "r")))
1958                     (const_int 0)))
1959    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1960         (and:SI (not:SI (match_dup 1)) (not:SI (match_dup 2))))]
1961   ""
1962   "nor. %0,%1,%2"
1963   [(set_attr "type" "compare")])
1964
1965 ;; maskir insn.  We need four forms because things might be in arbitrary
1966 ;; orders.  Don't define forms that only set CR fields because these
1967 ;; would modify an input register.
1968
1969 (define_insn ""
1970   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1971         (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
1972                         (match_operand:SI 1 "gpc_reg_operand" "0"))
1973                 (and:SI (match_dup 2)
1974                         (match_operand:SI 3 "gpc_reg_operand" "r"))))]
1975   "TARGET_POWER"
1976   "maskir %0,%3,%2")
1977
1978 (define_insn ""
1979   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1980         (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
1981                         (match_operand:SI 1 "gpc_reg_operand" "0"))
1982                 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
1983                         (match_dup 2))))]
1984   "TARGET_POWER"
1985   "maskir %0,%3,%2")
1986
1987 (define_insn ""
1988   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1989         (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
1990                         (match_operand:SI 3 "gpc_reg_operand" "r"))
1991                 (and:SI (not:SI (match_dup 2))
1992                         (match_operand:SI 1 "gpc_reg_operand" "0"))))]
1993   "TARGET_POWER"
1994   "maskir %0,%3,%2")
1995
1996 (define_insn ""
1997   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1998         (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
1999                         (match_operand:SI 2 "gpc_reg_operand" "r"))
2000                 (and:SI (not:SI (match_dup 2))
2001                         (match_operand:SI 1 "gpc_reg_operand" "0"))))]
2002   "TARGET_POWER"
2003   "maskir %0,%3,%2")
2004
2005 (define_insn ""
2006   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2007         (compare:CC
2008          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2009                          (match_operand:SI 1 "gpc_reg_operand" "0"))
2010                  (and:SI (match_dup 2)
2011                          (match_operand:SI 3 "gpc_reg_operand" "r")))
2012          (const_int 0)))
2013    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2014         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2015                 (and:SI (match_dup 2) (match_dup 3))))]
2016   "TARGET_POWER"
2017   "maskir. %0,%3,%2"
2018   [(set_attr "type" "compare")])
2019
2020 (define_insn ""
2021   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2022         (compare:CC
2023          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2024                          (match_operand:SI 1 "gpc_reg_operand" "0"))
2025                  (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2026                          (match_dup 2)))
2027          (const_int 0)))
2028    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2029         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2030                 (and:SI (match_dup 3) (match_dup 2))))]
2031   "TARGET_POWER"
2032   "maskir. %0,%3,%2"
2033   [(set_attr "type" "compare")])
2034
2035 (define_insn ""
2036   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2037         (compare:CC
2038          (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2039                          (match_operand:SI 3 "gpc_reg_operand" "r"))
2040                  (and:SI (not:SI (match_dup 2))
2041                          (match_operand:SI 1 "gpc_reg_operand" "0")))
2042          (const_int 0)))
2043    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2044         (ior:SI (and:SI (match_dup 2) (match_dup 3))
2045                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2046   "TARGET_POWER"
2047   "maskir. %0,%3,%2"
2048   [(set_attr "type" "compare")])
2049
2050 (define_insn ""
2051   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2052         (compare:CC
2053          (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2054                          (match_operand:SI 2 "gpc_reg_operand" "r"))
2055                  (and:SI (not:SI (match_dup 2))
2056                          (match_operand:SI 1 "gpc_reg_operand" "0")))
2057          (const_int 0)))
2058    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2059         (ior:SI (and:SI (match_dup 3) (match_dup 2))
2060                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2061   "TARGET_POWER"
2062   "maskir. %0,%3,%2"
2063   [(set_attr "type" "compare")])
2064 \f
2065 ;; Rotate and shift insns, in all their variants.  These support shifts,
2066 ;; field inserts and extracts, and various combinations thereof.
2067 (define_expand "insv"
2068   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2069                          (match_operand:SI 1 "const_int_operand" "i")
2070                          (match_operand:SI 2 "const_int_operand" "i"))
2071         (match_operand:SI 3 "gpc_reg_operand" "r"))]
2072   ""
2073   "
2074 {
2075   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
2076      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
2077      compiler if the address of the structure is taken later.  */
2078   if (GET_CODE (operands[0]) == SUBREG
2079       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
2080     FAIL;
2081 }")
2082
2083 (define_insn ""
2084   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2085                          (match_operand:SI 1 "const_int_operand" "i")
2086                          (match_operand:SI 2 "const_int_operand" "i"))
2087         (match_operand:SI 3 "gpc_reg_operand" "r"))]
2088   ""
2089   "*
2090 {
2091   int start = INTVAL (operands[2]) & 31;
2092   int size = INTVAL (operands[1]) & 31;
2093
2094   operands[4] = gen_rtx (CONST_INT, VOIDmode, 32 - start - size);
2095   operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
2096   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2097 }")
2098
2099 (define_insn ""
2100   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2101                          (match_operand:SI 1 "const_int_operand" "i")
2102                          (match_operand:SI 2 "const_int_operand" "i"))
2103         (ashift:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2104                    (match_operand:SI 4 "const_int_operand" "i")))]
2105   ""
2106   "*
2107 {
2108   int shift = INTVAL (operands[4]) & 31;
2109   int start = INTVAL (operands[2]) & 31;
2110   int size = INTVAL (operands[1]) & 31;
2111
2112   operands[4] = gen_rtx (CONST_INT, VOIDmode, shift - start - size);
2113   operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
2114   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2115 }")
2116
2117 (define_insn ""
2118   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2119                          (match_operand:SI 1 "const_int_operand" "i")
2120                          (match_operand:SI 2 "const_int_operand" "i"))
2121         (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2122                      (match_operand:SI 4 "const_int_operand" "i")))]
2123   ""
2124   "*
2125 {
2126   int shift = INTVAL (operands[4]) & 31;
2127   int start = INTVAL (operands[2]) & 31;
2128   int size = INTVAL (operands[1]) & 31;
2129
2130   operands[4] = gen_rtx (CONST_INT, VOIDmode, 32 - shift - start - size);
2131   operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
2132   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2133 }")
2134
2135 (define_insn ""
2136   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2137                          (match_operand:SI 1 "const_int_operand" "i")
2138                          (match_operand:SI 2 "const_int_operand" "i"))
2139         (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2140                      (match_operand:SI 4 "const_int_operand" "i")))]
2141   ""
2142   "*
2143 {
2144   int shift = INTVAL (operands[4]) & 31;
2145   int start = INTVAL (operands[2]) & 31;
2146   int size = INTVAL (operands[1]) & 31;
2147
2148   operands[4] = gen_rtx (CONST_INT, VOIDmode, 32 - shift - start - size);
2149   operands[1] = gen_rtx (CONST_INT, VOIDmode, start + size - 1);
2150   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2151 }")
2152
2153 (define_insn ""
2154   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2155                          (match_operand:SI 1 "const_int_operand" "i")
2156                          (match_operand:SI 2 "const_int_operand" "i"))
2157         (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2158                          (match_operand:SI 4 "const_int_operand" "i")
2159                          (match_operand:SI 5 "const_int_operand" "i")))]
2160   "INTVAL (operands[4]) >= INTVAL (operands[1])"
2161   "*
2162 {
2163   int extract_start = INTVAL (operands[5]) & 31;
2164   int extract_size = INTVAL (operands[4]) & 31;
2165   int insert_start = INTVAL (operands[2]) & 31;
2166   int insert_size = INTVAL (operands[1]) & 31;
2167
2168 /* Align extract field with insert field */
2169   operands[5] = gen_rtx (CONST_INT, VOIDmode,
2170                          extract_start + extract_size - insert_start - insert_size);
2171   operands[1] = gen_rtx (CONST_INT, VOIDmode, insert_start + insert_size - 1);
2172   return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
2173 }")
2174
2175 (define_insn ""
2176   [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
2177                          (match_operand:DI 1 "const_int_operand" "i")
2178                          (match_operand:DI 2 "const_int_operand" "i"))
2179         (match_operand:DI 3 "gpc_reg_operand" "r"))]
2180   "TARGET_POWERPC64"
2181   "*
2182 {
2183   int start = INTVAL (operands[2]) & 63;
2184   int size = INTVAL (operands[1]) & 63;
2185
2186   operands[2] = gen_rtx (CONST_INT, VOIDmode, 64 - start - size);
2187   return \"rldimi %0,%3,%H2,%H1\";
2188 }")
2189
2190 (define_expand "extzv"
2191   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2192         (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2193                          (match_operand:SI 2 "const_int_operand" "i")
2194                          (match_operand:SI 3 "const_int_operand" "i")))]
2195   ""
2196   "
2197 {
2198   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
2199      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
2200      compiler if the address of the structure is taken later.  */
2201   if (GET_CODE (operands[0]) == SUBREG
2202       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
2203     FAIL;
2204 }")
2205
2206 (define_insn ""
2207   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2208         (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2209                          (match_operand:SI 2 "const_int_operand" "i")
2210                          (match_operand:SI 3 "const_int_operand" "i")))]
2211   ""
2212   "*
2213 {
2214   int start = INTVAL (operands[3]) & 31;
2215   int size = INTVAL (operands[2]) & 31;
2216
2217   if (start + size >= 32)
2218     operands[3] = const0_rtx;
2219   else
2220     operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2221   return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
2222 }")
2223
2224 (define_insn ""
2225   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2226         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2227                          (match_operand:SI 2 "const_int_operand" "i")
2228                          (match_operand:SI 3 "const_int_operand" "i"))
2229                     (const_int 0)))
2230    (clobber (match_scratch:SI 4 "=r"))]
2231   ""
2232   "*
2233 {
2234   int start = INTVAL (operands[3]) & 31;
2235   int size = INTVAL (operands[2]) & 31;
2236
2237   /* If the bitfield being tested fits in the upper or lower half of a
2238      word, it is possible to use andiu. or andil. to test it.  This is
2239      useful because the condition register set-use delay is smaller for
2240      andi[ul]. than for rlinm.  This doesn't work when the starting bit
2241      position is 0 because the LT and GT bits may be set wrong.  */
2242
2243   if ((start > 0 && start + size <= 16) || start >= 16)
2244     {
2245       operands[3] = gen_rtx (CONST_INT, VOIDmode,
2246                              ((1 << (16 - (start & 15)))
2247                               - (1 << (16 - (start & 15) - size))));
2248       if (start < 16)
2249         return \"{andiu.|andis.} %4,%1,%3\";
2250       else
2251         return \"{andil.|andi.} %4,%1,%3\";
2252     }
2253
2254   if (start + size >= 32)
2255     operands[3] = const0_rtx;
2256   else
2257     operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2258   return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
2259 }"
2260   [(set_attr "type" "compare")])
2261
2262 (define_insn ""
2263   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2264         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2265                          (match_operand:SI 2 "const_int_operand" "i")
2266                          (match_operand:SI 3 "const_int_operand" "i"))
2267                     (const_int 0)))
2268    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2269         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
2270   ""
2271   "*
2272 {
2273   int start = INTVAL (operands[3]) & 31;
2274   int size = INTVAL (operands[2]) & 31;
2275
2276   if (start >= 16 && start + size == 32)
2277     {
2278       operands[3] = gen_rtx (CONST_INT, VOIDmode, (1 << (32 - start)) - 1);
2279       return \"{andil.|andi.} %0,%1,%3\";
2280     }
2281
2282   if (start + size >= 32)
2283     operands[3] = const0_rtx;
2284   else
2285     operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2286   return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
2287 }"
2288   [(set_attr "type" "delayed_compare")])
2289
2290 (define_insn ""
2291   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
2292         (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
2293                          (match_operand:DI 2 "const_int_operand" "i")
2294                          (match_operand:DI 3 "const_int_operand" "i")))]
2295   "TARGET_POWERPC64"
2296   "*
2297 {
2298   int start = INTVAL (operands[3]) & 63;
2299   int size = INTVAL (operands[2]) & 63;
2300
2301   if (start + size >= 64)
2302     operands[3] = const0_rtx;
2303   else
2304     operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2305   operands[2] = gen_rtx (CONST_INT, VOIDmode, 64 - size);
2306   return \"rldicl %0,%1,%3,%2\";
2307 }")
2308
2309 (define_insn ""
2310   [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
2311         (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
2312                          (match_operand:DI 2 "const_int_operand" "i")
2313                          (match_operand:DI 3 "const_int_operand" "i"))
2314                     (const_int 0)))
2315    (clobber (match_scratch:DI 4 "=r"))]
2316   "TARGET_POWERPC64"
2317   "*
2318 {
2319   int start = INTVAL (operands[3]) & 63;
2320   int size = INTVAL (operands[2]) & 63;
2321
2322   if (start + size >= 64)
2323     operands[3] = const0_rtx;
2324   else
2325     operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2326   operands[2] = gen_rtx (CONST_INT, VOIDmode, 64 - size);
2327   return \"rldicl. %4,%1,%3,%2\";
2328 }")
2329
2330 (define_insn ""
2331   [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
2332         (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
2333                          (match_operand:DI 2 "const_int_operand" "i")
2334                          (match_operand:DI 3 "const_int_operand" "i"))
2335                     (const_int 0)))
2336    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
2337         (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
2338   "TARGET_POWERPC64"
2339   "*
2340 {
2341   int start = INTVAL (operands[3]) & 63;
2342   int size = INTVAL (operands[2]) & 63;
2343
2344   if (start + size >= 64)
2345     operands[3] = const0_rtx;
2346   else
2347     operands[3] = gen_rtx (CONST_INT, VOIDmode, start + size);
2348   operands[2] = gen_rtx (CONST_INT, VOIDmode, 64 - size);
2349   return \"rldicl. %0,%1,%3,%2\";
2350 }")
2351
2352 (define_insn "rotlsi3"
2353   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2354         (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2355                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
2356   ""
2357   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffffffff")
2358
2359 (define_insn ""
2360   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2361         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2362                                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2363                     (const_int 0)))
2364    (clobber (match_scratch:SI 3 "=r"))]
2365   ""
2366   "{rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffffffff"
2367   [(set_attr "type" "delayed_compare")])
2368
2369 (define_insn ""
2370   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2371         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2372                                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2373                     (const_int 0)))
2374    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2375         (rotate:SI (match_dup 1) (match_dup 2)))]
2376   ""
2377   "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffffffff"
2378   [(set_attr "type" "delayed_compare")])
2379
2380 (define_insn ""
2381   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2382         (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2383                            (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2384                 (match_operand:SI 3 "mask_operand" "L")))]
2385   ""
2386   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,%m3,%M3")
2387
2388 (define_insn ""
2389   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2390         (compare:CC (and:SI
2391                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2392                                 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2393                      (match_operand:SI 3 "mask_operand" "L"))
2394                     (const_int 0)))
2395    (clobber (match_scratch:SI 4 "=r"))]
2396   ""
2397   "{rl%I2nm.|rlw%I2nm.} %4,%1,%h2,%m3,%M3"
2398   [(set_attr "type" "delayed_compare")])
2399
2400 (define_insn ""
2401   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2402         (compare:CC (and:SI
2403                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2404                                 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2405                      (match_operand:SI 3 "mask_operand" "L"))
2406                     (const_int 0)))
2407    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2408         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
2409   ""
2410   "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,%m3,%M3"
2411   [(set_attr "type" "delayed_compare")])
2412
2413 (define_insn ""
2414   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2415         (zero_extend:SI
2416          (subreg:QI
2417           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2418                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
2419   ""
2420   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
2421
2422 (define_insn ""
2423   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2424         (compare:CC (zero_extend:SI
2425                      (subreg:QI
2426                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2427                                  (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
2428                     (const_int 0)))
2429    (clobber (match_scratch:SI 3 "=r"))]
2430   ""
2431   "{rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xff"
2432   [(set_attr "type" "delayed_compare")])
2433
2434 (define_insn ""
2435   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2436         (compare:CC (zero_extend:SI
2437                      (subreg:QI
2438                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2439                                  (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
2440                     (const_int 0)))
2441    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2442         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
2443   ""
2444   "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xff"
2445   [(set_attr "type" "delayed_compare")])
2446
2447 (define_insn ""
2448   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2449         (zero_extend:SI
2450          (subreg:HI
2451           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2452                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
2453   ""
2454   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffff")
2455
2456 (define_insn ""
2457   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2458         (compare:CC (zero_extend:SI
2459                      (subreg:HI
2460                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2461                                  (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
2462                     (const_int 0)))
2463    (clobber (match_scratch:SI 3 "=r"))]
2464   ""
2465   "{rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffff"
2466   [(set_attr "type" "delayed_compare")])
2467
2468 (define_insn ""
2469   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2470         (compare:CC (zero_extend:SI
2471                      (subreg:HI
2472                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2473                                  (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0))
2474                     (const_int 0)))
2475    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2476         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
2477   ""
2478   "{rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffff"
2479   [(set_attr "type" "delayed_compare")])
2480
2481 ;; Note that we use "sle." instead of "sl." so that we can set
2482 ;; SHIFT_COUNT_TRUNCATED.
2483
2484 (define_expand "ashlsi3"
2485   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2486    (use (match_operand:SI 1 "gpc_reg_operand" ""))
2487    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
2488   ""
2489   "
2490 {
2491   if (TARGET_POWER)
2492     emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
2493   else
2494     emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
2495   DONE;
2496 }")
2497
2498 (define_insn "ashlsi3_power"
2499   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2500         (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2501                    (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
2502    (clobber (match_scratch:SI 3 "=q,X"))]
2503   "TARGET_POWER"
2504   "@
2505    sle %0,%1,%2
2506    {sli|slwi} %0,%1,%h2"
2507   [(set_attr "length" "8")])
2508
2509 (define_insn "ashlsi3_no_power"
2510   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2511         (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2512                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
2513   "! TARGET_POWER"
2514   "{sl|slw}%I2 %0,%1,%h2"
2515   [(set_attr "length" "8")])
2516
2517 (define_insn ""
2518   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
2519         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2520                                (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2521                     (const_int 0)))
2522    (clobber (match_scratch:SI 3 "=r,r"))
2523    (clobber (match_scratch:SI 4 "=q,X"))]
2524   "TARGET_POWER"
2525   "@
2526    sle. %3,%1,%2
2527    {sli.|slwi.} %3,%1,%h2"
2528   [(set_attr "type" "delayed_compare")])
2529
2530 (define_insn ""
2531   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2532         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2533                                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2534                     (const_int 0)))
2535    (clobber (match_scratch:SI 3 "=r"))]
2536   "! TARGET_POWER"
2537   "{sl|slw}%I2. %3,%1,%h2"
2538   [(set_attr "type" "delayed_compare")])
2539
2540 (define_insn ""
2541   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
2542         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2543                                (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2544                     (const_int 0)))
2545    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2546         (ashift:SI (match_dup 1) (match_dup 2)))
2547    (clobber (match_scratch:SI 4 "=q,X"))]
2548   "TARGET_POWER"
2549   "@
2550    sle. %0,%1,%2
2551    {sli.|slwi.} %0,%1,%h2"
2552   [(set_attr "type" "delayed_compare")])
2553
2554 (define_insn ""
2555   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2556         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2557                                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2558                     (const_int 0)))
2559    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2560         (ashift:SI (match_dup 1) (match_dup 2)))]
2561   "! TARGET_POWER"
2562   "{sl|slw}%I2. %0,%1,%h2"
2563   [(set_attr "type" "delayed_compare")])
2564
2565 (define_insn ""
2566   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2567         (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2568                            (match_operand:SI 2 "const_int_operand" "i"))
2569                 (match_operand:SI 3 "mask_operand" "L")))]
2570   "includes_lshift_p (operands[2], operands[3])"
2571   "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
2572
2573 (define_insn ""
2574   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2575         (compare:CC
2576          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2577                             (match_operand:SI 2 "const_int_operand" "i"))
2578                  (match_operand:SI 3 "mask_operand" "L"))
2579          (const_int 0)))
2580    (clobber (match_scratch:SI 4 "=r"))]
2581   "includes_lshift_p (operands[2], operands[3])"
2582   "{rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3"
2583   [(set_attr "type" "delayed_compare")])
2584
2585 (define_insn ""
2586   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2587         (compare:CC
2588          (and:SI (ashift: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    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2593         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
2594   "includes_lshift_p (operands[2], operands[3])"
2595   "{rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3"
2596   [(set_attr "type" "delayed_compare")])
2597
2598 ;; The AIX assembler mis-handles "sri x,x,0", so write that case as
2599 ;; "sli x,x,0".
2600 (define_expand "lshrsi3"
2601   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2602    (use (match_operand:SI 1 "gpc_reg_operand" ""))
2603    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
2604   ""
2605   "
2606 {
2607   if (TARGET_POWER)
2608     emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
2609   else
2610     emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
2611   DONE;
2612 }")
2613
2614 (define_insn "lshrsi3_power"
2615   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2616         (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
2617                      (match_operand:SI 2 "reg_or_cint_operand" "r,O,i")))
2618    (clobber (match_scratch:SI 3 "=q,X,X"))]
2619   "TARGET_POWER"
2620   "@
2621   sre %0,%1,%2
2622   mr %0,%1
2623   {s%A2i|s%A2wi} %0,%1,%h2")
2624
2625 (define_insn "lshrsi3_no_power"
2626   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2627         (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2628                      (match_operand:SI 2 "reg_or_cint_operand" "O,ri")))]
2629   "! TARGET_POWER"
2630   "@
2631   mr %0,%1
2632   {sr|srw}%I2 %0,%1,%h2")
2633
2634 (define_insn ""
2635   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x")
2636         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
2637                                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,i"))
2638                     (const_int 0)))
2639    (clobber (match_scratch:SI 3 "=r,X,r"))
2640    (clobber (match_scratch:SI 4 "=q,X,X"))]
2641   "TARGET_POWER"
2642   "@
2643   sre. %3,%1,%2
2644   mr. %1,%1
2645   {s%A2i.|s%A2wi.} %3,%1,%h2"
2646   [(set_attr "type" "delayed_compare")])
2647
2648 (define_insn ""
2649   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
2650         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2651                                  (match_operand:SI 2 "reg_or_cint_operand" "O,ri"))
2652                     (const_int 0)))
2653    (clobber (match_scratch:SI 3 "=X,r"))]
2654   "! TARGET_POWER"
2655   "@
2656    mr. %1,%1
2657    {sr|srw}%I2. %3,%1,%h2"
2658   [(set_attr "type" "delayed_compare")])
2659
2660 (define_insn ""
2661   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x")
2662         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
2663                                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,i"))
2664                     (const_int 0)))
2665    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2666         (lshiftrt:SI (match_dup 1) (match_dup 2)))
2667    (clobber (match_scratch:SI 4 "=q,X,X"))]
2668   "TARGET_POWER"
2669   "@
2670   sre. %0,%1,%2
2671   mr. %0,%1
2672   {s%A2i.|s%A2wi.} %0,%1,%h2"
2673   [(set_attr "type" "delayed_compare")])
2674
2675 (define_insn ""
2676   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
2677         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2678                                  (match_operand:SI 2 "reg_or_cint_operand" "O,ri"))
2679                     (const_int 0)))
2680    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2681         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
2682   "! TARGET_POWER"
2683   "@
2684    mr. %0,%1
2685    {sr|srw}%I2. %0,%1,%h2"
2686   [(set_attr "type" "delayed_compare")])
2687
2688 (define_insn ""
2689   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2690         (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2691                              (match_operand:SI 2 "const_int_operand" "i"))
2692                 (match_operand:SI 3 "mask_operand" "L")))]
2693   "includes_rshift_p (operands[2], operands[3])"
2694   "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
2695
2696 (define_insn ""
2697   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2698         (compare:CC
2699          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2700                               (match_operand:SI 2 "const_int_operand" "i"))
2701                  (match_operand:SI 3 "mask_operand" "L"))
2702          (const_int 0)))
2703    (clobber (match_scratch:SI 4 "=r"))]
2704   "includes_rshift_p (operands[2], operands[3])"
2705   "{rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3"
2706   [(set_attr "type" "delayed_compare")])
2707
2708 (define_insn ""
2709   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
2710         (compare:CC
2711          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2712                               (match_operand:SI 2 "const_int_operand" "i"))
2713                  (match_operand:SI 3 "mask_operand" "L"))
2714          (const_int 0)))
2715    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2716         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
2717   "includes_rshift_p (operands[2], operands[3])"
2718   "{rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3"
2719   [(set_attr "type" "delayed_compare")])
2720
2721 (define_insn ""
2722   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2723         (zero_extend:SI
2724          (subreg:QI
2725           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2726                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
2727   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
2728   "{rlinm|rlwinm} %0,%1,%s2,0xff")
2729
2730 (define_insn ""
2731   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2732         (compare:CC
2733          (zero_extend:SI
2734           (subreg:QI
2735            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2736                         (match_operand:SI 2 "const_int_operand" "i")) 0))
2737          (const_int 0)))
2738    (clobber (match_scratch:SI 3 "=r"))]
2739   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
2740   "{rlinm.|rlwinm.} %3,%1,%s2,0xff"
2741   [(set_attr "type" "delayed_compare")])
2742
2743 (define_insn ""
2744   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2745         (compare:CC
2746          (zero_extend:SI
2747           (subreg:QI
2748            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2749                         (match_operand:SI 2 "const_int_operand" "i")) 0))
2750          (const_int 0)))
2751    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2752         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
2753   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 255))"
2754   "{rlinm.|rlwinm.} %0,%1,%s2,0xff"
2755   [(set_attr "type" "delayed_compare")])
2756
2757 (define_insn ""
2758   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2759         (zero_extend:SI
2760          (subreg:HI
2761           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2762                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
2763   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
2764   "{rlinm|rlwinm} %0,%1,%s2,0xffff")
2765
2766 (define_insn ""
2767   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2768         (compare:CC
2769          (zero_extend:SI
2770           (subreg:HI
2771            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2772                         (match_operand:SI 2 "const_int_operand" "i")) 0))
2773          (const_int 0)))
2774    (clobber (match_scratch:SI 3 "=r"))]
2775   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
2776   "{rlinm.|rlwinm.} %3,%1,%s2,0xffff"
2777   [(set_attr "type" "delayed_compare")])
2778
2779 (define_insn ""
2780   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2781         (compare:CC
2782          (zero_extend:SI
2783           (subreg:HI
2784            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2785                         (match_operand:SI 2 "const_int_operand" "i")) 0))
2786          (const_int 0)))
2787    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2788         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
2789   "includes_rshift_p (operands[2], gen_rtx (CONST_INT, VOIDmode, 65535))"
2790   "{rlinm.|rlwinm.} %0,%1,%s2,0xffff"
2791   [(set_attr "type" "delayed_compare")])
2792
2793 (define_insn ""
2794   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2795                          (const_int 1)
2796                          (match_operand:SI 1 "gpc_reg_operand" "r"))
2797         (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2798                      (const_int 31)))]
2799   "TARGET_POWER"
2800   "rrib %0,%1,%2")
2801
2802 (define_insn ""
2803   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2804                          (const_int 1)
2805                          (match_operand:SI 1 "gpc_reg_operand" "r"))
2806         (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2807                      (const_int 31)))]
2808   "TARGET_POWER"
2809   "rrib %0,%1,%2")
2810
2811 (define_insn ""
2812   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2813                          (const_int 1)
2814                          (match_operand:SI 1 "gpc_reg_operand" "r"))
2815         (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2816                          (const_int 1)
2817                          (const_int 0)))]
2818   "TARGET_POWER"
2819   "rrib %0,%1,%2")
2820
2821 (define_expand "ashrsi3"
2822   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2823         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
2824                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
2825   ""
2826   "
2827 {
2828   if (TARGET_POWER)
2829     emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
2830   else
2831     emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
2832   DONE;
2833 }")
2834
2835 (define_insn "ashrsi3_power"
2836   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2837         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2838                      (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
2839    (clobber (match_scratch:SI 3 "=q,X"))]
2840   "TARGET_POWER"
2841   "@
2842    srea %0,%1,%2
2843    {srai|srawi} %0,%1,%h2")
2844
2845 (define_insn "ashrsi3_no_power"
2846   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2847         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2848                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
2849   "! TARGET_POWER"
2850   "{sra|sraw}%I2 %0,%1,%h2")
2851
2852 (define_insn ""
2853   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
2854         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2855                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2856                     (const_int 0)))
2857    (clobber (match_scratch:SI 3 "=r,r"))
2858    (clobber (match_scratch:SI 4 "=q,X"))]
2859   "TARGET_POWER"
2860   "@
2861    srea. %3,%1,%2
2862    {srai.|srawi.} %3,%1,%h2"
2863   [(set_attr "type" "delayed_compare")])
2864
2865 (define_insn ""
2866   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
2867         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2868                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2869                     (const_int 0)))
2870    (clobber (match_scratch:SI 3 "=r"))]
2871   "! TARGET_POWER"
2872   "{sra|sraw}%I2. %3,%1,%h2"
2873   [(set_attr "type" "delayed_compare")])
2874
2875 (define_insn ""
2876   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
2877         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2878                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
2879                     (const_int 0)))
2880    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2881         (ashiftrt:SI (match_dup 1) (match_dup 2)))
2882    (clobber (match_scratch:SI 4 "=q,X"))]
2883   "TARGET_POWER"
2884   "@
2885    srea. %0,%1,%2
2886    {srai.|srawi.} %0,%1,%h2"
2887   [(set_attr "type" "delayed_compare")])
2888
2889 (define_insn ""
2890   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
2891         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2892                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
2893                     (const_int 0)))
2894    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
2895         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
2896   "! TARGET_POWER"
2897   "{sra|sraw}%I2. %0,%1,%h2"
2898   [(set_attr "type" "delayed_compare")])
2899 \f
2900 ;; Floating-point insns, excluding normal data motion.
2901 ;;
2902 ;; PowerPC has a full set of single-precision floating point instructions.
2903 ;;
2904 ;; For the POWER architecture, we pretend that we have both SFmode and
2905 ;; DFmode insns, while, in fact, all fp insns are actually done in double.
2906 ;; The only conversions we will do will be when storing to memory.  In that
2907 ;; case, we will use the "frsp" instruction before storing.
2908 ;;
2909 ;; Note that when we store into a single-precision memory location, we need to
2910 ;; use the frsp insn first.  If the register being stored isn't dead, we
2911 ;; need a scratch register for the frsp.  But this is difficult when the store
2912 ;; is done by reload.  It is not incorrect to do the frsp on the register in
2913 ;; this case, we just lose precision that we would have otherwise gotten but
2914 ;; is not guaranteed.  Perhaps this should be tightened up at some point.
2915
2916 (define_insn "extendsfdf2"
2917   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
2918         (float_extend:DF (match_operand:SF 1 "gpc_reg_operand" "f")))]
2919   "TARGET_HARD_FLOAT"
2920   "*
2921 {
2922   if (REGNO (operands[0]) == REGNO (operands[1]))
2923     return \"\";
2924   else
2925     return \"fmr %0,%1\";
2926 }"
2927   [(set_attr "type" "fp")])
2928
2929 (define_insn "truncdfsf2"
2930   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2931         (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
2932   "TARGET_HARD_FLOAT"
2933   "frsp %0,%1"
2934   [(set_attr "type" "fp")])
2935
2936 (define_insn "aux_truncdfsf2"
2937   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2938         (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] 0))]
2939   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
2940   "frsp %0,%1"
2941   [(set_attr "type" "fp")])
2942
2943 (define_insn "negsf2"
2944   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2945         (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
2946   "TARGET_HARD_FLOAT"
2947   "fneg %0,%1"
2948   [(set_attr "type" "fp")])
2949
2950 (define_insn "abssf2"
2951   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2952         (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
2953   "TARGET_HARD_FLOAT"
2954   "fabs %0,%1"
2955   [(set_attr "type" "fp")])
2956
2957 (define_insn ""
2958   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2959         (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
2960   "TARGET_HARD_FLOAT"
2961   "fnabs %0,%1"
2962   [(set_attr "type" "fp")])
2963
2964 (define_expand "addsf3"
2965   [(set (match_operand:SF 0 "gpc_reg_operand" "")
2966         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
2967                  (match_operand:SF 2 "gpc_reg_operand" "")))]
2968   "TARGET_HARD_FLOAT"
2969   "")
2970
2971 (define_insn ""
2972   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2973         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2974                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
2975   "TARGET_POWERPC && TARGET_HARD_FLOAT"
2976   "fadds %0,%1,%2"
2977   [(set_attr "type" "fp")])
2978
2979 (define_insn ""
2980   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2981         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
2982                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
2983   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
2984   "{fa|fadd} %0,%1,%2"
2985   [(set_attr "type" "fp")])
2986
2987 (define_expand "subsf3"
2988   [(set (match_operand:SF 0 "gpc_reg_operand" "")
2989         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
2990                   (match_operand:SF 2 "gpc_reg_operand" "")))]
2991   "TARGET_HARD_FLOAT"
2992   "")
2993
2994 (define_insn ""
2995   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
2996         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
2997                   (match_operand:SF 2 "gpc_reg_operand" "f")))]
2998   "TARGET_POWERPC && TARGET_HARD_FLOAT"
2999   "fsubs %0,%1,%2"
3000   [(set_attr "type" "fp")])
3001
3002 (define_insn ""
3003   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3004         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
3005                   (match_operand:SF 2 "gpc_reg_operand" "f")))]
3006   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3007   "{fs|fsub} %0,%1,%2"
3008   [(set_attr "type" "fp")])
3009
3010 (define_expand "mulsf3"
3011   [(set (match_operand:SF 0 "gpc_reg_operand" "")
3012         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
3013                  (match_operand:SF 2 "gpc_reg_operand" "")))]
3014   "TARGET_HARD_FLOAT"
3015   "")
3016
3017 (define_insn ""
3018   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3019         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3020                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
3021   "TARGET_POWERPC && TARGET_HARD_FLOAT"
3022   "fmuls %0,%1,%2"
3023   [(set_attr "type" "fp")])
3024
3025 (define_insn ""
3026   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3027         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3028                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
3029   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3030   "{fm|fmul} %0,%1,%2"
3031   [(set_attr "type" "dmul")])
3032
3033 (define_expand "divsf3"
3034   [(set (match_operand:SF 0 "gpc_reg_operand" "")
3035         (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
3036                 (match_operand:SF 2 "gpc_reg_operand" "")))]
3037   "TARGET_HARD_FLOAT"
3038   "")
3039
3040 (define_insn ""
3041   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3042         (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
3043                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
3044   "TARGET_POWERPC && TARGET_HARD_FLOAT"
3045   "fdivs %0,%1,%2"
3046   [(set_attr "type" "sdiv")])
3047
3048 (define_insn ""
3049   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3050         (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
3051                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
3052   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3053   "{fd|fdiv} %0,%1,%2"
3054   [(set_attr "type" "ddiv")])
3055
3056 (define_insn ""
3057   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3058         (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3059                           (match_operand:SF 2 "gpc_reg_operand" "f"))
3060                  (match_operand:SF 3 "gpc_reg_operand" "f")))]
3061   "TARGET_POWERPC && TARGET_HARD_FLOAT"
3062   "fmadds %0,%1,%2,%3"
3063   [(set_attr "type" "fp")])
3064
3065 (define_insn ""
3066   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3067         (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3068                           (match_operand:SF 2 "gpc_reg_operand" "f"))
3069                  (match_operand:SF 3 "gpc_reg_operand" "f")))]
3070   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3071   "{fma|fmadd} %0,%1,%2,%3"
3072   [(set_attr "type" "dmul")])
3073
3074 (define_insn ""
3075   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3076         (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3077                            (match_operand:SF 2 "gpc_reg_operand" "f"))
3078                   (match_operand:SF 3 "gpc_reg_operand" "f")))]
3079   "TARGET_POWERPC && TARGET_HARD_FLOAT"
3080   "fmsubs %0,%1,%2,%3"
3081   [(set_attr "type" "fp")])
3082
3083 (define_insn ""
3084   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3085         (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3086                            (match_operand:SF 2 "gpc_reg_operand" "f"))
3087                   (match_operand:SF 3 "gpc_reg_operand" "f")))]
3088   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3089   "{fms|fmsub} %0,%1,%2,%3"
3090   [(set_attr "type" "dmul")])
3091
3092 (define_insn ""
3093   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3094         (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3095                                   (match_operand:SF 2 "gpc_reg_operand" "f"))
3096                          (match_operand:SF 3 "gpc_reg_operand" "f"))))]
3097   "TARGET_POWERPC && TARGET_HARD_FLOAT"
3098   "fnmadds %0,%1,%2,%3"
3099   [(set_attr "type" "fp")])
3100
3101 (define_insn ""
3102   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3103         (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3104                                   (match_operand:SF 2 "gpc_reg_operand" "f"))
3105                          (match_operand:SF 3 "gpc_reg_operand" "f"))))]
3106   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3107   "{fnma|fnmadd} %0,%1,%2,%3"
3108   [(set_attr "type" "dmul")])
3109
3110 (define_insn ""
3111   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3112         (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3113                                    (match_operand:SF 2 "gpc_reg_operand" "f"))
3114                           (match_operand:SF 3 "gpc_reg_operand" "f"))))]
3115   "TARGET_POWERPC && TARGET_HARD_FLOAT"
3116   "fnmsubs %0,%1,%2,%3"
3117   [(set_attr "type" "fp")])
3118
3119 (define_insn ""
3120   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3121         (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
3122                                    (match_operand:SF 2 "gpc_reg_operand" "f"))
3123                           (match_operand:SF 3 "gpc_reg_operand" "f"))))]
3124   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
3125   "{fnms|fnmsub} %0,%1,%2,%3"
3126   [(set_attr "type" "dmul")])
3127
3128 (define_expand "sqrtsf2"
3129   [(set (match_operand:SF 0 "gpc_reg_operand" "")
3130         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
3131   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT"
3132   "")
3133
3134 (define_insn ""
3135   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3136         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
3137   "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT"
3138   "fsqrts %0,%1"
3139   [(set_attr "type" "ssqrt")])
3140
3141 (define_insn ""
3142   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3143         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
3144   "TARGET_POWER2 && TARGET_HARD_FLOAT"
3145   "fsqrt %0,%1"
3146   [(set_attr "type" "dsqrt")])
3147
3148 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
3149 ;; fsel instruction and some auxiliary computations.  Then we just have a
3150 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
3151 ;; combine.
3152 (define_expand "maxsf3"
3153   [(set (match_dup 3)
3154         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
3155                   (match_operand:SF 2 "gpc_reg_operand" "")))
3156    (set (match_operand:SF 0 "gpc_reg_operand" "")
3157         (if_then_else:SF (ge (match_dup 3)
3158                              (const_int 0))
3159                          (match_dup 1)
3160                          (match_dup 2)))]
3161   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3162   "
3163 { operands[3] = gen_reg_rtx (SFmode); }")
3164
3165 (define_split
3166   [(set (match_operand:SF 0 "gpc_reg_operand" "")
3167         (smax:SF (match_operand:SF 1 "gpc_reg_operand" "")
3168                  (match_operand:SF 2 "gpc_reg_operand" "")))
3169    (clobber (match_operand:SF 3 "gpc_reg_operand" ""))]
3170   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3171   [(set (match_dup 3)
3172         (minus:SF (match_dup 1) (match_dup 2)))
3173    (set (match_dup 0)
3174         (if_then_else:SF (ge (match_dup 3)
3175                              (const_int 0))
3176                          (match_dup 1)
3177                          (match_dup 2)))]
3178   "")
3179
3180 (define_expand "minsf3"
3181   [(set (match_dup 3)
3182         (minus:SF (match_operand:SF 2 "gpc_reg_operand" "")
3183                   (match_operand:SF 1 "gpc_reg_operand" "")))
3184    (set (match_operand:SF 0 "gpc_reg_operand" "")
3185         (if_then_else:SF (ge (match_dup 3)
3186                              (const_int 0))
3187                          (match_dup 1)
3188                          (match_dup 2)))]
3189   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3190   "
3191 { operands[3] = gen_reg_rtx (SFmode); }")
3192
3193 (define_split
3194   [(set (match_operand:SF 0 "gpc_reg_operand" "")
3195         (smin:SF (match_operand:SF 1 "gpc_reg_operand" "")
3196                  (match_operand:SF 2 "gpc_reg_operand" "")))
3197    (clobber (match_operand:SF 3 "gpc_reg_operand" ""))]
3198   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3199   [(set (match_dup 3)
3200         (minus:SF (match_dup 2) (match_dup 1)))
3201    (set (match_dup 0)
3202         (if_then_else:SF (ge (match_dup 3)
3203                              (const_int 0))
3204                          (match_dup 1)
3205                          (match_dup 2)))]
3206   "")
3207
3208 (define_expand "movsfcc"
3209    [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3210          (if_then_else:SF (match_operand 1 "comparison_operator" "")
3211                           (match_operand:SF 2 "gpc_reg_operand" "f")
3212                           (match_operand:SF 3 "gpc_reg_operand" "f")))]
3213   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3214   "
3215 {
3216   rtx temp, op0, op1;
3217   enum rtx_code code = GET_CODE (operands[1]);
3218   if (! rs6000_compare_fp_p)
3219     FAIL;
3220   switch (code)
3221     {
3222     case GE: case EQ: case NE:
3223       op0 = rs6000_compare_op0;
3224       op1 = rs6000_compare_op1;
3225       break;
3226     case GT:
3227       op0 = rs6000_compare_op1;
3228       op1 = rs6000_compare_op0;
3229       temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
3230       break;
3231     case LE:
3232       op0 = rs6000_compare_op1;
3233       op1 = rs6000_compare_op0;
3234       break;
3235     case LT:
3236       op0 = rs6000_compare_op0;
3237       op1 = rs6000_compare_op1;
3238       temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
3239       break;
3240     default:
3241       FAIL;
3242     }
3243   if (GET_MODE (rs6000_compare_op0) == DFmode)
3244     {
3245       temp = gen_reg_rtx (DFmode);
3246       emit_insn (gen_subdf3 (temp, op0, op1));
3247       emit_insn (gen_fseldfsf4 (operands[0], temp, operands[2], operands[3]));
3248       if (code == EQ)
3249         {
3250           emit_insn (gen_negdf2 (temp, temp));
3251           emit_insn (gen_fseldfsf4 (operands[0], temp, operands[0], operands[3]));
3252         }
3253       if (code == NE)
3254         {
3255           emit_insn (gen_negdf2 (temp, temp));
3256           emit_insn (gen_fseldfsf4 (operands[0], temp, operands[3], operands[0]));
3257         }
3258     }
3259   else
3260     {
3261       temp = gen_reg_rtx (SFmode);
3262       emit_insn (gen_subsf3 (temp, op0, op1));
3263       emit_insn (gen_fselsfsf4 (operands[0], temp, operands[2], operands[3]));
3264       if (code == EQ)
3265         {
3266           emit_insn (gen_negsf2 (temp, temp));
3267           emit_insn (gen_fselsfsf4 (operands[0], temp, operands[0], operands[3]));
3268         }
3269       if (code == NE)
3270         {
3271           emit_insn (gen_negsf2 (temp, temp));
3272           emit_insn (gen_fselsfsf4 (operands[0], temp, operands[3], operands[0]));
3273         }
3274     }
3275   DONE;
3276 }")
3277
3278 (define_insn "fselsfsf4"
3279   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3280         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
3281                              (const_int 0))
3282                          (match_operand:SF 2 "gpc_reg_operand" "f")
3283                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
3284   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3285   "fsel %0,%1,%2,%3"
3286   [(set_attr "type" "fp")])
3287
3288 (define_insn "fseldfsf4"
3289   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
3290         (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
3291                              (const_int 0))
3292                          (match_operand:SF 2 "gpc_reg_operand" "f")
3293                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
3294   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3295   "fsel %0,%1,%2,%3"
3296   [(set_attr "type" "fp")])
3297
3298 (define_insn "negdf2"
3299   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3300         (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
3301   "TARGET_HARD_FLOAT"
3302   "fneg %0,%1"
3303   [(set_attr "type" "fp")])
3304
3305 (define_insn "absdf2"
3306   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3307         (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
3308   "TARGET_HARD_FLOAT"
3309   "fabs %0,%1"
3310   [(set_attr "type" "fp")])
3311
3312 (define_insn ""
3313   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3314         (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
3315   "TARGET_HARD_FLOAT"
3316   "fnabs %0,%1"
3317   [(set_attr "type" "fp")])
3318
3319 (define_insn "adddf3"
3320   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3321         (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3322                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
3323   "TARGET_HARD_FLOAT"
3324   "{fa|fadd} %0,%1,%2"
3325   [(set_attr "type" "fp")])
3326
3327 (define_insn "subdf3"
3328   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3329         (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
3330                   (match_operand:DF 2 "gpc_reg_operand" "f")))]
3331   "TARGET_HARD_FLOAT"
3332   "{fs|fsub} %0,%1,%2"
3333   [(set_attr "type" "fp")])
3334
3335 (define_insn "muldf3"
3336   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3337         (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3338                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
3339   "TARGET_HARD_FLOAT"
3340   "{fm|fmul} %0,%1,%2"
3341   [(set_attr "type" "dmul")])
3342
3343 (define_insn "divdf3"
3344   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3345         (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
3346                 (match_operand:DF 2 "gpc_reg_operand" "f")))]
3347   "TARGET_HARD_FLOAT"
3348   "{fd|fdiv} %0,%1,%2"
3349   [(set_attr "type" "ddiv")])
3350
3351 (define_insn ""
3352   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3353         (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3354                           (match_operand:DF 2 "gpc_reg_operand" "f"))
3355                  (match_operand:DF 3 "gpc_reg_operand" "f")))]
3356   "TARGET_HARD_FLOAT"
3357   "{fma|fmadd} %0,%1,%2,%3"
3358   [(set_attr "type" "dmul")])
3359
3360 (define_insn ""
3361   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3362         (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3363                            (match_operand:DF 2 "gpc_reg_operand" "f"))
3364                   (match_operand:DF 3 "gpc_reg_operand" "f")))]
3365   "TARGET_HARD_FLOAT"
3366   "{fms|fmsub} %0,%1,%2,%3"
3367   [(set_attr "type" "dmul")])
3368
3369 (define_insn ""
3370   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3371         (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3372                                   (match_operand:DF 2 "gpc_reg_operand" "f"))
3373                          (match_operand:DF 3 "gpc_reg_operand" "f"))))]
3374   "TARGET_HARD_FLOAT"
3375   "{fnma|fnmadd} %0,%1,%2,%3"
3376   [(set_attr "type" "dmul")])
3377
3378 (define_insn ""
3379   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3380         (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
3381                                    (match_operand:DF 2 "gpc_reg_operand" "f"))
3382                           (match_operand:DF 3 "gpc_reg_operand" "f"))))]
3383   "TARGET_HARD_FLOAT"
3384   "{fnms|fnmsub} %0,%1,%2,%3"
3385   [(set_attr "type" "dmul")])
3386
3387 (define_insn "sqrtdf2"
3388   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3389         (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
3390   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT"
3391   "fsqrt %0,%1"
3392   [(set_attr "type" "dsqrt")])
3393
3394 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
3395 ;; fsel instruction and some auxiliary computations.  Then we just have a
3396 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
3397 ;; combine.
3398
3399 (define_expand "maxdf3"
3400   [(set (match_dup 3)
3401         (minus:DF (match_operand:DF 1 "gpc_reg_operand" "")
3402                   (match_operand:DF 2 "gpc_reg_operand" "")))
3403    (set (match_operand:DF 0 "gpc_reg_operand" "")
3404         (if_then_else:DF (ge (match_dup 3)
3405                              (const_int 0))
3406                          (match_dup 1)
3407                          (match_dup 2)))]
3408   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3409   "
3410 { operands[3] = gen_reg_rtx (DFmode); }")
3411
3412 (define_split
3413   [(set (match_operand:DF 0 "gpc_reg_operand" "")
3414         (smax:DF (match_operand:DF 1 "gpc_reg_operand" "")
3415                  (match_operand:DF 2 "gpc_reg_operand" "")))
3416    (clobber (match_operand:DF 3 "gpc_reg_operand" ""))]
3417   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3418   [(set (match_dup 3)
3419         (minus:DF (match_dup 1) (match_dup 2)))
3420    (set (match_dup 0)
3421         (if_then_else:DF (ge (match_dup 3)
3422                              (const_int 0))
3423                          (match_dup 1)
3424                          (match_dup 2)))]
3425   "")
3426
3427 (define_expand "mindf3"
3428   [(set (match_dup 3)
3429         (minus:DF (match_operand:DF 2 "gpc_reg_operand" "")
3430                   (match_operand:DF 1 "gpc_reg_operand" "")))
3431    (set (match_operand:DF 0 "gpc_reg_operand" "")
3432         (if_then_else:DF (ge (match_dup 3)
3433                              (const_int 0))
3434                          (match_dup 1)
3435                          (match_dup 2)))]
3436   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3437   "
3438 { operands[3] = gen_reg_rtx (DFmode); }")
3439
3440 (define_split
3441   [(set (match_operand:DF 0 "gpc_reg_operand" "")
3442         (smin:DF (match_operand:DF 1 "gpc_reg_operand" "")
3443                  (match_operand:DF 2 "gpc_reg_operand" "")))
3444    (clobber (match_operand:DF 3 "gpc_reg_operand" ""))]
3445   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3446   [(set (match_dup 3)
3447         (minus:DF (match_dup 2) (match_dup 1)))
3448    (set (match_dup 0)
3449         (if_then_else:DF (ge (match_dup 3)
3450                              (const_int 0))
3451                          (match_dup 1)
3452                          (match_dup 2)))]
3453   "")
3454
3455 (define_expand "movdfcc"
3456    [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3457          (if_then_else:DF (match_operand 1 "comparison_operator" "")
3458                           (match_operand:DF 2 "gpc_reg_operand" "f")
3459                           (match_operand:DF 3 "gpc_reg_operand" "f")))]
3460   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3461   "
3462 {
3463   rtx temp, op0, op1;
3464   enum rtx_code code = GET_CODE (operands[1]);
3465   if (! rs6000_compare_fp_p)
3466     FAIL;
3467   switch (code)
3468     {
3469     case GE: case EQ: case NE:
3470       op0 = rs6000_compare_op0;
3471       op1 = rs6000_compare_op1;
3472       break;
3473     case GT:
3474       op0 = rs6000_compare_op1;
3475       op1 = rs6000_compare_op0;
3476       temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
3477       break;
3478     case LE:
3479       op0 = rs6000_compare_op1;
3480       op1 = rs6000_compare_op0;
3481       break;
3482     case LT:
3483       op0 = rs6000_compare_op0;
3484       op1 = rs6000_compare_op1;
3485       temp = operands[2]; operands[2] = operands[3]; operands[3] = temp;
3486       break;
3487     default:
3488       FAIL;
3489     }
3490   if (GET_MODE (rs6000_compare_op0) == DFmode)
3491     {
3492       temp = gen_reg_rtx (DFmode);
3493       emit_insn (gen_subdf3 (temp, op0, op1));
3494       emit_insn (gen_fseldfdf4 (operands[0], temp, operands[2], operands[3]));
3495       if (code == EQ)
3496         {
3497           emit_insn (gen_negdf2 (temp, temp));
3498           emit_insn (gen_fseldfdf4 (operands[0], temp, operands[0], operands[3]));
3499         }
3500       if (code == NE)
3501         {
3502           emit_insn (gen_negdf2 (temp, temp));
3503           emit_insn (gen_fseldfdf4 (operands[0], temp, operands[3], operands[0]));
3504         }
3505     }
3506   else
3507     {
3508       temp = gen_reg_rtx (SFmode);
3509       emit_insn (gen_subsf3 (temp, op0, op1));
3510       emit_insn (gen_fselsfdf4 (operands[0], temp, operands[2], operands[3]));
3511       if (code == EQ)
3512         {
3513           emit_insn (gen_negsf2 (temp, temp));
3514           emit_insn (gen_fselsfdf4 (operands[0], temp, operands[0], operands[3]));
3515         }
3516       if (code == NE)
3517         {
3518           emit_insn (gen_negsf2 (temp, temp));
3519           emit_insn (gen_fselsfdf4 (operands[0], temp, operands[3], operands[0]));
3520         }
3521     }
3522   DONE;
3523 }")
3524
3525 (define_insn "fseldfdf4"
3526   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3527         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
3528                              (const_int 0))
3529                          (match_operand:DF 2 "gpc_reg_operand" "f")
3530                          (match_operand:DF 3 "gpc_reg_operand" "f")))]
3531   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
3532   "fsel %0,%1,%2,%3"
3533   [(set_attr "type" "fp")])
3534
3535 (define_insn "fselsfdf4"
3536   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3537         (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
3538                              (const_int 0))
3539                          (match_operand:DF 2 "gpc_reg_operand" "f")
3540                          (match_operand:DF 3 "gpc_reg_operand" "f")))]
3541   "TARGET_PPC_GFXOPT"
3542   "fsel %0,%1,%2,%3"
3543   [(set_attr "type" "fp")])
3544 \f
3545 ;; Conversions to and from floating-point.
3546
3547 (define_expand "floatsidf2"
3548   [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
3549                    (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
3550               (use (match_dup 2))
3551               (use (match_dup 3))
3552               (clobber (match_dup 4))
3553               (clobber (match_dup 5))
3554               (clobber (reg:DF 76))])]
3555   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3556   "
3557 {
3558   operands[2] = force_reg (SImode, GEN_INT (0x43300000));
3559   operands[3] = force_reg (DFmode, rs6000_float_const (\"4503601774854144\", DFmode));
3560   operands[4] = gen_reg_rtx (SImode);
3561   operands[5] = gen_reg_rtx (Pmode);
3562 }")
3563
3564 (define_insn "*floatsidf2_internal"
3565   [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
3566         (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
3567    (use (match_operand:SI 2 "gpc_reg_operand" "r"))
3568    (use (match_operand:DF 3 "gpc_reg_operand" "f"))
3569    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
3570    (clobber (match_operand:SI 5 "gpc_reg_operand" "=b"))
3571    (clobber (reg:DF 76))]
3572   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3573   "#"
3574   [(set_attr "length" "24")])
3575
3576 (define_split
3577   [(set (match_operand:DF 0 "gpc_reg_operand" "")
3578         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
3579    (use (match_operand:SI 2 "gpc_reg_operand" ""))
3580    (use (match_operand:DF 3 "gpc_reg_operand" ""))
3581    (clobber (match_operand:SI 4 "gpc_reg_operand" ""))
3582    (clobber (match_operand:SI 5 "gpc_reg_operand" ""))
3583    (clobber (reg:DF 76))]
3584   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3585   [(set (match_dup 4)
3586         (xor:SI (match_dup 1)
3587                 (match_dup 6)))
3588    (set (match_dup 5)
3589         (unspec [(const_int 0)] 11))
3590    (set (match_dup 7)
3591         (unspec [(match_dup 4)
3592                  (match_dup 5)] 12))    ;; low word
3593    (set (match_dup 7)
3594         (unspec [(match_dup 2)
3595                  (match_dup 5)
3596                  (match_dup 7)] 13))    ;; high word
3597    (set (match_dup 0)
3598         (unspec [(match_dup 7)
3599                  (match_dup 5)] 14))
3600    (set (match_dup 0)
3601         (minus:DF (match_dup 0)
3602                   (match_dup 3)))]
3603   "
3604 {
3605   operands[6] = GEN_INT (0x80000000);
3606   operands[7] = gen_rtx (REG, DFmode, FPMEM_REGNUM);
3607 }")
3608
3609 (define_expand "floatunssidf2"
3610   [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
3611                    (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
3612               (use (match_dup 2))
3613               (use (match_dup 3))
3614               (clobber (match_dup 4))
3615               (clobber (reg:DF 76))])]
3616   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3617   "
3618 {
3619   operands[2] = force_reg (SImode, GEN_INT (0x43300000));
3620   operands[3] = force_reg (DFmode, rs6000_float_const (\"4503599627370496\", DFmode));
3621   operands[4] = gen_reg_rtx (Pmode);
3622 }")
3623
3624 (define_insn "*floatunssidf2_internal"
3625   [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
3626         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
3627    (use (match_operand:SI 2 "gpc_reg_operand" "r"))
3628    (use (match_operand:DF 3 "gpc_reg_operand" "f"))
3629    (clobber (match_operand:SI 4 "gpc_reg_operand" "=b"))
3630    (clobber (reg:DF 76))]
3631   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3632   "#"
3633   [(set_attr "length" "20")])
3634
3635 (define_split
3636   [(set (match_operand:DF 0 "gpc_reg_operand" "")
3637         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
3638    (use (match_operand:SI 2 "gpc_reg_operand" ""))
3639    (use (match_operand:DF 3 "gpc_reg_operand" ""))
3640    (clobber (match_operand:SI 4 "gpc_reg_operand" "=b"))
3641    (clobber (reg:DF 76))]
3642   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3643   [(set (match_dup 4)
3644         (unspec [(const_int 0)] 11))
3645    (set (match_dup 5)
3646         (unspec [(match_dup 1)
3647                  (match_dup 4)] 12))    ;; low word
3648    (set (match_dup 5)
3649         (unspec [(match_dup 2)
3650                  (match_dup 4)
3651                  (match_dup 5)] 13))    ;; high word
3652    (set (match_dup 0)
3653         (unspec [(match_dup 5)
3654                  (reg:SI 1)] 14))
3655    (set (match_dup 0)
3656         (minus:DF (match_dup 0)
3657                   (match_dup 3)))]
3658   "operands[5] = gen_rtx (REG, DFmode, FPMEM_REGNUM);")
3659
3660 ;; Load up scratch register with base address + offset if needed
3661 (define_insn "*floatsidf2_loadaddr"
3662   [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
3663         (unspec [(const_int 0)] 11))]
3664   "TARGET_HARD_FLOAT"
3665   "*
3666 {
3667   if (rs6000_fpmem_offset > 32760)
3668     {
3669       rtx xop[3];
3670
3671       xop[0] = operands[0];
3672       xop[1] = (frame_pointer_needed) ? frame_pointer_rtx : stack_pointer_rtx;
3673       xop[2] = GEN_INT ((rs6000_fpmem_offset >> 16) & 0xffff);
3674       output_asm_insn (\"{cau %0,%2(%1)|addis %0,%1,%2}\", xop);
3675     }
3676   else if (rs6000_fpmem_offset < 0)
3677     abort ();
3678
3679   return \"\";
3680 }"
3681   [(set_attr "length" "4")])
3682
3683 (define_insn "*floatsidf2_store1"
3684   [(set (reg:DF 76)
3685         (unspec [(match_operand:SI 0 "gpc_reg_operand" "r")
3686                  (match_operand:SI 1 "gpc_reg_operand" "r")] 12))]
3687   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3688   "*
3689 {
3690   rtx indx;
3691
3692   if (rs6000_fpmem_offset > 32760)
3693     indx = operands[1];
3694   else if (frame_pointer_needed)
3695     indx = frame_pointer_rtx;
3696   else
3697     indx = stack_pointer_rtx;
3698
3699   operands[2] = gen_rtx (MEM, SImode,
3700                          gen_rtx (PLUS, Pmode,
3701                                   indx,
3702                                   GEN_INT ((rs6000_fpmem_offset & 0xffff)
3703                                            + ((WORDS_BIG_ENDIAN != 0) * 4))));
3704
3705   return \"{st|stw} %0,%2\";
3706 }"
3707   [(set_attr "type" "store")])
3708
3709 (define_insn "*floatsidf2_store2"
3710   [(set (reg:DF 76)
3711         (unspec [(match_operand:SI 0 "gpc_reg_operand" "r")
3712                  (match_operand:SI 1 "gpc_reg_operand" "r")
3713                  (reg:DF 76)] 13))]
3714   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3715   "*
3716 {
3717   rtx indx;
3718
3719   if (rs6000_fpmem_offset > 32760)
3720     indx = operands[1];
3721   else if (frame_pointer_needed)
3722     indx = frame_pointer_rtx;
3723   else
3724     indx = stack_pointer_rtx;
3725
3726   operands[2] = gen_rtx (MEM, SImode,
3727                          gen_rtx (PLUS, Pmode,
3728                                   indx,
3729                                   GEN_INT ((rs6000_fpmem_offset & 0xffff)
3730                                            + ((WORDS_BIG_ENDIAN == 0) * 4))));
3731
3732   return \"{st|stw} %0,%2\";
3733 }"
3734   [(set_attr "type" "store")])
3735
3736 (define_insn "*floatsidf2_load"
3737   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3738         (unspec [(reg:DF 76)
3739                  (match_operand:SI 1 "gpc_reg_operand" "b")] 14))]
3740   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3741   "*
3742 {
3743   rtx indx;
3744
3745   if (rs6000_fpmem_offset > 32760)
3746     indx = operands[1];
3747   else if (frame_pointer_needed)
3748     indx = frame_pointer_rtx;
3749   else
3750     indx = stack_pointer_rtx;
3751
3752   operands[2] = gen_rtx (MEM, SImode,
3753                          gen_rtx (PLUS, Pmode,
3754                                   indx,
3755                                   GEN_INT (rs6000_fpmem_offset)));
3756
3757   return \"lfd %0,%2\";
3758 }"
3759   [(set_attr "type" "fpload")])
3760
3761 (define_expand "fix_truncdfsi2"
3762   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
3763                    (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
3764               (clobber (match_dup 2))
3765               (clobber (match_dup 3))
3766               (clobber (match_dup 4))])]
3767   "TARGET_HARD_FLOAT"
3768   "
3769 {
3770   if (!TARGET_POWER2 && !TARGET_POWERPC)
3771     {
3772       emit_insn (gen_trunc_call (operands[0], operands[1],
3773                                  gen_rtx (SYMBOL_REF, Pmode, RS6000_ITRUNC)));
3774       DONE;
3775     }
3776
3777   operands[2] = gen_reg_rtx (DImode);
3778   operands[3] = gen_reg_rtx (Pmode);
3779   operands[4] = gen_rtx (REG, DImode, FPMEM_REGNUM);
3780 }")
3781
3782 (define_insn "*fix_truncdfsi2_internal"
3783   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3784         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
3785    (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
3786    (clobber (match_operand:SI 3 "gpc_reg_operand" "=b"))
3787    (clobber (reg:DI 76))]
3788   "TARGET_HARD_FLOAT"
3789   "#"
3790   [(set_attr "length" "12")])
3791
3792 (define_split
3793   [(set (match_operand:SI 0 "gpc_reg_operand" "")
3794         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
3795    (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
3796    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))
3797    (clobber (reg:DI 76))]
3798   "TARGET_HARD_FLOAT"
3799   [(set (match_dup 2)
3800         (sign_extend:DI (fix:SI (match_operand:DF 1 "gpc_reg_operand" ""))))
3801    (set (match_dup 3)
3802         (unspec [(const_int 0)] 11))
3803    (set (match_dup 4)
3804         (unspec [(match_dup 2)
3805                  (match_dup 3)] 15))
3806    (set (match_operand:SI 0 "gpc_reg_operand" "")
3807         (unspec [(match_dup 4)
3808                  (match_dup 3)] 16))]
3809   "operands[4] = gen_rtx (REG, DImode, FPMEM_REGNUM);")
3810
3811 (define_insn "*fctiwz"
3812   [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
3813         (sign_extend:DI (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))))]
3814   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
3815   "{fcirz|fctiwz} %0,%1"
3816   [(set_attr "type" "fp")])
3817
3818 (define_insn "*fix_truncdfsi2_store"
3819   [(set (reg:DI 76)
3820         (unspec [(match_operand:DI 0 "gpc_reg_operand" "f")
3821                  (match_operand:SI 1 "gpc_reg_operand" "b")] 15))]
3822   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
3823   "*
3824 {
3825   rtx indx;
3826
3827   if (rs6000_fpmem_offset > 32760)
3828     indx = operands[1];
3829   else if (frame_pointer_needed)
3830     indx = frame_pointer_rtx;
3831   else
3832     indx = stack_pointer_rtx;
3833
3834   operands[2] = gen_rtx (MEM, DFmode,
3835                          gen_rtx (PLUS, Pmode,
3836                                   indx,
3837                                   GEN_INT ((rs6000_fpmem_offset & 0xffff))));
3838
3839   return \"stfd %0,%2\";
3840 }"
3841   [(set_attr "type" "fpstore")])
3842
3843 (define_insn "*fix_truncdfsi2_load"
3844   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3845         (unspec [(reg:DI 76)
3846                  (match_operand:SI 1 "gpc_reg_operand" "b")] 16))]
3847   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
3848   "*
3849 {
3850   rtx indx;
3851
3852   if (rs6000_fpmem_offset > 32760)
3853     indx = operands[1];
3854   else if (frame_pointer_needed)
3855     indx = frame_pointer_rtx;
3856   else
3857     indx = stack_pointer_rtx;
3858
3859   operands[2] = gen_rtx (MEM, DFmode,
3860                          gen_rtx (PLUS, Pmode,
3861                                   indx,
3862                                   GEN_INT ((rs6000_fpmem_offset & 0xffff)
3863                                            + ((WORDS_BIG_ENDIAN) ? 4 : 0))));
3864
3865   return \"{l|lwz} %0,%2\";
3866 }"
3867   [(set_attr "type" "load")])
3868
3869 (define_expand "fixuns_truncdfsi2"
3870   [(set (match_operand:SI 0 "gpc_reg_operand" "")
3871         (unsigned_fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))]
3872   "! TARGET_POWER2 && ! TARGET_POWERPC && TARGET_HARD_FLOAT"
3873   "
3874 {
3875   emit_insn (gen_trunc_call (operands[0], operands[1],
3876                              gen_rtx (SYMBOL_REF, Pmode, RS6000_UITRUNC)));
3877   DONE;
3878 }")
3879
3880 (define_expand "trunc_call"
3881   [(parallel [(set (match_operand:SI 0 "" "")
3882                    (fix:SI (match_operand:DF 1 "" "")))
3883               (use (match_operand:SI 2 "" ""))])]
3884   "TARGET_HARD_FLOAT"
3885   "
3886 {
3887   rtx insns = gen_trunc_call_rtl (operands[0], operands[1], operands[2]);
3888   rtx first = XVECEXP (insns, 0, 0);
3889   rtx last = XVECEXP (insns, 0, XVECLEN (insns, 0) - 1);
3890
3891   REG_NOTES (first) = gen_rtx (INSN_LIST, REG_LIBCALL, last,
3892                                REG_NOTES (first));
3893   REG_NOTES (last) = gen_rtx (INSN_LIST, REG_RETVAL, first, REG_NOTES (last));
3894
3895   emit_insn (insns);
3896   DONE;
3897 }")
3898
3899 (define_expand "trunc_call_rtl"
3900   [(set (reg:DF 33) (match_operand:DF 1 "gpc_reg_operand" ""))
3901    (use (reg:DF 33))
3902    (parallel [(set (reg:SI 3)
3903                    (call (mem:SI (match_operand 2 "" "")) (const_int 0)))
3904               (use (const_int 0))
3905               (clobber (scratch:SI))])
3906    (set (match_operand:SI 0 "gpc_reg_operand" "")
3907         (reg:SI 3))]
3908   "TARGET_HARD_FLOAT"
3909   "
3910 {
3911   rs6000_trunc_used = 1;
3912 }")
3913
3914 (define_insn "floatdidf2"
3915   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
3916         (float:DF (match_operand:DI 1 "gpc_reg_operand" "f")))]
3917   "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3918   "fcfid %0,%1"
3919   [(set_attr "type" "fp")])
3920
3921 (define_insn "fix_truncdfdi2"
3922   [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
3923         (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
3924   "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
3925   "fctidz %0,%1"
3926   [(set_attr "type" "fp")])
3927 \f
3928 ;; Define the DImode operations that can be done in a small number
3929 ;; of instructions.  The & constraints are to prevent the register
3930 ;; allocator from allocating registers that overlap with the inputs
3931 ;; (for example, having an input in 7,8 and an output in 6,7).  We
3932 ;; also allow for the the output being the same as one of the inputs.
3933
3934 (define_insn "*adddi3_noppc64"
3935   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
3936         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
3937                  (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
3938   "! TARGET_POWERPC64"
3939   "*
3940 {
3941   if (WORDS_BIG_ENDIAN)
3942     return (GET_CODE (operands[2])) != CONST_INT
3943             ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
3944             : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
3945   else
3946     return (GET_CODE (operands[2])) != CONST_INT
3947             ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
3948             : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
3949 }"
3950   [(set_attr "length" "8")])
3951
3952 (define_insn "*subdi3_noppc64"
3953   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
3954         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
3955                   (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
3956   "! TARGET_POWERPC64"
3957   "*
3958 {
3959   if (WORDS_BIG_ENDIAN)
3960     return (GET_CODE (operands[1]) != CONST_INT)
3961             ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
3962             : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
3963   else
3964     return (GET_CODE (operands[1]) != CONST_INT)
3965             ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
3966             : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
3967 }"
3968   [(set_attr "length" "8")])
3969
3970 (define_insn "*negdi2_noppc64"
3971   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
3972         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
3973   "! TARGET_POWERPC64"
3974   "*
3975 {
3976   return (WORDS_BIG_ENDIAN)
3977     ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
3978     : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
3979 }"
3980   [(set_attr "length" "8")])
3981
3982 (define_expand "mulsidi3"
3983   [(set (match_operand:DI 0 "gpc_reg_operand" "")
3984         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
3985                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
3986   ""
3987   "
3988 {
3989   if (! TARGET_POWER && ! TARGET_POWERPC)
3990     {
3991       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
3992       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
3993       emit_insn (gen_mull_call ());
3994       if (WORDS_BIG_ENDIAN)
3995         emit_move_insn (operands[0], gen_rtx (REG, DImode, 3));
3996       else
3997         {
3998           emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
3999                           gen_rtx (REG, SImode, 3));
4000           emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
4001                           gen_rtx (REG, SImode, 4));
4002         }
4003       DONE;
4004     }
4005   else if (TARGET_POWER)
4006     {
4007       emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
4008       DONE;
4009     }
4010 }")
4011
4012 (define_insn "mulsidi3_mq"
4013   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4014         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
4015                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
4016    (clobber (match_scratch:SI 3 "=q"))]
4017   "TARGET_POWER"
4018   "mul %0,%1,%2\;mfmq %L0"
4019   [(set_attr "type" "imul")
4020    (set_attr "length" "8")])
4021
4022 (define_insn "*mulsidi3_powerpc"
4023   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
4024         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
4025                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
4026   "TARGET_POWERPC && ! TARGET_POWERPC64"
4027   "*
4028 {
4029   return (WORDS_BIG_ENDIAN)
4030     ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
4031     : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
4032 }"
4033   [(set_attr "type" "imul")
4034    (set_attr "length" "8")])
4035
4036 (define_split
4037   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4038         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
4039                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
4040   "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
4041   [(set (match_dup 3)
4042         (truncate:SI
4043          (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
4044                                (sign_extend:DI (match_dup 2)))
4045                       (const_int 32))))
4046    (set (match_dup 4)
4047         (mult:SI (match_dup 1)
4048                  (match_dup 2)))]
4049   "
4050 {
4051   int endian = (WORDS_BIG_ENDIAN == 0);
4052   operands[3] = operand_subword (operands[0], endian, 0, DImode);
4053   operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
4054 }")
4055
4056 (define_insn "umulsidi3"
4057   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
4058         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
4059                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
4060   "TARGET_POWERPC && ! TARGET_POWERPC64"
4061   "*
4062 {
4063   return (WORDS_BIG_ENDIAN)
4064     ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
4065     : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
4066 }"
4067   [(set_attr "type" "imul")
4068    (set_attr "length" "8")])
4069
4070 (define_split
4071   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4072         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
4073                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
4074   "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
4075   [(set (match_dup 3)
4076         (truncate:SI
4077          (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
4078                                (zero_extend:DI (match_dup 2)))
4079                       (const_int 32))))
4080    (set (match_dup 4)
4081         (mult:SI (match_dup 1)
4082                  (match_dup 2)))]
4083   "
4084 {
4085   int endian = (WORDS_BIG_ENDIAN == 0);
4086   operands[3] = operand_subword (operands[0], endian, 0, DImode);
4087   operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
4088 }")
4089
4090 (define_expand "smulsi3_highpart"
4091   [(set (match_operand:SI 0 "gpc_reg_operand" "")
4092         (truncate:SI
4093          (lshiftrt:DI (mult:DI (sign_extend:DI
4094                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
4095                                (sign_extend:DI
4096                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
4097                       (const_int 32))))]
4098   ""
4099   "
4100 {
4101   if (! TARGET_POWER && ! TARGET_POWERPC)
4102     {
4103       emit_move_insn (gen_rtx (REG, SImode, 3), operands[1]);
4104       emit_move_insn (gen_rtx (REG, SImode, 4), operands[2]);
4105       emit_insn (gen_mulh_call ());
4106       emit_move_insn (operands[0], gen_rtx (REG, SImode, 3));
4107       DONE;
4108     }
4109   else if (TARGET_POWER)
4110     {
4111       emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
4112       DONE;
4113     }
4114 }")
4115
4116 (define_insn "smulsi3_highpart_mq"
4117   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4118         (truncate:SI
4119          (lshiftrt:DI (mult:DI (sign_extend:DI
4120                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
4121                                (sign_extend:DI
4122                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
4123                       (const_int 32))))
4124    (clobber (match_scratch:SI 3 "=q"))]
4125   "TARGET_POWER"
4126   "mul %0,%1,%2"
4127   [(set_attr "type" "imul")])
4128
4129 (define_insn ""
4130   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4131         (truncate:SI
4132          (lshiftrt:DI (mult:DI (sign_extend:DI
4133                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
4134                                (sign_extend:DI
4135                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
4136                       (const_int 32))))]
4137   "TARGET_POWERPC"
4138   "mulhw %0,%1,%2"
4139   [(set_attr "type" "imul")])
4140
4141 (define_insn "umulsi3_highpart"
4142   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4143         (truncate:SI
4144          (lshiftrt:DI (mult:DI (zero_extend:DI
4145                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
4146                                (zero_extend:DI
4147                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
4148                       (const_int 32))))]
4149   "TARGET_POWERPC"
4150   "mulhwu %0,%1,%2"
4151   [(set_attr "type" "imul")])
4152
4153 ;; If operands 0 and 2 are in the same register, we have a problem.  But
4154 ;; operands 0 and 1 (the usual case) can be in the same register.  That's
4155 ;; why we have the strange constraints below.
4156 (define_insn "ashldi3_power"
4157   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
4158         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
4159                    (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
4160    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
4161   "TARGET_POWER"
4162   "@
4163    {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
4164    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
4165    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
4166    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
4167   [(set_attr "length" "8")])
4168
4169 (define_insn "lshrdi3_power"
4170   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r,r,&r")
4171         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
4172                      (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
4173    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
4174   "TARGET_POWER"
4175   "@
4176    {cal %0,0(0)|li %0,0}\;{s%A2i|s%A2wi} %L0,%1,%h2
4177    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
4178    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
4179    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
4180   [(set_attr "length" "8")])
4181
4182 ;; Shift by a variable amount is too complex to be worth open-coding.  We
4183 ;; just handle shifts by constants.
4184 (define_insn "ashrdi3_power"
4185   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
4186         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
4187                      (match_operand:SI 2 "const_int_operand" "M,i")))
4188    (clobber (match_scratch:SI 3 "=X,q"))]
4189   "TARGET_POWER"
4190   "@
4191    {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
4192    sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
4193   [(set_attr "length" "8")])
4194 \f
4195 ;; PowerPC64 DImode operations.
4196
4197 (define_expand "adddi3"
4198   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4199         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
4200                  (match_operand:DI 2 "add_operand" "")))]
4201   ""
4202   "
4203 {
4204   if (! TARGET_POWERPC64 && non_add_cint_operand (operands[2], DImode))
4205     FAIL;
4206 }")
4207
4208 ;; Discourage ai/addic because of carry but provide it in an alternative
4209 ;; allowing register zero as source.
4210
4211 (define_insn ""
4212   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,?r,r")
4213         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,b,r,b")
4214                  (match_operand:DI 2 "add_operand" "r,I,I,J")))]
4215   "TARGET_POWERPC64"
4216   "@
4217    add %0,%1,%2
4218    addi %0,%1,%2
4219    addic %0,%1,%2
4220    addis %0,%1,%v2")
4221
4222 (define_insn ""
4223   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
4224         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
4225                              (match_operand:DI 2 "reg_or_short_operand" "r,I"))
4226                     (const_int 0)))
4227    (clobber (match_scratch:DI 3 "=r,r"))]
4228   "TARGET_POWERPC64"
4229   "@
4230    add. %3,%1,%2
4231    addic. %3,%1,%2"
4232   [(set_attr "type" "compare")])
4233
4234 (define_insn ""
4235   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
4236         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
4237                              (match_operand:DI 2 "reg_or_short_operand" "r,I"))
4238                     (const_int 0)))
4239    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
4240         (plus:DI (match_dup 1) (match_dup 2)))]
4241   "TARGET_POWERPC64"
4242   "@
4243    add. %0,%1,%2
4244    addic. %0,%1,%2"
4245   [(set_attr "type" "compare")])
4246
4247 ;; Split an add that we can't do in one insn into two insns, each of which
4248 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
4249 ;; add should be last in case the result gets used in an address.
4250
4251 (define_split
4252   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4253         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
4254                  (match_operand:DI 2 "non_add_cint_operand" "")))]
4255   "TARGET_POWERPC64"
4256   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
4257    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
4258 "
4259 {
4260   HOST_WIDE_INT low = INTVAL (operands[2]) & 0xffff;
4261   HOST_WIDE_INT high = INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff);
4262
4263   if (low & 0x8000)
4264     high+=0x10000, low |= ((HOST_WIDE_INT) -1) << 16;
4265
4266   operands[3] = GEN_INT (high);
4267   operands[4] = GEN_INT (low);
4268 }")
4269
4270 (define_insn "one_cmpldi2"
4271   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4272         (not:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
4273   "TARGET_POWERPC64"
4274   "nor %0,%1,%1")
4275
4276 (define_insn ""
4277   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4278         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4279                     (const_int 0)))
4280    (clobber (match_scratch:DI 2 "=r"))]
4281   "TARGET_POWERPC64"
4282   "nor. %2,%1,%1"
4283   [(set_attr "type" "compare")])
4284
4285 (define_insn ""
4286   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
4287         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4288                     (const_int 0)))
4289    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4290         (not:DI (match_dup 1)))]
4291   "TARGET_POWERPC64"
4292   "nor. %0,%1,%1"
4293   [(set_attr "type" "compare")])
4294
4295 (define_insn ""
4296   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
4297         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
4298                   (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
4299   "TARGET_POWERPC64"
4300   "@
4301    subf %0,%2,%1
4302    subfic %0,%2,%1")
4303
4304 (define_insn ""
4305   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4306         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4307                               (match_operand:DI 2 "gpc_reg_operand" "r"))
4308                     (const_int 0)))
4309    (clobber (match_scratch:DI 3 "=r"))]
4310   "TARGET_POWERPC64"
4311   "subf. %3,%2,%1"
4312   [(set_attr "type" "compare")])
4313
4314 (define_insn ""
4315   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4316         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4317                               (match_operand:DI 2 "gpc_reg_operand" "r"))
4318                     (const_int 0)))
4319    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4320         (minus:DI (match_dup 1) (match_dup 2)))]
4321   "TARGET_POWERPC64"
4322   "subf. %0,%2,%1"
4323   [(set_attr "type" "compare")])
4324
4325 (define_expand "subdi3"
4326   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4327         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "")
4328                   (match_operand:DI 2 "reg_or_cint_operand" "")))]
4329   ""
4330   "
4331 {
4332   if (GET_CODE (operands[2]) == CONST_INT)
4333     {
4334       emit_insn (gen_adddi3 (operands[0], operands[1],
4335                              negate_rtx (DImode, operands[2])));
4336       DONE;
4337     }
4338 }")
4339
4340 (define_insn "absdi2"
4341   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
4342         (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
4343    (clobber (match_scratch:DI 2 "=&r,&r"))]
4344   "TARGET_POWERPC64"
4345   "sradi %2,%1,31\;xor %0,%2,%1\;subf %0,%2,%0"
4346   [(set_attr "length" "12")])
4347
4348 (define_split
4349   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
4350         (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
4351    (clobber (match_scratch:DI 2 "=&r,&r"))]
4352   "TARGET_POWERPC64 && reload_completed"
4353   [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 31)))
4354    (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
4355    (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
4356   "")
4357
4358 (define_insn ""
4359   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
4360         (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
4361    (clobber (match_scratch:DI 2 "=&r,&r"))]
4362   "TARGET_POWERPC64"
4363   "sradi %2,%1,31\;xor %0,%2,%1\;subf %0,%0,%2"
4364   [(set_attr "length" "12")])
4365
4366 (define_split
4367   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
4368         (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
4369    (clobber (match_scratch:DI 2 "=&r,&r"))]
4370   "TARGET_POWERPC64 && reload_completed"
4371   [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 31)))
4372    (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
4373    (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
4374   "")
4375
4376 (define_expand "negdi2"
4377   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4378         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "")))]
4379   ""
4380   "")
4381
4382 (define_insn ""
4383   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4384         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
4385   "TARGET_POWERPC64"
4386   "neg %0,%1")
4387
4388 (define_insn ""
4389   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4390         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4391                     (const_int 0)))
4392    (clobber (match_scratch:DI 2 "=r"))]
4393   "TARGET_POWERPC64"
4394   "neg. %2,%1"
4395   [(set_attr "type" "compare")])
4396
4397 (define_insn ""
4398   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
4399         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4400                     (const_int 0)))
4401    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4402         (neg:DI (match_dup 1)))]
4403   "TARGET_POWERPC64"
4404   "neg. %0,%1"
4405   [(set_attr "type" "compare")])
4406
4407 (define_insn "ffsdi2"
4408   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
4409         (ffs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
4410   "TARGET_POWERPC64"
4411   "neg %0,%1\;and %0,%0,%1\;cntlzd %0,%0\;subfic %0,%0,64"
4412   [(set_attr "length" "16")])
4413
4414 (define_insn "muldi3"
4415   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4416         (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4417                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
4418   "TARGET_POWERPC64"
4419   "mulld %0,%1,%2"
4420    [(set_attr "type" "imul")])
4421
4422 (define_insn "smuldi3_highpart"
4423   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4424         (truncate:DI
4425          (lshiftrt:TI (mult:TI (sign_extend:TI
4426                                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
4427                                (sign_extend:TI
4428                                 (match_operand:DI 2 "gpc_reg_operand" "r")))
4429                       (const_int 64))))]
4430   "TARGET_POWERPC64"
4431   "mulhd %0,%1,%2"
4432   [(set_attr "type" "imul")])
4433
4434 (define_insn "umuldi3_highpart"
4435   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4436         (truncate:DI
4437          (lshiftrt:TI (mult:TI (zero_extend:TI
4438                                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
4439                                (zero_extend:TI
4440                                 (match_operand:DI 2 "gpc_reg_operand" "r")))
4441                       (const_int 64))))]
4442   "TARGET_POWERPC64"
4443   "mulhdu %0,%1,%2"
4444   [(set_attr "type" "imul")])
4445
4446 (define_expand "divdi3"
4447   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4448         (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
4449                 (match_operand:DI 2 "reg_or_cint_operand" "")))]
4450   "TARGET_POWERPC64"
4451   "
4452 {
4453   if (GET_CODE (operands[2]) == CONST_INT
4454       && exact_log2 (INTVAL (operands[2])) >= 0)
4455     ;
4456   else
4457     operands[2] = force_reg (DImode, operands[2]);
4458 }")
4459
4460 (define_expand "moddi3"
4461   [(use (match_operand:DI 0 "gpc_reg_operand" ""))
4462    (use (match_operand:DI 1 "gpc_reg_operand" ""))
4463    (use (match_operand:DI 2 "reg_or_cint_operand" ""))]
4464   "TARGET_POWERPC64"
4465   "
4466 {
4467   int i = exact_log2 (INTVAL (operands[2]));
4468   rtx temp1;
4469   rtx temp2;
4470
4471   if (GET_CODE (operands[2]) != CONST_INT || i < 0)
4472     FAIL;
4473
4474   temp1 = gen_reg_rtx (DImode);
4475   temp2 = gen_reg_rtx (DImode);
4476
4477   emit_insn (gen_divdi3 (temp1, operands[1], operands[2]));
4478   emit_insn (gen_ashldi3 (temp2, temp1, GEN_INT (i)));
4479   emit_insn (gen_subdi3 (operands[0], operands[1], temp2));
4480   DONE;
4481 }")
4482
4483 (define_insn ""
4484   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4485         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4486                 (match_operand:DI 2 "const_int_operand" "N")))]
4487   "TARGET_POWERPC64 && exact_log2 (INTVAL (operands[2])) >= 0"
4488   "sradi %0,%1,%p2\;addze %0,%0"
4489   [(set_attr "length" "8")])
4490
4491 (define_insn ""
4492   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4493         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4494                             (match_operand:DI 2 "const_int_operand" "N"))
4495                     (const_int 0)))
4496    (clobber (match_scratch:DI 3 "=r"))]
4497   "TARGET_POWERPC64 && exact_log2 (INTVAL (operands[2])) >= 0"
4498   "sradi %3,%1,%p2\;addze. %3,%3"
4499   [(set_attr "type" "compare")
4500    (set_attr "length" "8")])
4501
4502 (define_insn ""
4503   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4504         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4505                             (match_operand:DI 2 "const_int_operand" "N"))
4506                     (const_int 0)))
4507    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4508         (div:DI (match_dup 1) (match_dup 2)))]
4509   "TARGET_POWERPC64 && exact_log2 (INTVAL (operands[2])) >= 0"
4510   "sradi %0,%1,%p2\;addze. %0,%0"
4511   [(set_attr "type" "compare")
4512    (set_attr "length" "8")])
4513
4514 (define_insn ""
4515   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4516         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4517                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
4518   "TARGET_POWERPC64"
4519   "divd %0,%1,%2"
4520   [(set_attr "type" "idiv")])
4521
4522 (define_insn "udivdi3"
4523   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4524         (udiv:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4525                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
4526   "TARGET_POWERPC64"
4527   "divdu %0,%1,%2"
4528   [(set_attr "type" "idiv")])
4529
4530 (define_insn "rotldi3"
4531   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4532         (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4533                    (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
4534   "TARGET_POWERPC64"
4535   "rld%I2cl %0,%1,%H2,0")
4536
4537 (define_insn ""
4538   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4539         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4540                                (match_operand:DI 2 "reg_or_cint_operand" "ri"))
4541                     (const_int 0)))
4542    (clobber (match_scratch:DI 3 "=r"))]
4543   "TARGET_POWERPC64"
4544   "rld%I2cl. %3,%1,%H2,0"
4545   [(set_attr "type" "delayed_compare")])
4546
4547 (define_insn ""
4548   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4549         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4550                                (match_operand:DI 2 "reg_or_cint_operand" "ri"))
4551                     (const_int 0)))
4552    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4553         (rotate:DI (match_dup 1) (match_dup 2)))]
4554   "TARGET_POWERPC64"
4555   "rld%I2cl. %0,%1,%H2,0"
4556   [(set_attr "type" "delayed_compare")])
4557
4558 (define_expand "ashldi3"
4559   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4560         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
4561                    (match_operand:SI 2 "reg_or_cint_operand" "")))]
4562   "TARGET_POWERPC64 || TARGET_POWER"
4563   "
4564 {
4565   if (TARGET_POWERPC64)
4566     ;
4567   else if (TARGET_POWER)
4568     {
4569       emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
4570       DONE;
4571     }
4572   else
4573     FAIL;
4574 }")
4575
4576 (define_insn ""
4577   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4578         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4579                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4580   "TARGET_POWERPC64"
4581   "sld%I2 %0,%1,%H2"
4582   [(set_attr "length" "8")])
4583   
4584 (define_insn ""
4585   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4586         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4587                                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4588                     (const_int 0)))
4589    (clobber (match_scratch:DI 3 "=r"))]
4590   "TARGET_POWERPC64"
4591   "sld%I2. %3,%1,%H2"
4592   [(set_attr "type" "delayed_compare")])
4593   
4594 (define_insn ""
4595   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4596         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4597                                (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4598                     (const_int 0)))
4599    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4600         (ashift:DI (match_dup 1) (match_dup 2)))]
4601   "TARGET_POWERPC64"
4602   "sld%I2. %0,%1,%H2"
4603   [(set_attr "type" "delayed_compare")])
4604
4605 (define_expand "lshrdi3"
4606   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4607         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
4608                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
4609   "TARGET_POWERPC64 || TARGET_POWER"
4610   "
4611 {
4612   if (TARGET_POWERPC64)
4613     ;
4614   else if (TARGET_POWER)
4615     {
4616       emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
4617       DONE;
4618     }
4619   else
4620     FAIL;
4621 }")
4622
4623 (define_insn ""
4624   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4625         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4626                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4627   "TARGET_POWERPC64"
4628   "srd%I2 %0,%1,%H2")
4629
4630 (define_insn ""
4631   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4632         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4633                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4634                     (const_int 0)))
4635    (clobber (match_scratch:DI 3 "=r"))]
4636   "TARGET_POWERPC64"
4637   "srd%I2. %3,%1,%H2"
4638   [(set_attr "type" "delayed_compare")])
4639
4640 (define_insn ""
4641   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4642         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4643                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4644                     (const_int 0)))
4645    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4646         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
4647   "TARGET_POWERPC64"
4648   "srd%I2. %0,%1,%H2"
4649   [(set_attr "type" "delayed_compare")])
4650
4651 (define_expand "ashrdi3"
4652   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4653         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
4654                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
4655   "TARGET_POWERPC64 || TARGET_POWER"
4656   "
4657 {
4658   if (TARGET_POWERPC64)
4659     ;
4660   else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
4661     {
4662       emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
4663       DONE;
4664     }
4665   else
4666     FAIL;
4667 }")
4668
4669 (define_insn ""
4670   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4671         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4672                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4673   "TARGET_POWERPC64"
4674   "srad%I2 %0,%1,%H2")
4675
4676 (define_insn ""
4677   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4678         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4679                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4680                     (const_int 0)))
4681    (clobber (match_scratch:DI 3 "=r"))]
4682   "TARGET_POWERPC64"
4683   "srad%I2. %3,%1,%H2"
4684   [(set_attr "type" "delayed_compare")])
4685
4686 (define_insn ""
4687   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4688         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
4689                                  (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4690                     (const_int 0)))
4691    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4692         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
4693   "TARGET_POWERPC64"
4694   "srad%I2. %0,%1,%H2"
4695   [(set_attr "type" "delayed_compare")])
4696
4697 (define_insn "anddi3"
4698   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
4699         (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4700                 (match_operand:DI 2 "and_operand" "?r,K,J")))
4701    (clobber (match_scratch:CC 3 "=X,x,x"))]
4702   "TARGET_POWERPC64"
4703   "@
4704    and %0,%1,%2
4705    andi. %0,%1,%b2
4706    andis. %0,%1,%u2")
4707
4708 (define_insn ""
4709   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x")
4710         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4711                             (match_operand:DI 2 "and_operand" "r,K,J"))
4712                     (const_int 0)))
4713    (clobber (match_scratch:DI 3 "=r,r,r"))]
4714   "TARGET_POWERPC64"
4715   "@
4716    and. %3,%1,%2
4717    andi. %3,%1,%b2
4718    andis. %3,%1,%u2"
4719   [(set_attr "type" "compare,compare,compare")])
4720
4721 (define_insn ""
4722   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x")
4723         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4724                             (match_operand:DI 2 "and_operand" "r,K,J"))
4725                     (const_int 0)))
4726    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
4727         (and:DI (match_dup 1) (match_dup 2)))]
4728   "TARGET_POWERPC64"
4729   "@
4730    and. %0,%1,%2
4731    andi. %0,%1,%b2
4732    andis. %0,%1,%u2"
4733   [(set_attr "type" "compare,compare,compare")])
4734
4735 ;; Take a AND with a constant that cannot be done in a single insn and try to
4736 ;; split it into two insns.  This does not verify that the insns are valid
4737 ;; since this need not be done as combine will do it.
4738
4739 (define_split
4740   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4741         (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
4742                 (match_operand:DI 2 "non_and_cint_operand" "")))]
4743   "TARGET_POWERPC64"
4744   [(set (match_dup 0) (and:DI (match_dup 1) (match_dup 3)))
4745    (set (match_dup 0) (and:DI (match_dup 0) (match_dup 4)))]
4746   "
4747 {
4748   int maskval = INTVAL (operands[2]);
4749   int i, transitions, last_bit_value;
4750   int orig = maskval, first_c = maskval, second_c;
4751
4752   /* We know that MASKVAL must have more than 2 bit-transitions.  Start at
4753      the low-order bit and count for the third transition.  When we get there,
4754      make a first mask that has everything to the left of that position
4755      a one.  Then make the second mask to turn off whatever else is needed.  */
4756
4757   for (i = 1, transitions = 0, last_bit_value = maskval & 1; i < 32; i++)
4758     {
4759       if (((maskval >>= 1) & 1) != last_bit_value)
4760         last_bit_value ^= 1, transitions++;
4761
4762       if (transitions > 2)
4763         {
4764           first_c |= (~0) << i;
4765           break;
4766         }
4767     }
4768
4769   second_c = orig | ~ first_c;
4770
4771   operands[3] = gen_rtx (CONST_INT, VOIDmode, first_c);
4772   operands[4] = gen_rtx (CONST_INT, VOIDmode, second_c);
4773 }")
4774
4775 (define_insn "iordi3"
4776   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
4777         (ior:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4778                 (match_operand:DI 2 "logical_operand" "r,K,J")))]
4779   "TARGET_POWERPC64"
4780   "@
4781    or %0,%1,%2
4782    ori %0,%1,%b2
4783    oris %0,%1,%u2")
4784
4785 (define_insn ""
4786   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4787         (compare:CC (ior:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4788                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4789                     (const_int 0)))
4790    (clobber (match_scratch:DI 3 "=r"))]
4791   "TARGET_POWERPC64"
4792   "or. %3,%1,%2"
4793   [(set_attr "type" "compare")])
4794
4795 (define_insn ""
4796   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4797         (compare:CC (ior:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4798                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4799                     (const_int 0)))
4800    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4801         (ior:DI (match_dup 1) (match_dup 2)))]
4802   "TARGET_POWERPC64"
4803   "or. %0,%1,%2"
4804   [(set_attr "type" "compare")])
4805
4806 ;; Split an IOR that we can't do in one insn into two insns, each of which
4807 ;; does one 16-bit part.  This is used by combine.
4808
4809 (define_split
4810   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4811         (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
4812                 (match_operand:DI 2 "non_logical_cint_operand" "")))]
4813   "TARGET_POWERPC64"
4814   [(set (match_dup 0) (ior:DI (match_dup 1) (match_dup 3)))
4815    (set (match_dup 0) (ior:DI (match_dup 0) (match_dup 4)))]
4816 "
4817 {
4818   operands[3] = gen_rtx (CONST_INT, VOIDmode,
4819                          INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
4820   operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
4821 }")
4822
4823 (define_insn "xordi3"
4824   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
4825         (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
4826                 (match_operand:DI 2 "logical_operand" "r,K,J")))]
4827   "TARGET_POWERPC64"
4828   "@
4829    xor %0,%1,%2
4830    xori %0,%1,%b2
4831    xoris %0,%1,%u2")
4832
4833 (define_insn ""
4834   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4835         (compare:CC (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4836                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4837                     (const_int 0)))
4838    (clobber (match_scratch:DI 3 "=r"))]
4839   "TARGET_POWERPC64"
4840   "xor. %3,%1,%2"
4841   [(set_attr "type" "compare")])
4842
4843 (define_insn ""
4844   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4845         (compare:CC (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4846                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4847                     (const_int 0)))
4848    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4849         (xor:DI (match_dup 1) (match_dup 2)))]
4850   "TARGET_POWERPC64"
4851   "xor. %0,%1,%2"
4852   [(set_attr "type" "compare")])
4853
4854 ;; Split an XOR that we can't do in one insn into two insns, each of which
4855 ;; does one 16-bit part.  This is used by combine.
4856
4857 (define_split
4858   [(set (match_operand:DI 0 "gpc_reg_operand" "")
4859         (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
4860                 (match_operand:DI 2 "non_logical_cint_operand" "")))]
4861   "TARGET_POWERPC64"
4862   [(set (match_dup 0) (xor:DI (match_dup 1) (match_dup 3)))
4863    (set (match_dup 0) (xor:DI (match_dup 0) (match_dup 4)))]
4864 "
4865 {
4866   operands[3] = gen_rtx (CONST_INT, VOIDmode,
4867                          INTVAL (operands[2]) & 0xffff0000);
4868   operands[4] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[2]) & 0xffff);
4869 }")
4870
4871 (define_insn ""
4872   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4873         (not:DI (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4874                         (match_operand:DI 2 "gpc_reg_operand" "r"))))]
4875    "TARGET_POWERPC64"
4876    "eqv %0,%1,%2")
4877
4878 (define_insn ""
4879   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4880         (compare:CC (not:DI (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4881                                     (match_operand:DI 2 "gpc_reg_operand" "r")))
4882                     (const_int 0)))
4883    (clobber (match_scratch:DI 3 "=r"))]
4884    "TARGET_POWERPC64"
4885    "eqv. %3,%1,%2"
4886    [(set_attr "type" "compare")])
4887
4888 (define_insn ""
4889   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4890         (compare:CC (not:DI (xor:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
4891                                     (match_operand:DI 2 "gpc_reg_operand" "r")))
4892                     (const_int 0)))
4893    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4894         (not:DI (xor:DI (match_dup 1) (match_dup 2))))]
4895    "TARGET_POWERPC64"
4896    "eqv. %0,%1,%2"
4897    [(set_attr "type" "compare")])
4898
4899 (define_insn ""
4900   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4901         (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4902                 (match_operand:DI 2 "gpc_reg_operand" "r")))]
4903   "TARGET_POWERPC64"
4904   "andc %0,%2,%1")
4905
4906 (define_insn ""
4907   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4908         (compare:CC (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4909                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4910                     (const_int 0)))
4911    (clobber (match_scratch:DI 3 "=r"))]
4912   "TARGET_POWERPC64"
4913   "andc. %3,%2,%1"
4914   [(set_attr "type" "compare")])
4915
4916 (define_insn ""
4917   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4918         (compare:CC (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4919                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4920                     (const_int 0)))
4921    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4922         (and:DI (not:DI (match_dup 1)) (match_dup 2)))]
4923   "TARGET_POWERPC64"
4924   "andc. %0,%2,%1"
4925   [(set_attr "type" "compare")])
4926
4927 (define_insn ""
4928   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4929         (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4930                 (match_operand:DI 2 "gpc_reg_operand" "r")))]
4931   "TARGET_POWERPC64"
4932   "orc %0,%2,%1")
4933
4934 (define_insn ""
4935   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4936         (compare:CC (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4937                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4938                     (const_int 0)))
4939    (clobber (match_scratch:DI 3 "=r"))]
4940   "TARGET_POWERPC64"
4941   "orc. %3,%2,%1"
4942   [(set_attr "type" "compare")])
4943
4944 (define_insn ""
4945   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4946         (compare:CC (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
4947                             (match_operand:DI 2 "gpc_reg_operand" "r"))
4948                     (const_int 0)))
4949    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4950         (ior:DI (not:DI (match_dup 1)) (match_dup 2)))]
4951   "TARGET_POWERPC64"
4952   "orc. %0,%2,%1"
4953   [(set_attr "type" "compare")])
4954
4955 (define_insn ""
4956   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4957         (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4958                 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))))]
4959   "TARGET_POWERPC64"
4960   "nand %0,%1,%2")
4961
4962 (define_insn ""
4963   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4964         (compare:CC (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4965                             (not:DI (match_operand:DI 2 "gpc_reg_operand" "r")))
4966                     (const_int 0)))
4967    (clobber (match_scratch:DI 3 "=r"))]
4968   "TARGET_POWERPC64"
4969   "nand. %3,%1,%2"
4970   [(set_attr "type" "compare")])
4971
4972 (define_insn ""
4973   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
4974         (compare:CC (ior:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4975                             (not:DI (match_operand:DI 2 "gpc_reg_operand" "r")))
4976                     (const_int 0)))
4977    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
4978         (ior:DI (not:DI (match_dup 1)) (not:DI (match_dup 2))))]
4979   "TARGET_POWERPC64"
4980   "nand. %0,%1,%2"
4981   [(set_attr "type" "compare")])
4982
4983 (define_insn ""
4984   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4985         (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4986                 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))))]
4987   "TARGET_POWERPC64"
4988   "nor %0,%1,%2")
4989
4990 (define_insn ""
4991   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
4992         (compare:CC (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
4993                             (not:DI (match_operand:DI 2 "gpc_reg_operand" "r")))
4994                     (const_int 0)))
4995    (clobber (match_scratch:DI 3 "=r"))]
4996   "TARGET_POWERPC64"
4997   "nor. %3,%1,%2"
4998   [(set_attr "type" "compare")])
4999
5000 (define_insn ""
5001   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
5002         (compare:CC (and:DI (not:DI (match_operand:DI 1 "gpc_reg_operand" "%r"))
5003                             (not:DI (match_operand:DI 2 "gpc_reg_operand" "r")))
5004                     (const_int 0)))
5005    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
5006         (and:DI (not:DI (match_dup 1)) (not:DI (match_dup 2))))]
5007   "TARGET_POWERPC64"
5008   "nor. %0,%1,%2"
5009   [(set_attr "type" "compare")])
5010 \f
5011 ;; Now define ways of moving data around.
5012
5013 ;; Elf specific ways of loading addresses for non-PIC code.
5014 ;; The output of this could be r0, but we limit it to base
5015 ;; registers, since almost all uses of this will need it
5016 ;; in a base register shortly.
5017 (define_insn "elf_high"
5018   [(set (match_operand:SI 0 "register_operand" "=b")
5019         (high:SI (match_operand 1 "" "")))]
5020   "TARGET_ELF && !TARGET_64BIT"
5021   "{cau|addis} %0,0,%1@ha")
5022
5023 (define_insn "elf_low"
5024   [(set (match_operand:SI 0 "register_operand" "=r")
5025         (lo_sum:SI (match_operand:SI 1 "register_operand" "b")
5026                    (match_operand 2 "" "")))]
5027    "TARGET_ELF && !TARGET_64BIT"
5028    "{cal %0,%a2@l(%1)|addi %0,%1,%2@l}")
5029
5030 ;; Set up a register with a value from the GOT table
5031
5032 (define_expand "movsi_got"
5033   [(set (match_operand:SI 0 "register_operand" "")
5034         (unspec [(match_operand:SI 1 "got_operand" "")
5035                  (match_dup 2)] 8))]
5036   "(DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS) && flag_pic"
5037   "
5038 {
5039   operands[2] = rs6000_got_register (operands[1]);
5040 }")
5041
5042 (define_insn "*movsi_got_internal"
5043   [(set (match_operand:SI 0 "register_operand" "=r")
5044         (unspec [(match_operand:SI 1 "got_operand" "")
5045                  (match_operand:SI 2 "register_operand" "b")] 8))]
5046   "(DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS) && flag_pic == 1"
5047   "{l|lwz} %0,%a1@got(%2)"
5048   [(set_attr "type" "load")])
5049
5050 ;; For SI, we special-case integers that can't be loaded in one insn.  We
5051 ;; do the load 16-bits at a time.  We could do this by loading from memory,
5052 ;; and this is even supposed to be faster, but it is simpler not to get
5053 ;; integers in the TOC.
5054 (define_expand "movsi"
5055   [(set (match_operand:SI 0 "general_operand" "")
5056         (match_operand:SI 1 "any_operand" ""))]
5057   ""
5058   "
5059 {
5060   if (GET_CODE (operands[0]) != REG)
5061     operands[1] = force_reg (SImode, operands[1]);
5062
5063   /* Convert a move of a CONST_DOUBLE into a CONST_INT */
5064   if (GET_CODE (operands[1]) == CONST_DOUBLE)
5065     operands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
5066
5067   /* Use default pattern for address of ELF small data */
5068   if (TARGET_ELF
5069       && (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS)
5070       && (GET_CODE (operands[1]) == SYMBOL_REF || GET_CODE (operands[1]) == CONST)
5071       && small_data_operand (operands[1], SImode))
5072     {
5073       emit_insn (gen_rtx (SET, VOIDmode, operands[0], operands[1]));
5074       DONE;
5075     }
5076
5077   if ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS)
5078       && flag_pic == 1 && got_operand (operands[1], SImode))
5079     {
5080       emit_insn (gen_movsi_got (operands[0], operands[1]));
5081       DONE;
5082     }
5083
5084   if (TARGET_ELF && TARGET_NO_TOC && !TARGET_64BIT
5085       && CONSTANT_P (operands[1])
5086       && GET_CODE (operands[1]) != HIGH
5087       && GET_CODE (operands[1]) != CONST_INT)
5088     {
5089       rtx target = (reload_completed || reload_in_progress)
5090                         ? operands[0] : gen_reg_rtx (SImode);
5091
5092       /* If this is a function address on -mcall-aixdesc or -mcall-nt,
5093          convert it to the address of the descriptor.  */
5094       if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)
5095           && GET_CODE (operands[1]) == SYMBOL_REF
5096           && XSTR (operands[1], 0)[0] == '.')
5097         {
5098           char *name = XSTR (operands[1], 0);
5099           rtx new_ref;
5100           while (*name == '.')
5101             name++;
5102           new_ref = gen_rtx (SYMBOL_REF, Pmode, name);
5103           CONSTANT_POOL_ADDRESS_P (new_ref) = CONSTANT_POOL_ADDRESS_P (operands[1]);
5104           SYMBOL_REF_FLAG (new_ref) = SYMBOL_REF_FLAG (operands[1]);
5105           SYMBOL_REF_USED (new_ref) = SYMBOL_REF_USED (operands[1]);
5106           operands[1] = new_ref;
5107         }
5108
5109       emit_insn (gen_elf_high (target, operands[1]));
5110       emit_insn (gen_elf_low (operands[0], target, operands[1]));
5111       DONE;
5112     }
5113
5114   if (GET_CODE (operands[1]) == CONST
5115       && DEFAULT_ABI == ABI_NT
5116       && !side_effects_p (operands[0]))
5117     {
5118       rtx const_term = const0_rtx;
5119       rtx sym = eliminate_constant_term (XEXP (operands[1], 0), &const_term);
5120       if (sym && GET_CODE (const_term) == CONST_INT
5121           && (GET_CODE (sym) == SYMBOL_REF || GET_CODE (sym) == LABEL_REF))
5122         {
5123           unsigned HOST_WIDE_INT value = INTVAL (const_term);
5124           int new_reg_p = (flag_expensive_optimizations
5125                            && !reload_completed
5126                            && !reload_in_progress);
5127           rtx tmp1 = (new_reg_p && value != 0) ? gen_reg_rtx (SImode) : operands[0];
5128
5129           emit_insn (gen_movsi (tmp1, sym));
5130           if (INTVAL (const_term) != 0)
5131             {
5132               if (value + 0x8000 < 0x10000)
5133                 emit_insn (gen_addsi3 (operands[0], tmp1, GEN_INT (value)));
5134
5135               else
5136                 {
5137                   HOST_WIDE_INT high_int = value & (~ (HOST_WIDE_INT) 0xffff);
5138                   HOST_WIDE_INT low_int = value & 0xffff;
5139                   rtx tmp2 = (!new_reg_p || !low_int) ? operands[0] : gen_reg_rtx (Pmode);
5140
5141                   if (low_int & 0x8000)
5142                     high_int += 0x10000, low_int |= ((HOST_WIDE_INT) -1) << 16;
5143
5144                   emit_insn (gen_addsi3 (tmp2, tmp1, GEN_INT (high_int)));
5145                   if (low_int)
5146                     emit_insn (gen_addsi3 (operands[0], tmp2, GEN_INT (low_int)));
5147                 }
5148             }
5149           DONE;
5150         }
5151       else
5152         fatal_insn (\"bad address\", operands[1]);
5153     }
5154
5155   if ((!TARGET_WINDOWS_NT || DEFAULT_ABI != ABI_NT)
5156       && CONSTANT_P (operands[1])
5157       && GET_CODE (operands[1]) != CONST_INT
5158       && GET_CODE (operands[1]) != HIGH
5159       && ! LEGITIMATE_CONSTANT_POOL_ADDRESS_P (operands[1]))
5160     {
5161       /* If we are to limit the number of things we put in the TOC and
5162          this is a symbol plus a constant we can add in one insn,
5163          just put the symbol in the TOC and add the constant.  Don't do
5164          this if reload is in progress.  */
5165       if (GET_CODE (operands[1]) == CONST
5166           && TARGET_NO_SUM_IN_TOC && ! reload_in_progress
5167           && GET_CODE (XEXP (operands[1], 0)) == PLUS
5168           && add_operand (XEXP (XEXP (operands[1], 0), 1), SImode)
5169           && (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF
5170               || GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == SYMBOL_REF)
5171           && ! side_effects_p (operands[0]))
5172         {
5173           rtx sym = force_const_mem (SImode, XEXP (XEXP (operands[1], 0), 0));
5174           rtx other = XEXP (XEXP (operands[1], 0), 1);
5175
5176           emit_insn (gen_addsi3 (operands[0], force_reg (SImode, sym), other));
5177           DONE;
5178         }
5179
5180       operands[1] = force_const_mem (SImode, operands[1]);
5181       if (! memory_address_p (SImode, XEXP (operands[1], 0))
5182           && ! reload_in_progress)
5183         operands[1] = change_address (operands[1], SImode,
5184                                       XEXP (operands[1], 0));
5185     }
5186 }")
5187
5188 (define_insn ""
5189   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,r,m,r,r,r,r,r,*q,*c*l,*h")
5190         (match_operand:SI 1 "input_operand" "r,S,T,U,m,r,I,J,n,R,*h,r,r,0"))]
5191   "gpc_reg_operand (operands[0], SImode)
5192    || gpc_reg_operand (operands[1], SImode)"
5193   "@
5194    mr %0,%1
5195    {l|lwz} %0,[toc]%1(2)
5196    {l|lwz} %0,[toc]%l1(2)
5197    {cal|la} %0,%a1
5198    {l%U1%X1|lwz%U1%X1} %0,%1
5199    {st%U0%X0|stw%U0%X0} %1,%0
5200    {lil|li} %0,%1
5201    {liu|lis} %0,%v1
5202    #
5203    {cal|la} %0,%1(%*)
5204    mf%1 %0
5205    mt%0 %1
5206    mt%0 %1
5207    cror 0,0,0"
5208   [(set_attr "type" "*,load,load,*,load,store,*,*,*,*,*,*,mtjmpr,*")
5209    (set_attr "length" "4,4,4,4,4,4,4,4,8,4,4,4,4,4")])
5210
5211 ;; Split a load of a large constant into the appropriate two-insn
5212 ;; sequence.
5213
5214 (define_split
5215   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5216         (match_operand:SI 1 "const_int_operand" ""))]
5217   "(unsigned) (INTVAL (operands[1]) + 0x8000) >= 0x10000
5218    && (INTVAL (operands[1]) & 0xffff) != 0"
5219   [(set (match_dup 0)
5220         (match_dup 2))
5221    (set (match_dup 0)
5222         (ior:SI (match_dup 0)
5223                 (match_dup 3)))]
5224   "
5225 {
5226   operands[2] = gen_rtx (CONST_INT, VOIDmode,
5227                          INTVAL (operands[1]) & 0xffff0000);
5228   operands[3] = gen_rtx (CONST_INT, VOIDmode, INTVAL (operands[1]) & 0xffff);
5229 }")
5230
5231 (define_insn ""
5232   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
5233         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
5234                     (const_int 0)))
5235    (set (match_operand:SI 0 "gpc_reg_operand" "=r") (match_dup 1))]
5236   ""
5237   "mr. %0,%1"
5238   [(set_attr "type" "compare")])
5239 \f
5240 (define_expand "movhi"
5241   [(set (match_operand:HI 0 "general_operand" "")
5242         (match_operand:HI 1 "any_operand" ""))]
5243   ""
5244   "
5245 {
5246   if (GET_CODE (operands[0]) != REG)
5247     operands[1] = force_reg (HImode, operands[1]);
5248
5249   if (CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != CONST_INT)
5250     {
5251       operands[1] = force_const_mem (HImode, operands[1]);
5252       if (! memory_address_p (HImode, XEXP (operands[1], 0))
5253           && ! reload_in_progress)
5254         operands[1] = change_address (operands[1], HImode,
5255                                       XEXP (operands[1], 0));
5256     }
5257 }")
5258
5259 (define_insn ""
5260   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
5261         (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
5262   "gpc_reg_operand (operands[0], HImode)
5263    || gpc_reg_operand (operands[1], HImode)"
5264   "@
5265    mr %0,%1
5266    lhz%U1%X1 %0,%1
5267    sth%U0%X0 %1,%0
5268    {lil|li} %0,%w1
5269    mf%1 %0
5270    mt%0 %1
5271    mt%0 %1
5272    cror 0,0,0"
5273   [(set_attr "type" "*,load,store,*,*,*,mtjmpr,*")])
5274
5275 (define_expand "movqi"
5276   [(set (match_operand:QI 0 "general_operand" "")
5277         (match_operand:QI 1 "any_operand" ""))]
5278   ""
5279   "
5280 {
5281   if (GET_CODE (operands[0]) != REG)
5282     operands[1] = force_reg (QImode, operands[1]);
5283
5284   if (CONSTANT_P (operands[1]) && GET_CODE (operands[1]) != CONST_INT)
5285     {
5286       operands[1] = force_const_mem (QImode, operands[1]);
5287       if (! memory_address_p (QImode, XEXP (operands[1], 0))
5288           && ! reload_in_progress)
5289         operands[1] = change_address (operands[1], QImode,
5290                                       XEXP (operands[1], 0));
5291     }
5292 }")
5293
5294 (define_insn ""
5295   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
5296         (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
5297   "gpc_reg_operand (operands[0], QImode)
5298    || gpc_reg_operand (operands[1], QImode)"
5299   "@
5300    mr %0,%1
5301    lbz%U1%X1 %0,%1
5302    stb%U0%X0 %1,%0
5303    {lil|li} %0,%1
5304    mf%1 %0
5305    mt%0 %1
5306    mt%0 %1
5307    cror 0,0,0"
5308   [(set_attr "type" "*,load,store,*,*,*,mtjmpr,*")])
5309 \f
5310 ;; Here is how to move condition codes around.  When we store CC data in
5311 ;; an integer register or memory, we store just the high-order 4 bits.
5312 ;; This lets us not shift in the most common case of CR0.
5313 (define_expand "movcc"
5314   [(set (match_operand:CC 0 "nonimmediate_operand" "")
5315         (match_operand:CC 1 "nonimmediate_operand" ""))]
5316   ""
5317   "")
5318
5319 (define_insn ""
5320   [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,y,r,r,r,r,m")
5321         (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,m,r"))]
5322   "register_operand (operands[0], CCmode)
5323    || register_operand (operands[1], CCmode)"
5324   "@
5325    mcrf %0,%1
5326    mtcrf 128,%1
5327    {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
5328    mfcr %0
5329    mfcr %0\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
5330    mr %0,%1
5331    {l%U1%X1|lwz%U1%X1} %0,%1
5332    {st%U0%U1|stw%U0%U1} %1,%0"
5333   [(set_attr "type" "*,*,*,compare,*,*,load,store")
5334    (set_attr "length" "*,*,12,*,8,*,*,*")])
5335 \f
5336 ;; For floating-point, we normally deal with the floating-point registers
5337 ;; unless -msoft-float is used.  The sole exception is that parameter passing
5338 ;; can produce floating-point values in fixed-point registers.  Unless the
5339 ;; value is a simple constant or already in memory, we deal with this by
5340 ;; allocating memory and copying the value explicitly via that memory location.
5341 (define_expand "movsf"
5342   [(set (match_operand:SF 0 "nonimmediate_operand" "")
5343         (match_operand:SF 1 "any_operand" ""))]
5344   ""
5345   "
5346 {
5347   /* If we are called from reload, we might be getting a SUBREG of a hard
5348      reg.  So expand it.  */
5349   if (GET_CODE (operands[0]) == SUBREG
5350       && GET_CODE (SUBREG_REG (operands[0])) == REG
5351       && REGNO (SUBREG_REG (operands[0])) < FIRST_PSEUDO_REGISTER)
5352     operands[0] = alter_subreg (operands[0]);
5353   if (GET_CODE (operands[1]) == SUBREG
5354       && GET_CODE (SUBREG_REG (operands[1])) == REG
5355       && REGNO (SUBREG_REG (operands[1])) < FIRST_PSEUDO_REGISTER)
5356     operands[1] = alter_subreg (operands[1]);
5357
5358   if (TARGET_SOFT_FLOAT && GET_CODE (operands[0]) == MEM)
5359     operands[1] = force_reg (SFmode, operands[1]);
5360
5361   else if (TARGET_HARD_FLOAT)
5362     {
5363       if (GET_CODE (operands[1]) == REG && REGNO (operands[1]) < 32)
5364         {
5365           /* If this is a store to memory or another integer register do the
5366              move directly.  Otherwise store to a temporary stack slot and
5367              load from there into a floating point register.  */
5368
5369           if (GET_CODE (operands[0]) == MEM
5370               || (GET_CODE (operands[0]) == REG
5371                   && (REGNO (operands[0]) < 32
5372                       || (reload_in_progress
5373                           && REGNO (operands[0]) >= FIRST_PSEUDO_REGISTER))))
5374             {
5375               emit_move_insn (operand_subword (operands[0], 0, 0, SFmode),
5376                               operand_subword (operands[1], 0, 0, SFmode));
5377               DONE;
5378             }
5379           else
5380             {
5381               rtx stack_slot = assign_stack_temp (SFmode, 4, 0);
5382
5383               emit_move_insn (stack_slot, operands[1]);
5384               emit_move_insn (operands[0], stack_slot);
5385               DONE;
5386             }
5387         }
5388
5389       if (GET_CODE (operands[0]) == MEM)
5390         {
5391           /* If operands[1] is a register, it may have double-precision data
5392              in it, so truncate it to single precision.  We need not do
5393              this for POWERPC.  */
5394           if (! TARGET_POWERPC && TARGET_HARD_FLOAT
5395               && GET_CODE (operands[1]) == REG)
5396             {
5397               rtx newreg
5398                 = reload_in_progress ? operands[1] : gen_reg_rtx (SFmode);
5399               emit_insn (gen_aux_truncdfsf2 (newreg, operands[1]));
5400               operands[1] = newreg;
5401             }
5402
5403           operands[1] = force_reg (SFmode, operands[1]);
5404         }
5405
5406       if (GET_CODE (operands[0]) == REG && REGNO (operands[0]) < 32)
5407         {
5408           if (GET_CODE (operands[1]) == MEM
5409 #if HOST_FLOAT_FORMAT == TARGET_FLOAT_FORMAT && ! defined(REAL_IS_NOT_DOUBLE)
5410               || GET_CODE (operands[1]) == CONST_DOUBLE
5411 #endif
5412               || (GET_CODE (operands[1]) == REG
5413                   && (REGNO (operands[1]) < 32
5414                       || (reload_in_progress
5415                           && REGNO (operands[1]) >= FIRST_PSEUDO_REGISTER))))
5416             {
5417               emit_move_insn (operand_subword (operands[0], 0, 0, SFmode),
5418                               operand_subword (operands[1], 0, 0, SFmode));
5419               DONE;
5420             }
5421           else
5422             {
5423               rtx stack_slot = assign_stack_temp (SFmode, 4, 0);
5424
5425               emit_move_insn (stack_slot, operands[1]);
5426               emit_move_insn (operands[0], stack_slot);
5427               DONE;
5428             }
5429         }
5430     }
5431
5432   if (CONSTANT_P (operands[1]) && TARGET_HARD_FLOAT)
5433     {
5434       operands[1] = force_const_mem (SFmode, operands[1]);
5435       if (! memory_address_p (SFmode, XEXP (operands[1], 0))
5436           && ! reload_in_progress)
5437         operands[1] = change_address (operands[1], SFmode,
5438                                       XEXP (operands[1], 0));
5439     }
5440 }")
5441
5442 (define_split
5443   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5444         (match_operand:SF 1 "const_double_operand" ""))]
5445   "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], SFmode) <= 1 && REGNO (operands[0]) <= 31"
5446   [(set (match_dup 2) (match_dup 3))]
5447   "
5448 {
5449   long l;
5450   REAL_VALUE_TYPE rv;
5451
5452   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
5453   REAL_VALUE_TO_TARGET_SINGLE (rv, l);
5454
5455   operands[2] = gen_rtx (SUBREG, SImode, operands[0], 0);
5456   operands[3] = GEN_INT(l);
5457 }")
5458
5459 (define_split
5460   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5461         (match_operand:SF 1 "const_double_operand" ""))]
5462   "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], SFmode) == 2 && REGNO (operands[0]) <= 31"
5463   [(set (match_dup 2) (match_dup 3))
5464    (set (match_dup 2) (ior:SI (match_dup 2) (match_dup 4)))]
5465   "
5466 {
5467   long l;
5468   REAL_VALUE_TYPE rv;
5469
5470   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
5471   REAL_VALUE_TO_TARGET_SINGLE (rv, l);
5472
5473   operands[2] = gen_rtx (SUBREG, SImode, operands[0], 0);
5474   operands[3] = GEN_INT(l & 0xffff0000);
5475   operands[4] = GEN_INT(l & 0x0000ffff);
5476 }")
5477
5478 (define_insn "*movsf_hardfloat"
5479   [(set (match_operand:SF 0 "fp_reg_or_mem_operand" "=f,f,m,!r,!r")
5480         (match_operand:SF 1 "input_operand" "f,m,f,G,Fn"))]
5481   "(gpc_reg_operand (operands[0], SFmode)
5482    || gpc_reg_operand (operands[1], SFmode)) && TARGET_HARD_FLOAT"
5483   "@
5484    fmr %0,%1
5485    lfs%U1%X1 %0,%1
5486    stfs%U0%X0 %1,%0
5487    #
5488    #"
5489   [(set_attr "type" "fp,fpload,fpstore,*,*")
5490    (set_attr "length" "4,4,4,4,8")])
5491
5492 (define_insn "*movsf_softfloat"
5493   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,r")
5494         (match_operand:SF 1 "input_operand" "r,m,r,I,J,R,G,Fn"))]
5495   "(gpc_reg_operand (operands[0], SFmode)
5496    || gpc_reg_operand (operands[1], SFmode)) && TARGET_SOFT_FLOAT"
5497   "@
5498    mr %0,%1
5499    {l%U1%X1|lwz%U1%X1} %0,%1
5500    {st%U0%X0|stw%U0%X0} %1,%0
5501    {lil|li} %0,%1
5502    {liu|lis} %0,%v1
5503    {cal|la} %0,%1(%*)
5504    #
5505    #"
5506   [(set_attr "type" "*,load,store,*,*,*,*,*")
5507    (set_attr "length" "4,4,4,4,4,4,4,8")])
5508
5509 \f
5510 (define_expand "movdf"
5511   [(set (match_operand:DF 0 "nonimmediate_operand" "")
5512         (match_operand:DF 1 "any_operand" ""))]
5513   ""
5514   "
5515 {
5516   if (GET_CODE (operands[0]) != REG)
5517     operands[1] = force_reg (DFmode, operands[1]);
5518
5519       /* Stores between FPR and any non-FPR registers must go through a
5520          temporary stack slot.  */
5521
5522   if (TARGET_POWERPC64
5523       && GET_CODE (operands[0]) == REG && GET_CODE (operands[1]) == REG
5524       && ((FP_REGNO_P (REGNO (operands[0]))
5525            && ! FP_REGNO_P (REGNO (operands[1])))
5526           || (FP_REGNO_P (REGNO (operands[1]))
5527               && ! FP_REGNO_P (REGNO (operands[0])))))
5528     {
5529       rtx stack_slot = assign_stack_temp (DFmode, 8, 0);
5530
5531       emit_move_insn (stack_slot, operands[1]);
5532       emit_move_insn (operands[0], stack_slot);
5533       DONE;
5534     }
5535
5536   if (CONSTANT_P (operands[1]) && ! easy_fp_constant (operands[1], DFmode))
5537     {
5538       operands[1] = force_const_mem (DFmode, operands[1]);
5539       if (! memory_address_p (DFmode, XEXP (operands[1], 0))
5540           && ! reload_in_progress)
5541         operands[1] = change_address (operands[1], DFmode,
5542                                       XEXP (operands[1], 0));
5543     }
5544 }")
5545
5546 (define_split
5547   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5548         (match_operand:DF 1 "const_int_operand" ""))]
5549   "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DFmode) <= 1 && REGNO (operands[0]) <= 31"
5550   [(set (match_dup 2) (match_dup 4))
5551    (set (match_dup 3) (match_dup 1))]
5552   "
5553 {
5554   operands[2] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5555   operands[3] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5556   operands[4] = (INTVAL (operands[1]) & 0x80000000) ? constm1_rtx : const0_rtx;
5557 }")
5558
5559 (define_split
5560   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5561         (match_operand:DF 1 "const_int_operand" ""))]
5562   "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DFmode) >= 2 && REGNO (operands[0]) <= 31"
5563   [(set (match_dup 3) (match_dup 5))
5564    (set (match_dup 2) (match_dup 4))
5565    (set (match_dup 3) (ior:SI (match_dup 3) (match_dup 6)))]
5566   "
5567 {
5568   HOST_WIDE_INT value = INTVAL (operands[1]);
5569   operands[2] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5570   operands[3] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5571   operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
5572   operands[5] = GEN_INT (value & 0xffff0000);
5573   operands[6] = GEN_INT (value & 0x0000ffff);
5574 }")
5575
5576 (define_split
5577   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5578         (match_operand:DF 1 "const_double_operand" ""))]
5579   "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DFmode) <= 2 && REGNO (operands[0]) <= 31"
5580   [(set (match_dup 2) (match_dup 4))
5581    (set (match_dup 3) (match_dup 5))]
5582   "
5583 {
5584   operands[2] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5585   operands[3] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5586   operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
5587   operands[5] = GEN_INT (CONST_DOUBLE_LOW  (operands[1]));
5588 }")
5589
5590 (define_split
5591   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5592         (match_operand:DF 1 "const_double_operand" ""))]
5593   "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DFmode) == 3 && REGNO (operands[0]) <= 31"
5594   [(set (match_dup 2) (match_dup 4))
5595    (set (match_dup 3) (match_dup 5))
5596    (set (match_dup 2) (ior:SI (match_dup 2) (match_dup 6)))]
5597   "
5598 {
5599   HOST_WIDE_INT high = CONST_DOUBLE_HIGH (operands[1]);
5600   HOST_WIDE_INT low  = CONST_DOUBLE_LOW  (operands[1]);
5601   rtx high_reg = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5602   rtx low_reg  = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5603
5604   if (((unsigned HOST_WIDE_INT) (low + 0x8000) < 0x10000)
5605       || (low & 0xffff) == 0)
5606     {
5607       operands[2] = high_reg;
5608       operands[3] = low_reg;
5609       operands[4] = GEN_INT (high & 0xffff0000);
5610       operands[5] = GEN_INT (low);
5611       operands[6] = GEN_INT (high & 0x0000ffff);
5612     }
5613   else
5614     {
5615       operands[2] = low_reg;
5616       operands[3] = high_reg;
5617       operands[4] = GEN_INT (low & 0xffff0000);
5618       operands[5] = GEN_INT (high);
5619       operands[6] = GEN_INT (low & 0x0000ffff);
5620     }
5621 }")
5622
5623 (define_split
5624   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5625         (match_operand:DF 1 "const_double_operand" ""))]
5626   "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DFmode) >= 4 && REGNO (operands[0]) <= 31"
5627   [(set (match_dup 2) (match_dup 4))
5628    (set (match_dup 3) (match_dup 5))
5629    (set (match_dup 2) (ior:SI (match_dup 2) (match_dup 6)))
5630    (set (match_dup 3) (ior:SI (match_dup 3) (match_dup 7)))]
5631   "
5632 {
5633   HOST_WIDE_INT high = CONST_DOUBLE_HIGH (operands[1]);
5634   HOST_WIDE_INT low  = CONST_DOUBLE_LOW  (operands[1]);
5635
5636   operands[2] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5637   operands[3] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5638   operands[4] = GEN_INT (high & 0xffff0000);
5639   operands[5] = GEN_INT (low  & 0xffff0000);
5640   operands[6] = GEN_INT (high & 0x0000ffff);
5641   operands[7] = GEN_INT (low  & 0x0000ffff);
5642 }")
5643
5644 (define_split
5645   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5646         (match_operand:DF 1 "easy_fp_constant" ""))]
5647   "TARGET_64BIT && reload_completed && REGNO (operands[0]) <= 31"
5648   [(set (subreg:DI (match_dup 0) 0) (subreg:DI (match_dup 1) 0))]
5649   "")
5650
5651 ;; Don't have reload use general registers to load a constant.  First,
5652 ;; it might not work if the output operand has is the equivalent of
5653 ;; a non-offsettable memref, but also it is less efficient than loading
5654 ;; the constant into an FP register, since it will probably be used there.
5655 ;; The "??" is a kludge until we can figure out a more reasonable way
5656 ;; of handling these non-offsettable values.
5657 (define_insn "*movdf_hardfloat32"
5658   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,o,!r,!r,!r,f,f,m")
5659         (match_operand:DF 1 "input_operand" "r,o,r,G,H,F,f,m,f"))]
5660   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT
5661    && (register_operand (operands[0], DFmode)
5662        || register_operand (operands[1], DFmode))"
5663   "*
5664 {
5665   switch (which_alternative)
5666     {
5667     case 0:
5668       /* We normally copy the low-numbered register first.  However, if
5669          the first register operand 0 is the same as the second register of
5670          operand 1, we must copy in the opposite order.  */
5671       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
5672         return \"mr %L0,%L1\;mr %0,%1\";
5673       else
5674         return \"mr %0,%1\;mr %L0,%L1\";
5675     case 1:
5676       /* If the low-address word is used in the address, we must load it
5677          last.  Otherwise, load it first.  Note that we cannot have
5678          auto-increment in that case since the address register is known to be
5679          dead.  */
5680       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5681                              operands [1], 0))
5682         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
5683       else
5684         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
5685     case 2:
5686       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
5687     case 3:
5688     case 4:
5689     case 5:
5690       return \"#\";
5691     case 6:
5692       return \"fmr %0,%1\";
5693     case 7:
5694       return \"lfd%U1%X1 %0,%1\";
5695     case 8:
5696       return \"stfd%U0%X0 %1,%0\";
5697     }
5698 }"
5699   [(set_attr "type" "*,load,store,*,*,*,fp,fpload,fpstore")
5700    (set_attr "length" "8,8,8,8,12,16,*,*,*")])
5701
5702 (define_insn "*movdf_softfloat32"
5703   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,o,r,r,r")
5704         (match_operand:DF 1 "input_operand" "r,o,r,G,H,F"))]
5705   "! TARGET_POWERPC64 && TARGET_SOFT_FLOAT
5706    && (register_operand (operands[0], DFmode)
5707        || register_operand (operands[1], DFmode))"
5708   "*
5709 {
5710   switch (which_alternative)
5711     {
5712     case 0:
5713       /* We normally copy the low-numbered register first.  However, if
5714          the first register operand 0 is the same as the second register of
5715          operand 1, we must copy in the opposite order.  */
5716       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
5717         return \"mr %L0,%L1\;mr %0,%1\";
5718       else
5719         return \"mr %0,%1\;mr %L0,%L1\";
5720     case 1:
5721       /* If the low-address word is used in the address, we must load it
5722          last.  Otherwise, load it first.  Note that we cannot have
5723          auto-increment in that case since the address register is known to be
5724          dead.  */
5725       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5726                              operands [1], 0))
5727         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
5728       else
5729         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
5730     case 2:
5731       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
5732     case 3:
5733     case 4:
5734     case 5:
5735       return \"#\";
5736     }
5737 }"
5738   [(set_attr "type" "*,load,store,*,*,*")
5739    (set_attr "length" "8,8,8,8,12,16")])
5740
5741 (define_insn "*movdf_hardfloat64"
5742   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,o,!r,!r,!r,f,f,m")
5743         (match_operand:DF 1 "input_operand" "r,o,r,G,H,F,f,m,f"))]
5744   "TARGET_POWERPC64 && TARGET_HARD_FLOAT
5745    && (register_operand (operands[0], DFmode)
5746        || register_operand (operands[1], DFmode))"
5747   "@
5748    mr %0,%1
5749    ld%U1%X1 %0,%1
5750    std%U0%X0 %1,%0
5751    #
5752    #
5753    #
5754    fmr %0,%1
5755    lfd%U1%X1 %0,%1
5756    stfd%U0%X0 %1,%0"
5757   [(set_attr "type" "*,load,store,*,*,*,fp,fpload,fpstore")
5758    (set_attr "length" "4,4,4,8,12,16,4,4,4")])
5759
5760 (define_insn "*movdf_softfloat64"
5761   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,o,r,r,r")
5762         (match_operand:DF 1 "input_operand" "r,o,r,G,H,F"))]
5763   "TARGET_POWERPC64 && TARGET_SOFT_FLOAT
5764    && (register_operand (operands[0], DFmode)
5765        || register_operand (operands[1], DFmode))"
5766   "@
5767    mr %0,%1
5768    ld%U1%X1 %0,%1
5769    std%U0%X0 %1,%0
5770    #
5771    #
5772    #"
5773   [(set_attr "type" "*,load,store,*,*,*")
5774    (set_attr "length" "*,*,*,8,12,16")])
5775 \f
5776 ;; Next come the multi-word integer load and store and the load and store
5777 ;; multiple insns.
5778 (define_expand "movdi"
5779   [(set (match_operand:DI 0 "general_operand" "")
5780         (match_operand:DI 1 "any_operand" ""))]
5781   ""
5782   "
5783 {
5784   if (GET_CODE (operands[0]) != REG)
5785     operands[1] = force_reg (DImode, operands[1]);
5786
5787   if (TARGET_64BIT
5788       && (GET_CODE (operands[1]) == CONST_DOUBLE
5789           || GET_CODE (operands[1]) == CONST_INT))
5790     {
5791       HOST_WIDE_INT low;
5792       HOST_WIDE_INT high;
5793
5794       if (GET_CODE (operands[1]) == CONST_DOUBLE)
5795         {
5796           low = CONST_DOUBLE_LOW (operands[1]);
5797           high = CONST_DOUBLE_HIGH (operands[1]);
5798         }
5799       else
5800 #if HOST_BITS_PER_WIDE_INT == 32
5801         {
5802           low = INTVAL (operands[1]);
5803           high = (low < 0) ? ~0 : 0;
5804         }
5805 #else
5806         {
5807           low = INTVAL (operands[1]) & 0xffffffff;
5808           high = (HOST_WIDE_INT) INTVAL (operands[1]) >> 32;
5809         }
5810 #endif
5811
5812         if (high)
5813           {
5814             emit_move_insn (operands[0], GEN_INT (high));
5815             emit_insn (gen_ashldi3 (operands[0], operands[0], GEN_INT(32)));
5816             if (low)
5817               {
5818                 HOST_WIDE_INT low_low = low & 0xffff;
5819                 HOST_WIDE_INT low_high = low & (~ (HOST_WIDE_INT) 0xffff);
5820                 if (low_high)
5821                   emit_insn (gen_iordi3 (operands[0], operands[0],
5822                                          GEN_INT (low_high)));
5823                 if (low_low)
5824                   emit_insn (gen_iordi3 (operands[0], operands[0],
5825                                          GEN_INT (low_low)));
5826               }
5827               DONE;
5828           }
5829     }
5830
5831       /* Stores between FPR and any non-FPR registers must go through a
5832          temporary stack slot.  */
5833
5834   if (GET_CODE (operands[0]) == REG && GET_CODE (operands[1]) == REG
5835       && ((FP_REGNO_P (REGNO (operands[0]))
5836            && ! FP_REGNO_P (REGNO (operands[1])))
5837           || (FP_REGNO_P (REGNO (operands[1]))
5838               && ! FP_REGNO_P (REGNO (operands[0])))))
5839     {
5840       rtx stack_slot = assign_stack_temp (DImode, 8, 0);
5841
5842       emit_move_insn (stack_slot, operands[1]);
5843       emit_move_insn (operands[0], stack_slot);
5844       DONE;
5845     }
5846 }")
5847
5848 (define_insn "*movdi_32"
5849   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,f,f,m,r,r,r,r,r")
5850         (match_operand:DI 1 "input_operand" "r,m,r,f,m,f,IJK,n,G,H,F"))]
5851   "TARGET_32BIT
5852    && (gpc_reg_operand (operands[0], DImode)
5853        || gpc_reg_operand (operands[1], DImode))"
5854   "*
5855 {
5856   switch (which_alternative)
5857     {
5858     case 0:
5859       /* We normally copy the low-numbered register first.  However, if
5860          the first register operand 0 is the same as the second register of
5861          operand 1, we must copy in the opposite order.  */
5862       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
5863         return \"mr %L0,%L1\;mr %0,%1\";
5864       else
5865         return \"mr %0,%1\;mr %L0,%L1\";
5866     case 1:
5867       /* If the low-address word is used in the address, we must load it
5868          last.  Otherwise, load it first.  Note that we cannot have
5869          auto-increment in that case since the address register is known to be
5870          dead.  */
5871       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
5872                              operands [1], 0))
5873         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
5874       else
5875         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
5876     case 2:
5877       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
5878     case 3:
5879       return \"fmr %0,%1\";
5880     case 4:
5881       return \"lfd%U1%X1 %0,%1\";
5882     case 5:
5883       return \"stfd%U0%X0 %1,%0\";
5884     case 6:
5885     case 7:
5886     case 8:
5887     case 9:
5888     case 10:
5889       return \"#\";
5890     }
5891 }"
5892   [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*,*,*,*")
5893    (set_attr "length" "8,8,8,*,*,*,8,12,8,12,16")])
5894
5895 (define_split
5896   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5897         (match_operand:DI 1 "const_int_operand" ""))]
5898   "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DImode) <= 1"
5899   [(set (match_dup 2) (match_dup 4))
5900    (set (match_dup 3) (match_dup 1))]
5901   "
5902 {
5903   operands[2] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5904   operands[3] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5905   operands[4] = (INTVAL (operands[1]) & 0x80000000) ? constm1_rtx : const0_rtx;
5906 }")
5907
5908 (define_split
5909   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5910         (match_operand:DI 1 "const_int_operand" ""))]
5911   "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DImode) >= 2"
5912   [(set (match_dup 3) (match_dup 5))
5913    (set (match_dup 2) (match_dup 4))
5914    (set (match_dup 3) (ior:SI (match_dup 3) (match_dup 6)))]
5915   "
5916 {
5917   HOST_WIDE_INT value = INTVAL (operands[1]);
5918   operands[2] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5919   operands[3] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5920   operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
5921   operands[5] = GEN_INT (value & 0xffff0000);
5922   operands[6] = GEN_INT (value & 0x0000ffff);
5923 }")
5924
5925 (define_split
5926   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5927         (match_operand:DI 1 "const_double_operand" ""))]
5928   "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DImode) <= 2"
5929   [(set (match_dup 2) (match_dup 4))
5930    (set (match_dup 3) (match_dup 5))]
5931   "
5932 {
5933   operands[2] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5934   operands[3] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5935   operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
5936   operands[5] = GEN_INT (CONST_DOUBLE_LOW  (operands[1]));
5937 }")
5938
5939 (define_split
5940   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5941         (match_operand:DI 1 "const_double_operand" ""))]
5942   "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DImode) == 3"
5943   [(set (match_dup 2) (match_dup 4))
5944    (set (match_dup 3) (match_dup 5))
5945    (set (match_dup 2) (ior:SI (match_dup 2) (match_dup 6)))]
5946   "
5947 {
5948   HOST_WIDE_INT high = CONST_DOUBLE_HIGH (operands[1]);
5949   HOST_WIDE_INT low  = CONST_DOUBLE_LOW  (operands[1]);
5950   rtx high_reg = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5951   rtx low_reg  = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5952
5953   if (((unsigned HOST_WIDE_INT) (low + 0x8000) < 0x10000)
5954       || (low & 0xffff) == 0)
5955     {
5956       operands[2] = high_reg;
5957       operands[3] = low_reg;
5958       operands[4] = GEN_INT (high & 0xffff0000);
5959       operands[5] = GEN_INT (low);
5960       operands[6] = GEN_INT (high & 0x0000ffff);
5961     }
5962   else
5963     {
5964       operands[2] = low_reg;
5965       operands[3] = high_reg;
5966       operands[4] = GEN_INT (low & 0xffff0000);
5967       operands[5] = GEN_INT (high);
5968       operands[6] = GEN_INT (low & 0x0000ffff);
5969     }
5970 }")
5971
5972 (define_split
5973   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5974         (match_operand:DI 1 "const_double_operand" ""))]
5975   "TARGET_32BIT && reload_completed && num_insns_constant (operands[1], DImode) >= 4"
5976   [(set (match_dup 2) (match_dup 4))
5977    (set (match_dup 3) (match_dup 5))
5978    (set (match_dup 2) (ior:SI (match_dup 2) (match_dup 6)))
5979    (set (match_dup 3) (ior:SI (match_dup 3) (match_dup 7)))]
5980   "
5981 {
5982   HOST_WIDE_INT high = CONST_DOUBLE_HIGH (operands[1]);
5983   HOST_WIDE_INT low  = CONST_DOUBLE_LOW  (operands[1]);
5984
5985   operands[2] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN == 0);
5986   operands[3] = gen_rtx (SUBREG, SImode, operands[0], WORDS_BIG_ENDIAN != 0);
5987   operands[4] = GEN_INT (high & 0xffff0000);
5988   operands[5] = GEN_INT (low  & 0xffff0000);
5989   operands[6] = GEN_INT (high & 0x0000ffff);
5990   operands[7] = GEN_INT (low  & 0x0000ffff);
5991 }")
5992
5993 (define_insn "*movdi_64"
5994   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,f,f,m,r,*h,*h")
5995         (match_operand:DI 1 "input_operand" "r,m,r,I,J,nF,R,f,m,f,*h,r,0"))]
5996   "TARGET_64BIT
5997    && (gpc_reg_operand (operands[0], DImode)
5998        || gpc_reg_operand (operands[1], DImode))"
5999   "@
6000    mr %0,%1
6001    ld%U1%X1 %0,%1
6002    std%U0%X0 %1,%0
6003    li %0,%1
6004    lis %0,%v1
6005    #
6006    {cal|la} %0,%1(%*)
6007    fmr %0,%1
6008    lfd%U1%X1 %0,%1
6009    stfd%U0%X0 %1,%0
6010    mf%1 %0
6011    mt%0 %1
6012    cror 0,0,0"
6013   [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,*,mtjmpr,*")
6014    (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
6015
6016 ;; Split a load of a large constant into the appropriate five-instruction
6017 ;; sequence.  The expansion in movdi tries to perform the minimum number of
6018 ;; steps, but here we have to handle anything in a constant number of insns.
6019
6020 (define_split
6021   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6022         (match_operand:DI 1 "const_double_operand" ""))]
6023   "TARGET_64BIT && num_insns_constant (operands[1], DImode) > 1"
6024   [(set (match_dup 0)
6025         (match_dup 2))
6026    (set (match_dup 0)
6027         (ior:DI (match_dup 0)
6028                 (match_dup 3)))
6029    (set (match_dup 0)
6030         (ashift:DI (match_dup 0)
6031                    (const_int 32)))
6032    (set (match_dup 0)
6033         (ior:DI (match_dup 0)
6034                 (match_dup 4)))
6035    (set (match_dup 0)
6036         (ior:DI (match_dup 0)
6037                 (match_dup 5)))]
6038   "
6039 {
6040   HOST_WIDE_INT low;
6041   HOST_WIDE_INT high;
6042
6043   if (GET_CODE (operands[1]) == CONST_DOUBLE)
6044     {
6045       low = CONST_DOUBLE_LOW (operands[1]);
6046       high = CONST_DOUBLE_HIGH (operands[1]);
6047     }
6048   else
6049 #if HOST_BITS_PER_WIDE_INT == 32
6050     {
6051       low = INTVAL (operands[1]);
6052       high = (low < 0) ? ~0 : 0;
6053     }
6054 #else
6055     {
6056       low = INTVAL (operands[1]) & 0xffffffff;
6057       high = (HOST_WIDE_INT) INTVAL (operands[1]) >> 32;
6058     }
6059 #endif
6060
6061   if ((high + 0x8000) < 0x10000
6062       && ((low & 0xffff) == 0 || (low & (~ (HOST_WIDE_INT) 0xffff)) == 0))
6063     FAIL;
6064
6065   operands[2] = GEN_INT (high & (~ (HOST_WIDE_INT) 0xffff));
6066   operands[3] = GEN_INT (high & 0xffff);
6067   operands[4] = GEN_INT (low & (~ (HOST_WIDE_INT) 0xffff));
6068   operands[5] = GEN_INT (low & 0xffff);
6069 }")
6070
6071 (define_insn ""
6072   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
6073         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
6074                     (const_int 0)))
6075    (set (match_operand:DI 0 "gpc_reg_operand" "=r") (match_dup 1))]
6076   "TARGET_POWERPC64"
6077   "mr. %0,%1"
6078   [(set_attr "type" "compare")])
6079 \f
6080 ;; TImode is similar, except that we usually want to compute the address into
6081 ;; a register and use lsi/stsi (the exception is during reload).  MQ is also
6082 ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
6083 (define_expand "movti"
6084   [(parallel [(set (match_operand:TI 0 "general_operand" "")
6085                    (match_operand:TI 1 "general_operand" ""))
6086               (clobber (scratch:SI))])]
6087   "TARGET_STRING || TARGET_POWERPC64"
6088   "
6089 {
6090   if (GET_CODE (operands[0]) == MEM)
6091     operands[1] = force_reg (TImode, operands[1]);
6092
6093   if (GET_CODE (operands[0]) == MEM
6094       && GET_CODE (XEXP (operands[0], 0)) != REG
6095       && ! reload_in_progress)
6096     operands[0] = change_address (operands[0], TImode,
6097                                   copy_addr_to_reg (XEXP (operands[0], 0)));
6098
6099   if (GET_CODE (operands[1]) == MEM
6100       && GET_CODE (XEXP (operands[1], 0)) != REG
6101       && ! reload_in_progress)
6102     operands[1] = change_address (operands[1], TImode,
6103                                   copy_addr_to_reg (XEXP (operands[1], 0)));
6104 }")
6105
6106 ;; We say that MQ is clobbered in the last alternative because the first
6107 ;; alternative would never get used otherwise since it would need a reload
6108 ;; while the 2nd alternative would not.  We put memory cases first so they
6109 ;; are preferred.  Otherwise, we'd try to reload the output instead of
6110 ;; giving the SCRATCH mq.
6111 (define_insn ""
6112   [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
6113         (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))
6114    (clobber (match_scratch:SI 2 "=q,q#X,X,X,X"))]
6115   "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
6116    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
6117   "*
6118 {
6119   switch (which_alternative)
6120     {
6121     default:
6122       abort ();
6123
6124     case 0:
6125       return \"{stsi|stswi} %1,%P0,16\";
6126
6127     case 1:
6128       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
6129
6130     case 2:
6131       /* Normally copy registers with lowest numbered register copied first.
6132          But copy in the other order if the first register of the output
6133          is the second, third, or fourth register in the input.  */
6134       if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
6135           && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
6136         return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
6137       else
6138         return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
6139     case 3:
6140       /* If the address is not used in the output, we can use lsi.  Otherwise,
6141          fall through to generating four loads.  */
6142       if (! reg_overlap_mentioned_p (operands[0], operands[1]))
6143         return \"{lsi|lswi} %0,%P1,16\";
6144       /* ... fall through ... */
6145     case 4:
6146       /* If the address register is the same as the register for the lowest-
6147          addressed word, load it last.  Similarly for the next two words.
6148          Otherwise load lowest address to highest.  */
6149       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
6150                              operands[1], 0))
6151         return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
6152       else if (refers_to_regno_p (REGNO (operands[0]) + 1,
6153                                   REGNO (operands[0]) + 2, operands[1], 0))
6154         return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
6155       else if (refers_to_regno_p (REGNO (operands[0]) + 2,
6156                                   REGNO (operands[0]) + 3, operands[1], 0))
6157         return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
6158       else
6159         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
6160     }
6161 }"
6162   [(set_attr "type" "store,store,*,load,load")
6163    (set_attr "length" "*,16,16,*,16")])
6164
6165 (define_insn ""
6166   [(set (match_operand:TI 0 "reg_or_mem_operand" "=m,????r,????r")
6167         (match_operand:TI 1 "reg_or_mem_operand" "r,r,m"))
6168    (clobber (match_scratch:SI 2 "=X,X,X"))]
6169   "TARGET_STRING && !TARGET_POWER && ! TARGET_POWERPC64
6170    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
6171   "*
6172 {
6173   switch (which_alternative)
6174     {
6175     default:
6176       abort ();
6177
6178     case 0:
6179       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
6180
6181     case 1:
6182       /* Normally copy registers with lowest numbered register copied first.
6183          But copy in the other order if the first register of the output
6184          is the second, third, or fourth register in the input.  */
6185       if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
6186           && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
6187         return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
6188       else
6189         return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
6190     case 2:
6191       /* If the address register is the same as the register for the lowest-
6192          addressed word, load it last.  Similarly for the next two words.
6193          Otherwise load lowest address to highest.  */
6194       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
6195                              operands[1], 0))
6196         return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
6197       else if (refers_to_regno_p (REGNO (operands[0]) + 1,
6198                                   REGNO (operands[0]) + 2, operands[1], 0))
6199         return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
6200       else if (refers_to_regno_p (REGNO (operands[0]) + 2,
6201                                   REGNO (operands[0]) + 3, operands[1], 0))
6202         return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
6203       else
6204         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
6205     }
6206 }"
6207   [(set_attr "type" "store,*,load")
6208    (set_attr "length" "16,16,16")])
6209
6210 (define_insn ""
6211   [(set (match_operand:TI 0 "nonimmediate_operand" "=r,r,m")
6212         (match_operand:TI 1 "input_operand" "r,m,r"))]
6213   "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
6214    || gpc_reg_operand (operands[1], TImode))"
6215   "*
6216 {
6217   switch (which_alternative)
6218     {
6219     case 0:
6220       /* We normally copy the low-numbered register first.  However, if
6221          the first register operand 0 is the same as the second register of
6222          operand 1, we must copy in the opposite order.  */
6223       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
6224         return \"mr %L0,%L1\;mr %0,%1\";
6225       else
6226         return \"mr %0,%1\;mr %L0,%L1\";
6227     case 1:
6228       /* If the low-address word is used in the address, we must load it
6229          last.  Otherwise, load it first.  Note that we cannot have
6230          auto-increment in that case since the address register is known to be
6231          dead.  */
6232       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
6233                              operands [1], 0))
6234         return \"ld %L0,%L1\;ld %0,%1\";
6235       else
6236         return \"ld%U1 %0,%1\;ld %L0,%L1\";
6237     case 2:
6238       return \"std%U0 %1,%0\;std %L1,%L0\";
6239     }
6240 }"
6241   [(set_attr "type" "*,load,store")
6242    (set_attr "length" "8,8,8")])
6243 \f
6244 (define_expand "load_multiple"
6245   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
6246                           (match_operand:SI 1 "" ""))
6247                      (use (match_operand:SI 2 "" ""))])]
6248   "TARGET_STRING"
6249   "
6250 {
6251   int regno;
6252   int count;
6253   rtx from;
6254   int i;
6255
6256   /* Support only loading a constant number of fixed-point registers from
6257      memory and only bother with this if more than two; the machine
6258      doesn't support more than eight.  */
6259   if (GET_CODE (operands[2]) != CONST_INT
6260       || INTVAL (operands[2]) <= 2
6261       || INTVAL (operands[2]) > 8
6262       || GET_CODE (operands[1]) != MEM
6263       || GET_CODE (operands[0]) != REG
6264       || REGNO (operands[0]) >= 32)
6265     FAIL;
6266
6267   count = INTVAL (operands[2]);
6268   regno = REGNO (operands[0]);
6269
6270   operands[3] = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (count));
6271   from = force_reg (SImode, XEXP (operands[1], 0));
6272
6273   for (i = 0; i < count; i++)
6274     XVECEXP (operands[3], 0, i)
6275       = gen_rtx (SET, VOIDmode, gen_rtx (REG, SImode, regno + i),
6276                  gen_rtx (MEM, SImode, plus_constant (from, i * 4)));
6277 }")
6278
6279 (define_insn ""
6280   [(match_parallel 0 "load_multiple_operation"
6281                    [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
6282                          (mem:SI (match_operand:SI 2 "register_operand" "b")))])]
6283   "TARGET_STRING"
6284   "*
6285 {
6286   /* We have to handle the case where the pseudo used to contain the address
6287      is assigned to one of the output registers.  */
6288   int i, j;
6289   int words = XVECLEN (operands[0], 0);
6290   rtx xop[10];
6291
6292   if (XVECLEN (operands[0], 0) == 1)
6293     return \"{l|lwz} %1,0(%2)\";
6294
6295   for (i = 0; i < words; i++)
6296     if (refers_to_regno_p (REGNO (operands[1]) + i,
6297                            REGNO (operands[1]) + i + 1, operands[2], 0))
6298       {
6299         if (i == words-1)
6300           {
6301             xop[0] = operands[1];
6302             xop[1] = operands[2];
6303             xop[2] = GEN_INT (4 * (words-1));
6304             output_asm_insn (\"{lsi|lswi} %0,%1,%2\;{l|lwz} %1,%2(%1)\", xop);
6305             return \"\";
6306           }
6307         else if (i == 0)
6308           {
6309             xop[0] = operands[1];
6310             xop[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
6311             xop[2] = GEN_INT (4 * (words-1));
6312             output_asm_insn (\"{cal %0,4(%0)|addi %0,%0,4}\;{lsi|lswi} %1,%0,%2\;{l|lwz} %0,-4(%0)\", xop);
6313             return \"\";
6314           }
6315         else
6316           {
6317             for (j = 0; j < words; j++)
6318               if (j != i)
6319                 {
6320                   xop[0] = gen_rtx (REG, SImode, REGNO (operands[1]) + j);
6321                   xop[1] = operands[2];
6322                   xop[2] = GEN_INT (j * 4);
6323                   output_asm_insn (\"{l|lwz} %0,%2(%1)\", xop);
6324                 }
6325             xop[0] = operands[2];
6326             xop[1] = GEN_INT (i * 4);
6327             output_asm_insn (\"{l|lwz} %0,%1(%0)\", xop);
6328             return \"\";
6329           }
6330       }
6331
6332   return \"{lsi|lswi} %1,%2,%N0\";
6333 }"
6334   [(set_attr "type" "load")
6335    (set_attr "length" "32")])
6336
6337 \f
6338 (define_expand "store_multiple"
6339   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
6340                           (match_operand:SI 1 "" ""))
6341                      (clobber (scratch:SI))
6342                      (use (match_operand:SI 2 "" ""))])]
6343   "TARGET_STRING"
6344   "
6345 {
6346   int regno;
6347   int count;
6348   rtx to;
6349   int i;
6350
6351   /* Support only storing a constant number of fixed-point registers to
6352      memory and only bother with this if more than two; the machine
6353      doesn't support more than eight.  */
6354   if (GET_CODE (operands[2]) != CONST_INT
6355       || INTVAL (operands[2]) <= 2
6356       || INTVAL (operands[2]) > 8
6357       || GET_CODE (operands[0]) != MEM
6358       || GET_CODE (operands[1]) != REG
6359       || REGNO (operands[1]) >= 32)
6360     FAIL;
6361
6362   count = INTVAL (operands[2]);
6363   regno = REGNO (operands[1]);
6364
6365   operands[3] = gen_rtx (PARALLEL, VOIDmode, rtvec_alloc (count + 1));
6366   to = force_reg (SImode, XEXP (operands[0], 0));
6367
6368   XVECEXP (operands[3], 0, 0)
6369     = gen_rtx (SET, VOIDmode, gen_rtx (MEM, SImode, to), operands[1]);
6370   XVECEXP (operands[3], 0, 1) = gen_rtx (CLOBBER, VOIDmode,
6371                                                   gen_rtx (SCRATCH, SImode));
6372
6373   for (i = 1; i < count; i++)
6374     XVECEXP (operands[3], 0, i + 1)
6375       = gen_rtx (SET, VOIDmode,
6376                  gen_rtx (MEM, SImode, plus_constant (to, i * 4)),
6377                  gen_rtx (REG, SImode, regno + i));
6378 }")
6379
6380 (define_insn ""
6381   [(match_parallel 0 "store_multiple_operation"
6382                    [(set (match_operand:SI 1 "indirect_operand" "=Q")
6383                          (match_operand:SI 2 "gpc_reg_operand" "r"))
6384                     (clobber (match_scratch:SI 3 "=q"))])]
6385   "TARGET_STRING && TARGET_POWER"
6386   "{stsi|stswi} %2,%P1,%O0"
6387   [(set_attr "type" "store")])
6388
6389 (define_insn ""
6390   [(match_parallel 0 "store_multiple_operation"
6391                    [(set (mem:SI (match_operand:SI 1 "register_operand" "b"))
6392                          (match_operand:SI 2 "gpc_reg_operand" "r"))
6393                     (clobber (match_scratch:SI 3 "X"))])]
6394   "TARGET_STRING && !TARGET_POWER"
6395   "{stsi|stswi} %2,%1,%O0"
6396   [(set_attr "type" "store")])
6397
6398 \f
6399 ;; String/block move insn.
6400 ;; Argument 0 is the destination
6401 ;; Argument 1 is the source
6402 ;; Argument 2 is the length
6403 ;; Argument 3 is the alignment
6404
6405 (define_expand "movstrsi"
6406   [(parallel [(set (match_operand:BLK 0 "" "")
6407                    (match_operand:BLK 1 "" ""))
6408               (use (match_operand:SI 2 "" ""))
6409               (use (match_operand:SI 3 "" ""))])]
6410   ""
6411   "
6412 {
6413   if (expand_block_move (operands))
6414     DONE;
6415   else
6416     FAIL;
6417 }")
6418
6419 ;; Move up to 32 bytes at a time.  The fixed registers are needed because the
6420 ;; register allocator doesn't have a clue about allocating 8 word registers
6421 (define_expand "movstrsi_8reg"
6422   [(parallel [(set (match_operand 0 "" "")
6423                    (match_operand 1 "" ""))
6424               (use (match_operand 2 "" ""))
6425               (use (match_operand 3 "" ""))
6426               (clobber (reg:SI  5))
6427               (clobber (reg:SI  6))
6428               (clobber (reg:SI  7))
6429               (clobber (reg:SI  8))
6430               (clobber (reg:SI  9))
6431               (clobber (reg:SI 10))
6432               (clobber (reg:SI 11))
6433               (clobber (reg:SI 12))
6434               (clobber (match_scratch:SI 4 ""))])]
6435   "TARGET_STRING"
6436   "")
6437
6438 (define_insn ""
6439   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6440         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6441    (use (match_operand:SI 2 "immediate_operand" "i"))
6442    (use (match_operand:SI 3 "immediate_operand" "i"))
6443    (clobber (match_operand:SI 4 "register_operand" "=r"))
6444    (clobber (reg:SI  6))
6445    (clobber (reg:SI  7))
6446    (clobber (reg:SI  8))
6447    (clobber (reg:SI  9))
6448    (clobber (reg:SI 10))
6449    (clobber (reg:SI 11))
6450    (clobber (reg:SI 12))
6451    (clobber (match_scratch:SI 5 "=q"))]
6452   "TARGET_STRING && TARGET_POWER
6453    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32) || INTVAL (operands[2]) == 0)
6454    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
6455    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
6456    && REGNO (operands[4]) == 5"
6457   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6458   [(set_attr "type" "load")
6459    (set_attr "length" "8")])
6460
6461 (define_insn ""
6462   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6463         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6464    (use (match_operand:SI 2 "immediate_operand" "i"))
6465    (use (match_operand:SI 3 "immediate_operand" "i"))
6466    (clobber (match_operand:SI 4 "register_operand" "=r"))
6467    (clobber (reg:SI  6))
6468    (clobber (reg:SI  7))
6469    (clobber (reg:SI  8))
6470    (clobber (reg:SI  9))
6471    (clobber (reg:SI 10))
6472    (clobber (reg:SI 11))
6473    (clobber (reg:SI 12))
6474    (clobber (match_scratch:SI 5 "X"))]
6475   "TARGET_STRING && !TARGET_POWER
6476    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32) || INTVAL (operands[2]) == 0)
6477    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
6478    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
6479    && REGNO (operands[4]) == 5"
6480   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6481   [(set_attr "type" "load")
6482    (set_attr "length" "8")])
6483
6484 ;; Move up to 24 bytes at a time.  The fixed registers are needed because the
6485 ;; register allocator doesn't have a clue about allocating 6 word registers
6486 (define_expand "movstrsi_6reg"
6487   [(parallel [(set (match_operand 0 "" "")
6488                    (match_operand 1 "" ""))
6489               (use (match_operand 2 "" ""))
6490               (use (match_operand 3 "" ""))
6491               (clobber (reg:SI  7))
6492               (clobber (reg:SI  8))
6493               (clobber (reg:SI  9))
6494               (clobber (reg:SI 10))
6495               (clobber (reg:SI 11))
6496               (clobber (reg:SI 12))
6497               (clobber (match_scratch:SI 4 ""))])]
6498   "TARGET_STRING"
6499   "")
6500
6501 (define_insn ""
6502   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6503         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6504    (use (match_operand:SI 2 "immediate_operand" "i"))
6505    (use (match_operand:SI 3 "immediate_operand" "i"))
6506    (clobber (match_operand:SI 4 "register_operand" "=r"))
6507    (clobber (reg:SI  8))
6508    (clobber (reg:SI  9))
6509    (clobber (reg:SI 10))
6510    (clobber (reg:SI 11))
6511    (clobber (reg:SI 12))
6512    (clobber (match_scratch:SI 5 "=q"))]
6513   "TARGET_STRING && TARGET_POWER
6514    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
6515    && (REGNO (operands[0]) < 7 || REGNO (operands[0]) > 12)
6516    && (REGNO (operands[1]) < 7 || REGNO (operands[1]) > 12)
6517    && REGNO (operands[4]) == 7"
6518   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6519   [(set_attr "type" "load")
6520    (set_attr "length" "8")])
6521
6522 (define_insn ""
6523   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6524         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6525    (use (match_operand:SI 2 "immediate_operand" "i"))
6526    (use (match_operand:SI 3 "immediate_operand" "i"))
6527    (clobber (match_operand:SI 4 "register_operand" "=r"))
6528    (clobber (reg:SI  8))
6529    (clobber (reg:SI  9))
6530    (clobber (reg:SI 10))
6531    (clobber (reg:SI 11))
6532    (clobber (reg:SI 12))
6533    (clobber (match_scratch:SI 5 "X"))]
6534   "TARGET_STRING && !TARGET_POWER
6535    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
6536    && (REGNO (operands[0]) < 7 || REGNO (operands[0]) > 12)
6537    && (REGNO (operands[1]) < 7 || REGNO (operands[1]) > 12)
6538    && REGNO (operands[4]) == 7"
6539   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6540   [(set_attr "type" "load")
6541    (set_attr "length" "8")])
6542
6543 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill problems
6544 ;; with TImode
6545 (define_expand "movstrsi_4reg"
6546   [(parallel [(set (match_operand 0 "" "")
6547                    (match_operand 1 "" ""))
6548               (use (match_operand 2 "" ""))
6549               (use (match_operand 3 "" ""))
6550               (clobber (reg:SI  9))
6551               (clobber (reg:SI 10))
6552               (clobber (reg:SI 11))
6553               (clobber (reg:SI 12))
6554               (clobber (match_scratch:SI 4 ""))])]
6555   "TARGET_STRING"
6556   "")
6557
6558 (define_insn ""
6559   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6560         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6561    (use (match_operand:SI 2 "immediate_operand" "i"))
6562    (use (match_operand:SI 3 "immediate_operand" "i"))
6563    (clobber (match_operand:SI 4 "register_operand" "=r"))
6564    (clobber (reg:SI 10))
6565    (clobber (reg:SI 11))
6566    (clobber (reg:SI 12))
6567    (clobber (match_scratch:SI 5 "=q"))]
6568   "TARGET_STRING && TARGET_POWER
6569    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
6570    && (REGNO (operands[0]) < 9 || REGNO (operands[0]) > 12)
6571    && (REGNO (operands[1]) < 9 || REGNO (operands[1]) > 12)
6572    && REGNO (operands[4]) == 9"
6573   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6574   [(set_attr "type" "load")
6575    (set_attr "length" "8")])
6576
6577 (define_insn ""
6578   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6579         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6580    (use (match_operand:SI 2 "immediate_operand" "i"))
6581    (use (match_operand:SI 3 "immediate_operand" "i"))
6582    (clobber (match_operand:SI 4 "register_operand" "=r"))
6583    (clobber (reg:SI 10))
6584    (clobber (reg:SI 11))
6585    (clobber (reg:SI 12))
6586    (clobber (match_scratch:SI 5 "X"))]
6587   "TARGET_STRING && !TARGET_POWER
6588    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
6589    && (REGNO (operands[0]) < 9 || REGNO (operands[0]) > 12)
6590    && (REGNO (operands[1]) < 9 || REGNO (operands[1]) > 12)
6591    && REGNO (operands[4]) == 9"
6592   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6593   [(set_attr "type" "load")
6594    (set_attr "length" "8")])
6595
6596 ;; Move up to 8 bytes at a time.
6597 (define_expand "movstrsi_2reg"
6598   [(parallel [(set (match_operand 0 "" "")
6599                    (match_operand 1 "" ""))
6600               (use (match_operand 2 "" ""))
6601               (use (match_operand 3 "" ""))
6602               (clobber (match_scratch:DI 4 ""))
6603               (clobber (match_scratch:SI 5 ""))])]
6604   "TARGET_STRING && !TARGET_64BIT"
6605   "")
6606
6607 (define_insn ""
6608   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6609         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6610    (use (match_operand:SI 2 "immediate_operand" "i"))
6611    (use (match_operand:SI 3 "immediate_operand" "i"))
6612    (clobber (match_scratch:DI 4 "=&r"))
6613    (clobber (match_scratch:SI 5 "=q"))]
6614   "TARGET_STRING && TARGET_POWER && !TARGET_64BIT
6615    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
6616   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6617   [(set_attr "type" "load")
6618    (set_attr "length" "8")])
6619
6620 (define_insn ""
6621   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6622         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6623    (use (match_operand:SI 2 "immediate_operand" "i"))
6624    (use (match_operand:SI 3 "immediate_operand" "i"))
6625    (clobber (match_scratch:DI 4 "=&r"))
6626    (clobber (match_scratch:SI 5 "X"))]
6627   "TARGET_STRING && !TARGET_POWER && !TARGET_64BIT
6628    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
6629   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6630   [(set_attr "type" "load")
6631    (set_attr "length" "8")])
6632
6633 ;; Move up to 4 bytes at a time.
6634 (define_expand "movstrsi_1reg"
6635   [(parallel [(set (match_operand 0 "" "")
6636                    (match_operand 1 "" ""))
6637               (use (match_operand 2 "" ""))
6638               (use (match_operand 3 "" ""))
6639               (clobber (match_scratch:SI 4 ""))
6640               (clobber (match_scratch:SI 5 ""))])]
6641   "TARGET_STRING"
6642   "")
6643
6644 (define_insn ""
6645   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6646         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6647    (use (match_operand:SI 2 "immediate_operand" "i"))
6648    (use (match_operand:SI 3 "immediate_operand" "i"))
6649    (clobber (match_scratch:SI 4 "=&r"))
6650    (clobber (match_scratch:SI 5 "=q"))]
6651   "TARGET_STRING && TARGET_POWER
6652    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
6653   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6654   [(set_attr "type" "load")
6655    (set_attr "length" "8")])
6656
6657 (define_insn ""
6658   [(set (mem:BLK (match_operand:SI 0 "register_operand" "b"))
6659         (mem:BLK (match_operand:SI 1 "register_operand" "b")))
6660    (use (match_operand:SI 2 "immediate_operand" "i"))
6661    (use (match_operand:SI 3 "immediate_operand" "i"))
6662    (clobber (match_scratch:SI 4 "=&r"))
6663    (clobber (match_scratch:SI 5 "X"))]
6664   "TARGET_STRING && !TARGET_POWER
6665    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
6666   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
6667   [(set_attr "type" "load")
6668    (set_attr "length" "8")])
6669
6670 \f
6671 ;; Define insns that do load or store with update.  Some of these we can
6672 ;; get by using pre-decrement or pre-increment, but the hardware can also
6673 ;; do cases where the increment is not the size of the object.
6674 ;;
6675 ;; In all these cases, we use operands 0 and 1 for the register being
6676 ;; incremented because those are the operands that local-alloc will
6677 ;; tie and these are the pair most likely to be tieable (and the ones
6678 ;; that will benefit the most).
6679
6680 (define_insn ""
6681   [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
6682         (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
6683                          (match_operand:DI 2 "reg_or_short_operand" "r,I"))))
6684    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
6685         (plus:DI (match_dup 1) (match_dup 2)))]
6686   "TARGET_POWERPC64"
6687   "@
6688    ldux %3,%0,%2
6689    ldu %3,%2(%0)"
6690   [(set_attr "type" "load")])
6691
6692 (define_insn ""
6693   [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
6694         (sign_extend:DI
6695          (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
6696                           (match_operand:DI 2 "gpc_reg_operand" "r")))))
6697    (set (match_operand:DI 0 "gpc_reg_operand" "=b")
6698         (plus:DI (match_dup 1) (match_dup 2)))]
6699   "TARGET_POWERPC64"
6700   "lwaux %3,%0,%2"
6701   [(set_attr "type" "load")])
6702
6703 (define_insn "movdi_update"
6704   [(set (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
6705                          (match_operand:DI 2 "reg_or_short_operand" "r,I")))
6706         (match_operand:DI 3 "gpc_reg_operand" "r,r"))
6707    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
6708         (plus:DI (match_dup 1) (match_dup 2)))]
6709   "TARGET_POWERPC64"
6710   "@
6711    stdux %3,%0,%2
6712    stdu %3,%2(%0)"
6713   [(set_attr "type" "store")])
6714
6715 (define_insn ""
6716   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
6717         (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6718                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6719    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6720         (plus:SI (match_dup 1) (match_dup 2)))]
6721   ""
6722   "@
6723    {lux|lwzux} %3,%0,%2
6724    {lu|lwzu} %3,%2(%0)"
6725   [(set_attr "type" "load")])
6726
6727 (define_insn "movsi_update"
6728   [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6729                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6730         (match_operand:SI 3 "gpc_reg_operand" "r,r"))
6731    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6732         (plus:SI (match_dup 1) (match_dup 2)))]
6733   ""
6734   "@
6735    {stux|stwux} %3,%0,%2
6736    {stu|stwu} %3,%2(%0)"
6737   [(set_attr "type" "store")])
6738
6739 (define_insn ""
6740   [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
6741         (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6742                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6743    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6744         (plus:SI (match_dup 1) (match_dup 2)))]
6745   ""
6746   "@
6747    lhzux %3,%0,%2
6748    lhzu %3,%2(%0)"
6749   [(set_attr "type" "load")])
6750
6751 (define_insn ""
6752   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
6753         (zero_extend:SI
6754          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6755                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
6756    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6757         (plus:SI (match_dup 1) (match_dup 2)))]
6758   ""
6759   "@
6760    lhzux %3,%0,%2
6761    lhzu %3,%2(%0)"
6762   [(set_attr "type" "load")])
6763
6764 (define_insn ""
6765   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
6766         (sign_extend:SI
6767          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6768                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
6769    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6770         (plus:SI (match_dup 1) (match_dup 2)))]
6771   ""
6772   "@
6773    lhaux %3,%0,%2
6774    lhau %3,%2(%0)"
6775   [(set_attr "type" "load")])
6776
6777 (define_insn ""
6778   [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6779                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6780         (match_operand:HI 3 "gpc_reg_operand" "r,r"))
6781    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6782         (plus:SI (match_dup 1) (match_dup 2)))]
6783   ""
6784   "@
6785    sthux %3,%0,%2
6786    sthu %3,%2(%0)"
6787   [(set_attr "type" "store")])
6788
6789 (define_insn ""
6790   [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
6791         (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6792                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6793    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6794         (plus:SI (match_dup 1) (match_dup 2)))]
6795   ""
6796   "@
6797    lbzux %3,%0,%2
6798    lbzu %3,%2(%0)"
6799   [(set_attr "type" "load")])
6800
6801 (define_insn ""
6802   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
6803         (zero_extend:SI
6804          (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6805                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
6806    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6807         (plus:SI (match_dup 1) (match_dup 2)))]
6808   ""
6809   "@
6810    lbzux %3,%0,%2
6811    lbzu %3,%2(%0)"
6812   [(set_attr "type" "load")])
6813
6814 (define_insn ""
6815   [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6816                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6817         (match_operand:QI 3 "gpc_reg_operand" "r,r"))
6818    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6819         (plus:SI (match_dup 1) (match_dup 2)))]
6820   ""
6821   "@
6822    stbux %3,%0,%2
6823    stbu %3,%2(%0)"
6824   [(set_attr "type" "store")])
6825
6826 (define_insn ""
6827   [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
6828         (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6829                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6830    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6831         (plus:SI (match_dup 1) (match_dup 2)))]
6832   "TARGET_HARD_FLOAT"
6833   "@
6834    lfsux %3,%0,%2
6835    lfsu %3,%2(%0)"
6836   [(set_attr "type" "fpload")])
6837
6838 (define_insn ""
6839   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6840                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6841         (match_operand:SF 3 "gpc_reg_operand" "f,f"))
6842    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6843         (plus:SI (match_dup 1) (match_dup 2)))]
6844   "TARGET_HARD_FLOAT"
6845   "@
6846    stfsux %3,%0,%2
6847    stfsu %3,%2(%0)"
6848   [(set_attr "type" "fpstore")])
6849
6850 (define_insn ""
6851   [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
6852         (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6853                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
6854    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6855         (plus:SI (match_dup 1) (match_dup 2)))]
6856   "TARGET_HARD_FLOAT"
6857   "@
6858    lfdux %3,%0,%2
6859    lfdu %3,%2(%0)"
6860   [(set_attr "type" "fpload")])
6861
6862 (define_insn ""
6863   [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
6864                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
6865         (match_operand:DF 3 "gpc_reg_operand" "f,f"))
6866    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
6867         (plus:SI (match_dup 1) (match_dup 2)))]
6868   "TARGET_HARD_FLOAT"
6869   "@
6870    stfdux %3,%0,%2
6871    stfdu %3,%2(%0)"
6872   [(set_attr "type" "fpstore")])
6873
6874 ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
6875
6876 (define_peephole
6877   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6878         (match_operand:DF 1 "memory_operand" ""))
6879    (set (match_operand:DF 2 "gpc_reg_operand" "=f")
6880         (match_operand:DF 3 "memory_operand" ""))]
6881   "TARGET_POWER2
6882    && TARGET_HARD_FLOAT
6883    && registers_ok_for_quad_peep (operands[0], operands[2])
6884    && ! MEM_VOLATILE_P (operands[1]) && ! MEM_VOLATILE_P (operands[3])
6885    && addrs_ok_for_quad_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
6886   "lfq%U1%X1 %0,%1")
6887
6888 (define_peephole
6889   [(set (match_operand:DF 0 "memory_operand" "")
6890         (match_operand:DF 1 "gpc_reg_operand" "f"))
6891    (set (match_operand:DF 2 "memory_operand" "")
6892         (match_operand:DF 3 "gpc_reg_operand" "f"))]
6893   "TARGET_POWER2
6894    && TARGET_HARD_FLOAT
6895    && registers_ok_for_quad_peep (operands[1], operands[3])
6896    && ! MEM_VOLATILE_P (operands[0]) && ! MEM_VOLATILE_P (operands[2])
6897    && addrs_ok_for_quad_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
6898   "stfq%U0%X0 %1,%0")
6899 \f
6900 ;; Next come insns related to the calling sequence.
6901 ;;
6902 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
6903 ;; We move the back-chain and decrement the stack pointer.
6904
6905 (define_expand "allocate_stack"
6906   [(set (reg:SI 1)
6907         (minus:SI (reg:SI 1) (match_operand:SI 0 "reg_or_short_operand" "")))]
6908   ""
6909   "
6910 { rtx chain = gen_reg_rtx (Pmode);
6911   rtx stack_bot = gen_rtx (MEM, Pmode, stack_pointer_rtx);
6912   rtx neg_op0;
6913
6914   emit_move_insn (chain, stack_bot);
6915
6916   /* Under Windows NT, we need to add stack probes for large/variable allocations,
6917      so do it via a call to the external function alloca, instead of doing it
6918      inline.  */
6919   if (DEFAULT_ABI == ABI_NT
6920       && (GET_CODE (operands[0]) != CONST_INT || INTVAL (operands[0]) > 4096))
6921     {
6922       rtx tmp = gen_reg_rtx (SImode);
6923       emit_library_call_value (gen_rtx (SYMBOL_REF, Pmode, \"__allocate_stack\"),
6924                                tmp, 0, SImode, 1, operands[0], Pmode);
6925       emit_insn (gen_set_sp (tmp));
6926       DONE;
6927     }
6928
6929   if (GET_CODE (operands[0]) != CONST_INT
6930       || INTVAL (operands[0]) < -32767
6931       || INTVAL (operands[0]) > 32768)
6932     {
6933       neg_op0 = gen_reg_rtx (Pmode);
6934       if (TARGET_32BIT)
6935         emit_insn (gen_negsi2 (neg_op0, operands[0]));
6936       else
6937         emit_insn (gen_negdi2 (neg_op0, operands[0]));
6938     }
6939   else
6940     neg_op0 = GEN_INT (- INTVAL (operands[0]));
6941
6942   if (TARGET_32BIT)
6943     emit_insn (gen_movsi_update (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
6944   else
6945     emit_insn (gen_movdi_update (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
6946
6947   DONE;
6948 }")
6949
6950 ;; Marker to indicate that the stack pointer was changed under NT in
6951 ;; ways not known to the compiler
6952
6953 (define_insn "set_sp"
6954   [(set (reg:SI 1)
6955         (unspec [(match_operand:SI 0 "register_operand" "r")] 7))]
6956   ""
6957   ""
6958   [(set_attr "length" "0")])
6959
6960 ;; These patterns say how to save and restore the stack pointer.  We need not
6961 ;; save the stack pointer at function level since we are careful to
6962 ;; preserve the backchain.  At block level, we have to restore the backchain
6963 ;; when we restore the stack pointer.
6964 ;;
6965 ;; For nonlocal gotos, we must save both the stack pointer and its
6966 ;; backchain and restore both.  Note that in the nonlocal case, the
6967 ;; save area is a memory location.
6968
6969 (define_expand "save_stack_function"
6970   [(use (const_int 0))]
6971   ""
6972   "")
6973
6974 (define_expand "restore_stack_function"
6975   [(use (const_int 0))]
6976   ""
6977   "")
6978
6979 (define_expand "restore_stack_block"
6980   [(set (match_dup 2) (mem:SI (match_operand:SI 0 "register_operand" "")))
6981    (set (match_dup 0) (match_operand:SI 1 "register_operand" ""))
6982    (set (mem:SI (match_dup 0)) (match_dup 2))]
6983   ""
6984   "
6985 { operands[2] = gen_reg_rtx (SImode); }")
6986
6987 (define_expand "save_stack_nonlocal"
6988   [(match_operand:DI 0 "memory_operand" "")
6989    (match_operand:SI 1 "register_operand" "")]
6990   ""
6991   "
6992 {
6993   rtx temp = gen_reg_rtx (SImode);
6994
6995   /* Copy the backchain to the first word, sp to the second.  */
6996   emit_move_insn (temp, gen_rtx (MEM, SImode, operands[1]));
6997   emit_move_insn (operand_subword (operands[0], 0, 0, DImode), temp);
6998   emit_move_insn (operand_subword (operands[0], 1, 0, DImode), operands[1]);
6999   DONE;
7000 }")
7001
7002 (define_expand "restore_stack_nonlocal"
7003   [(match_operand:SI 0 "register_operand" "")
7004    (match_operand:DI 1 "memory_operand" "")]
7005   ""
7006   "
7007 {
7008   rtx temp = gen_reg_rtx (SImode);
7009
7010   /* Restore the backchain from the first word, sp from the second.  */
7011   emit_move_insn (temp, operand_subword (operands[1], 0, 0, DImode));
7012   emit_move_insn (operands[0], operand_subword (operands[1], 1, 0, DImode));
7013   emit_move_insn (gen_rtx (MEM, SImode, operands[0]), temp);
7014   DONE;
7015 }")
7016
7017 \f
7018 ;; A function pointer under AIX is a pointer to a data area whose first word
7019 ;; contains the actual address of the function, whose second word contains a
7020 ;; pointer to its TOC, and whose third word contains a value to place in the
7021 ;; static chain register (r11).  Note that if we load the static chain, our
7022 ;; "trampoline" need not have any executable code.
7023 ;;
7024 ;; operands[0] is a register pointing to the 3 word descriptor (aka, the function address)
7025 ;; operands[1] is the stack size to clean up
7026 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument (must be 0 for AIX)
7027 ;; operands[3] is location to store the TOC
7028 ;; operands[4] is the TOC register
7029 ;; operands[5] is the static chain register
7030 ;;
7031 ;; We do not break this into separate insns, so that the scheduler will not try
7032 ;; to move the load of the new TOC before any loads from the TOC.
7033
7034 (define_insn "call_indirect_aix"
7035   [(call (mem:SI (match_operand:SI 0 "register_operand" "b"))
7036          (match_operand 1 "const_int_operand" "n"))
7037    (use (match_operand 2 "const_int_operand" "n"))
7038    (use (match_operand 3 "offsettable_addr_operand" "p"))
7039    (use (match_operand 4 "register_operand" "r"))
7040    (clobber (match_operand 5 "register_operand" "=r"))
7041    (clobber (match_scratch:SI 6 "=&r"))
7042    (clobber (match_scratch:SI 7 "=l"))]
7043   "DEFAULT_ABI == ABI_AIX
7044    && (INTVAL (operands[2]) == CALL_NORMAL || (INTVAL (operands[2]) & CALL_LONG) != 0)"
7045   "{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"
7046   [(set_attr "type" "load")
7047    (set_attr "length" "28")])
7048
7049 (define_insn "call_value_indirect_aix"
7050   [(set (match_operand 0 "register_operand" "fg")
7051         (call (mem:SI (match_operand:SI 1 "register_operand" "b"))
7052               (match_operand 2 "const_int_operand" "n")))
7053    (use (match_operand 3 "const_int_operand" "n"))
7054    (use (match_operand 4 "offsettable_addr_operand" "p"))
7055    (use (match_operand 5 "register_operand" "r"))
7056    (clobber (match_operand 6 "register_operand" "=r"))
7057    (clobber (match_scratch:SI 7 "=&r"))
7058    (clobber (match_scratch:SI 8 "=l"))]
7059   "DEFAULT_ABI == ABI_AIX
7060    && (INTVAL (operands[3]) == CALL_NORMAL || (INTVAL (operands[3]) & CALL_LONG) != 0)"
7061   "{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"
7062   [(set_attr "type" "load")
7063    (set_attr "length" "28")])
7064
7065 ;; A function pointer undef NT is a pointer to a data area whose first word
7066 ;; contains the actual address of the function, whose second word contains a
7067 ;; pointer to its TOC.  The static chain is not stored under NT, which means
7068 ;; that we need a trampoline.
7069 ;;
7070 ;; operands[0] is an SImode pseudo in which we place the address of the function.
7071 ;; operands[1] is the stack size to clean up
7072 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument (must be 0 for NT)
7073 ;; operands[3] is location to store the TOC
7074 ;; operands[4] is the TOC register
7075 ;;
7076 ;; We do not break this into separate insns, so that the scheduler will not try
7077 ;; to move the load of the new TOC before any loads from the TOC.
7078
7079 (define_insn "call_indirect_nt"
7080   [(call (mem:SI (match_operand:SI 0 "register_operand" "b"))
7081          (match_operand 1 "const_int_operand" "n"))
7082    (use (match_operand 2 "const_int_operand" "n"))
7083    (use (match_operand 3 "offsettable_addr_operand" "p"))
7084    (use (match_operand 4 "register_operand" "r"))
7085    (clobber (match_scratch:SI 5 "=&r"))
7086    (clobber (match_scratch:SI 6 "=l"))]
7087   "DEFAULT_ABI == ABI_NT
7088    && (INTVAL (operands[2]) == CALL_NORMAL || (INTVAL (operands[2]) & CALL_LONG) != 0)"
7089   "{st|stw} %4,%a3\;{l|lwz} %5,0(%0)\;{l|lwz} %4,4(%0)\;mt%6 %5\;{brl|blrl}\;{l|lwz} %4,%a3"
7090   [(set_attr "type" "load")
7091    (set_attr "length" "24")])
7092
7093 (define_insn "call_value_indirect_nt"
7094   [(set (match_operand 0 "register_operand" "fg")
7095         (call (mem:SI (match_operand:SI 1 "register_operand" "b"))
7096               (match_operand 2 "const_int_operand" "n")))
7097    (use (match_operand 3 "const_int_operand" "n"))
7098    (use (match_operand 4 "offsettable_addr_operand" "p"))
7099    (use (match_operand 5 "register_operand" "r"))
7100    (clobber (match_scratch:SI 6 "=&r"))
7101    (clobber (match_scratch:SI 7 "=l"))]
7102   "DEFAULT_ABI == ABI_NT
7103    && (INTVAL (operands[3]) == CALL_NORMAL || (INTVAL (operands[3]) & CALL_LONG) != 0)"
7104   "{st|stw} %5,%a4\;{l|lwz} %6,0(%1)\;{l|lwz} %5,4(%1)\;mt%7 %6\;{brl|blrl}\;{l|lwz} %5,%a4"
7105   [(set_attr "type" "load")
7106    (set_attr "length" "24")])
7107
7108 ;; A function pointer under System V is just a normal pointer
7109 ;; operands[0] is the function pointer
7110 ;; operands[1] is the stack size to clean up
7111 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument which indicates how to set cr1
7112
7113 (define_insn "call_indirect_sysv"
7114   [(call (mem:SI (match_operand:SI 0 "register_operand" "l,l"))
7115          (match_operand 1 "const_int_operand" "n,n"))
7116    (use (match_operand 2 "const_int_operand" "O,n"))
7117    (clobber (match_scratch:SI 3 "=l,l"))]
7118   "DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS || DEFAULT_ABI == ABI_AIX_NODESC"
7119   "*
7120 {
7121   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
7122     output_asm_insn (\"crxor 6,6,6\", operands);
7123
7124   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
7125     output_asm_insn (\"creqv 6,6,6\", operands);
7126
7127   return \"{brl|blrl}\";
7128 }"
7129   [(set_attr "type" "jmpreg")
7130    (set_attr "length" "4,8")])
7131
7132 (define_insn "call_value_indirect_sysv"
7133   [(set (match_operand 0 "register_operand" "=fg,fg")
7134         (call (mem:SI (match_operand:SI 1 "register_operand" "l,l"))
7135               (match_operand 2 "const_int_operand" "n,n")))
7136    (use (match_operand 3 "const_int_operand" "O,n"))
7137    (clobber (match_scratch:SI 4 "=l,l"))]
7138   "DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS || DEFAULT_ABI == ABI_AIX_NODESC"
7139   "*
7140 {
7141   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
7142     output_asm_insn (\"crxor 6,6,6\", operands);
7143
7144   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
7145     output_asm_insn (\"creqv 6,6,6\", operands);
7146
7147   return \"{brl|blrl}\";
7148 }"
7149   [(set_attr "type" "jmpreg")
7150    (set_attr "length" "4,8")])
7151
7152 ;; Now the definitions for the call and call_value insns
7153 (define_expand "call"
7154   [(parallel [(call (mem:SI (match_operand:SI 0 "address_operand" ""))
7155                     (match_operand 1 "" ""))
7156               (use (match_operand 2 "" ""))
7157               (clobber (scratch:SI))])]
7158   ""
7159   "
7160 {
7161   if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
7162     abort ();
7163
7164   operands[0] = XEXP (operands[0], 0);
7165
7166   /* Convert NT DLL imports into an indirect call.  */
7167   if (GET_CODE (operands[0]) == SYMBOL_REF
7168       && (INTVAL (operands[2]) & CALL_NT_DLLIMPORT) != 0)
7169     {
7170       operands[0] = rs6000_dll_import_ref (operands[0]);
7171       operands[2] = GEN_INT ((int)CALL_NORMAL);
7172     }
7173
7174   if (GET_CODE (operands[0]) != SYMBOL_REF
7175       || (INTVAL (operands[2]) & CALL_LONG) != 0)
7176     {
7177       if (INTVAL (operands[2]) & CALL_LONG)
7178         operands[0] = rs6000_longcall_ref (operands[0]);
7179
7180       if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_SOLARIS)
7181         emit_call_insn (gen_call_indirect_sysv (force_reg (Pmode, operands[0]),
7182                                                 operands[1], operands[2]));
7183       else
7184         {
7185           rtx toc_reg = gen_rtx (REG, Pmode, 2);
7186           rtx toc_addr = RS6000_SAVE_TOC;
7187
7188           if (DEFAULT_ABI == ABI_AIX)
7189             {
7190               /* AIX function pointers are really pointers to a three word area */
7191               rtx static_chain = gen_rtx (REG, Pmode, STATIC_CHAIN_REGNUM);
7192               emit_call_insn (gen_call_indirect_aix (force_reg (Pmode, operands[0]),
7193                                                      operands[1], operands[2],
7194                                                      toc_addr, toc_reg, static_chain));
7195             }
7196           else if (DEFAULT_ABI == ABI_NT)
7197             {
7198               /* NT function pointers are really pointers to a two word area */
7199               rs6000_save_toc_p = 1;
7200               emit_call_insn (gen_call_indirect_nt (force_reg (Pmode, operands[0]),
7201                                                     operands[1], operands[2],
7202                                                     toc_addr, toc_reg));
7203             }
7204           else
7205             abort ();
7206         }
7207       DONE;
7208     }
7209 }")
7210
7211 (define_expand "call_value"
7212   [(parallel [(set (match_operand 0 "" "")
7213                    (call (mem:SI (match_operand:SI 1 "address_operand" ""))
7214                          (match_operand 2 "" "")))
7215               (use (match_operand 3 "" ""))
7216               (clobber (scratch:SI))])]
7217   ""
7218   "
7219 {
7220   if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
7221     abort ();
7222
7223   operands[1] = XEXP (operands[1], 0);
7224
7225   /* Convert NT DLL imports into an indirect call.  */
7226   if (GET_CODE (operands[1]) == SYMBOL_REF
7227       && (INTVAL (operands[3]) & CALL_NT_DLLIMPORT) != 0)
7228     {
7229       operands[1] = rs6000_dll_import_ref (operands[1]);
7230       operands[3] = GEN_INT ((int)CALL_NORMAL);
7231     }
7232
7233   if (GET_CODE (operands[1]) != SYMBOL_REF
7234       || (INTVAL (operands[3]) & CALL_LONG) != 0)
7235     {
7236       if (INTVAL (operands[2]) & CALL_LONG)
7237         operands[1] = rs6000_longcall_ref (operands[1]);
7238
7239       if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_SOLARIS)
7240         emit_call_insn (gen_call_value_indirect_sysv (operands[0], operands[1],
7241                                                       operands[2], operands[3]));
7242       else
7243         {
7244           rtx toc_reg = gen_rtx (REG, Pmode, 2);
7245           rtx toc_addr = RS6000_SAVE_TOC;
7246
7247           if (DEFAULT_ABI == ABI_AIX)
7248             {
7249               /* AIX function pointers are really pointers to a three word area */
7250               rtx static_chain = gen_rtx (REG, Pmode, STATIC_CHAIN_REGNUM);
7251               emit_call_insn (gen_call_value_indirect_aix (operands[0],
7252                                                            force_reg (Pmode, operands[1]),
7253                                                            operands[2], operands[3],
7254                                                            toc_addr, toc_reg, static_chain));
7255             }
7256           else if (DEFAULT_ABI == ABI_NT)
7257             {
7258               /* NT function pointers are really pointers to a two word area */
7259               rs6000_save_toc_p = 1;
7260               emit_call_insn (gen_call_value_indirect_nt (operands[0],
7261                                                           force_reg (Pmode, operands[1]),
7262                                                           operands[2], operands[3],
7263                                                           toc_addr, toc_reg));
7264             }
7265           else
7266             abort ();
7267         }
7268       DONE;
7269     }
7270 }")
7271
7272 ;; Call to function in current module.  No TOC pointer reload needed.
7273 ;; Operand2 is non-zero if we are using the V.4 calling sequence and
7274 ;; either the function was not prototyped, or it was prototyped as a
7275 ;; variable argument function.  It is > 0 if FP registers were passed
7276 ;; and < 0 if they were not.
7277
7278 (define_insn ""
7279   [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
7280          (match_operand 1 "" "g,g"))
7281    (use (match_operand:SI 2 "immediate_operand" "O,n"))
7282    (clobber (match_scratch:SI 3 "=l,l"))]
7283   "(INTVAL (operands[2]) & CALL_LONG) == 0"
7284   "*
7285 {
7286   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
7287     output_asm_insn (\"crxor 6,6,6\", operands);
7288
7289   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
7290     output_asm_insn (\"creqv 6,6,6\", operands);
7291
7292   return \"bl %z0\";
7293 }"
7294   [(set_attr "type" "branch")
7295    (set_attr "length" "4,8")])
7296
7297 ;; Call to function which may be in another module.  Restore the TOC
7298 ;; pointer (r2) after the call unless this is System V.
7299 ;; Operand2 is non-zero if we are using the V.4 calling sequence and
7300 ;; either the function was not prototyped, or it was prototyped as a
7301 ;; variable argument function.  It is > 0 if FP registers were passed
7302 ;; and < 0 if they were not.
7303
7304 (define_insn ""
7305   [(call (mem:SI (match_operand:SI 0 "call_operand" "s,s"))
7306          (match_operand 1 "" "fg,fg"))
7307    (use (match_operand:SI 2 "immediate_operand" "O,n"))
7308    (clobber (match_scratch:SI 3 "=l,l"))]
7309   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)
7310    && (INTVAL (operands[2]) & CALL_LONG) == 0"
7311   "*
7312 {
7313   /* Indirect calls should go through call_indirect */
7314   if (GET_CODE (operands[0]) == REG)
7315     abort ();
7316
7317   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
7318     output_asm_insn (\"crxor 6,6,6\", operands);
7319
7320   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
7321     output_asm_insn (\"creqv 6,6,6\", operands);
7322
7323   return (TARGET_WINDOWS_NT) ? \"bl %z0\;.znop %z0\" : \"bl %z0\;%.\";
7324 }"
7325   [(set_attr "type" "branch")
7326    (set_attr "length" "8,12")])
7327
7328 (define_insn ""
7329   [(call (mem:SI (match_operand:SI 0 "call_operand" "s,s"))
7330          (match_operand 1 "" "fg,fg"))
7331    (use (match_operand:SI 2 "immediate_operand" "O,n"))
7332    (clobber (match_scratch:SI 3 "=l,l"))]
7333   "(DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS)
7334    && (INTVAL (operands[2]) & CALL_LONG) == 0"
7335   "*
7336 {
7337   /* Indirect calls should go through call_indirect */
7338   if (GET_CODE (operands[0]) == REG)
7339     abort ();
7340
7341   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
7342     output_asm_insn (\"crxor 6,6,6\", operands);
7343
7344   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
7345     output_asm_insn (\"creqv 6,6,6\", operands);
7346
7347   return \"bl %z0\";
7348 }"
7349   [(set_attr "type" "branch")
7350    (set_attr "length" "4,8")])
7351
7352 (define_insn ""
7353   [(set (match_operand 0 "" "=fg,fg")
7354         (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
7355               (match_operand 2 "" "g,g")))
7356    (use (match_operand:SI 3 "immediate_operand" "O,n"))
7357    (clobber (match_scratch:SI 4 "=l,l"))]
7358   "(INTVAL (operands[3]) & CALL_LONG) == 0"
7359   "*
7360 {
7361   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
7362     output_asm_insn (\"crxor 6,6,6\", operands);
7363
7364   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
7365     output_asm_insn (\"creqv 6,6,6\", operands);
7366
7367   return \"bl %z1\";
7368 }"
7369   [(set_attr "type" "branch")
7370    (set_attr "length" "4,8")])
7371
7372 (define_insn ""
7373   [(set (match_operand 0 "" "=fg,fg")
7374         (call (mem:SI (match_operand:SI 1 "call_operand" "s,s"))
7375               (match_operand 2 "" "fg,fg")))
7376    (use (match_operand:SI 3 "immediate_operand" "O,n"))
7377    (clobber (match_scratch:SI 4 "=l,l"))]
7378   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_NT)
7379    && (INTVAL (operands[3]) & CALL_LONG) == 0"
7380   "*
7381 {
7382   /* This should be handled by call_value_indirect */
7383   if (GET_CODE (operands[1]) == REG)
7384     abort ();
7385
7386   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
7387     output_asm_insn (\"crxor 6,6,6\", operands);
7388
7389   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
7390     output_asm_insn (\"creqv 6,6,6\", operands);
7391
7392   return (TARGET_WINDOWS_NT) ? \"bl %z1\;.znop %z1\" : \"bl %z1\;%.\";
7393 }"
7394   [(set_attr "type" "branch")
7395    (set_attr "length" "8,12")])
7396
7397 (define_insn ""
7398   [(set (match_operand 0 "" "=fg,fg")
7399         (call (mem:SI (match_operand:SI 1 "call_operand" "s,s"))
7400               (match_operand 2 "" "fg,fg")))
7401    (use (match_operand:SI 3 "immediate_operand" "O,n"))
7402    (clobber (match_scratch:SI 4 "=l,l"))]
7403   "(DEFAULT_ABI == ABI_AIX_NODESC || DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS)
7404    && (INTVAL (operands[3]) & CALL_LONG) == 0"
7405   "*
7406 {
7407   /* This should be handled by call_value_indirect */
7408   if (GET_CODE (operands[1]) == REG)
7409     abort ();
7410
7411   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
7412     output_asm_insn (\"crxor 6,6,6\", operands);
7413
7414   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
7415     output_asm_insn (\"creqv 6,6,6\", operands);
7416
7417   return \"bl %z1\";
7418 }"
7419   [(set_attr "type" "branch")
7420    (set_attr "length" "4,8")])
7421
7422 ;; Call subroutine returning any type.
7423 (define_expand "untyped_call"
7424   [(parallel [(call (match_operand 0 "" "")
7425                     (const_int 0))
7426               (match_operand 1 "" "")
7427               (match_operand 2 "" "")])]
7428   ""
7429   "
7430 {
7431   int i;
7432
7433   emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx, const0_rtx));
7434
7435   for (i = 0; i < XVECLEN (operands[2], 0); i++)
7436     {
7437       rtx set = XVECEXP (operands[2], 0, i);
7438       emit_move_insn (SET_DEST (set), SET_SRC (set));
7439     }
7440
7441   /* The optimizer does not know that the call sets the function value
7442      registers we stored in the result block.  We avoid problems by
7443      claiming that all hard registers are used and clobbered at this
7444      point.  */
7445   emit_insn (gen_blockage ());
7446
7447   DONE;
7448 }")
7449
7450 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
7451 ;; all of memory.  This blocks insns from being moved across this point.
7452
7453 (define_insn "blockage"
7454   [(unspec_volatile [(const_int 0)] 0)]
7455   ""
7456   "")
7457
7458 ;; Synchronize instructions/data caches for V.4 trampolines
7459 ;; The extra memory_operand is to prevent the optimizer from
7460 ;; deleting insns with "no" effect.
7461 (define_insn "icbi"
7462   [(unspec [(match_operand 0 "memory_operand" "=m")
7463             (match_operand 1 "register_operand" "b")
7464             (match_operand 2 "register_operand" "r")] 3)]
7465   "TARGET_POWERPC"
7466   "icbi %1,%2")
7467
7468 (define_insn "dcbst"
7469   [(unspec [(match_operand 0 "memory_operand" "=m")
7470             (match_operand 1 "register_operand" "b")
7471             (match_operand 2 "register_operand" "r")] 4)]
7472   "TARGET_POWERPC"
7473   "dcbst %1,%2")
7474
7475 (define_insn "sync"
7476   [(unspec [(match_operand 0 "memory_operand" "=m")] 5)]
7477   ""
7478   "{dcs|sync}")
7479
7480 (define_insn "isync"
7481   [(unspec [(match_operand 0 "memory_operand" "=m")] 6)]
7482   ""
7483   "{ics|isync}")
7484
7485
7486 ;; V.4 specific code to initialize the PIC register
7487
7488 (define_insn "init_v4_pic"
7489   [(set (match_operand:SI 0 "register_operand" "=l")
7490         (unspec [(const_int 0)] 7))]
7491   "DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_SOLARIS"
7492   "bl _GLOBAL_OFFSET_TABLE_-4"
7493   [(set_attr "type" "branch")])
7494
7495 \f
7496 ;; Compare insns are next.  Note that the RS/6000 has two types of compares,
7497 ;; signed & unsigned, and one type of branch.
7498 ;;
7499 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
7500 ;; insns, and branches.  We store the operands of compares until we see
7501 ;; how it is used.
7502 (define_expand "cmpsi"
7503   [(set (cc0)
7504         (compare (match_operand:SI 0 "gpc_reg_operand" "")
7505                  (match_operand:SI 1 "reg_or_short_operand" "")))]
7506   ""
7507   "
7508 {
7509   /* Take care of the possibility that operands[1] might be negative but
7510      this might be a logical operation.  That insn doesn't exist.  */
7511   if (GET_CODE (operands[1]) == CONST_INT
7512       && INTVAL (operands[1]) < 0)
7513     operands[1] = force_reg (SImode, operands[1]);
7514
7515   rs6000_compare_op0 = operands[0];
7516   rs6000_compare_op1 = operands[1];
7517   rs6000_compare_fp_p = 0;
7518   DONE;
7519 }")
7520
7521 (define_expand "cmpdi"
7522   [(set (cc0)
7523         (compare (match_operand:DI 0 "gpc_reg_operand" "")
7524                  (match_operand:DI 1 "reg_or_short_operand" "")))]
7525   "TARGET_POWERPC64"
7526   "
7527 {
7528   /* Take care of the possibility that operands[1] might be negative but
7529      this might be a logical operation.  That insn doesn't exist.  */
7530   if (GET_CODE (operands[1]) == CONST_INT
7531       && INTVAL (operands[1]) < 0)
7532     operands[1] = force_reg (DImode, operands[1]);
7533
7534   rs6000_compare_op0 = operands[0];
7535   rs6000_compare_op1 = operands[1];
7536   rs6000_compare_fp_p = 0;
7537   DONE;
7538 }")
7539
7540 (define_expand "cmpsf"
7541   [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
7542                        (match_operand:SF 1 "gpc_reg_operand" "")))]
7543   "TARGET_HARD_FLOAT"
7544   "
7545 {
7546   rs6000_compare_op0 = operands[0];
7547   rs6000_compare_op1 = operands[1];
7548   rs6000_compare_fp_p = 1;
7549   DONE;
7550 }")
7551
7552 (define_expand "cmpdf"
7553   [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
7554                        (match_operand:DF 1 "gpc_reg_operand" "")))]
7555   "TARGET_HARD_FLOAT"
7556   "
7557 {
7558   rs6000_compare_op0 = operands[0];
7559   rs6000_compare_op1 = operands[1];
7560   rs6000_compare_fp_p = 1;
7561   DONE;
7562 }")
7563
7564 (define_expand "beq"
7565   [(set (match_dup 2) (match_dup 1))
7566    (set (pc)
7567         (if_then_else (eq (match_dup 2)
7568                           (const_int 0))
7569                       (label_ref (match_operand 0 "" ""))
7570                       (pc)))]
7571   ""
7572   "
7573 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7574   operands[1] = gen_rtx (COMPARE, mode,
7575                          rs6000_compare_op0, rs6000_compare_op1);
7576   operands[2] = gen_reg_rtx (mode);
7577 }")
7578
7579 (define_expand "bne"
7580   [(set (match_dup 2) (match_dup 1))
7581    (set (pc)
7582         (if_then_else (ne (match_dup 2)
7583                           (const_int 0))
7584                       (label_ref (match_operand 0 "" ""))
7585                       (pc)))]
7586   ""
7587   "
7588 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7589   operands[1] = gen_rtx (COMPARE, mode,
7590                          rs6000_compare_op0, rs6000_compare_op1);
7591   operands[2] = gen_reg_rtx (mode);
7592 }")
7593
7594 (define_expand "blt"
7595   [(set (match_dup 2) (match_dup 1))
7596    (set (pc)
7597         (if_then_else (lt (match_dup 2)
7598                           (const_int 0))
7599                       (label_ref (match_operand 0 "" ""))
7600                       (pc)))]
7601   ""
7602   "
7603 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7604   operands[1] = gen_rtx (COMPARE, mode,
7605                          rs6000_compare_op0, rs6000_compare_op1);
7606   operands[2] = gen_reg_rtx (mode);
7607 }")
7608
7609 (define_expand "bgt"
7610   [(set (match_dup 2) (match_dup 1))
7611    (set (pc)
7612         (if_then_else (gt (match_dup 2)
7613                           (const_int 0))
7614                       (label_ref (match_operand 0 "" ""))
7615                       (pc)))]
7616   ""
7617   "
7618 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7619   operands[1] = gen_rtx (COMPARE, mode,
7620                          rs6000_compare_op0, rs6000_compare_op1);
7621   operands[2] = gen_reg_rtx (mode);
7622 }")
7623
7624 (define_expand "ble"
7625   [(set (match_dup 2) (match_dup 1))
7626    (set (pc)
7627         (if_then_else (le (match_dup 2)
7628                           (const_int 0))
7629                       (label_ref (match_operand 0 "" ""))
7630                       (pc)))]
7631   ""
7632   "
7633 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7634   operands[1] = gen_rtx (COMPARE, mode,
7635                          rs6000_compare_op0, rs6000_compare_op1);
7636   operands[2] = gen_reg_rtx (mode);
7637 }")
7638
7639 (define_expand "bge"
7640   [(set (match_dup 2) (match_dup 1))
7641    (set (pc)
7642         (if_then_else (ge (match_dup 2)
7643                           (const_int 0))
7644                       (label_ref (match_operand 0 "" ""))
7645                       (pc)))]
7646   ""
7647   "
7648 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7649   operands[1] = gen_rtx (COMPARE, mode,
7650                          rs6000_compare_op0, rs6000_compare_op1);
7651   operands[2] = gen_reg_rtx (mode);
7652 }")
7653
7654 (define_expand "bgtu"
7655   [(set (match_dup 2) (match_dup 1))
7656    (set (pc)
7657         (if_then_else (gtu (match_dup 2)
7658                            (const_int 0))
7659                       (label_ref (match_operand 0 "" ""))
7660                       (pc)))]
7661   ""
7662   "
7663 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7664                          rs6000_compare_op0, rs6000_compare_op1);
7665   operands[2] = gen_reg_rtx (CCUNSmode);
7666 }")
7667
7668 (define_expand "bltu"
7669   [(set (match_dup 2) (match_dup 1))
7670    (set (pc)
7671         (if_then_else (ltu (match_dup 2)
7672                            (const_int 0))
7673                       (label_ref (match_operand 0 "" ""))
7674                       (pc)))]
7675   ""
7676   "
7677 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7678                          rs6000_compare_op0, rs6000_compare_op1);
7679   operands[2] = gen_reg_rtx (CCUNSmode);
7680 }")
7681
7682 (define_expand "bgeu"
7683   [(set (match_dup 2) (match_dup 1))
7684    (set (pc)
7685         (if_then_else (geu (match_dup 2)
7686                            (const_int 0))
7687                       (label_ref (match_operand 0 "" ""))
7688                       (pc)))]
7689   ""
7690   "
7691 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7692                          rs6000_compare_op0, rs6000_compare_op1);
7693   operands[2] = gen_reg_rtx (CCUNSmode);
7694 }")
7695
7696 (define_expand "bleu"
7697   [(set (match_dup 2) (match_dup 1))
7698    (set (pc)
7699         (if_then_else (leu (match_dup 2)
7700                            (const_int 0))
7701                       (label_ref (match_operand 0 "" ""))
7702                       (pc)))]
7703   ""
7704   "
7705 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7706                          rs6000_compare_op0, rs6000_compare_op1);
7707   operands[2] = gen_reg_rtx (CCUNSmode);
7708 }")
7709
7710 ;; For SNE, we would prefer that the xor/abs sequence be used for integers.
7711 ;; For SEQ, likewise, except that comparisons with zero should be done
7712 ;; with an scc insns.  However, due to the order that combine see the
7713 ;; resulting insns, we must, in fact, allow SEQ for integers.  Fail in
7714 ;; the cases we don't want to handle.
7715 (define_expand "seq"
7716   [(set (match_dup 2) (match_dup 1))
7717    (set (match_operand:SI 0 "gpc_reg_operand" "")
7718         (eq:SI (match_dup 2) (const_int 0)))]
7719   ""
7720   "
7721 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7722   operands[1] = gen_rtx (COMPARE, mode,
7723                          rs6000_compare_op0, rs6000_compare_op1);
7724   operands[2] = gen_reg_rtx (mode);
7725 }")
7726
7727 (define_expand "sne"
7728   [(set (match_dup 2) (match_dup 1))
7729    (set (match_operand:SI 0 "gpc_reg_operand" "")
7730         (ne:SI (match_dup 2) (const_int 0)))]
7731   ""
7732   "
7733 { if (! rs6000_compare_fp_p)
7734     FAIL;
7735
7736   operands[1] = gen_rtx (COMPARE, CCFPmode,
7737                          rs6000_compare_op0, rs6000_compare_op1);
7738   operands[2] = gen_reg_rtx (CCFPmode);
7739 }")
7740
7741 ;; A > 0 is best done using the portable sequence, so fail in that case.
7742 (define_expand "sgt"
7743   [(set (match_dup 2) (match_dup 1))
7744    (set (match_operand:SI 0 "gpc_reg_operand" "")
7745         (gt:SI (match_dup 2) (const_int 0)))]
7746   ""
7747   "
7748 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7749
7750   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
7751     FAIL;
7752
7753   operands[1] = gen_rtx (COMPARE, mode,
7754                          rs6000_compare_op0, rs6000_compare_op1);
7755   operands[2] = gen_reg_rtx (mode);
7756 }")
7757
7758 ;; A < 0 is best done in the portable way for A an integer.
7759 (define_expand "slt"
7760   [(set (match_dup 2) (match_dup 1))
7761    (set (match_operand:SI 0 "gpc_reg_operand" "")
7762         (lt:SI (match_dup 2) (const_int 0)))]
7763   ""
7764   "
7765 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7766
7767   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
7768     FAIL;
7769
7770   operands[1] = gen_rtx (COMPARE, mode,
7771                          rs6000_compare_op0, rs6000_compare_op1);
7772   operands[2] = gen_reg_rtx (mode);
7773 }")
7774
7775 (define_expand "sge"
7776   [(set (match_dup 2) (match_dup 1))
7777    (set (match_operand:SI 0 "gpc_reg_operand" "")
7778         (ge:SI (match_dup 2) (const_int 0)))]
7779   ""
7780   "
7781 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7782   operands[1] = gen_rtx (COMPARE, mode,
7783                          rs6000_compare_op0, rs6000_compare_op1);
7784   operands[2] = gen_reg_rtx (mode);
7785 }")
7786
7787 ;; A <= 0 is best done the portable way for A an integer.
7788 (define_expand "sle"
7789   [(set (match_dup 2) (match_dup 1))
7790    (set (match_operand:SI 0 "gpc_reg_operand" "")
7791         (le:SI (match_dup 2) (const_int 0)))]
7792   ""
7793   "
7794 { enum machine_mode mode = rs6000_compare_fp_p ? CCFPmode : CCmode;
7795
7796   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
7797     FAIL;
7798
7799   operands[1] = gen_rtx (COMPARE, mode,
7800                          rs6000_compare_op0, rs6000_compare_op1);
7801   operands[2] = gen_reg_rtx (mode);
7802 }")
7803
7804 (define_expand "sgtu"
7805   [(set (match_dup 2) (match_dup 1))
7806    (set (match_operand:SI 0 "gpc_reg_operand" "")
7807         (gtu:SI (match_dup 2) (const_int 0)))]
7808   ""
7809   "
7810 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7811                          rs6000_compare_op0, rs6000_compare_op1);
7812   operands[2] = gen_reg_rtx (CCUNSmode);
7813 }")
7814
7815 (define_expand "sltu"
7816   [(set (match_dup 2) (match_dup 1))
7817    (set (match_operand:SI 0 "gpc_reg_operand" "")
7818         (ltu:SI (match_dup 2) (const_int 0)))]
7819   ""
7820   "
7821 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7822                          rs6000_compare_op0, rs6000_compare_op1);
7823   operands[2] = gen_reg_rtx (CCUNSmode);
7824 }")
7825
7826 (define_expand "sgeu"
7827   [(set (match_dup 2) (match_dup 1))
7828    (set (match_operand:SI 0 "gpc_reg_operand" "")
7829         (geu:SI (match_dup 2) (const_int 0)))]
7830   ""
7831   "
7832 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7833                          rs6000_compare_op0, rs6000_compare_op1);
7834   operands[2] = gen_reg_rtx (CCUNSmode);
7835 }")
7836
7837 (define_expand "sleu"
7838   [(set (match_dup 2) (match_dup 1))
7839    (set (match_operand:SI 0 "gpc_reg_operand" "")
7840         (leu:SI (match_dup 2) (const_int 0)))]
7841   ""
7842   "
7843 { operands[1] = gen_rtx (COMPARE, CCUNSmode,
7844                          rs6000_compare_op0, rs6000_compare_op1);
7845   operands[2] = gen_reg_rtx (CCUNSmode);
7846 }")
7847 \f
7848 ;; Here are the actual compare insns.
7849 (define_insn ""
7850   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
7851         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
7852                     (match_operand:SI 2 "reg_or_short_operand" "rI")))]
7853   ""
7854   "{cmp%I2|cmpw%I2} %0,%1,%2"
7855   [(set_attr "type" "compare")])
7856
7857 (define_insn ""
7858   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
7859         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
7860                     (match_operand:DI 2 "reg_or_short_operand" "rI")))]
7861   "TARGET_POWERPC64"
7862   "cmpd%I2 %0,%1,%2"
7863   [(set_attr "type" "compare")])
7864
7865 ;; If we are comparing a register for equality with a large constant,
7866 ;; we can do this with an XOR followed by a compare.  But we need a scratch
7867 ;; register for the result of the XOR.
7868
7869 (define_split
7870   [(set (match_operand:CC 0 "cc_reg_operand" "")
7871         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
7872                     (match_operand:SI 2 "non_short_cint_operand" "")))
7873    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
7874   "find_single_use (operands[0], insn, 0)
7875    && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
7876        || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
7877   [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
7878    (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
7879   "
7880 {
7881   /* Get the constant we are comparing against, C,  and see what it looks like
7882      sign-extended to 16 bits.  Then see what constant could be XOR'ed
7883      with C to get the sign-extended value.  */
7884
7885   int c = INTVAL (operands[2]);
7886   int sextc = (c << 16) >> 16;
7887   int xorv = c ^ sextc;
7888
7889   operands[4] = gen_rtx (CONST_INT, VOIDmode, xorv);
7890   operands[5] = gen_rtx (CONST_INT, VOIDmode, sextc);
7891 }")
7892
7893 (define_insn ""
7894   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
7895         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
7896                        (match_operand:SI 2 "reg_or_u_short_operand" "rI")))]
7897   ""
7898   "{cmpl%I2|cmplw%I2} %0,%1,%W2"
7899   [(set_attr "type" "compare")])
7900
7901 (define_insn ""
7902   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
7903         (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
7904                        (match_operand:DI 2 "reg_or_u_short_operand" "rI")))]
7905   ""
7906   "cmpld%I2 %0,%1,%W2"
7907   [(set_attr "type" "compare")])
7908
7909 ;; The following two insns don't exist as single insns, but if we provide
7910 ;; them, we can swap an add and compare, which will enable us to overlap more
7911 ;; of the required delay between a compare and branch.  We generate code for
7912 ;; them by splitting.
7913
7914 (define_insn ""
7915   [(set (match_operand:CC 3 "cc_reg_operand" "=y")
7916         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
7917                     (match_operand:SI 2 "short_cint_operand" "i")))
7918    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7919         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
7920   ""
7921   "#"
7922   [(set_attr "length" "8")])
7923
7924 (define_insn ""
7925   [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
7926         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
7927                        (match_operand:SI 2 "u_short_cint_operand" "i")))
7928    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
7929         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
7930   ""
7931   "#"
7932   [(set_attr "length" "8")])
7933
7934 (define_split
7935   [(set (match_operand:CC 3 "cc_reg_operand" "")
7936         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
7937                     (match_operand:SI 2 "short_cint_operand" "")))
7938    (set (match_operand:SI 0 "gpc_reg_operand" "")
7939         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
7940   ""
7941   [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
7942    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
7943
7944 (define_split
7945   [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
7946         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
7947                        (match_operand:SI 2 "u_short_cint_operand" "")))
7948    (set (match_operand:SI 0 "gpc_reg_operand" "")
7949         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
7950   ""
7951   [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
7952    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
7953
7954 (define_insn ""
7955   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
7956         (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
7957                       (match_operand:SF 2 "gpc_reg_operand" "f")))]
7958   "TARGET_HARD_FLOAT"
7959   "fcmpu %0,%1,%2"
7960   [(set_attr "type" "fpcompare")])
7961
7962 (define_insn ""
7963   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
7964         (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
7965                       (match_operand:DF 2 "gpc_reg_operand" "f")))]
7966   "TARGET_HARD_FLOAT"
7967   "fcmpu %0,%1,%2"
7968   [(set_attr "type" "fpcompare")])
7969 \f
7970 ;; Now we have the scc insns.  We can do some combinations because of the
7971 ;; way the machine works.
7972 ;;
7973 ;; Note that this is probably faster if we can put an insn between the
7974 ;; mfcr and rlinm, but this is tricky.  Let's leave it for now.  In most
7975 ;; cases the insns below which don't use an intermediate CR field will
7976 ;; be used instead.
7977 (define_insn ""
7978   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7979         (match_operator:SI 1 "scc_comparison_operator"
7980                            [(match_operand 2 "cc_reg_operand" "y")
7981                             (const_int 0)]))]
7982   ""
7983   "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%J1,1"
7984   [(set_attr "length" "12")])
7985
7986 (define_insn ""
7987   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
7988         (compare:CC (match_operator:SI 1 "scc_comparison_operator"
7989                                        [(match_operand 2 "cc_reg_operand" "y")
7990                                         (const_int 0)])
7991                     (const_int 0)))
7992    (set (match_operand:SI 3 "gpc_reg_operand" "=r")
7993         (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
7994   ""
7995   "%D1mfcr %3\;{rlinm.|rlwinm.} %3,%3,%J1,1"
7996   [(set_attr "type" "delayed_compare")
7997    (set_attr "length" "12")])
7998
7999 (define_insn ""
8000   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8001         (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
8002                                       [(match_operand 2 "cc_reg_operand" "y")
8003                                        (const_int 0)])
8004                    (match_operand:SI 3 "const_int_operand" "n")))]
8005   ""
8006   "*
8007 {
8008   int is_bit = ccr_bit (operands[1], 1);
8009   int put_bit = 31 - (INTVAL (operands[3]) & 31);
8010   int count;
8011
8012   if (is_bit >= put_bit)
8013     count = is_bit - put_bit;
8014   else
8015     count = 32 - (put_bit - is_bit);
8016
8017   operands[4] = gen_rtx (CONST_INT, VOIDmode, count);
8018   operands[5] = gen_rtx (CONST_INT, VOIDmode, put_bit);
8019
8020   return \"%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
8021 }"
8022  [(set_attr "length" "12")])
8023
8024 (define_insn ""
8025   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8026         (compare:CC
8027          (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
8028                                        [(match_operand 2 "cc_reg_operand" "y")
8029                                         (const_int 0)])
8030                     (match_operand:SI 3 "const_int_operand" "n"))
8031          (const_int 0)))
8032    (set (match_operand:SI 4 "gpc_reg_operand" "=r")
8033         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
8034                    (match_dup 3)))]
8035   ""
8036   "*
8037 {
8038   int is_bit = ccr_bit (operands[1], 1);
8039   int put_bit = 31 - (INTVAL (operands[3]) & 31);
8040   int count;
8041
8042   if (is_bit >= put_bit)
8043     count = is_bit - put_bit;
8044   else
8045     count = 32 - (put_bit - is_bit);
8046
8047   operands[5] = gen_rtx (CONST_INT, VOIDmode, count);
8048   operands[6] = gen_rtx (CONST_INT, VOIDmode, put_bit);
8049
8050   return \"%D1mfcr %4\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
8051 }"
8052   [(set_attr "type" "delayed_compare")
8053    (set_attr "length" "12")])
8054
8055 ;; If we are comparing the result of two comparisons, this can be done
8056 ;; using creqv or crxor.
8057
8058 (define_insn ""
8059   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
8060         (compare:CCEQ (match_operator 1 "scc_comparison_operator"
8061                               [(match_operand 2 "cc_reg_operand" "y")
8062                                (const_int 0)])
8063                       (match_operator 3 "scc_comparison_operator"
8064                               [(match_operand 4 "cc_reg_operand" "y")
8065                                (const_int 0)])))]
8066   "REGNO (operands[2]) != REGNO (operands[4])"
8067   "*
8068 {
8069   enum rtx_code code1, code2;
8070
8071   code1 = GET_CODE (operands[1]);
8072   code2 = GET_CODE (operands[3]);
8073
8074   if ((code1 == EQ || code1 == LT || code1 == GT
8075        || code1 == LTU || code1 == GTU
8076        || (code1 != NE && GET_MODE (operands[2]) == CCFPmode))
8077       !=
8078       (code2 == EQ || code2 == LT || code2 == GT
8079        || code2 == LTU || code2 == GTU
8080        || (code2 != NE && GET_MODE (operands[4]) == CCFPmode)))
8081     return \"%C1%C3crxor %E0,%j1,%j3\";
8082   else
8083     return \"%C1%C3creqv %E0,%j1,%j3\";
8084 }"
8085   [(set_attr "length" "12")])
8086
8087 ;; There is a 3 cycle delay between consecutive mfcr instructions
8088 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
8089
8090 (define_peephole
8091   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8092         (match_operator:SI 1 "scc_comparison_operator"
8093                            [(match_operand 2 "cc_reg_operand" "y")
8094                             (const_int 0)]))
8095    (set (match_operand:SI 3 "gpc_reg_operand" "=r")
8096         (match_operator:SI 4 "scc_comparison_operator"
8097                            [(match_operand 5 "cc_reg_operand" "y")
8098                             (const_int 0)]))]
8099    "REGNO (operands[2]) != REGNO (operands[5])"
8100    "%D1%D4mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
8101    [(set_attr "length" "20")])
8102
8103 ;; There are some scc insns that can be done directly, without a compare.
8104 ;; These are faster because they don't involve the communications between
8105 ;; the FXU and branch units.   In fact, we will be replacing all of the
8106 ;; integer scc insns here or in the portable methods in emit_store_flag.
8107 ;;
8108 ;; Also support (neg (scc ..)) since that construct is used to replace
8109 ;; branches, (plus (scc ..) ..) since that construct is common and
8110 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
8111 ;; cases where it is no more expensive than (neg (scc ..)).
8112
8113 ;; Have reload force a constant into a register for the simple insns that
8114 ;; otherwise won't accept constants.  We do this because it is faster than
8115 ;; the cmp/mfcr sequence we would otherwise generate.
8116
8117 (define_insn ""
8118   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
8119         (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
8120                (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I")))
8121    (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
8122   ""
8123   "@
8124    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
8125    {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
8126    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
8127    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
8128    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
8129   [(set_attr "length" "12,8,12,12,12")])
8130
8131 (define_insn ""
8132   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x")
8133         (compare:CC
8134          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
8135                 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
8136          (const_int 0)))
8137    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
8138         (eq:SI (match_dup 1) (match_dup 2)))
8139    (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
8140   ""
8141   "@
8142    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
8143    {sfi|subfic} %3,%1,0\;{ae.|adde.} %0,%3,%1
8144    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
8145    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
8146    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0"
8147   [(set_attr "type" "compare")
8148    (set_attr "length" "12,8,12,12,12")])
8149
8150 ;; We have insns of the form shown by the first define_insn below.  If
8151 ;; there is something inside the comparison operation, we must split it.
8152 (define_split
8153   [(set (match_operand:SI 0 "gpc_reg_operand" "")
8154         (plus:SI (match_operator 1 "comparison_operator"
8155                                  [(match_operand:SI 2 "" "")
8156                                   (match_operand:SI 3
8157                                                     "reg_or_cint_operand" "")])
8158                  (match_operand:SI 4 "gpc_reg_operand" "")))
8159    (clobber (match_operand:SI 5 "register_operand" ""))]
8160   "! gpc_reg_operand (operands[2], SImode)"
8161   [(set (match_dup 5) (match_dup 2))
8162    (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
8163                                (match_dup 4)))])
8164
8165 (define_insn ""
8166   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
8167         (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
8168                         (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
8169                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))
8170    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
8171   ""
8172   "@
8173    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
8174    {sfi|subfic} %4,%1,0\;{aze|addze} %0,%3
8175    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
8176    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
8177    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3"
8178   [(set_attr "length" "12,8,12,12,12")])
8179
8180 (define_insn ""
8181   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x")
8182         (compare:CC
8183          (plus:SI
8184           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
8185                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
8186           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r"))
8187          (const_int 0)))
8188    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
8189   ""
8190   "@
8191    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
8192    {sfi|subfic} %4,%1,0\;{aze.|addze.} %0,%3
8193    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
8194    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
8195    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3"
8196   [(set_attr "type" "compare")
8197    (set_attr "length" "12,8,12,12,12")])
8198
8199 (define_insn ""
8200   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,x,x,x")
8201         (compare:CC
8202          (plus:SI
8203           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
8204                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))
8205           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r"))
8206          (const_int 0)))
8207    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
8208         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8209    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
8210   ""
8211   "@
8212    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
8213    {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
8214    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
8215    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
8216    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3"
8217   [(set_attr "type" "compare")
8218    (set_attr "length" "12,8,12,12,12")])
8219
8220 (define_insn ""
8221   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
8222         (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
8223                        (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,J,I"))))]
8224   ""
8225   "@
8226    xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
8227    {ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0
8228    {xoril|xori} %0,%1,%b2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
8229    {xoriu|xoris} %0,%1,%u2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
8230    {sfi|subfic} %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
8231    [(set_attr "length" "12,8,12,12,12")])
8232
8233 ;; Simplify (ne X (const_int 0)) on the PowerPC.  No need to on the Power,
8234 ;; since it nabs/sr is just as fast.
8235 (define_insn ""
8236   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8237         (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
8238                      (const_int 31)))
8239    (clobber (match_scratch:SI 2 "=&r"))]
8240   "!TARGET_POWER"
8241   "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
8242   [(set_attr "length" "8")])
8243
8244 ;; This is what (plus (ne X (const_int 0)) Y) looks like.
8245 (define_insn ""
8246   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8247         (plus:SI (lshiftrt:SI
8248                   (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
8249                   (const_int 31))
8250                  (match_operand:SI 2 "gpc_reg_operand" "r")))
8251    (clobber (match_scratch:SI 3 "=&r"))]
8252   ""
8253   "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
8254   [(set_attr "length" "8")])
8255
8256 (define_insn ""
8257   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8258         (compare:CC
8259          (plus:SI (lshiftrt:SI
8260                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
8261                    (const_int 31))
8262                   (match_operand:SI 2 "gpc_reg_operand" "r"))
8263          (const_int 0)))
8264    (clobber (match_scratch:SI 3 "=&r"))]
8265   ""
8266   "{ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2"
8267   [(set_attr "type" "compare")
8268    (set_attr "length" "8")])
8269
8270 (define_insn ""
8271   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
8272         (compare:CC
8273          (plus:SI (lshiftrt:SI
8274                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
8275                    (const_int 31))
8276                   (match_operand:SI 2 "gpc_reg_operand" "r"))
8277          (const_int 0)))
8278    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8279         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
8280                  (match_dup 2)))
8281    (clobber (match_scratch:SI 3 "=&r"))]
8282   ""
8283   "{ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2"
8284   [(set_attr "type" "compare")
8285    (set_attr "length" "8")])
8286
8287 (define_insn ""
8288   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8289         (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8290                (match_operand:SI 2 "reg_or_short_operand" "r,O")))
8291    (clobber (match_scratch:SI 3 "=r,X"))]
8292   "TARGET_POWER"
8293   "@
8294    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
8295    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
8296   [(set_attr "length" "12")])
8297
8298 (define_insn ""
8299   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x")
8300         (compare:CC
8301          (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8302                 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
8303          (const_int 0)))
8304    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8305         (le:SI (match_dup 1) (match_dup 2)))
8306    (clobber (match_scratch:SI 3 "=r,X"))]
8307   "TARGET_POWER"
8308   "@
8309    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
8310    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31"
8311   [(set_attr "type" "compare,delayed_compare")
8312    (set_attr "length" "12")])
8313
8314 (define_insn ""
8315   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8316         (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8317                         (match_operand:SI 2 "reg_or_short_operand" "r,O"))
8318                  (match_operand:SI 3 "gpc_reg_operand" "r,r")))
8319    (clobber (match_scratch:SI 4 "=&r,&r"))]
8320   "TARGET_POWER"
8321   "@
8322    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
8323    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze|addze} %0,%3"
8324   [(set_attr "length" "12")])
8325
8326 (define_insn ""
8327   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
8328         (compare:CC
8329          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8330                          (match_operand:SI 2 "reg_or_short_operand" "r,O"))
8331                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8332          (const_int 0)))
8333    (clobber (match_scratch:SI 4 "=&r,&r"))]
8334   "TARGET_POWER"
8335   "@
8336    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
8337    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3"
8338   [(set_attr "type" "compare")
8339    (set_attr "length" "12")])
8340
8341 (define_insn ""
8342   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
8343         (compare:CC
8344          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8345                          (match_operand:SI 2 "reg_or_short_operand" "r,O"))
8346                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8347          (const_int 0)))
8348    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8349         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8350    (clobber (match_scratch:SI 4 "=&r,&r"))]
8351   "TARGET_POWER"
8352   "@
8353    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
8354    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %0,%3"
8355   [(set_attr "type" "compare")
8356    (set_attr "length" "12")])
8357
8358 (define_insn ""
8359   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8360         (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8361                        (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
8362   "TARGET_POWER"
8363   "@
8364    doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
8365    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
8366   [(set_attr "length" "12")])
8367
8368 (define_insn ""
8369   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8370         (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8371                 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
8372   ""
8373   "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
8374   [(set_attr "length" "12")])
8375
8376 (define_insn ""
8377   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
8378         (compare:CC
8379          (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8380                  (match_operand:SI 2 "reg_or_short_operand" "rI"))
8381          (const_int 0)))
8382    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8383         (leu:SI (match_dup 1) (match_dup 2)))]
8384    ""
8385   "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0"
8386   [(set_attr "type" "compare")
8387    (set_attr "length" "12")])
8388
8389 (define_insn ""
8390   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8391         (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8392                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
8393                  (match_operand:SI 3 "gpc_reg_operand" "r")))
8394    (clobber (match_scratch:SI 4 "=&r"))]
8395   ""
8396   "{sf%I2|subf%I2c} %4,%1,%2\;{aze|addze} %0,%3"
8397   [(set_attr "length" "8")])
8398
8399 (define_insn ""
8400   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8401         (compare:CC
8402          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8403                           (match_operand:SI 2 "reg_or_short_operand" "rI"))
8404                   (match_operand:SI 3 "gpc_reg_operand" "r"))
8405          (const_int 0)))
8406    (clobber (match_scratch:SI 4 "=&r"))]
8407   ""
8408   "{sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3"
8409   [(set_attr "type" "compare")
8410    (set_attr "length" "8")])
8411
8412 (define_insn ""
8413   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
8414         (compare:CC
8415          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8416                           (match_operand:SI 2 "reg_or_short_operand" "rI"))
8417                   (match_operand:SI 3 "gpc_reg_operand" "r"))
8418          (const_int 0)))
8419    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8420         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8421    (clobber (match_scratch:SI 4 "=&r"))]
8422   ""
8423   "{sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %0,%3"
8424   [(set_attr "type" "compare")
8425    (set_attr "length" "8")])
8426
8427 (define_insn ""
8428   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8429         (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8430                         (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
8431   ""
8432   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
8433    [(set_attr "length" "12")])
8434
8435 (define_insn ""
8436   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8437         (and:SI (neg:SI
8438                  (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8439                          (match_operand:SI 2 "reg_or_short_operand" "rI")))
8440                 (match_operand:SI 3 "gpc_reg_operand" "r")))
8441    (clobber (match_scratch:SI 4 "=&r"))]
8442   ""
8443   "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4"
8444   [(set_attr "length" "12")])
8445
8446 (define_insn ""
8447   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8448         (compare:CC
8449          (and:SI (neg:SI
8450                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8451                           (match_operand:SI 2 "reg_or_short_operand" "rI")))
8452                  (match_operand:SI 3 "gpc_reg_operand" "r"))
8453          (const_int 0)))
8454    (clobber (match_scratch:SI 4 "=&r"))]
8455   ""
8456   "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4"
8457   [(set_attr "type" "compare")
8458    (set_attr "length" "12")])
8459
8460 (define_insn ""
8461   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
8462         (compare:CC
8463          (and:SI (neg:SI
8464                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8465                           (match_operand:SI 2 "reg_or_short_operand" "rI")))
8466                  (match_operand:SI 3 "gpc_reg_operand" "r"))
8467          (const_int 0)))
8468    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8469         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
8470    (clobber (match_scratch:SI 4 "=&r"))]
8471   ""
8472   "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4"
8473   [(set_attr "type" "compare")
8474    (set_attr "length" "12")])
8475
8476 (define_insn ""
8477   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8478         (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8479                (match_operand:SI 2 "reg_or_short_operand" "rI")))]
8480   "TARGET_POWER"
8481   "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
8482    [(set_attr "length" "12")])
8483
8484 (define_insn ""
8485   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
8486         (compare:CC
8487          (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8488                 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8489          (const_int 0)))
8490    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8491         (lt:SI (match_dup 1) (match_dup 2)))]
8492   "TARGET_POWER"
8493   "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31"
8494   [(set_attr "type" "delayed_compare")
8495    (set_attr "length" "12")])
8496
8497 (define_insn ""
8498   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8499         (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8500                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
8501                  (match_operand:SI 3 "gpc_reg_operand" "r")))
8502    (clobber (match_scratch:SI 4 "=&r"))]
8503   "TARGET_POWER"
8504   "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze|addze} %0,%3"
8505   [(set_attr "length" "12")])
8506
8507 (define_insn ""
8508   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8509         (compare:CC
8510          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8511                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
8512                   (match_operand:SI 3 "gpc_reg_operand" "r"))
8513          (const_int 0)))
8514    (clobber (match_scratch:SI 4 "=&r"))]
8515   "TARGET_POWER"
8516   "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3"
8517   [(set_attr "type" "compare")
8518    (set_attr "length" "12")])
8519
8520 (define_insn ""
8521   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
8522         (compare:CC
8523          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8524                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
8525                   (match_operand:SI 3 "gpc_reg_operand" "r"))
8526          (const_int 0)))
8527    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8528         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8529    (clobber (match_scratch:SI 4 "=&r"))]
8530   "TARGET_POWER"
8531   "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %0,%3"
8532   [(set_attr "type" "compare")
8533    (set_attr "length" "12")])
8534
8535 (define_insn ""
8536   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8537         (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8538                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
8539   "TARGET_POWER"
8540   "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
8541   [(set_attr "length" "12")])
8542
8543 (define_insn ""
8544   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8545         (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8546                 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
8547   ""
8548   "@
8549    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg %0,%0
8550    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
8551   [(set_attr "length" "12")])
8552
8553 (define_insn ""
8554   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
8555         (compare:CC
8556          (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8557                  (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8558          (const_int 0)))
8559    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8560         (ltu:SI (match_dup 1) (match_dup 2)))]
8561   ""
8562   "@
8563    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
8564    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0"
8565   [(set_attr "type" "compare")
8566    (set_attr "length" "12")])
8567
8568 (define_insn ""
8569   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
8570         (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
8571                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,r,P,P"))
8572                  (match_operand:SI 3 "reg_or_short_operand" "r,I,r,I")))
8573    (clobber (match_scratch:SI 4 "=&r,r,&r,r"))]
8574   ""
8575   "@
8576   {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
8577   {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
8578   {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
8579   {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3"
8580  [(set_attr "length" "12")])
8581
8582 (define_insn ""
8583   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
8584         (compare:CC
8585          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8586                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8587                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8588          (const_int 0)))
8589    (clobber (match_scratch:SI 4 "=&r,&r"))]
8590   ""
8591   "@
8592    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
8593    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3"
8594   [(set_attr "type" "compare")
8595    (set_attr "length" "12")])
8596
8597 (define_insn ""
8598   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
8599         (compare:CC
8600          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8601                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8602                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8603          (const_int 0)))
8604    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8605         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8606    (clobber (match_scratch:SI 4 "=&r,&r"))]
8607   ""
8608   "@
8609    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3
8610    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3"
8611   [(set_attr "type" "compare")
8612    (set_attr "length" "12")])
8613
8614 (define_insn ""
8615   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8616         (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8617                         (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
8618   ""
8619   "@
8620    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
8621    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
8622   [(set_attr "length" "8")])
8623
8624 (define_insn ""
8625   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8626         (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8627                (match_operand:SI 2 "reg_or_short_operand" "rI")))
8628    (clobber (match_scratch:SI 3 "=r"))]
8629   "TARGET_POWER"
8630   "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
8631    [(set_attr "length" "12")])
8632
8633 (define_insn ""
8634   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
8635         (compare:CC
8636          (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8637                 (match_operand:SI 2 "reg_or_short_operand" "rI"))
8638          (const_int 0)))
8639    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8640         (ge:SI (match_dup 1) (match_dup 2)))
8641    (clobber (match_scratch:SI 3 "=r"))]
8642   "TARGET_POWER"
8643   "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3"
8644   [(set_attr "type" "compare")
8645    (set_attr "length" "12")])
8646
8647 (define_insn ""
8648   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8649         (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8650                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
8651                  (match_operand:SI 3 "gpc_reg_operand" "r")))
8652    (clobber (match_scratch:SI 4 "=&r"))]
8653   "TARGET_POWER"
8654   "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3"
8655   [(set_attr "length" "12")])
8656
8657 (define_insn ""
8658   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8659         (compare:CC
8660          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8661                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
8662                   (match_operand:SI 3 "gpc_reg_operand" "r"))
8663          (const_int 0)))
8664    (clobber (match_scratch:SI 4 "=&r"))]
8665   "TARGET_POWER"
8666   "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3"
8667   [(set_attr "type" "compare")
8668    (set_attr "length" "12")])
8669
8670 (define_insn ""
8671   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
8672         (compare:CC
8673          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8674                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
8675                   (match_operand:SI 3 "gpc_reg_operand" "r"))
8676          (const_int 0)))
8677    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8678         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8679    (clobber (match_scratch:SI 4 "=&r"))]
8680   "TARGET_POWER"
8681   "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3"
8682   [(set_attr "type" "compare")
8683    (set_attr "length" "12")])
8684
8685 (define_insn ""
8686   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8687         (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8688                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
8689   "TARGET_POWER"
8690   "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
8691   [(set_attr "length" "12")])
8692
8693 ;; This is (and (neg (ge X (const_int 0))) Y).
8694 (define_insn ""
8695   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8696         (and:SI (neg:SI
8697                  (lshiftrt:SI
8698                   (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
8699                   (const_int 31)))
8700                 (match_operand:SI 2 "gpc_reg_operand" "r")))
8701    (clobber (match_scratch:SI 3 "=&r"))]
8702   ""
8703   "{srai|srawi} %3,%1,31\;andc %0,%2,%3"
8704   [(set_attr "length" "8")])
8705
8706 (define_insn ""
8707   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8708         (compare:CC
8709          (and:SI (neg:SI
8710                   (lshiftrt:SI
8711                    (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
8712                    (const_int 31)))
8713                  (match_operand:SI 2 "gpc_reg_operand" "r"))
8714          (const_int 0)))
8715    (clobber (match_scratch:SI 3 "=&r"))]
8716   ""
8717   "{srai|srawi} %3,%1,31\;andc. %3,%2,%3"
8718   [(set_attr "type" "compare")
8719    (set_attr "length" "8")])
8720
8721 (define_insn ""
8722   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
8723         (compare:CC
8724          (and:SI (neg:SI
8725                   (lshiftrt:SI
8726                    (not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
8727                    (const_int 31)))
8728                  (match_operand:SI 2 "gpc_reg_operand" "r"))
8729          (const_int 0)))
8730    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8731         (and:SI (neg:SI (lshiftrt:SI (not:SI (match_dup 1))
8732                                      (const_int 31)))
8733                 (match_dup 2)))
8734    (clobber (match_scratch:SI 3 "=&r"))]
8735   ""
8736   "{srai|srawi} %3,%1,31\;andc. %0,%2,%3"
8737   [(set_attr "type" "compare")
8738    (set_attr "length" "8")])
8739
8740 (define_insn ""
8741   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8742         (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8743                 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
8744   ""
8745   "@
8746    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
8747    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
8748   [(set_attr "length" "12")])
8749
8750 (define_insn ""
8751   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x")
8752         (compare:CC
8753          (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8754                  (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8755          (const_int 0)))
8756    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8757         (geu:SI (match_dup 1) (match_dup 2)))]
8758   ""
8759   "@
8760    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
8761    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0"
8762   [(set_attr "type" "compare")
8763    (set_attr "length" "12")])
8764
8765 (define_insn ""
8766   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8767         (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8768                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8769                  (match_operand:SI 3 "gpc_reg_operand" "r,r")))
8770    (clobber (match_scratch:SI 4 "=&r,&r"))]
8771   ""
8772   "@
8773    {sf|subfc} %4,%2,%1\;{aze|addze} %0,%3
8774    {ai|addic} %4,%1,%n2\;{aze|addze} %0,%3"
8775   [(set_attr "length" "8")])
8776
8777 (define_insn ""
8778   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
8779         (compare:CC
8780          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8781                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8782                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8783          (const_int 0)))
8784    (clobber (match_scratch:SI 4 "=&r,&r"))]
8785   ""
8786   "@
8787    {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
8788    {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3"
8789   [(set_attr "type" "compare")
8790    (set_attr "length" "8")])
8791
8792 (define_insn ""
8793   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
8794         (compare:CC
8795          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8796                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
8797                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8798          (const_int 0)))
8799    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8800         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8801    (clobber (match_scratch:SI 4 "=&r,&r"))]
8802   ""
8803   "@
8804    {sf|subfc} %4,%2,%1\;{aze.|addze.} %0,%3
8805    {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3"
8806   [(set_attr "type" "compare")
8807    (set_attr "length" "8")])
8808
8809 (define_insn ""
8810   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8811         (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8812                         (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
8813   ""
8814   "@
8815    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
8816    {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
8817   [(set_attr "length" "12")])
8818
8819 (define_insn ""
8820   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8821         (and:SI (neg:SI
8822                  (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8823                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
8824                 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
8825    (clobber (match_scratch:SI 4 "=&r,&r"))]
8826   ""
8827   "@
8828    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4
8829    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4"
8830   [(set_attr "length" "12")])
8831
8832 (define_insn ""
8833   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
8834         (compare:CC
8835          (and:SI (neg:SI
8836                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8837                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
8838                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8839          (const_int 0)))
8840    (clobber (match_scratch:SI 4 "=&r,&r"))]
8841   ""
8842   "@
8843    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
8844    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4"
8845   [(set_attr "type" "compare")
8846    (set_attr "length" "12")])
8847
8848 (define_insn ""
8849   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
8850         (compare:CC
8851          (and:SI (neg:SI
8852                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
8853                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
8854                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8855          (const_int 0)))
8856    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8857         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
8858    (clobber (match_scratch:SI 4 "=&r,&r"))]
8859   ""
8860   "@
8861    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4
8862    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4"
8863   [(set_attr "type" "compare")
8864    (set_attr "length" "12")])
8865
8866 (define_insn ""
8867   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8868         (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8869                (const_int 0)))]
8870   ""
8871   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri|srwi} %0,%0,31"
8872   [(set_attr "length" "12")])
8873
8874 (define_insn ""
8875   [(set (match_operand:CC 2 "cc_reg_operand" "=x")
8876         (compare:CC
8877          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8878                 (const_int 0))
8879          (const_int 0)))
8880    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8881         (gt:SI (match_dup 1) (const_int 0)))]
8882   ""
8883   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri.|srwi.} %0,%0,31"
8884   [(set_attr "type" "delayed_compare")
8885    (set_attr "length" "12")])
8886
8887 (define_insn ""
8888   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8889         (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8890                (match_operand:SI 2 "reg_or_short_operand" "r")))]
8891   "TARGET_POWER"
8892   "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
8893   [(set_attr "length" "12")])
8894
8895 (define_insn ""
8896   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
8897         (compare:CC
8898          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8899                 (match_operand:SI 2 "reg_or_short_operand" "r"))
8900          (const_int 0)))
8901    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8902         (gt:SI (match_dup 1) (match_dup 2)))]
8903   "TARGET_POWER"
8904   "doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31"
8905   [(set_attr "type" "delayed_compare")
8906    (set_attr "length" "12")])
8907
8908 (define_insn ""
8909   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8910         (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8911                         (const_int 0))
8912                  (match_operand:SI 2 "gpc_reg_operand" "r")))
8913    (clobber (match_scratch:SI 3 "=&r"))]
8914   ""
8915   "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze|addze} %0,%2"
8916   [(set_attr "length" "12")])
8917
8918 (define_insn ""
8919   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8920         (compare:CC
8921          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8922                          (const_int 0))
8923                   (match_operand:SI 2 "gpc_reg_operand" "r"))
8924          (const_int 0)))
8925    (clobber (match_scratch:SI 3 "=&r"))]
8926   ""
8927   "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %0,%2"
8928   [(set_attr "type" "compare")
8929    (set_attr "length" "12")])
8930
8931 (define_insn ""
8932   [(set (match_operand:CC 4 "cc_reg_operand" "=x")
8933         (compare:CC
8934          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8935                          (const_int 0))
8936                   (match_operand:SI 2 "gpc_reg_operand" "r"))
8937          (const_int 0)))
8938    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8939         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
8940    (clobber (match_scratch:SI 3 "=&r"))]
8941   ""
8942   "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2"
8943   [(set_attr "type" "compare")
8944    (set_attr "length" "12")])
8945
8946 (define_insn ""
8947   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8948         (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8949                         (match_operand:SI 2 "reg_or_short_operand" "r"))
8950                  (match_operand:SI 3 "gpc_reg_operand" "r")))
8951    (clobber (match_scratch:SI 4 "=&r"))]
8952   "TARGET_POWER"
8953   "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze|addze} %0,%3"
8954   [(set_attr "length" "12")])
8955
8956 (define_insn ""
8957   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
8958         (compare:CC
8959          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8960                          (match_operand:SI 2 "reg_or_short_operand" "r"))
8961                   (match_operand:SI 3 "gpc_reg_operand" "r"))
8962          (const_int 0)))
8963    (clobber (match_scratch:SI 4 "=&r"))]
8964   "TARGET_POWER"
8965   "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3"
8966   [(set_attr "type" "compare")
8967    (set_attr "length" "12")])
8968
8969 (define_insn ""
8970   [(set (match_operand:CC 5 "cc_reg_operand" "=x")
8971         (compare:CC
8972          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8973                          (match_operand:SI 2 "reg_or_short_operand" "r"))
8974                   (match_operand:SI 3 "gpc_reg_operand" "r"))
8975          (const_int 0)))
8976    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
8977         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
8978    (clobber (match_scratch:SI 4 "=&r"))]
8979   "TARGET_POWER"
8980   "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %0,%3"
8981   [(set_attr "type" "compare")
8982    (set_attr "length" "12")])
8983
8984 (define_insn ""
8985   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8986         (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8987                        (const_int 0))))]
8988   ""
8989   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{srai|srawi} %0,%0,31"
8990   [(set_attr "length" "12")])
8991
8992 (define_insn ""
8993   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8994         (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
8995                        (match_operand:SI 2 "reg_or_short_operand" "r"))))]
8996   "TARGET_POWER"
8997   "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
8998   [(set_attr "length" "12")])
8999
9000 (define_insn ""
9001   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9002         (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
9003                 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
9004   ""
9005   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
9006   [(set_attr "length" "12")])
9007
9008 (define_insn ""
9009   [(set (match_operand:CC 3 "cc_reg_operand" "=x")
9010         (compare:CC
9011          (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
9012                  (match_operand:SI 2 "reg_or_short_operand" "rI"))
9013          (const_int 0)))
9014    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
9015         (gtu:SI (match_dup 1) (match_dup 2)))]
9016   ""
9017   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0"
9018   [(set_attr "type" "compare")
9019    (set_attr "length" "12")])
9020
9021 (define_insn ""
9022   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
9023         (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
9024                          (match_operand:SI 2 "reg_or_short_operand" "I,r,rI"))
9025                  (match_operand:SI 3 "reg_or_short_operand" "r,r,I")))
9026    (clobber (match_scratch:SI 4 "=&r,&r,&r"))]
9027   ""
9028   "@
9029    {ai|addic} %4,%1,%k2\;{aze|addze} %0,%3
9030    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
9031    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3"
9032   [(set_attr "length" "8,12,12")])
9033
9034 (define_insn ""
9035   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x")
9036         (compare:CC
9037          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
9038                           (match_operand:SI 2 "reg_or_short_operand" "I,r"))
9039                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9040          (const_int 0)))
9041    (clobber (match_scratch:SI 4 "=&r,&r"))]
9042   ""
9043   "@
9044    {ai|addic} %4,%1,%k2\;{aze.|addze.} %0,%3
9045    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3"
9046   [(set_attr "type" "compare")
9047    (set_attr "length" "8,12")])
9048
9049 (define_insn ""
9050   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x")
9051         (compare:CC
9052          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
9053                           (match_operand:SI 2 "reg_or_short_operand" "I,r"))
9054                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9055          (const_int 0)))
9056    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
9057         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
9058    (clobber (match_scratch:SI 4 "=&r,&r"))]
9059   ""
9060   "@
9061    {ai|addic} %4,%1,%k2\;{aze.|addze.} %0,%3
9062    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3"
9063   [(set_attr "type" "compare")
9064    (set_attr "length" "8,12")])
9065
9066 (define_insn ""
9067   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9068         (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
9069                         (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
9070   ""
9071   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
9072   [(set_attr "length" "8")])
9073 \f
9074 ;; Define both directions of branch and return.  If we need a reload
9075 ;; register, we'd rather use CR0 since it is much easier to copy a
9076 ;; register CC value to there.
9077
9078 (define_insn ""
9079   [(set (pc)
9080         (if_then_else (match_operator 1 "branch_comparison_operator"
9081                                       [(match_operand 2
9082                                                       "cc_reg_operand" "x,?y")
9083                                        (const_int 0)])
9084                       (label_ref (match_operand 0 "" ""))
9085                       (pc)))]
9086   ""
9087   "*
9088 {
9089   if (get_attr_length (insn) == 8)
9090     return \"%C1bc %t1,%j1,%l0\";
9091   else
9092     return \"%C1bc %T1,%j1,%$+8\;b %l0\";
9093
9094 }"
9095   [(set_attr "type" "branch")])
9096
9097 (define_insn ""
9098   [(set (pc)
9099         (if_then_else (match_operator 0 "branch_comparison_operator"
9100                                       [(match_operand 1
9101                                                       "cc_reg_operand" "x,?y")
9102                                        (const_int 0)])
9103                       (return)
9104                       (pc)))]
9105   "direct_return ()"
9106   "{%C0bcr|%C0bclr} %t0,%j0"
9107   [(set_attr "type" "branch")
9108    (set_attr "length" "8")])
9109
9110 (define_insn ""
9111   [(set (pc)
9112         (if_then_else (match_operator 1 "branch_comparison_operator"
9113                                       [(match_operand 2
9114                                                       "cc_reg_operand" "x,?y")
9115                                        (const_int 0)])
9116                       (pc)
9117                       (label_ref (match_operand 0 "" ""))))]
9118   ""
9119   "*
9120 {
9121   if (get_attr_length (insn) == 8)
9122     return \"%C1bc %T1,%j1,%l0\";
9123   else
9124     return \"%C1bc %t1,%j1,%$+8\;b %l0\";
9125 }"
9126   [(set_attr "type" "branch")])
9127
9128 (define_insn ""
9129   [(set (pc)
9130         (if_then_else (match_operator 0 "branch_comparison_operator"
9131                                       [(match_operand 1
9132                                                       "cc_reg_operand" "x,?y")
9133                                        (const_int 0)])
9134                       (pc)
9135                       (return)))]
9136   "direct_return ()"
9137   "{%C0bcr|%C0bclr} %T0,%j0"
9138   [(set_attr "type" "branch")
9139    (set_attr "length" "8")])
9140
9141 ;; Unconditional branch and return.
9142
9143 (define_insn "jump"
9144   [(set (pc)
9145         (label_ref (match_operand 0 "" "")))]
9146   ""
9147   "b %l0"
9148   [(set_attr "type" "branch")])
9149
9150 (define_insn "return"
9151   [(return)]
9152   "direct_return ()"
9153   "{br|blr}"
9154   [(set_attr "type" "jmpreg")])
9155
9156 (define_insn "indirect_jump"
9157   [(set (pc) (match_operand:SI 0 "register_operand" "c,l"))]
9158   ""
9159   "@
9160    bctr
9161    {br|blr}"
9162   [(set_attr "type" "jmpreg")])
9163
9164 (define_insn ""
9165   [(set (pc) (match_operand:DI 0 "register_operand" "c,l"))]
9166   "TARGET_POWERPC64"
9167   "@
9168    bctr
9169    {br|blr}"
9170   [(set_attr "type" "jmpreg")])
9171
9172 ;; Table jump for switch statements:
9173 (define_expand "tablejump"
9174   [(use (match_operand 0 "" ""))
9175    (use (label_ref (match_operand 1 "" "")))]
9176   ""
9177   "
9178 {
9179   if (TARGET_32BIT)
9180     emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
9181   else
9182     emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
9183   DONE;
9184 }")
9185
9186 (define_expand "tablejumpsi"
9187   [(set (match_dup 3)
9188         (plus:SI (match_operand:SI 0 "" "")
9189                  (match_dup 2)))
9190    (parallel [(set (pc) (match_dup 3))
9191               (use (label_ref (match_operand 1 "" "")))])]
9192   ""
9193   "
9194 { operands[0] = force_reg (SImode, operands[0]);
9195   operands[2] = force_reg (SImode, gen_rtx (LABEL_REF, VOIDmode, operands[1]));
9196   operands[3] = gen_reg_rtx (SImode);
9197 }")
9198
9199 (define_expand "tablejumpdi"
9200   [(set (match_dup 3)
9201         (plus:DI (match_operand:DI 0 "" "")
9202                  (match_dup 2)))
9203    (parallel [(set (pc) (match_dup 3))
9204               (use (label_ref (match_operand 1 "" "")))])]
9205   ""
9206   "
9207 { operands[0] = force_reg (DImode, operands[0]);
9208   operands[2] = force_reg (DImode, gen_rtx (LABEL_REF, VOIDmode, operands[1]));
9209   operands[3] = gen_reg_rtx (DImode);
9210 }")
9211
9212 (define_insn ""
9213   [(set (pc)
9214         (match_operand:SI 0 "register_operand" "c,l"))
9215    (use (label_ref (match_operand 1 "" "")))]
9216   ""
9217   "@
9218    bctr
9219    {br|blr}"
9220   [(set_attr "type" "jmpreg")])
9221
9222 (define_insn ""
9223   [(set (pc)
9224         (match_operand:DI 0 "register_operand" "c,l"))
9225    (use (label_ref (match_operand 1 "" "")))]
9226   "TARGET_POWERPC64"
9227   "@
9228    bctr
9229    {br|blr}"
9230   [(set_attr "type" "jmpreg")])
9231
9232 (define_insn "nop"
9233   [(const_int 0)]
9234   ""
9235   "{cror 0,0,0|nop}")
9236 \f
9237 ;; Define the subtract-one-and-jump insns, starting with the template
9238 ;; so loop.c knows what to generate.
9239
9240 (define_expand "decrement_and_branch_on_count"
9241   [(parallel [(set (pc) (if_then_else (ne (match_operand:SI 0 "register_operand" "")
9242                                           (const_int 1))
9243                                       (label_ref (match_operand 1 "" ""))
9244                                       (pc)))
9245               (set (match_dup 0)
9246                    (plus:SI (match_dup 0)
9247                             (const_int -1)))
9248               (clobber (match_scratch:CC 2 ""))
9249               (clobber (match_scratch:SI 3 ""))])]
9250   ""
9251   "")
9252
9253 ;; We need to be able to do this for any operand, including MEM, or we
9254 ;; will cause reload to blow up since we don't allow output reloads on
9255 ;; JUMP_INSNs.
9256 ;; In order that the length attribute is calculated correctly, the
9257 ;; label MUST be operand 0.
9258
9259 (define_insn ""
9260   [(set (pc)
9261         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
9262                           (const_int 1))
9263                       (label_ref (match_operand 0 "" ""))
9264                       (pc)))
9265    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
9266         (plus:SI (match_dup 1)
9267                  (const_int -1)))
9268    (clobber (match_scratch:CC 3 "=X,&x,&x"))
9269    (clobber (match_scratch:SI 4 "=X,X,r"))]
9270   ""
9271   "*
9272 {
9273   if (which_alternative != 0)
9274     return \"#\";
9275   else if (get_attr_length (insn) == 8)
9276     return \"{bdn|bdnz} %l0\";
9277   else
9278     return \"bdz %$+8\;b %l0\";
9279 }"
9280   [(set_attr "type" "branch")
9281    (set_attr "length" "*,12,16")])
9282
9283 (define_insn ""
9284   [(set (pc)
9285         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
9286                           (const_int 1))
9287                       (pc)
9288                       (label_ref (match_operand 0 "" ""))))
9289    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
9290         (plus:SI (match_dup 1)
9291                  (const_int -1)))
9292    (clobber (match_scratch:CC 3 "=X,&x,&x"))
9293    (clobber (match_scratch:SI 4 "=X,X,r"))]
9294   ""
9295   "*
9296 {
9297   if (which_alternative != 0)
9298     return \"#\";
9299   else if (get_attr_length (insn) == 8)
9300     return \"bdz %l0\";
9301   else
9302     return \"{bdn|bdnz} %$+8\;b %l0\";
9303 }"
9304   [(set_attr "type" "branch")
9305    (set_attr "length" "*,12,16")])
9306
9307 ;; Similar, but we can use GE since we have a REG_NONNEG.
9308 (define_insn ""
9309   [(set (pc)
9310         (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
9311                           (const_int 0))
9312                       (label_ref (match_operand 0 "" ""))
9313                       (pc)))
9314    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
9315         (plus:SI (match_dup 1)
9316                  (const_int -1)))
9317    (clobber (match_scratch:CC 3 "=X,&x,&X"))
9318    (clobber (match_scratch:SI 4 "=X,X,r"))]
9319   "find_reg_note (insn, REG_NONNEG, 0)"
9320   "*
9321 {
9322   if (which_alternative != 0)
9323     return \"#\";
9324   else if (get_attr_length (insn) == 8)
9325     return \"{bdn|bdnz} %l0\";
9326   else
9327     return \"bdz %$+8\;b %l0\";
9328 }"
9329   [(set_attr "type" "branch")
9330    (set_attr "length" "*,12,16")])
9331
9332 (define_insn ""
9333   [(set (pc)
9334         (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
9335                           (const_int 0))
9336                       (pc)
9337                       (label_ref (match_operand 0 "" ""))))
9338    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
9339         (plus:SI (match_dup 1)
9340                  (const_int -1)))
9341    (clobber (match_scratch:CC 3 "=X,&x,&X"))
9342    (clobber (match_scratch:SI 4 "=X,X,r"))]
9343   "find_reg_note (insn, REG_NONNEG, 0)"
9344   "*
9345 {
9346   if (which_alternative != 0)
9347     return \"#\";
9348   else if (get_attr_length (insn) == 8)
9349     return \"bdz %l0\";
9350   else
9351     return \"{bdn|bdnz} %$+8\;b %l0\";
9352 }"
9353   [(set_attr "type" "branch")
9354    (set_attr "length" "*,12,16")])
9355
9356 (define_insn ""
9357   [(set (pc)
9358         (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
9359                           (const_int 1))
9360                       (label_ref (match_operand 0 "" ""))
9361                       (pc)))
9362    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
9363         (plus:SI (match_dup 1)
9364                  (const_int -1)))
9365    (clobber (match_scratch:CC 3 "=X,&x,&x"))
9366    (clobber (match_scratch:SI 4 "=X,X,r"))]
9367   ""
9368   "*
9369 {
9370   if (which_alternative != 0)
9371     return \"#\";
9372   else if (get_attr_length (insn) == 8)
9373     return \"bdz %l0\";
9374   else
9375     return \"{bdn|bdnz} %$+8\;b %l0\";
9376 }"
9377   [(set_attr "type" "branch")
9378    (set_attr "length" "*,12,16")])
9379
9380 (define_insn ""
9381   [(set (pc)
9382         (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
9383                           (const_int 1))
9384                       (pc)
9385                       (label_ref (match_operand 0 "" ""))))
9386    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
9387         (plus:SI (match_dup 1)
9388                  (const_int -1)))
9389    (clobber (match_scratch:CC 3 "=X,&x,&x"))
9390    (clobber (match_scratch:SI 4 "=X,X,r"))]
9391   ""
9392   "*
9393 {
9394   if (which_alternative != 0)
9395     return \"#\";
9396   else if (get_attr_length (insn) == 8)
9397     return \"{bdn|bdnz} %l0\";
9398   else
9399     return \"bdz %$+8\;b %l0\";
9400 }"
9401   [(set_attr "type" "branch")
9402    (set_attr "length" "*,12,16")])
9403
9404 (define_split
9405   [(set (pc)
9406         (if_then_else (match_operator 2 "comparison_operator"
9407                                       [(match_operand:SI 1 "gpc_reg_operand" "")
9408                                        (const_int 1)])
9409                       (match_operand 5 "" "")
9410                       (match_operand 6 "" "")))
9411    (set (match_operand:SI 0 "gpc_reg_operand" "")
9412         (plus:SI (match_dup 1)
9413                  (const_int -1)))
9414    (clobber (match_scratch:CC 3 ""))
9415    (clobber (match_scratch:SI 4 ""))]
9416   "reload_completed"
9417   [(parallel [(set (match_dup 3)
9418                    (compare:CC (plus:SI (match_dup 1)
9419                                         (const_int -1))
9420                                (const_int 0)))
9421               (set (match_dup 0)
9422                    (plus:SI (match_dup 1)
9423                             (const_int -1)))])
9424    (set (pc) (if_then_else (match_dup 7)
9425                            (match_dup 5)
9426                            (match_dup 6)))]
9427   "
9428 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
9429                          const0_rtx); }")
9430
9431 (define_split
9432   [(set (pc)
9433         (if_then_else (match_operator 2 "comparison_operator"
9434                                       [(match_operand:SI 1 "gpc_reg_operand" "")
9435                                        (const_int 1)])
9436                       (match_operand 5 "" "")
9437                       (match_operand 6 "" "")))
9438    (set (match_operand:SI 0 "general_operand" "")
9439         (plus:SI (match_dup 1) (const_int -1)))
9440    (clobber (match_scratch:CC 3 ""))
9441    (clobber (match_scratch:SI 4 ""))]
9442   "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
9443   [(parallel [(set (match_dup 3)
9444                    (compare:CC (plus:SI (match_dup 1)
9445                                         (const_int -1))
9446                                (const_int 0)))
9447               (set (match_dup 4)
9448                    (plus:SI (match_dup 1)
9449                             (const_int -1)))])
9450    (set (match_dup 0)
9451         (match_dup 4))
9452    (set (pc) (if_then_else (match_dup 7)
9453                            (match_dup 5)
9454                            (match_dup 6)))]
9455   "
9456 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
9457                          const0_rtx); }")