]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rs6000/rs6000.md
[multiple changes]
[thirdparty/gcc.git] / gcc / config / rs6000 / rs6000.md
1 ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
2 ;; Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
4 ;; Free Software Foundation, Inc.
5 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
6
7 ;; This file is part of GCC.
8
9 ;; GCC is free software; you can redistribute it and/or modify it
10 ;; under the terms of the GNU General Public License as published
11 ;; by the Free Software Foundation; either version 3, or (at your
12 ;; option) any later version.
13
14 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
15 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 ;; License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING3. If not see
21 ;; <http://www.gnu.org/licenses/>.
22
23 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
24
25 ;;
26 ;; REGNOS
27 ;;
28
29 (define_constants
30 [(MQ_REGNO 64)
31 (LR_REGNO 65)
32 (CTR_REGNO 66)
33 (CR0_REGNO 68)
34 (CR1_REGNO 69)
35 (CR2_REGNO 70)
36 (CR3_REGNO 71)
37 (CR4_REGNO 72)
38 (CR5_REGNO 73)
39 (CR6_REGNO 74)
40 (CR7_REGNO 75)
41 (MAX_CR_REGNO 75)
42 (XER_REGNO 76)
43 (FIRST_ALTIVEC_REGNO 77)
44 (LAST_ALTIVEC_REGNO 108)
45 (VRSAVE_REGNO 109)
46 (VSCR_REGNO 110)
47 (SPE_ACC_REGNO 111)
48 (SPEFSCR_REGNO 112)
49 (SFP_REGNO 113)
50 ])
51
52 ;;
53 ;; UNSPEC usage
54 ;;
55
56 (define_constants
57 [(UNSPEC_FRSP 0) ; frsp for POWER machines
58 (UNSPEC_TIE 5) ; tie stack contents and stack pointer
59 (UNSPEC_TOCPTR 6) ; address of a word pointing to the TOC
60 (UNSPEC_TOC 7) ; address of the TOC (more-or-less)
61 (UNSPEC_MOVSI_GOT 8)
62 (UNSPEC_MV_CR_OV 9) ; move_from_CR_ov_bit
63 (UNSPEC_FCTIWZ 10)
64 (UNSPEC_FRIM 11)
65 (UNSPEC_FRIN 12)
66 (UNSPEC_FRIP 13)
67 (UNSPEC_FRIZ 14)
68 (UNSPEC_LD_MPIC 15) ; load_macho_picbase
69 (UNSPEC_MPIC_CORRECT 16) ; macho_correct_pic
70 (UNSPEC_TLSGD 17)
71 (UNSPEC_TLSLD 18)
72 (UNSPEC_MOVESI_FROM_CR 19)
73 (UNSPEC_MOVESI_TO_CR 20)
74 (UNSPEC_TLSDTPREL 21)
75 (UNSPEC_TLSDTPRELHA 22)
76 (UNSPEC_TLSDTPRELLO 23)
77 (UNSPEC_TLSGOTDTPREL 24)
78 (UNSPEC_TLSTPREL 25)
79 (UNSPEC_TLSTPRELHA 26)
80 (UNSPEC_TLSTPRELLO 27)
81 (UNSPEC_TLSGOTTPREL 28)
82 (UNSPEC_TLSTLS 29)
83 (UNSPEC_FIX_TRUNC_TF 30) ; fadd, rounding towards zero
84 (UNSPEC_MV_CR_GT 31) ; move_from_CR_gt_bit
85 (UNSPEC_STFIWX 32)
86 (UNSPEC_POPCNTB 33)
87 (UNSPEC_FRES 34)
88 (UNSPEC_SP_SET 35)
89 (UNSPEC_SP_TEST 36)
90 (UNSPEC_SYNC 37)
91 (UNSPEC_LWSYNC 38)
92 (UNSPEC_ISYNC 39)
93 (UNSPEC_SYNC_OP 40)
94 (UNSPEC_ATOMIC 41)
95 (UNSPEC_CMPXCHG 42)
96 (UNSPEC_XCHG 43)
97 (UNSPEC_AND 44)
98 (UNSPEC_DLMZB 45)
99 (UNSPEC_DLMZB_CR 46)
100 (UNSPEC_DLMZB_STRLEN 47)
101 (UNSPEC_RSQRT 48)
102 ])
103
104 ;;
105 ;; UNSPEC_VOLATILE usage
106 ;;
107
108 (define_constants
109 [(UNSPECV_BLOCK 0)
110 (UNSPECV_LL 1) ; load-locked
111 (UNSPECV_SC 2) ; store-conditional
112 (UNSPECV_EH_RR 9) ; eh_reg_restore
113 ])
114 \f
115 ;; Define an insn type attribute. This is used in function unit delay
116 ;; computations.
117 (define_attr "type" "integer,two,three,load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,store,store_ux,store_u,fpload,fpload_ux,fpload_u,fpstore,fpstore_ux,fpstore_u,vecload,vecstore,imul,imul2,imul3,lmul,idiv,ldiv,insert_word,branch,cmp,fast_compare,compare,var_delayed_compare,delayed_compare,imul_compare,lmul_compare,fpcompare,cr_logical,delayed_cr,mfcr,mfcrf,mtcr,mfjmpr,mtjmpr,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg,brinc,vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,vecfloat,vecfdiv,isync,sync,load_l,store_c,shift,trap,insert_dword,var_shift_rotate,cntlz,exts,mffgpr,mftgpr"
118 (const_string "integer"))
119
120 ;; Length (in bytes).
121 ; '(pc)' in the following doesn't include the instruction itself; it is
122 ; calculated as if the instruction had zero size.
123 (define_attr "length" ""
124 (if_then_else (eq_attr "type" "branch")
125 (if_then_else (and (ge (minus (match_dup 0) (pc))
126 (const_int -32768))
127 (lt (minus (match_dup 0) (pc))
128 (const_int 32764)))
129 (const_int 4)
130 (const_int 8))
131 (const_int 4)))
132
133 ;; Processor type -- this attribute must exactly match the processor_type
134 ;; enumeration in rs6000.h.
135
136 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,ppce300c2,ppce300c3,ppce500mc,power4,power5,power6,cell"
137 (const (symbol_ref "rs6000_cpu_attr")))
138
139
140 ;; If this instruction is microcoded on the CELL processor
141 ; The default for load and stores is conditional
142 ; The default for load extended and the recorded instructions is always microcoded
143 (define_attr "cell_micro" "not,conditional,always"
144 (if_then_else (ior (ior (eq_attr "type" "load")
145 (eq_attr "type" "store"))
146 (ior (eq_attr "type" "fpload")
147 (eq_attr "type" "fpstore")))
148 (const_string "conditional")
149 (if_then_else (ior (eq_attr "type" "load_ext")
150 (ior (eq_attr "type" "compare")
151 (eq_attr "type" "delayed_compare")))
152 (const_string "always")
153 (const_string "not"))))
154
155
156 (automata_option "ndfa")
157
158 (include "rios1.md")
159 (include "rios2.md")
160 (include "rs64.md")
161 (include "mpc.md")
162 (include "40x.md")
163 (include "440.md")
164 (include "603.md")
165 (include "6xx.md")
166 (include "7xx.md")
167 (include "7450.md")
168 (include "8540.md")
169 (include "e300c2c3.md")
170 (include "e500mc.md")
171 (include "power4.md")
172 (include "power5.md")
173 (include "power6.md")
174 (include "cell.md")
175
176 (include "predicates.md")
177 (include "constraints.md")
178
179 (include "darwin.md")
180
181 \f
182 ;; Mode iterators
183
184 ; This mode iterator allows :GPR to be used to indicate the allowable size
185 ; of whole values in GPRs.
186 (define_mode_iterator GPR [SI (DI "TARGET_POWERPC64")])
187
188 ; Any supported integer mode.
189 (define_mode_iterator INT [QI HI SI DI TI])
190
191 ; Any supported integer mode that fits in one register.
192 (define_mode_iterator INT1 [QI HI SI (DI "TARGET_POWERPC64")])
193
194 ; extend modes for DImode
195 (define_mode_iterator QHSI [QI HI SI])
196
197 ; SImode or DImode, even if DImode doesn't fit in GPRs.
198 (define_mode_iterator SDI [SI DI])
199
200 ; The size of a pointer. Also, the size of the value that a record-condition
201 ; (one with a '.') will compare.
202 (define_mode_iterator P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
203
204 ; Any hardware-supported floating-point mode
205 (define_mode_iterator FP [(SF "TARGET_HARD_FLOAT")
206 (DF "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)")
207 (TF "!TARGET_IEEEQUAD
208 && TARGET_HARD_FLOAT
209 && (TARGET_FPRS || TARGET_E500_DOUBLE)
210 && TARGET_LONG_DOUBLE_128")
211 (DD "TARGET_DFP")
212 (TD "TARGET_DFP")])
213
214 ; Various instructions that come in SI and DI forms.
215 ; A generic w/d attribute, for things like cmpw/cmpd.
216 (define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
217
218 ; DImode bits
219 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
220
221 \f
222 ;; Start with fixed-point load and store insns. Here we put only the more
223 ;; complex forms. Basic data transfer is done later.
224
225 (define_expand "zero_extend<mode>di2"
226 [(set (match_operand:DI 0 "gpc_reg_operand" "")
227 (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "")))]
228 "TARGET_POWERPC64"
229 "")
230
231 (define_insn "*zero_extend<mode>di2_internal1"
232 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
233 (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
234 "TARGET_POWERPC64"
235 "@
236 l<wd>z%U1%X1 %0,%1
237 rldicl %0,%1,0,<dbits>"
238 [(set_attr "type" "load,*")])
239
240 (define_insn "*zero_extend<mode>di2_internal2"
241 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
242 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
243 (const_int 0)))
244 (clobber (match_scratch:DI 2 "=r,r"))]
245 "TARGET_64BIT"
246 "@
247 rldicl. %2,%1,0,<dbits>
248 #"
249 [(set_attr "type" "compare")
250 (set_attr "length" "4,8")])
251
252 (define_split
253 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
254 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
255 (const_int 0)))
256 (clobber (match_scratch:DI 2 ""))]
257 "TARGET_POWERPC64 && reload_completed"
258 [(set (match_dup 2)
259 (zero_extend:DI (match_dup 1)))
260 (set (match_dup 0)
261 (compare:CC (match_dup 2)
262 (const_int 0)))]
263 "")
264
265 (define_insn "*zero_extend<mode>di2_internal3"
266 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
267 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
268 (const_int 0)))
269 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
270 (zero_extend:DI (match_dup 1)))]
271 "TARGET_64BIT"
272 "@
273 rldicl. %0,%1,0,<dbits>
274 #"
275 [(set_attr "type" "compare")
276 (set_attr "length" "4,8")])
277
278 (define_split
279 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
280 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
281 (const_int 0)))
282 (set (match_operand:DI 0 "gpc_reg_operand" "")
283 (zero_extend:DI (match_dup 1)))]
284 "TARGET_POWERPC64 && reload_completed"
285 [(set (match_dup 0)
286 (zero_extend:DI (match_dup 1)))
287 (set (match_dup 2)
288 (compare:CC (match_dup 0)
289 (const_int 0)))]
290 "")
291
292 (define_insn "extendqidi2"
293 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
294 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
295 "TARGET_POWERPC64"
296 "extsb %0,%1"
297 [(set_attr "type" "exts")])
298
299 (define_insn ""
300 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
301 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
302 (const_int 0)))
303 (clobber (match_scratch:DI 2 "=r,r"))]
304 "TARGET_64BIT"
305 "@
306 extsb. %2,%1
307 #"
308 [(set_attr "type" "compare")
309 (set_attr "length" "4,8")])
310
311 (define_split
312 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
313 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
314 (const_int 0)))
315 (clobber (match_scratch:DI 2 ""))]
316 "TARGET_POWERPC64 && reload_completed"
317 [(set (match_dup 2)
318 (sign_extend:DI (match_dup 1)))
319 (set (match_dup 0)
320 (compare:CC (match_dup 2)
321 (const_int 0)))]
322 "")
323
324 (define_insn ""
325 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
326 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
327 (const_int 0)))
328 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
329 (sign_extend:DI (match_dup 1)))]
330 "TARGET_64BIT"
331 "@
332 extsb. %0,%1
333 #"
334 [(set_attr "type" "compare")
335 (set_attr "length" "4,8")])
336
337 (define_split
338 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
339 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
340 (const_int 0)))
341 (set (match_operand:DI 0 "gpc_reg_operand" "")
342 (sign_extend:DI (match_dup 1)))]
343 "TARGET_POWERPC64 && reload_completed"
344 [(set (match_dup 0)
345 (sign_extend:DI (match_dup 1)))
346 (set (match_dup 2)
347 (compare:CC (match_dup 0)
348 (const_int 0)))]
349 "")
350
351 (define_expand "extendhidi2"
352 [(set (match_operand:DI 0 "gpc_reg_operand" "")
353 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
354 "TARGET_POWERPC64"
355 "")
356
357 (define_insn ""
358 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
359 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
360 "TARGET_POWERPC64"
361 "@
362 lha%U1%X1 %0,%1
363 extsh %0,%1"
364 [(set_attr "type" "load_ext,exts")])
365
366 (define_insn ""
367 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
368 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
369 (const_int 0)))
370 (clobber (match_scratch:DI 2 "=r,r"))]
371 "TARGET_64BIT"
372 "@
373 extsh. %2,%1
374 #"
375 [(set_attr "type" "compare")
376 (set_attr "length" "4,8")])
377
378 (define_split
379 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
380 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
381 (const_int 0)))
382 (clobber (match_scratch:DI 2 ""))]
383 "TARGET_POWERPC64 && reload_completed"
384 [(set (match_dup 2)
385 (sign_extend:DI (match_dup 1)))
386 (set (match_dup 0)
387 (compare:CC (match_dup 2)
388 (const_int 0)))]
389 "")
390
391 (define_insn ""
392 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
393 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
394 (const_int 0)))
395 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
396 (sign_extend:DI (match_dup 1)))]
397 "TARGET_64BIT"
398 "@
399 extsh. %0,%1
400 #"
401 [(set_attr "type" "compare")
402 (set_attr "length" "4,8")])
403
404 (define_split
405 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
406 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
407 (const_int 0)))
408 (set (match_operand:DI 0 "gpc_reg_operand" "")
409 (sign_extend:DI (match_dup 1)))]
410 "TARGET_POWERPC64 && reload_completed"
411 [(set (match_dup 0)
412 (sign_extend:DI (match_dup 1)))
413 (set (match_dup 2)
414 (compare:CC (match_dup 0)
415 (const_int 0)))]
416 "")
417
418 (define_expand "extendsidi2"
419 [(set (match_operand:DI 0 "gpc_reg_operand" "")
420 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
421 "TARGET_POWERPC64"
422 "")
423
424 (define_insn ""
425 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
426 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
427 "TARGET_POWERPC64"
428 "@
429 lwa%U1%X1 %0,%1
430 extsw %0,%1"
431 [(set_attr "type" "load_ext,exts")])
432
433 (define_insn ""
434 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
435 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
436 (const_int 0)))
437 (clobber (match_scratch:DI 2 "=r,r"))]
438 "TARGET_64BIT"
439 "@
440 extsw. %2,%1
441 #"
442 [(set_attr "type" "compare")
443 (set_attr "length" "4,8")])
444
445 (define_split
446 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
447 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
448 (const_int 0)))
449 (clobber (match_scratch:DI 2 ""))]
450 "TARGET_POWERPC64 && reload_completed"
451 [(set (match_dup 2)
452 (sign_extend:DI (match_dup 1)))
453 (set (match_dup 0)
454 (compare:CC (match_dup 2)
455 (const_int 0)))]
456 "")
457
458 (define_insn ""
459 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
460 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
461 (const_int 0)))
462 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
463 (sign_extend:DI (match_dup 1)))]
464 "TARGET_64BIT"
465 "@
466 extsw. %0,%1
467 #"
468 [(set_attr "type" "compare")
469 (set_attr "length" "4,8")])
470
471 (define_split
472 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
473 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
474 (const_int 0)))
475 (set (match_operand:DI 0 "gpc_reg_operand" "")
476 (sign_extend:DI (match_dup 1)))]
477 "TARGET_POWERPC64 && reload_completed"
478 [(set (match_dup 0)
479 (sign_extend:DI (match_dup 1)))
480 (set (match_dup 2)
481 (compare:CC (match_dup 0)
482 (const_int 0)))]
483 "")
484
485 (define_expand "zero_extendqisi2"
486 [(set (match_operand:SI 0 "gpc_reg_operand" "")
487 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
488 ""
489 "")
490
491 (define_insn ""
492 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
493 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
494 ""
495 "@
496 lbz%U1%X1 %0,%1
497 {rlinm|rlwinm} %0,%1,0,0xff"
498 [(set_attr "type" "load,*")])
499
500 (define_insn ""
501 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
502 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
503 (const_int 0)))
504 (clobber (match_scratch:SI 2 "=r,r"))]
505 ""
506 "@
507 {andil.|andi.} %2,%1,0xff
508 #"
509 [(set_attr "type" "compare")
510 (set_attr "length" "4,8")])
511
512 (define_split
513 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
514 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
515 (const_int 0)))
516 (clobber (match_scratch:SI 2 ""))]
517 "reload_completed"
518 [(set (match_dup 2)
519 (zero_extend:SI (match_dup 1)))
520 (set (match_dup 0)
521 (compare:CC (match_dup 2)
522 (const_int 0)))]
523 "")
524
525 (define_insn ""
526 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
527 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
528 (const_int 0)))
529 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
530 (zero_extend:SI (match_dup 1)))]
531 ""
532 "@
533 {andil.|andi.} %0,%1,0xff
534 #"
535 [(set_attr "type" "compare")
536 (set_attr "length" "4,8")])
537
538 (define_split
539 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
540 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
541 (const_int 0)))
542 (set (match_operand:SI 0 "gpc_reg_operand" "")
543 (zero_extend:SI (match_dup 1)))]
544 "reload_completed"
545 [(set (match_dup 0)
546 (zero_extend:SI (match_dup 1)))
547 (set (match_dup 2)
548 (compare:CC (match_dup 0)
549 (const_int 0)))]
550 "")
551
552 (define_expand "extendqisi2"
553 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
554 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
555 ""
556 "
557 {
558 if (TARGET_POWERPC)
559 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
560 else if (TARGET_POWER)
561 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
562 else
563 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
564 DONE;
565 }")
566
567 (define_insn "extendqisi2_ppc"
568 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
569 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
570 "TARGET_POWERPC"
571 "extsb %0,%1"
572 [(set_attr "type" "exts")])
573
574 (define_insn ""
575 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
576 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
577 (const_int 0)))
578 (clobber (match_scratch:SI 2 "=r,r"))]
579 "TARGET_POWERPC"
580 "@
581 extsb. %2,%1
582 #"
583 [(set_attr "type" "compare")
584 (set_attr "length" "4,8")])
585
586 (define_split
587 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
588 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
589 (const_int 0)))
590 (clobber (match_scratch:SI 2 ""))]
591 "TARGET_POWERPC && reload_completed"
592 [(set (match_dup 2)
593 (sign_extend:SI (match_dup 1)))
594 (set (match_dup 0)
595 (compare:CC (match_dup 2)
596 (const_int 0)))]
597 "")
598
599 (define_insn ""
600 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
601 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
602 (const_int 0)))
603 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
604 (sign_extend:SI (match_dup 1)))]
605 "TARGET_POWERPC"
606 "@
607 extsb. %0,%1
608 #"
609 [(set_attr "type" "compare")
610 (set_attr "length" "4,8")])
611
612 (define_split
613 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
614 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
615 (const_int 0)))
616 (set (match_operand:SI 0 "gpc_reg_operand" "")
617 (sign_extend:SI (match_dup 1)))]
618 "TARGET_POWERPC && reload_completed"
619 [(set (match_dup 0)
620 (sign_extend:SI (match_dup 1)))
621 (set (match_dup 2)
622 (compare:CC (match_dup 0)
623 (const_int 0)))]
624 "")
625
626 (define_expand "extendqisi2_power"
627 [(parallel [(set (match_dup 2)
628 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
629 (const_int 24)))
630 (clobber (scratch:SI))])
631 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
632 (ashiftrt:SI (match_dup 2)
633 (const_int 24)))
634 (clobber (scratch:SI))])]
635 "TARGET_POWER"
636 "
637 { operands[1] = gen_lowpart (SImode, operands[1]);
638 operands[2] = gen_reg_rtx (SImode); }")
639
640 (define_expand "extendqisi2_no_power"
641 [(set (match_dup 2)
642 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
643 (const_int 24)))
644 (set (match_operand:SI 0 "gpc_reg_operand" "")
645 (ashiftrt:SI (match_dup 2)
646 (const_int 24)))]
647 "! TARGET_POWER && ! TARGET_POWERPC"
648 "
649 { operands[1] = gen_lowpart (SImode, operands[1]);
650 operands[2] = gen_reg_rtx (SImode); }")
651
652 (define_expand "zero_extendqihi2"
653 [(set (match_operand:HI 0 "gpc_reg_operand" "")
654 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
655 ""
656 "")
657
658 (define_insn ""
659 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
660 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
661 ""
662 "@
663 lbz%U1%X1 %0,%1
664 {rlinm|rlwinm} %0,%1,0,0xff"
665 [(set_attr "type" "load,*")])
666
667 (define_insn ""
668 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
669 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
670 (const_int 0)))
671 (clobber (match_scratch:HI 2 "=r,r"))]
672 ""
673 "@
674 {andil.|andi.} %2,%1,0xff
675 #"
676 [(set_attr "type" "compare")
677 (set_attr "length" "4,8")])
678
679 (define_split
680 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
681 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
682 (const_int 0)))
683 (clobber (match_scratch:HI 2 ""))]
684 "reload_completed"
685 [(set (match_dup 2)
686 (zero_extend:HI (match_dup 1)))
687 (set (match_dup 0)
688 (compare:CC (match_dup 2)
689 (const_int 0)))]
690 "")
691
692 (define_insn ""
693 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
694 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
695 (const_int 0)))
696 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
697 (zero_extend:HI (match_dup 1)))]
698 ""
699 "@
700 {andil.|andi.} %0,%1,0xff
701 #"
702 [(set_attr "type" "compare")
703 (set_attr "length" "4,8")])
704
705 (define_split
706 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
707 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
708 (const_int 0)))
709 (set (match_operand:HI 0 "gpc_reg_operand" "")
710 (zero_extend:HI (match_dup 1)))]
711 "reload_completed"
712 [(set (match_dup 0)
713 (zero_extend:HI (match_dup 1)))
714 (set (match_dup 2)
715 (compare:CC (match_dup 0)
716 (const_int 0)))]
717 "")
718
719 (define_expand "extendqihi2"
720 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
721 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
722 ""
723 "
724 {
725 if (TARGET_POWERPC)
726 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
727 else if (TARGET_POWER)
728 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
729 else
730 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
731 DONE;
732 }")
733
734 (define_insn "extendqihi2_ppc"
735 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
736 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
737 "TARGET_POWERPC"
738 "extsb %0,%1"
739 [(set_attr "type" "exts")])
740
741 (define_insn ""
742 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
743 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
744 (const_int 0)))
745 (clobber (match_scratch:HI 2 "=r,r"))]
746 "TARGET_POWERPC"
747 "@
748 extsb. %2,%1
749 #"
750 [(set_attr "type" "compare")
751 (set_attr "length" "4,8")])
752
753 (define_split
754 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
755 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
756 (const_int 0)))
757 (clobber (match_scratch:HI 2 ""))]
758 "TARGET_POWERPC && reload_completed"
759 [(set (match_dup 2)
760 (sign_extend:HI (match_dup 1)))
761 (set (match_dup 0)
762 (compare:CC (match_dup 2)
763 (const_int 0)))]
764 "")
765
766 (define_insn ""
767 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
768 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
769 (const_int 0)))
770 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
771 (sign_extend:HI (match_dup 1)))]
772 "TARGET_POWERPC"
773 "@
774 extsb. %0,%1
775 #"
776 [(set_attr "type" "compare")
777 (set_attr "length" "4,8")])
778
779 (define_split
780 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
781 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
782 (const_int 0)))
783 (set (match_operand:HI 0 "gpc_reg_operand" "")
784 (sign_extend:HI (match_dup 1)))]
785 "TARGET_POWERPC && reload_completed"
786 [(set (match_dup 0)
787 (sign_extend:HI (match_dup 1)))
788 (set (match_dup 2)
789 (compare:CC (match_dup 0)
790 (const_int 0)))]
791 "")
792
793 (define_expand "extendqihi2_power"
794 [(parallel [(set (match_dup 2)
795 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
796 (const_int 24)))
797 (clobber (scratch:SI))])
798 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
799 (ashiftrt:SI (match_dup 2)
800 (const_int 24)))
801 (clobber (scratch:SI))])]
802 "TARGET_POWER"
803 "
804 { operands[0] = gen_lowpart (SImode, operands[0]);
805 operands[1] = gen_lowpart (SImode, operands[1]);
806 operands[2] = gen_reg_rtx (SImode); }")
807
808 (define_expand "extendqihi2_no_power"
809 [(set (match_dup 2)
810 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
811 (const_int 24)))
812 (set (match_operand:HI 0 "gpc_reg_operand" "")
813 (ashiftrt:SI (match_dup 2)
814 (const_int 24)))]
815 "! TARGET_POWER && ! TARGET_POWERPC"
816 "
817 { operands[0] = gen_lowpart (SImode, operands[0]);
818 operands[1] = gen_lowpart (SImode, operands[1]);
819 operands[2] = gen_reg_rtx (SImode); }")
820
821 (define_expand "zero_extendhisi2"
822 [(set (match_operand:SI 0 "gpc_reg_operand" "")
823 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
824 ""
825 "")
826
827 (define_insn ""
828 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
829 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
830 ""
831 "@
832 lhz%U1%X1 %0,%1
833 {rlinm|rlwinm} %0,%1,0,0xffff"
834 [(set_attr "type" "load,*")])
835
836 (define_insn ""
837 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
838 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
839 (const_int 0)))
840 (clobber (match_scratch:SI 2 "=r,r"))]
841 ""
842 "@
843 {andil.|andi.} %2,%1,0xffff
844 #"
845 [(set_attr "type" "compare")
846 (set_attr "length" "4,8")])
847
848 (define_split
849 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
850 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
851 (const_int 0)))
852 (clobber (match_scratch:SI 2 ""))]
853 "reload_completed"
854 [(set (match_dup 2)
855 (zero_extend:SI (match_dup 1)))
856 (set (match_dup 0)
857 (compare:CC (match_dup 2)
858 (const_int 0)))]
859 "")
860
861 (define_insn ""
862 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
863 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
864 (const_int 0)))
865 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
866 (zero_extend:SI (match_dup 1)))]
867 ""
868 "@
869 {andil.|andi.} %0,%1,0xffff
870 #"
871 [(set_attr "type" "compare")
872 (set_attr "length" "4,8")])
873
874 (define_split
875 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
876 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
877 (const_int 0)))
878 (set (match_operand:SI 0 "gpc_reg_operand" "")
879 (zero_extend:SI (match_dup 1)))]
880 "reload_completed"
881 [(set (match_dup 0)
882 (zero_extend:SI (match_dup 1)))
883 (set (match_dup 2)
884 (compare:CC (match_dup 0)
885 (const_int 0)))]
886 "")
887
888 (define_expand "extendhisi2"
889 [(set (match_operand:SI 0 "gpc_reg_operand" "")
890 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
891 ""
892 "")
893
894 (define_insn ""
895 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
896 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
897 ""
898 "@
899 lha%U1%X1 %0,%1
900 {exts|extsh} %0,%1"
901 [(set_attr "type" "load_ext,exts")])
902
903 (define_insn ""
904 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
905 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
906 (const_int 0)))
907 (clobber (match_scratch:SI 2 "=r,r"))]
908 ""
909 "@
910 {exts.|extsh.} %2,%1
911 #"
912 [(set_attr "type" "compare")
913 (set_attr "length" "4,8")])
914
915 (define_split
916 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
917 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
918 (const_int 0)))
919 (clobber (match_scratch:SI 2 ""))]
920 "reload_completed"
921 [(set (match_dup 2)
922 (sign_extend:SI (match_dup 1)))
923 (set (match_dup 0)
924 (compare:CC (match_dup 2)
925 (const_int 0)))]
926 "")
927
928 (define_insn ""
929 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
930 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
931 (const_int 0)))
932 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
933 (sign_extend:SI (match_dup 1)))]
934 ""
935 "@
936 {exts.|extsh.} %0,%1
937 #"
938 [(set_attr "type" "compare")
939 (set_attr "length" "4,8")])
940 \f
941 ;; IBM 405, 440 and 464 half-word multiplication operations.
942
943 (define_insn "*macchwc"
944 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
945 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
946 (match_operand:SI 2 "gpc_reg_operand" "r")
947 (const_int 16))
948 (sign_extend:SI
949 (match_operand:HI 1 "gpc_reg_operand" "r")))
950 (match_operand:SI 4 "gpc_reg_operand" "0"))
951 (const_int 0)))
952 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
953 (plus:SI (mult:SI (ashiftrt:SI
954 (match_dup 2)
955 (const_int 16))
956 (sign_extend:SI
957 (match_dup 1)))
958 (match_dup 4)))]
959 "TARGET_MULHW"
960 "macchw. %0, %1, %2"
961 [(set_attr "type" "imul3")])
962
963 (define_insn "*macchw"
964 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
965 (plus:SI (mult:SI (ashiftrt:SI
966 (match_operand:SI 2 "gpc_reg_operand" "r")
967 (const_int 16))
968 (sign_extend:SI
969 (match_operand:HI 1 "gpc_reg_operand" "r")))
970 (match_operand:SI 3 "gpc_reg_operand" "0")))]
971 "TARGET_MULHW"
972 "macchw %0, %1, %2"
973 [(set_attr "type" "imul3")])
974
975 (define_insn "*macchwuc"
976 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
977 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
978 (match_operand:SI 2 "gpc_reg_operand" "r")
979 (const_int 16))
980 (zero_extend:SI
981 (match_operand:HI 1 "gpc_reg_operand" "r")))
982 (match_operand:SI 4 "gpc_reg_operand" "0"))
983 (const_int 0)))
984 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
985 (plus:SI (mult:SI (lshiftrt:SI
986 (match_dup 2)
987 (const_int 16))
988 (zero_extend:SI
989 (match_dup 1)))
990 (match_dup 4)))]
991 "TARGET_MULHW"
992 "macchwu. %0, %1, %2"
993 [(set_attr "type" "imul3")])
994
995 (define_insn "*macchwu"
996 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
997 (plus:SI (mult:SI (lshiftrt:SI
998 (match_operand:SI 2 "gpc_reg_operand" "r")
999 (const_int 16))
1000 (zero_extend:SI
1001 (match_operand:HI 1 "gpc_reg_operand" "r")))
1002 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1003 "TARGET_MULHW"
1004 "macchwu %0, %1, %2"
1005 [(set_attr "type" "imul3")])
1006
1007 (define_insn "*machhwc"
1008 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1009 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
1010 (match_operand:SI 1 "gpc_reg_operand" "%r")
1011 (const_int 16))
1012 (ashiftrt:SI
1013 (match_operand:SI 2 "gpc_reg_operand" "r")
1014 (const_int 16)))
1015 (match_operand:SI 4 "gpc_reg_operand" "0"))
1016 (const_int 0)))
1017 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1018 (plus:SI (mult:SI (ashiftrt:SI
1019 (match_dup 1)
1020 (const_int 16))
1021 (ashiftrt:SI
1022 (match_dup 2)
1023 (const_int 16)))
1024 (match_dup 4)))]
1025 "TARGET_MULHW"
1026 "machhw. %0, %1, %2"
1027 [(set_attr "type" "imul3")])
1028
1029 (define_insn "*machhw"
1030 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1031 (plus:SI (mult:SI (ashiftrt:SI
1032 (match_operand:SI 1 "gpc_reg_operand" "%r")
1033 (const_int 16))
1034 (ashiftrt:SI
1035 (match_operand:SI 2 "gpc_reg_operand" "r")
1036 (const_int 16)))
1037 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1038 "TARGET_MULHW"
1039 "machhw %0, %1, %2"
1040 [(set_attr "type" "imul3")])
1041
1042 (define_insn "*machhwuc"
1043 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1044 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
1045 (match_operand:SI 1 "gpc_reg_operand" "%r")
1046 (const_int 16))
1047 (lshiftrt:SI
1048 (match_operand:SI 2 "gpc_reg_operand" "r")
1049 (const_int 16)))
1050 (match_operand:SI 4 "gpc_reg_operand" "0"))
1051 (const_int 0)))
1052 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1053 (plus:SI (mult:SI (lshiftrt:SI
1054 (match_dup 1)
1055 (const_int 16))
1056 (lshiftrt:SI
1057 (match_dup 2)
1058 (const_int 16)))
1059 (match_dup 4)))]
1060 "TARGET_MULHW"
1061 "machhwu. %0, %1, %2"
1062 [(set_attr "type" "imul3")])
1063
1064 (define_insn "*machhwu"
1065 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1066 (plus:SI (mult:SI (lshiftrt:SI
1067 (match_operand:SI 1 "gpc_reg_operand" "%r")
1068 (const_int 16))
1069 (lshiftrt:SI
1070 (match_operand:SI 2 "gpc_reg_operand" "r")
1071 (const_int 16)))
1072 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1073 "TARGET_MULHW"
1074 "machhwu %0, %1, %2"
1075 [(set_attr "type" "imul3")])
1076
1077 (define_insn "*maclhwc"
1078 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1079 (compare:CC (plus:SI (mult:SI (sign_extend:SI
1080 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1081 (sign_extend:SI
1082 (match_operand:HI 2 "gpc_reg_operand" "r")))
1083 (match_operand:SI 4 "gpc_reg_operand" "0"))
1084 (const_int 0)))
1085 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1086 (plus:SI (mult:SI (sign_extend:SI
1087 (match_dup 1))
1088 (sign_extend:SI
1089 (match_dup 2)))
1090 (match_dup 4)))]
1091 "TARGET_MULHW"
1092 "maclhw. %0, %1, %2"
1093 [(set_attr "type" "imul3")])
1094
1095 (define_insn "*maclhw"
1096 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1097 (plus:SI (mult:SI (sign_extend:SI
1098 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1099 (sign_extend:SI
1100 (match_operand:HI 2 "gpc_reg_operand" "r")))
1101 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1102 "TARGET_MULHW"
1103 "maclhw %0, %1, %2"
1104 [(set_attr "type" "imul3")])
1105
1106 (define_insn "*maclhwuc"
1107 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1108 (compare:CC (plus:SI (mult:SI (zero_extend:SI
1109 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1110 (zero_extend:SI
1111 (match_operand:HI 2 "gpc_reg_operand" "r")))
1112 (match_operand:SI 4 "gpc_reg_operand" "0"))
1113 (const_int 0)))
1114 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1115 (plus:SI (mult:SI (zero_extend:SI
1116 (match_dup 1))
1117 (zero_extend:SI
1118 (match_dup 2)))
1119 (match_dup 4)))]
1120 "TARGET_MULHW"
1121 "maclhwu. %0, %1, %2"
1122 [(set_attr "type" "imul3")])
1123
1124 (define_insn "*maclhwu"
1125 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1126 (plus:SI (mult:SI (zero_extend:SI
1127 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1128 (zero_extend:SI
1129 (match_operand:HI 2 "gpc_reg_operand" "r")))
1130 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1131 "TARGET_MULHW"
1132 "maclhwu %0, %1, %2"
1133 [(set_attr "type" "imul3")])
1134
1135 (define_insn "*nmacchwc"
1136 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1137 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1138 (mult:SI (ashiftrt:SI
1139 (match_operand:SI 2 "gpc_reg_operand" "r")
1140 (const_int 16))
1141 (sign_extend:SI
1142 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1143 (const_int 0)))
1144 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1145 (minus:SI (match_dup 4)
1146 (mult:SI (ashiftrt:SI
1147 (match_dup 2)
1148 (const_int 16))
1149 (sign_extend:SI
1150 (match_dup 1)))))]
1151 "TARGET_MULHW"
1152 "nmacchw. %0, %1, %2"
1153 [(set_attr "type" "imul3")])
1154
1155 (define_insn "*nmacchw"
1156 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1157 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1158 (mult:SI (ashiftrt:SI
1159 (match_operand:SI 2 "gpc_reg_operand" "r")
1160 (const_int 16))
1161 (sign_extend:SI
1162 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1163 "TARGET_MULHW"
1164 "nmacchw %0, %1, %2"
1165 [(set_attr "type" "imul3")])
1166
1167 (define_insn "*nmachhwc"
1168 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1169 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1170 (mult:SI (ashiftrt:SI
1171 (match_operand:SI 1 "gpc_reg_operand" "%r")
1172 (const_int 16))
1173 (ashiftrt:SI
1174 (match_operand:SI 2 "gpc_reg_operand" "r")
1175 (const_int 16))))
1176 (const_int 0)))
1177 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1178 (minus:SI (match_dup 4)
1179 (mult:SI (ashiftrt:SI
1180 (match_dup 1)
1181 (const_int 16))
1182 (ashiftrt:SI
1183 (match_dup 2)
1184 (const_int 16)))))]
1185 "TARGET_MULHW"
1186 "nmachhw. %0, %1, %2"
1187 [(set_attr "type" "imul3")])
1188
1189 (define_insn "*nmachhw"
1190 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1191 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1192 (mult:SI (ashiftrt:SI
1193 (match_operand:SI 1 "gpc_reg_operand" "%r")
1194 (const_int 16))
1195 (ashiftrt:SI
1196 (match_operand:SI 2 "gpc_reg_operand" "r")
1197 (const_int 16)))))]
1198 "TARGET_MULHW"
1199 "nmachhw %0, %1, %2"
1200 [(set_attr "type" "imul3")])
1201
1202 (define_insn "*nmaclhwc"
1203 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1204 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1205 (mult:SI (sign_extend:SI
1206 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1207 (sign_extend:SI
1208 (match_operand:HI 2 "gpc_reg_operand" "r"))))
1209 (const_int 0)))
1210 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1211 (minus:SI (match_dup 4)
1212 (mult:SI (sign_extend:SI
1213 (match_dup 1))
1214 (sign_extend:SI
1215 (match_dup 2)))))]
1216 "TARGET_MULHW"
1217 "nmaclhw. %0, %1, %2"
1218 [(set_attr "type" "imul3")])
1219
1220 (define_insn "*nmaclhw"
1221 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1222 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1223 (mult:SI (sign_extend:SI
1224 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1225 (sign_extend:SI
1226 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1227 "TARGET_MULHW"
1228 "nmaclhw %0, %1, %2"
1229 [(set_attr "type" "imul3")])
1230
1231 (define_insn "*mulchwc"
1232 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1233 (compare:CC (mult:SI (ashiftrt:SI
1234 (match_operand:SI 2 "gpc_reg_operand" "r")
1235 (const_int 16))
1236 (sign_extend:SI
1237 (match_operand:HI 1 "gpc_reg_operand" "r")))
1238 (const_int 0)))
1239 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1240 (mult:SI (ashiftrt:SI
1241 (match_dup 2)
1242 (const_int 16))
1243 (sign_extend:SI
1244 (match_dup 1))))]
1245 "TARGET_MULHW"
1246 "mulchw. %0, %1, %2"
1247 [(set_attr "type" "imul3")])
1248
1249 (define_insn "*mulchw"
1250 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1251 (mult:SI (ashiftrt:SI
1252 (match_operand:SI 2 "gpc_reg_operand" "r")
1253 (const_int 16))
1254 (sign_extend:SI
1255 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1256 "TARGET_MULHW"
1257 "mulchw %0, %1, %2"
1258 [(set_attr "type" "imul3")])
1259
1260 (define_insn "*mulchwuc"
1261 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1262 (compare:CC (mult:SI (lshiftrt:SI
1263 (match_operand:SI 2 "gpc_reg_operand" "r")
1264 (const_int 16))
1265 (zero_extend:SI
1266 (match_operand:HI 1 "gpc_reg_operand" "r")))
1267 (const_int 0)))
1268 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1269 (mult:SI (lshiftrt:SI
1270 (match_dup 2)
1271 (const_int 16))
1272 (zero_extend:SI
1273 (match_dup 1))))]
1274 "TARGET_MULHW"
1275 "mulchwu. %0, %1, %2"
1276 [(set_attr "type" "imul3")])
1277
1278 (define_insn "*mulchwu"
1279 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1280 (mult:SI (lshiftrt:SI
1281 (match_operand:SI 2 "gpc_reg_operand" "r")
1282 (const_int 16))
1283 (zero_extend:SI
1284 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1285 "TARGET_MULHW"
1286 "mulchwu %0, %1, %2"
1287 [(set_attr "type" "imul3")])
1288
1289 (define_insn "*mulhhwc"
1290 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1291 (compare:CC (mult:SI (ashiftrt:SI
1292 (match_operand:SI 1 "gpc_reg_operand" "%r")
1293 (const_int 16))
1294 (ashiftrt:SI
1295 (match_operand:SI 2 "gpc_reg_operand" "r")
1296 (const_int 16)))
1297 (const_int 0)))
1298 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1299 (mult:SI (ashiftrt:SI
1300 (match_dup 1)
1301 (const_int 16))
1302 (ashiftrt:SI
1303 (match_dup 2)
1304 (const_int 16))))]
1305 "TARGET_MULHW"
1306 "mulhhw. %0, %1, %2"
1307 [(set_attr "type" "imul3")])
1308
1309 (define_insn "*mulhhw"
1310 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1311 (mult:SI (ashiftrt:SI
1312 (match_operand:SI 1 "gpc_reg_operand" "%r")
1313 (const_int 16))
1314 (ashiftrt:SI
1315 (match_operand:SI 2 "gpc_reg_operand" "r")
1316 (const_int 16))))]
1317 "TARGET_MULHW"
1318 "mulhhw %0, %1, %2"
1319 [(set_attr "type" "imul3")])
1320
1321 (define_insn "*mulhhwuc"
1322 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1323 (compare:CC (mult:SI (lshiftrt:SI
1324 (match_operand:SI 1 "gpc_reg_operand" "%r")
1325 (const_int 16))
1326 (lshiftrt:SI
1327 (match_operand:SI 2 "gpc_reg_operand" "r")
1328 (const_int 16)))
1329 (const_int 0)))
1330 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1331 (mult:SI (lshiftrt:SI
1332 (match_dup 1)
1333 (const_int 16))
1334 (lshiftrt:SI
1335 (match_dup 2)
1336 (const_int 16))))]
1337 "TARGET_MULHW"
1338 "mulhhwu. %0, %1, %2"
1339 [(set_attr "type" "imul3")])
1340
1341 (define_insn "*mulhhwu"
1342 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1343 (mult:SI (lshiftrt:SI
1344 (match_operand:SI 1 "gpc_reg_operand" "%r")
1345 (const_int 16))
1346 (lshiftrt:SI
1347 (match_operand:SI 2 "gpc_reg_operand" "r")
1348 (const_int 16))))]
1349 "TARGET_MULHW"
1350 "mulhhwu %0, %1, %2"
1351 [(set_attr "type" "imul3")])
1352
1353 (define_insn "*mullhwc"
1354 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1355 (compare:CC (mult:SI (sign_extend:SI
1356 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1357 (sign_extend:SI
1358 (match_operand:HI 2 "gpc_reg_operand" "r")))
1359 (const_int 0)))
1360 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1361 (mult:SI (sign_extend:SI
1362 (match_dup 1))
1363 (sign_extend:SI
1364 (match_dup 2))))]
1365 "TARGET_MULHW"
1366 "mullhw. %0, %1, %2"
1367 [(set_attr "type" "imul3")])
1368
1369 (define_insn "*mullhw"
1370 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1371 (mult:SI (sign_extend:SI
1372 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1373 (sign_extend:SI
1374 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1375 "TARGET_MULHW"
1376 "mullhw %0, %1, %2"
1377 [(set_attr "type" "imul3")])
1378
1379 (define_insn "*mullhwuc"
1380 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1381 (compare:CC (mult:SI (zero_extend:SI
1382 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1383 (zero_extend:SI
1384 (match_operand:HI 2 "gpc_reg_operand" "r")))
1385 (const_int 0)))
1386 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1387 (mult:SI (zero_extend:SI
1388 (match_dup 1))
1389 (zero_extend:SI
1390 (match_dup 2))))]
1391 "TARGET_MULHW"
1392 "mullhwu. %0, %1, %2"
1393 [(set_attr "type" "imul3")])
1394
1395 (define_insn "*mullhwu"
1396 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1397 (mult:SI (zero_extend:SI
1398 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1399 (zero_extend:SI
1400 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1401 "TARGET_MULHW"
1402 "mullhwu %0, %1, %2"
1403 [(set_attr "type" "imul3")])
1404 \f
1405 ;; IBM 405, 440 and 464 string-search dlmzb instruction support.
1406 (define_insn "dlmzb"
1407 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1408 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1409 (match_operand:SI 2 "gpc_reg_operand" "r")]
1410 UNSPEC_DLMZB_CR))
1411 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1412 (unspec:SI [(match_dup 1)
1413 (match_dup 2)]
1414 UNSPEC_DLMZB))]
1415 "TARGET_DLMZB"
1416 "dlmzb. %0, %1, %2")
1417
1418 (define_expand "strlensi"
1419 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1420 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1421 (match_operand:QI 2 "const_int_operand" "")
1422 (match_operand 3 "const_int_operand" "")]
1423 UNSPEC_DLMZB_STRLEN))
1424 (clobber (match_scratch:CC 4 "=x"))]
1425 "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1426 {
1427 rtx result = operands[0];
1428 rtx src = operands[1];
1429 rtx search_char = operands[2];
1430 rtx align = operands[3];
1431 rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1432 rtx loop_label, end_label, mem, cr0, cond;
1433 if (search_char != const0_rtx
1434 || GET_CODE (align) != CONST_INT
1435 || INTVAL (align) < 8)
1436 FAIL;
1437 word1 = gen_reg_rtx (SImode);
1438 word2 = gen_reg_rtx (SImode);
1439 scratch_dlmzb = gen_reg_rtx (SImode);
1440 scratch_string = gen_reg_rtx (Pmode);
1441 loop_label = gen_label_rtx ();
1442 end_label = gen_label_rtx ();
1443 addr = force_reg (Pmode, XEXP (src, 0));
1444 emit_move_insn (scratch_string, addr);
1445 emit_label (loop_label);
1446 mem = change_address (src, SImode, scratch_string);
1447 emit_move_insn (word1, mem);
1448 emit_move_insn (word2, adjust_address (mem, SImode, 4));
1449 cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1450 emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1451 cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1452 emit_jump_insn (gen_rtx_SET (VOIDmode,
1453 pc_rtx,
1454 gen_rtx_IF_THEN_ELSE (VOIDmode,
1455 cond,
1456 gen_rtx_LABEL_REF
1457 (VOIDmode,
1458 end_label),
1459 pc_rtx)));
1460 emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1461 emit_jump_insn (gen_rtx_SET (VOIDmode,
1462 pc_rtx,
1463 gen_rtx_LABEL_REF (VOIDmode, loop_label)));
1464 emit_barrier ();
1465 emit_label (end_label);
1466 emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1467 emit_insn (gen_subsi3 (result, scratch_string, addr));
1468 emit_insn (gen_subsi3 (result, result, const1_rtx));
1469 DONE;
1470 })
1471 \f
1472 (define_split
1473 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1474 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1475 (const_int 0)))
1476 (set (match_operand:SI 0 "gpc_reg_operand" "")
1477 (sign_extend:SI (match_dup 1)))]
1478 "reload_completed"
1479 [(set (match_dup 0)
1480 (sign_extend:SI (match_dup 1)))
1481 (set (match_dup 2)
1482 (compare:CC (match_dup 0)
1483 (const_int 0)))]
1484 "")
1485
1486 ;; Fixed-point arithmetic insns.
1487
1488 (define_expand "add<mode>3"
1489 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1490 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1491 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1492 ""
1493 {
1494 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1495 {
1496 if (non_short_cint_operand (operands[2], DImode))
1497 FAIL;
1498 }
1499 else if (GET_CODE (operands[2]) == CONST_INT
1500 && ! add_operand (operands[2], <MODE>mode))
1501 {
1502 rtx tmp = ((!can_create_pseudo_p ()
1503 || rtx_equal_p (operands[0], operands[1]))
1504 ? operands[0] : gen_reg_rtx (<MODE>mode));
1505
1506 HOST_WIDE_INT val = INTVAL (operands[2]);
1507 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1508 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1509
1510 if (<MODE>mode == DImode && !satisfies_constraint_L (GEN_INT (rest)))
1511 FAIL;
1512
1513 /* The ordering here is important for the prolog expander.
1514 When space is allocated from the stack, adding 'low' first may
1515 produce a temporary deallocation (which would be bad). */
1516 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1517 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1518 DONE;
1519 }
1520 })
1521
1522 ;; Discourage ai/addic because of carry but provide it in an alternative
1523 ;; allowing register zero as source.
1524 (define_insn "*add<mode>3_internal1"
1525 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1526 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1527 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
1528 "!DECIMAL_FLOAT_MODE_P (GET_MODE (operands[0])) && !DECIMAL_FLOAT_MODE_P (GET_MODE (operands[1]))"
1529 "@
1530 {cax|add} %0,%1,%2
1531 {cal %0,%2(%1)|addi %0,%1,%2}
1532 {ai|addic} %0,%1,%2
1533 {cau|addis} %0,%1,%v2"
1534 [(set_attr "length" "4,4,4,4")])
1535
1536 (define_insn "addsi3_high"
1537 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1538 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1539 (high:SI (match_operand 2 "" ""))))]
1540 "TARGET_MACHO && !TARGET_64BIT"
1541 "{cau|addis} %0,%1,ha16(%2)"
1542 [(set_attr "length" "4")])
1543
1544 (define_insn "*add<mode>3_internal2"
1545 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1546 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1547 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1548 (const_int 0)))
1549 (clobber (match_scratch:P 3 "=r,r,r,r"))]
1550 ""
1551 "@
1552 {cax.|add.} %3,%1,%2
1553 {ai.|addic.} %3,%1,%2
1554 #
1555 #"
1556 [(set_attr "type" "fast_compare,compare,compare,compare")
1557 (set_attr "length" "4,4,8,8")])
1558
1559 (define_split
1560 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1561 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1562 (match_operand:GPR 2 "reg_or_short_operand" ""))
1563 (const_int 0)))
1564 (clobber (match_scratch:GPR 3 ""))]
1565 "reload_completed"
1566 [(set (match_dup 3)
1567 (plus:GPR (match_dup 1)
1568 (match_dup 2)))
1569 (set (match_dup 0)
1570 (compare:CC (match_dup 3)
1571 (const_int 0)))]
1572 "")
1573
1574 (define_insn "*add<mode>3_internal3"
1575 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1576 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1577 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1578 (const_int 0)))
1579 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1580 (plus:P (match_dup 1)
1581 (match_dup 2)))]
1582 ""
1583 "@
1584 {cax.|add.} %0,%1,%2
1585 {ai.|addic.} %0,%1,%2
1586 #
1587 #"
1588 [(set_attr "type" "fast_compare,compare,compare,compare")
1589 (set_attr "length" "4,4,8,8")])
1590
1591 (define_split
1592 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1593 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1594 (match_operand:P 2 "reg_or_short_operand" ""))
1595 (const_int 0)))
1596 (set (match_operand:P 0 "gpc_reg_operand" "")
1597 (plus:P (match_dup 1) (match_dup 2)))]
1598 "reload_completed"
1599 [(set (match_dup 0)
1600 (plus:P (match_dup 1)
1601 (match_dup 2)))
1602 (set (match_dup 3)
1603 (compare:CC (match_dup 0)
1604 (const_int 0)))]
1605 "")
1606
1607 ;; Split an add that we can't do in one insn into two insns, each of which
1608 ;; does one 16-bit part. This is used by combine. Note that the low-order
1609 ;; add should be last in case the result gets used in an address.
1610
1611 (define_split
1612 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1613 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1614 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1615 ""
1616 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1617 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1618 {
1619 HOST_WIDE_INT val = INTVAL (operands[2]);
1620 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1621 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1622
1623 operands[4] = GEN_INT (low);
1624 if (<MODE>mode == SImode || satisfies_constraint_L (GEN_INT (rest)))
1625 operands[3] = GEN_INT (rest);
1626 else if (can_create_pseudo_p ())
1627 {
1628 operands[3] = gen_reg_rtx (DImode);
1629 emit_move_insn (operands[3], operands[2]);
1630 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1631 DONE;
1632 }
1633 else
1634 FAIL;
1635 })
1636
1637 (define_insn "one_cmpl<mode>2"
1638 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1639 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1640 ""
1641 "nor %0,%1,%1")
1642
1643 (define_insn ""
1644 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1645 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1646 (const_int 0)))
1647 (clobber (match_scratch:P 2 "=r,r"))]
1648 ""
1649 "@
1650 nor. %2,%1,%1
1651 #"
1652 [(set_attr "type" "compare")
1653 (set_attr "length" "4,8")])
1654
1655 (define_split
1656 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1657 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1658 (const_int 0)))
1659 (clobber (match_scratch:P 2 ""))]
1660 "reload_completed"
1661 [(set (match_dup 2)
1662 (not:P (match_dup 1)))
1663 (set (match_dup 0)
1664 (compare:CC (match_dup 2)
1665 (const_int 0)))]
1666 "")
1667
1668 (define_insn ""
1669 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1670 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1671 (const_int 0)))
1672 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1673 (not:P (match_dup 1)))]
1674 ""
1675 "@
1676 nor. %0,%1,%1
1677 #"
1678 [(set_attr "type" "compare")
1679 (set_attr "length" "4,8")])
1680
1681 (define_split
1682 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1683 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1684 (const_int 0)))
1685 (set (match_operand:P 0 "gpc_reg_operand" "")
1686 (not:P (match_dup 1)))]
1687 "reload_completed"
1688 [(set (match_dup 0)
1689 (not:P (match_dup 1)))
1690 (set (match_dup 2)
1691 (compare:CC (match_dup 0)
1692 (const_int 0)))]
1693 "")
1694
1695 (define_insn ""
1696 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1697 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1698 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1699 "! TARGET_POWERPC"
1700 "{sf%I1|subf%I1c} %0,%2,%1")
1701
1702 (define_insn ""
1703 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1704 (minus:GPR (match_operand:GPR 1 "reg_or_short_operand" "r,I")
1705 (match_operand:GPR 2 "gpc_reg_operand" "r,r")))]
1706 "TARGET_POWERPC"
1707 "@
1708 subf %0,%2,%1
1709 subfic %0,%2,%1")
1710
1711 (define_insn ""
1712 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1713 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1714 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1715 (const_int 0)))
1716 (clobber (match_scratch:SI 3 "=r,r"))]
1717 "! TARGET_POWERPC"
1718 "@
1719 {sf.|subfc.} %3,%2,%1
1720 #"
1721 [(set_attr "type" "compare")
1722 (set_attr "length" "4,8")])
1723
1724 (define_insn ""
1725 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1726 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1727 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1728 (const_int 0)))
1729 (clobber (match_scratch:P 3 "=r,r"))]
1730 "TARGET_POWERPC"
1731 "@
1732 subf. %3,%2,%1
1733 #"
1734 [(set_attr "type" "fast_compare")
1735 (set_attr "length" "4,8")])
1736
1737 (define_split
1738 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1739 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1740 (match_operand:P 2 "gpc_reg_operand" ""))
1741 (const_int 0)))
1742 (clobber (match_scratch:P 3 ""))]
1743 "reload_completed"
1744 [(set (match_dup 3)
1745 (minus:P (match_dup 1)
1746 (match_dup 2)))
1747 (set (match_dup 0)
1748 (compare:CC (match_dup 3)
1749 (const_int 0)))]
1750 "")
1751
1752 (define_insn ""
1753 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1754 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1755 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1756 (const_int 0)))
1757 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1758 (minus:SI (match_dup 1) (match_dup 2)))]
1759 "! TARGET_POWERPC"
1760 "@
1761 {sf.|subfc.} %0,%2,%1
1762 #"
1763 [(set_attr "type" "compare")
1764 (set_attr "length" "4,8")])
1765
1766 (define_insn ""
1767 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1768 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1769 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1770 (const_int 0)))
1771 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1772 (minus:P (match_dup 1)
1773 (match_dup 2)))]
1774 "TARGET_POWERPC"
1775 "@
1776 subf. %0,%2,%1
1777 #"
1778 [(set_attr "type" "fast_compare")
1779 (set_attr "length" "4,8")])
1780
1781 (define_split
1782 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1783 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1784 (match_operand:P 2 "gpc_reg_operand" ""))
1785 (const_int 0)))
1786 (set (match_operand:P 0 "gpc_reg_operand" "")
1787 (minus:P (match_dup 1)
1788 (match_dup 2)))]
1789 "reload_completed"
1790 [(set (match_dup 0)
1791 (minus:P (match_dup 1)
1792 (match_dup 2)))
1793 (set (match_dup 3)
1794 (compare:CC (match_dup 0)
1795 (const_int 0)))]
1796 "")
1797
1798 (define_expand "sub<mode>3"
1799 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1800 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1801 (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
1802 ""
1803 "
1804 {
1805 if (GET_CODE (operands[2]) == CONST_INT)
1806 {
1807 emit_insn (gen_add<mode>3 (operands[0], operands[1],
1808 negate_rtx (<MODE>mode, operands[2])));
1809 DONE;
1810 }
1811 }")
1812
1813 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1814 ;; instruction and some auxiliary computations. Then we just have a single
1815 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1816 ;; combine.
1817
1818 (define_expand "sminsi3"
1819 [(set (match_dup 3)
1820 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1821 (match_operand:SI 2 "reg_or_short_operand" ""))
1822 (const_int 0)
1823 (minus:SI (match_dup 2) (match_dup 1))))
1824 (set (match_operand:SI 0 "gpc_reg_operand" "")
1825 (minus:SI (match_dup 2) (match_dup 3)))]
1826 "TARGET_POWER || TARGET_ISEL"
1827 "
1828 {
1829 if (TARGET_ISEL)
1830 {
1831 operands[2] = force_reg (SImode, operands[2]);
1832 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1833 DONE;
1834 }
1835
1836 operands[3] = gen_reg_rtx (SImode);
1837 }")
1838
1839 (define_split
1840 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1841 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1842 (match_operand:SI 2 "reg_or_short_operand" "")))
1843 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1844 "TARGET_POWER"
1845 [(set (match_dup 3)
1846 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1847 (const_int 0)
1848 (minus:SI (match_dup 2) (match_dup 1))))
1849 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1850 "")
1851
1852 (define_expand "smaxsi3"
1853 [(set (match_dup 3)
1854 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1855 (match_operand:SI 2 "reg_or_short_operand" ""))
1856 (const_int 0)
1857 (minus:SI (match_dup 2) (match_dup 1))))
1858 (set (match_operand:SI 0 "gpc_reg_operand" "")
1859 (plus:SI (match_dup 3) (match_dup 1)))]
1860 "TARGET_POWER || TARGET_ISEL"
1861 "
1862 {
1863 if (TARGET_ISEL)
1864 {
1865 operands[2] = force_reg (SImode, operands[2]);
1866 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1867 DONE;
1868 }
1869 operands[3] = gen_reg_rtx (SImode);
1870 }")
1871
1872 (define_split
1873 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1874 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1875 (match_operand:SI 2 "reg_or_short_operand" "")))
1876 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1877 "TARGET_POWER"
1878 [(set (match_dup 3)
1879 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1880 (const_int 0)
1881 (minus:SI (match_dup 2) (match_dup 1))))
1882 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1883 "")
1884
1885 (define_expand "uminsi3"
1886 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1887 (match_dup 5)))
1888 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1889 (match_dup 5)))
1890 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1891 (const_int 0)
1892 (minus:SI (match_dup 4) (match_dup 3))))
1893 (set (match_operand:SI 0 "gpc_reg_operand" "")
1894 (minus:SI (match_dup 2) (match_dup 3)))]
1895 "TARGET_POWER || TARGET_ISEL"
1896 "
1897 {
1898 if (TARGET_ISEL)
1899 {
1900 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1901 DONE;
1902 }
1903 operands[3] = gen_reg_rtx (SImode);
1904 operands[4] = gen_reg_rtx (SImode);
1905 operands[5] = GEN_INT (-2147483647 - 1);
1906 }")
1907
1908 (define_expand "umaxsi3"
1909 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1910 (match_dup 5)))
1911 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1912 (match_dup 5)))
1913 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1914 (const_int 0)
1915 (minus:SI (match_dup 4) (match_dup 3))))
1916 (set (match_operand:SI 0 "gpc_reg_operand" "")
1917 (plus:SI (match_dup 3) (match_dup 1)))]
1918 "TARGET_POWER || TARGET_ISEL"
1919 "
1920 {
1921 if (TARGET_ISEL)
1922 {
1923 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1924 DONE;
1925 }
1926 operands[3] = gen_reg_rtx (SImode);
1927 operands[4] = gen_reg_rtx (SImode);
1928 operands[5] = GEN_INT (-2147483647 - 1);
1929 }")
1930
1931 (define_insn ""
1932 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1933 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1934 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1935 (const_int 0)
1936 (minus:SI (match_dup 2) (match_dup 1))))]
1937 "TARGET_POWER"
1938 "doz%I2 %0,%1,%2")
1939
1940 (define_insn ""
1941 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1942 (compare:CC
1943 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1944 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1945 (const_int 0)
1946 (minus:SI (match_dup 2) (match_dup 1)))
1947 (const_int 0)))
1948 (clobber (match_scratch:SI 3 "=r,r"))]
1949 "TARGET_POWER"
1950 "@
1951 doz%I2. %3,%1,%2
1952 #"
1953 [(set_attr "type" "delayed_compare")
1954 (set_attr "length" "4,8")])
1955
1956 (define_split
1957 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1958 (compare:CC
1959 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1960 (match_operand:SI 2 "reg_or_short_operand" ""))
1961 (const_int 0)
1962 (minus:SI (match_dup 2) (match_dup 1)))
1963 (const_int 0)))
1964 (clobber (match_scratch:SI 3 ""))]
1965 "TARGET_POWER && reload_completed"
1966 [(set (match_dup 3)
1967 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1968 (const_int 0)
1969 (minus:SI (match_dup 2) (match_dup 1))))
1970 (set (match_dup 0)
1971 (compare:CC (match_dup 3)
1972 (const_int 0)))]
1973 "")
1974
1975 (define_insn ""
1976 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1977 (compare:CC
1978 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1979 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1980 (const_int 0)
1981 (minus:SI (match_dup 2) (match_dup 1)))
1982 (const_int 0)))
1983 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1984 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1985 (const_int 0)
1986 (minus:SI (match_dup 2) (match_dup 1))))]
1987 "TARGET_POWER"
1988 "@
1989 doz%I2. %0,%1,%2
1990 #"
1991 [(set_attr "type" "delayed_compare")
1992 (set_attr "length" "4,8")])
1993
1994 (define_split
1995 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1996 (compare:CC
1997 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1998 (match_operand:SI 2 "reg_or_short_operand" ""))
1999 (const_int 0)
2000 (minus:SI (match_dup 2) (match_dup 1)))
2001 (const_int 0)))
2002 (set (match_operand:SI 0 "gpc_reg_operand" "")
2003 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2004 (const_int 0)
2005 (minus:SI (match_dup 2) (match_dup 1))))]
2006 "TARGET_POWER && reload_completed"
2007 [(set (match_dup 0)
2008 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2009 (const_int 0)
2010 (minus:SI (match_dup 2) (match_dup 1))))
2011 (set (match_dup 3)
2012 (compare:CC (match_dup 0)
2013 (const_int 0)))]
2014 "")
2015
2016 ;; We don't need abs with condition code because such comparisons should
2017 ;; never be done.
2018 (define_expand "abssi2"
2019 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2020 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2021 ""
2022 "
2023 {
2024 if (TARGET_ISEL)
2025 {
2026 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
2027 DONE;
2028 }
2029 else if (! TARGET_POWER)
2030 {
2031 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
2032 DONE;
2033 }
2034 }")
2035
2036 (define_insn "*abssi2_power"
2037 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2038 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2039 "TARGET_POWER"
2040 "abs %0,%1")
2041
2042 (define_insn_and_split "abssi2_isel"
2043 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2044 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
2045 (clobber (match_scratch:SI 2 "=&b"))
2046 (clobber (match_scratch:CC 3 "=y"))]
2047 "TARGET_ISEL"
2048 "#"
2049 "&& reload_completed"
2050 [(set (match_dup 2) (neg:SI (match_dup 1)))
2051 (set (match_dup 3)
2052 (compare:CC (match_dup 1)
2053 (const_int 0)))
2054 (set (match_dup 0)
2055 (if_then_else:SI (ge (match_dup 3)
2056 (const_int 0))
2057 (match_dup 1)
2058 (match_dup 2)))]
2059 "")
2060
2061 (define_insn_and_split "abssi2_nopower"
2062 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2063 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
2064 (clobber (match_scratch:SI 2 "=&r,&r"))]
2065 "! TARGET_POWER && ! TARGET_ISEL"
2066 "#"
2067 "&& reload_completed"
2068 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2069 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2070 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
2071 "")
2072
2073 (define_insn "*nabs_power"
2074 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2075 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
2076 "TARGET_POWER"
2077 "nabs %0,%1")
2078
2079 (define_insn_and_split "*nabs_nopower"
2080 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2081 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
2082 (clobber (match_scratch:SI 2 "=&r,&r"))]
2083 "! TARGET_POWER"
2084 "#"
2085 "&& reload_completed"
2086 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2087 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2088 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
2089 "")
2090
2091 (define_expand "neg<mode>2"
2092 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2093 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
2094 ""
2095 "")
2096
2097 (define_insn "*neg<mode>2_internal"
2098 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2099 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2100 ""
2101 "neg %0,%1")
2102
2103 (define_insn ""
2104 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2105 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2106 (const_int 0)))
2107 (clobber (match_scratch:P 2 "=r,r"))]
2108 ""
2109 "@
2110 neg. %2,%1
2111 #"
2112 [(set_attr "type" "fast_compare")
2113 (set_attr "length" "4,8")])
2114
2115 (define_split
2116 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2117 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2118 (const_int 0)))
2119 (clobber (match_scratch:P 2 ""))]
2120 "reload_completed"
2121 [(set (match_dup 2)
2122 (neg:P (match_dup 1)))
2123 (set (match_dup 0)
2124 (compare:CC (match_dup 2)
2125 (const_int 0)))]
2126 "")
2127
2128 (define_insn ""
2129 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2130 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2131 (const_int 0)))
2132 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2133 (neg:P (match_dup 1)))]
2134 ""
2135 "@
2136 neg. %0,%1
2137 #"
2138 [(set_attr "type" "fast_compare")
2139 (set_attr "length" "4,8")])
2140
2141 (define_split
2142 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2143 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2144 (const_int 0)))
2145 (set (match_operand:P 0 "gpc_reg_operand" "")
2146 (neg:P (match_dup 1)))]
2147 "reload_completed"
2148 [(set (match_dup 0)
2149 (neg:P (match_dup 1)))
2150 (set (match_dup 2)
2151 (compare:CC (match_dup 0)
2152 (const_int 0)))]
2153 "")
2154
2155 (define_insn "clz<mode>2"
2156 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2157 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2158 ""
2159 "{cntlz|cntlz<wd>} %0,%1"
2160 [(set_attr "type" "cntlz")])
2161
2162 (define_expand "ctz<mode>2"
2163 [(set (match_dup 2)
2164 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
2165 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2166 (match_dup 2)))
2167 (clobber (scratch:CC))])
2168 (set (match_dup 4) (clz:GPR (match_dup 3)))
2169 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2170 (minus:GPR (match_dup 5) (match_dup 4)))]
2171 ""
2172 {
2173 operands[2] = gen_reg_rtx (<MODE>mode);
2174 operands[3] = gen_reg_rtx (<MODE>mode);
2175 operands[4] = gen_reg_rtx (<MODE>mode);
2176 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
2177 })
2178
2179 (define_expand "ffs<mode>2"
2180 [(set (match_dup 2)
2181 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
2182 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2183 (match_dup 2)))
2184 (clobber (scratch:CC))])
2185 (set (match_dup 4) (clz:GPR (match_dup 3)))
2186 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2187 (minus:GPR (match_dup 5) (match_dup 4)))]
2188 ""
2189 {
2190 operands[2] = gen_reg_rtx (<MODE>mode);
2191 operands[3] = gen_reg_rtx (<MODE>mode);
2192 operands[4] = gen_reg_rtx (<MODE>mode);
2193 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
2194 })
2195
2196 (define_insn "popcntb<mode>2"
2197 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2198 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2199 UNSPEC_POPCNTB))]
2200 "TARGET_POPCNTB"
2201 "popcntb %0,%1")
2202
2203 (define_expand "popcount<mode>2"
2204 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2205 (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
2206 "TARGET_POPCNTB"
2207 {
2208 rs6000_emit_popcount (operands[0], operands[1]);
2209 DONE;
2210 })
2211
2212 (define_expand "parity<mode>2"
2213 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2214 (parity:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
2215 "TARGET_POPCNTB"
2216 {
2217 rs6000_emit_parity (operands[0], operands[1]);
2218 DONE;
2219 })
2220
2221 (define_insn "bswapsi2"
2222 [(set (match_operand:SI 0 "reg_or_mem_operand" "=r,Z,&r")
2223 (bswap:SI (match_operand:SI 1 "reg_or_mem_operand" "Z,r,r")))]
2224 ""
2225 "@
2226 {lbrx|lwbrx} %0,%y1
2227 {stbrx|stwbrx} %1,%y0
2228 #"
2229 [(set_attr "length" "4,4,12")])
2230
2231 (define_split
2232 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2233 (bswap:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2234 "reload_completed"
2235 [(set (match_dup 0)
2236 (rotate:SI (match_dup 1) (const_int 8)))
2237 (set (zero_extract:SI (match_dup 0)
2238 (const_int 8)
2239 (const_int 0))
2240 (match_dup 1))
2241 (set (zero_extract:SI (match_dup 0)
2242 (const_int 8)
2243 (const_int 16))
2244 (rotate:SI (match_dup 1)
2245 (const_int 16)))]
2246 "")
2247
2248 (define_expand "mulsi3"
2249 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2250 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2251 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2252 ""
2253 "
2254 {
2255 if (TARGET_POWER)
2256 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2257 else
2258 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2259 DONE;
2260 }")
2261
2262 (define_insn "mulsi3_mq"
2263 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2264 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2265 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2266 (clobber (match_scratch:SI 3 "=q,q"))]
2267 "TARGET_POWER"
2268 "@
2269 {muls|mullw} %0,%1,%2
2270 {muli|mulli} %0,%1,%2"
2271 [(set (attr "type")
2272 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2273 (const_string "imul3")
2274 (match_operand:SI 2 "short_cint_operand" "")
2275 (const_string "imul2")]
2276 (const_string "imul")))])
2277
2278 (define_insn "mulsi3_no_mq"
2279 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2280 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2281 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2282 "! TARGET_POWER"
2283 "@
2284 {muls|mullw} %0,%1,%2
2285 {muli|mulli} %0,%1,%2"
2286 [(set (attr "type")
2287 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2288 (const_string "imul3")
2289 (match_operand:SI 2 "short_cint_operand" "")
2290 (const_string "imul2")]
2291 (const_string "imul")))])
2292
2293 (define_insn "*mulsi3_mq_internal1"
2294 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2295 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2296 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2297 (const_int 0)))
2298 (clobber (match_scratch:SI 3 "=r,r"))
2299 (clobber (match_scratch:SI 4 "=q,q"))]
2300 "TARGET_POWER"
2301 "@
2302 {muls.|mullw.} %3,%1,%2
2303 #"
2304 [(set_attr "type" "imul_compare")
2305 (set_attr "length" "4,8")])
2306
2307 (define_split
2308 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2309 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2310 (match_operand:SI 2 "gpc_reg_operand" ""))
2311 (const_int 0)))
2312 (clobber (match_scratch:SI 3 ""))
2313 (clobber (match_scratch:SI 4 ""))]
2314 "TARGET_POWER && reload_completed"
2315 [(parallel [(set (match_dup 3)
2316 (mult:SI (match_dup 1) (match_dup 2)))
2317 (clobber (match_dup 4))])
2318 (set (match_dup 0)
2319 (compare:CC (match_dup 3)
2320 (const_int 0)))]
2321 "")
2322
2323 (define_insn "*mulsi3_no_mq_internal1"
2324 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2325 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2326 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2327 (const_int 0)))
2328 (clobber (match_scratch:SI 3 "=r,r"))]
2329 "! TARGET_POWER"
2330 "@
2331 {muls.|mullw.} %3,%1,%2
2332 #"
2333 [(set_attr "type" "imul_compare")
2334 (set_attr "length" "4,8")])
2335
2336 (define_split
2337 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2338 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2339 (match_operand:SI 2 "gpc_reg_operand" ""))
2340 (const_int 0)))
2341 (clobber (match_scratch:SI 3 ""))]
2342 "! TARGET_POWER && reload_completed"
2343 [(set (match_dup 3)
2344 (mult:SI (match_dup 1) (match_dup 2)))
2345 (set (match_dup 0)
2346 (compare:CC (match_dup 3)
2347 (const_int 0)))]
2348 "")
2349
2350 (define_insn "*mulsi3_mq_internal2"
2351 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2352 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2353 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2354 (const_int 0)))
2355 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2356 (mult:SI (match_dup 1) (match_dup 2)))
2357 (clobber (match_scratch:SI 4 "=q,q"))]
2358 "TARGET_POWER"
2359 "@
2360 {muls.|mullw.} %0,%1,%2
2361 #"
2362 [(set_attr "type" "imul_compare")
2363 (set_attr "length" "4,8")])
2364
2365 (define_split
2366 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2367 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2368 (match_operand:SI 2 "gpc_reg_operand" ""))
2369 (const_int 0)))
2370 (set (match_operand:SI 0 "gpc_reg_operand" "")
2371 (mult:SI (match_dup 1) (match_dup 2)))
2372 (clobber (match_scratch:SI 4 ""))]
2373 "TARGET_POWER && reload_completed"
2374 [(parallel [(set (match_dup 0)
2375 (mult:SI (match_dup 1) (match_dup 2)))
2376 (clobber (match_dup 4))])
2377 (set (match_dup 3)
2378 (compare:CC (match_dup 0)
2379 (const_int 0)))]
2380 "")
2381
2382 (define_insn "*mulsi3_no_mq_internal2"
2383 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2384 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2385 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2386 (const_int 0)))
2387 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2388 (mult:SI (match_dup 1) (match_dup 2)))]
2389 "! TARGET_POWER"
2390 "@
2391 {muls.|mullw.} %0,%1,%2
2392 #"
2393 [(set_attr "type" "imul_compare")
2394 (set_attr "length" "4,8")])
2395
2396 (define_split
2397 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2398 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2399 (match_operand:SI 2 "gpc_reg_operand" ""))
2400 (const_int 0)))
2401 (set (match_operand:SI 0 "gpc_reg_operand" "")
2402 (mult:SI (match_dup 1) (match_dup 2)))]
2403 "! TARGET_POWER && reload_completed"
2404 [(set (match_dup 0)
2405 (mult:SI (match_dup 1) (match_dup 2)))
2406 (set (match_dup 3)
2407 (compare:CC (match_dup 0)
2408 (const_int 0)))]
2409 "")
2410
2411 ;; Operand 1 is divided by operand 2; quotient goes to operand
2412 ;; 0 and remainder to operand 3.
2413 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2414
2415 (define_expand "divmodsi4"
2416 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2417 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2418 (match_operand:SI 2 "gpc_reg_operand" "")))
2419 (set (match_operand:SI 3 "register_operand" "")
2420 (mod:SI (match_dup 1) (match_dup 2)))])]
2421 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2422 "
2423 {
2424 if (! TARGET_POWER && ! TARGET_POWERPC)
2425 {
2426 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2427 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2428 emit_insn (gen_divss_call ());
2429 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2430 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2431 DONE;
2432 }
2433 }")
2434
2435 (define_insn "*divmodsi4_internal"
2436 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2437 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2438 (match_operand:SI 2 "gpc_reg_operand" "r")))
2439 (set (match_operand:SI 3 "register_operand" "=q")
2440 (mod:SI (match_dup 1) (match_dup 2)))]
2441 "TARGET_POWER"
2442 "divs %0,%1,%2"
2443 [(set_attr "type" "idiv")])
2444
2445 (define_expand "udiv<mode>3"
2446 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2447 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2448 (match_operand:GPR 2 "gpc_reg_operand" "")))]
2449 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2450 "
2451 {
2452 if (! TARGET_POWER && ! TARGET_POWERPC)
2453 {
2454 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2455 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2456 emit_insn (gen_quous_call ());
2457 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2458 DONE;
2459 }
2460 else if (TARGET_POWER)
2461 {
2462 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2463 DONE;
2464 }
2465 }")
2466
2467 (define_insn "udivsi3_mq"
2468 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2469 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2470 (match_operand:SI 2 "gpc_reg_operand" "r")))
2471 (clobber (match_scratch:SI 3 "=q"))]
2472 "TARGET_POWERPC && TARGET_POWER"
2473 "divwu %0,%1,%2"
2474 [(set_attr "type" "idiv")])
2475
2476 (define_insn "*udivsi3_no_mq"
2477 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2478 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2479 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2480 "TARGET_POWERPC && ! TARGET_POWER"
2481 "div<wd>u %0,%1,%2"
2482 [(set (attr "type")
2483 (cond [(match_operand:SI 0 "" "")
2484 (const_string "idiv")]
2485 (const_string "ldiv")))])
2486
2487
2488 ;; For powers of two we can do srai/aze for divide and then adjust for
2489 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2490 ;; used; for PowerPC, force operands into register and do a normal divide;
2491 ;; for AIX common-mode, use quoss call on register operands.
2492 (define_expand "div<mode>3"
2493 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2494 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2495 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2496 ""
2497 "
2498 {
2499 if (GET_CODE (operands[2]) == CONST_INT
2500 && INTVAL (operands[2]) > 0
2501 && exact_log2 (INTVAL (operands[2])) >= 0)
2502 ;
2503 else if (TARGET_POWERPC)
2504 {
2505 operands[2] = force_reg (<MODE>mode, operands[2]);
2506 if (TARGET_POWER)
2507 {
2508 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2509 DONE;
2510 }
2511 }
2512 else if (TARGET_POWER)
2513 FAIL;
2514 else
2515 {
2516 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2517 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2518 emit_insn (gen_quoss_call ());
2519 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2520 DONE;
2521 }
2522 }")
2523
2524 (define_insn "divsi3_mq"
2525 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2526 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2527 (match_operand:SI 2 "gpc_reg_operand" "r")))
2528 (clobber (match_scratch:SI 3 "=q"))]
2529 "TARGET_POWERPC && TARGET_POWER"
2530 "divw %0,%1,%2"
2531 [(set_attr "type" "idiv")])
2532
2533 (define_insn "*div<mode>3_no_mq"
2534 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2535 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2536 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2537 "TARGET_POWERPC && ! TARGET_POWER"
2538 "div<wd> %0,%1,%2"
2539 [(set (attr "type")
2540 (cond [(match_operand:SI 0 "" "")
2541 (const_string "idiv")]
2542 (const_string "ldiv")))])
2543
2544 (define_expand "mod<mode>3"
2545 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2546 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2547 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
2548 ""
2549 "
2550 {
2551 int i;
2552 rtx temp1;
2553 rtx temp2;
2554
2555 if (GET_CODE (operands[2]) != CONST_INT
2556 || INTVAL (operands[2]) <= 0
2557 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2558 FAIL;
2559
2560 temp1 = gen_reg_rtx (<MODE>mode);
2561 temp2 = gen_reg_rtx (<MODE>mode);
2562
2563 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2564 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2565 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
2566 DONE;
2567 }")
2568
2569 (define_insn ""
2570 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2571 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2572 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
2573 ""
2574 "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
2575 [(set_attr "type" "two")
2576 (set_attr "length" "8")])
2577
2578 (define_insn ""
2579 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2580 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2581 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2582 (const_int 0)))
2583 (clobber (match_scratch:P 3 "=r,r"))]
2584 ""
2585 "@
2586 {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
2587 #"
2588 [(set_attr "type" "compare")
2589 (set_attr "length" "8,12")])
2590
2591 (define_split
2592 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2593 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2594 (match_operand:GPR 2 "exact_log2_cint_operand"
2595 ""))
2596 (const_int 0)))
2597 (clobber (match_scratch:GPR 3 ""))]
2598 "reload_completed"
2599 [(set (match_dup 3)
2600 (div:<MODE> (match_dup 1) (match_dup 2)))
2601 (set (match_dup 0)
2602 (compare:CC (match_dup 3)
2603 (const_int 0)))]
2604 "")
2605
2606 (define_insn ""
2607 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2608 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2609 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2610 (const_int 0)))
2611 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2612 (div:P (match_dup 1) (match_dup 2)))]
2613 ""
2614 "@
2615 {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
2616 #"
2617 [(set_attr "type" "compare")
2618 (set_attr "length" "8,12")])
2619
2620 (define_split
2621 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2622 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2623 (match_operand:GPR 2 "exact_log2_cint_operand"
2624 ""))
2625 (const_int 0)))
2626 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2627 (div:GPR (match_dup 1) (match_dup 2)))]
2628 "reload_completed"
2629 [(set (match_dup 0)
2630 (div:<MODE> (match_dup 1) (match_dup 2)))
2631 (set (match_dup 3)
2632 (compare:CC (match_dup 0)
2633 (const_int 0)))]
2634 "")
2635
2636 (define_insn ""
2637 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2638 (udiv:SI
2639 (plus:DI (ashift:DI
2640 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2641 (const_int 32))
2642 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2643 (match_operand:SI 3 "gpc_reg_operand" "r")))
2644 (set (match_operand:SI 2 "register_operand" "=*q")
2645 (umod:SI
2646 (plus:DI (ashift:DI
2647 (zero_extend:DI (match_dup 1)) (const_int 32))
2648 (zero_extend:DI (match_dup 4)))
2649 (match_dup 3)))]
2650 "TARGET_POWER"
2651 "div %0,%1,%3"
2652 [(set_attr "type" "idiv")])
2653
2654 ;; To do unsigned divide we handle the cases of the divisor looking like a
2655 ;; negative number. If it is a constant that is less than 2**31, we don't
2656 ;; have to worry about the branches. So make a few subroutines here.
2657 ;;
2658 ;; First comes the normal case.
2659 (define_expand "udivmodsi4_normal"
2660 [(set (match_dup 4) (const_int 0))
2661 (parallel [(set (match_operand:SI 0 "" "")
2662 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2663 (const_int 32))
2664 (zero_extend:DI (match_operand:SI 1 "" "")))
2665 (match_operand:SI 2 "" "")))
2666 (set (match_operand:SI 3 "" "")
2667 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2668 (const_int 32))
2669 (zero_extend:DI (match_dup 1)))
2670 (match_dup 2)))])]
2671 "TARGET_POWER"
2672 "
2673 { operands[4] = gen_reg_rtx (SImode); }")
2674
2675 ;; This handles the branches.
2676 (define_expand "udivmodsi4_tests"
2677 [(set (match_operand:SI 0 "" "") (const_int 0))
2678 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2679 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2680 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2681 (label_ref (match_operand:SI 4 "" "")) (pc)))
2682 (set (match_dup 0) (const_int 1))
2683 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2684 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2685 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2686 (label_ref (match_dup 4)) (pc)))]
2687 "TARGET_POWER"
2688 "
2689 { operands[5] = gen_reg_rtx (CCUNSmode);
2690 operands[6] = gen_reg_rtx (CCmode);
2691 }")
2692
2693 (define_expand "udivmodsi4"
2694 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2695 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2696 (match_operand:SI 2 "reg_or_cint_operand" "")))
2697 (set (match_operand:SI 3 "gpc_reg_operand" "")
2698 (umod:SI (match_dup 1) (match_dup 2)))])]
2699 ""
2700 "
2701 {
2702 rtx label = 0;
2703
2704 if (! TARGET_POWER)
2705 {
2706 if (! TARGET_POWERPC)
2707 {
2708 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2709 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2710 emit_insn (gen_divus_call ());
2711 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2712 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2713 DONE;
2714 }
2715 else
2716 FAIL;
2717 }
2718
2719 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2720 {
2721 operands[2] = force_reg (SImode, operands[2]);
2722 label = gen_label_rtx ();
2723 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2724 operands[3], label));
2725 }
2726 else
2727 operands[2] = force_reg (SImode, operands[2]);
2728
2729 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2730 operands[3]));
2731 if (label)
2732 emit_label (label);
2733
2734 DONE;
2735 }")
2736
2737 ;; AIX architecture-independent common-mode multiply (DImode),
2738 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2739 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2740 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2741 ;; assumed unused if generating common-mode, so ignore.
2742 (define_insn "mulh_call"
2743 [(set (reg:SI 3)
2744 (truncate:SI
2745 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2746 (sign_extend:DI (reg:SI 4)))
2747 (const_int 32))))
2748 (clobber (reg:SI LR_REGNO))]
2749 "! TARGET_POWER && ! TARGET_POWERPC"
2750 "bla __mulh"
2751 [(set_attr "type" "imul")])
2752
2753 (define_insn "mull_call"
2754 [(set (reg:DI 3)
2755 (mult:DI (sign_extend:DI (reg:SI 3))
2756 (sign_extend:DI (reg:SI 4))))
2757 (clobber (reg:SI LR_REGNO))
2758 (clobber (reg:SI 0))]
2759 "! TARGET_POWER && ! TARGET_POWERPC"
2760 "bla __mull"
2761 [(set_attr "type" "imul")])
2762
2763 (define_insn "divss_call"
2764 [(set (reg:SI 3)
2765 (div:SI (reg:SI 3) (reg:SI 4)))
2766 (set (reg:SI 4)
2767 (mod:SI (reg:SI 3) (reg:SI 4)))
2768 (clobber (reg:SI LR_REGNO))
2769 (clobber (reg:SI 0))]
2770 "! TARGET_POWER && ! TARGET_POWERPC"
2771 "bla __divss"
2772 [(set_attr "type" "idiv")])
2773
2774 (define_insn "divus_call"
2775 [(set (reg:SI 3)
2776 (udiv:SI (reg:SI 3) (reg:SI 4)))
2777 (set (reg:SI 4)
2778 (umod:SI (reg:SI 3) (reg:SI 4)))
2779 (clobber (reg:SI LR_REGNO))
2780 (clobber (reg:SI 0))
2781 (clobber (match_scratch:CC 0 "=x"))
2782 (clobber (reg:CC CR1_REGNO))]
2783 "! TARGET_POWER && ! TARGET_POWERPC"
2784 "bla __divus"
2785 [(set_attr "type" "idiv")])
2786
2787 (define_insn "quoss_call"
2788 [(set (reg:SI 3)
2789 (div:SI (reg:SI 3) (reg:SI 4)))
2790 (clobber (reg:SI LR_REGNO))]
2791 "! TARGET_POWER && ! TARGET_POWERPC"
2792 "bla __quoss"
2793 [(set_attr "type" "idiv")])
2794
2795 (define_insn "quous_call"
2796 [(set (reg:SI 3)
2797 (udiv:SI (reg:SI 3) (reg:SI 4)))
2798 (clobber (reg:SI LR_REGNO))
2799 (clobber (reg:SI 0))
2800 (clobber (match_scratch:CC 0 "=x"))
2801 (clobber (reg:CC CR1_REGNO))]
2802 "! TARGET_POWER && ! TARGET_POWERPC"
2803 "bla __quous"
2804 [(set_attr "type" "idiv")])
2805 \f
2806 ;; Logical instructions
2807 ;; The logical instructions are mostly combined by using match_operator,
2808 ;; but the plain AND insns are somewhat different because there is no
2809 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2810 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2811
2812 (define_insn "andsi3"
2813 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2814 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2815 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2816 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2817 ""
2818 "@
2819 and %0,%1,%2
2820 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2821 {andil.|andi.} %0,%1,%b2
2822 {andiu.|andis.} %0,%1,%u2"
2823 [(set_attr "type" "*,*,compare,compare")])
2824
2825 ;; Note to set cr's other than cr0 we do the and immediate and then
2826 ;; the test again -- this avoids a mfcr which on the higher end
2827 ;; machines causes an execution serialization
2828
2829 (define_insn "*andsi3_internal2"
2830 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2831 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2832 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2833 (const_int 0)))
2834 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2835 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2836 "TARGET_32BIT"
2837 "@
2838 and. %3,%1,%2
2839 {andil.|andi.} %3,%1,%b2
2840 {andiu.|andis.} %3,%1,%u2
2841 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2842 #
2843 #
2844 #
2845 #"
2846 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2847 (set_attr "length" "4,4,4,4,8,8,8,8")])
2848
2849 (define_insn "*andsi3_internal3"
2850 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2851 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2852 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2853 (const_int 0)))
2854 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2855 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2856 "TARGET_64BIT"
2857 "@
2858 #
2859 {andil.|andi.} %3,%1,%b2
2860 {andiu.|andis.} %3,%1,%u2
2861 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2862 #
2863 #
2864 #
2865 #"
2866 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2867 (set_attr "length" "8,4,4,4,8,8,8,8")])
2868
2869 (define_split
2870 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2871 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2872 (match_operand:GPR 2 "and_operand" ""))
2873 (const_int 0)))
2874 (clobber (match_scratch:GPR 3 ""))
2875 (clobber (match_scratch:CC 4 ""))]
2876 "reload_completed"
2877 [(parallel [(set (match_dup 3)
2878 (and:<MODE> (match_dup 1)
2879 (match_dup 2)))
2880 (clobber (match_dup 4))])
2881 (set (match_dup 0)
2882 (compare:CC (match_dup 3)
2883 (const_int 0)))]
2884 "")
2885
2886 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2887 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2888
2889 (define_split
2890 [(set (match_operand:CC 0 "cc_reg_operand" "")
2891 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2892 (match_operand:SI 2 "gpc_reg_operand" ""))
2893 (const_int 0)))
2894 (clobber (match_scratch:SI 3 ""))
2895 (clobber (match_scratch:CC 4 ""))]
2896 "TARGET_POWERPC64 && reload_completed"
2897 [(parallel [(set (match_dup 3)
2898 (and:SI (match_dup 1)
2899 (match_dup 2)))
2900 (clobber (match_dup 4))])
2901 (set (match_dup 0)
2902 (compare:CC (match_dup 3)
2903 (const_int 0)))]
2904 "")
2905
2906 (define_insn "*andsi3_internal4"
2907 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2908 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2909 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2910 (const_int 0)))
2911 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2912 (and:SI (match_dup 1)
2913 (match_dup 2)))
2914 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2915 "TARGET_32BIT"
2916 "@
2917 and. %0,%1,%2
2918 {andil.|andi.} %0,%1,%b2
2919 {andiu.|andis.} %0,%1,%u2
2920 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2921 #
2922 #
2923 #
2924 #"
2925 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2926 (set_attr "length" "4,4,4,4,8,8,8,8")])
2927
2928 (define_insn "*andsi3_internal5"
2929 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2930 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2931 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2932 (const_int 0)))
2933 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2934 (and:SI (match_dup 1)
2935 (match_dup 2)))
2936 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2937 "TARGET_64BIT"
2938 "@
2939 #
2940 {andil.|andi.} %0,%1,%b2
2941 {andiu.|andis.} %0,%1,%u2
2942 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2943 #
2944 #
2945 #
2946 #"
2947 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2948 (set_attr "length" "8,4,4,4,8,8,8,8")])
2949
2950 (define_split
2951 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2952 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2953 (match_operand:SI 2 "and_operand" ""))
2954 (const_int 0)))
2955 (set (match_operand:SI 0 "gpc_reg_operand" "")
2956 (and:SI (match_dup 1)
2957 (match_dup 2)))
2958 (clobber (match_scratch:CC 4 ""))]
2959 "reload_completed"
2960 [(parallel [(set (match_dup 0)
2961 (and:SI (match_dup 1)
2962 (match_dup 2)))
2963 (clobber (match_dup 4))])
2964 (set (match_dup 3)
2965 (compare:CC (match_dup 0)
2966 (const_int 0)))]
2967 "")
2968
2969 (define_split
2970 [(set (match_operand:CC 3 "cc_reg_operand" "")
2971 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2972 (match_operand:SI 2 "gpc_reg_operand" ""))
2973 (const_int 0)))
2974 (set (match_operand:SI 0 "gpc_reg_operand" "")
2975 (and:SI (match_dup 1)
2976 (match_dup 2)))
2977 (clobber (match_scratch:CC 4 ""))]
2978 "TARGET_POWERPC64 && reload_completed"
2979 [(parallel [(set (match_dup 0)
2980 (and:SI (match_dup 1)
2981 (match_dup 2)))
2982 (clobber (match_dup 4))])
2983 (set (match_dup 3)
2984 (compare:CC (match_dup 0)
2985 (const_int 0)))]
2986 "")
2987
2988 ;; Handle the PowerPC64 rlwinm corner case
2989
2990 (define_insn_and_split "*andsi3_internal6"
2991 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2992 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2993 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2994 "TARGET_POWERPC64"
2995 "#"
2996 "TARGET_POWERPC64"
2997 [(set (match_dup 0)
2998 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2999 (match_dup 4)))
3000 (set (match_dup 0)
3001 (rotate:SI (match_dup 0) (match_dup 5)))]
3002 "
3003 {
3004 int mb = extract_MB (operands[2]);
3005 int me = extract_ME (operands[2]);
3006 operands[3] = GEN_INT (me + 1);
3007 operands[5] = GEN_INT (32 - (me + 1));
3008 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
3009 }"
3010 [(set_attr "length" "8")])
3011
3012 (define_expand "iorsi3"
3013 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3014 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
3015 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
3016 ""
3017 "
3018 {
3019 if (GET_CODE (operands[2]) == CONST_INT
3020 && ! logical_operand (operands[2], SImode))
3021 {
3022 HOST_WIDE_INT value = INTVAL (operands[2]);
3023 rtx tmp = ((!can_create_pseudo_p ()
3024 || rtx_equal_p (operands[0], operands[1]))
3025 ? operands[0] : gen_reg_rtx (SImode));
3026
3027 emit_insn (gen_iorsi3 (tmp, operands[1],
3028 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3029 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3030 DONE;
3031 }
3032 }")
3033
3034 (define_expand "xorsi3"
3035 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3036 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
3037 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
3038 ""
3039 "
3040 {
3041 if (GET_CODE (operands[2]) == CONST_INT
3042 && ! logical_operand (operands[2], SImode))
3043 {
3044 HOST_WIDE_INT value = INTVAL (operands[2]);
3045 rtx tmp = ((!can_create_pseudo_p ()
3046 || rtx_equal_p (operands[0], operands[1]))
3047 ? operands[0] : gen_reg_rtx (SImode));
3048
3049 emit_insn (gen_xorsi3 (tmp, operands[1],
3050 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3051 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3052 DONE;
3053 }
3054 }")
3055
3056 (define_insn "*boolsi3_internal1"
3057 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
3058 (match_operator:SI 3 "boolean_or_operator"
3059 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
3060 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
3061 ""
3062 "@
3063 %q3 %0,%1,%2
3064 {%q3il|%q3i} %0,%1,%b2
3065 {%q3iu|%q3is} %0,%1,%u2")
3066
3067 (define_insn "*boolsi3_internal2"
3068 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3069 (compare:CC (match_operator:SI 4 "boolean_or_operator"
3070 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3071 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3072 (const_int 0)))
3073 (clobber (match_scratch:SI 3 "=r,r"))]
3074 "TARGET_32BIT"
3075 "@
3076 %q4. %3,%1,%2
3077 #"
3078 [(set_attr "type" "compare")
3079 (set_attr "length" "4,8")])
3080
3081 (define_split
3082 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3083 (compare:CC (match_operator:SI 4 "boolean_operator"
3084 [(match_operand:SI 1 "gpc_reg_operand" "")
3085 (match_operand:SI 2 "gpc_reg_operand" "")])
3086 (const_int 0)))
3087 (clobber (match_scratch:SI 3 ""))]
3088 "TARGET_32BIT && reload_completed"
3089 [(set (match_dup 3) (match_dup 4))
3090 (set (match_dup 0)
3091 (compare:CC (match_dup 3)
3092 (const_int 0)))]
3093 "")
3094
3095 (define_insn "*boolsi3_internal3"
3096 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3097 (compare:CC (match_operator:SI 4 "boolean_operator"
3098 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3099 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3100 (const_int 0)))
3101 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3102 (match_dup 4))]
3103 "TARGET_32BIT"
3104 "@
3105 %q4. %0,%1,%2
3106 #"
3107 [(set_attr "type" "compare")
3108 (set_attr "length" "4,8")])
3109
3110 (define_split
3111 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3112 (compare:CC (match_operator:SI 4 "boolean_operator"
3113 [(match_operand:SI 1 "gpc_reg_operand" "")
3114 (match_operand:SI 2 "gpc_reg_operand" "")])
3115 (const_int 0)))
3116 (set (match_operand:SI 0 "gpc_reg_operand" "")
3117 (match_dup 4))]
3118 "TARGET_32BIT && reload_completed"
3119 [(set (match_dup 0) (match_dup 4))
3120 (set (match_dup 3)
3121 (compare:CC (match_dup 0)
3122 (const_int 0)))]
3123 "")
3124
3125 ;; Split a logical operation that we can't do in one insn into two insns,
3126 ;; each of which does one 16-bit part. This is used by combine.
3127
3128 (define_split
3129 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3130 (match_operator:SI 3 "boolean_or_operator"
3131 [(match_operand:SI 1 "gpc_reg_operand" "")
3132 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
3133 ""
3134 [(set (match_dup 0) (match_dup 4))
3135 (set (match_dup 0) (match_dup 5))]
3136 "
3137 {
3138 rtx i;
3139 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
3140 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3141 operands[1], i);
3142 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
3143 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3144 operands[0], i);
3145 }")
3146
3147 (define_insn "*boolcsi3_internal1"
3148 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3149 (match_operator:SI 3 "boolean_operator"
3150 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3151 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
3152 ""
3153 "%q3 %0,%2,%1")
3154
3155 (define_insn "*boolcsi3_internal2"
3156 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3157 (compare:CC (match_operator:SI 4 "boolean_operator"
3158 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3159 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3160 (const_int 0)))
3161 (clobber (match_scratch:SI 3 "=r,r"))]
3162 "TARGET_32BIT"
3163 "@
3164 %q4. %3,%2,%1
3165 #"
3166 [(set_attr "type" "compare")
3167 (set_attr "length" "4,8")])
3168
3169 (define_split
3170 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3171 (compare:CC (match_operator:SI 4 "boolean_operator"
3172 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3173 (match_operand:SI 2 "gpc_reg_operand" "")])
3174 (const_int 0)))
3175 (clobber (match_scratch:SI 3 ""))]
3176 "TARGET_32BIT && reload_completed"
3177 [(set (match_dup 3) (match_dup 4))
3178 (set (match_dup 0)
3179 (compare:CC (match_dup 3)
3180 (const_int 0)))]
3181 "")
3182
3183 (define_insn "*boolcsi3_internal3"
3184 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3185 (compare:CC (match_operator:SI 4 "boolean_operator"
3186 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3187 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3188 (const_int 0)))
3189 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3190 (match_dup 4))]
3191 "TARGET_32BIT"
3192 "@
3193 %q4. %0,%2,%1
3194 #"
3195 [(set_attr "type" "compare")
3196 (set_attr "length" "4,8")])
3197
3198 (define_split
3199 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3200 (compare:CC (match_operator:SI 4 "boolean_operator"
3201 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3202 (match_operand:SI 2 "gpc_reg_operand" "")])
3203 (const_int 0)))
3204 (set (match_operand:SI 0 "gpc_reg_operand" "")
3205 (match_dup 4))]
3206 "TARGET_32BIT && reload_completed"
3207 [(set (match_dup 0) (match_dup 4))
3208 (set (match_dup 3)
3209 (compare:CC (match_dup 0)
3210 (const_int 0)))]
3211 "")
3212
3213 (define_insn "*boolccsi3_internal1"
3214 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3215 (match_operator:SI 3 "boolean_operator"
3216 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3217 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3218 ""
3219 "%q3 %0,%1,%2")
3220
3221 (define_insn "*boolccsi3_internal2"
3222 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3223 (compare:CC (match_operator:SI 4 "boolean_operator"
3224 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3225 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3226 (const_int 0)))
3227 (clobber (match_scratch:SI 3 "=r,r"))]
3228 "TARGET_32BIT"
3229 "@
3230 %q4. %3,%1,%2
3231 #"
3232 [(set_attr "type" "compare")
3233 (set_attr "length" "4,8")])
3234
3235 (define_split
3236 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3237 (compare:CC (match_operator:SI 4 "boolean_operator"
3238 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3239 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3240 (const_int 0)))
3241 (clobber (match_scratch:SI 3 ""))]
3242 "TARGET_32BIT && reload_completed"
3243 [(set (match_dup 3) (match_dup 4))
3244 (set (match_dup 0)
3245 (compare:CC (match_dup 3)
3246 (const_int 0)))]
3247 "")
3248
3249 (define_insn "*boolccsi3_internal3"
3250 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3251 (compare:CC (match_operator:SI 4 "boolean_operator"
3252 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3253 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3254 (const_int 0)))
3255 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3256 (match_dup 4))]
3257 "TARGET_32BIT"
3258 "@
3259 %q4. %0,%1,%2
3260 #"
3261 [(set_attr "type" "compare")
3262 (set_attr "length" "4,8")])
3263
3264 (define_split
3265 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3266 (compare:CC (match_operator:SI 4 "boolean_operator"
3267 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3268 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3269 (const_int 0)))
3270 (set (match_operand:SI 0 "gpc_reg_operand" "")
3271 (match_dup 4))]
3272 "TARGET_32BIT && reload_completed"
3273 [(set (match_dup 0) (match_dup 4))
3274 (set (match_dup 3)
3275 (compare:CC (match_dup 0)
3276 (const_int 0)))]
3277 "")
3278
3279 ;; maskir insn. We need four forms because things might be in arbitrary
3280 ;; orders. Don't define forms that only set CR fields because these
3281 ;; would modify an input register.
3282
3283 (define_insn "*maskir_internal1"
3284 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3285 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3286 (match_operand:SI 1 "gpc_reg_operand" "0"))
3287 (and:SI (match_dup 2)
3288 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
3289 "TARGET_POWER"
3290 "maskir %0,%3,%2")
3291
3292 (define_insn "*maskir_internal2"
3293 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3294 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3295 (match_operand:SI 1 "gpc_reg_operand" "0"))
3296 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3297 (match_dup 2))))]
3298 "TARGET_POWER"
3299 "maskir %0,%3,%2")
3300
3301 (define_insn "*maskir_internal3"
3302 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3303 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
3304 (match_operand:SI 3 "gpc_reg_operand" "r"))
3305 (and:SI (not:SI (match_dup 2))
3306 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3307 "TARGET_POWER"
3308 "maskir %0,%3,%2")
3309
3310 (define_insn "*maskir_internal4"
3311 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3312 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3313 (match_operand:SI 2 "gpc_reg_operand" "r"))
3314 (and:SI (not:SI (match_dup 2))
3315 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3316 "TARGET_POWER"
3317 "maskir %0,%3,%2")
3318
3319 (define_insn "*maskir_internal5"
3320 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3321 (compare:CC
3322 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3323 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3324 (and:SI (match_dup 2)
3325 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
3326 (const_int 0)))
3327 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3328 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3329 (and:SI (match_dup 2) (match_dup 3))))]
3330 "TARGET_POWER"
3331 "@
3332 maskir. %0,%3,%2
3333 #"
3334 [(set_attr "type" "compare")
3335 (set_attr "length" "4,8")])
3336
3337 (define_split
3338 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3339 (compare:CC
3340 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3341 (match_operand:SI 1 "gpc_reg_operand" ""))
3342 (and:SI (match_dup 2)
3343 (match_operand:SI 3 "gpc_reg_operand" "")))
3344 (const_int 0)))
3345 (set (match_operand:SI 0 "gpc_reg_operand" "")
3346 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3347 (and:SI (match_dup 2) (match_dup 3))))]
3348 "TARGET_POWER && reload_completed"
3349 [(set (match_dup 0)
3350 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3351 (and:SI (match_dup 2) (match_dup 3))))
3352 (set (match_dup 4)
3353 (compare:CC (match_dup 0)
3354 (const_int 0)))]
3355 "")
3356
3357 (define_insn "*maskir_internal6"
3358 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3359 (compare:CC
3360 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3361 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3362 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3363 (match_dup 2)))
3364 (const_int 0)))
3365 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3366 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3367 (and:SI (match_dup 3) (match_dup 2))))]
3368 "TARGET_POWER"
3369 "@
3370 maskir. %0,%3,%2
3371 #"
3372 [(set_attr "type" "compare")
3373 (set_attr "length" "4,8")])
3374
3375 (define_split
3376 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3377 (compare:CC
3378 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3379 (match_operand:SI 1 "gpc_reg_operand" ""))
3380 (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3381 (match_dup 2)))
3382 (const_int 0)))
3383 (set (match_operand:SI 0 "gpc_reg_operand" "")
3384 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3385 (and:SI (match_dup 3) (match_dup 2))))]
3386 "TARGET_POWER && reload_completed"
3387 [(set (match_dup 0)
3388 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3389 (and:SI (match_dup 3) (match_dup 2))))
3390 (set (match_dup 4)
3391 (compare:CC (match_dup 0)
3392 (const_int 0)))]
3393 "")
3394
3395 (define_insn "*maskir_internal7"
3396 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3397 (compare:CC
3398 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
3399 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
3400 (and:SI (not:SI (match_dup 2))
3401 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3402 (const_int 0)))
3403 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3404 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3405 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3406 "TARGET_POWER"
3407 "@
3408 maskir. %0,%3,%2
3409 #"
3410 [(set_attr "type" "compare")
3411 (set_attr "length" "4,8")])
3412
3413 (define_split
3414 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3415 (compare:CC
3416 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
3417 (match_operand:SI 3 "gpc_reg_operand" ""))
3418 (and:SI (not:SI (match_dup 2))
3419 (match_operand:SI 1 "gpc_reg_operand" "")))
3420 (const_int 0)))
3421 (set (match_operand:SI 0 "gpc_reg_operand" "")
3422 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3423 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3424 "TARGET_POWER && reload_completed"
3425 [(set (match_dup 0)
3426 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3427 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3428 (set (match_dup 4)
3429 (compare:CC (match_dup 0)
3430 (const_int 0)))]
3431 "")
3432
3433 (define_insn "*maskir_internal8"
3434 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3435 (compare:CC
3436 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3437 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3438 (and:SI (not:SI (match_dup 2))
3439 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3440 (const_int 0)))
3441 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3442 (ior:SI (and:SI (match_dup 3) (match_dup 2))
3443 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3444 "TARGET_POWER"
3445 "@
3446 maskir. %0,%3,%2
3447 #"
3448 [(set_attr "type" "compare")
3449 (set_attr "length" "4,8")])
3450
3451 (define_split
3452 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3453 (compare:CC
3454 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3455 (match_operand:SI 2 "gpc_reg_operand" ""))
3456 (and:SI (not:SI (match_dup 2))
3457 (match_operand:SI 1 "gpc_reg_operand" "")))
3458 (const_int 0)))
3459 (set (match_operand:SI 0 "gpc_reg_operand" "")
3460 (ior:SI (and:SI (match_dup 3) (match_dup 2))
3461 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3462 "TARGET_POWER && reload_completed"
3463 [(set (match_dup 0)
3464 (ior:SI (and:SI (match_dup 3) (match_dup 2))
3465 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3466 (set (match_dup 4)
3467 (compare:CC (match_dup 0)
3468 (const_int 0)))]
3469 "")
3470 \f
3471 ;; Rotate and shift insns, in all their variants. These support shifts,
3472 ;; field inserts and extracts, and various combinations thereof.
3473 (define_expand "insv"
3474 [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
3475 (match_operand:SI 1 "const_int_operand" "")
3476 (match_operand:SI 2 "const_int_operand" ""))
3477 (match_operand 3 "gpc_reg_operand" ""))]
3478 ""
3479 "
3480 {
3481 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3482 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3483 compiler if the address of the structure is taken later. Likewise, do
3484 not handle invalid E500 subregs. */
3485 if (GET_CODE (operands[0]) == SUBREG
3486 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD
3487 || ((TARGET_E500_DOUBLE || TARGET_SPE)
3488 && invalid_e500_subreg (operands[0], GET_MODE (operands[0])))))
3489 FAIL;
3490
3491 if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
3492 emit_insn (gen_insvdi (operands[0], operands[1], operands[2], operands[3]));
3493 else
3494 emit_insn (gen_insvsi (operands[0], operands[1], operands[2], operands[3]));
3495 DONE;
3496 }")
3497
3498 (define_insn "insvsi"
3499 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3500 (match_operand:SI 1 "const_int_operand" "i")
3501 (match_operand:SI 2 "const_int_operand" "i"))
3502 (match_operand:SI 3 "gpc_reg_operand" "r"))]
3503 ""
3504 "*
3505 {
3506 int start = INTVAL (operands[2]) & 31;
3507 int size = INTVAL (operands[1]) & 31;
3508
3509 operands[4] = GEN_INT (32 - start - size);
3510 operands[1] = GEN_INT (start + size - 1);
3511 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3512 }"
3513 [(set_attr "type" "insert_word")])
3514
3515 (define_insn "*insvsi_internal1"
3516 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3517 (match_operand:SI 1 "const_int_operand" "i")
3518 (match_operand:SI 2 "const_int_operand" "i"))
3519 (rotate:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3520 (match_operand:SI 4 "const_int_operand" "i")))]
3521 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3522 "*
3523 {
3524 int shift = INTVAL (operands[4]) & 31;
3525 int start = INTVAL (operands[2]) & 31;
3526 int size = INTVAL (operands[1]) & 31;
3527
3528 operands[4] = GEN_INT (shift - start - size);
3529 operands[1] = GEN_INT (start + size - 1);
3530 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3531 }"
3532 [(set_attr "type" "insert_word")])
3533
3534 (define_insn "*insvsi_internal2"
3535 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3536 (match_operand:SI 1 "const_int_operand" "i")
3537 (match_operand:SI 2 "const_int_operand" "i"))
3538 (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3539 (match_operand:SI 4 "const_int_operand" "i")))]
3540 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3541 "*
3542 {
3543 int shift = INTVAL (operands[4]) & 31;
3544 int start = INTVAL (operands[2]) & 31;
3545 int size = INTVAL (operands[1]) & 31;
3546
3547 operands[4] = GEN_INT (32 - shift - start - size);
3548 operands[1] = GEN_INT (start + size - 1);
3549 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3550 }"
3551 [(set_attr "type" "insert_word")])
3552
3553 (define_insn "*insvsi_internal3"
3554 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3555 (match_operand:SI 1 "const_int_operand" "i")
3556 (match_operand:SI 2 "const_int_operand" "i"))
3557 (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3558 (match_operand:SI 4 "const_int_operand" "i")))]
3559 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3560 "*
3561 {
3562 int shift = INTVAL (operands[4]) & 31;
3563 int start = INTVAL (operands[2]) & 31;
3564 int size = INTVAL (operands[1]) & 31;
3565
3566 operands[4] = GEN_INT (32 - shift - start - size);
3567 operands[1] = GEN_INT (start + size - 1);
3568 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3569 }"
3570 [(set_attr "type" "insert_word")])
3571
3572 (define_insn "*insvsi_internal4"
3573 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3574 (match_operand:SI 1 "const_int_operand" "i")
3575 (match_operand:SI 2 "const_int_operand" "i"))
3576 (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3577 (match_operand:SI 4 "const_int_operand" "i")
3578 (match_operand:SI 5 "const_int_operand" "i")))]
3579 "INTVAL (operands[4]) >= INTVAL (operands[1])"
3580 "*
3581 {
3582 int extract_start = INTVAL (operands[5]) & 31;
3583 int extract_size = INTVAL (operands[4]) & 31;
3584 int insert_start = INTVAL (operands[2]) & 31;
3585 int insert_size = INTVAL (operands[1]) & 31;
3586
3587 /* Align extract field with insert field */
3588 operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
3589 operands[1] = GEN_INT (insert_start + insert_size - 1);
3590 return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
3591 }"
3592 [(set_attr "type" "insert_word")])
3593
3594 ;; combine patterns for rlwimi
3595 (define_insn "*insvsi_internal5"
3596 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3597 (ior:SI (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3598 (match_operand:SI 1 "mask_operand" "i"))
3599 (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3600 (match_operand:SI 2 "const_int_operand" "i"))
3601 (match_operand:SI 5 "mask_operand" "i"))))]
3602 "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
3603 "*
3604 {
3605 int me = extract_ME(operands[5]);
3606 int mb = extract_MB(operands[5]);
3607 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3608 operands[2] = GEN_INT(mb);
3609 operands[1] = GEN_INT(me);
3610 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3611 }"
3612 [(set_attr "type" "insert_word")])
3613
3614 (define_insn "*insvsi_internal6"
3615 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3616 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3617 (match_operand:SI 2 "const_int_operand" "i"))
3618 (match_operand:SI 5 "mask_operand" "i"))
3619 (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3620 (match_operand:SI 1 "mask_operand" "i"))))]
3621 "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
3622 "*
3623 {
3624 int me = extract_ME(operands[5]);
3625 int mb = extract_MB(operands[5]);
3626 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3627 operands[2] = GEN_INT(mb);
3628 operands[1] = GEN_INT(me);
3629 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3630 }"
3631 [(set_attr "type" "insert_word")])
3632
3633 (define_insn "insvdi"
3634 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3635 (match_operand:SI 1 "const_int_operand" "i")
3636 (match_operand:SI 2 "const_int_operand" "i"))
3637 (match_operand:DI 3 "gpc_reg_operand" "r"))]
3638 "TARGET_POWERPC64"
3639 "*
3640 {
3641 int start = INTVAL (operands[2]) & 63;
3642 int size = INTVAL (operands[1]) & 63;
3643
3644 operands[1] = GEN_INT (64 - start - size);
3645 return \"rldimi %0,%3,%H1,%H2\";
3646 }"
3647 [(set_attr "type" "insert_dword")])
3648
3649 (define_insn "*insvdi_internal2"
3650 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3651 (match_operand:SI 1 "const_int_operand" "i")
3652 (match_operand:SI 2 "const_int_operand" "i"))
3653 (ashiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3654 (match_operand:SI 4 "const_int_operand" "i")))]
3655 "TARGET_POWERPC64
3656 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3657 "*
3658 {
3659 int shift = INTVAL (operands[4]) & 63;
3660 int start = (INTVAL (operands[2]) & 63) - 32;
3661 int size = INTVAL (operands[1]) & 63;
3662
3663 operands[4] = GEN_INT (64 - shift - start - size);
3664 operands[2] = GEN_INT (start);
3665 operands[1] = GEN_INT (start + size - 1);
3666 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3667 }")
3668
3669 (define_insn "*insvdi_internal3"
3670 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3671 (match_operand:SI 1 "const_int_operand" "i")
3672 (match_operand:SI 2 "const_int_operand" "i"))
3673 (lshiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3674 (match_operand:SI 4 "const_int_operand" "i")))]
3675 "TARGET_POWERPC64
3676 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3677 "*
3678 {
3679 int shift = INTVAL (operands[4]) & 63;
3680 int start = (INTVAL (operands[2]) & 63) - 32;
3681 int size = INTVAL (operands[1]) & 63;
3682
3683 operands[4] = GEN_INT (64 - shift - start - size);
3684 operands[2] = GEN_INT (start);
3685 operands[1] = GEN_INT (start + size - 1);
3686 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3687 }")
3688
3689 (define_expand "extzv"
3690 [(set (match_operand 0 "gpc_reg_operand" "")
3691 (zero_extract (match_operand 1 "gpc_reg_operand" "")
3692 (match_operand:SI 2 "const_int_operand" "")
3693 (match_operand:SI 3 "const_int_operand" "")))]
3694 ""
3695 "
3696 {
3697 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3698 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3699 compiler if the address of the structure is taken later. */
3700 if (GET_CODE (operands[0]) == SUBREG
3701 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3702 FAIL;
3703
3704 if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3705 emit_insn (gen_extzvdi (operands[0], operands[1], operands[2], operands[3]));
3706 else
3707 emit_insn (gen_extzvsi (operands[0], operands[1], operands[2], operands[3]));
3708 DONE;
3709 }")
3710
3711 (define_insn "extzvsi"
3712 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3713 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3714 (match_operand:SI 2 "const_int_operand" "i")
3715 (match_operand:SI 3 "const_int_operand" "i")))]
3716 ""
3717 "*
3718 {
3719 int start = INTVAL (operands[3]) & 31;
3720 int size = INTVAL (operands[2]) & 31;
3721
3722 if (start + size >= 32)
3723 operands[3] = const0_rtx;
3724 else
3725 operands[3] = GEN_INT (start + size);
3726 return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
3727 }")
3728
3729 (define_insn "*extzvsi_internal1"
3730 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3731 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3732 (match_operand:SI 2 "const_int_operand" "i,i")
3733 (match_operand:SI 3 "const_int_operand" "i,i"))
3734 (const_int 0)))
3735 (clobber (match_scratch:SI 4 "=r,r"))]
3736 ""
3737 "*
3738 {
3739 int start = INTVAL (operands[3]) & 31;
3740 int size = INTVAL (operands[2]) & 31;
3741
3742 /* Force split for non-cc0 compare. */
3743 if (which_alternative == 1)
3744 return \"#\";
3745
3746 /* If the bit-field being tested fits in the upper or lower half of a
3747 word, it is possible to use andiu. or andil. to test it. This is
3748 useful because the condition register set-use delay is smaller for
3749 andi[ul]. than for rlinm. This doesn't work when the starting bit
3750 position is 0 because the LT and GT bits may be set wrong. */
3751
3752 if ((start > 0 && start + size <= 16) || start >= 16)
3753 {
3754 operands[3] = GEN_INT (((1 << (16 - (start & 15)))
3755 - (1 << (16 - (start & 15) - size))));
3756 if (start < 16)
3757 return \"{andiu.|andis.} %4,%1,%3\";
3758 else
3759 return \"{andil.|andi.} %4,%1,%3\";
3760 }
3761
3762 if (start + size >= 32)
3763 operands[3] = const0_rtx;
3764 else
3765 operands[3] = GEN_INT (start + size);
3766 return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
3767 }"
3768 [(set_attr "type" "delayed_compare")
3769 (set_attr "length" "4,8")])
3770
3771 (define_split
3772 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3773 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3774 (match_operand:SI 2 "const_int_operand" "")
3775 (match_operand:SI 3 "const_int_operand" ""))
3776 (const_int 0)))
3777 (clobber (match_scratch:SI 4 ""))]
3778 "reload_completed"
3779 [(set (match_dup 4)
3780 (zero_extract:SI (match_dup 1) (match_dup 2)
3781 (match_dup 3)))
3782 (set (match_dup 0)
3783 (compare:CC (match_dup 4)
3784 (const_int 0)))]
3785 "")
3786
3787 (define_insn "*extzvsi_internal2"
3788 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3789 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3790 (match_operand:SI 2 "const_int_operand" "i,i")
3791 (match_operand:SI 3 "const_int_operand" "i,i"))
3792 (const_int 0)))
3793 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3794 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3795 ""
3796 "*
3797 {
3798 int start = INTVAL (operands[3]) & 31;
3799 int size = INTVAL (operands[2]) & 31;
3800
3801 /* Force split for non-cc0 compare. */
3802 if (which_alternative == 1)
3803 return \"#\";
3804
3805 /* Since we are using the output value, we can't ignore any need for
3806 a shift. The bit-field must end at the LSB. */
3807 if (start >= 16 && start + size == 32)
3808 {
3809 operands[3] = GEN_INT ((1 << size) - 1);
3810 return \"{andil.|andi.} %0,%1,%3\";
3811 }
3812
3813 if (start + size >= 32)
3814 operands[3] = const0_rtx;
3815 else
3816 operands[3] = GEN_INT (start + size);
3817 return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
3818 }"
3819 [(set_attr "type" "delayed_compare")
3820 (set_attr "length" "4,8")])
3821
3822 (define_split
3823 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3824 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3825 (match_operand:SI 2 "const_int_operand" "")
3826 (match_operand:SI 3 "const_int_operand" ""))
3827 (const_int 0)))
3828 (set (match_operand:SI 0 "gpc_reg_operand" "")
3829 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3830 "reload_completed"
3831 [(set (match_dup 0)
3832 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3833 (set (match_dup 4)
3834 (compare:CC (match_dup 0)
3835 (const_int 0)))]
3836 "")
3837
3838 (define_insn "extzvdi"
3839 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3840 (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3841 (match_operand:SI 2 "const_int_operand" "i")
3842 (match_operand:SI 3 "const_int_operand" "i")))]
3843 "TARGET_POWERPC64"
3844 "*
3845 {
3846 int start = INTVAL (operands[3]) & 63;
3847 int size = INTVAL (operands[2]) & 63;
3848
3849 if (start + size >= 64)
3850 operands[3] = const0_rtx;
3851 else
3852 operands[3] = GEN_INT (start + size);
3853 operands[2] = GEN_INT (64 - size);
3854 return \"rldicl %0,%1,%3,%2\";
3855 }")
3856
3857 (define_insn "*extzvdi_internal1"
3858 [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3859 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3860 (match_operand:SI 2 "const_int_operand" "i")
3861 (match_operand:SI 3 "const_int_operand" "i"))
3862 (const_int 0)))
3863 (clobber (match_scratch:DI 4 "=r"))]
3864 "TARGET_64BIT"
3865 "*
3866 {
3867 int start = INTVAL (operands[3]) & 63;
3868 int size = INTVAL (operands[2]) & 63;
3869
3870 if (start + size >= 64)
3871 operands[3] = const0_rtx;
3872 else
3873 operands[3] = GEN_INT (start + size);
3874 operands[2] = GEN_INT (64 - size);
3875 return \"rldicl. %4,%1,%3,%2\";
3876 }"
3877 [(set_attr "type" "compare")])
3878
3879 (define_insn "*extzvdi_internal2"
3880 [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3881 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3882 (match_operand:SI 2 "const_int_operand" "i")
3883 (match_operand:SI 3 "const_int_operand" "i"))
3884 (const_int 0)))
3885 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
3886 (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
3887 "TARGET_64BIT"
3888 "*
3889 {
3890 int start = INTVAL (operands[3]) & 63;
3891 int size = INTVAL (operands[2]) & 63;
3892
3893 if (start + size >= 64)
3894 operands[3] = const0_rtx;
3895 else
3896 operands[3] = GEN_INT (start + size);
3897 operands[2] = GEN_INT (64 - size);
3898 return \"rldicl. %0,%1,%3,%2\";
3899 }"
3900 [(set_attr "type" "compare")])
3901
3902 (define_insn "rotlsi3"
3903 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3904 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3905 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))]
3906 ""
3907 "@
3908 {rlnm|rlwnm} %0,%1,%2,0xffffffff
3909 {rlinm|rlwinm} %0,%1,%h2,0xffffffff"
3910 [(set_attr "type" "var_shift_rotate,integer")])
3911
3912 (define_insn "*rotlsi3_internal2"
3913 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3914 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3915 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
3916 (const_int 0)))
3917 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
3918 ""
3919 "@
3920 {rlnm.|rlwnm.} %3,%1,%2,0xffffffff
3921 {rlinm.|rlwinm.} %3,%1,%h2,0xffffffff
3922 #
3923 #"
3924 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
3925 (set_attr "length" "4,4,8,8")])
3926
3927 (define_split
3928 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3929 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3930 (match_operand:SI 2 "reg_or_cint_operand" ""))
3931 (const_int 0)))
3932 (clobber (match_scratch:SI 3 ""))]
3933 "reload_completed"
3934 [(set (match_dup 3)
3935 (rotate:SI (match_dup 1) (match_dup 2)))
3936 (set (match_dup 0)
3937 (compare:CC (match_dup 3)
3938 (const_int 0)))]
3939 "")
3940
3941 (define_insn "*rotlsi3_internal3"
3942 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3943 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3944 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
3945 (const_int 0)))
3946 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
3947 (rotate:SI (match_dup 1) (match_dup 2)))]
3948 ""
3949 "@
3950 {rlnm.|rlwnm.} %0,%1,%2,0xffffffff
3951 {rlinm.|rlwinm.} %0,%1,%h2,0xffffffff
3952 #
3953 #"
3954 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
3955 (set_attr "length" "4,4,8,8")])
3956
3957 (define_split
3958 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3959 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3960 (match_operand:SI 2 "reg_or_cint_operand" ""))
3961 (const_int 0)))
3962 (set (match_operand:SI 0 "gpc_reg_operand" "")
3963 (rotate:SI (match_dup 1) (match_dup 2)))]
3964 "reload_completed"
3965 [(set (match_dup 0)
3966 (rotate:SI (match_dup 1) (match_dup 2)))
3967 (set (match_dup 3)
3968 (compare:CC (match_dup 0)
3969 (const_int 0)))]
3970 "")
3971
3972 (define_insn "*rotlsi3_internal4"
3973 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3974 (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3975 (match_operand:SI 2 "reg_or_cint_operand" "r,i"))
3976 (match_operand:SI 3 "mask_operand" "n,n")))]
3977 ""
3978 "@
3979 {rlnm|rlwnm} %0,%1,%2,%m3,%M3
3980 {rlinm|rlwinm} %0,%1,%h2,%m3,%M3"
3981 [(set_attr "type" "var_shift_rotate,integer")])
3982
3983 (define_insn "*rotlsi3_internal5"
3984 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3985 (compare:CC (and:SI
3986 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3987 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
3988 (match_operand:SI 3 "mask_operand" "n,n,n,n"))
3989 (const_int 0)))
3990 (clobber (match_scratch:SI 4 "=r,r,r,r"))]
3991 ""
3992 "@
3993 {rlnm.|rlwnm.} %4,%1,%2,%m3,%M3
3994 {rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3
3995 #
3996 #"
3997 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
3998 (set_attr "length" "4,4,8,8")])
3999
4000 (define_split
4001 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4002 (compare:CC (and:SI
4003 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4004 (match_operand:SI 2 "reg_or_cint_operand" ""))
4005 (match_operand:SI 3 "mask_operand" ""))
4006 (const_int 0)))
4007 (clobber (match_scratch:SI 4 ""))]
4008 "reload_completed"
4009 [(set (match_dup 4)
4010 (and:SI (rotate:SI (match_dup 1)
4011 (match_dup 2))
4012 (match_dup 3)))
4013 (set (match_dup 0)
4014 (compare:CC (match_dup 4)
4015 (const_int 0)))]
4016 "")
4017
4018 (define_insn "*rotlsi3_internal6"
4019 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
4020 (compare:CC (and:SI
4021 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4022 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4023 (match_operand:SI 3 "mask_operand" "n,n,n,n"))
4024 (const_int 0)))
4025 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4026 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4027 ""
4028 "@
4029 {rlnm.|rlwnm.} %0,%1,%2,%m3,%M3
4030 {rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3
4031 #
4032 #"
4033 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4034 (set_attr "length" "4,4,8,8")])
4035
4036 (define_split
4037 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4038 (compare:CC (and:SI
4039 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4040 (match_operand:SI 2 "reg_or_cint_operand" ""))
4041 (match_operand:SI 3 "mask_operand" ""))
4042 (const_int 0)))
4043 (set (match_operand:SI 0 "gpc_reg_operand" "")
4044 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4045 "reload_completed"
4046 [(set (match_dup 0)
4047 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4048 (set (match_dup 4)
4049 (compare:CC (match_dup 0)
4050 (const_int 0)))]
4051 "")
4052
4053 (define_insn "*rotlsi3_internal7"
4054 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4055 (zero_extend:SI
4056 (subreg:QI
4057 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4058 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
4059 ""
4060 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
4061
4062 (define_insn "*rotlsi3_internal8"
4063 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4064 (compare:CC (zero_extend:SI
4065 (subreg:QI
4066 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4067 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
4068 (const_int 0)))
4069 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
4070 ""
4071 "@
4072 {rlnm.|rlwnm.} %3,%1,%2,0xff
4073 {rlinm.|rlwinm.} %3,%1,%h2,0xff
4074 #
4075 #"
4076 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4077 (set_attr "length" "4,4,8,8")])
4078
4079 (define_split
4080 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4081 (compare:CC (zero_extend:SI
4082 (subreg:QI
4083 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4084 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4085 (const_int 0)))
4086 (clobber (match_scratch:SI 3 ""))]
4087 "reload_completed"
4088 [(set (match_dup 3)
4089 (zero_extend:SI (subreg:QI
4090 (rotate:SI (match_dup 1)
4091 (match_dup 2)) 0)))
4092 (set (match_dup 0)
4093 (compare:CC (match_dup 3)
4094 (const_int 0)))]
4095 "")
4096
4097 (define_insn "*rotlsi3_internal9"
4098 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4099 (compare:CC (zero_extend:SI
4100 (subreg:QI
4101 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4102 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
4103 (const_int 0)))
4104 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4105 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4106 ""
4107 "@
4108 {rlnm.|rlwnm.} %0,%1,%2,0xff
4109 {rlinm.|rlwinm.} %0,%1,%h2,0xff
4110 #
4111 #"
4112 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4113 (set_attr "length" "4,4,8,8")])
4114
4115 (define_split
4116 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4117 (compare:CC (zero_extend:SI
4118 (subreg:QI
4119 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4120 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4121 (const_int 0)))
4122 (set (match_operand:SI 0 "gpc_reg_operand" "")
4123 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4124 "reload_completed"
4125 [(set (match_dup 0)
4126 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
4127 (set (match_dup 3)
4128 (compare:CC (match_dup 0)
4129 (const_int 0)))]
4130 "")
4131
4132 (define_insn "*rotlsi3_internal10"
4133 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4134 (zero_extend:SI
4135 (subreg:HI
4136 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4137 (match_operand:SI 2 "reg_or_cint_operand" "r,i")) 0)))]
4138 ""
4139 "@
4140 {rlnm|rlwnm} %0,%1,%2,0xffff
4141 {rlinm|rlwinm} %0,%1,%h2,0xffff"
4142 [(set_attr "type" "var_shift_rotate,integer")])
4143
4144
4145 (define_insn "*rotlsi3_internal11"
4146 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4147 (compare:CC (zero_extend:SI
4148 (subreg:HI
4149 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4150 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
4151 (const_int 0)))
4152 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
4153 ""
4154 "@
4155 {rlnm.|rlwnm.} %3,%1,%2,0xffff
4156 {rlinm.|rlwinm.} %3,%1,%h2,0xffff
4157 #
4158 #"
4159 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4160 (set_attr "length" "4,4,8,8")])
4161
4162 (define_split
4163 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4164 (compare:CC (zero_extend:SI
4165 (subreg:HI
4166 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4167 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4168 (const_int 0)))
4169 (clobber (match_scratch:SI 3 ""))]
4170 "reload_completed"
4171 [(set (match_dup 3)
4172 (zero_extend:SI (subreg:HI
4173 (rotate:SI (match_dup 1)
4174 (match_dup 2)) 0)))
4175 (set (match_dup 0)
4176 (compare:CC (match_dup 3)
4177 (const_int 0)))]
4178 "")
4179
4180 (define_insn "*rotlsi3_internal12"
4181 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4182 (compare:CC (zero_extend:SI
4183 (subreg:HI
4184 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4185 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
4186 (const_int 0)))
4187 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4188 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4189 ""
4190 "@
4191 {rlnm.|rlwnm.} %0,%1,%2,0xffff
4192 {rlinm.|rlwinm.} %0,%1,%h2,0xffff
4193 #
4194 #"
4195 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4196 (set_attr "length" "4,4,8,8")])
4197
4198 (define_split
4199 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4200 (compare:CC (zero_extend:SI
4201 (subreg:HI
4202 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4203 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4204 (const_int 0)))
4205 (set (match_operand:SI 0 "gpc_reg_operand" "")
4206 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4207 "reload_completed"
4208 [(set (match_dup 0)
4209 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
4210 (set (match_dup 3)
4211 (compare:CC (match_dup 0)
4212 (const_int 0)))]
4213 "")
4214
4215 ;; Note that we use "sle." instead of "sl." so that we can set
4216 ;; SHIFT_COUNT_TRUNCATED.
4217
4218 (define_expand "ashlsi3"
4219 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
4220 (use (match_operand:SI 1 "gpc_reg_operand" ""))
4221 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
4222 ""
4223 "
4224 {
4225 if (TARGET_POWER)
4226 emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
4227 else
4228 emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
4229 DONE;
4230 }")
4231
4232 (define_insn "ashlsi3_power"
4233 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4234 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4235 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4236 (clobber (match_scratch:SI 3 "=q,X"))]
4237 "TARGET_POWER"
4238 "@
4239 sle %0,%1,%2
4240 {sli|slwi} %0,%1,%h2")
4241
4242 (define_insn "ashlsi3_no_power"
4243 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4244 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4245 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))]
4246 "! TARGET_POWER"
4247 "@
4248 {sl|slw} %0,%1,%2
4249 {sli|slwi} %0,%1,%h2"
4250 [(set_attr "type" "var_shift_rotate,shift")])
4251
4252 (define_insn ""
4253 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4254 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4255 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4256 (const_int 0)))
4257 (clobber (match_scratch:SI 3 "=r,r,r,r"))
4258 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4259 "TARGET_POWER"
4260 "@
4261 sle. %3,%1,%2
4262 {sli.|slwi.} %3,%1,%h2
4263 #
4264 #"
4265 [(set_attr "type" "delayed_compare")
4266 (set_attr "length" "4,4,8,8")])
4267
4268 (define_split
4269 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4270 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4271 (match_operand:SI 2 "reg_or_cint_operand" ""))
4272 (const_int 0)))
4273 (clobber (match_scratch:SI 3 ""))
4274 (clobber (match_scratch:SI 4 ""))]
4275 "TARGET_POWER && reload_completed"
4276 [(parallel [(set (match_dup 3)
4277 (ashift:SI (match_dup 1) (match_dup 2)))
4278 (clobber (match_dup 4))])
4279 (set (match_dup 0)
4280 (compare:CC (match_dup 3)
4281 (const_int 0)))]
4282 "")
4283
4284 (define_insn ""
4285 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4286 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4287 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4288 (const_int 0)))
4289 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
4290 "! TARGET_POWER && TARGET_32BIT"
4291 "@
4292 {sl.|slw.} %3,%1,%2
4293 {sli.|slwi.} %3,%1,%h2
4294 #
4295 #"
4296 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4297 (set_attr "length" "4,4,8,8")])
4298
4299 (define_split
4300 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4301 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4302 (match_operand:SI 2 "reg_or_cint_operand" ""))
4303 (const_int 0)))
4304 (clobber (match_scratch:SI 3 ""))]
4305 "! TARGET_POWER && TARGET_32BIT && reload_completed"
4306 [(set (match_dup 3)
4307 (ashift:SI (match_dup 1) (match_dup 2)))
4308 (set (match_dup 0)
4309 (compare:CC (match_dup 3)
4310 (const_int 0)))]
4311 "")
4312
4313 (define_insn ""
4314 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4315 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4316 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4317 (const_int 0)))
4318 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4319 (ashift:SI (match_dup 1) (match_dup 2)))
4320 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4321 "TARGET_POWER"
4322 "@
4323 sle. %0,%1,%2
4324 {sli.|slwi.} %0,%1,%h2
4325 #
4326 #"
4327 [(set_attr "type" "delayed_compare")
4328 (set_attr "length" "4,4,8,8")])
4329
4330 (define_split
4331 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4332 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4333 (match_operand:SI 2 "reg_or_cint_operand" ""))
4334 (const_int 0)))
4335 (set (match_operand:SI 0 "gpc_reg_operand" "")
4336 (ashift:SI (match_dup 1) (match_dup 2)))
4337 (clobber (match_scratch:SI 4 ""))]
4338 "TARGET_POWER && reload_completed"
4339 [(parallel [(set (match_dup 0)
4340 (ashift:SI (match_dup 1) (match_dup 2)))
4341 (clobber (match_dup 4))])
4342 (set (match_dup 3)
4343 (compare:CC (match_dup 0)
4344 (const_int 0)))]
4345 "")
4346
4347 (define_insn ""
4348 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4349 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4350 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4351 (const_int 0)))
4352 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4353 (ashift:SI (match_dup 1) (match_dup 2)))]
4354 "! TARGET_POWER && TARGET_32BIT"
4355 "@
4356 {sl.|slw.} %0,%1,%2
4357 {sli.|slwi.} %0,%1,%h2
4358 #
4359 #"
4360 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4361 (set_attr "length" "4,4,8,8")])
4362
4363 (define_split
4364 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4365 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4366 (match_operand:SI 2 "reg_or_cint_operand" ""))
4367 (const_int 0)))
4368 (set (match_operand:SI 0 "gpc_reg_operand" "")
4369 (ashift:SI (match_dup 1) (match_dup 2)))]
4370 "! TARGET_POWER && TARGET_32BIT && reload_completed"
4371 [(set (match_dup 0)
4372 (ashift:SI (match_dup 1) (match_dup 2)))
4373 (set (match_dup 3)
4374 (compare:CC (match_dup 0)
4375 (const_int 0)))]
4376 "")
4377
4378 (define_insn "rlwinm"
4379 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4380 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4381 (match_operand:SI 2 "const_int_operand" "i"))
4382 (match_operand:SI 3 "mask_operand" "n")))]
4383 "includes_lshift_p (operands[2], operands[3])"
4384 "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
4385
4386 (define_insn ""
4387 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4388 (compare:CC
4389 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4390 (match_operand:SI 2 "const_int_operand" "i,i"))
4391 (match_operand:SI 3 "mask_operand" "n,n"))
4392 (const_int 0)))
4393 (clobber (match_scratch:SI 4 "=r,r"))]
4394 "includes_lshift_p (operands[2], operands[3])"
4395 "@
4396 {rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3
4397 #"
4398 [(set_attr "type" "delayed_compare")
4399 (set_attr "length" "4,8")])
4400
4401 (define_split
4402 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4403 (compare:CC
4404 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4405 (match_operand:SI 2 "const_int_operand" ""))
4406 (match_operand:SI 3 "mask_operand" ""))
4407 (const_int 0)))
4408 (clobber (match_scratch:SI 4 ""))]
4409 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
4410 [(set (match_dup 4)
4411 (and:SI (ashift:SI (match_dup 1) (match_dup 2))
4412 (match_dup 3)))
4413 (set (match_dup 0)
4414 (compare:CC (match_dup 4)
4415 (const_int 0)))]
4416 "")
4417
4418 (define_insn ""
4419 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4420 (compare:CC
4421 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4422 (match_operand:SI 2 "const_int_operand" "i,i"))
4423 (match_operand:SI 3 "mask_operand" "n,n"))
4424 (const_int 0)))
4425 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4426 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4427 "includes_lshift_p (operands[2], operands[3])"
4428 "@
4429 {rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3
4430 #"
4431 [(set_attr "type" "delayed_compare")
4432 (set_attr "length" "4,8")])
4433
4434 (define_split
4435 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4436 (compare:CC
4437 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4438 (match_operand:SI 2 "const_int_operand" ""))
4439 (match_operand:SI 3 "mask_operand" ""))
4440 (const_int 0)))
4441 (set (match_operand:SI 0 "gpc_reg_operand" "")
4442 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4443 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
4444 [(set (match_dup 0)
4445 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4446 (set (match_dup 4)
4447 (compare:CC (match_dup 0)
4448 (const_int 0)))]
4449 "")
4450
4451 ;; The AIX assembler mis-handles "sri x,x,0", so write that case as
4452 ;; "sli x,x,0".
4453 (define_expand "lshrsi3"
4454 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
4455 (use (match_operand:SI 1 "gpc_reg_operand" ""))
4456 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
4457 ""
4458 "
4459 {
4460 if (TARGET_POWER)
4461 emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
4462 else
4463 emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
4464 DONE;
4465 }")
4466
4467 (define_insn "lshrsi3_power"
4468 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
4469 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
4470 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i")))
4471 (clobber (match_scratch:SI 3 "=q,X,X"))]
4472 "TARGET_POWER"
4473 "@
4474 sre %0,%1,%2
4475 mr %0,%1
4476 {s%A2i|s%A2wi} %0,%1,%h2")
4477
4478 (define_insn "lshrsi3_no_power"
4479 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
4480 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
4481 (match_operand:SI 2 "reg_or_cint_operand" "O,r,i")))]
4482 "! TARGET_POWER"
4483 "@
4484 mr %0,%1
4485 {sr|srw} %0,%1,%2
4486 {sri|srwi} %0,%1,%h2"
4487 [(set_attr "type" "integer,var_shift_rotate,shift")])
4488
4489 (define_insn ""
4490 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4491 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4492 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
4493 (const_int 0)))
4494 (clobber (match_scratch:SI 3 "=r,X,r,r,X,r"))
4495 (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
4496 "TARGET_POWER"
4497 "@
4498 sre. %3,%1,%2
4499 mr. %1,%1
4500 {s%A2i.|s%A2wi.} %3,%1,%h2
4501 #
4502 #
4503 #"
4504 [(set_attr "type" "delayed_compare")
4505 (set_attr "length" "4,4,4,8,8,8")])
4506
4507 (define_split
4508 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4509 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4510 (match_operand:SI 2 "reg_or_cint_operand" ""))
4511 (const_int 0)))
4512 (clobber (match_scratch:SI 3 ""))
4513 (clobber (match_scratch:SI 4 ""))]
4514 "TARGET_POWER && reload_completed"
4515 [(parallel [(set (match_dup 3)
4516 (lshiftrt:SI (match_dup 1) (match_dup 2)))
4517 (clobber (match_dup 4))])
4518 (set (match_dup 0)
4519 (compare:CC (match_dup 3)
4520 (const_int 0)))]
4521 "")
4522
4523 (define_insn ""
4524 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4525 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4526 (match_operand:SI 2 "reg_or_cint_operand" "O,r,i,O,r,i"))
4527 (const_int 0)))
4528 (clobber (match_scratch:SI 3 "=X,r,r,X,r,r"))]
4529 "! TARGET_POWER && TARGET_32BIT"
4530 "@
4531 mr. %1,%1
4532 {sr.|srw.} %3,%1,%2
4533 {sri.|srwi.} %3,%1,%h2
4534 #
4535 #
4536 #"
4537 [(set_attr "type" "delayed_compare,var_delayed_compare,delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4538 (set_attr "length" "4,4,4,8,8,8")])
4539
4540 (define_split
4541 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4542 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4543 (match_operand:SI 2 "reg_or_cint_operand" ""))
4544 (const_int 0)))
4545 (clobber (match_scratch:SI 3 ""))]
4546 "! TARGET_POWER && TARGET_32BIT && reload_completed"
4547 [(set (match_dup 3)
4548 (lshiftrt:SI (match_dup 1) (match_dup 2)))
4549 (set (match_dup 0)
4550 (compare:CC (match_dup 3)
4551 (const_int 0)))]
4552 "")
4553
4554 (define_insn ""
4555 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4556 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4557 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
4558 (const_int 0)))
4559 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
4560 (lshiftrt:SI (match_dup 1) (match_dup 2)))
4561 (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
4562 "TARGET_POWER"
4563 "@
4564 sre. %0,%1,%2
4565 mr. %0,%1
4566 {s%A2i.|s%A2wi.} %0,%1,%h2
4567 #
4568 #
4569 #"
4570 [(set_attr "type" "delayed_compare")
4571 (set_attr "length" "4,4,4,8,8,8")])
4572
4573 (define_split
4574 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4575 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4576 (match_operand:SI 2 "reg_or_cint_operand" ""))
4577 (const_int 0)))
4578 (set (match_operand:SI 0 "gpc_reg_operand" "")
4579 (lshiftrt:SI (match_dup 1) (match_dup 2)))
4580 (clobber (match_scratch:SI 4 ""))]
4581 "TARGET_POWER && reload_completed"
4582 [(parallel [(set (match_dup 0)
4583 (lshiftrt:SI (match_dup 1) (match_dup 2)))
4584 (clobber (match_dup 4))])
4585 (set (match_dup 3)
4586 (compare:CC (match_dup 0)
4587 (const_int 0)))]
4588 "")
4589
4590 (define_insn ""
4591 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4592 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4593 (match_operand:SI 2 "reg_or_cint_operand" "O,r,i,O,r,i"))
4594 (const_int 0)))
4595 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
4596 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
4597 "! TARGET_POWER && TARGET_32BIT"
4598 "@
4599 mr. %0,%1
4600 {sr.|srw.} %0,%1,%2
4601 {sri.|srwi.} %0,%1,%h2
4602 #
4603 #
4604 #"
4605 [(set_attr "type" "delayed_compare,var_delayed_compare,delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4606 (set_attr "length" "4,4,4,8,8,8")])
4607
4608 (define_split
4609 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4610 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4611 (match_operand:SI 2 "reg_or_cint_operand" ""))
4612 (const_int 0)))
4613 (set (match_operand:SI 0 "gpc_reg_operand" "")
4614 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
4615 "! TARGET_POWER && TARGET_32BIT && reload_completed"
4616 [(set (match_dup 0)
4617 (lshiftrt:SI (match_dup 1) (match_dup 2)))
4618 (set (match_dup 3)
4619 (compare:CC (match_dup 0)
4620 (const_int 0)))]
4621 "")
4622
4623 (define_insn ""
4624 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4625 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4626 (match_operand:SI 2 "const_int_operand" "i"))
4627 (match_operand:SI 3 "mask_operand" "n")))]
4628 "includes_rshift_p (operands[2], operands[3])"
4629 "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
4630
4631 (define_insn ""
4632 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4633 (compare:CC
4634 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4635 (match_operand:SI 2 "const_int_operand" "i,i"))
4636 (match_operand:SI 3 "mask_operand" "n,n"))
4637 (const_int 0)))
4638 (clobber (match_scratch:SI 4 "=r,r"))]
4639 "includes_rshift_p (operands[2], operands[3])"
4640 "@
4641 {rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3
4642 #"
4643 [(set_attr "type" "delayed_compare")
4644 (set_attr "length" "4,8")])
4645
4646 (define_split
4647 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4648 (compare:CC
4649 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4650 (match_operand:SI 2 "const_int_operand" ""))
4651 (match_operand:SI 3 "mask_operand" ""))
4652 (const_int 0)))
4653 (clobber (match_scratch:SI 4 ""))]
4654 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4655 [(set (match_dup 4)
4656 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
4657 (match_dup 3)))
4658 (set (match_dup 0)
4659 (compare:CC (match_dup 4)
4660 (const_int 0)))]
4661 "")
4662
4663 (define_insn ""
4664 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4665 (compare:CC
4666 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4667 (match_operand:SI 2 "const_int_operand" "i,i"))
4668 (match_operand:SI 3 "mask_operand" "n,n"))
4669 (const_int 0)))
4670 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4671 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4672 "includes_rshift_p (operands[2], operands[3])"
4673 "@
4674 {rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3
4675 #"
4676 [(set_attr "type" "delayed_compare")
4677 (set_attr "length" "4,8")])
4678
4679 (define_split
4680 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4681 (compare:CC
4682 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4683 (match_operand:SI 2 "const_int_operand" ""))
4684 (match_operand:SI 3 "mask_operand" ""))
4685 (const_int 0)))
4686 (set (match_operand:SI 0 "gpc_reg_operand" "")
4687 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4688 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4689 [(set (match_dup 0)
4690 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4691 (set (match_dup 4)
4692 (compare:CC (match_dup 0)
4693 (const_int 0)))]
4694 "")
4695
4696 (define_insn ""
4697 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4698 (zero_extend:SI
4699 (subreg:QI
4700 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4701 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4702 "includes_rshift_p (operands[2], GEN_INT (255))"
4703 "{rlinm|rlwinm} %0,%1,%s2,0xff")
4704
4705 (define_insn ""
4706 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4707 (compare:CC
4708 (zero_extend:SI
4709 (subreg:QI
4710 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4711 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4712 (const_int 0)))
4713 (clobber (match_scratch:SI 3 "=r,r"))]
4714 "includes_rshift_p (operands[2], GEN_INT (255))"
4715 "@
4716 {rlinm.|rlwinm.} %3,%1,%s2,0xff
4717 #"
4718 [(set_attr "type" "delayed_compare")
4719 (set_attr "length" "4,8")])
4720
4721 (define_split
4722 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4723 (compare:CC
4724 (zero_extend:SI
4725 (subreg:QI
4726 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4727 (match_operand:SI 2 "const_int_operand" "")) 0))
4728 (const_int 0)))
4729 (clobber (match_scratch:SI 3 ""))]
4730 "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4731 [(set (match_dup 3)
4732 (zero_extend:SI (subreg:QI
4733 (lshiftrt:SI (match_dup 1)
4734 (match_dup 2)) 0)))
4735 (set (match_dup 0)
4736 (compare:CC (match_dup 3)
4737 (const_int 0)))]
4738 "")
4739
4740 (define_insn ""
4741 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4742 (compare:CC
4743 (zero_extend:SI
4744 (subreg:QI
4745 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4746 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4747 (const_int 0)))
4748 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4749 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4750 "includes_rshift_p (operands[2], GEN_INT (255))"
4751 "@
4752 {rlinm.|rlwinm.} %0,%1,%s2,0xff
4753 #"
4754 [(set_attr "type" "delayed_compare")
4755 (set_attr "length" "4,8")])
4756
4757 (define_split
4758 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4759 (compare:CC
4760 (zero_extend:SI
4761 (subreg:QI
4762 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4763 (match_operand:SI 2 "const_int_operand" "")) 0))
4764 (const_int 0)))
4765 (set (match_operand:SI 0 "gpc_reg_operand" "")
4766 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4767 "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4768 [(set (match_dup 0)
4769 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4770 (set (match_dup 3)
4771 (compare:CC (match_dup 0)
4772 (const_int 0)))]
4773 "")
4774
4775 (define_insn ""
4776 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4777 (zero_extend:SI
4778 (subreg:HI
4779 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4780 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4781 "includes_rshift_p (operands[2], GEN_INT (65535))"
4782 "{rlinm|rlwinm} %0,%1,%s2,0xffff")
4783
4784 (define_insn ""
4785 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4786 (compare:CC
4787 (zero_extend:SI
4788 (subreg:HI
4789 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4790 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4791 (const_int 0)))
4792 (clobber (match_scratch:SI 3 "=r,r"))]
4793 "includes_rshift_p (operands[2], GEN_INT (65535))"
4794 "@
4795 {rlinm.|rlwinm.} %3,%1,%s2,0xffff
4796 #"
4797 [(set_attr "type" "delayed_compare")
4798 (set_attr "length" "4,8")])
4799
4800 (define_split
4801 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4802 (compare:CC
4803 (zero_extend:SI
4804 (subreg:HI
4805 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4806 (match_operand:SI 2 "const_int_operand" "")) 0))
4807 (const_int 0)))
4808 (clobber (match_scratch:SI 3 ""))]
4809 "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4810 [(set (match_dup 3)
4811 (zero_extend:SI (subreg:HI
4812 (lshiftrt:SI (match_dup 1)
4813 (match_dup 2)) 0)))
4814 (set (match_dup 0)
4815 (compare:CC (match_dup 3)
4816 (const_int 0)))]
4817 "")
4818
4819 (define_insn ""
4820 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4821 (compare:CC
4822 (zero_extend:SI
4823 (subreg:HI
4824 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4825 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4826 (const_int 0)))
4827 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4828 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4829 "includes_rshift_p (operands[2], GEN_INT (65535))"
4830 "@
4831 {rlinm.|rlwinm.} %0,%1,%s2,0xffff
4832 #"
4833 [(set_attr "type" "delayed_compare")
4834 (set_attr "length" "4,8")])
4835
4836 (define_split
4837 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4838 (compare:CC
4839 (zero_extend:SI
4840 (subreg:HI
4841 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4842 (match_operand:SI 2 "const_int_operand" "")) 0))
4843 (const_int 0)))
4844 (set (match_operand:SI 0 "gpc_reg_operand" "")
4845 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4846 "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4847 [(set (match_dup 0)
4848 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4849 (set (match_dup 3)
4850 (compare:CC (match_dup 0)
4851 (const_int 0)))]
4852 "")
4853
4854 (define_insn ""
4855 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4856 (const_int 1)
4857 (match_operand:SI 1 "gpc_reg_operand" "r"))
4858 (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4859 (const_int 31)))]
4860 "TARGET_POWER"
4861 "rrib %0,%1,%2")
4862
4863 (define_insn ""
4864 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4865 (const_int 1)
4866 (match_operand:SI 1 "gpc_reg_operand" "r"))
4867 (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4868 (const_int 31)))]
4869 "TARGET_POWER"
4870 "rrib %0,%1,%2")
4871
4872 (define_insn ""
4873 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4874 (const_int 1)
4875 (match_operand:SI 1 "gpc_reg_operand" "r"))
4876 (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4877 (const_int 1)
4878 (const_int 0)))]
4879 "TARGET_POWER"
4880 "rrib %0,%1,%2")
4881
4882 (define_expand "ashrsi3"
4883 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4884 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4885 (match_operand:SI 2 "reg_or_cint_operand" "")))]
4886 ""
4887 "
4888 {
4889 if (TARGET_POWER)
4890 emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
4891 else
4892 emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
4893 DONE;
4894 }")
4895
4896 (define_insn "ashrsi3_power"
4897 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4898 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4899 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4900 (clobber (match_scratch:SI 3 "=q,X"))]
4901 "TARGET_POWER"
4902 "@
4903 srea %0,%1,%2
4904 {srai|srawi} %0,%1,%h2"
4905 [(set_attr "type" "shift")])
4906
4907 (define_insn "ashrsi3_no_power"
4908 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4909 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4910 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))]
4911 "! TARGET_POWER"
4912 "@
4913 {sra|sraw} %0,%1,%2
4914 {srai|srawi} %0,%1,%h2"
4915 [(set_attr "type" "var_shift_rotate,shift")])
4916
4917 (define_insn ""
4918 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4919 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4920 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4921 (const_int 0)))
4922 (clobber (match_scratch:SI 3 "=r,r,r,r"))
4923 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4924 "TARGET_POWER"
4925 "@
4926 srea. %3,%1,%2
4927 {srai.|srawi.} %3,%1,%h2
4928 #
4929 #"
4930 [(set_attr "type" "delayed_compare")
4931 (set_attr "length" "4,4,8,8")])
4932
4933 (define_split
4934 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4935 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4936 (match_operand:SI 2 "reg_or_cint_operand" ""))
4937 (const_int 0)))
4938 (clobber (match_scratch:SI 3 ""))
4939 (clobber (match_scratch:SI 4 ""))]
4940 "TARGET_POWER && reload_completed"
4941 [(parallel [(set (match_dup 3)
4942 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4943 (clobber (match_dup 4))])
4944 (set (match_dup 0)
4945 (compare:CC (match_dup 3)
4946 (const_int 0)))]
4947 "")
4948
4949 (define_insn ""
4950 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4951 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4952 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4953 (const_int 0)))
4954 (clobber (match_scratch:SI 3 "=r,r,r,r"))]
4955 "! TARGET_POWER"
4956 "@
4957 {sra.|sraw.} %3,%1,%2
4958 {srai.|srawi.} %3,%1,%h2
4959 #
4960 #"
4961 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
4962 (set_attr "length" "4,4,8,8")])
4963
4964 (define_split
4965 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4966 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4967 (match_operand:SI 2 "reg_or_cint_operand" ""))
4968 (const_int 0)))
4969 (clobber (match_scratch:SI 3 ""))]
4970 "! TARGET_POWER && reload_completed"
4971 [(set (match_dup 3)
4972 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4973 (set (match_dup 0)
4974 (compare:CC (match_dup 3)
4975 (const_int 0)))]
4976 "")
4977
4978 (define_insn ""
4979 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4980 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4981 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4982 (const_int 0)))
4983 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4984 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4985 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4986 "TARGET_POWER"
4987 "@
4988 srea. %0,%1,%2
4989 {srai.|srawi.} %0,%1,%h2
4990 #
4991 #"
4992 [(set_attr "type" "delayed_compare")
4993 (set_attr "length" "4,4,8,8")])
4994
4995 (define_split
4996 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4997 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4998 (match_operand:SI 2 "reg_or_cint_operand" ""))
4999 (const_int 0)))
5000 (set (match_operand:SI 0 "gpc_reg_operand" "")
5001 (ashiftrt:SI (match_dup 1) (match_dup 2)))
5002 (clobber (match_scratch:SI 4 ""))]
5003 "TARGET_POWER && reload_completed"
5004 [(parallel [(set (match_dup 0)
5005 (ashiftrt:SI (match_dup 1) (match_dup 2)))
5006 (clobber (match_dup 4))])
5007 (set (match_dup 3)
5008 (compare:CC (match_dup 0)
5009 (const_int 0)))]
5010 "")
5011
5012 (define_insn ""
5013 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
5014 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
5015 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
5016 (const_int 0)))
5017 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
5018 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
5019 "! TARGET_POWER"
5020 "@
5021 {sra.|sraw.} %0,%1,%2
5022 {srai.|srawi.} %0,%1,%h2
5023 #
5024 #"
5025 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
5026 (set_attr "length" "4,4,8,8")])
5027 \f
5028 (define_split
5029 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5030 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
5031 (match_operand:SI 2 "reg_or_cint_operand" ""))
5032 (const_int 0)))
5033 (set (match_operand:SI 0 "gpc_reg_operand" "")
5034 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
5035 "! TARGET_POWER && reload_completed"
5036 [(set (match_dup 0)
5037 (ashiftrt:SI (match_dup 1) (match_dup 2)))
5038 (set (match_dup 3)
5039 (compare:CC (match_dup 0)
5040 (const_int 0)))]
5041 "")
5042
5043 ;; Floating-point insns, excluding normal data motion.
5044 ;;
5045 ;; PowerPC has a full set of single-precision floating point instructions.
5046 ;;
5047 ;; For the POWER architecture, we pretend that we have both SFmode and
5048 ;; DFmode insns, while, in fact, all fp insns are actually done in double.
5049 ;; The only conversions we will do will be when storing to memory. In that
5050 ;; case, we will use the "frsp" instruction before storing.
5051 ;;
5052 ;; Note that when we store into a single-precision memory location, we need to
5053 ;; use the frsp insn first. If the register being stored isn't dead, we
5054 ;; need a scratch register for the frsp. But this is difficult when the store
5055 ;; is done by reload. It is not incorrect to do the frsp on the register in
5056 ;; this case, we just lose precision that we would have otherwise gotten but
5057 ;; is not guaranteed. Perhaps this should be tightened up at some point.
5058
5059 (define_expand "extendsfdf2"
5060 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5061 (float_extend:DF (match_operand:SF 1 "reg_or_none500mem_operand" "")))]
5062 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5063 "")
5064
5065 (define_insn_and_split "*extendsfdf2_fpr"
5066 [(set (match_operand:DF 0 "gpc_reg_operand" "=f,?f,f")
5067 (float_extend:DF (match_operand:SF 1 "reg_or_mem_operand" "0,f,m")))]
5068 "TARGET_HARD_FLOAT && TARGET_FPRS"
5069 "@
5070 #
5071 fmr %0,%1
5072 lfs%U1%X1 %0,%1"
5073 "&& reload_completed && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])"
5074 [(const_int 0)]
5075 {
5076 emit_note (NOTE_INSN_DELETED);
5077 DONE;
5078 }
5079 [(set_attr "type" "fp,fp,fpload")])
5080
5081 (define_expand "truncdfsf2"
5082 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5083 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "")))]
5084 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5085 "")
5086
5087 (define_insn "*truncdfsf2_fpr"
5088 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5089 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5090 "TARGET_HARD_FLOAT && TARGET_FPRS"
5091 "frsp %0,%1"
5092 [(set_attr "type" "fp")])
5093
5094 (define_insn "aux_truncdfsf2"
5095 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5096 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRSP))]
5097 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5098 "frsp %0,%1"
5099 [(set_attr "type" "fp")])
5100
5101 (define_expand "negsf2"
5102 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5103 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
5104 "TARGET_HARD_FLOAT"
5105 "")
5106
5107 (define_insn "*negsf2"
5108 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5109 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5110 "TARGET_HARD_FLOAT && TARGET_FPRS"
5111 "fneg %0,%1"
5112 [(set_attr "type" "fp")])
5113
5114 (define_expand "abssf2"
5115 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5116 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
5117 "TARGET_HARD_FLOAT"
5118 "")
5119
5120 (define_insn "*abssf2"
5121 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5122 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5123 "TARGET_HARD_FLOAT && TARGET_FPRS"
5124 "fabs %0,%1"
5125 [(set_attr "type" "fp")])
5126
5127 (define_insn ""
5128 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5129 (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
5130 "TARGET_HARD_FLOAT && TARGET_FPRS"
5131 "fnabs %0,%1"
5132 [(set_attr "type" "fp")])
5133
5134 (define_expand "addsf3"
5135 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5136 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
5137 (match_operand:SF 2 "gpc_reg_operand" "")))]
5138 "TARGET_HARD_FLOAT"
5139 "")
5140
5141 (define_insn ""
5142 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5143 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5144 (match_operand:SF 2 "gpc_reg_operand" "f")))]
5145 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5146 "fadds %0,%1,%2"
5147 [(set_attr "type" "fp")])
5148
5149 (define_insn ""
5150 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5151 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5152 (match_operand:SF 2 "gpc_reg_operand" "f")))]
5153 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5154 "{fa|fadd} %0,%1,%2"
5155 [(set_attr "type" "fp")])
5156
5157 (define_expand "subsf3"
5158 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5159 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
5160 (match_operand:SF 2 "gpc_reg_operand" "")))]
5161 "TARGET_HARD_FLOAT"
5162 "")
5163
5164 (define_insn ""
5165 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5166 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5167 (match_operand:SF 2 "gpc_reg_operand" "f")))]
5168 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5169 "fsubs %0,%1,%2"
5170 [(set_attr "type" "fp")])
5171
5172 (define_insn ""
5173 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5174 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5175 (match_operand:SF 2 "gpc_reg_operand" "f")))]
5176 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5177 "{fs|fsub} %0,%1,%2"
5178 [(set_attr "type" "fp")])
5179
5180 (define_expand "mulsf3"
5181 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5182 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
5183 (match_operand:SF 2 "gpc_reg_operand" "")))]
5184 "TARGET_HARD_FLOAT"
5185 "")
5186
5187 (define_insn ""
5188 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5189 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5190 (match_operand:SF 2 "gpc_reg_operand" "f")))]
5191 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5192 "fmuls %0,%1,%2"
5193 [(set_attr "type" "fp")])
5194
5195 (define_insn ""
5196 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5197 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5198 (match_operand:SF 2 "gpc_reg_operand" "f")))]
5199 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5200 "{fm|fmul} %0,%1,%2"
5201 [(set_attr "type" "dmul")])
5202
5203 (define_expand "divsf3"
5204 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5205 (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
5206 (match_operand:SF 2 "gpc_reg_operand" "")))]
5207 "TARGET_HARD_FLOAT"
5208 "")
5209
5210 (define_insn ""
5211 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5212 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5213 (match_operand:SF 2 "gpc_reg_operand" "f")))]
5214 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5215 "fdivs %0,%1,%2"
5216 [(set_attr "type" "sdiv")])
5217
5218 (define_insn ""
5219 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5220 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5221 (match_operand:SF 2 "gpc_reg_operand" "f")))]
5222 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5223 "{fd|fdiv} %0,%1,%2"
5224 [(set_attr "type" "ddiv")])
5225
5226 (define_expand "recipsf3"
5227 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5228 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")
5229 (match_operand:SF 2 "gpc_reg_operand" "f")]
5230 UNSPEC_FRES))]
5231 "TARGET_RECIP && TARGET_HARD_FLOAT && TARGET_PPC_GFXOPT && !optimize_size
5232 && flag_finite_math_only && !flag_trapping_math"
5233 {
5234 rs6000_emit_swdivsf (operands[0], operands[1], operands[2]);
5235 DONE;
5236 })
5237
5238 (define_insn "fres"
5239 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5240 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRES))]
5241 "TARGET_PPC_GFXOPT && flag_finite_math_only"
5242 "fres %0,%1"
5243 [(set_attr "type" "fp")])
5244
5245 (define_insn ""
5246 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5247 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5248 (match_operand:SF 2 "gpc_reg_operand" "f"))
5249 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5250 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5251 "fmadds %0,%1,%2,%3"
5252 [(set_attr "type" "fp")])
5253
5254 (define_insn ""
5255 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5256 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5257 (match_operand:SF 2 "gpc_reg_operand" "f"))
5258 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5259 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5260 "{fma|fmadd} %0,%1,%2,%3"
5261 [(set_attr "type" "dmul")])
5262
5263 (define_insn ""
5264 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5265 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5266 (match_operand:SF 2 "gpc_reg_operand" "f"))
5267 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5268 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5269 "fmsubs %0,%1,%2,%3"
5270 [(set_attr "type" "fp")])
5271
5272 (define_insn ""
5273 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5274 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5275 (match_operand:SF 2 "gpc_reg_operand" "f"))
5276 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5277 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5278 "{fms|fmsub} %0,%1,%2,%3"
5279 [(set_attr "type" "dmul")])
5280
5281 (define_insn ""
5282 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5283 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5284 (match_operand:SF 2 "gpc_reg_operand" "f"))
5285 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5286 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5287 && HONOR_SIGNED_ZEROS (SFmode)"
5288 "fnmadds %0,%1,%2,%3"
5289 [(set_attr "type" "fp")])
5290
5291 (define_insn ""
5292 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5293 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
5294 (match_operand:SF 2 "gpc_reg_operand" "f"))
5295 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5296 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5297 && ! HONOR_SIGNED_ZEROS (SFmode)"
5298 "fnmadds %0,%1,%2,%3"
5299 [(set_attr "type" "fp")])
5300
5301 (define_insn ""
5302 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5303 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5304 (match_operand:SF 2 "gpc_reg_operand" "f"))
5305 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5306 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5307 "{fnma|fnmadd} %0,%1,%2,%3"
5308 [(set_attr "type" "dmul")])
5309
5310 (define_insn ""
5311 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5312 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
5313 (match_operand:SF 2 "gpc_reg_operand" "f"))
5314 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5315 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5316 && ! HONOR_SIGNED_ZEROS (SFmode)"
5317 "{fnma|fnmadd} %0,%1,%2,%3"
5318 [(set_attr "type" "dmul")])
5319
5320 (define_insn ""
5321 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5322 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5323 (match_operand:SF 2 "gpc_reg_operand" "f"))
5324 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5325 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5326 && HONOR_SIGNED_ZEROS (SFmode)"
5327 "fnmsubs %0,%1,%2,%3"
5328 [(set_attr "type" "fp")])
5329
5330 (define_insn ""
5331 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5332 (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
5333 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5334 (match_operand:SF 2 "gpc_reg_operand" "f"))))]
5335 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5336 && ! HONOR_SIGNED_ZEROS (SFmode)"
5337 "fnmsubs %0,%1,%2,%3"
5338 [(set_attr "type" "fp")])
5339
5340 (define_insn ""
5341 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5342 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5343 (match_operand:SF 2 "gpc_reg_operand" "f"))
5344 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5345 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5346 "{fnms|fnmsub} %0,%1,%2,%3"
5347 [(set_attr "type" "dmul")])
5348
5349 (define_insn ""
5350 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5351 (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
5352 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5353 (match_operand:SF 2 "gpc_reg_operand" "f"))))]
5354 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5355 && ! HONOR_SIGNED_ZEROS (SFmode)"
5356 "{fnms|fnmsub} %0,%1,%2,%3"
5357 [(set_attr "type" "dmul")])
5358
5359 (define_expand "sqrtsf2"
5360 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5361 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
5362 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
5363 "")
5364
5365 (define_insn ""
5366 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5367 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5368 "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5369 "fsqrts %0,%1"
5370 [(set_attr "type" "ssqrt")])
5371
5372 (define_insn ""
5373 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5374 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5375 "TARGET_POWER2 && TARGET_HARD_FLOAT && TARGET_FPRS"
5376 "fsqrt %0,%1"
5377 [(set_attr "type" "dsqrt")])
5378
5379 (define_expand "rsqrtsf2"
5380 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5381 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")]
5382 UNSPEC_RSQRT))]
5383 "TARGET_RECIP && TARGET_HARD_FLOAT && TARGET_PPC_GFXOPT && !optimize_size
5384 && flag_finite_math_only && !flag_trapping_math"
5385 {
5386 rs6000_emit_swrsqrtsf (operands[0], operands[1]);
5387 DONE;
5388 })
5389
5390 (define_insn "*rsqrt_internal1"
5391 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5392 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")]
5393 UNSPEC_RSQRT))]
5394 "TARGET_HARD_FLOAT && TARGET_PPC_GFXOPT"
5395 "frsqrte %0,%1"
5396 [(set_attr "type" "fp")])
5397
5398 (define_expand "copysignsf3"
5399 [(set (match_dup 3)
5400 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))
5401 (set (match_dup 4)
5402 (neg:SF (abs:SF (match_dup 1))))
5403 (set (match_operand:SF 0 "gpc_reg_operand" "")
5404 (if_then_else:SF (ge (match_operand:SF 2 "gpc_reg_operand" "")
5405 (match_dup 5))
5406 (match_dup 3)
5407 (match_dup 4)))]
5408 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS
5409 && !HONOR_NANS (SFmode) && !HONOR_SIGNED_ZEROS (SFmode)"
5410 {
5411 operands[3] = gen_reg_rtx (SFmode);
5412 operands[4] = gen_reg_rtx (SFmode);
5413 operands[5] = CONST0_RTX (SFmode);
5414 })
5415
5416 (define_expand "copysigndf3"
5417 [(set (match_dup 3)
5418 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "")))
5419 (set (match_dup 4)
5420 (neg:DF (abs:DF (match_dup 1))))
5421 (set (match_operand:DF 0 "gpc_reg_operand" "")
5422 (if_then_else:DF (ge (match_operand:DF 2 "gpc_reg_operand" "")
5423 (match_dup 5))
5424 (match_dup 3)
5425 (match_dup 4)))]
5426 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS
5427 && !HONOR_NANS (DFmode) && !HONOR_SIGNED_ZEROS (DFmode)"
5428 {
5429 operands[3] = gen_reg_rtx (DFmode);
5430 operands[4] = gen_reg_rtx (DFmode);
5431 operands[5] = CONST0_RTX (DFmode);
5432 })
5433
5434 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
5435 ;; fsel instruction and some auxiliary computations. Then we just have a
5436 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
5437 ;; combine.
5438 (define_expand "smaxsf3"
5439 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5440 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
5441 (match_operand:SF 2 "gpc_reg_operand" ""))
5442 (match_dup 1)
5443 (match_dup 2)))]
5444 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
5445 "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
5446
5447 (define_expand "sminsf3"
5448 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5449 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
5450 (match_operand:SF 2 "gpc_reg_operand" ""))
5451 (match_dup 2)
5452 (match_dup 1)))]
5453 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
5454 "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
5455
5456 (define_split
5457 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5458 (match_operator:SF 3 "min_max_operator"
5459 [(match_operand:SF 1 "gpc_reg_operand" "")
5460 (match_operand:SF 2 "gpc_reg_operand" "")]))]
5461 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
5462 [(const_int 0)]
5463 "
5464 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
5465 operands[1], operands[2]);
5466 DONE;
5467 }")
5468
5469 (define_expand "movsicc"
5470 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5471 (if_then_else:SI (match_operand 1 "comparison_operator" "")
5472 (match_operand:SI 2 "gpc_reg_operand" "")
5473 (match_operand:SI 3 "gpc_reg_operand" "")))]
5474 "TARGET_ISEL"
5475 "
5476 {
5477 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5478 DONE;
5479 else
5480 FAIL;
5481 }")
5482
5483 ;; We use the BASE_REGS for the isel input operands because, if rA is
5484 ;; 0, the value of 0 is placed in rD upon truth. Similarly for rB
5485 ;; because we may switch the operands and rB may end up being rA.
5486 ;;
5487 ;; We need 2 patterns: an unsigned and a signed pattern. We could
5488 ;; leave out the mode in operand 4 and use one pattern, but reload can
5489 ;; change the mode underneath our feet and then gets confused trying
5490 ;; to reload the value.
5491 (define_insn "isel_signed"
5492 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5493 (if_then_else:SI
5494 (match_operator 1 "comparison_operator"
5495 [(match_operand:CC 4 "cc_reg_operand" "y")
5496 (const_int 0)])
5497 (match_operand:SI 2 "gpc_reg_operand" "b")
5498 (match_operand:SI 3 "gpc_reg_operand" "b")))]
5499 "TARGET_ISEL"
5500 "*
5501 { return output_isel (operands); }"
5502 [(set_attr "length" "4")])
5503
5504 (define_insn "isel_unsigned"
5505 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5506 (if_then_else:SI
5507 (match_operator 1 "comparison_operator"
5508 [(match_operand:CCUNS 4 "cc_reg_operand" "y")
5509 (const_int 0)])
5510 (match_operand:SI 2 "gpc_reg_operand" "b")
5511 (match_operand:SI 3 "gpc_reg_operand" "b")))]
5512 "TARGET_ISEL"
5513 "*
5514 { return output_isel (operands); }"
5515 [(set_attr "length" "4")])
5516
5517 (define_expand "movsfcc"
5518 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5519 (if_then_else:SF (match_operand 1 "comparison_operator" "")
5520 (match_operand:SF 2 "gpc_reg_operand" "")
5521 (match_operand:SF 3 "gpc_reg_operand" "")))]
5522 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5523 "
5524 {
5525 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5526 DONE;
5527 else
5528 FAIL;
5529 }")
5530
5531 (define_insn "*fselsfsf4"
5532 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5533 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5534 (match_operand:SF 4 "zero_fp_constant" "F"))
5535 (match_operand:SF 2 "gpc_reg_operand" "f")
5536 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5537 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5538 "fsel %0,%1,%2,%3"
5539 [(set_attr "type" "fp")])
5540
5541 (define_insn "*fseldfsf4"
5542 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5543 (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
5544 (match_operand:DF 4 "zero_fp_constant" "F"))
5545 (match_operand:SF 2 "gpc_reg_operand" "f")
5546 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5547 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5548 "fsel %0,%1,%2,%3"
5549 [(set_attr "type" "fp")])
5550
5551 (define_expand "negdf2"
5552 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5553 (neg:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
5554 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5555 "")
5556
5557 (define_insn "*negdf2_fpr"
5558 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5559 (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5560 "TARGET_HARD_FLOAT && TARGET_FPRS"
5561 "fneg %0,%1"
5562 [(set_attr "type" "fp")])
5563
5564 (define_expand "absdf2"
5565 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5566 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
5567 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5568 "")
5569
5570 (define_insn "*absdf2_fpr"
5571 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5572 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5573 "TARGET_HARD_FLOAT && TARGET_FPRS"
5574 "fabs %0,%1"
5575 [(set_attr "type" "fp")])
5576
5577 (define_insn "*nabsdf2_fpr"
5578 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5579 (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
5580 "TARGET_HARD_FLOAT && TARGET_FPRS"
5581 "fnabs %0,%1"
5582 [(set_attr "type" "fp")])
5583
5584 (define_expand "adddf3"
5585 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5586 (plus:DF (match_operand:DF 1 "gpc_reg_operand" "")
5587 (match_operand:DF 2 "gpc_reg_operand" "")))]
5588 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5589 "")
5590
5591 (define_insn "*adddf3_fpr"
5592 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5593 (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5594 (match_operand:DF 2 "gpc_reg_operand" "f")))]
5595 "TARGET_HARD_FLOAT && TARGET_FPRS"
5596 "{fa|fadd} %0,%1,%2"
5597 [(set_attr "type" "fp")])
5598
5599 (define_expand "subdf3"
5600 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5601 (minus:DF (match_operand:DF 1 "gpc_reg_operand" "")
5602 (match_operand:DF 2 "gpc_reg_operand" "")))]
5603 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5604 "")
5605
5606 (define_insn "*subdf3_fpr"
5607 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5608 (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
5609 (match_operand:DF 2 "gpc_reg_operand" "f")))]
5610 "TARGET_HARD_FLOAT && TARGET_FPRS"
5611 "{fs|fsub} %0,%1,%2"
5612 [(set_attr "type" "fp")])
5613
5614 (define_expand "muldf3"
5615 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5616 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "")
5617 (match_operand:DF 2 "gpc_reg_operand" "")))]
5618 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5619 "")
5620
5621 (define_insn "*muldf3_fpr"
5622 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5623 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5624 (match_operand:DF 2 "gpc_reg_operand" "f")))]
5625 "TARGET_HARD_FLOAT && TARGET_FPRS"
5626 "{fm|fmul} %0,%1,%2"
5627 [(set_attr "type" "dmul")])
5628
5629 (define_expand "divdf3"
5630 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5631 (div:DF (match_operand:DF 1 "gpc_reg_operand" "")
5632 (match_operand:DF 2 "gpc_reg_operand" "")))]
5633 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5634 "")
5635
5636 (define_insn "*divdf3_fpr"
5637 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5638 (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
5639 (match_operand:DF 2 "gpc_reg_operand" "f")))]
5640 "TARGET_HARD_FLOAT && TARGET_FPRS"
5641 "{fd|fdiv} %0,%1,%2"
5642 [(set_attr "type" "ddiv")])
5643
5644 (define_expand "recipdf3"
5645 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5646 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")
5647 (match_operand:DF 2 "gpc_reg_operand" "f")]
5648 UNSPEC_FRES))]
5649 "TARGET_RECIP && TARGET_HARD_FLOAT && TARGET_POPCNTB && !optimize_size
5650 && flag_finite_math_only && !flag_trapping_math"
5651 {
5652 rs6000_emit_swdivdf (operands[0], operands[1], operands[2]);
5653 DONE;
5654 })
5655
5656 (define_insn "fred"
5657 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5658 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")] UNSPEC_FRES))]
5659 "TARGET_POPCNTB && flag_finite_math_only"
5660 "fre %0,%1"
5661 [(set_attr "type" "fp")])
5662
5663 (define_insn ""
5664 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5665 (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5666 (match_operand:DF 2 "gpc_reg_operand" "f"))
5667 (match_operand:DF 3 "gpc_reg_operand" "f")))]
5668 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5669 "{fma|fmadd} %0,%1,%2,%3"
5670 [(set_attr "type" "dmul")])
5671
5672 (define_insn ""
5673 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5674 (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5675 (match_operand:DF 2 "gpc_reg_operand" "f"))
5676 (match_operand:DF 3 "gpc_reg_operand" "f")))]
5677 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5678 "{fms|fmsub} %0,%1,%2,%3"
5679 [(set_attr "type" "dmul")])
5680
5681 (define_insn ""
5682 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5683 (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5684 (match_operand:DF 2 "gpc_reg_operand" "f"))
5685 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
5686 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5687 && HONOR_SIGNED_ZEROS (DFmode)"
5688 "{fnma|fnmadd} %0,%1,%2,%3"
5689 [(set_attr "type" "dmul")])
5690
5691 (define_insn ""
5692 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5693 (minus:DF (mult:DF (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f"))
5694 (match_operand:DF 2 "gpc_reg_operand" "f"))
5695 (match_operand:DF 3 "gpc_reg_operand" "f")))]
5696 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5697 && ! HONOR_SIGNED_ZEROS (DFmode)"
5698 "{fnma|fnmadd} %0,%1,%2,%3"
5699 [(set_attr "type" "dmul")])
5700
5701 (define_insn ""
5702 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5703 (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5704 (match_operand:DF 2 "gpc_reg_operand" "f"))
5705 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
5706 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5707 && HONOR_SIGNED_ZEROS (DFmode)"
5708 "{fnms|fnmsub} %0,%1,%2,%3"
5709 [(set_attr "type" "dmul")])
5710
5711 (define_insn ""
5712 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5713 (minus:DF (match_operand:DF 3 "gpc_reg_operand" "f")
5714 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5715 (match_operand:DF 2 "gpc_reg_operand" "f"))))]
5716 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5717 && ! HONOR_SIGNED_ZEROS (DFmode)"
5718 "{fnms|fnmsub} %0,%1,%2,%3"
5719 [(set_attr "type" "dmul")])
5720
5721 (define_insn "sqrtdf2"
5722 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5723 (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5724 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
5725 "fsqrt %0,%1"
5726 [(set_attr "type" "dsqrt")])
5727
5728 ;; The conditional move instructions allow us to perform max and min
5729 ;; operations even when
5730
5731 (define_expand "smaxdf3"
5732 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5733 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5734 (match_operand:DF 2 "gpc_reg_operand" ""))
5735 (match_dup 1)
5736 (match_dup 2)))]
5737 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
5738 "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
5739
5740 (define_expand "smindf3"
5741 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5742 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5743 (match_operand:DF 2 "gpc_reg_operand" ""))
5744 (match_dup 2)
5745 (match_dup 1)))]
5746 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
5747 "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
5748
5749 (define_split
5750 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5751 (match_operator:DF 3 "min_max_operator"
5752 [(match_operand:DF 1 "gpc_reg_operand" "")
5753 (match_operand:DF 2 "gpc_reg_operand" "")]))]
5754 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
5755 [(const_int 0)]
5756 "
5757 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
5758 operands[1], operands[2]);
5759 DONE;
5760 }")
5761
5762 (define_expand "movdfcc"
5763 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5764 (if_then_else:DF (match_operand 1 "comparison_operator" "")
5765 (match_operand:DF 2 "gpc_reg_operand" "")
5766 (match_operand:DF 3 "gpc_reg_operand" "")))]
5767 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5768 "
5769 {
5770 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5771 DONE;
5772 else
5773 FAIL;
5774 }")
5775
5776 (define_insn "*fseldfdf4"
5777 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5778 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
5779 (match_operand:DF 4 "zero_fp_constant" "F"))
5780 (match_operand:DF 2 "gpc_reg_operand" "f")
5781 (match_operand:DF 3 "gpc_reg_operand" "f")))]
5782 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5783 "fsel %0,%1,%2,%3"
5784 [(set_attr "type" "fp")])
5785
5786 (define_insn "*fselsfdf4"
5787 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5788 (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5789 (match_operand:SF 4 "zero_fp_constant" "F"))
5790 (match_operand:DF 2 "gpc_reg_operand" "f")
5791 (match_operand:DF 3 "gpc_reg_operand" "f")))]
5792 "TARGET_PPC_GFXOPT"
5793 "fsel %0,%1,%2,%3"
5794 [(set_attr "type" "fp")])
5795 \f
5796 ;; Conversions to and from floating-point.
5797
5798 (define_expand "fixuns_truncsfsi2"
5799 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5800 (unsigned_fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
5801 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5802 "")
5803
5804 (define_expand "fix_truncsfsi2"
5805 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5806 (fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
5807 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5808 "")
5809
5810 ; For each of these conversions, there is a define_expand, a define_insn
5811 ; with a '#' template, and a define_split (with C code). The idea is
5812 ; to allow constant folding with the template of the define_insn,
5813 ; then to have the insns split later (between sched1 and final).
5814
5815 (define_expand "floatsidf2"
5816 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5817 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5818 (use (match_dup 2))
5819 (use (match_dup 3))
5820 (clobber (match_dup 4))
5821 (clobber (match_dup 5))
5822 (clobber (match_dup 6))])]
5823 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5824 "
5825 {
5826 if (TARGET_E500_DOUBLE)
5827 {
5828 emit_insn (gen_spe_floatsidf2 (operands[0], operands[1]));
5829 DONE;
5830 }
5831 if (TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS)
5832 {
5833 rtx t1 = gen_reg_rtx (DImode);
5834 emit_insn (gen_floatsidf_ppc64_mfpgpr (operands[0], operands[1], t1));
5835 DONE;
5836 }
5837 if (TARGET_POWERPC64)
5838 {
5839 rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5840 rtx t1 = gen_reg_rtx (DImode);
5841 rtx t2 = gen_reg_rtx (DImode);
5842 emit_insn (gen_floatsidf_ppc64 (operands[0], operands[1], mem, t1, t2));
5843 DONE;
5844 }
5845
5846 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5847 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503601774854144\", DFmode));
5848 operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5849 operands[5] = gen_reg_rtx (DFmode);
5850 operands[6] = gen_reg_rtx (SImode);
5851 }")
5852
5853 (define_insn_and_split "*floatsidf2_internal"
5854 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5855 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5856 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5857 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5858 (clobber (match_operand:DF 4 "offsettable_mem_operand" "=o"))
5859 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))
5860 (clobber (match_operand:SI 6 "gpc_reg_operand" "=&r"))]
5861 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5862 "#"
5863 "&& (can_create_pseudo_p () || offsettable_nonstrict_memref_p (operands[4]))"
5864 [(pc)]
5865 "
5866 {
5867 rtx lowword, highword;
5868 gcc_assert (MEM_P (operands[4]));
5869 highword = adjust_address (operands[4], SImode, 0);
5870 lowword = adjust_address (operands[4], SImode, 4);
5871 if (! WORDS_BIG_ENDIAN)
5872 {
5873 rtx tmp;
5874 tmp = highword; highword = lowword; lowword = tmp;
5875 }
5876
5877 emit_insn (gen_xorsi3 (operands[6], operands[1],
5878 GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
5879 emit_move_insn (lowword, operands[6]);
5880 emit_move_insn (highword, operands[2]);
5881 emit_move_insn (operands[5], operands[4]);
5882 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5883 DONE;
5884 }"
5885 [(set_attr "length" "24")])
5886
5887 (define_expand "floatunssisf2"
5888 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5889 (unsigned_float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5890 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5891 "")
5892
5893 (define_expand "floatunssidf2"
5894 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5895 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5896 (use (match_dup 2))
5897 (use (match_dup 3))
5898 (clobber (match_dup 4))
5899 (clobber (match_dup 5))])]
5900 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5901 "
5902 {
5903 if (TARGET_E500_DOUBLE)
5904 {
5905 emit_insn (gen_spe_floatunssidf2 (operands[0], operands[1]));
5906 DONE;
5907 }
5908 if (TARGET_POWERPC64)
5909 {
5910 rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5911 rtx t1 = gen_reg_rtx (DImode);
5912 rtx t2 = gen_reg_rtx (DImode);
5913 emit_insn (gen_floatunssidf_ppc64 (operands[0], operands[1], mem,
5914 t1, t2));
5915 DONE;
5916 }
5917
5918 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5919 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503599627370496\", DFmode));
5920 operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5921 operands[5] = gen_reg_rtx (DFmode);
5922 }")
5923
5924 (define_insn_and_split "*floatunssidf2_internal"
5925 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5926 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5927 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5928 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5929 (clobber (match_operand:DF 4 "offsettable_mem_operand" "=o"))
5930 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))]
5931 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5932 "#"
5933 "&& (can_create_pseudo_p () || offsettable_nonstrict_memref_p (operands[4]))"
5934 [(pc)]
5935 "
5936 {
5937 rtx lowword, highword;
5938 gcc_assert (MEM_P (operands[4]));
5939 highword = adjust_address (operands[4], SImode, 0);
5940 lowword = adjust_address (operands[4], SImode, 4);
5941 if (! WORDS_BIG_ENDIAN)
5942 {
5943 rtx tmp;
5944 tmp = highword; highword = lowword; lowword = tmp;
5945 }
5946
5947 emit_move_insn (lowword, operands[1]);
5948 emit_move_insn (highword, operands[2]);
5949 emit_move_insn (operands[5], operands[4]);
5950 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5951 DONE;
5952 }"
5953 [(set_attr "length" "20")])
5954
5955 (define_expand "fix_truncdfsi2"
5956 [(parallel [(set (match_operand:SI 0 "fix_trunc_dest_operand" "")
5957 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5958 (clobber (match_dup 2))
5959 (clobber (match_dup 3))])]
5960 "(TARGET_POWER2 || TARGET_POWERPC)
5961 && TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5962 "
5963 {
5964 if (TARGET_E500_DOUBLE)
5965 {
5966 emit_insn (gen_spe_fix_truncdfsi2 (operands[0], operands[1]));
5967 DONE;
5968 }
5969 operands[2] = gen_reg_rtx (DImode);
5970 if (TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS
5971 && gpc_reg_operand(operands[0], GET_MODE (operands[0])))
5972 {
5973 operands[3] = gen_reg_rtx (DImode);
5974 emit_insn (gen_fix_truncdfsi2_mfpgpr (operands[0], operands[1],
5975 operands[2], operands[3]));
5976 DONE;
5977 }
5978 if (TARGET_PPC_GFXOPT)
5979 {
5980 rtx orig_dest = operands[0];
5981 if (! memory_operand (orig_dest, GET_MODE (orig_dest)))
5982 operands[0] = assign_stack_temp (SImode, GET_MODE_SIZE (SImode), 0);
5983 emit_insn (gen_fix_truncdfsi2_internal_gfxopt (operands[0], operands[1],
5984 operands[2]));
5985 if (operands[0] != orig_dest)
5986 emit_move_insn (orig_dest, operands[0]);
5987 DONE;
5988 }
5989 operands[3] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5990 }")
5991
5992 (define_insn_and_split "*fix_truncdfsi2_internal"
5993 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5994 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
5995 (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
5996 (clobber (match_operand:DI 3 "offsettable_mem_operand" "=o"))]
5997 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5998 "#"
5999 "&& (can_create_pseudo_p () || offsettable_nonstrict_memref_p (operands[3]))"
6000 [(pc)]
6001 "
6002 {
6003 rtx lowword;
6004 gcc_assert (MEM_P (operands[3]));
6005 lowword = adjust_address (operands[3], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
6006
6007 emit_insn (gen_fctiwz (operands[2], operands[1]));
6008 emit_move_insn (operands[3], operands[2]);
6009 emit_move_insn (operands[0], lowword);
6010 DONE;
6011 }"
6012 [(set_attr "length" "16")])
6013
6014 (define_insn_and_split "fix_truncdfsi2_internal_gfxopt"
6015 [(set (match_operand:SI 0 "memory_operand" "=Z")
6016 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
6017 (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))]
6018 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS
6019 && TARGET_PPC_GFXOPT"
6020 "#"
6021 "&& 1"
6022 [(pc)]
6023 "
6024 {
6025 emit_insn (gen_fctiwz (operands[2], operands[1]));
6026 emit_insn (gen_stfiwx (operands[0], operands[2]));
6027 DONE;
6028 }"
6029 [(set_attr "length" "16")])
6030
6031 (define_insn_and_split "fix_truncdfsi2_mfpgpr"
6032 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6033 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
6034 (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
6035 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))]
6036 "TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS"
6037 "#"
6038 "&& 1"
6039 [(set (match_dup 2) (unspec:DI [(fix:SI (match_dup 1))] UNSPEC_FCTIWZ))
6040 (set (match_dup 3) (match_dup 2))
6041 (set (match_dup 0) (subreg:SI (match_dup 3) 4))]
6042 ""
6043 [(set_attr "length" "12")])
6044
6045 ; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] UNSPEC_FCTIWZ))
6046 ; rather than (set (subreg:SI (reg)) (fix:SI ...))
6047 ; because the first makes it clear that operand 0 is not live
6048 ; before the instruction.
6049 (define_insn "fctiwz"
6050 [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
6051 (unspec:DI [(fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))]
6052 UNSPEC_FCTIWZ))]
6053 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
6054 "{fcirz|fctiwz} %0,%1"
6055 [(set_attr "type" "fp")])
6056
6057 (define_insn "btruncdf2"
6058 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6059 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")] UNSPEC_FRIZ))]
6060 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
6061 "friz %0,%1"
6062 [(set_attr "type" "fp")])
6063
6064 (define_insn "btruncsf2"
6065 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6066 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRIZ))]
6067 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
6068 "friz %0,%1"
6069 [(set_attr "type" "fp")])
6070
6071 (define_insn "ceildf2"
6072 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6073 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")] UNSPEC_FRIP))]
6074 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
6075 "frip %0,%1"
6076 [(set_attr "type" "fp")])
6077
6078 (define_insn "ceilsf2"
6079 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6080 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRIP))]
6081 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
6082 "frip %0,%1"
6083 [(set_attr "type" "fp")])
6084
6085 (define_insn "floordf2"
6086 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6087 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")] UNSPEC_FRIM))]
6088 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
6089 "frim %0,%1"
6090 [(set_attr "type" "fp")])
6091
6092 (define_insn "floorsf2"
6093 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6094 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRIM))]
6095 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
6096 "frim %0,%1"
6097 [(set_attr "type" "fp")])
6098
6099 (define_insn "rounddf2"
6100 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6101 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")] UNSPEC_FRIN))]
6102 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
6103 "frin %0,%1"
6104 [(set_attr "type" "fp")])
6105
6106 (define_insn "roundsf2"
6107 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6108 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRIN))]
6109 "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS"
6110 "frin %0,%1"
6111 [(set_attr "type" "fp")])
6112
6113 ; An UNSPEC is used so we don't have to support SImode in FP registers.
6114 (define_insn "stfiwx"
6115 [(set (match_operand:SI 0 "memory_operand" "=Z")
6116 (unspec:SI [(match_operand:DI 1 "gpc_reg_operand" "f")]
6117 UNSPEC_STFIWX))]
6118 "TARGET_PPC_GFXOPT"
6119 "stfiwx %1,%y0"
6120 [(set_attr "type" "fpstore")])
6121
6122 (define_expand "floatsisf2"
6123 [(set (match_operand:SF 0 "gpc_reg_operand" "")
6124 (float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
6125 "TARGET_HARD_FLOAT && !TARGET_FPRS"
6126 "")
6127
6128 (define_insn "floatdidf2"
6129 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6130 (float:DF (match_operand:DI 1 "gpc_reg_operand" "!f#r")))]
6131 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
6132 "fcfid %0,%1"
6133 [(set_attr "type" "fp")])
6134
6135 (define_insn_and_split "floatsidf_ppc64_mfpgpr"
6136 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6137 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
6138 (clobber (match_operand:DI 2 "gpc_reg_operand" "=r"))]
6139 "TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS"
6140 "#"
6141 "&& 1"
6142 [(set (match_dup 2) (sign_extend:DI (match_dup 1)))
6143 (set (match_dup 0) (float:DF (match_dup 2)))]
6144 "")
6145
6146 (define_insn_and_split "floatsidf_ppc64"
6147 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6148 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
6149 (clobber (match_operand:DI 2 "offsettable_mem_operand" "=o"))
6150 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
6151 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
6152 "TARGET_POWERPC64 && !TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS"
6153 "#"
6154 "&& 1"
6155 [(set (match_dup 3) (sign_extend:DI (match_dup 1)))
6156 (set (match_dup 2) (match_dup 3))
6157 (set (match_dup 4) (match_dup 2))
6158 (set (match_dup 0) (float:DF (match_dup 4)))]
6159 "")
6160
6161 (define_insn_and_split "floatunssidf_ppc64"
6162 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
6163 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
6164 (clobber (match_operand:DI 2 "offsettable_mem_operand" "=o"))
6165 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
6166 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
6167 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
6168 "#"
6169 "&& 1"
6170 [(set (match_dup 3) (zero_extend:DI (match_dup 1)))
6171 (set (match_dup 2) (match_dup 3))
6172 (set (match_dup 4) (match_dup 2))
6173 (set (match_dup 0) (float:DF (match_dup 4)))]
6174 "")
6175
6176 (define_insn "fix_truncdfdi2"
6177 [(set (match_operand:DI 0 "gpc_reg_operand" "=!f#r")
6178 (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
6179 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
6180 "fctidz %0,%1"
6181 [(set_attr "type" "fp")])
6182
6183 (define_expand "floatdisf2"
6184 [(set (match_operand:SF 0 "gpc_reg_operand" "")
6185 (float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
6186 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
6187 "
6188 {
6189 rtx val = operands[1];
6190 if (!flag_unsafe_math_optimizations)
6191 {
6192 rtx label = gen_label_rtx ();
6193 val = gen_reg_rtx (DImode);
6194 emit_insn (gen_floatdisf2_internal2 (val, operands[1], label));
6195 emit_label (label);
6196 }
6197 emit_insn (gen_floatdisf2_internal1 (operands[0], val));
6198 DONE;
6199 }")
6200
6201 ;; This is not IEEE compliant if rounding mode is "round to nearest".
6202 ;; If the DI->DF conversion is inexact, then it's possible to suffer
6203 ;; from double rounding.
6204 (define_insn_and_split "floatdisf2_internal1"
6205 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6206 (float:SF (match_operand:DI 1 "gpc_reg_operand" "!f#r")))
6207 (clobber (match_scratch:DF 2 "=f"))]
6208 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
6209 "#"
6210 "&& reload_completed"
6211 [(set (match_dup 2)
6212 (float:DF (match_dup 1)))
6213 (set (match_dup 0)
6214 (float_truncate:SF (match_dup 2)))]
6215 "")
6216
6217 ;; Twiddles bits to avoid double rounding.
6218 ;; Bits that might be truncated when converting to DFmode are replaced
6219 ;; by a bit that won't be lost at that stage, but is below the SFmode
6220 ;; rounding position.
6221 (define_expand "floatdisf2_internal2"
6222 [(set (match_dup 3) (ashiftrt:DI (match_operand:DI 1 "" "")
6223 (const_int 53)))
6224 (parallel [(set (match_operand:DI 0 "" "") (and:DI (match_dup 1)
6225 (const_int 2047)))
6226 (clobber (scratch:CC))])
6227 (set (match_dup 3) (plus:DI (match_dup 3)
6228 (const_int 1)))
6229 (set (match_dup 0) (plus:DI (match_dup 0)
6230 (const_int 2047)))
6231 (set (match_dup 4) (compare:CCUNS (match_dup 3)
6232 (const_int 2)))
6233 (set (match_dup 0) (ior:DI (match_dup 0)
6234 (match_dup 1)))
6235 (parallel [(set (match_dup 0) (and:DI (match_dup 0)
6236 (const_int -2048)))
6237 (clobber (scratch:CC))])
6238 (set (pc) (if_then_else (geu (match_dup 4) (const_int 0))
6239 (label_ref (match_operand:DI 2 "" ""))
6240 (pc)))
6241 (set (match_dup 0) (match_dup 1))]
6242 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
6243 "
6244 {
6245 operands[3] = gen_reg_rtx (DImode);
6246 operands[4] = gen_reg_rtx (CCUNSmode);
6247 }")
6248 \f
6249 ;; Define the DImode operations that can be done in a small number
6250 ;; of instructions. The & constraints are to prevent the register
6251 ;; allocator from allocating registers that overlap with the inputs
6252 ;; (for example, having an input in 7,8 and an output in 6,7). We
6253 ;; also allow for the output being the same as one of the inputs.
6254
6255 (define_insn "*adddi3_noppc64"
6256 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
6257 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
6258 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
6259 "! TARGET_POWERPC64"
6260 "*
6261 {
6262 if (WORDS_BIG_ENDIAN)
6263 return (GET_CODE (operands[2])) != CONST_INT
6264 ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
6265 : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
6266 else
6267 return (GET_CODE (operands[2])) != CONST_INT
6268 ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
6269 : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
6270 }"
6271 [(set_attr "type" "two")
6272 (set_attr "length" "8")])
6273
6274 (define_insn "*subdi3_noppc64"
6275 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
6276 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
6277 (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
6278 "! TARGET_POWERPC64"
6279 "*
6280 {
6281 if (WORDS_BIG_ENDIAN)
6282 return (GET_CODE (operands[1]) != CONST_INT)
6283 ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
6284 : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
6285 else
6286 return (GET_CODE (operands[1]) != CONST_INT)
6287 ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
6288 : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
6289 }"
6290 [(set_attr "type" "two")
6291 (set_attr "length" "8")])
6292
6293 (define_insn "*negdi2_noppc64"
6294 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6295 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
6296 "! TARGET_POWERPC64"
6297 "*
6298 {
6299 return (WORDS_BIG_ENDIAN)
6300 ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
6301 : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
6302 }"
6303 [(set_attr "type" "two")
6304 (set_attr "length" "8")])
6305
6306 (define_expand "mulsidi3"
6307 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6308 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
6309 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
6310 "! TARGET_POWERPC64"
6311 "
6312 {
6313 if (! TARGET_POWER && ! TARGET_POWERPC)
6314 {
6315 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
6316 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
6317 emit_insn (gen_mull_call ());
6318 if (WORDS_BIG_ENDIAN)
6319 emit_move_insn (operands[0], gen_rtx_REG (DImode, 3));
6320 else
6321 {
6322 emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
6323 gen_rtx_REG (SImode, 3));
6324 emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
6325 gen_rtx_REG (SImode, 4));
6326 }
6327 DONE;
6328 }
6329 else if (TARGET_POWER)
6330 {
6331 emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
6332 DONE;
6333 }
6334 }")
6335
6336 (define_insn "mulsidi3_mq"
6337 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6338 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
6339 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
6340 (clobber (match_scratch:SI 3 "=q"))]
6341 "TARGET_POWER"
6342 "mul %0,%1,%2\;mfmq %L0"
6343 [(set_attr "type" "imul")
6344 (set_attr "length" "8")])
6345
6346 (define_insn "*mulsidi3_no_mq"
6347 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
6348 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
6349 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
6350 "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
6351 "*
6352 {
6353 return (WORDS_BIG_ENDIAN)
6354 ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
6355 : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
6356 }"
6357 [(set_attr "type" "imul")
6358 (set_attr "length" "8")])
6359
6360 (define_split
6361 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6362 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
6363 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
6364 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
6365 [(set (match_dup 3)
6366 (truncate:SI
6367 (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
6368 (sign_extend:DI (match_dup 2)))
6369 (const_int 32))))
6370 (set (match_dup 4)
6371 (mult:SI (match_dup 1)
6372 (match_dup 2)))]
6373 "
6374 {
6375 int endian = (WORDS_BIG_ENDIAN == 0);
6376 operands[3] = operand_subword (operands[0], endian, 0, DImode);
6377 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
6378 }")
6379
6380 (define_expand "umulsidi3"
6381 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6382 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
6383 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
6384 "TARGET_POWERPC && ! TARGET_POWERPC64"
6385 "
6386 {
6387 if (TARGET_POWER)
6388 {
6389 emit_insn (gen_umulsidi3_mq (operands[0], operands[1], operands[2]));
6390 DONE;
6391 }
6392 }")
6393
6394 (define_insn "umulsidi3_mq"
6395 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
6396 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
6397 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
6398 (clobber (match_scratch:SI 3 "=q"))]
6399 "TARGET_POWERPC && TARGET_POWER"
6400 "*
6401 {
6402 return (WORDS_BIG_ENDIAN)
6403 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
6404 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
6405 }"
6406 [(set_attr "type" "imul")
6407 (set_attr "length" "8")])
6408
6409 (define_insn "*umulsidi3_no_mq"
6410 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
6411 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
6412 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
6413 "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
6414 "*
6415 {
6416 return (WORDS_BIG_ENDIAN)
6417 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
6418 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
6419 }"
6420 [(set_attr "type" "imul")
6421 (set_attr "length" "8")])
6422
6423 (define_split
6424 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6425 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
6426 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
6427 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
6428 [(set (match_dup 3)
6429 (truncate:SI
6430 (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
6431 (zero_extend:DI (match_dup 2)))
6432 (const_int 32))))
6433 (set (match_dup 4)
6434 (mult:SI (match_dup 1)
6435 (match_dup 2)))]
6436 "
6437 {
6438 int endian = (WORDS_BIG_ENDIAN == 0);
6439 operands[3] = operand_subword (operands[0], endian, 0, DImode);
6440 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
6441 }")
6442
6443 (define_expand "smulsi3_highpart"
6444 [(set (match_operand:SI 0 "gpc_reg_operand" "")
6445 (truncate:SI
6446 (lshiftrt:DI (mult:DI (sign_extend:DI
6447 (match_operand:SI 1 "gpc_reg_operand" ""))
6448 (sign_extend:DI
6449 (match_operand:SI 2 "gpc_reg_operand" "")))
6450 (const_int 32))))]
6451 ""
6452 "
6453 {
6454 if (! TARGET_POWER && ! TARGET_POWERPC)
6455 {
6456 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
6457 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
6458 emit_insn (gen_mulh_call ());
6459 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
6460 DONE;
6461 }
6462 else if (TARGET_POWER)
6463 {
6464 emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
6465 DONE;
6466 }
6467 }")
6468
6469 (define_insn "smulsi3_highpart_mq"
6470 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6471 (truncate:SI
6472 (lshiftrt:DI (mult:DI (sign_extend:DI
6473 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6474 (sign_extend:DI
6475 (match_operand:SI 2 "gpc_reg_operand" "r")))
6476 (const_int 32))))
6477 (clobber (match_scratch:SI 3 "=q"))]
6478 "TARGET_POWER"
6479 "mul %0,%1,%2"
6480 [(set_attr "type" "imul")])
6481
6482 (define_insn "*smulsi3_highpart_no_mq"
6483 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6484 (truncate:SI
6485 (lshiftrt:DI (mult:DI (sign_extend:DI
6486 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6487 (sign_extend:DI
6488 (match_operand:SI 2 "gpc_reg_operand" "r")))
6489 (const_int 32))))]
6490 "TARGET_POWERPC && ! TARGET_POWER"
6491 "mulhw %0,%1,%2"
6492 [(set_attr "type" "imul")])
6493
6494 (define_expand "umulsi3_highpart"
6495 [(set (match_operand:SI 0 "gpc_reg_operand" "")
6496 (truncate:SI
6497 (lshiftrt:DI (mult:DI (zero_extend:DI
6498 (match_operand:SI 1 "gpc_reg_operand" ""))
6499 (zero_extend:DI
6500 (match_operand:SI 2 "gpc_reg_operand" "")))
6501 (const_int 32))))]
6502 "TARGET_POWERPC"
6503 "
6504 {
6505 if (TARGET_POWER)
6506 {
6507 emit_insn (gen_umulsi3_highpart_mq (operands[0], operands[1], operands[2]));
6508 DONE;
6509 }
6510 }")
6511
6512 (define_insn "umulsi3_highpart_mq"
6513 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6514 (truncate:SI
6515 (lshiftrt:DI (mult:DI (zero_extend:DI
6516 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6517 (zero_extend:DI
6518 (match_operand:SI 2 "gpc_reg_operand" "r")))
6519 (const_int 32))))
6520 (clobber (match_scratch:SI 3 "=q"))]
6521 "TARGET_POWERPC && TARGET_POWER"
6522 "mulhwu %0,%1,%2"
6523 [(set_attr "type" "imul")])
6524
6525 (define_insn "*umulsi3_highpart_no_mq"
6526 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6527 (truncate:SI
6528 (lshiftrt:DI (mult:DI (zero_extend:DI
6529 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6530 (zero_extend:DI
6531 (match_operand:SI 2 "gpc_reg_operand" "r")))
6532 (const_int 32))))]
6533 "TARGET_POWERPC && ! TARGET_POWER"
6534 "mulhwu %0,%1,%2"
6535 [(set_attr "type" "imul")])
6536
6537 ;; If operands 0 and 2 are in the same register, we have a problem. But
6538 ;; operands 0 and 1 (the usual case) can be in the same register. That's
6539 ;; why we have the strange constraints below.
6540 (define_insn "ashldi3_power"
6541 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
6542 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
6543 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
6544 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
6545 "TARGET_POWER"
6546 "@
6547 {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
6548 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
6549 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
6550 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
6551 [(set_attr "length" "8")])
6552
6553 (define_insn "lshrdi3_power"
6554 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
6555 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
6556 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
6557 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
6558 "TARGET_POWER"
6559 "@
6560 {s%A2i|s%A2wi} %L0,%1,%h2\;{cal %0,0(0)|li %0,0}
6561 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
6562 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
6563 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
6564 [(set_attr "length" "8")])
6565
6566 ;; Shift by a variable amount is too complex to be worth open-coding. We
6567 ;; just handle shifts by constants.
6568 (define_insn "ashrdi3_power"
6569 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6570 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6571 (match_operand:SI 2 "const_int_operand" "M,i")))
6572 (clobber (match_scratch:SI 3 "=X,q"))]
6573 "TARGET_POWER"
6574 "@
6575 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
6576 sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
6577 [(set_attr "type" "shift")
6578 (set_attr "length" "8")])
6579
6580 (define_insn "ashrdi3_no_power"
6581 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
6582 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6583 (match_operand:SI 2 "const_int_operand" "M,i")))]
6584 "TARGET_32BIT && !TARGET_POWERPC64 && !TARGET_POWER && WORDS_BIG_ENDIAN"
6585 "@
6586 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
6587 {sri|srwi} %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;{srai|srawi} %0,%1,%h2"
6588 [(set_attr "type" "two,three")
6589 (set_attr "length" "8,12")])
6590
6591 (define_insn "*ashrdisi3_noppc64"
6592 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6593 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6594 (const_int 32)) 4))]
6595 "TARGET_32BIT && !TARGET_POWERPC64"
6596 "*
6597 {
6598 if (REGNO (operands[0]) == REGNO (operands[1]))
6599 return \"\";
6600 else
6601 return \"mr %0,%1\";
6602 }"
6603 [(set_attr "length" "4")])
6604
6605 \f
6606 ;; PowerPC64 DImode operations.
6607
6608 (define_insn_and_split "absdi2"
6609 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6610 (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
6611 (clobber (match_scratch:DI 2 "=&r,&r"))]
6612 "TARGET_POWERPC64"
6613 "#"
6614 "&& reload_completed"
6615 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
6616 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
6617 (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
6618 "")
6619
6620 (define_insn_and_split "*nabsdi2"
6621 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6622 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
6623 (clobber (match_scratch:DI 2 "=&r,&r"))]
6624 "TARGET_POWERPC64"
6625 "#"
6626 "&& reload_completed"
6627 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
6628 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
6629 (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
6630 "")
6631
6632 (define_insn "muldi3"
6633 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6634 (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6635 (match_operand:DI 2 "reg_or_short_operand" "r,I")))]
6636 "TARGET_POWERPC64"
6637 "@
6638 mulld %0,%1,%2
6639 mulli %0,%1,%2"
6640 [(set (attr "type")
6641 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
6642 (const_string "imul3")
6643 (match_operand:SI 2 "short_cint_operand" "")
6644 (const_string "imul2")]
6645 (const_string "lmul")))])
6646
6647 (define_insn "*muldi3_internal1"
6648 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6649 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6650 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6651 (const_int 0)))
6652 (clobber (match_scratch:DI 3 "=r,r"))]
6653 "TARGET_POWERPC64"
6654 "@
6655 mulld. %3,%1,%2
6656 #"
6657 [(set_attr "type" "lmul_compare")
6658 (set_attr "length" "4,8")])
6659
6660 (define_split
6661 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6662 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
6663 (match_operand:DI 2 "gpc_reg_operand" ""))
6664 (const_int 0)))
6665 (clobber (match_scratch:DI 3 ""))]
6666 "TARGET_POWERPC64 && reload_completed"
6667 [(set (match_dup 3)
6668 (mult:DI (match_dup 1) (match_dup 2)))
6669 (set (match_dup 0)
6670 (compare:CC (match_dup 3)
6671 (const_int 0)))]
6672 "")
6673
6674 (define_insn "*muldi3_internal2"
6675 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6676 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6677 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6678 (const_int 0)))
6679 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6680 (mult:DI (match_dup 1) (match_dup 2)))]
6681 "TARGET_POWERPC64"
6682 "@
6683 mulld. %0,%1,%2
6684 #"
6685 [(set_attr "type" "lmul_compare")
6686 (set_attr "length" "4,8")])
6687
6688 (define_split
6689 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6690 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
6691 (match_operand:DI 2 "gpc_reg_operand" ""))
6692 (const_int 0)))
6693 (set (match_operand:DI 0 "gpc_reg_operand" "")
6694 (mult:DI (match_dup 1) (match_dup 2)))]
6695 "TARGET_POWERPC64 && reload_completed"
6696 [(set (match_dup 0)
6697 (mult:DI (match_dup 1) (match_dup 2)))
6698 (set (match_dup 3)
6699 (compare:CC (match_dup 0)
6700 (const_int 0)))]
6701 "")
6702
6703 (define_insn "smuldi3_highpart"
6704 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6705 (truncate:DI
6706 (lshiftrt:TI (mult:TI (sign_extend:TI
6707 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6708 (sign_extend:TI
6709 (match_operand:DI 2 "gpc_reg_operand" "r")))
6710 (const_int 64))))]
6711 "TARGET_POWERPC64"
6712 "mulhd %0,%1,%2"
6713 [(set_attr "type" "lmul")])
6714
6715 (define_insn "umuldi3_highpart"
6716 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6717 (truncate:DI
6718 (lshiftrt:TI (mult:TI (zero_extend:TI
6719 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6720 (zero_extend:TI
6721 (match_operand:DI 2 "gpc_reg_operand" "r")))
6722 (const_int 64))))]
6723 "TARGET_POWERPC64"
6724 "mulhdu %0,%1,%2"
6725 [(set_attr "type" "lmul")])
6726
6727 (define_insn "rotldi3"
6728 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6729 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6730 (match_operand:DI 2 "reg_or_cint_operand" "r,i")))]
6731 "TARGET_POWERPC64"
6732 "@
6733 rldcl %0,%1,%2,0
6734 rldicl %0,%1,%H2,0"
6735 [(set_attr "type" "var_shift_rotate,integer")])
6736
6737 (define_insn "*rotldi3_internal2"
6738 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
6739 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6740 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i"))
6741 (const_int 0)))
6742 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
6743 "TARGET_64BIT"
6744 "@
6745 rldcl. %3,%1,%2,0
6746 rldicl. %3,%1,%H2,0
6747 #
6748 #"
6749 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6750 (set_attr "length" "4,4,8,8")])
6751
6752 (define_split
6753 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6754 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6755 (match_operand:DI 2 "reg_or_cint_operand" ""))
6756 (const_int 0)))
6757 (clobber (match_scratch:DI 3 ""))]
6758 "TARGET_POWERPC64 && reload_completed"
6759 [(set (match_dup 3)
6760 (rotate:DI (match_dup 1) (match_dup 2)))
6761 (set (match_dup 0)
6762 (compare:CC (match_dup 3)
6763 (const_int 0)))]
6764 "")
6765
6766 (define_insn "*rotldi3_internal3"
6767 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
6768 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6769 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i"))
6770 (const_int 0)))
6771 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
6772 (rotate:DI (match_dup 1) (match_dup 2)))]
6773 "TARGET_64BIT"
6774 "@
6775 rldcl. %0,%1,%2,0
6776 rldicl. %0,%1,%H2,0
6777 #
6778 #"
6779 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6780 (set_attr "length" "4,4,8,8")])
6781
6782 (define_split
6783 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6784 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6785 (match_operand:DI 2 "reg_or_cint_operand" ""))
6786 (const_int 0)))
6787 (set (match_operand:DI 0 "gpc_reg_operand" "")
6788 (rotate:DI (match_dup 1) (match_dup 2)))]
6789 "TARGET_POWERPC64 && reload_completed"
6790 [(set (match_dup 0)
6791 (rotate:DI (match_dup 1) (match_dup 2)))
6792 (set (match_dup 3)
6793 (compare:CC (match_dup 0)
6794 (const_int 0)))]
6795 "")
6796
6797 (define_insn "*rotldi3_internal4"
6798 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6799 (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6800 (match_operand:DI 2 "reg_or_cint_operand" "r,i"))
6801 (match_operand:DI 3 "mask64_operand" "n,n")))]
6802 "TARGET_POWERPC64"
6803 "@
6804 rldc%B3 %0,%1,%2,%S3
6805 rldic%B3 %0,%1,%H2,%S3"
6806 [(set_attr "type" "var_shift_rotate,integer")])
6807
6808 (define_insn "*rotldi3_internal5"
6809 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
6810 (compare:CC (and:DI
6811 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6812 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i"))
6813 (match_operand:DI 3 "mask64_operand" "n,n,n,n"))
6814 (const_int 0)))
6815 (clobber (match_scratch:DI 4 "=r,r,r,r"))]
6816 "TARGET_64BIT"
6817 "@
6818 rldc%B3. %4,%1,%2,%S3
6819 rldic%B3. %4,%1,%H2,%S3
6820 #
6821 #"
6822 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6823 (set_attr "length" "4,4,8,8")])
6824
6825 (define_split
6826 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6827 (compare:CC (and:DI
6828 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6829 (match_operand:DI 2 "reg_or_cint_operand" ""))
6830 (match_operand:DI 3 "mask64_operand" ""))
6831 (const_int 0)))
6832 (clobber (match_scratch:DI 4 ""))]
6833 "TARGET_POWERPC64 && reload_completed"
6834 [(set (match_dup 4)
6835 (and:DI (rotate:DI (match_dup 1)
6836 (match_dup 2))
6837 (match_dup 3)))
6838 (set (match_dup 0)
6839 (compare:CC (match_dup 4)
6840 (const_int 0)))]
6841 "")
6842
6843 (define_insn "*rotldi3_internal6"
6844 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
6845 (compare:CC (and:DI
6846 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6847 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i"))
6848 (match_operand:DI 3 "mask64_operand" "n,n,n,n"))
6849 (const_int 0)))
6850 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
6851 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6852 "TARGET_64BIT"
6853 "@
6854 rldc%B3. %0,%1,%2,%S3
6855 rldic%B3. %0,%1,%H2,%S3
6856 #
6857 #"
6858 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6859 (set_attr "length" "4,4,8,8")])
6860
6861 (define_split
6862 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6863 (compare:CC (and:DI
6864 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6865 (match_operand:DI 2 "reg_or_cint_operand" ""))
6866 (match_operand:DI 3 "mask64_operand" ""))
6867 (const_int 0)))
6868 (set (match_operand:DI 0 "gpc_reg_operand" "")
6869 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6870 "TARGET_POWERPC64 && reload_completed"
6871 [(set (match_dup 0)
6872 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6873 (set (match_dup 4)
6874 (compare:CC (match_dup 0)
6875 (const_int 0)))]
6876 "")
6877
6878 (define_insn "*rotldi3_internal7"
6879 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6880 (zero_extend:DI
6881 (subreg:QI
6882 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6883 (match_operand:DI 2 "reg_or_cint_operand" "r,i")) 0)))]
6884 "TARGET_POWERPC64"
6885 "@
6886 rldcl %0,%1,%2,56
6887 rldicl %0,%1,%H2,56"
6888 [(set_attr "type" "var_shift_rotate,integer")])
6889
6890 (define_insn "*rotldi3_internal8"
6891 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
6892 (compare:CC (zero_extend:DI
6893 (subreg:QI
6894 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6895 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
6896 (const_int 0)))
6897 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
6898 "TARGET_64BIT"
6899 "@
6900 rldcl. %3,%1,%2,56
6901 rldicl. %3,%1,%H2,56
6902 #
6903 #"
6904 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6905 (set_attr "length" "4,4,8,8")])
6906
6907 (define_split
6908 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6909 (compare:CC (zero_extend:DI
6910 (subreg:QI
6911 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6912 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6913 (const_int 0)))
6914 (clobber (match_scratch:DI 3 ""))]
6915 "TARGET_POWERPC64 && reload_completed"
6916 [(set (match_dup 3)
6917 (zero_extend:DI (subreg:QI
6918 (rotate:DI (match_dup 1)
6919 (match_dup 2)) 0)))
6920 (set (match_dup 0)
6921 (compare:CC (match_dup 3)
6922 (const_int 0)))]
6923 "")
6924
6925 (define_insn "*rotldi3_internal9"
6926 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
6927 (compare:CC (zero_extend:DI
6928 (subreg:QI
6929 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6930 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
6931 (const_int 0)))
6932 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
6933 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6934 "TARGET_64BIT"
6935 "@
6936 rldcl. %0,%1,%2,56
6937 rldicl. %0,%1,%H2,56
6938 #
6939 #"
6940 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6941 (set_attr "length" "4,4,8,8")])
6942
6943 (define_split
6944 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6945 (compare:CC (zero_extend:DI
6946 (subreg:QI
6947 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6948 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6949 (const_int 0)))
6950 (set (match_operand:DI 0 "gpc_reg_operand" "")
6951 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6952 "TARGET_POWERPC64 && reload_completed"
6953 [(set (match_dup 0)
6954 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6955 (set (match_dup 3)
6956 (compare:CC (match_dup 0)
6957 (const_int 0)))]
6958 "")
6959
6960 (define_insn "*rotldi3_internal10"
6961 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6962 (zero_extend:DI
6963 (subreg:HI
6964 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6965 (match_operand:DI 2 "reg_or_cint_operand" "r,i")) 0)))]
6966 "TARGET_POWERPC64"
6967 "@
6968 rldcl %0,%1,%2,48
6969 rldicl %0,%1,%H2,48"
6970 [(set_attr "type" "var_shift_rotate,integer")])
6971
6972 (define_insn "*rotldi3_internal11"
6973 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
6974 (compare:CC (zero_extend:DI
6975 (subreg:HI
6976 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
6977 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
6978 (const_int 0)))
6979 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
6980 "TARGET_64BIT"
6981 "@
6982 rldcl. %3,%1,%2,48
6983 rldicl. %3,%1,%H2,48
6984 #
6985 #"
6986 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
6987 (set_attr "length" "4,4,8,8")])
6988
6989 (define_split
6990 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6991 (compare:CC (zero_extend:DI
6992 (subreg:HI
6993 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6994 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6995 (const_int 0)))
6996 (clobber (match_scratch:DI 3 ""))]
6997 "TARGET_POWERPC64 && reload_completed"
6998 [(set (match_dup 3)
6999 (zero_extend:DI (subreg:HI
7000 (rotate:DI (match_dup 1)
7001 (match_dup 2)) 0)))
7002 (set (match_dup 0)
7003 (compare:CC (match_dup 3)
7004 (const_int 0)))]
7005 "")
7006
7007 (define_insn "*rotldi3_internal12"
7008 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
7009 (compare:CC (zero_extend:DI
7010 (subreg:HI
7011 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7012 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
7013 (const_int 0)))
7014 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
7015 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7016 "TARGET_64BIT"
7017 "@
7018 rldcl. %0,%1,%2,48
7019 rldicl. %0,%1,%H2,48
7020 #
7021 #"
7022 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7023 (set_attr "length" "4,4,8,8")])
7024
7025 (define_split
7026 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7027 (compare:CC (zero_extend:DI
7028 (subreg:HI
7029 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7030 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7031 (const_int 0)))
7032 (set (match_operand:DI 0 "gpc_reg_operand" "")
7033 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7034 "TARGET_POWERPC64 && reload_completed"
7035 [(set (match_dup 0)
7036 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
7037 (set (match_dup 3)
7038 (compare:CC (match_dup 0)
7039 (const_int 0)))]
7040 "")
7041
7042 (define_insn "*rotldi3_internal13"
7043 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7044 (zero_extend:DI
7045 (subreg:SI
7046 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7047 (match_operand:DI 2 "reg_or_cint_operand" "r,i")) 0)))]
7048 "TARGET_POWERPC64"
7049 "@
7050 rldcl %0,%1,%2,32
7051 rldicl %0,%1,%H2,32"
7052 [(set_attr "type" "var_shift_rotate,integer")])
7053
7054 (define_insn "*rotldi3_internal14"
7055 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
7056 (compare:CC (zero_extend:DI
7057 (subreg:SI
7058 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7059 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
7060 (const_int 0)))
7061 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
7062 "TARGET_64BIT"
7063 "@
7064 rldcl. %3,%1,%2,32
7065 rldicl. %3,%1,%H2,32
7066 #
7067 #"
7068 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7069 (set_attr "length" "4,4,8,8")])
7070
7071 (define_split
7072 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7073 (compare:CC (zero_extend:DI
7074 (subreg:SI
7075 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7076 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7077 (const_int 0)))
7078 (clobber (match_scratch:DI 3 ""))]
7079 "TARGET_POWERPC64 && reload_completed"
7080 [(set (match_dup 3)
7081 (zero_extend:DI (subreg:SI
7082 (rotate:DI (match_dup 1)
7083 (match_dup 2)) 0)))
7084 (set (match_dup 0)
7085 (compare:CC (match_dup 3)
7086 (const_int 0)))]
7087 "")
7088
7089 (define_insn "*rotldi3_internal15"
7090 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
7091 (compare:CC (zero_extend:DI
7092 (subreg:SI
7093 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7094 (match_operand:DI 2 "reg_or_cint_operand" "r,i,r,i")) 0))
7095 (const_int 0)))
7096 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
7097 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7098 "TARGET_64BIT"
7099 "@
7100 rldcl. %0,%1,%2,32
7101 rldicl. %0,%1,%H2,32
7102 #
7103 #"
7104 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7105 (set_attr "length" "4,4,8,8")])
7106
7107 (define_split
7108 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7109 (compare:CC (zero_extend:DI
7110 (subreg:SI
7111 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7112 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7113 (const_int 0)))
7114 (set (match_operand:DI 0 "gpc_reg_operand" "")
7115 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7116 "TARGET_POWERPC64 && reload_completed"
7117 [(set (match_dup 0)
7118 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
7119 (set (match_dup 3)
7120 (compare:CC (match_dup 0)
7121 (const_int 0)))]
7122 "")
7123
7124 (define_expand "ashldi3"
7125 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7126 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7127 (match_operand:SI 2 "reg_or_cint_operand" "")))]
7128 "TARGET_POWERPC64 || TARGET_POWER"
7129 "
7130 {
7131 if (TARGET_POWERPC64)
7132 ;
7133 else if (TARGET_POWER)
7134 {
7135 emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
7136 DONE;
7137 }
7138 else
7139 FAIL;
7140 }")
7141
7142 (define_insn "*ashldi3_internal1"
7143 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7144 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7145 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))]
7146 "TARGET_POWERPC64"
7147 "@
7148 sld %0,%1,%2
7149 sldi %0,%1,%H2"
7150 [(set_attr "type" "var_shift_rotate,shift")])
7151
7152 (define_insn "*ashldi3_internal2"
7153 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
7154 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7155 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
7156 (const_int 0)))
7157 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
7158 "TARGET_64BIT"
7159 "@
7160 sld. %3,%1,%2
7161 sldi. %3,%1,%H2
7162 #
7163 #"
7164 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7165 (set_attr "length" "4,4,8,8")])
7166
7167 (define_split
7168 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7169 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7170 (match_operand:SI 2 "reg_or_cint_operand" ""))
7171 (const_int 0)))
7172 (clobber (match_scratch:DI 3 ""))]
7173 "TARGET_POWERPC64 && reload_completed"
7174 [(set (match_dup 3)
7175 (ashift:DI (match_dup 1) (match_dup 2)))
7176 (set (match_dup 0)
7177 (compare:CC (match_dup 3)
7178 (const_int 0)))]
7179 "")
7180
7181 (define_insn "*ashldi3_internal3"
7182 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
7183 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7184 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
7185 (const_int 0)))
7186 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
7187 (ashift:DI (match_dup 1) (match_dup 2)))]
7188 "TARGET_64BIT"
7189 "@
7190 sld. %0,%1,%2
7191 sldi. %0,%1,%H2
7192 #
7193 #"
7194 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7195 (set_attr "length" "4,4,8,8")])
7196
7197 (define_split
7198 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7199 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7200 (match_operand:SI 2 "reg_or_cint_operand" ""))
7201 (const_int 0)))
7202 (set (match_operand:DI 0 "gpc_reg_operand" "")
7203 (ashift:DI (match_dup 1) (match_dup 2)))]
7204 "TARGET_POWERPC64 && reload_completed"
7205 [(set (match_dup 0)
7206 (ashift:DI (match_dup 1) (match_dup 2)))
7207 (set (match_dup 3)
7208 (compare:CC (match_dup 0)
7209 (const_int 0)))]
7210 "")
7211
7212 (define_insn "*ashldi3_internal4"
7213 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7214 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7215 (match_operand:SI 2 "const_int_operand" "i"))
7216 (match_operand:DI 3 "const_int_operand" "n")))]
7217 "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
7218 "rldic %0,%1,%H2,%W3")
7219
7220 (define_insn "ashldi3_internal5"
7221 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7222 (compare:CC
7223 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7224 (match_operand:SI 2 "const_int_operand" "i,i"))
7225 (match_operand:DI 3 "const_int_operand" "n,n"))
7226 (const_int 0)))
7227 (clobber (match_scratch:DI 4 "=r,r"))]
7228 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
7229 "@
7230 rldic. %4,%1,%H2,%W3
7231 #"
7232 [(set_attr "type" "compare")
7233 (set_attr "length" "4,8")])
7234
7235 (define_split
7236 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7237 (compare:CC
7238 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7239 (match_operand:SI 2 "const_int_operand" ""))
7240 (match_operand:DI 3 "const_int_operand" ""))
7241 (const_int 0)))
7242 (clobber (match_scratch:DI 4 ""))]
7243 "TARGET_POWERPC64 && reload_completed
7244 && includes_rldic_lshift_p (operands[2], operands[3])"
7245 [(set (match_dup 4)
7246 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7247 (match_dup 3)))
7248 (set (match_dup 0)
7249 (compare:CC (match_dup 4)
7250 (const_int 0)))]
7251 "")
7252
7253 (define_insn "*ashldi3_internal6"
7254 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
7255 (compare:CC
7256 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7257 (match_operand:SI 2 "const_int_operand" "i,i"))
7258 (match_operand:DI 3 "const_int_operand" "n,n"))
7259 (const_int 0)))
7260 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7261 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7262 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
7263 "@
7264 rldic. %0,%1,%H2,%W3
7265 #"
7266 [(set_attr "type" "compare")
7267 (set_attr "length" "4,8")])
7268
7269 (define_split
7270 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
7271 (compare:CC
7272 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7273 (match_operand:SI 2 "const_int_operand" ""))
7274 (match_operand:DI 3 "const_int_operand" ""))
7275 (const_int 0)))
7276 (set (match_operand:DI 0 "gpc_reg_operand" "")
7277 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7278 "TARGET_POWERPC64 && reload_completed
7279 && includes_rldic_lshift_p (operands[2], operands[3])"
7280 [(set (match_dup 0)
7281 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7282 (match_dup 3)))
7283 (set (match_dup 4)
7284 (compare:CC (match_dup 0)
7285 (const_int 0)))]
7286 "")
7287
7288 (define_insn "*ashldi3_internal7"
7289 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7290 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7291 (match_operand:SI 2 "const_int_operand" "i"))
7292 (match_operand:DI 3 "mask64_operand" "n")))]
7293 "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
7294 "rldicr %0,%1,%H2,%S3")
7295
7296 (define_insn "ashldi3_internal8"
7297 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7298 (compare:CC
7299 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7300 (match_operand:SI 2 "const_int_operand" "i,i"))
7301 (match_operand:DI 3 "mask64_operand" "n,n"))
7302 (const_int 0)))
7303 (clobber (match_scratch:DI 4 "=r,r"))]
7304 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
7305 "@
7306 rldicr. %4,%1,%H2,%S3
7307 #"
7308 [(set_attr "type" "compare")
7309 (set_attr "length" "4,8")])
7310
7311 (define_split
7312 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7313 (compare:CC
7314 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7315 (match_operand:SI 2 "const_int_operand" ""))
7316 (match_operand:DI 3 "mask64_operand" ""))
7317 (const_int 0)))
7318 (clobber (match_scratch:DI 4 ""))]
7319 "TARGET_POWERPC64 && reload_completed
7320 && includes_rldicr_lshift_p (operands[2], operands[3])"
7321 [(set (match_dup 4)
7322 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7323 (match_dup 3)))
7324 (set (match_dup 0)
7325 (compare:CC (match_dup 4)
7326 (const_int 0)))]
7327 "")
7328
7329 (define_insn "*ashldi3_internal9"
7330 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
7331 (compare:CC
7332 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7333 (match_operand:SI 2 "const_int_operand" "i,i"))
7334 (match_operand:DI 3 "mask64_operand" "n,n"))
7335 (const_int 0)))
7336 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7337 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7338 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
7339 "@
7340 rldicr. %0,%1,%H2,%S3
7341 #"
7342 [(set_attr "type" "compare")
7343 (set_attr "length" "4,8")])
7344
7345 (define_split
7346 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
7347 (compare:CC
7348 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7349 (match_operand:SI 2 "const_int_operand" ""))
7350 (match_operand:DI 3 "mask64_operand" ""))
7351 (const_int 0)))
7352 (set (match_operand:DI 0 "gpc_reg_operand" "")
7353 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7354 "TARGET_POWERPC64 && reload_completed
7355 && includes_rldicr_lshift_p (operands[2], operands[3])"
7356 [(set (match_dup 0)
7357 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7358 (match_dup 3)))
7359 (set (match_dup 4)
7360 (compare:CC (match_dup 0)
7361 (const_int 0)))]
7362 "")
7363
7364 (define_expand "lshrdi3"
7365 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7366 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7367 (match_operand:SI 2 "reg_or_cint_operand" "")))]
7368 "TARGET_POWERPC64 || TARGET_POWER"
7369 "
7370 {
7371 if (TARGET_POWERPC64)
7372 ;
7373 else if (TARGET_POWER)
7374 {
7375 emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
7376 DONE;
7377 }
7378 else
7379 FAIL;
7380 }")
7381
7382 (define_insn "*lshrdi3_internal1"
7383 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7384 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7385 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))]
7386 "TARGET_POWERPC64"
7387 "@
7388 srd %0,%1,%2
7389 srdi %0,%1,%H2"
7390 [(set_attr "type" "var_shift_rotate,shift")])
7391
7392 (define_insn "*lshrdi3_internal2"
7393 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
7394 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7395 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
7396 (const_int 0)))
7397 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
7398 "TARGET_64BIT "
7399 "@
7400 srd. %3,%1,%2
7401 srdi. %3,%1,%H2
7402 #
7403 #"
7404 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7405 (set_attr "length" "4,4,8,8")])
7406
7407 (define_split
7408 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7409 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7410 (match_operand:SI 2 "reg_or_cint_operand" ""))
7411 (const_int 0)))
7412 (clobber (match_scratch:DI 3 ""))]
7413 "TARGET_POWERPC64 && reload_completed"
7414 [(set (match_dup 3)
7415 (lshiftrt:DI (match_dup 1) (match_dup 2)))
7416 (set (match_dup 0)
7417 (compare:CC (match_dup 3)
7418 (const_int 0)))]
7419 "")
7420
7421 (define_insn "*lshrdi3_internal3"
7422 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
7423 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7424 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
7425 (const_int 0)))
7426 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
7427 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
7428 "TARGET_64BIT"
7429 "@
7430 srd. %0,%1,%2
7431 srdi. %0,%1,%H2
7432 #
7433 #"
7434 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7435 (set_attr "length" "4,4,8,8")])
7436
7437 (define_split
7438 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7439 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7440 (match_operand:SI 2 "reg_or_cint_operand" ""))
7441 (const_int 0)))
7442 (set (match_operand:DI 0 "gpc_reg_operand" "")
7443 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
7444 "TARGET_POWERPC64 && reload_completed"
7445 [(set (match_dup 0)
7446 (lshiftrt:DI (match_dup 1) (match_dup 2)))
7447 (set (match_dup 3)
7448 (compare:CC (match_dup 0)
7449 (const_int 0)))]
7450 "")
7451
7452 (define_expand "ashrdi3"
7453 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7454 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7455 (match_operand:SI 2 "reg_or_cint_operand" "")))]
7456 "WORDS_BIG_ENDIAN"
7457 "
7458 {
7459 if (TARGET_POWERPC64)
7460 ;
7461 else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
7462 {
7463 emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
7464 DONE;
7465 }
7466 else if (TARGET_32BIT && GET_CODE (operands[2]) == CONST_INT
7467 && WORDS_BIG_ENDIAN)
7468 {
7469 emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
7470 DONE;
7471 }
7472 else
7473 FAIL;
7474 }")
7475
7476 (define_insn "*ashrdi3_internal1"
7477 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7478 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7479 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))]
7480 "TARGET_POWERPC64"
7481 "@
7482 srad %0,%1,%2
7483 sradi %0,%1,%H2"
7484 [(set_attr "type" "var_shift_rotate,shift")])
7485
7486 (define_insn "*ashrdi3_internal2"
7487 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
7488 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7489 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
7490 (const_int 0)))
7491 (clobber (match_scratch:DI 3 "=r,r,r,r"))]
7492 "TARGET_64BIT"
7493 "@
7494 srad. %3,%1,%2
7495 sradi. %3,%1,%H2
7496 #
7497 #"
7498 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7499 (set_attr "length" "4,4,8,8")])
7500
7501 (define_split
7502 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7503 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7504 (match_operand:SI 2 "reg_or_cint_operand" ""))
7505 (const_int 0)))
7506 (clobber (match_scratch:DI 3 ""))]
7507 "TARGET_POWERPC64 && reload_completed"
7508 [(set (match_dup 3)
7509 (ashiftrt:DI (match_dup 1) (match_dup 2)))
7510 (set (match_dup 0)
7511 (compare:CC (match_dup 3)
7512 (const_int 0)))]
7513 "")
7514
7515 (define_insn "*ashrdi3_internal3"
7516 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
7517 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
7518 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
7519 (const_int 0)))
7520 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
7521 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7522 "TARGET_64BIT"
7523 "@
7524 srad. %0,%1,%2
7525 sradi. %0,%1,%H2
7526 #
7527 #"
7528 [(set_attr "type" "var_delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
7529 (set_attr "length" "4,4,8,8")])
7530
7531 (define_split
7532 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7533 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7534 (match_operand:SI 2 "reg_or_cint_operand" ""))
7535 (const_int 0)))
7536 (set (match_operand:DI 0 "gpc_reg_operand" "")
7537 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7538 "TARGET_POWERPC64 && reload_completed"
7539 [(set (match_dup 0)
7540 (ashiftrt:DI (match_dup 1) (match_dup 2)))
7541 (set (match_dup 3)
7542 (compare:CC (match_dup 0)
7543 (const_int 0)))]
7544 "")
7545
7546 (define_insn "anddi3"
7547 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
7548 (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r")
7549 (match_operand:DI 2 "and64_2_operand" "?r,S,T,K,J,t")))
7550 (clobber (match_scratch:CC 3 "=X,X,X,x,x,X"))]
7551 "TARGET_POWERPC64"
7552 "@
7553 and %0,%1,%2
7554 rldic%B2 %0,%1,0,%S2
7555 rlwinm %0,%1,0,%m2,%M2
7556 andi. %0,%1,%b2
7557 andis. %0,%1,%u2
7558 #"
7559 [(set_attr "type" "*,*,*,compare,compare,*")
7560 (set_attr "length" "4,4,4,4,4,8")])
7561
7562 (define_split
7563 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7564 (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7565 (match_operand:DI 2 "mask64_2_operand" "")))
7566 (clobber (match_scratch:CC 3 ""))]
7567 "TARGET_POWERPC64
7568 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7569 && !mask_operand (operands[2], DImode)
7570 && !mask64_operand (operands[2], DImode)"
7571 [(set (match_dup 0)
7572 (and:DI (rotate:DI (match_dup 1)
7573 (match_dup 4))
7574 (match_dup 5)))
7575 (set (match_dup 0)
7576 (and:DI (rotate:DI (match_dup 0)
7577 (match_dup 6))
7578 (match_dup 7)))]
7579 {
7580 build_mask64_2_operands (operands[2], &operands[4]);
7581 })
7582
7583 (define_insn "*anddi3_internal2"
7584 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,x,?y,?y,?y,??y,??y,?y")
7585 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r,r,r")
7586 (match_operand:DI 2 "and64_2_operand" "r,S,T,K,J,t,r,S,T,K,J,t"))
7587 (const_int 0)))
7588 (clobber (match_scratch:DI 3 "=r,r,r,r,r,r,r,r,r,r,r,r"))
7589 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,X,X,x,x,X"))]
7590 "TARGET_64BIT"
7591 "@
7592 and. %3,%1,%2
7593 rldic%B2. %3,%1,0,%S2
7594 rlwinm. %3,%1,0,%m2,%M2
7595 andi. %3,%1,%b2
7596 andis. %3,%1,%u2
7597 #
7598 #
7599 #
7600 #
7601 #
7602 #
7603 #"
7604 [(set_attr "type" "compare,compare,delayed_compare,compare,compare,compare,compare,compare,compare,compare,compare,compare")
7605 (set_attr "length" "4,4,4,4,4,8,8,8,8,8,8,12")])
7606
7607 (define_split
7608 [(set (match_operand:CC 0 "cc_reg_operand" "")
7609 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7610 (match_operand:DI 2 "mask64_2_operand" ""))
7611 (const_int 0)))
7612 (clobber (match_scratch:DI 3 ""))
7613 (clobber (match_scratch:CC 4 ""))]
7614 "TARGET_64BIT && reload_completed
7615 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7616 && !mask_operand (operands[2], DImode)
7617 && !mask64_operand (operands[2], DImode)"
7618 [(set (match_dup 3)
7619 (and:DI (rotate:DI (match_dup 1)
7620 (match_dup 5))
7621 (match_dup 6)))
7622 (parallel [(set (match_dup 0)
7623 (compare:CC (and:DI (rotate:DI (match_dup 3)
7624 (match_dup 7))
7625 (match_dup 8))
7626 (const_int 0)))
7627 (clobber (match_dup 3))])]
7628 "
7629 {
7630 build_mask64_2_operands (operands[2], &operands[5]);
7631 }")
7632
7633 (define_insn "*anddi3_internal3"
7634 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,x,x,?y,?y,?y,??y,??y,?y")
7635 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r,r,r")
7636 (match_operand:DI 2 "and64_2_operand" "r,S,T,K,J,t,r,S,T,K,J,t"))
7637 (const_int 0)))
7638 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r,r,r")
7639 (and:DI (match_dup 1) (match_dup 2)))
7640 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,X,X,x,x,X"))]
7641 "TARGET_64BIT"
7642 "@
7643 and. %0,%1,%2
7644 rldic%B2. %0,%1,0,%S2
7645 rlwinm. %0,%1,0,%m2,%M2
7646 andi. %0,%1,%b2
7647 andis. %0,%1,%u2
7648 #
7649 #
7650 #
7651 #
7652 #
7653 #
7654 #"
7655 [(set_attr "type" "compare,compare,delayed_compare,compare,compare,compare,compare,compare,compare,compare,compare,compare")
7656 (set_attr "length" "4,4,4,4,4,8,8,8,8,8,8,12")])
7657
7658 (define_split
7659 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7660 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7661 (match_operand:DI 2 "and64_2_operand" ""))
7662 (const_int 0)))
7663 (set (match_operand:DI 0 "gpc_reg_operand" "")
7664 (and:DI (match_dup 1) (match_dup 2)))
7665 (clobber (match_scratch:CC 4 ""))]
7666 "TARGET_64BIT && reload_completed"
7667 [(parallel [(set (match_dup 0)
7668 (and:DI (match_dup 1) (match_dup 2)))
7669 (clobber (match_dup 4))])
7670 (set (match_dup 3)
7671 (compare:CC (match_dup 0)
7672 (const_int 0)))]
7673 "")
7674
7675 (define_split
7676 [(set (match_operand:CC 3 "cc_reg_operand" "")
7677 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7678 (match_operand:DI 2 "mask64_2_operand" ""))
7679 (const_int 0)))
7680 (set (match_operand:DI 0 "gpc_reg_operand" "")
7681 (and:DI (match_dup 1) (match_dup 2)))
7682 (clobber (match_scratch:CC 4 ""))]
7683 "TARGET_64BIT && reload_completed
7684 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7685 && !mask_operand (operands[2], DImode)
7686 && !mask64_operand (operands[2], DImode)"
7687 [(set (match_dup 0)
7688 (and:DI (rotate:DI (match_dup 1)
7689 (match_dup 5))
7690 (match_dup 6)))
7691 (parallel [(set (match_dup 3)
7692 (compare:CC (and:DI (rotate:DI (match_dup 0)
7693 (match_dup 7))
7694 (match_dup 8))
7695 (const_int 0)))
7696 (set (match_dup 0)
7697 (and:DI (rotate:DI (match_dup 0)
7698 (match_dup 7))
7699 (match_dup 8)))])]
7700 "
7701 {
7702 build_mask64_2_operands (operands[2], &operands[5]);
7703 }")
7704
7705 (define_expand "iordi3"
7706 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7707 (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
7708 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
7709 "TARGET_POWERPC64"
7710 "
7711 {
7712 if (non_logical_cint_operand (operands[2], DImode))
7713 {
7714 HOST_WIDE_INT value;
7715 rtx tmp = ((!can_create_pseudo_p ()
7716 || rtx_equal_p (operands[0], operands[1]))
7717 ? operands[0] : gen_reg_rtx (DImode));
7718
7719 if (GET_CODE (operands[2]) == CONST_INT)
7720 {
7721 value = INTVAL (operands[2]);
7722 emit_insn (gen_iordi3 (tmp, operands[1],
7723 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7724 }
7725 else
7726 {
7727 value = CONST_DOUBLE_LOW (operands[2]);
7728 emit_insn (gen_iordi3 (tmp, operands[1],
7729 immed_double_const (value
7730 & (~ (HOST_WIDE_INT) 0xffff),
7731 0, DImode)));
7732 }
7733
7734 emit_insn (gen_iordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7735 DONE;
7736 }
7737 }")
7738
7739 (define_expand "xordi3"
7740 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7741 (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
7742 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
7743 "TARGET_POWERPC64"
7744 "
7745 {
7746 if (non_logical_cint_operand (operands[2], DImode))
7747 {
7748 HOST_WIDE_INT value;
7749 rtx tmp = ((!can_create_pseudo_p ()
7750 || rtx_equal_p (operands[0], operands[1]))
7751 ? operands[0] : gen_reg_rtx (DImode));
7752
7753 if (GET_CODE (operands[2]) == CONST_INT)
7754 {
7755 value = INTVAL (operands[2]);
7756 emit_insn (gen_xordi3 (tmp, operands[1],
7757 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7758 }
7759 else
7760 {
7761 value = CONST_DOUBLE_LOW (operands[2]);
7762 emit_insn (gen_xordi3 (tmp, operands[1],
7763 immed_double_const (value
7764 & (~ (HOST_WIDE_INT) 0xffff),
7765 0, DImode)));
7766 }
7767
7768 emit_insn (gen_xordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7769 DONE;
7770 }
7771 }")
7772
7773 (define_insn "*booldi3_internal1"
7774 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
7775 (match_operator:DI 3 "boolean_or_operator"
7776 [(match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
7777 (match_operand:DI 2 "logical_operand" "r,K,JF")]))]
7778 "TARGET_POWERPC64"
7779 "@
7780 %q3 %0,%1,%2
7781 %q3i %0,%1,%b2
7782 %q3is %0,%1,%u2")
7783
7784 (define_insn "*booldi3_internal2"
7785 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7786 (compare:CC (match_operator:DI 4 "boolean_or_operator"
7787 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7788 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7789 (const_int 0)))
7790 (clobber (match_scratch:DI 3 "=r,r"))]
7791 "TARGET_64BIT"
7792 "@
7793 %q4. %3,%1,%2
7794 #"
7795 [(set_attr "type" "compare")
7796 (set_attr "length" "4,8")])
7797
7798 (define_split
7799 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7800 (compare:CC (match_operator:DI 4 "boolean_operator"
7801 [(match_operand:DI 1 "gpc_reg_operand" "")
7802 (match_operand:DI 2 "gpc_reg_operand" "")])
7803 (const_int 0)))
7804 (clobber (match_scratch:DI 3 ""))]
7805 "TARGET_POWERPC64 && reload_completed"
7806 [(set (match_dup 3) (match_dup 4))
7807 (set (match_dup 0)
7808 (compare:CC (match_dup 3)
7809 (const_int 0)))]
7810 "")
7811
7812 (define_insn "*booldi3_internal3"
7813 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7814 (compare:CC (match_operator:DI 4 "boolean_operator"
7815 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7816 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7817 (const_int 0)))
7818 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7819 (match_dup 4))]
7820 "TARGET_64BIT"
7821 "@
7822 %q4. %0,%1,%2
7823 #"
7824 [(set_attr "type" "compare")
7825 (set_attr "length" "4,8")])
7826
7827 (define_split
7828 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7829 (compare:CC (match_operator:DI 4 "boolean_operator"
7830 [(match_operand:DI 1 "gpc_reg_operand" "")
7831 (match_operand:DI 2 "gpc_reg_operand" "")])
7832 (const_int 0)))
7833 (set (match_operand:DI 0 "gpc_reg_operand" "")
7834 (match_dup 4))]
7835 "TARGET_POWERPC64 && reload_completed"
7836 [(set (match_dup 0) (match_dup 4))
7837 (set (match_dup 3)
7838 (compare:CC (match_dup 0)
7839 (const_int 0)))]
7840 "")
7841
7842 ;; Split a logical operation that we can't do in one insn into two insns,
7843 ;; each of which does one 16-bit part. This is used by combine.
7844
7845 (define_split
7846 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7847 (match_operator:DI 3 "boolean_or_operator"
7848 [(match_operand:DI 1 "gpc_reg_operand" "")
7849 (match_operand:DI 2 "non_logical_cint_operand" "")]))]
7850 "TARGET_POWERPC64"
7851 [(set (match_dup 0) (match_dup 4))
7852 (set (match_dup 0) (match_dup 5))]
7853 "
7854 {
7855 rtx i3,i4;
7856
7857 if (GET_CODE (operands[2]) == CONST_DOUBLE)
7858 {
7859 HOST_WIDE_INT value = CONST_DOUBLE_LOW (operands[2]);
7860 i3 = immed_double_const (value & (~ (HOST_WIDE_INT) 0xffff),
7861 0, DImode);
7862 i4 = GEN_INT (value & 0xffff);
7863 }
7864 else
7865 {
7866 i3 = GEN_INT (INTVAL (operands[2])
7867 & (~ (HOST_WIDE_INT) 0xffff));
7868 i4 = GEN_INT (INTVAL (operands[2]) & 0xffff);
7869 }
7870 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
7871 operands[1], i3);
7872 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
7873 operands[0], i4);
7874 }")
7875
7876 (define_insn "*boolcdi3_internal1"
7877 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7878 (match_operator:DI 3 "boolean_operator"
7879 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7880 (match_operand:DI 2 "gpc_reg_operand" "r")]))]
7881 "TARGET_POWERPC64"
7882 "%q3 %0,%2,%1")
7883
7884 (define_insn "*boolcdi3_internal2"
7885 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7886 (compare:CC (match_operator:DI 4 "boolean_operator"
7887 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7888 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7889 (const_int 0)))
7890 (clobber (match_scratch:DI 3 "=r,r"))]
7891 "TARGET_64BIT"
7892 "@
7893 %q4. %3,%2,%1
7894 #"
7895 [(set_attr "type" "compare")
7896 (set_attr "length" "4,8")])
7897
7898 (define_split
7899 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7900 (compare:CC (match_operator:DI 4 "boolean_operator"
7901 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7902 (match_operand:DI 2 "gpc_reg_operand" "")])
7903 (const_int 0)))
7904 (clobber (match_scratch:DI 3 ""))]
7905 "TARGET_POWERPC64 && reload_completed"
7906 [(set (match_dup 3) (match_dup 4))
7907 (set (match_dup 0)
7908 (compare:CC (match_dup 3)
7909 (const_int 0)))]
7910 "")
7911
7912 (define_insn "*boolcdi3_internal3"
7913 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7914 (compare:CC (match_operator:DI 4 "boolean_operator"
7915 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7916 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7917 (const_int 0)))
7918 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7919 (match_dup 4))]
7920 "TARGET_64BIT"
7921 "@
7922 %q4. %0,%2,%1
7923 #"
7924 [(set_attr "type" "compare")
7925 (set_attr "length" "4,8")])
7926
7927 (define_split
7928 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7929 (compare:CC (match_operator:DI 4 "boolean_operator"
7930 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7931 (match_operand:DI 2 "gpc_reg_operand" "")])
7932 (const_int 0)))
7933 (set (match_operand:DI 0 "gpc_reg_operand" "")
7934 (match_dup 4))]
7935 "TARGET_POWERPC64 && reload_completed"
7936 [(set (match_dup 0) (match_dup 4))
7937 (set (match_dup 3)
7938 (compare:CC (match_dup 0)
7939 (const_int 0)))]
7940 "")
7941
7942 (define_insn "*boolccdi3_internal1"
7943 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7944 (match_operator:DI 3 "boolean_operator"
7945 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7946 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))]))]
7947 "TARGET_POWERPC64"
7948 "%q3 %0,%1,%2")
7949
7950 (define_insn "*boolccdi3_internal2"
7951 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7952 (compare:CC (match_operator:DI 4 "boolean_operator"
7953 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7954 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7955 (const_int 0)))
7956 (clobber (match_scratch:DI 3 "=r,r"))]
7957 "TARGET_64BIT"
7958 "@
7959 %q4. %3,%1,%2
7960 #"
7961 [(set_attr "type" "compare")
7962 (set_attr "length" "4,8")])
7963
7964 (define_split
7965 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7966 (compare:CC (match_operator:DI 4 "boolean_operator"
7967 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7968 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7969 (const_int 0)))
7970 (clobber (match_scratch:DI 3 ""))]
7971 "TARGET_POWERPC64 && reload_completed"
7972 [(set (match_dup 3) (match_dup 4))
7973 (set (match_dup 0)
7974 (compare:CC (match_dup 3)
7975 (const_int 0)))]
7976 "")
7977
7978 (define_insn "*boolccdi3_internal3"
7979 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7980 (compare:CC (match_operator:DI 4 "boolean_operator"
7981 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7982 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7983 (const_int 0)))
7984 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7985 (match_dup 4))]
7986 "TARGET_64BIT"
7987 "@
7988 %q4. %0,%1,%2
7989 #"
7990 [(set_attr "type" "compare")
7991 (set_attr "length" "4,8")])
7992
7993 (define_split
7994 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7995 (compare:CC (match_operator:DI 4 "boolean_operator"
7996 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7997 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7998 (const_int 0)))
7999 (set (match_operand:DI 0 "gpc_reg_operand" "")
8000 (match_dup 4))]
8001 "TARGET_POWERPC64 && reload_completed"
8002 [(set (match_dup 0) (match_dup 4))
8003 (set (match_dup 3)
8004 (compare:CC (match_dup 0)
8005 (const_int 0)))]
8006 "")
8007 \f
8008 ;; Now define ways of moving data around.
8009
8010 ;; Set up a register with a value from the GOT table
8011
8012 (define_expand "movsi_got"
8013 [(set (match_operand:SI 0 "gpc_reg_operand" "")
8014 (unspec:SI [(match_operand:SI 1 "got_operand" "")
8015 (match_dup 2)] UNSPEC_MOVSI_GOT))]
8016 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
8017 "
8018 {
8019 if (GET_CODE (operands[1]) == CONST)
8020 {
8021 rtx offset = const0_rtx;
8022 HOST_WIDE_INT value;
8023
8024 operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
8025 value = INTVAL (offset);
8026 if (value != 0)
8027 {
8028 rtx tmp = (!can_create_pseudo_p ()
8029 ? operands[0]
8030 : gen_reg_rtx (Pmode));
8031 emit_insn (gen_movsi_got (tmp, operands[1]));
8032 emit_insn (gen_addsi3 (operands[0], tmp, offset));
8033 DONE;
8034 }
8035 }
8036
8037 operands[2] = rs6000_got_register (operands[1]);
8038 }")
8039
8040 (define_insn "*movsi_got_internal"
8041 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8042 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
8043 (match_operand:SI 2 "gpc_reg_operand" "b")]
8044 UNSPEC_MOVSI_GOT))]
8045 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
8046 "{l|lwz} %0,%a1@got(%2)"
8047 [(set_attr "type" "load")])
8048
8049 ;; Used by sched, shorten_branches and final when the GOT pseudo reg
8050 ;; didn't get allocated to a hard register.
8051 (define_split
8052 [(set (match_operand:SI 0 "gpc_reg_operand" "")
8053 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
8054 (match_operand:SI 2 "memory_operand" "")]
8055 UNSPEC_MOVSI_GOT))]
8056 "DEFAULT_ABI == ABI_V4
8057 && flag_pic == 1
8058 && (reload_in_progress || reload_completed)"
8059 [(set (match_dup 0) (match_dup 2))
8060 (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)]
8061 UNSPEC_MOVSI_GOT))]
8062 "")
8063
8064 ;; For SI, we special-case integers that can't be loaded in one insn. We
8065 ;; do the load 16-bits at a time. We could do this by loading from memory,
8066 ;; and this is even supposed to be faster, but it is simpler not to get
8067 ;; integers in the TOC.
8068 (define_insn "movsi_low"
8069 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8070 (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
8071 (match_operand 2 "" ""))))]
8072 "TARGET_MACHO && ! TARGET_64BIT"
8073 "{l|lwz} %0,lo16(%2)(%1)"
8074 [(set_attr "type" "load")
8075 (set_attr "length" "4")])
8076
8077 (define_insn "*movsi_internal1"
8078 [(set (match_operand:SI 0 "rs6000_nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
8079 (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,R,*h,r,r,r,0"))]
8080 "gpc_reg_operand (operands[0], SImode)
8081 || gpc_reg_operand (operands[1], SImode)"
8082 "@
8083 mr %0,%1
8084 {cal|la} %0,%a1
8085 {l%U1%X1|lwz%U1%X1} %0,%1
8086 {st%U0%X0|stw%U0%X0} %1,%0
8087 {lil|li} %0,%1
8088 {liu|lis} %0,%v1
8089 #
8090 {cal|la} %0,%a1
8091 mf%1 %0
8092 mt%0 %1
8093 mt%0 %1
8094 mt%0 %1
8095 {cror 0,0,0|nop}"
8096 [(set_attr "type" "*,*,load,store,*,*,*,*,mfjmpr,*,mtjmpr,*,*")
8097 (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
8098
8099 ;; Split a load of a large constant into the appropriate two-insn
8100 ;; sequence.
8101
8102 (define_split
8103 [(set (match_operand:SI 0 "gpc_reg_operand" "")
8104 (match_operand:SI 1 "const_int_operand" ""))]
8105 "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
8106 && (INTVAL (operands[1]) & 0xffff) != 0"
8107 [(set (match_dup 0)
8108 (match_dup 2))
8109 (set (match_dup 0)
8110 (ior:SI (match_dup 0)
8111 (match_dup 3)))]
8112 "
8113 { rtx tem = rs6000_emit_set_const (operands[0], SImode, operands[1], 2);
8114
8115 if (tem == operands[0])
8116 DONE;
8117 else
8118 FAIL;
8119 }")
8120
8121 (define_insn "*mov<mode>_internal2"
8122 [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
8123 (compare:CC (match_operand:P 1 "gpc_reg_operand" "0,r,r")
8124 (const_int 0)))
8125 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
8126 ""
8127 "@
8128 {cmpi|cmp<wd>i} %2,%0,0
8129 mr. %0,%1
8130 #"
8131 [(set_attr "type" "cmp,compare,cmp")
8132 (set_attr "length" "4,4,8")])
8133
8134 (define_split
8135 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
8136 (compare:CC (match_operand:P 1 "gpc_reg_operand" "")
8137 (const_int 0)))
8138 (set (match_operand:P 0 "gpc_reg_operand" "") (match_dup 1))]
8139 "reload_completed"
8140 [(set (match_dup 0) (match_dup 1))
8141 (set (match_dup 2)
8142 (compare:CC (match_dup 0)
8143 (const_int 0)))]
8144 "")
8145 \f
8146 (define_insn "*movhi_internal"
8147 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
8148 (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
8149 "gpc_reg_operand (operands[0], HImode)
8150 || gpc_reg_operand (operands[1], HImode)"
8151 "@
8152 mr %0,%1
8153 lhz%U1%X1 %0,%1
8154 sth%U0%X0 %1,%0
8155 {lil|li} %0,%w1
8156 mf%1 %0
8157 mt%0 %1
8158 mt%0 %1
8159 {cror 0,0,0|nop}"
8160 [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
8161
8162 (define_expand "mov<mode>"
8163 [(set (match_operand:INT 0 "general_operand" "")
8164 (match_operand:INT 1 "any_operand" ""))]
8165 ""
8166 "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
8167
8168 (define_insn "*movqi_internal"
8169 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
8170 (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
8171 "gpc_reg_operand (operands[0], QImode)
8172 || gpc_reg_operand (operands[1], QImode)"
8173 "@
8174 mr %0,%1
8175 lbz%U1%X1 %0,%1
8176 stb%U0%X0 %1,%0
8177 {lil|li} %0,%1
8178 mf%1 %0
8179 mt%0 %1
8180 mt%0 %1
8181 {cror 0,0,0|nop}"
8182 [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
8183 \f
8184 ;; Here is how to move condition codes around. When we store CC data in
8185 ;; an integer register or memory, we store just the high-order 4 bits.
8186 ;; This lets us not shift in the most common case of CR0.
8187 (define_expand "movcc"
8188 [(set (match_operand:CC 0 "nonimmediate_operand" "")
8189 (match_operand:CC 1 "nonimmediate_operand" ""))]
8190 ""
8191 "")
8192
8193 (define_insn "*movcc_internal1"
8194 [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,?y,y,r,r,r,r,r,q,cl,r,m")
8195 (match_operand:CC 1 "general_operand" "y,r,r,O,x,y,r,I,h,r,r,m,r"))]
8196 "register_operand (operands[0], CCmode)
8197 || register_operand (operands[1], CCmode)"
8198 "@
8199 mcrf %0,%1
8200 mtcrf 128,%1
8201 {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
8202 crxor %0,%0,%0
8203 mfcr %0%Q1
8204 mfcr %0%Q1\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
8205 mr %0,%1
8206 {lil|li} %0,%1
8207 mf%1 %0
8208 mt%0 %1
8209 mt%0 %1
8210 {l%U1%X1|lwz%U1%X1} %0,%1
8211 {st%U0%U1|stw%U0%U1} %1,%0"
8212 [(set (attr "type")
8213 (cond [(eq_attr "alternative" "0,3")
8214 (const_string "cr_logical")
8215 (eq_attr "alternative" "1,2")
8216 (const_string "mtcr")
8217 (eq_attr "alternative" "6,7,9")
8218 (const_string "integer")
8219 (eq_attr "alternative" "8")
8220 (const_string "mfjmpr")
8221 (eq_attr "alternative" "10")
8222 (const_string "mtjmpr")
8223 (eq_attr "alternative" "11")
8224 (const_string "load")
8225 (eq_attr "alternative" "12")
8226 (const_string "store")
8227 (ne (symbol_ref "TARGET_MFCRF") (const_int 0))
8228 (const_string "mfcrf")
8229 ]
8230 (const_string "mfcr")))
8231 (set_attr "length" "4,4,12,4,4,8,4,4,4,4,4,4,4")])
8232 \f
8233 ;; For floating-point, we normally deal with the floating-point registers
8234 ;; unless -msoft-float is used. The sole exception is that parameter passing
8235 ;; can produce floating-point values in fixed-point registers. Unless the
8236 ;; value is a simple constant or already in memory, we deal with this by
8237 ;; allocating memory and copying the value explicitly via that memory location.
8238 (define_expand "movsf"
8239 [(set (match_operand:SF 0 "nonimmediate_operand" "")
8240 (match_operand:SF 1 "any_operand" ""))]
8241 ""
8242 "{ rs6000_emit_move (operands[0], operands[1], SFmode); DONE; }")
8243
8244 (define_split
8245 [(set (match_operand:SF 0 "gpc_reg_operand" "")
8246 (match_operand:SF 1 "const_double_operand" ""))]
8247 "reload_completed
8248 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8249 || (GET_CODE (operands[0]) == SUBREG
8250 && GET_CODE (SUBREG_REG (operands[0])) == REG
8251 && REGNO (SUBREG_REG (operands[0])) <= 31))"
8252 [(set (match_dup 2) (match_dup 3))]
8253 "
8254 {
8255 long l;
8256 REAL_VALUE_TYPE rv;
8257
8258 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8259 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
8260
8261 if (! TARGET_POWERPC64)
8262 operands[2] = operand_subword (operands[0], 0, 0, SFmode);
8263 else
8264 operands[2] = gen_lowpart (SImode, operands[0]);
8265
8266 operands[3] = gen_int_mode (l, SImode);
8267 }")
8268
8269 (define_insn "*movsf_hardfloat"
8270 [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,*c*l,*q,!r,*h,!r,!r")
8271 (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,r,r,h,0,G,Fn"))]
8272 "(gpc_reg_operand (operands[0], SFmode)
8273 || gpc_reg_operand (operands[1], SFmode))
8274 && (TARGET_HARD_FLOAT && TARGET_FPRS)"
8275 "@
8276 mr %0,%1
8277 {l%U1%X1|lwz%U1%X1} %0,%1
8278 {st%U0%X0|stw%U0%X0} %1,%0
8279 fmr %0,%1
8280 lfs%U1%X1 %0,%1
8281 stfs%U0%X0 %1,%0
8282 mt%0 %1
8283 mt%0 %1
8284 mf%1 %0
8285 {cror 0,0,0|nop}
8286 #
8287 #"
8288 [(set_attr "type" "*,load,store,fp,fpload,fpstore,mtjmpr,*,mfjmpr,*,*,*")
8289 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,8")])
8290
8291 (define_insn "*movsf_softfloat"
8292 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,cl,q,r,r,m,r,r,r,r,r,*h")
8293 (match_operand:SF 1 "input_operand" "r,r,r,h,m,r,I,L,R,G,Fn,0"))]
8294 "(gpc_reg_operand (operands[0], SFmode)
8295 || gpc_reg_operand (operands[1], SFmode))
8296 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
8297 "@
8298 mr %0,%1
8299 mt%0 %1
8300 mt%0 %1
8301 mf%1 %0
8302 {l%U1%X1|lwz%U1%X1} %0,%1
8303 {st%U0%X0|stw%U0%X0} %1,%0
8304 {lil|li} %0,%1
8305 {liu|lis} %0,%v1
8306 {cal|la} %0,%a1
8307 #
8308 #
8309 {cror 0,0,0|nop}"
8310 [(set_attr "type" "*,mtjmpr,*,mfjmpr,load,store,*,*,*,*,*,*")
8311 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8,4")])
8312
8313 \f
8314 (define_expand "movdf"
8315 [(set (match_operand:DF 0 "nonimmediate_operand" "")
8316 (match_operand:DF 1 "any_operand" ""))]
8317 ""
8318 "{ rs6000_emit_move (operands[0], operands[1], DFmode); DONE; }")
8319
8320 (define_split
8321 [(set (match_operand:DF 0 "gpc_reg_operand" "")
8322 (match_operand:DF 1 "const_int_operand" ""))]
8323 "! TARGET_POWERPC64 && reload_completed
8324 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8325 || (GET_CODE (operands[0]) == SUBREG
8326 && GET_CODE (SUBREG_REG (operands[0])) == REG
8327 && REGNO (SUBREG_REG (operands[0])) <= 31))"
8328 [(set (match_dup 2) (match_dup 4))
8329 (set (match_dup 3) (match_dup 1))]
8330 "
8331 {
8332 int endian = (WORDS_BIG_ENDIAN == 0);
8333 HOST_WIDE_INT value = INTVAL (operands[1]);
8334
8335 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
8336 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
8337 #if HOST_BITS_PER_WIDE_INT == 32
8338 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
8339 #else
8340 operands[4] = GEN_INT (value >> 32);
8341 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8342 #endif
8343 }")
8344
8345 (define_split
8346 [(set (match_operand:DF 0 "gpc_reg_operand" "")
8347 (match_operand:DF 1 "const_double_operand" ""))]
8348 "! TARGET_POWERPC64 && reload_completed
8349 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8350 || (GET_CODE (operands[0]) == SUBREG
8351 && GET_CODE (SUBREG_REG (operands[0])) == REG
8352 && REGNO (SUBREG_REG (operands[0])) <= 31))"
8353 [(set (match_dup 2) (match_dup 4))
8354 (set (match_dup 3) (match_dup 5))]
8355 "
8356 {
8357 int endian = (WORDS_BIG_ENDIAN == 0);
8358 long l[2];
8359 REAL_VALUE_TYPE rv;
8360
8361 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8362 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8363
8364 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
8365 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
8366 operands[4] = gen_int_mode (l[endian], SImode);
8367 operands[5] = gen_int_mode (l[1 - endian], SImode);
8368 }")
8369
8370 (define_split
8371 [(set (match_operand:DF 0 "gpc_reg_operand" "")
8372 (match_operand:DF 1 "const_double_operand" ""))]
8373 "TARGET_POWERPC64 && reload_completed
8374 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8375 || (GET_CODE (operands[0]) == SUBREG
8376 && GET_CODE (SUBREG_REG (operands[0])) == REG
8377 && REGNO (SUBREG_REG (operands[0])) <= 31))"
8378 [(set (match_dup 2) (match_dup 3))]
8379 "
8380 {
8381 int endian = (WORDS_BIG_ENDIAN == 0);
8382 long l[2];
8383 REAL_VALUE_TYPE rv;
8384 #if HOST_BITS_PER_WIDE_INT >= 64
8385 HOST_WIDE_INT val;
8386 #endif
8387
8388 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8389 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8390
8391 operands[2] = gen_lowpart (DImode, operands[0]);
8392 /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN. */
8393 #if HOST_BITS_PER_WIDE_INT >= 64
8394 val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32
8395 | ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
8396
8397 operands[3] = gen_int_mode (val, DImode);
8398 #else
8399 operands[3] = immed_double_const (l[1 - endian], l[endian], DImode);
8400 #endif
8401 }")
8402
8403 ;; Don't have reload use general registers to load a constant. First,
8404 ;; it might not work if the output operand is the equivalent of
8405 ;; a non-offsettable memref, but also it is less efficient than loading
8406 ;; the constant into an FP register, since it will probably be used there.
8407 ;; The "??" is a kludge until we can figure out a more reasonable way
8408 ;; of handling these non-offsettable values.
8409 (define_insn "*movdf_hardfloat32"
8410 [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,f,f,m,!r,!r,!r")
8411 (match_operand:DF 1 "input_operand" "r,m,r,f,m,f,G,H,F"))]
8412 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
8413 && (gpc_reg_operand (operands[0], DFmode)
8414 || gpc_reg_operand (operands[1], DFmode))"
8415 "*
8416 {
8417 switch (which_alternative)
8418 {
8419 default:
8420 gcc_unreachable ();
8421 case 0:
8422 /* We normally copy the low-numbered register first. However, if
8423 the first register operand 0 is the same as the second register
8424 of operand 1, we must copy in the opposite order. */
8425 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8426 return \"mr %L0,%L1\;mr %0,%1\";
8427 else
8428 return \"mr %0,%1\;mr %L0,%L1\";
8429 case 1:
8430 if (rs6000_offsettable_memref_p (operands[1])
8431 || (GET_CODE (operands[1]) == MEM
8432 && (GET_CODE (XEXP (operands[1], 0)) == LO_SUM
8433 || GET_CODE (XEXP (operands[1], 0)) == PRE_INC
8434 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC
8435 || GET_CODE (XEXP (operands[1], 0)) == PRE_MODIFY)))
8436 {
8437 /* If the low-address word is used in the address, we must load
8438 it last. Otherwise, load it first. Note that we cannot have
8439 auto-increment in that case since the address register is
8440 known to be dead. */
8441 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8442 operands[1], 0))
8443 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8444 else
8445 return \"{l%U1%X1|lwz%U1%X1} %0,%1\;{l|lwz} %L0,%L1\";
8446 }
8447 else
8448 {
8449 rtx addreg;
8450
8451 addreg = find_addr_reg (XEXP (operands[1], 0));
8452 if (refers_to_regno_p (REGNO (operands[0]),
8453 REGNO (operands[0]) + 1,
8454 operands[1], 0))
8455 {
8456 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8457 output_asm_insn (\"{l%X1|lwz%X1} %L0,%1\", operands);
8458 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8459 return \"{l%X1|lwz%X1} %0,%1\";
8460 }
8461 else
8462 {
8463 output_asm_insn (\"{l%X1|lwz%X1} %0,%1\", operands);
8464 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8465 output_asm_insn (\"{l%X1|lwz%X1} %L0,%1\", operands);
8466 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8467 return \"\";
8468 }
8469 }
8470 case 2:
8471 if (rs6000_offsettable_memref_p (operands[0])
8472 || (GET_CODE (operands[0]) == MEM
8473 && (GET_CODE (XEXP (operands[0], 0)) == LO_SUM
8474 || GET_CODE (XEXP (operands[0], 0)) == PRE_INC
8475 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
8476 || GET_CODE (XEXP (operands[0], 0)) == PRE_MODIFY)))
8477 return \"{st%U0%X0|stw%U0%X0} %1,%0\;{st|stw} %L1,%L0\";
8478 else
8479 {
8480 rtx addreg;
8481
8482 addreg = find_addr_reg (XEXP (operands[0], 0));
8483 output_asm_insn (\"{st%X0|stw%X0} %1,%0\", operands);
8484 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8485 output_asm_insn (\"{st%X0|stw%X0} %L1,%0\", operands);
8486 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8487 return \"\";
8488 }
8489 case 3:
8490 return \"fmr %0,%1\";
8491 case 4:
8492 return \"lfd%U1%X1 %0,%1\";
8493 case 5:
8494 return \"stfd%U0%X0 %1,%0\";
8495 case 6:
8496 case 7:
8497 case 8:
8498 return \"#\";
8499 }
8500 }"
8501 [(set_attr "type" "two,load,store,fp,fpload,fpstore,*,*,*")
8502 (set_attr "length" "8,16,16,4,4,4,8,12,16")])
8503
8504 (define_insn "*movdf_softfloat32"
8505 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
8506 (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
8507 "! TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || TARGET_E500_SINGLE)
8508 && (gpc_reg_operand (operands[0], DFmode)
8509 || gpc_reg_operand (operands[1], DFmode))"
8510 "*
8511 {
8512 switch (which_alternative)
8513 {
8514 default:
8515 gcc_unreachable ();
8516 case 0:
8517 /* We normally copy the low-numbered register first. However, if
8518 the first register operand 0 is the same as the second register of
8519 operand 1, we must copy in the opposite order. */
8520 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8521 return \"mr %L0,%L1\;mr %0,%1\";
8522 else
8523 return \"mr %0,%1\;mr %L0,%L1\";
8524 case 1:
8525 /* If the low-address word is used in the address, we must load
8526 it last. Otherwise, load it first. Note that we cannot have
8527 auto-increment in that case since the address register is
8528 known to be dead. */
8529 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8530 operands[1], 0))
8531 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8532 else
8533 return \"{l%U1%X1|lwz%U1%X1} %0,%1\;{l|lwz} %L0,%L1\";
8534 case 2:
8535 return \"{st%U0%X0|stw%U0%X0} %1,%0\;{st|stw} %L1,%L0\";
8536 case 3:
8537 case 4:
8538 case 5:
8539 return \"#\";
8540 }
8541 }"
8542 [(set_attr "type" "two,load,store,*,*,*")
8543 (set_attr "length" "8,8,8,8,12,16")])
8544
8545 ; ld/std require word-aligned displacements -> 'Y' constraint.
8546 ; List Y->r and r->Y before r->r for reload.
8547 (define_insn "*movdf_hardfloat64_mfpgpr"
8548 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,r,!r,f,f,m,*c*l,!r,*h,!r,!r,!r,r,f")
8549 (match_operand:DF 1 "input_operand" "r,Y,r,f,m,f,r,h,0,G,H,F,f,r"))]
8550 "TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS
8551 && (gpc_reg_operand (operands[0], DFmode)
8552 || gpc_reg_operand (operands[1], DFmode))"
8553 "@
8554 std%U0%X0 %1,%0
8555 ld%U1%X1 %0,%1
8556 mr %0,%1
8557 fmr %0,%1
8558 lfd%U1%X1 %0,%1
8559 stfd%U0%X0 %1,%0
8560 mt%0 %1
8561 mf%1 %0
8562 {cror 0,0,0|nop}
8563 #
8564 #
8565 #
8566 mftgpr %0,%1
8567 mffgpr %0,%1"
8568 [(set_attr "type" "store,load,*,fp,fpload,fpstore,mtjmpr,mfjmpr,*,*,*,*,mftgpr,mffgpr")
8569 (set_attr "length" "4,4,4,4,4,4,4,4,4,8,12,16,4,4")])
8570
8571 ; ld/std require word-aligned displacements -> 'Y' constraint.
8572 ; List Y->r and r->Y before r->r for reload.
8573 (define_insn "*movdf_hardfloat64"
8574 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,r,!r,f,f,m,*c*l,!r,*h,!r,!r,!r")
8575 (match_operand:DF 1 "input_operand" "r,Y,r,f,m,f,r,h,0,G,H,F"))]
8576 "TARGET_POWERPC64 && !TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS
8577 && (gpc_reg_operand (operands[0], DFmode)
8578 || gpc_reg_operand (operands[1], DFmode))"
8579 "@
8580 std%U0%X0 %1,%0
8581 ld%U1%X1 %0,%1
8582 mr %0,%1
8583 fmr %0,%1
8584 lfd%U1%X1 %0,%1
8585 stfd%U0%X0 %1,%0
8586 mt%0 %1
8587 mf%1 %0
8588 {cror 0,0,0|nop}
8589 #
8590 #
8591 #"
8592 [(set_attr "type" "store,load,*,fp,fpload,fpstore,mtjmpr,mfjmpr,*,*,*,*")
8593 (set_attr "length" "4,4,4,4,4,4,4,4,4,8,12,16")])
8594
8595 (define_insn "*movdf_softfloat64"
8596 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,Y,r,cl,r,r,r,r,*h")
8597 (match_operand:DF 1 "input_operand" "Y,r,r,r,h,G,H,F,0"))]
8598 "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
8599 && (gpc_reg_operand (operands[0], DFmode)
8600 || gpc_reg_operand (operands[1], DFmode))"
8601 "@
8602 ld%U1%X1 %0,%1
8603 std%U0%X0 %1,%0
8604 mr %0,%1
8605 mt%0 %1
8606 mf%1 %0
8607 #
8608 #
8609 #
8610 {cror 0,0,0|nop}"
8611 [(set_attr "type" "load,store,*,mtjmpr,mfjmpr,*,*,*,*")
8612 (set_attr "length" "4,4,4,4,4,8,12,16,4")])
8613 \f
8614 (define_expand "movtf"
8615 [(set (match_operand:TF 0 "general_operand" "")
8616 (match_operand:TF 1 "any_operand" ""))]
8617 "!TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128"
8618 "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
8619
8620 ; It's important to list the o->f and f->o moves before f->f because
8621 ; otherwise reload, given m->f, will try to pick f->f and reload it,
8622 ; which doesn't make progress. Likewise r->Y must be before r->r.
8623 (define_insn_and_split "*movtf_internal"
8624 [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,f,r,Y,r")
8625 (match_operand:TF 1 "input_operand" "f,o,f,YGHF,r,r"))]
8626 "!TARGET_IEEEQUAD
8627 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128
8628 && (gpc_reg_operand (operands[0], TFmode)
8629 || gpc_reg_operand (operands[1], TFmode))"
8630 "#"
8631 "&& reload_completed"
8632 [(pc)]
8633 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8634 [(set_attr "length" "8,8,8,20,20,16")])
8635
8636 (define_insn_and_split "*movtf_softfloat"
8637 [(set (match_operand:TF 0 "rs6000_nonimmediate_operand" "=r,Y,r")
8638 (match_operand:TF 1 "input_operand" "YGHF,r,r"))]
8639 "!TARGET_IEEEQUAD
8640 && (TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_LONG_DOUBLE_128
8641 && (gpc_reg_operand (operands[0], TFmode)
8642 || gpc_reg_operand (operands[1], TFmode))"
8643 "#"
8644 "&& reload_completed"
8645 [(pc)]
8646 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8647 [(set_attr "length" "20,20,16")])
8648
8649 (define_expand "extenddftf2"
8650 [(set (match_operand:TF 0 "nonimmediate_operand" "")
8651 (float_extend:TF (match_operand:DF 1 "input_operand" "")))]
8652 "!TARGET_IEEEQUAD
8653 && TARGET_HARD_FLOAT
8654 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8655 && TARGET_LONG_DOUBLE_128"
8656 {
8657 if (TARGET_E500_DOUBLE)
8658 emit_insn (gen_spe_extenddftf2 (operands[0], operands[1]));
8659 else
8660 emit_insn (gen_extenddftf2_fprs (operands[0], operands[1]));
8661 DONE;
8662 })
8663
8664 (define_expand "extenddftf2_fprs"
8665 [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
8666 (float_extend:TF (match_operand:DF 1 "input_operand" "")))
8667 (use (match_dup 2))])]
8668 "!TARGET_IEEEQUAD
8669 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8670 {
8671 operands[2] = CONST0_RTX (DFmode);
8672 /* Generate GOT reference early for SVR4 PIC. */
8673 if (DEFAULT_ABI == ABI_V4 && flag_pic)
8674 operands[2] = validize_mem (force_const_mem (DFmode, operands[2]));
8675 })
8676
8677 (define_insn_and_split "*extenddftf2_internal"
8678 [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,&f,r")
8679 (float_extend:TF (match_operand:DF 1 "input_operand" "fr,mf,mf,rmGHF")))
8680 (use (match_operand:DF 2 "zero_reg_mem_operand" "rf,m,f,n"))]
8681 "!TARGET_IEEEQUAD
8682 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8683 "#"
8684 "&& reload_completed"
8685 [(pc)]
8686 {
8687 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
8688 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
8689 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word),
8690 operands[1]);
8691 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word),
8692 operands[2]);
8693 DONE;
8694 })
8695
8696 (define_expand "extendsftf2"
8697 [(set (match_operand:TF 0 "nonimmediate_operand" "")
8698 (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "")))]
8699 "!TARGET_IEEEQUAD
8700 && TARGET_HARD_FLOAT
8701 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8702 && TARGET_LONG_DOUBLE_128"
8703 {
8704 rtx tmp = gen_reg_rtx (DFmode);
8705 emit_insn (gen_extendsfdf2 (tmp, operands[1]));
8706 emit_insn (gen_extenddftf2 (operands[0], tmp));
8707 DONE;
8708 })
8709
8710 (define_expand "trunctfdf2"
8711 [(set (match_operand:DF 0 "gpc_reg_operand" "")
8712 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))]
8713 "!TARGET_IEEEQUAD
8714 && TARGET_HARD_FLOAT
8715 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8716 && TARGET_LONG_DOUBLE_128"
8717 "")
8718
8719 (define_insn_and_split "trunctfdf2_internal1"
8720 [(set (match_operand:DF 0 "gpc_reg_operand" "=f,?f")
8721 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "0,f")))]
8722 "!TARGET_IEEEQUAD && !TARGET_XL_COMPAT
8723 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8724 "@
8725 #
8726 fmr %0,%1"
8727 "&& reload_completed && REGNO (operands[0]) == REGNO (operands[1])"
8728 [(const_int 0)]
8729 {
8730 emit_note (NOTE_INSN_DELETED);
8731 DONE;
8732 }
8733 [(set_attr "type" "fp")])
8734
8735 (define_insn "trunctfdf2_internal2"
8736 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8737 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8738 "!TARGET_IEEEQUAD && TARGET_XL_COMPAT
8739 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8740 "fadd %0,%1,%L1"
8741 [(set_attr "type" "fp")])
8742
8743 (define_expand "trunctfsf2"
8744 [(set (match_operand:SF 0 "gpc_reg_operand" "")
8745 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "")))]
8746 "!TARGET_IEEEQUAD
8747 && TARGET_HARD_FLOAT
8748 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8749 && TARGET_LONG_DOUBLE_128"
8750 {
8751 if (TARGET_E500_DOUBLE)
8752 emit_insn (gen_spe_trunctfsf2 (operands[0], operands[1]));
8753 else
8754 emit_insn (gen_trunctfsf2_fprs (operands[0], operands[1]));
8755 DONE;
8756 })
8757
8758 (define_insn_and_split "trunctfsf2_fprs"
8759 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
8760 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "f")))
8761 (clobber (match_scratch:DF 2 "=f"))]
8762 "!TARGET_IEEEQUAD
8763 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8764 "#"
8765 "&& reload_completed"
8766 [(set (match_dup 2)
8767 (float_truncate:DF (match_dup 1)))
8768 (set (match_dup 0)
8769 (float_truncate:SF (match_dup 2)))]
8770 "")
8771
8772 (define_expand "floatsitf2"
8773 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8774 (float:TF (match_operand:SI 1 "gpc_reg_operand" "")))]
8775 "!TARGET_IEEEQUAD
8776 && TARGET_HARD_FLOAT
8777 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8778 && TARGET_LONG_DOUBLE_128"
8779 {
8780 rtx tmp = gen_reg_rtx (DFmode);
8781 expand_float (tmp, operands[1], false);
8782 emit_insn (gen_extenddftf2 (operands[0], tmp));
8783 DONE;
8784 })
8785
8786 ; fadd, but rounding towards zero.
8787 ; This is probably not the optimal code sequence.
8788 (define_insn "fix_trunc_helper"
8789 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8790 (unspec:DF [(match_operand:TF 1 "gpc_reg_operand" "f")]
8791 UNSPEC_FIX_TRUNC_TF))
8792 (clobber (match_operand:DF 2 "gpc_reg_operand" "=&f"))]
8793 "TARGET_HARD_FLOAT && TARGET_FPRS"
8794 "mffs %2\n\tmtfsb1 31\n\tmtfsb0 30\n\tfadd %0,%1,%L1\n\tmtfsf 1,%2"
8795 [(set_attr "type" "fp")
8796 (set_attr "length" "20")])
8797
8798 (define_expand "fix_trunctfsi2"
8799 [(set (match_operand:SI 0 "gpc_reg_operand" "")
8800 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))]
8801 "!TARGET_IEEEQUAD
8802 && (TARGET_POWER2 || TARGET_POWERPC)
8803 && TARGET_HARD_FLOAT
8804 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8805 && TARGET_LONG_DOUBLE_128"
8806 {
8807 if (TARGET_E500_DOUBLE)
8808 emit_insn (gen_spe_fix_trunctfsi2 (operands[0], operands[1]));
8809 else
8810 emit_insn (gen_fix_trunctfsi2_fprs (operands[0], operands[1]));
8811 DONE;
8812 })
8813
8814 (define_expand "fix_trunctfsi2_fprs"
8815 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
8816 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))
8817 (clobber (match_dup 2))
8818 (clobber (match_dup 3))
8819 (clobber (match_dup 4))
8820 (clobber (match_dup 5))])]
8821 "!TARGET_IEEEQUAD
8822 && (TARGET_POWER2 || TARGET_POWERPC)
8823 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8824 {
8825 operands[2] = gen_reg_rtx (DFmode);
8826 operands[3] = gen_reg_rtx (DFmode);
8827 operands[4] = gen_reg_rtx (DImode);
8828 operands[5] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
8829 })
8830
8831 (define_insn_and_split "*fix_trunctfsi2_internal"
8832 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8833 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "f")))
8834 (clobber (match_operand:DF 2 "gpc_reg_operand" "=f"))
8835 (clobber (match_operand:DF 3 "gpc_reg_operand" "=&f"))
8836 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))
8837 (clobber (match_operand:DI 5 "offsettable_mem_operand" "=o"))]
8838 "!TARGET_IEEEQUAD
8839 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8840 "#"
8841 "&& (can_create_pseudo_p () || offsettable_nonstrict_memref_p (operands[5]))"
8842 [(pc)]
8843 {
8844 rtx lowword;
8845 emit_insn (gen_fix_trunc_helper (operands[2], operands[1], operands[3]));
8846
8847 gcc_assert (MEM_P (operands[5]));
8848 lowword = adjust_address (operands[5], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
8849
8850 emit_insn (gen_fctiwz (operands[4], operands[2]));
8851 emit_move_insn (operands[5], operands[4]);
8852 emit_move_insn (operands[0], lowword);
8853 DONE;
8854 })
8855
8856 (define_expand "negtf2"
8857 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8858 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "")))]
8859 "!TARGET_IEEEQUAD
8860 && TARGET_HARD_FLOAT
8861 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8862 && TARGET_LONG_DOUBLE_128"
8863 "")
8864
8865 (define_insn "negtf2_internal"
8866 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8867 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8868 "!TARGET_IEEEQUAD
8869 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8870 "*
8871 {
8872 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8873 return \"fneg %L0,%L1\;fneg %0,%1\";
8874 else
8875 return \"fneg %0,%1\;fneg %L0,%L1\";
8876 }"
8877 [(set_attr "type" "fp")
8878 (set_attr "length" "8")])
8879
8880 (define_expand "abstf2"
8881 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8882 (abs:TF (match_operand:TF 1 "gpc_reg_operand" "")))]
8883 "!TARGET_IEEEQUAD
8884 && TARGET_HARD_FLOAT
8885 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8886 && TARGET_LONG_DOUBLE_128"
8887 "
8888 {
8889 rtx label = gen_label_rtx ();
8890 if (TARGET_E500_DOUBLE)
8891 {
8892 if (flag_unsafe_math_optimizations)
8893 emit_insn (gen_spe_abstf2_tst (operands[0], operands[1], label));
8894 else
8895 emit_insn (gen_spe_abstf2_cmp (operands[0], operands[1], label));
8896 }
8897 else
8898 emit_insn (gen_abstf2_internal (operands[0], operands[1], label));
8899 emit_label (label);
8900 DONE;
8901 }")
8902
8903 (define_expand "abstf2_internal"
8904 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8905 (match_operand:TF 1 "gpc_reg_operand" ""))
8906 (set (match_dup 3) (match_dup 5))
8907 (set (match_dup 5) (abs:DF (match_dup 5)))
8908 (set (match_dup 4) (compare:CCFP (match_dup 3) (match_dup 5)))
8909 (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
8910 (label_ref (match_operand 2 "" ""))
8911 (pc)))
8912 (set (match_dup 6) (neg:DF (match_dup 6)))]
8913 "!TARGET_IEEEQUAD
8914 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8915 "
8916 {
8917 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
8918 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
8919 operands[3] = gen_reg_rtx (DFmode);
8920 operands[4] = gen_reg_rtx (CCFPmode);
8921 operands[5] = simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word);
8922 operands[6] = simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word);
8923 }")
8924 \f
8925 ;; Next come the multi-word integer load and store and the load and store
8926 ;; multiple insns.
8927
8928 ; List r->r after r->"o<>", otherwise reload will try to reload a
8929 ; non-offsettable address by using r->r which won't make progress.
8930 (define_insn "*movdi_internal32"
8931 [(set (match_operand:DI 0 "rs6000_nonimmediate_operand" "=o<>,r,r,*f,*f,m,r")
8932 (match_operand:DI 1 "input_operand" "r,r,m,f,m,f,IJKnGHF"))]
8933 "! TARGET_POWERPC64
8934 && (gpc_reg_operand (operands[0], DImode)
8935 || gpc_reg_operand (operands[1], DImode))"
8936 "@
8937 #
8938 #
8939 #
8940 fmr %0,%1
8941 lfd%U1%X1 %0,%1
8942 stfd%U0%X0 %1,%0
8943 #"
8944 [(set_attr "type" "load,*,store,fp,fpload,fpstore,*")])
8945
8946 (define_split
8947 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8948 (match_operand:DI 1 "const_int_operand" ""))]
8949 "! TARGET_POWERPC64 && reload_completed"
8950 [(set (match_dup 2) (match_dup 4))
8951 (set (match_dup 3) (match_dup 1))]
8952 "
8953 {
8954 HOST_WIDE_INT value = INTVAL (operands[1]);
8955 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8956 DImode);
8957 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8958 DImode);
8959 #if HOST_BITS_PER_WIDE_INT == 32
8960 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
8961 #else
8962 operands[4] = GEN_INT (value >> 32);
8963 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8964 #endif
8965 }")
8966
8967 (define_split
8968 [(set (match_operand:DI 0 "rs6000_nonimmediate_operand" "")
8969 (match_operand:DI 1 "input_operand" ""))]
8970 "reload_completed && !TARGET_POWERPC64
8971 && gpr_or_gpr_p (operands[0], operands[1])"
8972 [(pc)]
8973 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8974
8975 (define_insn "*movdi_mfpgpr"
8976 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,*f,*f,m,r,*h,*h,r,*f")
8977 (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0,*f,r"))]
8978 "TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS
8979 && (gpc_reg_operand (operands[0], DImode)
8980 || gpc_reg_operand (operands[1], DImode))"
8981 "@
8982 mr %0,%1
8983 ld%U1%X1 %0,%1
8984 std%U0%X0 %1,%0
8985 li %0,%1
8986 lis %0,%v1
8987 #
8988 {cal|la} %0,%a1
8989 fmr %0,%1
8990 lfd%U1%X1 %0,%1
8991 stfd%U0%X0 %1,%0
8992 mf%1 %0
8993 mt%0 %1
8994 {cror 0,0,0|nop}
8995 mftgpr %0,%1
8996 mffgpr %0,%1"
8997 [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,mfjmpr,mtjmpr,*,mftgpr,mffgpr")
8998 (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4,4,4")])
8999
9000 (define_insn "*movdi_internal64"
9001 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,*f,*f,m,r,*h,*h")
9002 (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0"))]
9003 "TARGET_POWERPC64 && (!TARGET_MFPGPR || !TARGET_HARD_FLOAT || !TARGET_FPRS)
9004 && (gpc_reg_operand (operands[0], DImode)
9005 || gpc_reg_operand (operands[1], DImode))"
9006 "@
9007 mr %0,%1
9008 ld%U1%X1 %0,%1
9009 std%U0%X0 %1,%0
9010 li %0,%1
9011 lis %0,%v1
9012 #
9013 {cal|la} %0,%a1
9014 fmr %0,%1
9015 lfd%U1%X1 %0,%1
9016 stfd%U0%X0 %1,%0
9017 mf%1 %0
9018 mt%0 %1
9019 {cror 0,0,0|nop}"
9020 [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,mfjmpr,mtjmpr,*")
9021 (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
9022
9023 ;; immediate value valid for a single instruction hiding in a const_double
9024 (define_insn ""
9025 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9026 (match_operand:DI 1 "const_double_operand" "F"))]
9027 "HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64
9028 && GET_CODE (operands[1]) == CONST_DOUBLE
9029 && num_insns_constant (operands[1], DImode) == 1"
9030 "*
9031 {
9032 return ((unsigned HOST_WIDE_INT)
9033 (CONST_DOUBLE_LOW (operands[1]) + 0x8000) < 0x10000)
9034 ? \"li %0,%1\" : \"lis %0,%v1\";
9035 }")
9036
9037 ;; Generate all one-bits and clear left or right.
9038 ;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
9039 (define_split
9040 [(set (match_operand:DI 0 "gpc_reg_operand" "")
9041 (match_operand:DI 1 "mask64_operand" ""))]
9042 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
9043 [(set (match_dup 0) (const_int -1))
9044 (set (match_dup 0)
9045 (and:DI (rotate:DI (match_dup 0)
9046 (const_int 0))
9047 (match_dup 1)))]
9048 "")
9049
9050 ;; Split a load of a large constant into the appropriate five-instruction
9051 ;; sequence. Handle anything in a constant number of insns.
9052 ;; When non-easy constants can go in the TOC, this should use
9053 ;; easy_fp_constant predicate.
9054 (define_split
9055 [(set (match_operand:DI 0 "gpc_reg_operand" "")
9056 (match_operand:DI 1 "const_int_operand" ""))]
9057 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
9058 [(set (match_dup 0) (match_dup 2))
9059 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
9060 "
9061 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
9062
9063 if (tem == operands[0])
9064 DONE;
9065 else
9066 FAIL;
9067 }")
9068
9069 (define_split
9070 [(set (match_operand:DI 0 "gpc_reg_operand" "")
9071 (match_operand:DI 1 "const_double_operand" ""))]
9072 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
9073 [(set (match_dup 0) (match_dup 2))
9074 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
9075 "
9076 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
9077
9078 if (tem == operands[0])
9079 DONE;
9080 else
9081 FAIL;
9082 }")
9083 \f
9084 ;; TImode is similar, except that we usually want to compute the address into
9085 ;; a register and use lsi/stsi (the exception is during reload). MQ is also
9086 ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
9087
9088 ;; We say that MQ is clobbered in the last alternative because the first
9089 ;; alternative would never get used otherwise since it would need a reload
9090 ;; while the 2nd alternative would not. We put memory cases first so they
9091 ;; are preferred. Otherwise, we'd try to reload the output instead of
9092 ;; giving the SCRATCH mq.
9093
9094 (define_insn "*movti_power"
9095 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r,r")
9096 (match_operand:TI 1 "input_operand" "r,r,r,Q,m,n"))
9097 (clobber (match_scratch:SI 2 "=q,q#X,X,X,X,X"))]
9098 "TARGET_POWER && ! TARGET_POWERPC64
9099 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
9100 "*
9101 {
9102 switch (which_alternative)
9103 {
9104 default:
9105 gcc_unreachable ();
9106
9107 case 0:
9108 if (TARGET_STRING)
9109 return \"{stsi|stswi} %1,%P0,16\";
9110 case 1:
9111 case 2:
9112 return \"#\";
9113 case 3:
9114 /* If the address is not used in the output, we can use lsi. Otherwise,
9115 fall through to generating four loads. */
9116 if (TARGET_STRING
9117 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
9118 return \"{lsi|lswi} %0,%P1,16\";
9119 /* ... fall through ... */
9120 case 4:
9121 case 5:
9122 return \"#\";
9123 }
9124 }"
9125 [(set_attr "type" "store,store,*,load,load,*")])
9126
9127 (define_insn "*movti_string"
9128 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,o<>,????r,????r,????r,r")
9129 (match_operand:TI 1 "input_operand" "r,r,r,Q,m,n"))]
9130 "! TARGET_POWER && ! TARGET_POWERPC64
9131 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
9132 "*
9133 {
9134 switch (which_alternative)
9135 {
9136 default:
9137 gcc_unreachable ();
9138 case 0:
9139 if (TARGET_STRING)
9140 return \"{stsi|stswi} %1,%P0,16\";
9141 case 1:
9142 case 2:
9143 return \"#\";
9144 case 3:
9145 /* If the address is not used in the output, we can use lsi. Otherwise,
9146 fall through to generating four loads. */
9147 if (TARGET_STRING
9148 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
9149 return \"{lsi|lswi} %0,%P1,16\";
9150 /* ... fall through ... */
9151 case 4:
9152 case 5:
9153 return \"#\";
9154 }
9155 }"
9156 [(set_attr "type" "store_ux,store_ux,*,load_ux,load_ux,*")])
9157
9158 (define_insn "*movti_ppc64"
9159 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o<>,r")
9160 (match_operand:TI 1 "input_operand" "r,r,m"))]
9161 "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
9162 || gpc_reg_operand (operands[1], TImode))"
9163 "#"
9164 [(set_attr "type" "*,load,store")])
9165
9166 (define_split
9167 [(set (match_operand:TI 0 "gpc_reg_operand" "")
9168 (match_operand:TI 1 "const_double_operand" ""))]
9169 "TARGET_POWERPC64"
9170 [(set (match_dup 2) (match_dup 4))
9171 (set (match_dup 3) (match_dup 5))]
9172 "
9173 {
9174 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
9175 TImode);
9176 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
9177 TImode);
9178 if (GET_CODE (operands[1]) == CONST_DOUBLE)
9179 {
9180 operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
9181 operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
9182 }
9183 else if (GET_CODE (operands[1]) == CONST_INT)
9184 {
9185 operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
9186 operands[5] = operands[1];
9187 }
9188 else
9189 FAIL;
9190 }")
9191
9192 (define_split
9193 [(set (match_operand:TI 0 "nonimmediate_operand" "")
9194 (match_operand:TI 1 "input_operand" ""))]
9195 "reload_completed
9196 && gpr_or_gpr_p (operands[0], operands[1])"
9197 [(pc)]
9198 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
9199 \f
9200 (define_expand "load_multiple"
9201 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
9202 (match_operand:SI 1 "" ""))
9203 (use (match_operand:SI 2 "" ""))])]
9204 "TARGET_STRING && !TARGET_POWERPC64"
9205 "
9206 {
9207 int regno;
9208 int count;
9209 rtx op1;
9210 int i;
9211
9212 /* Support only loading a constant number of fixed-point registers from
9213 memory and only bother with this if more than two; the machine
9214 doesn't support more than eight. */
9215 if (GET_CODE (operands[2]) != CONST_INT
9216 || INTVAL (operands[2]) <= 2
9217 || INTVAL (operands[2]) > 8
9218 || GET_CODE (operands[1]) != MEM
9219 || GET_CODE (operands[0]) != REG
9220 || REGNO (operands[0]) >= 32)
9221 FAIL;
9222
9223 count = INTVAL (operands[2]);
9224 regno = REGNO (operands[0]);
9225
9226 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
9227 op1 = replace_equiv_address (operands[1],
9228 force_reg (SImode, XEXP (operands[1], 0)));
9229
9230 for (i = 0; i < count; i++)
9231 XVECEXP (operands[3], 0, i)
9232 = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
9233 adjust_address_nv (op1, SImode, i * 4));
9234 }")
9235
9236 (define_insn "*ldmsi8"
9237 [(match_parallel 0 "load_multiple_operation"
9238 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9239 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9240 (set (match_operand:SI 3 "gpc_reg_operand" "")
9241 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9242 (set (match_operand:SI 4 "gpc_reg_operand" "")
9243 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9244 (set (match_operand:SI 5 "gpc_reg_operand" "")
9245 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
9246 (set (match_operand:SI 6 "gpc_reg_operand" "")
9247 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
9248 (set (match_operand:SI 7 "gpc_reg_operand" "")
9249 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
9250 (set (match_operand:SI 8 "gpc_reg_operand" "")
9251 (mem:SI (plus:SI (match_dup 1) (const_int 24))))
9252 (set (match_operand:SI 9 "gpc_reg_operand" "")
9253 (mem:SI (plus:SI (match_dup 1) (const_int 28))))])]
9254 "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
9255 "*
9256 { return rs6000_output_load_multiple (operands); }"
9257 [(set_attr "type" "load_ux")
9258 (set_attr "length" "32")])
9259
9260 (define_insn "*ldmsi7"
9261 [(match_parallel 0 "load_multiple_operation"
9262 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9263 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9264 (set (match_operand:SI 3 "gpc_reg_operand" "")
9265 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9266 (set (match_operand:SI 4 "gpc_reg_operand" "")
9267 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9268 (set (match_operand:SI 5 "gpc_reg_operand" "")
9269 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
9270 (set (match_operand:SI 6 "gpc_reg_operand" "")
9271 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
9272 (set (match_operand:SI 7 "gpc_reg_operand" "")
9273 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
9274 (set (match_operand:SI 8 "gpc_reg_operand" "")
9275 (mem:SI (plus:SI (match_dup 1) (const_int 24))))])]
9276 "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
9277 "*
9278 { return rs6000_output_load_multiple (operands); }"
9279 [(set_attr "type" "load_ux")
9280 (set_attr "length" "32")])
9281
9282 (define_insn "*ldmsi6"
9283 [(match_parallel 0 "load_multiple_operation"
9284 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9285 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9286 (set (match_operand:SI 3 "gpc_reg_operand" "")
9287 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9288 (set (match_operand:SI 4 "gpc_reg_operand" "")
9289 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9290 (set (match_operand:SI 5 "gpc_reg_operand" "")
9291 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
9292 (set (match_operand:SI 6 "gpc_reg_operand" "")
9293 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
9294 (set (match_operand:SI 7 "gpc_reg_operand" "")
9295 (mem:SI (plus:SI (match_dup 1) (const_int 20))))])]
9296 "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
9297 "*
9298 { return rs6000_output_load_multiple (operands); }"
9299 [(set_attr "type" "load_ux")
9300 (set_attr "length" "32")])
9301
9302 (define_insn "*ldmsi5"
9303 [(match_parallel 0 "load_multiple_operation"
9304 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9305 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9306 (set (match_operand:SI 3 "gpc_reg_operand" "")
9307 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9308 (set (match_operand:SI 4 "gpc_reg_operand" "")
9309 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9310 (set (match_operand:SI 5 "gpc_reg_operand" "")
9311 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
9312 (set (match_operand:SI 6 "gpc_reg_operand" "")
9313 (mem:SI (plus:SI (match_dup 1) (const_int 16))))])]
9314 "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
9315 "*
9316 { return rs6000_output_load_multiple (operands); }"
9317 [(set_attr "type" "load_ux")
9318 (set_attr "length" "32")])
9319
9320 (define_insn "*ldmsi4"
9321 [(match_parallel 0 "load_multiple_operation"
9322 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9323 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9324 (set (match_operand:SI 3 "gpc_reg_operand" "")
9325 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9326 (set (match_operand:SI 4 "gpc_reg_operand" "")
9327 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9328 (set (match_operand:SI 5 "gpc_reg_operand" "")
9329 (mem:SI (plus:SI (match_dup 1) (const_int 12))))])]
9330 "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
9331 "*
9332 { return rs6000_output_load_multiple (operands); }"
9333 [(set_attr "type" "load_ux")
9334 (set_attr "length" "32")])
9335
9336 (define_insn "*ldmsi3"
9337 [(match_parallel 0 "load_multiple_operation"
9338 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9339 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9340 (set (match_operand:SI 3 "gpc_reg_operand" "")
9341 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9342 (set (match_operand:SI 4 "gpc_reg_operand" "")
9343 (mem:SI (plus:SI (match_dup 1) (const_int 8))))])]
9344 "TARGET_STRING && XVECLEN (operands[0], 0) == 3"
9345 "*
9346 { return rs6000_output_load_multiple (operands); }"
9347 [(set_attr "type" "load_ux")
9348 (set_attr "length" "32")])
9349
9350 (define_expand "store_multiple"
9351 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
9352 (match_operand:SI 1 "" ""))
9353 (clobber (scratch:SI))
9354 (use (match_operand:SI 2 "" ""))])]
9355 "TARGET_STRING && !TARGET_POWERPC64"
9356 "
9357 {
9358 int regno;
9359 int count;
9360 rtx to;
9361 rtx op0;
9362 int i;
9363
9364 /* Support only storing a constant number of fixed-point registers to
9365 memory and only bother with this if more than two; the machine
9366 doesn't support more than eight. */
9367 if (GET_CODE (operands[2]) != CONST_INT
9368 || INTVAL (operands[2]) <= 2
9369 || INTVAL (operands[2]) > 8
9370 || GET_CODE (operands[0]) != MEM
9371 || GET_CODE (operands[1]) != REG
9372 || REGNO (operands[1]) >= 32)
9373 FAIL;
9374
9375 count = INTVAL (operands[2]);
9376 regno = REGNO (operands[1]);
9377
9378 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
9379 to = force_reg (SImode, XEXP (operands[0], 0));
9380 op0 = replace_equiv_address (operands[0], to);
9381
9382 XVECEXP (operands[3], 0, 0)
9383 = gen_rtx_SET (VOIDmode, adjust_address_nv (op0, SImode, 0), operands[1]);
9384 XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
9385 gen_rtx_SCRATCH (SImode));
9386
9387 for (i = 1; i < count; i++)
9388 XVECEXP (operands[3], 0, i + 1)
9389 = gen_rtx_SET (VOIDmode,
9390 adjust_address_nv (op0, SImode, i * 4),
9391 gen_rtx_REG (SImode, regno + i));
9392 }")
9393
9394 (define_insn "*stmsi8"
9395 [(match_parallel 0 "store_multiple_operation"
9396 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9397 (match_operand:SI 2 "gpc_reg_operand" "r"))
9398 (clobber (match_scratch:SI 3 "=X"))
9399 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9400 (match_operand:SI 4 "gpc_reg_operand" "r"))
9401 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9402 (match_operand:SI 5 "gpc_reg_operand" "r"))
9403 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9404 (match_operand:SI 6 "gpc_reg_operand" "r"))
9405 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9406 (match_operand:SI 7 "gpc_reg_operand" "r"))
9407 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9408 (match_operand:SI 8 "gpc_reg_operand" "r"))
9409 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9410 (match_operand:SI 9 "gpc_reg_operand" "r"))
9411 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
9412 (match_operand:SI 10 "gpc_reg_operand" "r"))])]
9413 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 9"
9414 "{stsi|stswi} %2,%1,%O0"
9415 [(set_attr "type" "store_ux")])
9416
9417 (define_insn "*stmsi7"
9418 [(match_parallel 0 "store_multiple_operation"
9419 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9420 (match_operand:SI 2 "gpc_reg_operand" "r"))
9421 (clobber (match_scratch:SI 3 "=X"))
9422 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9423 (match_operand:SI 4 "gpc_reg_operand" "r"))
9424 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9425 (match_operand:SI 5 "gpc_reg_operand" "r"))
9426 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9427 (match_operand:SI 6 "gpc_reg_operand" "r"))
9428 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9429 (match_operand:SI 7 "gpc_reg_operand" "r"))
9430 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9431 (match_operand:SI 8 "gpc_reg_operand" "r"))
9432 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9433 (match_operand:SI 9 "gpc_reg_operand" "r"))])]
9434 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 8"
9435 "{stsi|stswi} %2,%1,%O0"
9436 [(set_attr "type" "store_ux")])
9437
9438 (define_insn "*stmsi6"
9439 [(match_parallel 0 "store_multiple_operation"
9440 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9441 (match_operand:SI 2 "gpc_reg_operand" "r"))
9442 (clobber (match_scratch:SI 3 "=X"))
9443 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9444 (match_operand:SI 4 "gpc_reg_operand" "r"))
9445 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9446 (match_operand:SI 5 "gpc_reg_operand" "r"))
9447 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9448 (match_operand:SI 6 "gpc_reg_operand" "r"))
9449 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9450 (match_operand:SI 7 "gpc_reg_operand" "r"))
9451 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9452 (match_operand:SI 8 "gpc_reg_operand" "r"))])]
9453 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 7"
9454 "{stsi|stswi} %2,%1,%O0"
9455 [(set_attr "type" "store_ux")])
9456
9457 (define_insn "*stmsi5"
9458 [(match_parallel 0 "store_multiple_operation"
9459 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9460 (match_operand:SI 2 "gpc_reg_operand" "r"))
9461 (clobber (match_scratch:SI 3 "=X"))
9462 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9463 (match_operand:SI 4 "gpc_reg_operand" "r"))
9464 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9465 (match_operand:SI 5 "gpc_reg_operand" "r"))
9466 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9467 (match_operand:SI 6 "gpc_reg_operand" "r"))
9468 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9469 (match_operand:SI 7 "gpc_reg_operand" "r"))])]
9470 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 6"
9471 "{stsi|stswi} %2,%1,%O0"
9472 [(set_attr "type" "store_ux")])
9473
9474 (define_insn "*stmsi4"
9475 [(match_parallel 0 "store_multiple_operation"
9476 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9477 (match_operand:SI 2 "gpc_reg_operand" "r"))
9478 (clobber (match_scratch:SI 3 "=X"))
9479 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9480 (match_operand:SI 4 "gpc_reg_operand" "r"))
9481 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9482 (match_operand:SI 5 "gpc_reg_operand" "r"))
9483 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9484 (match_operand:SI 6 "gpc_reg_operand" "r"))])]
9485 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 5"
9486 "{stsi|stswi} %2,%1,%O0"
9487 [(set_attr "type" "store_ux")])
9488
9489 (define_insn "*stmsi3"
9490 [(match_parallel 0 "store_multiple_operation"
9491 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9492 (match_operand:SI 2 "gpc_reg_operand" "r"))
9493 (clobber (match_scratch:SI 3 "=X"))
9494 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9495 (match_operand:SI 4 "gpc_reg_operand" "r"))
9496 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9497 (match_operand:SI 5 "gpc_reg_operand" "r"))])]
9498 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 4"
9499 "{stsi|stswi} %2,%1,%O0"
9500 [(set_attr "type" "store_ux")])
9501
9502 (define_insn "*stmsi8_power"
9503 [(match_parallel 0 "store_multiple_operation"
9504 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9505 (match_operand:SI 2 "gpc_reg_operand" "r"))
9506 (clobber (match_scratch:SI 3 "=q"))
9507 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9508 (match_operand:SI 4 "gpc_reg_operand" "r"))
9509 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9510 (match_operand:SI 5 "gpc_reg_operand" "r"))
9511 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9512 (match_operand:SI 6 "gpc_reg_operand" "r"))
9513 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9514 (match_operand:SI 7 "gpc_reg_operand" "r"))
9515 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9516 (match_operand:SI 8 "gpc_reg_operand" "r"))
9517 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9518 (match_operand:SI 9 "gpc_reg_operand" "r"))
9519 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
9520 (match_operand:SI 10 "gpc_reg_operand" "r"))])]
9521 "TARGET_STRING && TARGET_POWER && XVECLEN (operands[0], 0) == 9"
9522 "{stsi|stswi} %2,%1,%O0"
9523 [(set_attr "type" "store_ux")])
9524
9525 (define_insn "*stmsi7_power"
9526 [(match_parallel 0 "store_multiple_operation"
9527 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9528 (match_operand:SI 2 "gpc_reg_operand" "r"))
9529 (clobber (match_scratch:SI 3 "=q"))
9530 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9531 (match_operand:SI 4 "gpc_reg_operand" "r"))
9532 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9533 (match_operand:SI 5 "gpc_reg_operand" "r"))
9534 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9535 (match_operand:SI 6 "gpc_reg_operand" "r"))
9536 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9537 (match_operand:SI 7 "gpc_reg_operand" "r"))
9538 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9539 (match_operand:SI 8 "gpc_reg_operand" "r"))
9540 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9541 (match_operand:SI 9 "gpc_reg_operand" "r"))])]
9542 "TARGET_STRING && TARGET_POWER && XVECLEN (operands[0], 0) == 8"
9543 "{stsi|stswi} %2,%1,%O0"
9544 [(set_attr "type" "store_ux")])
9545
9546 (define_insn "*stmsi6_power"
9547 [(match_parallel 0 "store_multiple_operation"
9548 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9549 (match_operand:SI 2 "gpc_reg_operand" "r"))
9550 (clobber (match_scratch:SI 3 "=q"))
9551 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9552 (match_operand:SI 4 "gpc_reg_operand" "r"))
9553 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9554 (match_operand:SI 5 "gpc_reg_operand" "r"))
9555 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9556 (match_operand:SI 6 "gpc_reg_operand" "r"))
9557 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9558 (match_operand:SI 7 "gpc_reg_operand" "r"))
9559 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9560 (match_operand:SI 8 "gpc_reg_operand" "r"))])]
9561 "TARGET_STRING && TARGET_POWER && XVECLEN (operands[0], 0) == 7"
9562 "{stsi|stswi} %2,%1,%O0"
9563 [(set_attr "type" "store_ux")])
9564
9565 (define_insn "*stmsi5_power"
9566 [(match_parallel 0 "store_multiple_operation"
9567 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9568 (match_operand:SI 2 "gpc_reg_operand" "r"))
9569 (clobber (match_scratch:SI 3 "=q"))
9570 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9571 (match_operand:SI 4 "gpc_reg_operand" "r"))
9572 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9573 (match_operand:SI 5 "gpc_reg_operand" "r"))
9574 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9575 (match_operand:SI 6 "gpc_reg_operand" "r"))
9576 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9577 (match_operand:SI 7 "gpc_reg_operand" "r"))])]
9578 "TARGET_STRING && TARGET_POWER && XVECLEN (operands[0], 0) == 6"
9579 "{stsi|stswi} %2,%1,%O0"
9580 [(set_attr "type" "store_ux")])
9581
9582 (define_insn "*stmsi4_power"
9583 [(match_parallel 0 "store_multiple_operation"
9584 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9585 (match_operand:SI 2 "gpc_reg_operand" "r"))
9586 (clobber (match_scratch:SI 3 "=q"))
9587 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9588 (match_operand:SI 4 "gpc_reg_operand" "r"))
9589 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9590 (match_operand:SI 5 "gpc_reg_operand" "r"))
9591 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9592 (match_operand:SI 6 "gpc_reg_operand" "r"))])]
9593 "TARGET_STRING && TARGET_POWER && XVECLEN (operands[0], 0) == 5"
9594 "{stsi|stswi} %2,%1,%O0"
9595 [(set_attr "type" "store_ux")])
9596
9597 (define_insn "*stmsi3_power"
9598 [(match_parallel 0 "store_multiple_operation"
9599 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9600 (match_operand:SI 2 "gpc_reg_operand" "r"))
9601 (clobber (match_scratch:SI 3 "=q"))
9602 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9603 (match_operand:SI 4 "gpc_reg_operand" "r"))
9604 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9605 (match_operand:SI 5 "gpc_reg_operand" "r"))])]
9606 "TARGET_STRING && TARGET_POWER && XVECLEN (operands[0], 0) == 4"
9607 "{stsi|stswi} %2,%1,%O0"
9608 [(set_attr "type" "store_ux")])
9609 \f
9610 (define_expand "setmemsi"
9611 [(parallel [(set (match_operand:BLK 0 "" "")
9612 (match_operand 2 "const_int_operand" ""))
9613 (use (match_operand:SI 1 "" ""))
9614 (use (match_operand:SI 3 "" ""))])]
9615 ""
9616 "
9617 {
9618 /* If value to set is not zero, use the library routine. */
9619 if (operands[2] != const0_rtx)
9620 FAIL;
9621
9622 if (expand_block_clear (operands))
9623 DONE;
9624 else
9625 FAIL;
9626 }")
9627
9628 ;; String/block move insn.
9629 ;; Argument 0 is the destination
9630 ;; Argument 1 is the source
9631 ;; Argument 2 is the length
9632 ;; Argument 3 is the alignment
9633
9634 (define_expand "movmemsi"
9635 [(parallel [(set (match_operand:BLK 0 "" "")
9636 (match_operand:BLK 1 "" ""))
9637 (use (match_operand:SI 2 "" ""))
9638 (use (match_operand:SI 3 "" ""))])]
9639 ""
9640 "
9641 {
9642 if (expand_block_move (operands))
9643 DONE;
9644 else
9645 FAIL;
9646 }")
9647
9648 ;; Move up to 32 bytes at a time. The fixed registers are needed because the
9649 ;; register allocator doesn't have a clue about allocating 8 word registers.
9650 ;; rD/rS = r5 is preferred, efficient form.
9651 (define_expand "movmemsi_8reg"
9652 [(parallel [(set (match_operand 0 "" "")
9653 (match_operand 1 "" ""))
9654 (use (match_operand 2 "" ""))
9655 (use (match_operand 3 "" ""))
9656 (clobber (reg:SI 5))
9657 (clobber (reg:SI 6))
9658 (clobber (reg:SI 7))
9659 (clobber (reg:SI 8))
9660 (clobber (reg:SI 9))
9661 (clobber (reg:SI 10))
9662 (clobber (reg:SI 11))
9663 (clobber (reg:SI 12))
9664 (clobber (match_scratch:SI 4 ""))])]
9665 "TARGET_STRING"
9666 "")
9667
9668 (define_insn ""
9669 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9670 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9671 (use (match_operand:SI 2 "immediate_operand" "i"))
9672 (use (match_operand:SI 3 "immediate_operand" "i"))
9673 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9674 (clobber (reg:SI 6))
9675 (clobber (reg:SI 7))
9676 (clobber (reg:SI 8))
9677 (clobber (reg:SI 9))
9678 (clobber (reg:SI 10))
9679 (clobber (reg:SI 11))
9680 (clobber (reg:SI 12))
9681 (clobber (match_scratch:SI 5 "=q"))]
9682 "TARGET_STRING && TARGET_POWER
9683 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9684 || INTVAL (operands[2]) == 0)
9685 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9686 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9687 && REGNO (operands[4]) == 5"
9688 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9689 [(set_attr "type" "store_ux")
9690 (set_attr "length" "8")])
9691
9692 (define_insn ""
9693 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9694 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9695 (use (match_operand:SI 2 "immediate_operand" "i"))
9696 (use (match_operand:SI 3 "immediate_operand" "i"))
9697 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9698 (clobber (reg:SI 6))
9699 (clobber (reg:SI 7))
9700 (clobber (reg:SI 8))
9701 (clobber (reg:SI 9))
9702 (clobber (reg:SI 10))
9703 (clobber (reg:SI 11))
9704 (clobber (reg:SI 12))
9705 (clobber (match_scratch:SI 5 "=X"))]
9706 "TARGET_STRING && ! TARGET_POWER
9707 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9708 || INTVAL (operands[2]) == 0)
9709 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9710 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9711 && REGNO (operands[4]) == 5"
9712 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9713 [(set_attr "type" "store_ux")
9714 (set_attr "length" "8")])
9715
9716 ;; Move up to 24 bytes at a time. The fixed registers are needed because the
9717 ;; register allocator doesn't have a clue about allocating 6 word registers.
9718 ;; rD/rS = r5 is preferred, efficient form.
9719 (define_expand "movmemsi_6reg"
9720 [(parallel [(set (match_operand 0 "" "")
9721 (match_operand 1 "" ""))
9722 (use (match_operand 2 "" ""))
9723 (use (match_operand 3 "" ""))
9724 (clobber (reg:SI 5))
9725 (clobber (reg:SI 6))
9726 (clobber (reg:SI 7))
9727 (clobber (reg:SI 8))
9728 (clobber (reg:SI 9))
9729 (clobber (reg:SI 10))
9730 (clobber (match_scratch:SI 4 ""))])]
9731 "TARGET_STRING"
9732 "")
9733
9734 (define_insn ""
9735 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9736 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9737 (use (match_operand:SI 2 "immediate_operand" "i"))
9738 (use (match_operand:SI 3 "immediate_operand" "i"))
9739 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9740 (clobber (reg:SI 6))
9741 (clobber (reg:SI 7))
9742 (clobber (reg:SI 8))
9743 (clobber (reg:SI 9))
9744 (clobber (reg:SI 10))
9745 (clobber (match_scratch:SI 5 "=q"))]
9746 "TARGET_STRING && TARGET_POWER
9747 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
9748 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9749 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9750 && REGNO (operands[4]) == 5"
9751 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9752 [(set_attr "type" "store_ux")
9753 (set_attr "length" "8")])
9754
9755 (define_insn ""
9756 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9757 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9758 (use (match_operand:SI 2 "immediate_operand" "i"))
9759 (use (match_operand:SI 3 "immediate_operand" "i"))
9760 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9761 (clobber (reg:SI 6))
9762 (clobber (reg:SI 7))
9763 (clobber (reg:SI 8))
9764 (clobber (reg:SI 9))
9765 (clobber (reg:SI 10))
9766 (clobber (match_scratch:SI 5 "=X"))]
9767 "TARGET_STRING && ! TARGET_POWER
9768 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9769 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9770 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9771 && REGNO (operands[4]) == 5"
9772 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9773 [(set_attr "type" "store_ux")
9774 (set_attr "length" "8")])
9775
9776 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
9777 ;; problems with TImode.
9778 ;; rD/rS = r5 is preferred, efficient form.
9779 (define_expand "movmemsi_4reg"
9780 [(parallel [(set (match_operand 0 "" "")
9781 (match_operand 1 "" ""))
9782 (use (match_operand 2 "" ""))
9783 (use (match_operand 3 "" ""))
9784 (clobber (reg:SI 5))
9785 (clobber (reg:SI 6))
9786 (clobber (reg:SI 7))
9787 (clobber (reg:SI 8))
9788 (clobber (match_scratch:SI 4 ""))])]
9789 "TARGET_STRING"
9790 "")
9791
9792 (define_insn ""
9793 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9794 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9795 (use (match_operand:SI 2 "immediate_operand" "i"))
9796 (use (match_operand:SI 3 "immediate_operand" "i"))
9797 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9798 (clobber (reg:SI 6))
9799 (clobber (reg:SI 7))
9800 (clobber (reg:SI 8))
9801 (clobber (match_scratch:SI 5 "=q"))]
9802 "TARGET_STRING && TARGET_POWER
9803 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9804 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9805 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9806 && REGNO (operands[4]) == 5"
9807 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9808 [(set_attr "type" "store_ux")
9809 (set_attr "length" "8")])
9810
9811 (define_insn ""
9812 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9813 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9814 (use (match_operand:SI 2 "immediate_operand" "i"))
9815 (use (match_operand:SI 3 "immediate_operand" "i"))
9816 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9817 (clobber (reg:SI 6))
9818 (clobber (reg:SI 7))
9819 (clobber (reg:SI 8))
9820 (clobber (match_scratch:SI 5 "=X"))]
9821 "TARGET_STRING && ! TARGET_POWER
9822 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9823 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9824 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9825 && REGNO (operands[4]) == 5"
9826 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9827 [(set_attr "type" "store_ux")
9828 (set_attr "length" "8")])
9829
9830 ;; Move up to 8 bytes at a time.
9831 (define_expand "movmemsi_2reg"
9832 [(parallel [(set (match_operand 0 "" "")
9833 (match_operand 1 "" ""))
9834 (use (match_operand 2 "" ""))
9835 (use (match_operand 3 "" ""))
9836 (clobber (match_scratch:DI 4 ""))
9837 (clobber (match_scratch:SI 5 ""))])]
9838 "TARGET_STRING && ! TARGET_POWERPC64"
9839 "")
9840
9841 (define_insn ""
9842 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9843 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9844 (use (match_operand:SI 2 "immediate_operand" "i"))
9845 (use (match_operand:SI 3 "immediate_operand" "i"))
9846 (clobber (match_scratch:DI 4 "=&r"))
9847 (clobber (match_scratch:SI 5 "=q"))]
9848 "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
9849 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9850 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9851 [(set_attr "type" "store_ux")
9852 (set_attr "length" "8")])
9853
9854 (define_insn ""
9855 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9856 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9857 (use (match_operand:SI 2 "immediate_operand" "i"))
9858 (use (match_operand:SI 3 "immediate_operand" "i"))
9859 (clobber (match_scratch:DI 4 "=&r"))
9860 (clobber (match_scratch:SI 5 "=X"))]
9861 "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
9862 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9863 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9864 [(set_attr "type" "store_ux")
9865 (set_attr "length" "8")])
9866
9867 ;; Move up to 4 bytes at a time.
9868 (define_expand "movmemsi_1reg"
9869 [(parallel [(set (match_operand 0 "" "")
9870 (match_operand 1 "" ""))
9871 (use (match_operand 2 "" ""))
9872 (use (match_operand 3 "" ""))
9873 (clobber (match_scratch:SI 4 ""))
9874 (clobber (match_scratch:SI 5 ""))])]
9875 "TARGET_STRING"
9876 "")
9877
9878 (define_insn ""
9879 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9880 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9881 (use (match_operand:SI 2 "immediate_operand" "i"))
9882 (use (match_operand:SI 3 "immediate_operand" "i"))
9883 (clobber (match_scratch:SI 4 "=&r"))
9884 (clobber (match_scratch:SI 5 "=q"))]
9885 "TARGET_STRING && TARGET_POWER
9886 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9887 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9888 [(set_attr "type" "store_ux")
9889 (set_attr "length" "8")])
9890
9891 (define_insn ""
9892 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9893 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9894 (use (match_operand:SI 2 "immediate_operand" "i"))
9895 (use (match_operand:SI 3 "immediate_operand" "i"))
9896 (clobber (match_scratch:SI 4 "=&r"))
9897 (clobber (match_scratch:SI 5 "=X"))]
9898 "TARGET_STRING && ! TARGET_POWER
9899 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9900 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9901 [(set_attr "type" "store_ux")
9902 (set_attr "length" "8")])
9903 \f
9904 ;; Define insns that do load or store with update. Some of these we can
9905 ;; get by using pre-decrement or pre-increment, but the hardware can also
9906 ;; do cases where the increment is not the size of the object.
9907 ;;
9908 ;; In all these cases, we use operands 0 and 1 for the register being
9909 ;; incremented because those are the operands that local-alloc will
9910 ;; tie and these are the pair most likely to be tieable (and the ones
9911 ;; that will benefit the most).
9912
9913 (define_insn "*movdi_update1"
9914 [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
9915 (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9916 (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
9917 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9918 (plus:DI (match_dup 1) (match_dup 2)))]
9919 "TARGET_POWERPC64 && TARGET_UPDATE"
9920 "@
9921 ldux %3,%0,%2
9922 ldu %3,%2(%0)"
9923 [(set_attr "type" "load_ux,load_u")])
9924
9925 (define_insn "movdi_<mode>_update"
9926 [(set (mem:DI (plus:P (match_operand:P 1 "gpc_reg_operand" "0,0")
9927 (match_operand:P 2 "reg_or_aligned_short_operand" "r,I")))
9928 (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9929 (set (match_operand:P 0 "gpc_reg_operand" "=b,b")
9930 (plus:P (match_dup 1) (match_dup 2)))]
9931 "TARGET_POWERPC64 && TARGET_UPDATE"
9932 "@
9933 stdux %3,%0,%2
9934 stdu %3,%2(%0)"
9935 [(set_attr "type" "store_ux,store_u")])
9936
9937 (define_insn "*movsi_update1"
9938 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9939 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9940 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9941 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9942 (plus:SI (match_dup 1) (match_dup 2)))]
9943 "TARGET_UPDATE"
9944 "@
9945 {lux|lwzux} %3,%0,%2
9946 {lu|lwzu} %3,%2(%0)"
9947 [(set_attr "type" "load_ux,load_u")])
9948
9949 (define_insn "*movsi_update2"
9950 [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
9951 (sign_extend:DI
9952 (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
9953 (match_operand:DI 2 "gpc_reg_operand" "r")))))
9954 (set (match_operand:DI 0 "gpc_reg_operand" "=b")
9955 (plus:DI (match_dup 1) (match_dup 2)))]
9956 "TARGET_POWERPC64"
9957 "lwaux %3,%0,%2"
9958 [(set_attr "type" "load_ext_ux")])
9959
9960 (define_insn "movsi_update"
9961 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9962 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9963 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9964 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9965 (plus:SI (match_dup 1) (match_dup 2)))]
9966 "TARGET_UPDATE"
9967 "@
9968 {stux|stwux} %3,%0,%2
9969 {stu|stwu} %3,%2(%0)"
9970 [(set_attr "type" "store_ux,store_u")])
9971
9972 (define_insn "*movhi_update1"
9973 [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
9974 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9975 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9976 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9977 (plus:SI (match_dup 1) (match_dup 2)))]
9978 "TARGET_UPDATE"
9979 "@
9980 lhzux %3,%0,%2
9981 lhzu %3,%2(%0)"
9982 [(set_attr "type" "load_ux,load_u")])
9983
9984 (define_insn "*movhi_update2"
9985 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9986 (zero_extend:SI
9987 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9988 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9989 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9990 (plus:SI (match_dup 1) (match_dup 2)))]
9991 "TARGET_UPDATE"
9992 "@
9993 lhzux %3,%0,%2
9994 lhzu %3,%2(%0)"
9995 [(set_attr "type" "load_ux,load_u")])
9996
9997 (define_insn "*movhi_update3"
9998 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9999 (sign_extend:SI
10000 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10001 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
10002 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10003 (plus:SI (match_dup 1) (match_dup 2)))]
10004 "TARGET_UPDATE"
10005 "@
10006 lhaux %3,%0,%2
10007 lhau %3,%2(%0)"
10008 [(set_attr "type" "load_ext_ux,load_ext_u")])
10009
10010 (define_insn "*movhi_update4"
10011 [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10012 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
10013 (match_operand:HI 3 "gpc_reg_operand" "r,r"))
10014 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10015 (plus:SI (match_dup 1) (match_dup 2)))]
10016 "TARGET_UPDATE"
10017 "@
10018 sthux %3,%0,%2
10019 sthu %3,%2(%0)"
10020 [(set_attr "type" "store_ux,store_u")])
10021
10022 (define_insn "*movqi_update1"
10023 [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
10024 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10025 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
10026 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10027 (plus:SI (match_dup 1) (match_dup 2)))]
10028 "TARGET_UPDATE"
10029 "@
10030 lbzux %3,%0,%2
10031 lbzu %3,%2(%0)"
10032 [(set_attr "type" "load_ux,load_u")])
10033
10034 (define_insn "*movqi_update2"
10035 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
10036 (zero_extend:SI
10037 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10038 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
10039 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10040 (plus:SI (match_dup 1) (match_dup 2)))]
10041 "TARGET_UPDATE"
10042 "@
10043 lbzux %3,%0,%2
10044 lbzu %3,%2(%0)"
10045 [(set_attr "type" "load_ux,load_u")])
10046
10047 (define_insn "*movqi_update3"
10048 [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10049 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
10050 (match_operand:QI 3 "gpc_reg_operand" "r,r"))
10051 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10052 (plus:SI (match_dup 1) (match_dup 2)))]
10053 "TARGET_UPDATE"
10054 "@
10055 stbux %3,%0,%2
10056 stbu %3,%2(%0)"
10057 [(set_attr "type" "store_ux,store_u")])
10058
10059 (define_insn "*movsf_update1"
10060 [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
10061 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10062 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
10063 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10064 (plus:SI (match_dup 1) (match_dup 2)))]
10065 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
10066 "@
10067 lfsux %3,%0,%2
10068 lfsu %3,%2(%0)"
10069 [(set_attr "type" "fpload_ux,fpload_u")])
10070
10071 (define_insn "*movsf_update2"
10072 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10073 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
10074 (match_operand:SF 3 "gpc_reg_operand" "f,f"))
10075 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10076 (plus:SI (match_dup 1) (match_dup 2)))]
10077 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
10078 "@
10079 stfsux %3,%0,%2
10080 stfsu %3,%2(%0)"
10081 [(set_attr "type" "fpstore_ux,fpstore_u")])
10082
10083 (define_insn "*movsf_update3"
10084 [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
10085 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10086 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
10087 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10088 (plus:SI (match_dup 1) (match_dup 2)))]
10089 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
10090 "@
10091 {lux|lwzux} %3,%0,%2
10092 {lu|lwzu} %3,%2(%0)"
10093 [(set_attr "type" "load_ux,load_u")])
10094
10095 (define_insn "*movsf_update4"
10096 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10097 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
10098 (match_operand:SF 3 "gpc_reg_operand" "r,r"))
10099 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10100 (plus:SI (match_dup 1) (match_dup 2)))]
10101 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
10102 "@
10103 {stux|stwux} %3,%0,%2
10104 {stu|stwu} %3,%2(%0)"
10105 [(set_attr "type" "store_ux,store_u")])
10106
10107 (define_insn "*movdf_update1"
10108 [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
10109 (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10110 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
10111 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10112 (plus:SI (match_dup 1) (match_dup 2)))]
10113 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
10114 "@
10115 lfdux %3,%0,%2
10116 lfdu %3,%2(%0)"
10117 [(set_attr "type" "fpload_ux,fpload_u")])
10118
10119 (define_insn "*movdf_update2"
10120 [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10121 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
10122 (match_operand:DF 3 "gpc_reg_operand" "f,f"))
10123 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10124 (plus:SI (match_dup 1) (match_dup 2)))]
10125 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
10126 "@
10127 stfdux %3,%0,%2
10128 stfdu %3,%2(%0)"
10129 [(set_attr "type" "fpstore_ux,fpstore_u")])
10130
10131 ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
10132
10133 (define_insn "*lfq_power2"
10134 [(set (match_operand:V2DF 0 "gpc_reg_operand" "=f")
10135 (match_operand:V2DF 1 "memory_operand" ""))]
10136 "TARGET_POWER2
10137 && TARGET_HARD_FLOAT && TARGET_FPRS"
10138 "lfq%U1%X1 %0,%1")
10139
10140 (define_peephole2
10141 [(set (match_operand:DF 0 "gpc_reg_operand" "")
10142 (match_operand:DF 1 "memory_operand" ""))
10143 (set (match_operand:DF 2 "gpc_reg_operand" "")
10144 (match_operand:DF 3 "memory_operand" ""))]
10145 "TARGET_POWER2
10146 && TARGET_HARD_FLOAT && TARGET_FPRS
10147 && registers_ok_for_quad_peep (operands[0], operands[2])
10148 && mems_ok_for_quad_peep (operands[1], operands[3])"
10149 [(set (match_dup 0)
10150 (match_dup 1))]
10151 "operands[1] = widen_memory_access (operands[1], V2DFmode, 0);
10152 operands[0] = gen_rtx_REG (V2DFmode, REGNO (operands[0]));")
10153
10154 (define_insn "*stfq_power2"
10155 [(set (match_operand:V2DF 0 "memory_operand" "")
10156 (match_operand:V2DF 1 "gpc_reg_operand" "f"))]
10157 "TARGET_POWER2
10158 && TARGET_HARD_FLOAT && TARGET_FPRS"
10159 "stfq%U0%X0 %1,%0")
10160
10161
10162 (define_peephole2
10163 [(set (match_operand:DF 0 "memory_operand" "")
10164 (match_operand:DF 1 "gpc_reg_operand" ""))
10165 (set (match_operand:DF 2 "memory_operand" "")
10166 (match_operand:DF 3 "gpc_reg_operand" ""))]
10167 "TARGET_POWER2
10168 && TARGET_HARD_FLOAT && TARGET_FPRS
10169 && registers_ok_for_quad_peep (operands[1], operands[3])
10170 && mems_ok_for_quad_peep (operands[0], operands[2])"
10171 [(set (match_dup 0)
10172 (match_dup 1))]
10173 "operands[0] = widen_memory_access (operands[0], V2DFmode, 0);
10174 operands[1] = gen_rtx_REG (V2DFmode, REGNO (operands[1]));")
10175
10176 ;; After inserting conditional returns we can sometimes have
10177 ;; unnecessary register moves. Unfortunately we cannot have a
10178 ;; modeless peephole here, because some single SImode sets have early
10179 ;; clobber outputs. Although those sets expand to multi-ppc-insn
10180 ;; sequences, using get_attr_length here will smash the operands
10181 ;; array. Neither is there an early_cobbler_p predicate.
10182 ;; Disallow subregs for E500 so we don't munge frob_di_df_2.
10183 (define_peephole2
10184 [(set (match_operand:DF 0 "gpc_reg_operand" "")
10185 (match_operand:DF 1 "any_operand" ""))
10186 (set (match_operand:DF 2 "gpc_reg_operand" "")
10187 (match_dup 0))]
10188 "!(TARGET_E500_DOUBLE && GET_CODE (operands[2]) == SUBREG)
10189 && peep2_reg_dead_p (2, operands[0])"
10190 [(set (match_dup 2) (match_dup 1))])
10191
10192 (define_peephole2
10193 [(set (match_operand:SF 0 "gpc_reg_operand" "")
10194 (match_operand:SF 1 "any_operand" ""))
10195 (set (match_operand:SF 2 "gpc_reg_operand" "")
10196 (match_dup 0))]
10197 "peep2_reg_dead_p (2, operands[0])"
10198 [(set (match_dup 2) (match_dup 1))])
10199
10200 \f
10201 ;; TLS support.
10202
10203 ;; Mode attributes for different ABIs.
10204 (define_mode_iterator TLSmode [(SI "! TARGET_64BIT") (DI "TARGET_64BIT")])
10205 (define_mode_attr tls_abi_suffix [(SI "32") (DI "64")])
10206 (define_mode_attr tls_sysv_suffix [(SI "si") (DI "di")])
10207 (define_mode_attr tls_insn_suffix [(SI "wz") (DI "d")])
10208
10209 (define_insn "tls_gd_aix<TLSmode:tls_abi_suffix>"
10210 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10211 (call (mem:TLSmode (match_operand:TLSmode 3 "symbol_ref_operand" "s"))
10212 (match_operand 4 "" "g")))
10213 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10214 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10215 UNSPEC_TLSGD)
10216 (clobber (reg:SI LR_REGNO))]
10217 "HAVE_AS_TLS && DEFAULT_ABI == ABI_AIX"
10218 "addi %0,%1,%2@got@tlsgd\;bl %z3\;%."
10219 [(set_attr "type" "two")
10220 (set_attr "length" "12")])
10221
10222 (define_insn "tls_gd_sysv<TLSmode:tls_sysv_suffix>"
10223 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10224 (call (mem:TLSmode (match_operand:TLSmode 3 "symbol_ref_operand" "s"))
10225 (match_operand 4 "" "g")))
10226 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10227 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10228 UNSPEC_TLSGD)
10229 (clobber (reg:SI LR_REGNO))]
10230 "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4"
10231 {
10232 if (flag_pic)
10233 {
10234 if (TARGET_SECURE_PLT && flag_pic == 2)
10235 return "addi %0,%1,%2@got@tlsgd\;bl %z3+32768@plt";
10236 else
10237 return "addi %0,%1,%2@got@tlsgd\;bl %z3@plt";
10238 }
10239 else
10240 return "addi %0,%1,%2@got@tlsgd\;bl %z3";
10241 }
10242 [(set_attr "type" "two")
10243 (set_attr "length" "8")])
10244
10245 (define_insn "tls_ld_aix<TLSmode:tls_abi_suffix>"
10246 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10247 (call (mem:TLSmode (match_operand:TLSmode 2 "symbol_ref_operand" "s"))
10248 (match_operand 3 "" "g")))
10249 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
10250 UNSPEC_TLSLD)
10251 (clobber (reg:SI LR_REGNO))]
10252 "HAVE_AS_TLS && DEFAULT_ABI == ABI_AIX"
10253 "addi %0,%1,%&@got@tlsld\;bl %z2\;%."
10254 [(set_attr "length" "12")])
10255
10256 (define_insn "tls_ld_sysv<TLSmode:tls_sysv_suffix>"
10257 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10258 (call (mem:TLSmode (match_operand:TLSmode 2 "symbol_ref_operand" "s"))
10259 (match_operand 3 "" "g")))
10260 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
10261 UNSPEC_TLSLD)
10262 (clobber (reg:SI LR_REGNO))]
10263 "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4"
10264 {
10265 if (flag_pic)
10266 {
10267 if (TARGET_SECURE_PLT && flag_pic == 2)
10268 return "addi %0,%1,%&@got@tlsld\;bl %z2+32768@plt";
10269 else
10270 return "addi %0,%1,%&@got@tlsld\;bl %z2@plt";
10271 }
10272 else
10273 return "addi %0,%1,%&@got@tlsld\;bl %z2";
10274 }
10275 [(set_attr "length" "8")])
10276
10277 (define_insn "tls_dtprel_<TLSmode:tls_abi_suffix>"
10278 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10279 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10280 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10281 UNSPEC_TLSDTPREL))]
10282 "HAVE_AS_TLS"
10283 "addi %0,%1,%2@dtprel")
10284
10285 (define_insn "tls_dtprel_ha_<TLSmode:tls_abi_suffix>"
10286 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10287 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10288 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10289 UNSPEC_TLSDTPRELHA))]
10290 "HAVE_AS_TLS"
10291 "addis %0,%1,%2@dtprel@ha")
10292
10293 (define_insn "tls_dtprel_lo_<TLSmode:tls_abi_suffix>"
10294 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10295 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10296 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10297 UNSPEC_TLSDTPRELLO))]
10298 "HAVE_AS_TLS"
10299 "addi %0,%1,%2@dtprel@l")
10300
10301 (define_insn "tls_got_dtprel_<TLSmode:tls_abi_suffix>"
10302 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10303 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10304 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10305 UNSPEC_TLSGOTDTPREL))]
10306 "HAVE_AS_TLS"
10307 "l<TLSmode:tls_insn_suffix> %0,%2@got@dtprel(%1)")
10308
10309 (define_insn "tls_tprel_<TLSmode:tls_abi_suffix>"
10310 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10311 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10312 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10313 UNSPEC_TLSTPREL))]
10314 "HAVE_AS_TLS"
10315 "addi %0,%1,%2@tprel")
10316
10317 (define_insn "tls_tprel_ha_<TLSmode:tls_abi_suffix>"
10318 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10319 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10320 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10321 UNSPEC_TLSTPRELHA))]
10322 "HAVE_AS_TLS"
10323 "addis %0,%1,%2@tprel@ha")
10324
10325 (define_insn "tls_tprel_lo_<TLSmode:tls_abi_suffix>"
10326 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10327 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10328 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10329 UNSPEC_TLSTPRELLO))]
10330 "HAVE_AS_TLS"
10331 "addi %0,%1,%2@tprel@l")
10332
10333 ;; "b" output constraint here and on tls_tls input to support linker tls
10334 ;; optimization. The linker may edit the instructions emitted by a
10335 ;; tls_got_tprel/tls_tls pair to addis,addi.
10336 (define_insn "tls_got_tprel_<TLSmode:tls_abi_suffix>"
10337 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10338 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10339 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10340 UNSPEC_TLSGOTTPREL))]
10341 "HAVE_AS_TLS"
10342 "l<TLSmode:tls_insn_suffix> %0,%2@got@tprel(%1)")
10343
10344 (define_insn "tls_tls_<TLSmode:tls_abi_suffix>"
10345 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10346 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10347 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10348 UNSPEC_TLSTLS))]
10349 "HAVE_AS_TLS"
10350 "add %0,%1,%2@tls")
10351
10352 \f
10353 ;; Next come insns related to the calling sequence.
10354 ;;
10355 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
10356 ;; We move the back-chain and decrement the stack pointer.
10357
10358 (define_expand "allocate_stack"
10359 [(set (match_operand 0 "gpc_reg_operand" "")
10360 (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
10361 (set (reg 1)
10362 (minus (reg 1) (match_dup 1)))]
10363 ""
10364 "
10365 { rtx chain = gen_reg_rtx (Pmode);
10366 rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
10367 rtx neg_op0;
10368
10369 emit_move_insn (chain, stack_bot);
10370
10371 /* Check stack bounds if necessary. */
10372 if (crtl->limit_stack)
10373 {
10374 rtx available;
10375 available = expand_binop (Pmode, sub_optab,
10376 stack_pointer_rtx, stack_limit_rtx,
10377 NULL_RTX, 1, OPTAB_WIDEN);
10378 emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
10379 }
10380
10381 if (GET_CODE (operands[1]) != CONST_INT
10382 || INTVAL (operands[1]) < -32767
10383 || INTVAL (operands[1]) > 32768)
10384 {
10385 neg_op0 = gen_reg_rtx (Pmode);
10386 if (TARGET_32BIT)
10387 emit_insn (gen_negsi2 (neg_op0, operands[1]));
10388 else
10389 emit_insn (gen_negdi2 (neg_op0, operands[1]));
10390 }
10391 else
10392 neg_op0 = GEN_INT (- INTVAL (operands[1]));
10393
10394 if (TARGET_UPDATE)
10395 emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_di_update))
10396 (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
10397
10398 else
10399 {
10400 emit_insn ((* ((TARGET_32BIT) ? gen_addsi3 : gen_adddi3))
10401 (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
10402 emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), chain);
10403 }
10404
10405 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
10406 DONE;
10407 }")
10408
10409 ;; These patterns say how to save and restore the stack pointer. We need not
10410 ;; save the stack pointer at function level since we are careful to
10411 ;; preserve the backchain. At block level, we have to restore the backchain
10412 ;; when we restore the stack pointer.
10413 ;;
10414 ;; For nonlocal gotos, we must save both the stack pointer and its
10415 ;; backchain and restore both. Note that in the nonlocal case, the
10416 ;; save area is a memory location.
10417
10418 (define_expand "save_stack_function"
10419 [(match_operand 0 "any_operand" "")
10420 (match_operand 1 "any_operand" "")]
10421 ""
10422 "DONE;")
10423
10424 (define_expand "restore_stack_function"
10425 [(match_operand 0 "any_operand" "")
10426 (match_operand 1 "any_operand" "")]
10427 ""
10428 "DONE;")
10429
10430 ;; Adjust stack pointer (op0) to a new value (op1).
10431 ;; First copy old stack backchain to new location, and ensure that the
10432 ;; scheduler won't reorder the sp assignment before the backchain write.
10433 (define_expand "restore_stack_block"
10434 [(set (match_dup 2) (match_dup 3))
10435 (set (match_dup 4) (match_dup 2))
10436 (set (match_dup 5) (unspec:BLK [(match_dup 5)] UNSPEC_TIE))
10437 (set (match_operand 0 "register_operand" "")
10438 (match_operand 1 "register_operand" ""))]
10439 ""
10440 "
10441 {
10442 operands[1] = force_reg (Pmode, operands[1]);
10443 operands[2] = gen_reg_rtx (Pmode);
10444 operands[3] = gen_frame_mem (Pmode, operands[0]);
10445 operands[4] = gen_frame_mem (Pmode, operands[1]);
10446 operands[5] = gen_frame_mem (BLKmode, operands[0]);
10447 }")
10448
10449 (define_expand "save_stack_nonlocal"
10450 [(set (match_dup 3) (match_dup 4))
10451 (set (match_operand 0 "memory_operand" "") (match_dup 3))
10452 (set (match_dup 2) (match_operand 1 "register_operand" ""))]
10453 ""
10454 "
10455 {
10456 int units_per_word = (TARGET_32BIT) ? 4 : 8;
10457
10458 /* Copy the backchain to the first word, sp to the second. */
10459 operands[0] = adjust_address_nv (operands[0], Pmode, 0);
10460 operands[2] = adjust_address_nv (operands[0], Pmode, units_per_word);
10461 operands[3] = gen_reg_rtx (Pmode);
10462 operands[4] = gen_frame_mem (Pmode, operands[1]);
10463 }")
10464
10465 (define_expand "restore_stack_nonlocal"
10466 [(set (match_dup 2) (match_operand 1 "memory_operand" ""))
10467 (set (match_dup 3) (match_dup 4))
10468 (set (match_dup 5) (match_dup 2))
10469 (set (match_dup 6) (unspec:BLK [(match_dup 6)] UNSPEC_TIE))
10470 (set (match_operand 0 "register_operand" "") (match_dup 3))]
10471 ""
10472 "
10473 {
10474 int units_per_word = (TARGET_32BIT) ? 4 : 8;
10475
10476 /* Restore the backchain from the first word, sp from the second. */
10477 operands[2] = gen_reg_rtx (Pmode);
10478 operands[3] = gen_reg_rtx (Pmode);
10479 operands[1] = adjust_address_nv (operands[1], Pmode, 0);
10480 operands[4] = adjust_address_nv (operands[1], Pmode, units_per_word);
10481 operands[5] = gen_frame_mem (Pmode, operands[3]);
10482 operands[6] = gen_frame_mem (BLKmode, operands[0]);
10483 }")
10484 \f
10485 ;; TOC register handling.
10486
10487 ;; Code to initialize the TOC register...
10488
10489 (define_insn "load_toc_aix_si"
10490 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10491 (unspec:SI [(const_int 0)] UNSPEC_TOC))
10492 (use (reg:SI 2))])]
10493 "DEFAULT_ABI == ABI_AIX && TARGET_32BIT"
10494 "*
10495 {
10496 char buf[30];
10497 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
10498 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
10499 operands[2] = gen_rtx_REG (Pmode, 2);
10500 return \"{l|lwz} %0,%1(%2)\";
10501 }"
10502 [(set_attr "type" "load")])
10503
10504 (define_insn "load_toc_aix_di"
10505 [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10506 (unspec:DI [(const_int 0)] UNSPEC_TOC))
10507 (use (reg:DI 2))])]
10508 "DEFAULT_ABI == ABI_AIX && TARGET_64BIT"
10509 "*
10510 {
10511 char buf[30];
10512 #ifdef TARGET_RELOCATABLE
10513 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
10514 !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
10515 #else
10516 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
10517 #endif
10518 if (TARGET_ELF)
10519 strcat (buf, \"@toc\");
10520 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
10521 operands[2] = gen_rtx_REG (Pmode, 2);
10522 return \"ld %0,%1(%2)\";
10523 }"
10524 [(set_attr "type" "load")])
10525
10526 (define_insn "load_toc_v4_pic_si"
10527 [(set (reg:SI LR_REGNO)
10528 (unspec:SI [(const_int 0)] UNSPEC_TOC))]
10529 "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
10530 "bl _GLOBAL_OFFSET_TABLE_@local-4"
10531 [(set_attr "type" "branch")
10532 (set_attr "length" "4")])
10533
10534 (define_insn "load_toc_v4_PIC_1"
10535 [(set (reg:SI LR_REGNO)
10536 (match_operand:SI 0 "immediate_operand" "s"))
10537 (use (unspec [(match_dup 0)] UNSPEC_TOC))]
10538 "TARGET_ELF && DEFAULT_ABI != ABI_AIX
10539 && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
10540 "bcl 20,31,%0\\n%0:"
10541 [(set_attr "type" "branch")
10542 (set_attr "length" "4")])
10543
10544 (define_insn "load_toc_v4_PIC_1b"
10545 [(set (reg:SI LR_REGNO)
10546 (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")]
10547 UNSPEC_TOCPTR))]
10548 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
10549 "bcl 20,31,$+8\\n\\t.long %0-$"
10550 [(set_attr "type" "branch")
10551 (set_attr "length" "8")])
10552
10553 (define_insn "load_toc_v4_PIC_2"
10554 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10555 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10556 (minus:SI (match_operand:SI 2 "immediate_operand" "s")
10557 (match_operand:SI 3 "immediate_operand" "s")))))]
10558 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
10559 "{l|lwz} %0,%2-%3(%1)"
10560 [(set_attr "type" "load")])
10561
10562 (define_insn "load_toc_v4_PIC_3b"
10563 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
10564 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
10565 (high:SI
10566 (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
10567 (match_operand:SI 3 "symbol_ref_operand" "s")))))]
10568 "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI != ABI_AIX && flag_pic"
10569 "{cau|addis} %0,%1,%2-%3@ha")
10570
10571 (define_insn "load_toc_v4_PIC_3c"
10572 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10573 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10574 (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
10575 (match_operand:SI 3 "symbol_ref_operand" "s"))))]
10576 "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI != ABI_AIX && flag_pic"
10577 "{cal|addi} %0,%1,%2-%3@l")
10578
10579 ;; If the TOC is shared over a translation unit, as happens with all
10580 ;; the kinds of PIC that we support, we need to restore the TOC
10581 ;; pointer only when jumping over units of translation.
10582 ;; On Darwin, we need to reload the picbase.
10583
10584 (define_expand "builtin_setjmp_receiver"
10585 [(use (label_ref (match_operand 0 "" "")))]
10586 "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
10587 || (TARGET_TOC && TARGET_MINIMAL_TOC)
10588 || (DEFAULT_ABI == ABI_DARWIN && flag_pic)"
10589 "
10590 {
10591 #if TARGET_MACHO
10592 if (DEFAULT_ABI == ABI_DARWIN)
10593 {
10594 const char *picbase = machopic_function_base_name ();
10595 rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (picbase));
10596 rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
10597 rtx tmplabrtx;
10598 char tmplab[20];
10599
10600 ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\",
10601 CODE_LABEL_NUMBER (operands[0]));
10602 tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
10603
10604 emit_insn (gen_load_macho_picbase (tmplabrtx));
10605 emit_move_insn (picreg, gen_rtx_REG (Pmode, LR_REGNO));
10606 emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
10607 }
10608 else
10609 #endif
10610 rs6000_emit_load_toc_table (FALSE);
10611 DONE;
10612 }")
10613
10614 ;; Elf specific ways of loading addresses for non-PIC code.
10615 ;; The output of this could be r0, but we make a very strong
10616 ;; preference for a base register because it will usually
10617 ;; be needed there.
10618 (define_insn "elf_high"
10619 [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
10620 (high:SI (match_operand 1 "" "")))]
10621 "TARGET_ELF && ! TARGET_64BIT"
10622 "{liu|lis} %0,%1@ha")
10623
10624 (define_insn "elf_low"
10625 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
10626 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
10627 (match_operand 2 "" "")))]
10628 "TARGET_ELF && ! TARGET_64BIT"
10629 "@
10630 {cal|la} %0,%2@l(%1)
10631 {ai|addic} %0,%1,%K2")
10632 \f
10633 ;; A function pointer under AIX is a pointer to a data area whose first word
10634 ;; contains the actual address of the function, whose second word contains a
10635 ;; pointer to its TOC, and whose third word contains a value to place in the
10636 ;; static chain register (r11). Note that if we load the static chain, our
10637 ;; "trampoline" need not have any executable code.
10638
10639 (define_expand "call_indirect_aix32"
10640 [(set (match_dup 2)
10641 (mem:SI (match_operand:SI 0 "gpc_reg_operand" "")))
10642 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
10643 (reg:SI 2))
10644 (set (reg:SI 2)
10645 (mem:SI (plus:SI (match_dup 0)
10646 (const_int 4))))
10647 (set (reg:SI 11)
10648 (mem:SI (plus:SI (match_dup 0)
10649 (const_int 8))))
10650 (parallel [(call (mem:SI (match_dup 2))
10651 (match_operand 1 "" ""))
10652 (use (reg:SI 2))
10653 (use (reg:SI 11))
10654 (set (reg:SI 2)
10655 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10656 (clobber (reg:SI LR_REGNO))])]
10657 "TARGET_32BIT"
10658 "
10659 { operands[2] = gen_reg_rtx (SImode); }")
10660
10661 (define_expand "call_indirect_aix64"
10662 [(set (match_dup 2)
10663 (mem:DI (match_operand:DI 0 "gpc_reg_operand" "")))
10664 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10665 (reg:DI 2))
10666 (set (reg:DI 2)
10667 (mem:DI (plus:DI (match_dup 0)
10668 (const_int 8))))
10669 (set (reg:DI 11)
10670 (mem:DI (plus:DI (match_dup 0)
10671 (const_int 16))))
10672 (parallel [(call (mem:SI (match_dup 2))
10673 (match_operand 1 "" ""))
10674 (use (reg:DI 2))
10675 (use (reg:DI 11))
10676 (set (reg:DI 2)
10677 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10678 (clobber (reg:SI LR_REGNO))])]
10679 "TARGET_64BIT"
10680 "
10681 { operands[2] = gen_reg_rtx (DImode); }")
10682
10683 (define_expand "call_value_indirect_aix32"
10684 [(set (match_dup 3)
10685 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
10686 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
10687 (reg:SI 2))
10688 (set (reg:SI 2)
10689 (mem:SI (plus:SI (match_dup 1)
10690 (const_int 4))))
10691 (set (reg:SI 11)
10692 (mem:SI (plus:SI (match_dup 1)
10693 (const_int 8))))
10694 (parallel [(set (match_operand 0 "" "")
10695 (call (mem:SI (match_dup 3))
10696 (match_operand 2 "" "")))
10697 (use (reg:SI 2))
10698 (use (reg:SI 11))
10699 (set (reg:SI 2)
10700 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10701 (clobber (reg:SI LR_REGNO))])]
10702 "TARGET_32BIT"
10703 "
10704 { operands[3] = gen_reg_rtx (SImode); }")
10705
10706 (define_expand "call_value_indirect_aix64"
10707 [(set (match_dup 3)
10708 (mem:DI (match_operand:DI 1 "gpc_reg_operand" "")))
10709 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10710 (reg:DI 2))
10711 (set (reg:DI 2)
10712 (mem:DI (plus:DI (match_dup 1)
10713 (const_int 8))))
10714 (set (reg:DI 11)
10715 (mem:DI (plus:DI (match_dup 1)
10716 (const_int 16))))
10717 (parallel [(set (match_operand 0 "" "")
10718 (call (mem:SI (match_dup 3))
10719 (match_operand 2 "" "")))
10720 (use (reg:DI 2))
10721 (use (reg:DI 11))
10722 (set (reg:DI 2)
10723 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10724 (clobber (reg:SI LR_REGNO))])]
10725 "TARGET_64BIT"
10726 "
10727 { operands[3] = gen_reg_rtx (DImode); }")
10728
10729 ;; Now the definitions for the call and call_value insns
10730 (define_expand "call"
10731 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10732 (match_operand 1 "" ""))
10733 (use (match_operand 2 "" ""))
10734 (clobber (reg:SI LR_REGNO))])]
10735 ""
10736 "
10737 {
10738 #if TARGET_MACHO
10739 if (MACHOPIC_INDIRECT)
10740 operands[0] = machopic_indirect_call_target (operands[0]);
10741 #endif
10742
10743 gcc_assert (GET_CODE (operands[0]) == MEM);
10744 gcc_assert (GET_CODE (operands[1]) == CONST_INT);
10745
10746 operands[0] = XEXP (operands[0], 0);
10747
10748 if (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT
10749 && flag_pic
10750 && GET_CODE (operands[0]) == SYMBOL_REF
10751 && !SYMBOL_REF_LOCAL_P (operands[0]))
10752 {
10753 rtx call;
10754 rtvec tmp;
10755
10756 tmp = gen_rtvec (3,
10757 gen_rtx_CALL (VOIDmode,
10758 gen_rtx_MEM (SImode, operands[0]),
10759 operands[1]),
10760 gen_rtx_USE (VOIDmode, operands[2]),
10761 gen_rtx_CLOBBER (VOIDmode,
10762 gen_rtx_REG (Pmode, LR_REGNO)));
10763 call = emit_call_insn (gen_rtx_PARALLEL (VOIDmode, tmp));
10764 use_reg (&CALL_INSN_FUNCTION_USAGE (call), pic_offset_table_rtx);
10765 DONE;
10766 }
10767
10768 if (GET_CODE (operands[0]) != SYMBOL_REF
10769 || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[0]))
10770 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[2]) & CALL_LONG) != 0))
10771 {
10772 if (INTVAL (operands[2]) & CALL_LONG)
10773 operands[0] = rs6000_longcall_ref (operands[0]);
10774
10775 switch (DEFAULT_ABI)
10776 {
10777 case ABI_V4:
10778 case ABI_DARWIN:
10779 operands[0] = force_reg (Pmode, operands[0]);
10780 break;
10781
10782 case ABI_AIX:
10783 /* AIX function pointers are really pointers to a three word
10784 area. */
10785 emit_call_insn (TARGET_32BIT
10786 ? gen_call_indirect_aix32 (force_reg (SImode,
10787 operands[0]),
10788 operands[1])
10789 : gen_call_indirect_aix64 (force_reg (DImode,
10790 operands[0]),
10791 operands[1]));
10792 DONE;
10793
10794 default:
10795 gcc_unreachable ();
10796 }
10797 }
10798 }")
10799
10800 (define_expand "call_value"
10801 [(parallel [(set (match_operand 0 "" "")
10802 (call (mem:SI (match_operand 1 "address_operand" ""))
10803 (match_operand 2 "" "")))
10804 (use (match_operand 3 "" ""))
10805 (clobber (reg:SI LR_REGNO))])]
10806 ""
10807 "
10808 {
10809 #if TARGET_MACHO
10810 if (MACHOPIC_INDIRECT)
10811 operands[1] = machopic_indirect_call_target (operands[1]);
10812 #endif
10813
10814 gcc_assert (GET_CODE (operands[1]) == MEM);
10815 gcc_assert (GET_CODE (operands[2]) == CONST_INT);
10816
10817 operands[1] = XEXP (operands[1], 0);
10818
10819 if (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT
10820 && flag_pic
10821 && GET_CODE (operands[1]) == SYMBOL_REF
10822 && !SYMBOL_REF_LOCAL_P (operands[1]))
10823 {
10824 rtx call;
10825 rtvec tmp;
10826
10827 tmp = gen_rtvec (3,
10828 gen_rtx_SET (VOIDmode,
10829 operands[0],
10830 gen_rtx_CALL (VOIDmode,
10831 gen_rtx_MEM (SImode,
10832 operands[1]),
10833 operands[2])),
10834 gen_rtx_USE (VOIDmode, operands[3]),
10835 gen_rtx_CLOBBER (VOIDmode,
10836 gen_rtx_REG (Pmode, LR_REGNO)));
10837 call = emit_call_insn (gen_rtx_PARALLEL (VOIDmode, tmp));
10838 use_reg (&CALL_INSN_FUNCTION_USAGE (call), pic_offset_table_rtx);
10839 DONE;
10840 }
10841
10842 if (GET_CODE (operands[1]) != SYMBOL_REF
10843 || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[1]))
10844 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[3]) & CALL_LONG) != 0))
10845 {
10846 if (INTVAL (operands[3]) & CALL_LONG)
10847 operands[1] = rs6000_longcall_ref (operands[1]);
10848
10849 switch (DEFAULT_ABI)
10850 {
10851 case ABI_V4:
10852 case ABI_DARWIN:
10853 operands[1] = force_reg (Pmode, operands[1]);
10854 break;
10855
10856 case ABI_AIX:
10857 /* AIX function pointers are really pointers to a three word
10858 area. */
10859 emit_call_insn (TARGET_32BIT
10860 ? gen_call_value_indirect_aix32 (operands[0],
10861 force_reg (SImode,
10862 operands[1]),
10863 operands[2])
10864 : gen_call_value_indirect_aix64 (operands[0],
10865 force_reg (DImode,
10866 operands[1]),
10867 operands[2]));
10868 DONE;
10869
10870 default:
10871 gcc_unreachable ();
10872 }
10873 }
10874 }")
10875
10876 ;; Call to function in current module. No TOC pointer reload needed.
10877 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
10878 ;; either the function was not prototyped, or it was prototyped as a
10879 ;; variable argument function. It is > 0 if FP registers were passed
10880 ;; and < 0 if they were not.
10881
10882 (define_insn "*call_local32"
10883 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10884 (match_operand 1 "" "g,g"))
10885 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10886 (clobber (reg:SI LR_REGNO))]
10887 "(INTVAL (operands[2]) & CALL_LONG) == 0"
10888 "*
10889 {
10890 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10891 output_asm_insn (\"crxor 6,6,6\", operands);
10892
10893 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10894 output_asm_insn (\"creqv 6,6,6\", operands);
10895
10896 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10897 }"
10898 [(set_attr "type" "branch")
10899 (set_attr "length" "4,8")])
10900
10901 (define_insn "*call_local64"
10902 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10903 (match_operand 1 "" "g,g"))
10904 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10905 (clobber (reg:SI LR_REGNO))]
10906 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10907 "*
10908 {
10909 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10910 output_asm_insn (\"crxor 6,6,6\", operands);
10911
10912 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10913 output_asm_insn (\"creqv 6,6,6\", operands);
10914
10915 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10916 }"
10917 [(set_attr "type" "branch")
10918 (set_attr "length" "4,8")])
10919
10920 (define_insn "*call_value_local32"
10921 [(set (match_operand 0 "" "")
10922 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10923 (match_operand 2 "" "g,g")))
10924 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10925 (clobber (reg:SI LR_REGNO))]
10926 "(INTVAL (operands[3]) & CALL_LONG) == 0"
10927 "*
10928 {
10929 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10930 output_asm_insn (\"crxor 6,6,6\", operands);
10931
10932 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10933 output_asm_insn (\"creqv 6,6,6\", operands);
10934
10935 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10936 }"
10937 [(set_attr "type" "branch")
10938 (set_attr "length" "4,8")])
10939
10940
10941 (define_insn "*call_value_local64"
10942 [(set (match_operand 0 "" "")
10943 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10944 (match_operand 2 "" "g,g")))
10945 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10946 (clobber (reg:SI LR_REGNO))]
10947 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10948 "*
10949 {
10950 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10951 output_asm_insn (\"crxor 6,6,6\", operands);
10952
10953 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10954 output_asm_insn (\"creqv 6,6,6\", operands);
10955
10956 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10957 }"
10958 [(set_attr "type" "branch")
10959 (set_attr "length" "4,8")])
10960
10961 ;; Call to function which may be in another module. Restore the TOC
10962 ;; pointer (r2) after the call unless this is System V.
10963 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
10964 ;; either the function was not prototyped, or it was prototyped as a
10965 ;; variable argument function. It is > 0 if FP registers were passed
10966 ;; and < 0 if they were not.
10967
10968 (define_insn "*call_indirect_nonlocal_aix32"
10969 [(call (mem:SI (match_operand:SI 0 "register_operand" "c,*l"))
10970 (match_operand 1 "" "g,g"))
10971 (use (reg:SI 2))
10972 (use (reg:SI 11))
10973 (set (reg:SI 2)
10974 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10975 (clobber (reg:SI LR_REGNO))]
10976 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10977 "b%T0l\;{l|lwz} 2,20(1)"
10978 [(set_attr "type" "jmpreg")
10979 (set_attr "length" "8")])
10980
10981 (define_insn "*call_nonlocal_aix32"
10982 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
10983 (match_operand 1 "" "g"))
10984 (use (match_operand:SI 2 "immediate_operand" "O"))
10985 (clobber (reg:SI LR_REGNO))]
10986 "TARGET_32BIT
10987 && DEFAULT_ABI == ABI_AIX
10988 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10989 "bl %z0\;%."
10990 [(set_attr "type" "branch")
10991 (set_attr "length" "8")])
10992
10993 (define_insn "*call_indirect_nonlocal_aix64"
10994 [(call (mem:SI (match_operand:DI 0 "register_operand" "c,*l"))
10995 (match_operand 1 "" "g,g"))
10996 (use (reg:DI 2))
10997 (use (reg:DI 11))
10998 (set (reg:DI 2)
10999 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
11000 (clobber (reg:SI LR_REGNO))]
11001 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
11002 "b%T0l\;ld 2,40(1)"
11003 [(set_attr "type" "jmpreg")
11004 (set_attr "length" "8")])
11005
11006 (define_insn "*call_nonlocal_aix64"
11007 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
11008 (match_operand 1 "" "g"))
11009 (use (match_operand:SI 2 "immediate_operand" "O"))
11010 (clobber (reg:SI LR_REGNO))]
11011 "TARGET_64BIT
11012 && DEFAULT_ABI == ABI_AIX
11013 && (INTVAL (operands[2]) & CALL_LONG) == 0"
11014 "bl %z0\;%."
11015 [(set_attr "type" "branch")
11016 (set_attr "length" "8")])
11017
11018 (define_insn "*call_value_indirect_nonlocal_aix32"
11019 [(set (match_operand 0 "" "")
11020 (call (mem:SI (match_operand:SI 1 "register_operand" "c,*l"))
11021 (match_operand 2 "" "g,g")))
11022 (use (reg:SI 2))
11023 (use (reg:SI 11))
11024 (set (reg:SI 2)
11025 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
11026 (clobber (reg:SI LR_REGNO))]
11027 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
11028 "b%T1l\;{l|lwz} 2,20(1)"
11029 [(set_attr "type" "jmpreg")
11030 (set_attr "length" "8")])
11031
11032 (define_insn "*call_value_nonlocal_aix32"
11033 [(set (match_operand 0 "" "")
11034 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
11035 (match_operand 2 "" "g")))
11036 (use (match_operand:SI 3 "immediate_operand" "O"))
11037 (clobber (reg:SI LR_REGNO))]
11038 "TARGET_32BIT
11039 && DEFAULT_ABI == ABI_AIX
11040 && (INTVAL (operands[3]) & CALL_LONG) == 0"
11041 "bl %z1\;%."
11042 [(set_attr "type" "branch")
11043 (set_attr "length" "8")])
11044
11045 (define_insn "*call_value_indirect_nonlocal_aix64"
11046 [(set (match_operand 0 "" "")
11047 (call (mem:SI (match_operand:DI 1 "register_operand" "c,*l"))
11048 (match_operand 2 "" "g,g")))
11049 (use (reg:DI 2))
11050 (use (reg:DI 11))
11051 (set (reg:DI 2)
11052 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
11053 (clobber (reg:SI LR_REGNO))]
11054 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
11055 "b%T1l\;ld 2,40(1)"
11056 [(set_attr "type" "jmpreg")
11057 (set_attr "length" "8")])
11058
11059 (define_insn "*call_value_nonlocal_aix64"
11060 [(set (match_operand 0 "" "")
11061 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
11062 (match_operand 2 "" "g")))
11063 (use (match_operand:SI 3 "immediate_operand" "O"))
11064 (clobber (reg:SI LR_REGNO))]
11065 "TARGET_64BIT
11066 && DEFAULT_ABI == ABI_AIX
11067 && (INTVAL (operands[3]) & CALL_LONG) == 0"
11068 "bl %z1\;%."
11069 [(set_attr "type" "branch")
11070 (set_attr "length" "8")])
11071
11072 ;; A function pointer under System V is just a normal pointer
11073 ;; operands[0] is the function pointer
11074 ;; operands[1] is the stack size to clean up
11075 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
11076 ;; which indicates how to set cr1
11077
11078 (define_insn "*call_indirect_nonlocal_sysv<mode>"
11079 [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l,c,*l"))
11080 (match_operand 1 "" "g,g,g,g"))
11081 (use (match_operand:SI 2 "immediate_operand" "O,O,n,n"))
11082 (clobber (reg:SI LR_REGNO))]
11083 "DEFAULT_ABI == ABI_V4
11084 || DEFAULT_ABI == ABI_DARWIN"
11085 {
11086 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11087 output_asm_insn ("crxor 6,6,6", operands);
11088
11089 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11090 output_asm_insn ("creqv 6,6,6", operands);
11091
11092 return "b%T0l";
11093 }
11094 [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
11095 (set_attr "length" "4,4,8,8")])
11096
11097 (define_insn "*call_nonlocal_sysv<mode>"
11098 [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s"))
11099 (match_operand 1 "" "g,g"))
11100 (use (match_operand:SI 2 "immediate_operand" "O,n"))
11101 (clobber (reg:SI LR_REGNO))]
11102 "(DEFAULT_ABI == ABI_DARWIN
11103 || (DEFAULT_ABI == ABI_V4
11104 && (INTVAL (operands[2]) & CALL_LONG) == 0))"
11105 {
11106 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11107 output_asm_insn ("crxor 6,6,6", operands);
11108
11109 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11110 output_asm_insn ("creqv 6,6,6", operands);
11111
11112 #if TARGET_MACHO
11113 return output_call(insn, operands, 0, 2);
11114 #else
11115 if (DEFAULT_ABI == ABI_V4 && flag_pic)
11116 {
11117 if (TARGET_SECURE_PLT && flag_pic == 2)
11118 /* The magic 32768 offset here and in the other sysv call insns
11119 corresponds to the offset of r30 in .got2, as given by LCTOC1.
11120 See sysv4.h:toc_section. */
11121 return "bl %z0+32768@plt";
11122 else
11123 return "bl %z0@plt";
11124 }
11125 else
11126 return "bl %z0";
11127 #endif
11128 }
11129 [(set_attr "type" "branch,branch")
11130 (set_attr "length" "4,8")])
11131
11132 (define_insn "*call_value_indirect_nonlocal_sysv<mode>"
11133 [(set (match_operand 0 "" "")
11134 (call (mem:SI (match_operand:P 1 "register_operand" "c,*l,c,*l"))
11135 (match_operand 2 "" "g,g,g,g")))
11136 (use (match_operand:SI 3 "immediate_operand" "O,O,n,n"))
11137 (clobber (reg:SI LR_REGNO))]
11138 "DEFAULT_ABI == ABI_V4
11139 || DEFAULT_ABI == ABI_DARWIN"
11140 {
11141 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11142 output_asm_insn ("crxor 6,6,6", operands);
11143
11144 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11145 output_asm_insn ("creqv 6,6,6", operands);
11146
11147 return "b%T1l";
11148 }
11149 [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
11150 (set_attr "length" "4,4,8,8")])
11151
11152 (define_insn "*call_value_nonlocal_sysv<mode>"
11153 [(set (match_operand 0 "" "")
11154 (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s"))
11155 (match_operand 2 "" "g,g")))
11156 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11157 (clobber (reg:SI LR_REGNO))]
11158 "(DEFAULT_ABI == ABI_DARWIN
11159 || (DEFAULT_ABI == ABI_V4
11160 && (INTVAL (operands[3]) & CALL_LONG) == 0))"
11161 {
11162 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11163 output_asm_insn ("crxor 6,6,6", operands);
11164
11165 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11166 output_asm_insn ("creqv 6,6,6", operands);
11167
11168 #if TARGET_MACHO
11169 return output_call(insn, operands, 1, 3);
11170 #else
11171 if (DEFAULT_ABI == ABI_V4 && flag_pic)
11172 {
11173 if (TARGET_SECURE_PLT && flag_pic == 2)
11174 return "bl %z1+32768@plt";
11175 else
11176 return "bl %z1@plt";
11177 }
11178 else
11179 return "bl %z1";
11180 #endif
11181 }
11182 [(set_attr "type" "branch,branch")
11183 (set_attr "length" "4,8")])
11184
11185 ;; Call subroutine returning any type.
11186 (define_expand "untyped_call"
11187 [(parallel [(call (match_operand 0 "" "")
11188 (const_int 0))
11189 (match_operand 1 "" "")
11190 (match_operand 2 "" "")])]
11191 ""
11192 "
11193 {
11194 int i;
11195
11196 emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
11197
11198 for (i = 0; i < XVECLEN (operands[2], 0); i++)
11199 {
11200 rtx set = XVECEXP (operands[2], 0, i);
11201 emit_move_insn (SET_DEST (set), SET_SRC (set));
11202 }
11203
11204 /* The optimizer does not know that the call sets the function value
11205 registers we stored in the result block. We avoid problems by
11206 claiming that all hard registers are used and clobbered at this
11207 point. */
11208 emit_insn (gen_blockage ());
11209
11210 DONE;
11211 }")
11212
11213 ;; sibling call patterns
11214 (define_expand "sibcall"
11215 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
11216 (match_operand 1 "" ""))
11217 (use (match_operand 2 "" ""))
11218 (use (reg:SI LR_REGNO))
11219 (return)])]
11220 ""
11221 "
11222 {
11223 #if TARGET_MACHO
11224 if (MACHOPIC_INDIRECT)
11225 operands[0] = machopic_indirect_call_target (operands[0]);
11226 #endif
11227
11228 gcc_assert (GET_CODE (operands[0]) == MEM);
11229 gcc_assert (GET_CODE (operands[1]) == CONST_INT);
11230
11231 operands[0] = XEXP (operands[0], 0);
11232 }")
11233
11234 ;; this and similar patterns must be marked as using LR, otherwise
11235 ;; dataflow will try to delete the store into it. This is true
11236 ;; even when the actual reg to jump to is in CTR, when LR was
11237 ;; saved and restored around the PIC-setting BCL.
11238 (define_insn "*sibcall_local32"
11239 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
11240 (match_operand 1 "" "g,g"))
11241 (use (match_operand:SI 2 "immediate_operand" "O,n"))
11242 (use (reg:SI LR_REGNO))
11243 (return)]
11244 "(INTVAL (operands[2]) & CALL_LONG) == 0"
11245 "*
11246 {
11247 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11248 output_asm_insn (\"crxor 6,6,6\", operands);
11249
11250 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11251 output_asm_insn (\"creqv 6,6,6\", operands);
11252
11253 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
11254 }"
11255 [(set_attr "type" "branch")
11256 (set_attr "length" "4,8")])
11257
11258 (define_insn "*sibcall_local64"
11259 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
11260 (match_operand 1 "" "g,g"))
11261 (use (match_operand:SI 2 "immediate_operand" "O,n"))
11262 (use (reg:SI LR_REGNO))
11263 (return)]
11264 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
11265 "*
11266 {
11267 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11268 output_asm_insn (\"crxor 6,6,6\", operands);
11269
11270 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11271 output_asm_insn (\"creqv 6,6,6\", operands);
11272
11273 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
11274 }"
11275 [(set_attr "type" "branch")
11276 (set_attr "length" "4,8")])
11277
11278 (define_insn "*sibcall_value_local32"
11279 [(set (match_operand 0 "" "")
11280 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
11281 (match_operand 2 "" "g,g")))
11282 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11283 (use (reg:SI LR_REGNO))
11284 (return)]
11285 "(INTVAL (operands[3]) & CALL_LONG) == 0"
11286 "*
11287 {
11288 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11289 output_asm_insn (\"crxor 6,6,6\", operands);
11290
11291 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11292 output_asm_insn (\"creqv 6,6,6\", operands);
11293
11294 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
11295 }"
11296 [(set_attr "type" "branch")
11297 (set_attr "length" "4,8")])
11298
11299
11300 (define_insn "*sibcall_value_local64"
11301 [(set (match_operand 0 "" "")
11302 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
11303 (match_operand 2 "" "g,g")))
11304 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11305 (use (reg:SI LR_REGNO))
11306 (return)]
11307 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
11308 "*
11309 {
11310 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11311 output_asm_insn (\"crxor 6,6,6\", operands);
11312
11313 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11314 output_asm_insn (\"creqv 6,6,6\", operands);
11315
11316 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
11317 }"
11318 [(set_attr "type" "branch")
11319 (set_attr "length" "4,8")])
11320
11321 (define_insn "*sibcall_nonlocal_aix32"
11322 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
11323 (match_operand 1 "" "g"))
11324 (use (match_operand:SI 2 "immediate_operand" "O"))
11325 (use (reg:SI LR_REGNO))
11326 (return)]
11327 "TARGET_32BIT
11328 && DEFAULT_ABI == ABI_AIX
11329 && (INTVAL (operands[2]) & CALL_LONG) == 0"
11330 "b %z0"
11331 [(set_attr "type" "branch")
11332 (set_attr "length" "4")])
11333
11334 (define_insn "*sibcall_nonlocal_aix64"
11335 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
11336 (match_operand 1 "" "g"))
11337 (use (match_operand:SI 2 "immediate_operand" "O"))
11338 (use (reg:SI LR_REGNO))
11339 (return)]
11340 "TARGET_64BIT
11341 && DEFAULT_ABI == ABI_AIX
11342 && (INTVAL (operands[2]) & CALL_LONG) == 0"
11343 "b %z0"
11344 [(set_attr "type" "branch")
11345 (set_attr "length" "4")])
11346
11347 (define_insn "*sibcall_value_nonlocal_aix32"
11348 [(set (match_operand 0 "" "")
11349 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
11350 (match_operand 2 "" "g")))
11351 (use (match_operand:SI 3 "immediate_operand" "O"))
11352 (use (reg:SI LR_REGNO))
11353 (return)]
11354 "TARGET_32BIT
11355 && DEFAULT_ABI == ABI_AIX
11356 && (INTVAL (operands[3]) & CALL_LONG) == 0"
11357 "b %z1"
11358 [(set_attr "type" "branch")
11359 (set_attr "length" "4")])
11360
11361 (define_insn "*sibcall_value_nonlocal_aix64"
11362 [(set (match_operand 0 "" "")
11363 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
11364 (match_operand 2 "" "g")))
11365 (use (match_operand:SI 3 "immediate_operand" "O"))
11366 (use (reg:SI LR_REGNO))
11367 (return)]
11368 "TARGET_64BIT
11369 && DEFAULT_ABI == ABI_AIX
11370 && (INTVAL (operands[3]) & CALL_LONG) == 0"
11371 "b %z1"
11372 [(set_attr "type" "branch")
11373 (set_attr "length" "4")])
11374
11375 (define_insn "*sibcall_nonlocal_sysv<mode>"
11376 [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s"))
11377 (match_operand 1 "" ""))
11378 (use (match_operand 2 "immediate_operand" "O,n"))
11379 (use (reg:SI LR_REGNO))
11380 (return)]
11381 "(DEFAULT_ABI == ABI_DARWIN
11382 || DEFAULT_ABI == ABI_V4)
11383 && (INTVAL (operands[2]) & CALL_LONG) == 0"
11384 "*
11385 {
11386 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11387 output_asm_insn (\"crxor 6,6,6\", operands);
11388
11389 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11390 output_asm_insn (\"creqv 6,6,6\", operands);
11391
11392 if (DEFAULT_ABI == ABI_V4 && flag_pic)
11393 {
11394 if (TARGET_SECURE_PLT && flag_pic == 2)
11395 return \"b %z0+32768@plt\";
11396 else
11397 return \"b %z0@plt\";
11398 }
11399 else
11400 return \"b %z0\";
11401 }"
11402 [(set_attr "type" "branch,branch")
11403 (set_attr "length" "4,8")])
11404
11405 (define_expand "sibcall_value"
11406 [(parallel [(set (match_operand 0 "register_operand" "")
11407 (call (mem:SI (match_operand 1 "address_operand" ""))
11408 (match_operand 2 "" "")))
11409 (use (match_operand 3 "" ""))
11410 (use (reg:SI LR_REGNO))
11411 (return)])]
11412 ""
11413 "
11414 {
11415 #if TARGET_MACHO
11416 if (MACHOPIC_INDIRECT)
11417 operands[1] = machopic_indirect_call_target (operands[1]);
11418 #endif
11419
11420 gcc_assert (GET_CODE (operands[1]) == MEM);
11421 gcc_assert (GET_CODE (operands[2]) == CONST_INT);
11422
11423 operands[1] = XEXP (operands[1], 0);
11424 }")
11425
11426 (define_insn "*sibcall_value_nonlocal_sysv<mode>"
11427 [(set (match_operand 0 "" "")
11428 (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s"))
11429 (match_operand 2 "" "")))
11430 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11431 (use (reg:SI LR_REGNO))
11432 (return)]
11433 "(DEFAULT_ABI == ABI_DARWIN
11434 || DEFAULT_ABI == ABI_V4)
11435 && (INTVAL (operands[3]) & CALL_LONG) == 0"
11436 "*
11437 {
11438 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11439 output_asm_insn (\"crxor 6,6,6\", operands);
11440
11441 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11442 output_asm_insn (\"creqv 6,6,6\", operands);
11443
11444 if (DEFAULT_ABI == ABI_V4 && flag_pic)
11445 {
11446 if (TARGET_SECURE_PLT && flag_pic == 2)
11447 return \"b %z1+32768@plt\";
11448 else
11449 return \"b %z1@plt\";
11450 }
11451 else
11452 return \"b %z1\";
11453 }"
11454 [(set_attr "type" "branch,branch")
11455 (set_attr "length" "4,8")])
11456
11457 (define_expand "sibcall_epilogue"
11458 [(use (const_int 0))]
11459 "TARGET_SCHED_PROLOG"
11460 "
11461 {
11462 rs6000_emit_epilogue (TRUE);
11463 DONE;
11464 }")
11465
11466 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
11467 ;; all of memory. This blocks insns from being moved across this point.
11468
11469 (define_insn "blockage"
11470 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCK)]
11471 ""
11472 "")
11473 \f
11474 ;; Compare insns are next. Note that the RS/6000 has two types of compares,
11475 ;; signed & unsigned, and one type of branch.
11476 ;;
11477 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
11478 ;; insns, and branches. We store the operands of compares until we see
11479 ;; how it is used.
11480 (define_expand "cmp<mode>"
11481 [(set (cc0)
11482 (compare (match_operand:GPR 0 "gpc_reg_operand" "")
11483 (match_operand:GPR 1 "reg_or_short_operand" "")))]
11484 ""
11485 "
11486 {
11487 /* Take care of the possibility that operands[1] might be negative but
11488 this might be a logical operation. That insn doesn't exist. */
11489 if (GET_CODE (operands[1]) == CONST_INT
11490 && INTVAL (operands[1]) < 0)
11491 operands[1] = force_reg (<MODE>mode, operands[1]);
11492
11493 rs6000_compare_op0 = operands[0];
11494 rs6000_compare_op1 = operands[1];
11495 rs6000_compare_fp_p = 0;
11496 DONE;
11497 }")
11498
11499 (define_expand "cmp<mode>"
11500 [(set (cc0) (compare (match_operand:FP 0 "gpc_reg_operand" "")
11501 (match_operand:FP 1 "gpc_reg_operand" "")))]
11502 ""
11503 "
11504 {
11505 rs6000_compare_op0 = operands[0];
11506 rs6000_compare_op1 = operands[1];
11507 rs6000_compare_fp_p = 1;
11508 DONE;
11509 }")
11510
11511 (define_expand "beq"
11512 [(use (match_operand 0 "" ""))]
11513 ""
11514 "{ rs6000_emit_cbranch (EQ, operands[0]); DONE; }")
11515
11516 (define_expand "bne"
11517 [(use (match_operand 0 "" ""))]
11518 ""
11519 "{ rs6000_emit_cbranch (NE, operands[0]); DONE; }")
11520
11521 (define_expand "bge"
11522 [(use (match_operand 0 "" ""))]
11523 ""
11524 "{ rs6000_emit_cbranch (GE, operands[0]); DONE; }")
11525
11526 (define_expand "bgt"
11527 [(use (match_operand 0 "" ""))]
11528 ""
11529 "{ rs6000_emit_cbranch (GT, operands[0]); DONE; }")
11530
11531 (define_expand "ble"
11532 [(use (match_operand 0 "" ""))]
11533 ""
11534 "{ rs6000_emit_cbranch (LE, operands[0]); DONE; }")
11535
11536 (define_expand "blt"
11537 [(use (match_operand 0 "" ""))]
11538 ""
11539 "{ rs6000_emit_cbranch (LT, operands[0]); DONE; }")
11540
11541 (define_expand "bgeu"
11542 [(use (match_operand 0 "" ""))]
11543 ""
11544 "{ rs6000_emit_cbranch (GEU, operands[0]); DONE; }")
11545
11546 (define_expand "bgtu"
11547 [(use (match_operand 0 "" ""))]
11548 ""
11549 "{ rs6000_emit_cbranch (GTU, operands[0]); DONE; }")
11550
11551 (define_expand "bleu"
11552 [(use (match_operand 0 "" ""))]
11553 ""
11554 "{ rs6000_emit_cbranch (LEU, operands[0]); DONE; }")
11555
11556 (define_expand "bltu"
11557 [(use (match_operand 0 "" ""))]
11558 ""
11559 "{ rs6000_emit_cbranch (LTU, operands[0]); DONE; }")
11560
11561 (define_expand "bunordered"
11562 [(use (match_operand 0 "" ""))]
11563 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11564 "{ rs6000_emit_cbranch (UNORDERED, operands[0]); DONE; }")
11565
11566 (define_expand "bordered"
11567 [(use (match_operand 0 "" ""))]
11568 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11569 "{ rs6000_emit_cbranch (ORDERED, operands[0]); DONE; }")
11570
11571 (define_expand "buneq"
11572 [(use (match_operand 0 "" ""))]
11573 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11574 "{ rs6000_emit_cbranch (UNEQ, operands[0]); DONE; }")
11575
11576 (define_expand "bunge"
11577 [(use (match_operand 0 "" ""))]
11578 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11579 "{ rs6000_emit_cbranch (UNGE, operands[0]); DONE; }")
11580
11581 (define_expand "bungt"
11582 [(use (match_operand 0 "" ""))]
11583 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11584 "{ rs6000_emit_cbranch (UNGT, operands[0]); DONE; }")
11585
11586 (define_expand "bunle"
11587 [(use (match_operand 0 "" ""))]
11588 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11589 "{ rs6000_emit_cbranch (UNLE, operands[0]); DONE; }")
11590
11591 (define_expand "bunlt"
11592 [(use (match_operand 0 "" ""))]
11593 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11594 "{ rs6000_emit_cbranch (UNLT, operands[0]); DONE; }")
11595
11596 (define_expand "bltgt"
11597 [(use (match_operand 0 "" ""))]
11598 ""
11599 "{ rs6000_emit_cbranch (LTGT, operands[0]); DONE; }")
11600
11601 ;; For SNE, we would prefer that the xor/abs sequence be used for integers.
11602 ;; For SEQ, likewise, except that comparisons with zero should be done
11603 ;; with an scc insns. However, due to the order that combine see the
11604 ;; resulting insns, we must, in fact, allow SEQ for integers. Fail in
11605 ;; the cases we don't want to handle.
11606 (define_expand "seq"
11607 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11608 ""
11609 "{ rs6000_emit_sCOND (EQ, operands[0]); DONE; }")
11610
11611 (define_expand "sne"
11612 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11613 ""
11614 "
11615 {
11616 if (! rs6000_compare_fp_p)
11617 FAIL;
11618
11619 rs6000_emit_sCOND (NE, operands[0]);
11620 DONE;
11621 }")
11622
11623 ;; A >= 0 is best done the portable way for A an integer.
11624 (define_expand "sge"
11625 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11626 ""
11627 "
11628 {
11629 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
11630 FAIL;
11631
11632 rs6000_emit_sCOND (GE, operands[0]);
11633 DONE;
11634 }")
11635
11636 ;; A > 0 is best done using the portable sequence, so fail in that case.
11637 (define_expand "sgt"
11638 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11639 ""
11640 "
11641 {
11642 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
11643 FAIL;
11644
11645 rs6000_emit_sCOND (GT, operands[0]);
11646 DONE;
11647 }")
11648
11649 ;; A <= 0 is best done the portable way for A an integer.
11650 (define_expand "sle"
11651 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11652 ""
11653 "
11654 {
11655 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
11656 FAIL;
11657
11658 rs6000_emit_sCOND (LE, operands[0]);
11659 DONE;
11660 }")
11661
11662 ;; A < 0 is best done in the portable way for A an integer.
11663 (define_expand "slt"
11664 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11665 ""
11666 "
11667 {
11668 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
11669 FAIL;
11670
11671 rs6000_emit_sCOND (LT, operands[0]);
11672 DONE;
11673 }")
11674
11675 (define_expand "sgeu"
11676 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11677 ""
11678 "{ rs6000_emit_sCOND (GEU, operands[0]); DONE; }")
11679
11680 (define_expand "sgtu"
11681 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11682 ""
11683 "{ rs6000_emit_sCOND (GTU, operands[0]); DONE; }")
11684
11685 (define_expand "sleu"
11686 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11687 ""
11688 "{ rs6000_emit_sCOND (LEU, operands[0]); DONE; }")
11689
11690 (define_expand "sltu"
11691 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11692 ""
11693 "{ rs6000_emit_sCOND (LTU, operands[0]); DONE; }")
11694
11695 (define_expand "sunordered"
11696 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11697 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11698 "{ rs6000_emit_sCOND (UNORDERED, operands[0]); DONE; }")
11699
11700 (define_expand "sordered"
11701 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11702 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11703 "{ rs6000_emit_sCOND (ORDERED, operands[0]); DONE; }")
11704
11705 (define_expand "suneq"
11706 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11707 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11708 "{ rs6000_emit_sCOND (UNEQ, operands[0]); DONE; }")
11709
11710 (define_expand "sunge"
11711 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11712 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11713 "{ rs6000_emit_sCOND (UNGE, operands[0]); DONE; }")
11714
11715 (define_expand "sungt"
11716 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11717 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11718 "{ rs6000_emit_sCOND (UNGT, operands[0]); DONE; }")
11719
11720 (define_expand "sunle"
11721 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11722 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11723 "{ rs6000_emit_sCOND (UNLE, operands[0]); DONE; }")
11724
11725 (define_expand "sunlt"
11726 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11727 "! (TARGET_HARD_FLOAT && !TARGET_FPRS)"
11728 "{ rs6000_emit_sCOND (UNLT, operands[0]); DONE; }")
11729
11730 (define_expand "sltgt"
11731 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11732 ""
11733 "{ rs6000_emit_sCOND (LTGT, operands[0]); DONE; }")
11734
11735 (define_expand "stack_protect_set"
11736 [(match_operand 0 "memory_operand" "")
11737 (match_operand 1 "memory_operand" "")]
11738 ""
11739 {
11740 #ifdef TARGET_THREAD_SSP_OFFSET
11741 rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
11742 rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
11743 operands[1] = gen_rtx_MEM (Pmode, addr);
11744 #endif
11745 if (TARGET_64BIT)
11746 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
11747 else
11748 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
11749 DONE;
11750 })
11751
11752 (define_insn "stack_protect_setsi"
11753 [(set (match_operand:SI 0 "memory_operand" "=m")
11754 (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET))
11755 (set (match_scratch:SI 2 "=&r") (const_int 0))]
11756 "TARGET_32BIT"
11757 "{l%U1%X1|lwz%U1%X1} %2,%1\;{st%U0%X0|stw%U0%X0} %2,%0\;{lil|li} %2,0"
11758 [(set_attr "type" "three")
11759 (set_attr "length" "12")])
11760
11761 (define_insn "stack_protect_setdi"
11762 [(set (match_operand:DI 0 "memory_operand" "=m")
11763 (unspec:DI [(match_operand:DI 1 "memory_operand" "m")] UNSPEC_SP_SET))
11764 (set (match_scratch:DI 2 "=&r") (const_int 0))]
11765 "TARGET_64BIT"
11766 "ld%U1%X1 %2,%1\;std%U0%X0 %2,%0\;{lil|li} %2,0"
11767 [(set_attr "type" "three")
11768 (set_attr "length" "12")])
11769
11770 (define_expand "stack_protect_test"
11771 [(match_operand 0 "memory_operand" "")
11772 (match_operand 1 "memory_operand" "")
11773 (match_operand 2 "" "")]
11774 ""
11775 {
11776 #ifdef TARGET_THREAD_SSP_OFFSET
11777 rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
11778 rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
11779 operands[1] = gen_rtx_MEM (Pmode, addr);
11780 #endif
11781 rs6000_compare_op0 = operands[0];
11782 rs6000_compare_op1 = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, operands[1]),
11783 UNSPEC_SP_TEST);
11784 rs6000_compare_fp_p = 0;
11785 emit_jump_insn (gen_beq (operands[2]));
11786 DONE;
11787 })
11788
11789 (define_insn "stack_protect_testsi"
11790 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
11791 (unspec:CCEQ [(match_operand:SI 1 "memory_operand" "m,m")
11792 (match_operand:SI 2 "memory_operand" "m,m")]
11793 UNSPEC_SP_TEST))
11794 (set (match_scratch:SI 4 "=r,r") (const_int 0))
11795 (clobber (match_scratch:SI 3 "=&r,&r"))]
11796 "TARGET_32BIT"
11797 "@
11798 {l%U1%X1|lwz%U1%X1} %3,%1\;{l%U2%X2|lwz%U2%X2} %4,%2\;xor. %3,%3,%4\;{lil|li} %4,0
11799 {l%U1%X1|lwz%U1%X1} %3,%1\;{l%U2%X2|lwz%U2%X2} %4,%2\;{cmpl|cmplw} %0,%3,%4\;{lil|li} %3,0\;{lil|li} %4,0"
11800 [(set_attr "length" "16,20")])
11801
11802 (define_insn "stack_protect_testdi"
11803 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
11804 (unspec:CCEQ [(match_operand:DI 1 "memory_operand" "m,m")
11805 (match_operand:DI 2 "memory_operand" "m,m")]
11806 UNSPEC_SP_TEST))
11807 (set (match_scratch:DI 4 "=r,r") (const_int 0))
11808 (clobber (match_scratch:DI 3 "=&r,&r"))]
11809 "TARGET_64BIT"
11810 "@
11811 ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;xor. %3,%3,%4\;{lil|li} %4,0
11812 ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;cmpld %0,%3,%4\;{lil|li} %3,0\;{lil|li} %4,0"
11813 [(set_attr "length" "16,20")])
11814
11815 \f
11816 ;; Here are the actual compare insns.
11817 (define_insn "*cmp<mode>_internal1"
11818 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
11819 (compare:CC (match_operand:GPR 1 "gpc_reg_operand" "r")
11820 (match_operand:GPR 2 "reg_or_short_operand" "rI")))]
11821 ""
11822 "{cmp%I2|cmp<wd>%I2} %0,%1,%2"
11823 [(set_attr "type" "cmp")])
11824
11825 ;; If we are comparing a register for equality with a large constant,
11826 ;; we can do this with an XOR followed by a compare. But this is profitable
11827 ;; only if the large constant is only used for the comparison (and in this
11828 ;; case we already have a register to reuse as scratch).
11829 ;;
11830 ;; For 64-bit registers, we could only do so if the constant's bit 15 is clear:
11831 ;; otherwise we'd need to XOR with FFFFFFFF????0000 which is not available.
11832
11833 (define_peephole2
11834 [(set (match_operand:SI 0 "register_operand")
11835 (match_operand:SI 1 "logical_const_operand" ""))
11836 (set (match_dup 0) (match_operator:SI 3 "boolean_or_operator"
11837 [(match_dup 0)
11838 (match_operand:SI 2 "logical_const_operand" "")]))
11839 (set (match_operand:CC 4 "cc_reg_operand" "")
11840 (compare:CC (match_operand:SI 5 "gpc_reg_operand" "")
11841 (match_dup 0)))
11842 (set (pc)
11843 (if_then_else (match_operator 6 "equality_operator"
11844 [(match_dup 4) (const_int 0)])
11845 (match_operand 7 "" "")
11846 (match_operand 8 "" "")))]
11847 "peep2_reg_dead_p (3, operands[0])
11848 && peep2_reg_dead_p (4, operands[4])"
11849 [(set (match_dup 0) (xor:SI (match_dup 5) (match_dup 9)))
11850 (set (match_dup 4) (compare:CC (match_dup 0) (match_dup 10)))
11851 (set (pc) (if_then_else (match_dup 6) (match_dup 7) (match_dup 8)))]
11852
11853 {
11854 /* Get the constant we are comparing against, and see what it looks like
11855 when sign-extended from 16 to 32 bits. Then see what constant we could
11856 XOR with SEXTC to get the sign-extended value. */
11857 rtx cnst = simplify_const_binary_operation (GET_CODE (operands[3]),
11858 SImode,
11859 operands[1], operands[2]);
11860 HOST_WIDE_INT c = INTVAL (cnst);
11861 HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
11862 HOST_WIDE_INT xorv = c ^ sextc;
11863
11864 operands[9] = GEN_INT (xorv);
11865 operands[10] = GEN_INT (sextc);
11866 })
11867
11868 (define_insn "*cmpsi_internal2"
11869 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11870 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11871 (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
11872 ""
11873 "{cmpl%I2|cmplw%I2} %0,%1,%b2"
11874 [(set_attr "type" "cmp")])
11875
11876 (define_insn "*cmpdi_internal2"
11877 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11878 (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
11879 (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
11880 ""
11881 "cmpld%I2 %0,%1,%b2"
11882 [(set_attr "type" "cmp")])
11883
11884 ;; The following two insns don't exist as single insns, but if we provide
11885 ;; them, we can swap an add and compare, which will enable us to overlap more
11886 ;; of the required delay between a compare and branch. We generate code for
11887 ;; them by splitting.
11888
11889 (define_insn ""
11890 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
11891 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
11892 (match_operand:SI 2 "short_cint_operand" "i")))
11893 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
11894 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11895 ""
11896 "#"
11897 [(set_attr "length" "8")])
11898
11899 (define_insn ""
11900 [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
11901 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11902 (match_operand:SI 2 "u_short_cint_operand" "i")))
11903 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
11904 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11905 ""
11906 "#"
11907 [(set_attr "length" "8")])
11908
11909 (define_split
11910 [(set (match_operand:CC 3 "cc_reg_operand" "")
11911 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
11912 (match_operand:SI 2 "short_cint_operand" "")))
11913 (set (match_operand:SI 0 "gpc_reg_operand" "")
11914 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11915 ""
11916 [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
11917 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11918
11919 (define_split
11920 [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
11921 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
11922 (match_operand:SI 2 "u_short_cint_operand" "")))
11923 (set (match_operand:SI 0 "gpc_reg_operand" "")
11924 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11925 ""
11926 [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
11927 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11928
11929 (define_insn "*cmpsf_internal1"
11930 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11931 (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
11932 (match_operand:SF 2 "gpc_reg_operand" "f")))]
11933 "TARGET_HARD_FLOAT && TARGET_FPRS"
11934 "fcmpu %0,%1,%2"
11935 [(set_attr "type" "fpcompare")])
11936
11937 (define_insn "*cmpdf_internal1"
11938 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11939 (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
11940 (match_operand:DF 2 "gpc_reg_operand" "f")))]
11941 "TARGET_HARD_FLOAT && TARGET_FPRS"
11942 "fcmpu %0,%1,%2"
11943 [(set_attr "type" "fpcompare")])
11944
11945 ;; Only need to compare second words if first words equal
11946 (define_insn "*cmptf_internal1"
11947 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11948 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
11949 (match_operand:TF 2 "gpc_reg_operand" "f")))]
11950 "!TARGET_IEEEQUAD && !TARGET_XL_COMPAT
11951 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
11952 "fcmpu %0,%1,%2\;bne %0,$+8\;fcmpu %0,%L1,%L2"
11953 [(set_attr "type" "fpcompare")
11954 (set_attr "length" "12")])
11955
11956 (define_insn_and_split "*cmptf_internal2"
11957 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11958 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
11959 (match_operand:TF 2 "gpc_reg_operand" "f")))
11960 (clobber (match_scratch:DF 3 "=f"))
11961 (clobber (match_scratch:DF 4 "=f"))
11962 (clobber (match_scratch:DF 5 "=f"))
11963 (clobber (match_scratch:DF 6 "=f"))
11964 (clobber (match_scratch:DF 7 "=f"))
11965 (clobber (match_scratch:DF 8 "=f"))
11966 (clobber (match_scratch:DF 9 "=f"))
11967 (clobber (match_scratch:DF 10 "=f"))]
11968 "!TARGET_IEEEQUAD && TARGET_XL_COMPAT
11969 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
11970 "#"
11971 "&& reload_completed"
11972 [(set (match_dup 3) (match_dup 13))
11973 (set (match_dup 4) (match_dup 14))
11974 (set (match_dup 9) (abs:DF (match_dup 5)))
11975 (set (match_dup 0) (compare:CCFP (match_dup 9) (match_dup 3)))
11976 (set (pc) (if_then_else (ne (match_dup 0) (const_int 0))
11977 (label_ref (match_dup 11))
11978 (pc)))
11979 (set (match_dup 0) (compare:CCFP (match_dup 5) (match_dup 7)))
11980 (set (pc) (label_ref (match_dup 12)))
11981 (match_dup 11)
11982 (set (match_dup 10) (minus:DF (match_dup 5) (match_dup 7)))
11983 (set (match_dup 9) (minus:DF (match_dup 6) (match_dup 8)))
11984 (set (match_dup 9) (plus:DF (match_dup 10) (match_dup 9)))
11985 (set (match_dup 0) (compare:CCFP (match_dup 7) (match_dup 4)))
11986 (match_dup 12)]
11987 {
11988 REAL_VALUE_TYPE rv;
11989 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
11990 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
11991
11992 operands[5] = simplify_gen_subreg (DFmode, operands[1], TFmode, hi_word);
11993 operands[6] = simplify_gen_subreg (DFmode, operands[1], TFmode, lo_word);
11994 operands[7] = simplify_gen_subreg (DFmode, operands[2], TFmode, hi_word);
11995 operands[8] = simplify_gen_subreg (DFmode, operands[2], TFmode, lo_word);
11996 operands[11] = gen_label_rtx ();
11997 operands[12] = gen_label_rtx ();
11998 real_inf (&rv);
11999 operands[13] = force_const_mem (DFmode,
12000 CONST_DOUBLE_FROM_REAL_VALUE (rv, DFmode));
12001 operands[14] = force_const_mem (DFmode,
12002 CONST_DOUBLE_FROM_REAL_VALUE (dconst0,
12003 DFmode));
12004 if (TARGET_TOC)
12005 {
12006 operands[13] = gen_const_mem (DFmode,
12007 create_TOC_reference (XEXP (operands[13], 0)));
12008 operands[14] = gen_const_mem (DFmode,
12009 create_TOC_reference (XEXP (operands[14], 0)));
12010 set_mem_alias_set (operands[13], get_TOC_alias_set ());
12011 set_mem_alias_set (operands[14], get_TOC_alias_set ());
12012 }
12013 })
12014 \f
12015 ;; Now we have the scc insns. We can do some combinations because of the
12016 ;; way the machine works.
12017 ;;
12018 ;; Note that this is probably faster if we can put an insn between the
12019 ;; mfcr and rlinm, but this is tricky. Let's leave it for now. In most
12020 ;; cases the insns below which don't use an intermediate CR field will
12021 ;; be used instead.
12022 (define_insn ""
12023 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12024 (match_operator:SI 1 "scc_comparison_operator"
12025 [(match_operand 2 "cc_reg_operand" "y")
12026 (const_int 0)]))]
12027 ""
12028 "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
12029 [(set (attr "type")
12030 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
12031 (const_string "mfcrf")
12032 ]
12033 (const_string "mfcr")))
12034 (set_attr "length" "8")])
12035
12036 ;; Same as above, but get the GT bit.
12037 (define_insn "move_from_CR_gt_bit"
12038 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12039 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_GT))]
12040 "TARGET_E500"
12041 "mfcr %0\;{rlinm|rlwinm} %0,%0,%D1,31,31"
12042 [(set_attr "type" "mfcr")
12043 (set_attr "length" "8")])
12044
12045 ;; Same as above, but get the OV/ORDERED bit.
12046 (define_insn "move_from_CR_ov_bit"
12047 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12048 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_OV))]
12049 "TARGET_ISEL"
12050 "mfcr %0\;{rlinm|rlwinm} %0,%0,%t1,1"
12051 [(set_attr "type" "mfcr")
12052 (set_attr "length" "8")])
12053
12054 (define_insn ""
12055 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12056 (match_operator:DI 1 "scc_comparison_operator"
12057 [(match_operand 2 "cc_reg_operand" "y")
12058 (const_int 0)]))]
12059 "TARGET_POWERPC64"
12060 "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
12061 [(set (attr "type")
12062 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
12063 (const_string "mfcrf")
12064 ]
12065 (const_string "mfcr")))
12066 (set_attr "length" "8")])
12067
12068 (define_insn ""
12069 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12070 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
12071 [(match_operand 2 "cc_reg_operand" "y,y")
12072 (const_int 0)])
12073 (const_int 0)))
12074 (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
12075 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
12076 "TARGET_32BIT"
12077 "@
12078 mfcr %3%Q2\;{rlinm.|rlwinm.} %3,%3,%J1,1
12079 #"
12080 [(set_attr "type" "delayed_compare")
12081 (set_attr "length" "8,16")])
12082
12083 (define_split
12084 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12085 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
12086 [(match_operand 2 "cc_reg_operand" "")
12087 (const_int 0)])
12088 (const_int 0)))
12089 (set (match_operand:SI 3 "gpc_reg_operand" "")
12090 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
12091 "TARGET_32BIT && reload_completed"
12092 [(set (match_dup 3)
12093 (match_op_dup 1 [(match_dup 2) (const_int 0)]))
12094 (set (match_dup 0)
12095 (compare:CC (match_dup 3)
12096 (const_int 0)))]
12097 "")
12098
12099 (define_insn ""
12100 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12101 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
12102 [(match_operand 2 "cc_reg_operand" "y")
12103 (const_int 0)])
12104 (match_operand:SI 3 "const_int_operand" "n")))]
12105 ""
12106 "*
12107 {
12108 int is_bit = ccr_bit (operands[1], 1);
12109 int put_bit = 31 - (INTVAL (operands[3]) & 31);
12110 int count;
12111
12112 if (is_bit >= put_bit)
12113 count = is_bit - put_bit;
12114 else
12115 count = 32 - (put_bit - is_bit);
12116
12117 operands[4] = GEN_INT (count);
12118 operands[5] = GEN_INT (put_bit);
12119
12120 return \"mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
12121 }"
12122 [(set (attr "type")
12123 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
12124 (const_string "mfcrf")
12125 ]
12126 (const_string "mfcr")))
12127 (set_attr "length" "8")])
12128
12129 (define_insn ""
12130 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12131 (compare:CC
12132 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
12133 [(match_operand 2 "cc_reg_operand" "y,y")
12134 (const_int 0)])
12135 (match_operand:SI 3 "const_int_operand" "n,n"))
12136 (const_int 0)))
12137 (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
12138 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
12139 (match_dup 3)))]
12140 ""
12141 "*
12142 {
12143 int is_bit = ccr_bit (operands[1], 1);
12144 int put_bit = 31 - (INTVAL (operands[3]) & 31);
12145 int count;
12146
12147 /* Force split for non-cc0 compare. */
12148 if (which_alternative == 1)
12149 return \"#\";
12150
12151 if (is_bit >= put_bit)
12152 count = is_bit - put_bit;
12153 else
12154 count = 32 - (put_bit - is_bit);
12155
12156 operands[5] = GEN_INT (count);
12157 operands[6] = GEN_INT (put_bit);
12158
12159 return \"mfcr %4%Q2\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
12160 }"
12161 [(set_attr "type" "delayed_compare")
12162 (set_attr "length" "8,16")])
12163
12164 (define_split
12165 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12166 (compare:CC
12167 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
12168 [(match_operand 2 "cc_reg_operand" "")
12169 (const_int 0)])
12170 (match_operand:SI 3 "const_int_operand" ""))
12171 (const_int 0)))
12172 (set (match_operand:SI 4 "gpc_reg_operand" "")
12173 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
12174 (match_dup 3)))]
12175 "reload_completed"
12176 [(set (match_dup 4)
12177 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
12178 (match_dup 3)))
12179 (set (match_dup 0)
12180 (compare:CC (match_dup 4)
12181 (const_int 0)))]
12182 "")
12183
12184 ;; There is a 3 cycle delay between consecutive mfcr instructions
12185 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
12186
12187 (define_peephole
12188 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12189 (match_operator:SI 1 "scc_comparison_operator"
12190 [(match_operand 2 "cc_reg_operand" "y")
12191 (const_int 0)]))
12192 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
12193 (match_operator:SI 4 "scc_comparison_operator"
12194 [(match_operand 5 "cc_reg_operand" "y")
12195 (const_int 0)]))]
12196 "REGNO (operands[2]) != REGNO (operands[5])"
12197 "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
12198 [(set_attr "type" "mfcr")
12199 (set_attr "length" "12")])
12200
12201 (define_peephole
12202 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12203 (match_operator:DI 1 "scc_comparison_operator"
12204 [(match_operand 2 "cc_reg_operand" "y")
12205 (const_int 0)]))
12206 (set (match_operand:DI 3 "gpc_reg_operand" "=r")
12207 (match_operator:DI 4 "scc_comparison_operator"
12208 [(match_operand 5 "cc_reg_operand" "y")
12209 (const_int 0)]))]
12210 "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
12211 "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
12212 [(set_attr "type" "mfcr")
12213 (set_attr "length" "12")])
12214
12215 ;; There are some scc insns that can be done directly, without a compare.
12216 ;; These are faster because they don't involve the communications between
12217 ;; the FXU and branch units. In fact, we will be replacing all of the
12218 ;; integer scc insns here or in the portable methods in emit_store_flag.
12219 ;;
12220 ;; Also support (neg (scc ..)) since that construct is used to replace
12221 ;; branches, (plus (scc ..) ..) since that construct is common and
12222 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
12223 ;; cases where it is no more expensive than (neg (scc ..)).
12224
12225 ;; Have reload force a constant into a register for the simple insns that
12226 ;; otherwise won't accept constants. We do this because it is faster than
12227 ;; the cmp/mfcr sequence we would otherwise generate.
12228
12229 (define_mode_attr scc_eq_op2 [(SI "rKLI")
12230 (DI "rKJI")])
12231
12232 (define_insn_and_split "*eq<mode>"
12233 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
12234 (eq:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
12235 (match_operand:GPR 2 "scc_eq_operand" "<scc_eq_op2>")))]
12236 "!TARGET_POWER"
12237 "#"
12238 "!TARGET_POWER"
12239 [(set (match_dup 0)
12240 (clz:GPR (match_dup 3)))
12241 (set (match_dup 0)
12242 (lshiftrt:GPR (match_dup 0) (match_dup 4)))]
12243 {
12244 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
12245 {
12246 /* Use output operand as intermediate. */
12247 operands[3] = operands[0];
12248
12249 if (logical_operand (operands[2], <MODE>mode))
12250 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12251 gen_rtx_XOR (<MODE>mode,
12252 operands[1], operands[2])));
12253 else
12254 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12255 gen_rtx_PLUS (<MODE>mode, operands[1],
12256 negate_rtx (<MODE>mode,
12257 operands[2]))));
12258 }
12259 else
12260 operands[3] = operands[1];
12261
12262 operands[4] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
12263 })
12264
12265 (define_insn_and_split "*eq<mode>_compare"
12266 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
12267 (compare:CC
12268 (eq:P (match_operand:P 1 "gpc_reg_operand" "=r")
12269 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))
12270 (const_int 0)))
12271 (set (match_operand:P 0 "gpc_reg_operand" "=r")
12272 (eq:P (match_dup 1) (match_dup 2)))]
12273 "!TARGET_POWER && optimize_size"
12274 "#"
12275 "!TARGET_POWER && optimize_size"
12276 [(set (match_dup 0)
12277 (clz:P (match_dup 4)))
12278 (parallel [(set (match_dup 3)
12279 (compare:CC (lshiftrt:P (match_dup 0) (match_dup 5))
12280 (const_int 0)))
12281 (set (match_dup 0)
12282 (lshiftrt:P (match_dup 0) (match_dup 5)))])]
12283 {
12284 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
12285 {
12286 /* Use output operand as intermediate. */
12287 operands[4] = operands[0];
12288
12289 if (logical_operand (operands[2], <MODE>mode))
12290 emit_insn (gen_rtx_SET (VOIDmode, operands[4],
12291 gen_rtx_XOR (<MODE>mode,
12292 operands[1], operands[2])));
12293 else
12294 emit_insn (gen_rtx_SET (VOIDmode, operands[4],
12295 gen_rtx_PLUS (<MODE>mode, operands[1],
12296 negate_rtx (<MODE>mode,
12297 operands[2]))));
12298 }
12299 else
12300 operands[4] = operands[1];
12301
12302 operands[5] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
12303 })
12304
12305 (define_insn "*eqsi_power"
12306 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
12307 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
12308 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I")))
12309 (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
12310 "TARGET_POWER"
12311 "@
12312 xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
12313 {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
12314 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
12315 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
12316 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
12317 [(set_attr "type" "three,two,three,three,three")
12318 (set_attr "length" "12,8,12,12,12")])
12319
12320 ;; We have insns of the form shown by the first define_insn below. If
12321 ;; there is something inside the comparison operation, we must split it.
12322 (define_split
12323 [(set (match_operand:SI 0 "gpc_reg_operand" "")
12324 (plus:SI (match_operator 1 "comparison_operator"
12325 [(match_operand:SI 2 "" "")
12326 (match_operand:SI 3
12327 "reg_or_cint_operand" "")])
12328 (match_operand:SI 4 "gpc_reg_operand" "")))
12329 (clobber (match_operand:SI 5 "register_operand" ""))]
12330 "! gpc_reg_operand (operands[2], SImode)"
12331 [(set (match_dup 5) (match_dup 2))
12332 (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
12333 (match_dup 4)))])
12334
12335 (define_insn "*plus_eqsi"
12336 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
12337 (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
12338 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I"))
12339 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
12340 "TARGET_32BIT"
12341 "@
12342 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
12343 {sfi|subfic} %0,%1,0\;{aze|addze} %0,%3
12344 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
12345 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
12346 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
12347 [(set_attr "type" "three,two,three,three,three")
12348 (set_attr "length" "12,8,12,12,12")])
12349
12350 (define_insn "*compare_plus_eqsi"
12351 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
12352 (compare:CC
12353 (plus:SI
12354 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
12355 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
12356 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
12357 (const_int 0)))
12358 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
12359 "TARGET_32BIT && optimize_size"
12360 "@
12361 xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12362 {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
12363 {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12364 {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12365 {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12366 #
12367 #
12368 #
12369 #
12370 #"
12371 [(set_attr "type" "compare")
12372 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
12373
12374 (define_split
12375 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12376 (compare:CC
12377 (plus:SI
12378 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
12379 (match_operand:SI 2 "scc_eq_operand" ""))
12380 (match_operand:SI 3 "gpc_reg_operand" ""))
12381 (const_int 0)))
12382 (clobber (match_scratch:SI 4 ""))]
12383 "TARGET_32BIT && optimize_size && reload_completed"
12384 [(set (match_dup 4)
12385 (plus:SI (eq:SI (match_dup 1)
12386 (match_dup 2))
12387 (match_dup 3)))
12388 (set (match_dup 0)
12389 (compare:CC (match_dup 4)
12390 (const_int 0)))]
12391 "")
12392
12393 (define_insn "*plus_eqsi_compare"
12394 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
12395 (compare:CC
12396 (plus:SI
12397 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
12398 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
12399 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
12400 (const_int 0)))
12401 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
12402 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12403 "TARGET_32BIT && optimize_size"
12404 "@
12405 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12406 {sfi|subfic} %0,%1,0\;{aze.|addze.} %0,%3
12407 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12408 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12409 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12410 #
12411 #
12412 #
12413 #
12414 #"
12415 [(set_attr "type" "compare")
12416 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
12417
12418 (define_split
12419 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12420 (compare:CC
12421 (plus:SI
12422 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
12423 (match_operand:SI 2 "scc_eq_operand" ""))
12424 (match_operand:SI 3 "gpc_reg_operand" ""))
12425 (const_int 0)))
12426 (set (match_operand:SI 0 "gpc_reg_operand" "")
12427 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12428 "TARGET_32BIT && optimize_size && reload_completed"
12429 [(set (match_dup 0)
12430 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12431 (set (match_dup 4)
12432 (compare:CC (match_dup 0)
12433 (const_int 0)))]
12434 "")
12435
12436 (define_insn "*neg_eq0<mode>"
12437 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12438 (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "r")
12439 (const_int 0))))]
12440 ""
12441 "{ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0"
12442 [(set_attr "type" "two")
12443 (set_attr "length" "8")])
12444
12445 (define_insn_and_split "*neg_eq<mode>"
12446 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12447 (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "%r")
12448 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))))]
12449 ""
12450 "#"
12451 ""
12452 [(set (match_dup 0) (neg:P (eq:P (match_dup 3) (const_int 0))))]
12453 {
12454 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
12455 {
12456 /* Use output operand as intermediate. */
12457 operands[3] = operands[0];
12458
12459 if (logical_operand (operands[2], <MODE>mode))
12460 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12461 gen_rtx_XOR (<MODE>mode,
12462 operands[1], operands[2])));
12463 else
12464 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12465 gen_rtx_PLUS (<MODE>mode, operands[1],
12466 negate_rtx (<MODE>mode,
12467 operands[2]))));
12468 }
12469 else
12470 operands[3] = operands[1];
12471 })
12472
12473 ;; Simplify (ne X (const_int 0)) on the PowerPC. No need to on the Power,
12474 ;; since it nabs/sr is just as fast.
12475 (define_insn "*ne0si"
12476 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12477 (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
12478 (const_int 31)))
12479 (clobber (match_scratch:SI 2 "=&r"))]
12480 "! TARGET_POWER && TARGET_32BIT && !TARGET_ISEL"
12481 "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
12482 [(set_attr "type" "two")
12483 (set_attr "length" "8")])
12484
12485 (define_insn "*ne0di"
12486 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12487 (lshiftrt:DI (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
12488 (const_int 63)))
12489 (clobber (match_scratch:DI 2 "=&r"))]
12490 "TARGET_64BIT"
12491 "addic %2,%1,-1\;subfe %0,%2,%1"
12492 [(set_attr "type" "two")
12493 (set_attr "length" "8")])
12494
12495 ;; This is what (plus (ne X (const_int 0)) Y) looks like.
12496 (define_insn "*plus_ne0si"
12497 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12498 (plus:SI (lshiftrt:SI
12499 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
12500 (const_int 31))
12501 (match_operand:SI 2 "gpc_reg_operand" "r")))
12502 (clobber (match_scratch:SI 3 "=&r"))]
12503 "TARGET_32BIT"
12504 "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
12505 [(set_attr "type" "two")
12506 (set_attr "length" "8")])
12507
12508 (define_insn "*plus_ne0di"
12509 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12510 (plus:DI (lshiftrt:DI
12511 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
12512 (const_int 63))
12513 (match_operand:DI 2 "gpc_reg_operand" "r")))
12514 (clobber (match_scratch:DI 3 "=&r"))]
12515 "TARGET_64BIT"
12516 "addic %3,%1,-1\;addze %0,%2"
12517 [(set_attr "type" "two")
12518 (set_attr "length" "8")])
12519
12520 (define_insn "*compare_plus_ne0si"
12521 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12522 (compare:CC
12523 (plus:SI (lshiftrt:SI
12524 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
12525 (const_int 31))
12526 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12527 (const_int 0)))
12528 (clobber (match_scratch:SI 3 "=&r,&r"))
12529 (clobber (match_scratch:SI 4 "=X,&r"))]
12530 "TARGET_32BIT"
12531 "@
12532 {ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2
12533 #"
12534 [(set_attr "type" "compare")
12535 (set_attr "length" "8,12")])
12536
12537 (define_split
12538 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12539 (compare:CC
12540 (plus:SI (lshiftrt:SI
12541 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
12542 (const_int 31))
12543 (match_operand:SI 2 "gpc_reg_operand" ""))
12544 (const_int 0)))
12545 (clobber (match_scratch:SI 3 ""))
12546 (clobber (match_scratch:SI 4 ""))]
12547 "TARGET_32BIT && reload_completed"
12548 [(parallel [(set (match_dup 3)
12549 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1)))
12550 (const_int 31))
12551 (match_dup 2)))
12552 (clobber (match_dup 4))])
12553 (set (match_dup 0)
12554 (compare:CC (match_dup 3)
12555 (const_int 0)))]
12556 "")
12557
12558 (define_insn "*compare_plus_ne0di"
12559 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12560 (compare:CC
12561 (plus:DI (lshiftrt:DI
12562 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
12563 (const_int 63))
12564 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12565 (const_int 0)))
12566 (clobber (match_scratch:DI 3 "=&r,&r"))]
12567 "TARGET_64BIT"
12568 "@
12569 addic %3,%1,-1\;addze. %3,%2
12570 #"
12571 [(set_attr "type" "compare")
12572 (set_attr "length" "8,12")])
12573
12574 (define_split
12575 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12576 (compare:CC
12577 (plus:DI (lshiftrt:DI
12578 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
12579 (const_int 63))
12580 (match_operand:DI 2 "gpc_reg_operand" ""))
12581 (const_int 0)))
12582 (clobber (match_scratch:DI 3 ""))]
12583 "TARGET_64BIT && reload_completed"
12584 [(set (match_dup 3)
12585 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1)))
12586 (const_int 63))
12587 (match_dup 2)))
12588 (set (match_dup 0)
12589 (compare:CC (match_dup 3)
12590 (const_int 0)))]
12591 "")
12592
12593 (define_insn "*plus_ne0si_compare"
12594 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12595 (compare:CC
12596 (plus:SI (lshiftrt:SI
12597 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
12598 (const_int 31))
12599 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12600 (const_int 0)))
12601 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12602 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
12603 (match_dup 2)))
12604 (clobber (match_scratch:SI 3 "=&r,&r"))]
12605 "TARGET_32BIT"
12606 "@
12607 {ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2
12608 #"
12609 [(set_attr "type" "compare")
12610 (set_attr "length" "8,12")])
12611
12612 (define_split
12613 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12614 (compare:CC
12615 (plus:SI (lshiftrt:SI
12616 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
12617 (const_int 31))
12618 (match_operand:SI 2 "gpc_reg_operand" ""))
12619 (const_int 0)))
12620 (set (match_operand:SI 0 "gpc_reg_operand" "")
12621 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
12622 (match_dup 2)))
12623 (clobber (match_scratch:SI 3 ""))]
12624 "TARGET_32BIT && reload_completed"
12625 [(parallel [(set (match_dup 0)
12626 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
12627 (match_dup 2)))
12628 (clobber (match_dup 3))])
12629 (set (match_dup 4)
12630 (compare:CC (match_dup 0)
12631 (const_int 0)))]
12632 "")
12633
12634 (define_insn "*plus_ne0di_compare"
12635 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12636 (compare:CC
12637 (plus:DI (lshiftrt:DI
12638 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
12639 (const_int 63))
12640 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12641 (const_int 0)))
12642 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12643 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12644 (match_dup 2)))
12645 (clobber (match_scratch:DI 3 "=&r,&r"))]
12646 "TARGET_64BIT"
12647 "@
12648 addic %3,%1,-1\;addze. %0,%2
12649 #"
12650 [(set_attr "type" "compare")
12651 (set_attr "length" "8,12")])
12652
12653 (define_split
12654 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12655 (compare:CC
12656 (plus:DI (lshiftrt:DI
12657 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
12658 (const_int 63))
12659 (match_operand:DI 2 "gpc_reg_operand" ""))
12660 (const_int 0)))
12661 (set (match_operand:DI 0 "gpc_reg_operand" "")
12662 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12663 (match_dup 2)))
12664 (clobber (match_scratch:DI 3 ""))]
12665 "TARGET_64BIT && reload_completed"
12666 [(parallel [(set (match_dup 0)
12667 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12668 (match_dup 2)))
12669 (clobber (match_dup 3))])
12670 (set (match_dup 4)
12671 (compare:CC (match_dup 0)
12672 (const_int 0)))]
12673 "")
12674
12675 (define_insn ""
12676 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12677 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12678 (match_operand:SI 2 "reg_or_short_operand" "r,O")))
12679 (clobber (match_scratch:SI 3 "=r,X"))]
12680 "TARGET_POWER"
12681 "@
12682 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
12683 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
12684 [(set_attr "length" "12")])
12685
12686 (define_insn ""
12687 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12688 (compare:CC
12689 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12690 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12691 (const_int 0)))
12692 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12693 (le:SI (match_dup 1) (match_dup 2)))
12694 (clobber (match_scratch:SI 3 "=r,X,r,X"))]
12695 "TARGET_POWER"
12696 "@
12697 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
12698 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31
12699 #
12700 #"
12701 [(set_attr "type" "compare,delayed_compare,compare,delayed_compare")
12702 (set_attr "length" "12,12,16,16")])
12703
12704 (define_split
12705 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12706 (compare:CC
12707 (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12708 (match_operand:SI 2 "reg_or_short_operand" ""))
12709 (const_int 0)))
12710 (set (match_operand:SI 0 "gpc_reg_operand" "")
12711 (le:SI (match_dup 1) (match_dup 2)))
12712 (clobber (match_scratch:SI 3 ""))]
12713 "TARGET_POWER && reload_completed"
12714 [(parallel [(set (match_dup 0)
12715 (le:SI (match_dup 1) (match_dup 2)))
12716 (clobber (match_dup 3))])
12717 (set (match_dup 4)
12718 (compare:CC (match_dup 0)
12719 (const_int 0)))]
12720 "")
12721
12722 (define_insn ""
12723 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12724 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12725 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
12726 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
12727 "TARGET_POWER"
12728 "@
12729 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
12730 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze|addze} %0,%3"
12731 [(set_attr "length" "12")])
12732
12733 (define_insn ""
12734 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12735 (compare:CC
12736 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12737 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12738 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12739 (const_int 0)))
12740 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12741 "TARGET_POWER"
12742 "@
12743 doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12744 {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3
12745 #
12746 #"
12747 [(set_attr "type" "compare")
12748 (set_attr "length" "12,12,16,16")])
12749
12750 (define_split
12751 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12752 (compare:CC
12753 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12754 (match_operand:SI 2 "reg_or_short_operand" ""))
12755 (match_operand:SI 3 "gpc_reg_operand" ""))
12756 (const_int 0)))
12757 (clobber (match_scratch:SI 4 ""))]
12758 "TARGET_POWER && reload_completed"
12759 [(set (match_dup 4)
12760 (plus:SI (le:SI (match_dup 1) (match_dup 2))
12761 (match_dup 3)))
12762 (set (match_dup 0)
12763 (compare:CC (match_dup 4)
12764 (const_int 0)))]
12765 "")
12766
12767 (define_insn ""
12768 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12769 (compare:CC
12770 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12771 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12772 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12773 (const_int 0)))
12774 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12775 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12776 "TARGET_POWER"
12777 "@
12778 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12779 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze.|addze.} %0,%3
12780 #
12781 #"
12782 [(set_attr "type" "compare")
12783 (set_attr "length" "12,12,16,16")])
12784
12785 (define_split
12786 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12787 (compare:CC
12788 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12789 (match_operand:SI 2 "reg_or_short_operand" ""))
12790 (match_operand:SI 3 "gpc_reg_operand" ""))
12791 (const_int 0)))
12792 (set (match_operand:SI 0 "gpc_reg_operand" "")
12793 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12794 "TARGET_POWER && reload_completed"
12795 [(set (match_dup 0)
12796 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12797 (set (match_dup 4)
12798 (compare:CC (match_dup 0)
12799 (const_int 0)))]
12800 "")
12801
12802 (define_insn ""
12803 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12804 (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12805 (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
12806 "TARGET_POWER"
12807 "@
12808 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
12809 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
12810 [(set_attr "length" "12")])
12811
12812 (define_insn "*leu<mode>"
12813 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12814 (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12815 (match_operand:P 2 "reg_or_short_operand" "rI")))]
12816 ""
12817 "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
12818 [(set_attr "type" "three")
12819 (set_attr "length" "12")])
12820
12821 (define_insn "*leu<mode>_compare"
12822 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12823 (compare:CC
12824 (leu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12825 (match_operand:P 2 "reg_or_short_operand" "rI,rI"))
12826 (const_int 0)))
12827 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12828 (leu:P (match_dup 1) (match_dup 2)))]
12829 ""
12830 "@
12831 {sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12832 #"
12833 [(set_attr "type" "compare")
12834 (set_attr "length" "12,16")])
12835
12836 (define_split
12837 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12838 (compare:CC
12839 (leu:P (match_operand:P 1 "gpc_reg_operand" "")
12840 (match_operand:P 2 "reg_or_short_operand" ""))
12841 (const_int 0)))
12842 (set (match_operand:P 0 "gpc_reg_operand" "")
12843 (leu:P (match_dup 1) (match_dup 2)))]
12844 "reload_completed"
12845 [(set (match_dup 0)
12846 (leu:P (match_dup 1) (match_dup 2)))
12847 (set (match_dup 3)
12848 (compare:CC (match_dup 0)
12849 (const_int 0)))]
12850 "")
12851
12852 (define_insn "*plus_leu<mode>"
12853 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12854 (plus:P (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12855 (match_operand:P 2 "reg_or_short_operand" "rI"))
12856 (match_operand:P 3 "gpc_reg_operand" "r")))]
12857 ""
12858 "{sf%I2|subf%I2c} %0,%1,%2\;{aze|addze} %0,%3"
12859 [(set_attr "type" "two")
12860 (set_attr "length" "8")])
12861
12862 (define_insn ""
12863 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12864 (compare:CC
12865 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12866 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12867 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12868 (const_int 0)))
12869 (clobber (match_scratch:SI 4 "=&r,&r"))]
12870 "TARGET_32BIT"
12871 "@
12872 {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3
12873 #"
12874 [(set_attr "type" "compare")
12875 (set_attr "length" "8,12")])
12876
12877 (define_split
12878 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12879 (compare:CC
12880 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12881 (match_operand:SI 2 "reg_or_short_operand" ""))
12882 (match_operand:SI 3 "gpc_reg_operand" ""))
12883 (const_int 0)))
12884 (clobber (match_scratch:SI 4 ""))]
12885 "TARGET_32BIT && reload_completed"
12886 [(set (match_dup 4)
12887 (plus:SI (leu:SI (match_dup 1) (match_dup 2))
12888 (match_dup 3)))
12889 (set (match_dup 0)
12890 (compare:CC (match_dup 4)
12891 (const_int 0)))]
12892 "")
12893
12894 (define_insn ""
12895 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12896 (compare:CC
12897 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12898 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12899 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12900 (const_int 0)))
12901 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12902 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12903 "TARGET_32BIT"
12904 "@
12905 {sf%I2|subf%I2c} %0,%1,%2\;{aze.|addze.} %0,%3
12906 #"
12907 [(set_attr "type" "compare")
12908 (set_attr "length" "8,12")])
12909
12910 (define_split
12911 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12912 (compare:CC
12913 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12914 (match_operand:SI 2 "reg_or_short_operand" ""))
12915 (match_operand:SI 3 "gpc_reg_operand" ""))
12916 (const_int 0)))
12917 (set (match_operand:SI 0 "gpc_reg_operand" "")
12918 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12919 "TARGET_32BIT && reload_completed"
12920 [(set (match_dup 0)
12921 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12922 (set (match_dup 4)
12923 (compare:CC (match_dup 0)
12924 (const_int 0)))]
12925 "")
12926
12927 (define_insn "*neg_leu<mode>"
12928 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12929 (neg:P (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12930 (match_operand:P 2 "reg_or_short_operand" "rI"))))]
12931 ""
12932 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
12933 [(set_attr "type" "three")
12934 (set_attr "length" "12")])
12935
12936 (define_insn "*and_neg_leu<mode>"
12937 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12938 (and:P (neg:P
12939 (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12940 (match_operand:P 2 "reg_or_short_operand" "rI")))
12941 (match_operand:P 3 "gpc_reg_operand" "r")))]
12942 ""
12943 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
12944 [(set_attr "type" "three")
12945 (set_attr "length" "12")])
12946
12947 (define_insn ""
12948 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12949 (compare:CC
12950 (and:SI (neg:SI
12951 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12952 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12953 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12954 (const_int 0)))
12955 (clobber (match_scratch:SI 4 "=&r,&r"))]
12956 "TARGET_32BIT"
12957 "@
12958 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12959 #"
12960 [(set_attr "type" "compare")
12961 (set_attr "length" "12,16")])
12962
12963 (define_split
12964 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12965 (compare:CC
12966 (and:SI (neg:SI
12967 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12968 (match_operand:SI 2 "reg_or_short_operand" "")))
12969 (match_operand:SI 3 "gpc_reg_operand" ""))
12970 (const_int 0)))
12971 (clobber (match_scratch:SI 4 ""))]
12972 "TARGET_32BIT && reload_completed"
12973 [(set (match_dup 4)
12974 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12975 (match_dup 3)))
12976 (set (match_dup 0)
12977 (compare:CC (match_dup 4)
12978 (const_int 0)))]
12979 "")
12980
12981 (define_insn ""
12982 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12983 (compare:CC
12984 (and:SI (neg:SI
12985 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12986 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12987 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12988 (const_int 0)))
12989 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12990 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12991 "TARGET_32BIT"
12992 "@
12993 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
12994 #"
12995 [(set_attr "type" "compare")
12996 (set_attr "length" "12,16")])
12997
12998 (define_split
12999 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13000 (compare:CC
13001 (and:SI (neg:SI
13002 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13003 (match_operand:SI 2 "reg_or_short_operand" "")))
13004 (match_operand:SI 3 "gpc_reg_operand" ""))
13005 (const_int 0)))
13006 (set (match_operand:SI 0 "gpc_reg_operand" "")
13007 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
13008 "TARGET_32BIT && reload_completed"
13009 [(set (match_dup 0)
13010 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
13011 (match_dup 3)))
13012 (set (match_dup 4)
13013 (compare:CC (match_dup 0)
13014 (const_int 0)))]
13015 "")
13016
13017 (define_insn ""
13018 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13019 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13020 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
13021 "TARGET_POWER"
13022 "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
13023 [(set_attr "length" "12")])
13024
13025 (define_insn ""
13026 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13027 (compare:CC
13028 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13029 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13030 (const_int 0)))
13031 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
13032 (lt:SI (match_dup 1) (match_dup 2)))]
13033 "TARGET_POWER"
13034 "@
13035 doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
13036 #"
13037 [(set_attr "type" "delayed_compare")
13038 (set_attr "length" "12,16")])
13039
13040 (define_split
13041 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13042 (compare:CC
13043 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13044 (match_operand:SI 2 "reg_or_short_operand" ""))
13045 (const_int 0)))
13046 (set (match_operand:SI 0 "gpc_reg_operand" "")
13047 (lt:SI (match_dup 1) (match_dup 2)))]
13048 "TARGET_POWER && reload_completed"
13049 [(set (match_dup 0)
13050 (lt:SI (match_dup 1) (match_dup 2)))
13051 (set (match_dup 3)
13052 (compare:CC (match_dup 0)
13053 (const_int 0)))]
13054 "")
13055
13056 (define_insn ""
13057 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
13058 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13059 (match_operand:SI 2 "reg_or_short_operand" "rI"))
13060 (match_operand:SI 3 "gpc_reg_operand" "r")))]
13061 "TARGET_POWER"
13062 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
13063 [(set_attr "length" "12")])
13064
13065 (define_insn ""
13066 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
13067 (compare:CC
13068 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13069 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13070 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
13071 (const_int 0)))
13072 (clobber (match_scratch:SI 4 "=&r,&r"))]
13073 "TARGET_POWER"
13074 "@
13075 doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
13076 #"
13077 [(set_attr "type" "compare")
13078 (set_attr "length" "12,16")])
13079
13080 (define_split
13081 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13082 (compare:CC
13083 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13084 (match_operand:SI 2 "reg_or_short_operand" ""))
13085 (match_operand:SI 3 "gpc_reg_operand" ""))
13086 (const_int 0)))
13087 (clobber (match_scratch:SI 4 ""))]
13088 "TARGET_POWER && reload_completed"
13089 [(set (match_dup 4)
13090 (plus:SI (lt:SI (match_dup 1) (match_dup 2))
13091 (match_dup 3)))
13092 (set (match_dup 0)
13093 (compare:CC (match_dup 4)
13094 (const_int 0)))]
13095 "")
13096
13097 (define_insn ""
13098 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
13099 (compare:CC
13100 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13101 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13102 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
13103 (const_int 0)))
13104 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13105 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13106 "TARGET_POWER"
13107 "@
13108 doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
13109 #"
13110 [(set_attr "type" "compare")
13111 (set_attr "length" "12,16")])
13112
13113 (define_split
13114 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13115 (compare:CC
13116 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13117 (match_operand:SI 2 "reg_or_short_operand" ""))
13118 (match_operand:SI 3 "gpc_reg_operand" ""))
13119 (const_int 0)))
13120 (set (match_operand:SI 0 "gpc_reg_operand" "")
13121 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13122 "TARGET_POWER && reload_completed"
13123 [(set (match_dup 0)
13124 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13125 (set (match_dup 4)
13126 (compare:CC (match_dup 0)
13127 (const_int 0)))]
13128 "")
13129
13130 (define_insn ""
13131 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13132 (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13133 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
13134 "TARGET_POWER"
13135 "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
13136 [(set_attr "length" "12")])
13137
13138 (define_insn_and_split "*ltu<mode>"
13139 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
13140 (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13141 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))]
13142 ""
13143 "#"
13144 ""
13145 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
13146 (set (match_dup 0) (neg:P (match_dup 0)))]
13147 "")
13148
13149 (define_insn_and_split "*ltu<mode>_compare"
13150 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
13151 (compare:CC
13152 (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
13153 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
13154 (const_int 0)))
13155 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
13156 (ltu:P (match_dup 1) (match_dup 2)))]
13157 ""
13158 "#"
13159 ""
13160 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
13161 (parallel [(set (match_dup 3)
13162 (compare:CC (neg:P (match_dup 0)) (const_int 0)))
13163 (set (match_dup 0) (neg:P (match_dup 0)))])]
13164 "")
13165
13166 (define_insn_and_split "*plus_ltu<mode>"
13167 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,r")
13168 (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13169 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
13170 (match_operand:P 3 "reg_or_short_operand" "rI,rI")))]
13171 ""
13172 "#"
13173 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13174 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
13175 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))]
13176 "")
13177
13178 (define_insn_and_split "*plus_ltu<mode>_compare"
13179 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13180 (compare:CC
13181 (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
13182 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
13183 (match_operand:P 3 "gpc_reg_operand" "r,r,r,r"))
13184 (const_int 0)))
13185 (set (match_operand:P 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13186 (plus:P (ltu:P (match_dup 1) (match_dup 2)) (match_dup 3)))]
13187 ""
13188 "#"
13189 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13190 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
13191 (parallel [(set (match_dup 4)
13192 (compare:CC (minus:P (match_dup 3) (match_dup 0))
13193 (const_int 0)))
13194 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))])]
13195 "")
13196
13197 (define_insn "*neg_ltu<mode>"
13198 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
13199 (neg:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13200 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))))]
13201 ""
13202 "@
13203 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
13204 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
13205 [(set_attr "type" "two")
13206 (set_attr "length" "8")])
13207
13208 (define_insn ""
13209 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13210 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13211 (match_operand:SI 2 "reg_or_short_operand" "rI")))
13212 (clobber (match_scratch:SI 3 "=r"))]
13213 "TARGET_POWER"
13214 "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
13215 [(set_attr "length" "12")])
13216
13217 (define_insn ""
13218 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
13219 (compare:CC
13220 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13221 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13222 (const_int 0)))
13223 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
13224 (ge:SI (match_dup 1) (match_dup 2)))
13225 (clobber (match_scratch:SI 3 "=r,r"))]
13226 "TARGET_POWER"
13227 "@
13228 doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
13229 #"
13230 [(set_attr "type" "compare")
13231 (set_attr "length" "12,16")])
13232
13233 (define_split
13234 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13235 (compare:CC
13236 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
13237 (match_operand:SI 2 "reg_or_short_operand" ""))
13238 (const_int 0)))
13239 (set (match_operand:SI 0 "gpc_reg_operand" "")
13240 (ge:SI (match_dup 1) (match_dup 2)))
13241 (clobber (match_scratch:SI 3 ""))]
13242 "TARGET_POWER && reload_completed"
13243 [(parallel [(set (match_dup 0)
13244 (ge:SI (match_dup 1) (match_dup 2)))
13245 (clobber (match_dup 3))])
13246 (set (match_dup 4)
13247 (compare:CC (match_dup 0)
13248 (const_int 0)))]
13249 "")
13250
13251 (define_insn ""
13252 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
13253 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13254 (match_operand:SI 2 "reg_or_short_operand" "rI"))
13255 (match_operand:SI 3 "gpc_reg_operand" "r")))]
13256 "TARGET_POWER"
13257 "doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
13258 [(set_attr "length" "12")])
13259
13260 (define_insn ""
13261 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
13262 (compare:CC
13263 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13264 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13265 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
13266 (const_int 0)))
13267 (clobber (match_scratch:SI 4 "=&r,&r"))]
13268 "TARGET_POWER"
13269 "@
13270 doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
13271 #"
13272 [(set_attr "type" "compare")
13273 (set_attr "length" "12,16")])
13274
13275 (define_split
13276 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13277 (compare:CC
13278 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
13279 (match_operand:SI 2 "reg_or_short_operand" ""))
13280 (match_operand:SI 3 "gpc_reg_operand" ""))
13281 (const_int 0)))
13282 (clobber (match_scratch:SI 4 ""))]
13283 "TARGET_POWER && reload_completed"
13284 [(set (match_dup 4)
13285 (plus:SI (ge:SI (match_dup 1) (match_dup 2))
13286 (match_dup 3)))
13287 (set (match_dup 0)
13288 (compare:CC (match_dup 4)
13289 (const_int 0)))]
13290 "")
13291
13292 (define_insn ""
13293 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
13294 (compare:CC
13295 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13296 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13297 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
13298 (const_int 0)))
13299 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13300 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13301 "TARGET_POWER"
13302 "@
13303 doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
13304 #"
13305 [(set_attr "type" "compare")
13306 (set_attr "length" "12,16")])
13307
13308 (define_split
13309 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13310 (compare:CC
13311 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
13312 (match_operand:SI 2 "reg_or_short_operand" ""))
13313 (match_operand:SI 3 "gpc_reg_operand" ""))
13314 (const_int 0)))
13315 (set (match_operand:SI 0 "gpc_reg_operand" "")
13316 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13317 "TARGET_POWER && reload_completed"
13318 [(set (match_dup 0)
13319 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13320 (set (match_dup 4)
13321 (compare:CC (match_dup 0)
13322 (const_int 0)))]
13323 "")
13324
13325 (define_insn ""
13326 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13327 (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13328 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
13329 "TARGET_POWER"
13330 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
13331 [(set_attr "length" "12")])
13332
13333 (define_insn "*geu<mode>"
13334 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
13335 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13336 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))]
13337 ""
13338 "@
13339 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
13340 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
13341 [(set_attr "type" "three")
13342 (set_attr "length" "12")])
13343
13344 (define_insn "*geu<mode>_compare"
13345 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
13346 (compare:CC
13347 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
13348 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
13349 (const_int 0)))
13350 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
13351 (geu:P (match_dup 1) (match_dup 2)))]
13352 ""
13353 "@
13354 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
13355 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
13356 #
13357 #"
13358 [(set_attr "type" "compare")
13359 (set_attr "length" "12,12,16,16")])
13360
13361 (define_split
13362 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13363 (compare:CC
13364 (geu:P (match_operand:P 1 "gpc_reg_operand" "")
13365 (match_operand:P 2 "reg_or_neg_short_operand" ""))
13366 (const_int 0)))
13367 (set (match_operand:P 0 "gpc_reg_operand" "")
13368 (geu:P (match_dup 1) (match_dup 2)))]
13369 "reload_completed"
13370 [(set (match_dup 0)
13371 (geu:P (match_dup 1) (match_dup 2)))
13372 (set (match_dup 3)
13373 (compare:CC (match_dup 0)
13374 (const_int 0)))]
13375 "")
13376
13377 (define_insn "*plus_geu<mode>"
13378 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,&r")
13379 (plus:P (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13380 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
13381 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
13382 ""
13383 "@
13384 {sf|subfc} %0,%2,%1\;{aze|addze} %0,%3
13385 {ai|addic} %0,%1,%n2\;{aze|addze} %0,%3"
13386 [(set_attr "type" "two")
13387 (set_attr "length" "8")])
13388
13389 (define_insn ""
13390 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
13391 (compare:CC
13392 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13393 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
13394 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13395 (const_int 0)))
13396 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
13397 "TARGET_32BIT"
13398 "@
13399 {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
13400 {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3
13401 #
13402 #"
13403 [(set_attr "type" "compare")
13404 (set_attr "length" "8,8,12,12")])
13405
13406 (define_split
13407 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13408 (compare:CC
13409 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13410 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
13411 (match_operand:SI 3 "gpc_reg_operand" ""))
13412 (const_int 0)))
13413 (clobber (match_scratch:SI 4 ""))]
13414 "TARGET_32BIT && reload_completed"
13415 [(set (match_dup 4)
13416 (plus:SI (geu:SI (match_dup 1) (match_dup 2))
13417 (match_dup 3)))
13418 (set (match_dup 0)
13419 (compare:CC (match_dup 4)
13420 (const_int 0)))]
13421 "")
13422
13423 (define_insn ""
13424 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13425 (compare:CC
13426 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13427 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
13428 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13429 (const_int 0)))
13430 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13431 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13432 "TARGET_32BIT"
13433 "@
13434 {sf|subfc} %0,%2,%1\;{aze.|addze.} %0,%3
13435 {ai|addic} %0,%1,%n2\;{aze.|addze.} %0,%3
13436 #
13437 #"
13438 [(set_attr "type" "compare")
13439 (set_attr "length" "8,8,12,12")])
13440
13441 (define_split
13442 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13443 (compare:CC
13444 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13445 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
13446 (match_operand:SI 3 "gpc_reg_operand" ""))
13447 (const_int 0)))
13448 (set (match_operand:SI 0 "gpc_reg_operand" "")
13449 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13450 "TARGET_32BIT && reload_completed"
13451 [(set (match_dup 0)
13452 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13453 (set (match_dup 4)
13454 (compare:CC (match_dup 0)
13455 (const_int 0)))]
13456 "")
13457
13458 (define_insn "*neg_geu<mode>"
13459 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
13460 (neg:P (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13461 (match_operand:P 2 "reg_or_short_operand" "r,I"))))]
13462 ""
13463 "@
13464 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
13465 {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
13466 [(set_attr "type" "three")
13467 (set_attr "length" "12")])
13468
13469 (define_insn "*and_neg_geu<mode>"
13470 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,&r")
13471 (and:P (neg:P
13472 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13473 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))
13474 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
13475 ""
13476 "@
13477 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0
13478 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
13479 [(set_attr "type" "three")
13480 (set_attr "length" "12")])
13481
13482 (define_insn ""
13483 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
13484 (compare:CC
13485 (and:SI (neg:SI
13486 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13487 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
13488 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13489 (const_int 0)))
13490 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
13491 "TARGET_32BIT"
13492 "@
13493 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
13494 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
13495 #
13496 #"
13497 [(set_attr "type" "compare")
13498 (set_attr "length" "12,12,16,16")])
13499
13500 (define_split
13501 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13502 (compare:CC
13503 (and:SI (neg:SI
13504 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13505 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
13506 (match_operand:SI 3 "gpc_reg_operand" ""))
13507 (const_int 0)))
13508 (clobber (match_scratch:SI 4 ""))]
13509 "TARGET_32BIT && reload_completed"
13510 [(set (match_dup 4)
13511 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2)))
13512 (match_dup 3)))
13513 (set (match_dup 0)
13514 (compare:CC (match_dup 4)
13515 (const_int 0)))]
13516 "")
13517
13518 (define_insn ""
13519 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13520 (compare:CC
13521 (and:SI (neg:SI
13522 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13523 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
13524 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13525 (const_int 0)))
13526 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13527 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
13528 "TARGET_32BIT"
13529 "@
13530 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
13531 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
13532 #
13533 #"
13534 [(set_attr "type" "compare")
13535 (set_attr "length" "12,12,16,16")])
13536
13537 (define_split
13538 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13539 (compare:CC
13540 (and:SI (neg:SI
13541 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13542 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
13543 (match_operand:SI 3 "gpc_reg_operand" ""))
13544 (const_int 0)))
13545 (set (match_operand:SI 0 "gpc_reg_operand" "")
13546 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
13547 "TARGET_32BIT && reload_completed"
13548 [(set (match_dup 0)
13549 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
13550 (set (match_dup 4)
13551 (compare:CC (match_dup 0)
13552 (const_int 0)))]
13553 "")
13554
13555 (define_insn ""
13556 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13557 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13558 (match_operand:SI 2 "reg_or_short_operand" "r")))]
13559 "TARGET_POWER"
13560 "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
13561 [(set_attr "length" "12")])
13562
13563 (define_insn ""
13564 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13565 (compare:CC
13566 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13567 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13568 (const_int 0)))
13569 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
13570 (gt:SI (match_dup 1) (match_dup 2)))]
13571 "TARGET_POWER"
13572 "@
13573 doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
13574 #"
13575 [(set_attr "type" "delayed_compare")
13576 (set_attr "length" "12,16")])
13577
13578 (define_split
13579 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13580 (compare:CC
13581 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13582 (match_operand:SI 2 "reg_or_short_operand" ""))
13583 (const_int 0)))
13584 (set (match_operand:SI 0 "gpc_reg_operand" "")
13585 (gt:SI (match_dup 1) (match_dup 2)))]
13586 "TARGET_POWER && reload_completed"
13587 [(set (match_dup 0)
13588 (gt:SI (match_dup 1) (match_dup 2)))
13589 (set (match_dup 3)
13590 (compare:CC (match_dup 0)
13591 (const_int 0)))]
13592 "")
13593
13594 (define_insn "*plus_gt0<mode>"
13595 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
13596 (plus:P (gt:P (match_operand:P 1 "gpc_reg_operand" "r")
13597 (const_int 0))
13598 (match_operand:P 2 "gpc_reg_operand" "r")))]
13599 ""
13600 "{a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze|addze} %0,%2"
13601 [(set_attr "type" "three")
13602 (set_attr "length" "12")])
13603
13604 (define_insn ""
13605 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
13606 (compare:CC
13607 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13608 (const_int 0))
13609 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
13610 (const_int 0)))
13611 (clobber (match_scratch:SI 3 "=&r,&r"))]
13612 "TARGET_32BIT"
13613 "@
13614 {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
13615 #"
13616 [(set_attr "type" "compare")
13617 (set_attr "length" "12,16")])
13618
13619 (define_split
13620 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13621 (compare:CC
13622 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13623 (const_int 0))
13624 (match_operand:SI 2 "gpc_reg_operand" ""))
13625 (const_int 0)))
13626 (clobber (match_scratch:SI 3 ""))]
13627 "TARGET_32BIT && reload_completed"
13628 [(set (match_dup 3)
13629 (plus:SI (gt:SI (match_dup 1) (const_int 0))
13630 (match_dup 2)))
13631 (set (match_dup 0)
13632 (compare:CC (match_dup 3)
13633 (const_int 0)))]
13634 "")
13635
13636 (define_insn ""
13637 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
13638 (compare:CC
13639 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13640 (const_int 0))
13641 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
13642 (const_int 0)))
13643 (clobber (match_scratch:DI 3 "=&r,&r"))]
13644 "TARGET_64BIT"
13645 "@
13646 addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
13647 #"
13648 [(set_attr "type" "compare")
13649 (set_attr "length" "12,16")])
13650
13651 (define_split
13652 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13653 (compare:CC
13654 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13655 (const_int 0))
13656 (match_operand:DI 2 "gpc_reg_operand" ""))
13657 (const_int 0)))
13658 (clobber (match_scratch:DI 3 ""))]
13659 "TARGET_64BIT && reload_completed"
13660 [(set (match_dup 3)
13661 (plus:DI (gt:DI (match_dup 1) (const_int 0))
13662 (match_dup 2)))
13663 (set (match_dup 0)
13664 (compare:CC (match_dup 3)
13665 (const_int 0)))]
13666 "")
13667
13668 (define_insn ""
13669 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13670 (compare:CC
13671 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13672 (const_int 0))
13673 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
13674 (const_int 0)))
13675 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13676 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
13677 "TARGET_32BIT"
13678 "@
13679 {a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze.|addze.} %0,%2
13680 #"
13681 [(set_attr "type" "compare")
13682 (set_attr "length" "12,16")])
13683
13684 (define_split
13685 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13686 (compare:CC
13687 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13688 (const_int 0))
13689 (match_operand:SI 2 "gpc_reg_operand" ""))
13690 (const_int 0)))
13691 (set (match_operand:SI 0 "gpc_reg_operand" "")
13692 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
13693 "TARGET_32BIT && reload_completed"
13694 [(set (match_dup 0)
13695 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
13696 (set (match_dup 3)
13697 (compare:CC (match_dup 0)
13698 (const_int 0)))]
13699 "")
13700
13701 (define_insn ""
13702 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13703 (compare:CC
13704 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13705 (const_int 0))
13706 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
13707 (const_int 0)))
13708 (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
13709 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
13710 "TARGET_64BIT"
13711 "@
13712 addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
13713 #"
13714 [(set_attr "type" "compare")
13715 (set_attr "length" "12,16")])
13716
13717 (define_split
13718 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13719 (compare:CC
13720 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13721 (const_int 0))
13722 (match_operand:DI 2 "gpc_reg_operand" ""))
13723 (const_int 0)))
13724 (set (match_operand:DI 0 "gpc_reg_operand" "")
13725 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
13726 "TARGET_64BIT && reload_completed"
13727 [(set (match_dup 0)
13728 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
13729 (set (match_dup 3)
13730 (compare:CC (match_dup 0)
13731 (const_int 0)))]
13732 "")
13733
13734 (define_insn ""
13735 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
13736 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13737 (match_operand:SI 2 "reg_or_short_operand" "r"))
13738 (match_operand:SI 3 "gpc_reg_operand" "r")))]
13739 "TARGET_POWER"
13740 "doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
13741 [(set_attr "length" "12")])
13742
13743 (define_insn ""
13744 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
13745 (compare:CC
13746 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13747 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13748 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
13749 (const_int 0)))
13750 (clobber (match_scratch:SI 4 "=&r,&r"))]
13751 "TARGET_POWER"
13752 "@
13753 doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
13754 #"
13755 [(set_attr "type" "compare")
13756 (set_attr "length" "12,16")])
13757
13758 (define_split
13759 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13760 (compare:CC
13761 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13762 (match_operand:SI 2 "reg_or_short_operand" ""))
13763 (match_operand:SI 3 "gpc_reg_operand" ""))
13764 (const_int 0)))
13765 (clobber (match_scratch:SI 4 ""))]
13766 "TARGET_POWER && reload_completed"
13767 [(set (match_dup 4)
13768 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13769 (set (match_dup 0)
13770 (compare:CC (match_dup 4)
13771 (const_int 0)))]
13772 "")
13773
13774 (define_insn ""
13775 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
13776 (compare:CC
13777 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13778 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13779 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
13780 (const_int 0)))
13781 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13782 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13783 "TARGET_POWER"
13784 "@
13785 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
13786 #"
13787 [(set_attr "type" "compare")
13788 (set_attr "length" "12,16")])
13789
13790 (define_split
13791 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13792 (compare:CC
13793 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13794 (match_operand:SI 2 "reg_or_short_operand" ""))
13795 (match_operand:SI 3 "gpc_reg_operand" ""))
13796 (const_int 0)))
13797 (set (match_operand:SI 0 "gpc_reg_operand" "")
13798 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13799 "TARGET_POWER && reload_completed"
13800 [(set (match_dup 0)
13801 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13802 (set (match_dup 4)
13803 (compare:CC (match_dup 0)
13804 (const_int 0)))]
13805 "")
13806
13807 (define_insn ""
13808 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13809 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13810 (match_operand:SI 2 "reg_or_short_operand" "r"))))]
13811 "TARGET_POWER"
13812 "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
13813 [(set_attr "length" "12")])
13814
13815 (define_insn_and_split "*gtu<mode>"
13816 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
13817 (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
13818 (match_operand:P 2 "reg_or_short_operand" "rI")))]
13819 ""
13820 "#"
13821 ""
13822 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13823 (set (match_dup 0) (neg:P (match_dup 0)))]
13824 "")
13825
13826 (define_insn_and_split "*gtu<mode>_compare"
13827 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13828 (compare:CC
13829 (gtu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13830 (match_operand:P 2 "reg_or_short_operand" "rI,rI"))
13831 (const_int 0)))
13832 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
13833 (gtu:P (match_dup 1) (match_dup 2)))]
13834 ""
13835 "#"
13836 ""
13837 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13838 (parallel [(set (match_dup 3)
13839 (compare:CC (neg:P (match_dup 0)) (const_int 0)))
13840 (set (match_dup 0) (neg:P (match_dup 0)))])]
13841 "")
13842
13843 (define_insn_and_split "*plus_gtu<mode>"
13844 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
13845 (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
13846 (match_operand:P 2 "reg_or_short_operand" "rI"))
13847 (match_operand:P 3 "reg_or_short_operand" "rI")))]
13848 ""
13849 "#"
13850 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13851 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13852 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))]
13853 "")
13854
13855 (define_insn_and_split "*plus_gtu<mode>_compare"
13856 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13857 (compare:CC
13858 (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
13859 (match_operand:P 2 "reg_or_short_operand" "I,r,I,r"))
13860 (match_operand:P 3 "gpc_reg_operand" "r,r,r,r"))
13861 (const_int 0)))
13862 (set (match_operand:P 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13863 (plus:P (gtu:P (match_dup 1) (match_dup 2)) (match_dup 3)))]
13864 ""
13865 "#"
13866 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13867 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13868 (parallel [(set (match_dup 4)
13869 (compare:CC (minus:P (match_dup 3) (match_dup 0))
13870 (const_int 0)))
13871 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))])]
13872 "")
13873
13874 (define_insn "*neg_gtu<mode>"
13875 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
13876 (neg:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
13877 (match_operand:P 2 "reg_or_short_operand" "rI"))))]
13878 ""
13879 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
13880 [(set_attr "type" "two")
13881 (set_attr "length" "8")])
13882
13883 \f
13884 ;; Define both directions of branch and return. If we need a reload
13885 ;; register, we'd rather use CR0 since it is much easier to copy a
13886 ;; register CC value to there.
13887
13888 (define_insn ""
13889 [(set (pc)
13890 (if_then_else (match_operator 1 "branch_comparison_operator"
13891 [(match_operand 2
13892 "cc_reg_operand" "y")
13893 (const_int 0)])
13894 (label_ref (match_operand 0 "" ""))
13895 (pc)))]
13896 ""
13897 "*
13898 {
13899 return output_cbranch (operands[1], \"%l0\", 0, insn);
13900 }"
13901 [(set_attr "type" "branch")])
13902
13903 (define_insn ""
13904 [(set (pc)
13905 (if_then_else (match_operator 0 "branch_comparison_operator"
13906 [(match_operand 1
13907 "cc_reg_operand" "y")
13908 (const_int 0)])
13909 (return)
13910 (pc)))]
13911 "direct_return ()"
13912 "*
13913 {
13914 return output_cbranch (operands[0], NULL, 0, insn);
13915 }"
13916 [(set_attr "type" "jmpreg")
13917 (set_attr "length" "4")])
13918
13919 (define_insn ""
13920 [(set (pc)
13921 (if_then_else (match_operator 1 "branch_comparison_operator"
13922 [(match_operand 2
13923 "cc_reg_operand" "y")
13924 (const_int 0)])
13925 (pc)
13926 (label_ref (match_operand 0 "" ""))))]
13927 ""
13928 "*
13929 {
13930 return output_cbranch (operands[1], \"%l0\", 1, insn);
13931 }"
13932 [(set_attr "type" "branch")])
13933
13934 (define_insn ""
13935 [(set (pc)
13936 (if_then_else (match_operator 0 "branch_comparison_operator"
13937 [(match_operand 1
13938 "cc_reg_operand" "y")
13939 (const_int 0)])
13940 (pc)
13941 (return)))]
13942 "direct_return ()"
13943 "*
13944 {
13945 return output_cbranch (operands[0], NULL, 1, insn);
13946 }"
13947 [(set_attr "type" "jmpreg")
13948 (set_attr "length" "4")])
13949
13950 ;; Logic on condition register values.
13951
13952 ; This pattern matches things like
13953 ; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
13954 ; (eq:SI (reg:CCFP 68) (const_int 0)))
13955 ; (const_int 1)))
13956 ; which are generated by the branch logic.
13957 ; Prefer destructive operations where BT = BB (for crXX BT,BA,BB)
13958
13959 (define_insn "*cceq_ior_compare"
13960 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13961 (compare:CCEQ (match_operator:SI 1 "boolean_operator"
13962 [(match_operator:SI 2
13963 "branch_positive_comparison_operator"
13964 [(match_operand 3
13965 "cc_reg_operand" "y,y")
13966 (const_int 0)])
13967 (match_operator:SI 4
13968 "branch_positive_comparison_operator"
13969 [(match_operand 5
13970 "cc_reg_operand" "0,y")
13971 (const_int 0)])])
13972 (const_int 1)))]
13973 ""
13974 "cr%q1 %E0,%j2,%j4"
13975 [(set_attr "type" "cr_logical,delayed_cr")])
13976
13977 ; Why is the constant -1 here, but 1 in the previous pattern?
13978 ; Because ~1 has all but the low bit set.
13979 (define_insn ""
13980 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13981 (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
13982 [(not:SI (match_operator:SI 2
13983 "branch_positive_comparison_operator"
13984 [(match_operand 3
13985 "cc_reg_operand" "y,y")
13986 (const_int 0)]))
13987 (match_operator:SI 4
13988 "branch_positive_comparison_operator"
13989 [(match_operand 5
13990 "cc_reg_operand" "0,y")
13991 (const_int 0)])])
13992 (const_int -1)))]
13993 ""
13994 "cr%q1 %E0,%j2,%j4"
13995 [(set_attr "type" "cr_logical,delayed_cr")])
13996
13997 (define_insn "*cceq_rev_compare"
13998 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13999 (compare:CCEQ (match_operator:SI 1
14000 "branch_positive_comparison_operator"
14001 [(match_operand 2
14002 "cc_reg_operand" "0,y")
14003 (const_int 0)])
14004 (const_int 0)))]
14005 ""
14006 "{crnor %E0,%j1,%j1|crnot %E0,%j1}"
14007 [(set_attr "type" "cr_logical,delayed_cr")])
14008
14009 ;; If we are comparing the result of two comparisons, this can be done
14010 ;; using creqv or crxor.
14011
14012 (define_insn_and_split ""
14013 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
14014 (compare:CCEQ (match_operator 1 "branch_comparison_operator"
14015 [(match_operand 2 "cc_reg_operand" "y")
14016 (const_int 0)])
14017 (match_operator 3 "branch_comparison_operator"
14018 [(match_operand 4 "cc_reg_operand" "y")
14019 (const_int 0)])))]
14020 ""
14021 "#"
14022 ""
14023 [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
14024 (match_dup 5)))]
14025 "
14026 {
14027 int positive_1, positive_2;
14028
14029 positive_1 = branch_positive_comparison_operator (operands[1],
14030 GET_MODE (operands[1]));
14031 positive_2 = branch_positive_comparison_operator (operands[3],
14032 GET_MODE (operands[3]));
14033
14034 if (! positive_1)
14035 operands[1] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[2]),
14036 GET_CODE (operands[1])),
14037 SImode,
14038 operands[2], const0_rtx);
14039 else if (GET_MODE (operands[1]) != SImode)
14040 operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode,
14041 operands[2], const0_rtx);
14042
14043 if (! positive_2)
14044 operands[3] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[4]),
14045 GET_CODE (operands[3])),
14046 SImode,
14047 operands[4], const0_rtx);
14048 else if (GET_MODE (operands[3]) != SImode)
14049 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
14050 operands[4], const0_rtx);
14051
14052 if (positive_1 == positive_2)
14053 {
14054 operands[1] = gen_rtx_NOT (SImode, operands[1]);
14055 operands[5] = constm1_rtx;
14056 }
14057 else
14058 {
14059 operands[5] = const1_rtx;
14060 }
14061 }")
14062
14063 ;; Unconditional branch and return.
14064
14065 (define_insn "jump"
14066 [(set (pc)
14067 (label_ref (match_operand 0 "" "")))]
14068 ""
14069 "b %l0"
14070 [(set_attr "type" "branch")])
14071
14072 (define_insn "return"
14073 [(return)]
14074 "direct_return ()"
14075 "{br|blr}"
14076 [(set_attr "type" "jmpreg")])
14077
14078 (define_expand "indirect_jump"
14079 [(set (pc) (match_operand 0 "register_operand" ""))])
14080
14081 (define_insn "*indirect_jump<mode>"
14082 [(set (pc) (match_operand:P 0 "register_operand" "c,*l"))]
14083 ""
14084 "@
14085 bctr
14086 {br|blr}"
14087 [(set_attr "type" "jmpreg")])
14088
14089 ;; Table jump for switch statements:
14090 (define_expand "tablejump"
14091 [(use (match_operand 0 "" ""))
14092 (use (label_ref (match_operand 1 "" "")))]
14093 ""
14094 "
14095 {
14096 if (TARGET_32BIT)
14097 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
14098 else
14099 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
14100 DONE;
14101 }")
14102
14103 (define_expand "tablejumpsi"
14104 [(set (match_dup 3)
14105 (plus:SI (match_operand:SI 0 "" "")
14106 (match_dup 2)))
14107 (parallel [(set (pc) (match_dup 3))
14108 (use (label_ref (match_operand 1 "" "")))])]
14109 "TARGET_32BIT"
14110 "
14111 { operands[0] = force_reg (SImode, operands[0]);
14112 operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
14113 operands[3] = gen_reg_rtx (SImode);
14114 }")
14115
14116 (define_expand "tablejumpdi"
14117 [(set (match_dup 4)
14118 (sign_extend:DI (match_operand:SI 0 "lwa_operand" "")))
14119 (set (match_dup 3)
14120 (plus:DI (match_dup 4)
14121 (match_dup 2)))
14122 (parallel [(set (pc) (match_dup 3))
14123 (use (label_ref (match_operand 1 "" "")))])]
14124 "TARGET_64BIT"
14125 "
14126 { operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
14127 operands[3] = gen_reg_rtx (DImode);
14128 operands[4] = gen_reg_rtx (DImode);
14129 }")
14130
14131 (define_insn "*tablejump<mode>_internal1"
14132 [(set (pc)
14133 (match_operand:P 0 "register_operand" "c,*l"))
14134 (use (label_ref (match_operand 1 "" "")))]
14135 ""
14136 "@
14137 bctr
14138 {br|blr}"
14139 [(set_attr "type" "jmpreg")])
14140
14141 (define_insn "nop"
14142 [(const_int 0)]
14143 ""
14144 "{cror 0,0,0|nop}")
14145 \f
14146 ;; Define the subtract-one-and-jump insns, starting with the template
14147 ;; so loop.c knows what to generate.
14148
14149 (define_expand "doloop_end"
14150 [(use (match_operand 0 "" "")) ; loop pseudo
14151 (use (match_operand 1 "" "")) ; iterations; zero if unknown
14152 (use (match_operand 2 "" "")) ; max iterations
14153 (use (match_operand 3 "" "")) ; loop level
14154 (use (match_operand 4 "" ""))] ; label
14155 ""
14156 "
14157 {
14158 /* Only use this on innermost loops. */
14159 if (INTVAL (operands[3]) > 1)
14160 FAIL;
14161 if (TARGET_64BIT)
14162 {
14163 if (GET_MODE (operands[0]) != DImode)
14164 FAIL;
14165 emit_jump_insn (gen_ctrdi (operands[0], operands[4]));
14166 }
14167 else
14168 {
14169 if (GET_MODE (operands[0]) != SImode)
14170 FAIL;
14171 emit_jump_insn (gen_ctrsi (operands[0], operands[4]));
14172 }
14173 DONE;
14174 }")
14175
14176 (define_expand "ctr<mode>"
14177 [(parallel [(set (pc)
14178 (if_then_else (ne (match_operand:P 0 "register_operand" "")
14179 (const_int 1))
14180 (label_ref (match_operand 1 "" ""))
14181 (pc)))
14182 (set (match_dup 0)
14183 (plus:P (match_dup 0)
14184 (const_int -1)))
14185 (clobber (match_scratch:CC 2 ""))
14186 (clobber (match_scratch:P 3 ""))])]
14187 ""
14188 "")
14189
14190 ;; We need to be able to do this for any operand, including MEM, or we
14191 ;; will cause reload to blow up since we don't allow output reloads on
14192 ;; JUMP_INSNs.
14193 ;; For the length attribute to be calculated correctly, the
14194 ;; label MUST be operand 0.
14195
14196 (define_insn "*ctr<mode>_internal1"
14197 [(set (pc)
14198 (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
14199 (const_int 1))
14200 (label_ref (match_operand 0 "" ""))
14201 (pc)))
14202 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
14203 (plus:P (match_dup 1)
14204 (const_int -1)))
14205 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14206 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
14207 ""
14208 "*
14209 {
14210 if (which_alternative != 0)
14211 return \"#\";
14212 else if (get_attr_length (insn) == 4)
14213 return \"{bdn|bdnz} %l0\";
14214 else
14215 return \"bdz $+8\;b %l0\";
14216 }"
14217 [(set_attr "type" "branch")
14218 (set_attr "length" "*,12,16,16")])
14219
14220 (define_insn "*ctr<mode>_internal2"
14221 [(set (pc)
14222 (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
14223 (const_int 1))
14224 (pc)
14225 (label_ref (match_operand 0 "" ""))))
14226 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
14227 (plus:P (match_dup 1)
14228 (const_int -1)))
14229 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14230 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
14231 ""
14232 "*
14233 {
14234 if (which_alternative != 0)
14235 return \"#\";
14236 else if (get_attr_length (insn) == 4)
14237 return \"bdz %l0\";
14238 else
14239 return \"{bdn|bdnz} $+8\;b %l0\";
14240 }"
14241 [(set_attr "type" "branch")
14242 (set_attr "length" "*,12,16,16")])
14243
14244 ;; Similar but use EQ
14245
14246 (define_insn "*ctr<mode>_internal5"
14247 [(set (pc)
14248 (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
14249 (const_int 1))
14250 (label_ref (match_operand 0 "" ""))
14251 (pc)))
14252 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
14253 (plus:P (match_dup 1)
14254 (const_int -1)))
14255 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14256 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
14257 ""
14258 "*
14259 {
14260 if (which_alternative != 0)
14261 return \"#\";
14262 else if (get_attr_length (insn) == 4)
14263 return \"bdz %l0\";
14264 else
14265 return \"{bdn|bdnz} $+8\;b %l0\";
14266 }"
14267 [(set_attr "type" "branch")
14268 (set_attr "length" "*,12,16,16")])
14269
14270 (define_insn "*ctr<mode>_internal6"
14271 [(set (pc)
14272 (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
14273 (const_int 1))
14274 (pc)
14275 (label_ref (match_operand 0 "" ""))))
14276 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
14277 (plus:P (match_dup 1)
14278 (const_int -1)))
14279 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14280 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
14281 ""
14282 "*
14283 {
14284 if (which_alternative != 0)
14285 return \"#\";
14286 else if (get_attr_length (insn) == 4)
14287 return \"{bdn|bdnz} %l0\";
14288 else
14289 return \"bdz $+8\;b %l0\";
14290 }"
14291 [(set_attr "type" "branch")
14292 (set_attr "length" "*,12,16,16")])
14293
14294 ;; Now the splitters if we could not allocate the CTR register
14295
14296 (define_split
14297 [(set (pc)
14298 (if_then_else (match_operator 2 "comparison_operator"
14299 [(match_operand:P 1 "gpc_reg_operand" "")
14300 (const_int 1)])
14301 (match_operand 5 "" "")
14302 (match_operand 6 "" "")))
14303 (set (match_operand:P 0 "gpc_reg_operand" "")
14304 (plus:P (match_dup 1) (const_int -1)))
14305 (clobber (match_scratch:CC 3 ""))
14306 (clobber (match_scratch:P 4 ""))]
14307 "reload_completed"
14308 [(parallel [(set (match_dup 3)
14309 (compare:CC (plus:P (match_dup 1)
14310 (const_int -1))
14311 (const_int 0)))
14312 (set (match_dup 0)
14313 (plus:P (match_dup 1)
14314 (const_int -1)))])
14315 (set (pc) (if_then_else (match_dup 7)
14316 (match_dup 5)
14317 (match_dup 6)))]
14318 "
14319 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
14320 operands[3], const0_rtx); }")
14321
14322 (define_split
14323 [(set (pc)
14324 (if_then_else (match_operator 2 "comparison_operator"
14325 [(match_operand:P 1 "gpc_reg_operand" "")
14326 (const_int 1)])
14327 (match_operand 5 "" "")
14328 (match_operand 6 "" "")))
14329 (set (match_operand:P 0 "nonimmediate_operand" "")
14330 (plus:P (match_dup 1) (const_int -1)))
14331 (clobber (match_scratch:CC 3 ""))
14332 (clobber (match_scratch:P 4 ""))]
14333 "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
14334 [(parallel [(set (match_dup 3)
14335 (compare:CC (plus:P (match_dup 1)
14336 (const_int -1))
14337 (const_int 0)))
14338 (set (match_dup 4)
14339 (plus:P (match_dup 1)
14340 (const_int -1)))])
14341 (set (match_dup 0)
14342 (match_dup 4))
14343 (set (pc) (if_then_else (match_dup 7)
14344 (match_dup 5)
14345 (match_dup 6)))]
14346 "
14347 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
14348 operands[3], const0_rtx); }")
14349 \f
14350 (define_insn "trap"
14351 [(trap_if (const_int 1) (const_int 0))]
14352 ""
14353 "{t 31,0,0|trap}"
14354 [(set_attr "type" "trap")])
14355
14356 (define_expand "conditional_trap"
14357 [(trap_if (match_operator 0 "trap_comparison_operator"
14358 [(match_dup 2) (match_dup 3)])
14359 (match_operand 1 "const_int_operand" ""))]
14360 ""
14361 "if (rs6000_compare_fp_p || operands[1] != const0_rtx) FAIL;
14362 operands[2] = rs6000_compare_op0;
14363 operands[3] = rs6000_compare_op1;")
14364
14365 (define_insn ""
14366 [(trap_if (match_operator 0 "trap_comparison_operator"
14367 [(match_operand:GPR 1 "register_operand" "r")
14368 (match_operand:GPR 2 "reg_or_short_operand" "rI")])
14369 (const_int 0))]
14370 ""
14371 "{t|t<wd>}%V0%I2 %1,%2"
14372 [(set_attr "type" "trap")])
14373 \f
14374 ;; Insns related to generating the function prologue and epilogue.
14375
14376 (define_expand "prologue"
14377 [(use (const_int 0))]
14378 "TARGET_SCHED_PROLOG"
14379 "
14380 {
14381 rs6000_emit_prologue ();
14382 DONE;
14383 }")
14384
14385 (define_insn "*movesi_from_cr_one"
14386 [(match_parallel 0 "mfcr_operation"
14387 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
14388 (unspec:SI [(match_operand:CC 2 "cc_reg_operand" "y")
14389 (match_operand 3 "immediate_operand" "n")]
14390 UNSPEC_MOVESI_FROM_CR))])]
14391 "TARGET_MFCRF"
14392 "*
14393 {
14394 int mask = 0;
14395 int i;
14396 for (i = 0; i < XVECLEN (operands[0], 0); i++)
14397 {
14398 mask = INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
14399 operands[4] = GEN_INT (mask);
14400 output_asm_insn (\"mfcr %1,%4\", operands);
14401 }
14402 return \"\";
14403 }"
14404 [(set_attr "type" "mfcrf")])
14405
14406 (define_insn "movesi_from_cr"
14407 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
14408 (unspec:SI [(reg:CC CR0_REGNO) (reg:CC CR1_REGNO)
14409 (reg:CC CR2_REGNO) (reg:CC CR3_REGNO)
14410 (reg:CC CR4_REGNO) (reg:CC CR5_REGNO)
14411 (reg:CC CR6_REGNO) (reg:CC CR7_REGNO)]
14412 UNSPEC_MOVESI_FROM_CR))]
14413 ""
14414 "mfcr %0"
14415 [(set_attr "type" "mfcr")])
14416
14417 (define_insn "*stmw"
14418 [(match_parallel 0 "stmw_operation"
14419 [(set (match_operand:SI 1 "memory_operand" "=m")
14420 (match_operand:SI 2 "gpc_reg_operand" "r"))])]
14421 "TARGET_MULTIPLE"
14422 "{stm|stmw} %2,%1"
14423 [(set_attr "type" "store_ux")])
14424
14425 (define_insn "*save_gpregs_<mode>"
14426 [(match_parallel 0 "any_parallel_operand"
14427 [(clobber (reg:P 65))
14428 (use (match_operand:P 1 "symbol_ref_operand" "s"))
14429 (use (match_operand:P 2 "gpc_reg_operand" "r"))
14430 (set (match_operand:P 3 "memory_operand" "=m")
14431 (match_operand:P 4 "gpc_reg_operand" "r"))])]
14432 ""
14433 "bl %z1"
14434 [(set_attr "type" "branch")
14435 (set_attr "length" "4")])
14436
14437 (define_insn "*save_fpregs_<mode>"
14438 [(match_parallel 0 "any_parallel_operand"
14439 [(clobber (reg:P 65))
14440 (use (match_operand:P 1 "symbol_ref_operand" "s"))
14441 (use (match_operand:P 2 "gpc_reg_operand" "r"))
14442 (set (match_operand:DF 3 "memory_operand" "=m")
14443 (match_operand:DF 4 "gpc_reg_operand" "f"))])]
14444 ""
14445 "bl %z1"
14446 [(set_attr "type" "branch")
14447 (set_attr "length" "4")])
14448
14449 ; These are to explain that changes to the stack pointer should
14450 ; not be moved over stores to stack memory.
14451 (define_insn "stack_tie"
14452 [(set (match_operand:BLK 0 "memory_operand" "+m")
14453 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
14454 ""
14455 ""
14456 [(set_attr "length" "0")])
14457
14458
14459 (define_expand "epilogue"
14460 [(use (const_int 0))]
14461 "TARGET_SCHED_PROLOG"
14462 "
14463 {
14464 rs6000_emit_epilogue (FALSE);
14465 DONE;
14466 }")
14467
14468 ; On some processors, doing the mtcrf one CC register at a time is
14469 ; faster (like on the 604e). On others, doing them all at once is
14470 ; faster; for instance, on the 601 and 750.
14471
14472 (define_expand "movsi_to_cr_one"
14473 [(set (match_operand:CC 0 "cc_reg_operand" "")
14474 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "")
14475 (match_dup 2)] UNSPEC_MOVESI_TO_CR))]
14476 ""
14477 "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
14478
14479 (define_insn "*movsi_to_cr"
14480 [(match_parallel 0 "mtcrf_operation"
14481 [(set (match_operand:CC 1 "cc_reg_operand" "=y")
14482 (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
14483 (match_operand 3 "immediate_operand" "n")]
14484 UNSPEC_MOVESI_TO_CR))])]
14485 ""
14486 "*
14487 {
14488 int mask = 0;
14489 int i;
14490 for (i = 0; i < XVECLEN (operands[0], 0); i++)
14491 mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
14492 operands[4] = GEN_INT (mask);
14493 return \"mtcrf %4,%2\";
14494 }"
14495 [(set_attr "type" "mtcr")])
14496
14497 (define_insn "*mtcrfsi"
14498 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
14499 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
14500 (match_operand 2 "immediate_operand" "n")]
14501 UNSPEC_MOVESI_TO_CR))]
14502 "GET_CODE (operands[0]) == REG
14503 && CR_REGNO_P (REGNO (operands[0]))
14504 && GET_CODE (operands[2]) == CONST_INT
14505 && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
14506 "mtcrf %R0,%1"
14507 [(set_attr "type" "mtcr")])
14508
14509 ; The load-multiple instructions have similar properties.
14510 ; Note that "load_multiple" is a name known to the machine-independent
14511 ; code that actually corresponds to the PowerPC load-string.
14512
14513 (define_insn "*lmw"
14514 [(match_parallel 0 "lmw_operation"
14515 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
14516 (match_operand:SI 2 "memory_operand" "m"))])]
14517 "TARGET_MULTIPLE"
14518 "{lm|lmw} %1,%2"
14519 [(set_attr "type" "load_ux")])
14520
14521 (define_insn "*return_internal_<mode>"
14522 [(return)
14523 (use (match_operand:P 0 "register_operand" "lc"))]
14524 ""
14525 "b%T0"
14526 [(set_attr "type" "jmpreg")])
14527
14528 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
14529 ; stuff was in GCC. Oh, and "any_parallel_operand" is a bit flexible...
14530
14531 (define_insn "*restore_gpregs_<mode>"
14532 [(match_parallel 0 "any_parallel_operand"
14533 [(clobber (match_operand:P 1 "register_operand" "=l"))
14534 (use (match_operand:P 2 "symbol_ref_operand" "s"))
14535 (use (match_operand:P 3 "gpc_reg_operand" "r"))
14536 (set (match_operand:P 4 "gpc_reg_operand" "=r")
14537 (match_operand:P 5 "memory_operand" "m"))])]
14538 ""
14539 "bl %z2"
14540 [(set_attr "type" "branch")
14541 (set_attr "length" "4")])
14542
14543 (define_insn "*return_and_restore_gpregs_<mode>"
14544 [(match_parallel 0 "any_parallel_operand"
14545 [(return)
14546 (clobber (match_operand:P 1 "register_operand" "=l"))
14547 (use (match_operand:P 2 "symbol_ref_operand" "s"))
14548 (use (match_operand:P 3 "gpc_reg_operand" "r"))
14549 (set (match_operand:P 4 "gpc_reg_operand" "=r")
14550 (match_operand:P 5 "memory_operand" "m"))])]
14551 ""
14552 "b %z2"
14553 [(set_attr "type" "branch")
14554 (set_attr "length" "4")])
14555
14556 (define_insn "*return_and_restore_fpregs_<mode>"
14557 [(match_parallel 0 "any_parallel_operand"
14558 [(return)
14559 (clobber (match_operand:P 1 "register_operand" "=l"))
14560 (use (match_operand:P 2 "symbol_ref_operand" "s"))
14561 (use (match_operand:P 3 "gpc_reg_operand" "r"))
14562 (set (match_operand:DF 4 "gpc_reg_operand" "=f")
14563 (match_operand:DF 5 "memory_operand" "m"))])]
14564 ""
14565 "b %z2"
14566 [(set_attr "type" "branch")
14567 (set_attr "length" "4")])
14568
14569 ; This is used in compiling the unwind routines.
14570 (define_expand "eh_return"
14571 [(use (match_operand 0 "general_operand" ""))]
14572 ""
14573 "
14574 {
14575 if (TARGET_32BIT)
14576 emit_insn (gen_eh_set_lr_si (operands[0]));
14577 else
14578 emit_insn (gen_eh_set_lr_di (operands[0]));
14579 DONE;
14580 }")
14581
14582 ; We can't expand this before we know where the link register is stored.
14583 (define_insn "eh_set_lr_<mode>"
14584 [(unspec_volatile [(match_operand:P 0 "register_operand" "r")]
14585 UNSPECV_EH_RR)
14586 (clobber (match_scratch:P 1 "=&b"))]
14587 ""
14588 "#")
14589
14590 (define_split
14591 [(unspec_volatile [(match_operand 0 "register_operand" "")] UNSPECV_EH_RR)
14592 (clobber (match_scratch 1 ""))]
14593 "reload_completed"
14594 [(const_int 0)]
14595 "
14596 {
14597 rs6000_emit_eh_reg_restore (operands[0], operands[1]);
14598 DONE;
14599 }")
14600
14601 (define_insn "prefetch"
14602 [(prefetch (match_operand 0 "indexed_or_indirect_address" "a")
14603 (match_operand:SI 1 "const_int_operand" "n")
14604 (match_operand:SI 2 "const_int_operand" "n"))]
14605 "TARGET_POWERPC"
14606 "*
14607 {
14608 if (GET_CODE (operands[0]) == REG)
14609 return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
14610 return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
14611 }"
14612 [(set_attr "type" "load")])
14613 \f
14614
14615 (include "sync.md")
14616 (include "altivec.md")
14617 (include "spe.md")
14618 (include "dfp.md")
14619 (include "paired.md")