]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rs6000/rs6000.md
re PR target/21571 (ICE in rs6000.c with -msdata=default.)
[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 Free Software Foundation, Inc.
4 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
5
6 ;; This file is part of GCC.
7
8 ;; GCC is free software; you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published
10 ;; by the Free Software Foundation; either version 2, or (at your
11 ;; option) any later version.
12
13 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
14 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 ;; License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING. If not, write to the
20 ;; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
21 ;; MA 02110-1301, USA.
22
23 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
24
25 ;;
26 ;; UNSPEC usage
27 ;;
28
29 (define_constants
30 [(UNSPEC_FRSP 0) ; frsp for POWER machines
31 (UNSPEC_TIE 5) ; tie stack contents and stack pointer
32 (UNSPEC_TOCPTR 6) ; address of a word pointing to the TOC
33 (UNSPEC_TOC 7) ; address of the TOC (more-or-less)
34 (UNSPEC_MOVSI_GOT 8)
35 (UNSPEC_MV_CR_OV 9) ; move_from_CR_ov_bit
36 (UNSPEC_FCTIWZ 10)
37 (UNSPEC_LD_MPIC 15) ; load_macho_picbase
38 (UNSPEC_MPIC_CORRECT 16) ; macho_correct_pic
39 (UNSPEC_TLSGD 17)
40 (UNSPEC_TLSLD 18)
41 (UNSPEC_MOVESI_FROM_CR 19)
42 (UNSPEC_MOVESI_TO_CR 20)
43 (UNSPEC_TLSDTPREL 21)
44 (UNSPEC_TLSDTPRELHA 22)
45 (UNSPEC_TLSDTPRELLO 23)
46 (UNSPEC_TLSGOTDTPREL 24)
47 (UNSPEC_TLSTPREL 25)
48 (UNSPEC_TLSTPRELHA 26)
49 (UNSPEC_TLSTPRELLO 27)
50 (UNSPEC_TLSGOTTPREL 28)
51 (UNSPEC_TLSTLS 29)
52 (UNSPEC_FIX_TRUNC_TF 30) ; fadd, rounding towards zero
53 (UNSPEC_MV_CR_GT 31) ; move_from_CR_eq_bit
54 (UNSPEC_STFIWX 32)
55 (UNSPEC_POPCNTB 33)
56 (UNSPEC_FRES 34)
57 (UNSPEC_SP_SET 35)
58 (UNSPEC_SP_TEST 36)
59 (UNSPEC_SYNC 37)
60 (UNSPEC_LWSYNC 38)
61 (UNSPEC_ISYNC 39)
62 (UNSPEC_SYNC_OP 40)
63 (UNSPEC_ATOMIC 41)
64 (UNSPEC_CMPXCHG 42)
65 (UNSPEC_XCHG 43)
66 (UNSPEC_AND 44)
67 ])
68
69 ;;
70 ;; UNSPEC_VOLATILE usage
71 ;;
72
73 (define_constants
74 [(UNSPECV_BLOCK 0)
75 (UNSPECV_LL 1) ; load-locked
76 (UNSPECV_SC 2) ; store-conditional
77 (UNSPECV_EH_RR 9) ; eh_reg_restore
78 ])
79 \f
80 ;; Define an insn type attribute. This is used in function unit delay
81 ;; computations.
82 (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,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"
83 (const_string "integer"))
84
85 ;; Length (in bytes).
86 ; '(pc)' in the following doesn't include the instruction itself; it is
87 ; calculated as if the instruction had zero size.
88 (define_attr "length" ""
89 (if_then_else (eq_attr "type" "branch")
90 (if_then_else (and (ge (minus (match_dup 0) (pc))
91 (const_int -32768))
92 (lt (minus (match_dup 0) (pc))
93 (const_int 32764)))
94 (const_int 4)
95 (const_int 8))
96 (const_int 4)))
97
98 ;; Processor type -- this attribute must exactly match the processor_type
99 ;; enumeration in rs6000.h.
100
101 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4,power5"
102 (const (symbol_ref "rs6000_cpu_attr")))
103
104 (automata_option "ndfa")
105
106 (include "rios1.md")
107 (include "rios2.md")
108 (include "rs64.md")
109 (include "mpc.md")
110 (include "40x.md")
111 (include "440.md")
112 (include "603.md")
113 (include "6xx.md")
114 (include "7xx.md")
115 (include "7450.md")
116 (include "8540.md")
117 (include "power4.md")
118 (include "power5.md")
119
120 (include "predicates.md")
121
122 (include "darwin.md")
123
124 \f
125 ;; Mode macros
126
127 ; This mode macro allows :GPR to be used to indicate the allowable size
128 ; of whole values in GPRs.
129 (define_mode_macro GPR [SI (DI "TARGET_POWERPC64")])
130
131 ; Any supported integer mode.
132 (define_mode_macro INT [QI HI SI DI TI])
133
134 ; Any supported integer mode that fits in one register.
135 (define_mode_macro INT1 [QI HI SI (DI "TARGET_POWERPC64")])
136
137 ; extend modes for DImode
138 (define_mode_macro QHSI [QI HI SI])
139
140 ; SImode or DImode, even if DImode doesn't fit in GPRs.
141 (define_mode_macro SDI [SI DI])
142
143 ; The size of a pointer. Also, the size of the value that a record-condition
144 ; (one with a '.') will compare.
145 (define_mode_macro P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
146
147 ; Any hardware-supported floating-point mode
148 (define_mode_macro FP [(SF "TARGET_HARD_FLOAT")
149 (DF "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)")
150 (TF "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
151 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128")])
152
153 ; Various instructions that come in SI and DI forms.
154 ; A generic w/d attribute, for things like cmpw/cmpd.
155 (define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
156
157 ; DImode bits
158 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
159
160 \f
161 ;; Start with fixed-point load and store insns. Here we put only the more
162 ;; complex forms. Basic data transfer is done later.
163
164 (define_expand "zero_extend<mode>di2"
165 [(set (match_operand:DI 0 "gpc_reg_operand" "")
166 (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "")))]
167 "TARGET_POWERPC64"
168 "")
169
170 (define_insn "*zero_extend<mode>di2_internal1"
171 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
172 (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
173 "TARGET_POWERPC64"
174 "@
175 l<wd>z%U1%X1 %0,%1
176 rldicl %0,%1,0,<dbits>"
177 [(set_attr "type" "load,*")])
178
179 (define_insn "*zero_extend<mode>di2_internal2"
180 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
181 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
182 (const_int 0)))
183 (clobber (match_scratch:DI 2 "=r,r"))]
184 "TARGET_64BIT"
185 "@
186 rldicl. %2,%1,0,<dbits>
187 #"
188 [(set_attr "type" "compare")
189 (set_attr "length" "4,8")])
190
191 (define_split
192 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
193 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
194 (const_int 0)))
195 (clobber (match_scratch:DI 2 ""))]
196 "TARGET_POWERPC64 && reload_completed"
197 [(set (match_dup 2)
198 (zero_extend:DI (match_dup 1)))
199 (set (match_dup 0)
200 (compare:CC (match_dup 2)
201 (const_int 0)))]
202 "")
203
204 (define_insn "*zero_extend<mode>di2_internal3"
205 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
206 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
207 (const_int 0)))
208 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
209 (zero_extend:DI (match_dup 1)))]
210 "TARGET_64BIT"
211 "@
212 rldicl. %0,%1,0,<dbits>
213 #"
214 [(set_attr "type" "compare")
215 (set_attr "length" "4,8")])
216
217 (define_split
218 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
219 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
220 (const_int 0)))
221 (set (match_operand:DI 0 "gpc_reg_operand" "")
222 (zero_extend:DI (match_dup 1)))]
223 "TARGET_POWERPC64 && reload_completed"
224 [(set (match_dup 0)
225 (zero_extend:DI (match_dup 1)))
226 (set (match_dup 2)
227 (compare:CC (match_dup 0)
228 (const_int 0)))]
229 "")
230
231 (define_insn "extendqidi2"
232 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
233 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
234 "TARGET_POWERPC64"
235 "extsb %0,%1")
236
237 (define_insn ""
238 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
239 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
240 (const_int 0)))
241 (clobber (match_scratch:DI 2 "=r,r"))]
242 "TARGET_64BIT"
243 "@
244 extsb. %2,%1
245 #"
246 [(set_attr "type" "compare")
247 (set_attr "length" "4,8")])
248
249 (define_split
250 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
251 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
252 (const_int 0)))
253 (clobber (match_scratch:DI 2 ""))]
254 "TARGET_POWERPC64 && reload_completed"
255 [(set (match_dup 2)
256 (sign_extend:DI (match_dup 1)))
257 (set (match_dup 0)
258 (compare:CC (match_dup 2)
259 (const_int 0)))]
260 "")
261
262 (define_insn ""
263 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
264 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
265 (const_int 0)))
266 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
267 (sign_extend:DI (match_dup 1)))]
268 "TARGET_64BIT"
269 "@
270 extsb. %0,%1
271 #"
272 [(set_attr "type" "compare")
273 (set_attr "length" "4,8")])
274
275 (define_split
276 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
277 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
278 (const_int 0)))
279 (set (match_operand:DI 0 "gpc_reg_operand" "")
280 (sign_extend:DI (match_dup 1)))]
281 "TARGET_POWERPC64 && reload_completed"
282 [(set (match_dup 0)
283 (sign_extend:DI (match_dup 1)))
284 (set (match_dup 2)
285 (compare:CC (match_dup 0)
286 (const_int 0)))]
287 "")
288
289 (define_expand "extendhidi2"
290 [(set (match_operand:DI 0 "gpc_reg_operand" "")
291 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
292 "TARGET_POWERPC64"
293 "")
294
295 (define_insn ""
296 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
297 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
298 "TARGET_POWERPC64"
299 "@
300 lha%U1%X1 %0,%1
301 extsh %0,%1"
302 [(set_attr "type" "load_ext,*")])
303
304 (define_insn ""
305 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
306 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
307 (const_int 0)))
308 (clobber (match_scratch:DI 2 "=r,r"))]
309 "TARGET_64BIT"
310 "@
311 extsh. %2,%1
312 #"
313 [(set_attr "type" "compare")
314 (set_attr "length" "4,8")])
315
316 (define_split
317 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
318 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
319 (const_int 0)))
320 (clobber (match_scratch:DI 2 ""))]
321 "TARGET_POWERPC64 && reload_completed"
322 [(set (match_dup 2)
323 (sign_extend:DI (match_dup 1)))
324 (set (match_dup 0)
325 (compare:CC (match_dup 2)
326 (const_int 0)))]
327 "")
328
329 (define_insn ""
330 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
331 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
332 (const_int 0)))
333 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
334 (sign_extend:DI (match_dup 1)))]
335 "TARGET_64BIT"
336 "@
337 extsh. %0,%1
338 #"
339 [(set_attr "type" "compare")
340 (set_attr "length" "4,8")])
341
342 (define_split
343 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
344 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
345 (const_int 0)))
346 (set (match_operand:DI 0 "gpc_reg_operand" "")
347 (sign_extend:DI (match_dup 1)))]
348 "TARGET_POWERPC64 && reload_completed"
349 [(set (match_dup 0)
350 (sign_extend:DI (match_dup 1)))
351 (set (match_dup 2)
352 (compare:CC (match_dup 0)
353 (const_int 0)))]
354 "")
355
356 (define_expand "extendsidi2"
357 [(set (match_operand:DI 0 "gpc_reg_operand" "")
358 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
359 "TARGET_POWERPC64"
360 "")
361
362 (define_insn ""
363 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
364 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
365 "TARGET_POWERPC64"
366 "@
367 lwa%U1%X1 %0,%1
368 extsw %0,%1"
369 [(set_attr "type" "load_ext,*")])
370
371 (define_insn ""
372 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
373 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
374 (const_int 0)))
375 (clobber (match_scratch:DI 2 "=r,r"))]
376 "TARGET_64BIT"
377 "@
378 extsw. %2,%1
379 #"
380 [(set_attr "type" "compare")
381 (set_attr "length" "4,8")])
382
383 (define_split
384 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
385 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
386 (const_int 0)))
387 (clobber (match_scratch:DI 2 ""))]
388 "TARGET_POWERPC64 && reload_completed"
389 [(set (match_dup 2)
390 (sign_extend:DI (match_dup 1)))
391 (set (match_dup 0)
392 (compare:CC (match_dup 2)
393 (const_int 0)))]
394 "")
395
396 (define_insn ""
397 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
398 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
399 (const_int 0)))
400 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
401 (sign_extend:DI (match_dup 1)))]
402 "TARGET_64BIT"
403 "@
404 extsw. %0,%1
405 #"
406 [(set_attr "type" "compare")
407 (set_attr "length" "4,8")])
408
409 (define_split
410 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
411 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
412 (const_int 0)))
413 (set (match_operand:DI 0 "gpc_reg_operand" "")
414 (sign_extend:DI (match_dup 1)))]
415 "TARGET_POWERPC64 && reload_completed"
416 [(set (match_dup 0)
417 (sign_extend:DI (match_dup 1)))
418 (set (match_dup 2)
419 (compare:CC (match_dup 0)
420 (const_int 0)))]
421 "")
422
423 (define_expand "zero_extendqisi2"
424 [(set (match_operand:SI 0 "gpc_reg_operand" "")
425 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
426 ""
427 "")
428
429 (define_insn ""
430 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
431 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
432 ""
433 "@
434 lbz%U1%X1 %0,%1
435 {rlinm|rlwinm} %0,%1,0,0xff"
436 [(set_attr "type" "load,*")])
437
438 (define_insn ""
439 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
440 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
441 (const_int 0)))
442 (clobber (match_scratch:SI 2 "=r,r"))]
443 ""
444 "@
445 {andil.|andi.} %2,%1,0xff
446 #"
447 [(set_attr "type" "compare")
448 (set_attr "length" "4,8")])
449
450 (define_split
451 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
452 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
453 (const_int 0)))
454 (clobber (match_scratch:SI 2 ""))]
455 "reload_completed"
456 [(set (match_dup 2)
457 (zero_extend:SI (match_dup 1)))
458 (set (match_dup 0)
459 (compare:CC (match_dup 2)
460 (const_int 0)))]
461 "")
462
463 (define_insn ""
464 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
465 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
466 (const_int 0)))
467 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
468 (zero_extend:SI (match_dup 1)))]
469 ""
470 "@
471 {andil.|andi.} %0,%1,0xff
472 #"
473 [(set_attr "type" "compare")
474 (set_attr "length" "4,8")])
475
476 (define_split
477 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
478 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
479 (const_int 0)))
480 (set (match_operand:SI 0 "gpc_reg_operand" "")
481 (zero_extend:SI (match_dup 1)))]
482 "reload_completed"
483 [(set (match_dup 0)
484 (zero_extend:SI (match_dup 1)))
485 (set (match_dup 2)
486 (compare:CC (match_dup 0)
487 (const_int 0)))]
488 "")
489
490 (define_expand "extendqisi2"
491 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
492 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
493 ""
494 "
495 {
496 if (TARGET_POWERPC)
497 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
498 else if (TARGET_POWER)
499 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
500 else
501 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
502 DONE;
503 }")
504
505 (define_insn "extendqisi2_ppc"
506 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
507 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
508 "TARGET_POWERPC"
509 "extsb %0,%1")
510
511 (define_insn ""
512 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
513 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
514 (const_int 0)))
515 (clobber (match_scratch:SI 2 "=r,r"))]
516 "TARGET_POWERPC"
517 "@
518 extsb. %2,%1
519 #"
520 [(set_attr "type" "compare")
521 (set_attr "length" "4,8")])
522
523 (define_split
524 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
525 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
526 (const_int 0)))
527 (clobber (match_scratch:SI 2 ""))]
528 "TARGET_POWERPC && reload_completed"
529 [(set (match_dup 2)
530 (sign_extend:SI (match_dup 1)))
531 (set (match_dup 0)
532 (compare:CC (match_dup 2)
533 (const_int 0)))]
534 "")
535
536 (define_insn ""
537 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
538 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
539 (const_int 0)))
540 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
541 (sign_extend:SI (match_dup 1)))]
542 "TARGET_POWERPC"
543 "@
544 extsb. %0,%1
545 #"
546 [(set_attr "type" "compare")
547 (set_attr "length" "4,8")])
548
549 (define_split
550 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
551 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
552 (const_int 0)))
553 (set (match_operand:SI 0 "gpc_reg_operand" "")
554 (sign_extend:SI (match_dup 1)))]
555 "TARGET_POWERPC && reload_completed"
556 [(set (match_dup 0)
557 (sign_extend:SI (match_dup 1)))
558 (set (match_dup 2)
559 (compare:CC (match_dup 0)
560 (const_int 0)))]
561 "")
562
563 (define_expand "extendqisi2_power"
564 [(parallel [(set (match_dup 2)
565 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
566 (const_int 24)))
567 (clobber (scratch:SI))])
568 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
569 (ashiftrt:SI (match_dup 2)
570 (const_int 24)))
571 (clobber (scratch:SI))])]
572 "TARGET_POWER"
573 "
574 { operands[1] = gen_lowpart (SImode, operands[1]);
575 operands[2] = gen_reg_rtx (SImode); }")
576
577 (define_expand "extendqisi2_no_power"
578 [(set (match_dup 2)
579 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
580 (const_int 24)))
581 (set (match_operand:SI 0 "gpc_reg_operand" "")
582 (ashiftrt:SI (match_dup 2)
583 (const_int 24)))]
584 "! TARGET_POWER && ! TARGET_POWERPC"
585 "
586 { operands[1] = gen_lowpart (SImode, operands[1]);
587 operands[2] = gen_reg_rtx (SImode); }")
588
589 (define_expand "zero_extendqihi2"
590 [(set (match_operand:HI 0 "gpc_reg_operand" "")
591 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
592 ""
593 "")
594
595 (define_insn ""
596 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
597 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
598 ""
599 "@
600 lbz%U1%X1 %0,%1
601 {rlinm|rlwinm} %0,%1,0,0xff"
602 [(set_attr "type" "load,*")])
603
604 (define_insn ""
605 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
606 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
607 (const_int 0)))
608 (clobber (match_scratch:HI 2 "=r,r"))]
609 ""
610 "@
611 {andil.|andi.} %2,%1,0xff
612 #"
613 [(set_attr "type" "compare")
614 (set_attr "length" "4,8")])
615
616 (define_split
617 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
618 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
619 (const_int 0)))
620 (clobber (match_scratch:HI 2 ""))]
621 "reload_completed"
622 [(set (match_dup 2)
623 (zero_extend:HI (match_dup 1)))
624 (set (match_dup 0)
625 (compare:CC (match_dup 2)
626 (const_int 0)))]
627 "")
628
629 (define_insn ""
630 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
631 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
632 (const_int 0)))
633 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
634 (zero_extend:HI (match_dup 1)))]
635 ""
636 "@
637 {andil.|andi.} %0,%1,0xff
638 #"
639 [(set_attr "type" "compare")
640 (set_attr "length" "4,8")])
641
642 (define_split
643 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
644 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
645 (const_int 0)))
646 (set (match_operand:HI 0 "gpc_reg_operand" "")
647 (zero_extend:HI (match_dup 1)))]
648 "reload_completed"
649 [(set (match_dup 0)
650 (zero_extend:HI (match_dup 1)))
651 (set (match_dup 2)
652 (compare:CC (match_dup 0)
653 (const_int 0)))]
654 "")
655
656 (define_expand "extendqihi2"
657 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
658 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
659 ""
660 "
661 {
662 if (TARGET_POWERPC)
663 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
664 else if (TARGET_POWER)
665 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
666 else
667 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
668 DONE;
669 }")
670
671 (define_insn "extendqihi2_ppc"
672 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
673 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
674 "TARGET_POWERPC"
675 "extsb %0,%1")
676
677 (define_insn ""
678 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
679 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
680 (const_int 0)))
681 (clobber (match_scratch:HI 2 "=r,r"))]
682 "TARGET_POWERPC"
683 "@
684 extsb. %2,%1
685 #"
686 [(set_attr "type" "compare")
687 (set_attr "length" "4,8")])
688
689 (define_split
690 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
691 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
692 (const_int 0)))
693 (clobber (match_scratch:HI 2 ""))]
694 "TARGET_POWERPC && reload_completed"
695 [(set (match_dup 2)
696 (sign_extend:HI (match_dup 1)))
697 (set (match_dup 0)
698 (compare:CC (match_dup 2)
699 (const_int 0)))]
700 "")
701
702 (define_insn ""
703 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
704 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
705 (const_int 0)))
706 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
707 (sign_extend:HI (match_dup 1)))]
708 "TARGET_POWERPC"
709 "@
710 extsb. %0,%1
711 #"
712 [(set_attr "type" "compare")
713 (set_attr "length" "4,8")])
714
715 (define_split
716 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
717 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
718 (const_int 0)))
719 (set (match_operand:HI 0 "gpc_reg_operand" "")
720 (sign_extend:HI (match_dup 1)))]
721 "TARGET_POWERPC && reload_completed"
722 [(set (match_dup 0)
723 (sign_extend:HI (match_dup 1)))
724 (set (match_dup 2)
725 (compare:CC (match_dup 0)
726 (const_int 0)))]
727 "")
728
729 (define_expand "extendqihi2_power"
730 [(parallel [(set (match_dup 2)
731 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
732 (const_int 24)))
733 (clobber (scratch:SI))])
734 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
735 (ashiftrt:SI (match_dup 2)
736 (const_int 24)))
737 (clobber (scratch:SI))])]
738 "TARGET_POWER"
739 "
740 { operands[0] = gen_lowpart (SImode, operands[0]);
741 operands[1] = gen_lowpart (SImode, operands[1]);
742 operands[2] = gen_reg_rtx (SImode); }")
743
744 (define_expand "extendqihi2_no_power"
745 [(set (match_dup 2)
746 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
747 (const_int 24)))
748 (set (match_operand:HI 0 "gpc_reg_operand" "")
749 (ashiftrt:SI (match_dup 2)
750 (const_int 24)))]
751 "! TARGET_POWER && ! TARGET_POWERPC"
752 "
753 { operands[0] = gen_lowpart (SImode, operands[0]);
754 operands[1] = gen_lowpart (SImode, operands[1]);
755 operands[2] = gen_reg_rtx (SImode); }")
756
757 (define_expand "zero_extendhisi2"
758 [(set (match_operand:SI 0 "gpc_reg_operand" "")
759 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
760 ""
761 "")
762
763 (define_insn ""
764 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
765 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
766 ""
767 "@
768 lhz%U1%X1 %0,%1
769 {rlinm|rlwinm} %0,%1,0,0xffff"
770 [(set_attr "type" "load,*")])
771
772 (define_insn ""
773 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
774 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
775 (const_int 0)))
776 (clobber (match_scratch:SI 2 "=r,r"))]
777 ""
778 "@
779 {andil.|andi.} %2,%1,0xffff
780 #"
781 [(set_attr "type" "compare")
782 (set_attr "length" "4,8")])
783
784 (define_split
785 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
786 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
787 (const_int 0)))
788 (clobber (match_scratch:SI 2 ""))]
789 "reload_completed"
790 [(set (match_dup 2)
791 (zero_extend:SI (match_dup 1)))
792 (set (match_dup 0)
793 (compare:CC (match_dup 2)
794 (const_int 0)))]
795 "")
796
797 (define_insn ""
798 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
799 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
800 (const_int 0)))
801 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
802 (zero_extend:SI (match_dup 1)))]
803 ""
804 "@
805 {andil.|andi.} %0,%1,0xffff
806 #"
807 [(set_attr "type" "compare")
808 (set_attr "length" "4,8")])
809
810 (define_split
811 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
812 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
813 (const_int 0)))
814 (set (match_operand:SI 0 "gpc_reg_operand" "")
815 (zero_extend:SI (match_dup 1)))]
816 "reload_completed"
817 [(set (match_dup 0)
818 (zero_extend:SI (match_dup 1)))
819 (set (match_dup 2)
820 (compare:CC (match_dup 0)
821 (const_int 0)))]
822 "")
823
824 (define_expand "extendhisi2"
825 [(set (match_operand:SI 0 "gpc_reg_operand" "")
826 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
827 ""
828 "")
829
830 (define_insn ""
831 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
832 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
833 ""
834 "@
835 lha%U1%X1 %0,%1
836 {exts|extsh} %0,%1"
837 [(set_attr "type" "load_ext,*")])
838
839 (define_insn ""
840 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
841 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
842 (const_int 0)))
843 (clobber (match_scratch:SI 2 "=r,r"))]
844 ""
845 "@
846 {exts.|extsh.} %2,%1
847 #"
848 [(set_attr "type" "compare")
849 (set_attr "length" "4,8")])
850
851 (define_split
852 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
853 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
854 (const_int 0)))
855 (clobber (match_scratch:SI 2 ""))]
856 "reload_completed"
857 [(set (match_dup 2)
858 (sign_extend:SI (match_dup 1)))
859 (set (match_dup 0)
860 (compare:CC (match_dup 2)
861 (const_int 0)))]
862 "")
863
864 (define_insn ""
865 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
866 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
867 (const_int 0)))
868 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
869 (sign_extend:SI (match_dup 1)))]
870 ""
871 "@
872 {exts.|extsh.} %0,%1
873 #"
874 [(set_attr "type" "compare")
875 (set_attr "length" "4,8")])
876 \f
877 (define_split
878 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
879 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
880 (const_int 0)))
881 (set (match_operand:SI 0 "gpc_reg_operand" "")
882 (sign_extend:SI (match_dup 1)))]
883 "reload_completed"
884 [(set (match_dup 0)
885 (sign_extend:SI (match_dup 1)))
886 (set (match_dup 2)
887 (compare:CC (match_dup 0)
888 (const_int 0)))]
889 "")
890
891 ;; Fixed-point arithmetic insns.
892
893 (define_expand "add<mode>3"
894 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
895 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
896 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
897 ""
898 "
899 {
900 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
901 {
902 if (non_short_cint_operand (operands[2], DImode))
903 FAIL;
904 }
905 else if (GET_CODE (operands[2]) == CONST_INT
906 && ! add_operand (operands[2], <MODE>mode))
907 {
908 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
909 ? operands[0] : gen_reg_rtx (<MODE>mode));
910
911 HOST_WIDE_INT val = INTVAL (operands[2]);
912 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
913 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
914
915 if (<MODE>mode == DImode && !CONST_OK_FOR_LETTER_P (rest, 'L'))
916 FAIL;
917
918 /* The ordering here is important for the prolog expander.
919 When space is allocated from the stack, adding 'low' first may
920 produce a temporary deallocation (which would be bad). */
921 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
922 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
923 DONE;
924 }
925 }")
926
927 ;; Discourage ai/addic because of carry but provide it in an alternative
928 ;; allowing register zero as source.
929 (define_insn "*add<mode>3_internal1"
930 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
931 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
932 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
933 ""
934 "@
935 {cax|add} %0,%1,%2
936 {cal %0,%2(%1)|addi %0,%1,%2}
937 {ai|addic} %0,%1,%2
938 {cau|addis} %0,%1,%v2"
939 [(set_attr "length" "4,4,4,4")])
940
941 (define_insn "addsi3_high"
942 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
943 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
944 (high:SI (match_operand 2 "" ""))))]
945 "TARGET_MACHO && !TARGET_64BIT"
946 "{cau|addis} %0,%1,ha16(%2)"
947 [(set_attr "length" "4")])
948
949 (define_insn "*add<mode>3_internal2"
950 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
951 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
952 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
953 (const_int 0)))
954 (clobber (match_scratch:P 3 "=r,r,r,r"))]
955 ""
956 "@
957 {cax.|add.} %3,%1,%2
958 {ai.|addic.} %3,%1,%2
959 #
960 #"
961 [(set_attr "type" "fast_compare,compare,compare,compare")
962 (set_attr "length" "4,4,8,8")])
963
964 (define_split
965 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
966 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
967 (match_operand:GPR 2 "reg_or_short_operand" ""))
968 (const_int 0)))
969 (clobber (match_scratch:GPR 3 ""))]
970 "reload_completed"
971 [(set (match_dup 3)
972 (plus:GPR (match_dup 1)
973 (match_dup 2)))
974 (set (match_dup 0)
975 (compare:CC (match_dup 3)
976 (const_int 0)))]
977 "")
978
979 (define_insn "*add<mode>3_internal3"
980 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
981 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
982 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
983 (const_int 0)))
984 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
985 (plus:P (match_dup 1)
986 (match_dup 2)))]
987 ""
988 "@
989 {cax.|add.} %0,%1,%2
990 {ai.|addic.} %0,%1,%2
991 #
992 #"
993 [(set_attr "type" "fast_compare,compare,compare,compare")
994 (set_attr "length" "4,4,8,8")])
995
996 (define_split
997 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
998 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
999 (match_operand:P 2 "reg_or_short_operand" ""))
1000 (const_int 0)))
1001 (set (match_operand:P 0 "gpc_reg_operand" "")
1002 (plus:P (match_dup 1) (match_dup 2)))]
1003 "reload_completed"
1004 [(set (match_dup 0)
1005 (plus:P (match_dup 1)
1006 (match_dup 2)))
1007 (set (match_dup 3)
1008 (compare:CC (match_dup 0)
1009 (const_int 0)))]
1010 "")
1011
1012 ;; Split an add that we can't do in one insn into two insns, each of which
1013 ;; does one 16-bit part. This is used by combine. Note that the low-order
1014 ;; add should be last in case the result gets used in an address.
1015
1016 (define_split
1017 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1018 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1019 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1020 ""
1021 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1022 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1023 "
1024 {
1025 HOST_WIDE_INT val = INTVAL (operands[2]);
1026 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1027 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1028
1029 operands[4] = GEN_INT (low);
1030 if (<MODE>mode == SImode || CONST_OK_FOR_LETTER_P (rest, 'L'))
1031 operands[3] = GEN_INT (rest);
1032 else if (! no_new_pseudos)
1033 {
1034 operands[3] = gen_reg_rtx (DImode);
1035 emit_move_insn (operands[3], operands[2]);
1036 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1037 DONE;
1038 }
1039 else
1040 FAIL;
1041 }")
1042
1043 (define_insn "one_cmpl<mode>2"
1044 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1045 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1046 ""
1047 "nor %0,%1,%1")
1048
1049 (define_insn ""
1050 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1051 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1052 (const_int 0)))
1053 (clobber (match_scratch:P 2 "=r,r"))]
1054 ""
1055 "@
1056 nor. %2,%1,%1
1057 #"
1058 [(set_attr "type" "compare")
1059 (set_attr "length" "4,8")])
1060
1061 (define_split
1062 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1063 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1064 (const_int 0)))
1065 (clobber (match_scratch:P 2 ""))]
1066 "reload_completed"
1067 [(set (match_dup 2)
1068 (not:P (match_dup 1)))
1069 (set (match_dup 0)
1070 (compare:CC (match_dup 2)
1071 (const_int 0)))]
1072 "")
1073
1074 (define_insn ""
1075 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1076 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1077 (const_int 0)))
1078 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1079 (not:P (match_dup 1)))]
1080 ""
1081 "@
1082 nor. %0,%1,%1
1083 #"
1084 [(set_attr "type" "compare")
1085 (set_attr "length" "4,8")])
1086
1087 (define_split
1088 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1089 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1090 (const_int 0)))
1091 (set (match_operand:P 0 "gpc_reg_operand" "")
1092 (not:P (match_dup 1)))]
1093 "reload_completed"
1094 [(set (match_dup 0)
1095 (not:P (match_dup 1)))
1096 (set (match_dup 2)
1097 (compare:CC (match_dup 0)
1098 (const_int 0)))]
1099 "")
1100
1101 (define_insn ""
1102 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1103 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1104 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1105 "! TARGET_POWERPC"
1106 "{sf%I1|subf%I1c} %0,%2,%1")
1107
1108 (define_insn ""
1109 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1110 (minus:GPR (match_operand:GPR 1 "reg_or_short_operand" "r,I")
1111 (match_operand:GPR 2 "gpc_reg_operand" "r,r")))]
1112 "TARGET_POWERPC"
1113 "@
1114 subf %0,%2,%1
1115 subfic %0,%2,%1")
1116
1117 (define_insn ""
1118 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1119 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1120 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1121 (const_int 0)))
1122 (clobber (match_scratch:SI 3 "=r,r"))]
1123 "! TARGET_POWERPC"
1124 "@
1125 {sf.|subfc.} %3,%2,%1
1126 #"
1127 [(set_attr "type" "compare")
1128 (set_attr "length" "4,8")])
1129
1130 (define_insn ""
1131 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1132 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1133 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1134 (const_int 0)))
1135 (clobber (match_scratch:P 3 "=r,r"))]
1136 "TARGET_POWERPC"
1137 "@
1138 subf. %3,%2,%1
1139 #"
1140 [(set_attr "type" "fast_compare")
1141 (set_attr "length" "4,8")])
1142
1143 (define_split
1144 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1145 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1146 (match_operand:P 2 "gpc_reg_operand" ""))
1147 (const_int 0)))
1148 (clobber (match_scratch:P 3 ""))]
1149 "reload_completed"
1150 [(set (match_dup 3)
1151 (minus:P (match_dup 1)
1152 (match_dup 2)))
1153 (set (match_dup 0)
1154 (compare:CC (match_dup 3)
1155 (const_int 0)))]
1156 "")
1157
1158 (define_insn ""
1159 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1160 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1161 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1162 (const_int 0)))
1163 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1164 (minus:SI (match_dup 1) (match_dup 2)))]
1165 "! TARGET_POWERPC"
1166 "@
1167 {sf.|subfc.} %0,%2,%1
1168 #"
1169 [(set_attr "type" "compare")
1170 (set_attr "length" "4,8")])
1171
1172 (define_insn ""
1173 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1174 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1175 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1176 (const_int 0)))
1177 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1178 (minus:P (match_dup 1)
1179 (match_dup 2)))]
1180 "TARGET_POWERPC"
1181 "@
1182 subf. %0,%2,%1
1183 #"
1184 [(set_attr "type" "fast_compare")
1185 (set_attr "length" "4,8")])
1186
1187 (define_split
1188 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1189 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1190 (match_operand:P 2 "gpc_reg_operand" ""))
1191 (const_int 0)))
1192 (set (match_operand:P 0 "gpc_reg_operand" "")
1193 (minus:P (match_dup 1)
1194 (match_dup 2)))]
1195 "reload_completed"
1196 [(set (match_dup 0)
1197 (minus:P (match_dup 1)
1198 (match_dup 2)))
1199 (set (match_dup 3)
1200 (compare:CC (match_dup 0)
1201 (const_int 0)))]
1202 "")
1203
1204 (define_expand "sub<mode>3"
1205 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1206 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1207 (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
1208 ""
1209 "
1210 {
1211 if (GET_CODE (operands[2]) == CONST_INT)
1212 {
1213 emit_insn (gen_add<mode>3 (operands[0], operands[1],
1214 negate_rtx (<MODE>mode, operands[2])));
1215 DONE;
1216 }
1217 }")
1218
1219 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1220 ;; instruction and some auxiliary computations. Then we just have a single
1221 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1222 ;; combine.
1223
1224 (define_expand "sminsi3"
1225 [(set (match_dup 3)
1226 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1227 (match_operand:SI 2 "reg_or_short_operand" ""))
1228 (const_int 0)
1229 (minus:SI (match_dup 2) (match_dup 1))))
1230 (set (match_operand:SI 0 "gpc_reg_operand" "")
1231 (minus:SI (match_dup 2) (match_dup 3)))]
1232 "TARGET_POWER || TARGET_ISEL"
1233 "
1234 {
1235 if (TARGET_ISEL)
1236 {
1237 operands[2] = force_reg (SImode, operands[2]);
1238 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1239 DONE;
1240 }
1241
1242 operands[3] = gen_reg_rtx (SImode);
1243 }")
1244
1245 (define_split
1246 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1247 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1248 (match_operand:SI 2 "reg_or_short_operand" "")))
1249 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1250 "TARGET_POWER"
1251 [(set (match_dup 3)
1252 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1253 (const_int 0)
1254 (minus:SI (match_dup 2) (match_dup 1))))
1255 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1256 "")
1257
1258 (define_expand "smaxsi3"
1259 [(set (match_dup 3)
1260 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1261 (match_operand:SI 2 "reg_or_short_operand" ""))
1262 (const_int 0)
1263 (minus:SI (match_dup 2) (match_dup 1))))
1264 (set (match_operand:SI 0 "gpc_reg_operand" "")
1265 (plus:SI (match_dup 3) (match_dup 1)))]
1266 "TARGET_POWER || TARGET_ISEL"
1267 "
1268 {
1269 if (TARGET_ISEL)
1270 {
1271 operands[2] = force_reg (SImode, operands[2]);
1272 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1273 DONE;
1274 }
1275 operands[3] = gen_reg_rtx (SImode);
1276 }")
1277
1278 (define_split
1279 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1280 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1281 (match_operand:SI 2 "reg_or_short_operand" "")))
1282 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1283 "TARGET_POWER"
1284 [(set (match_dup 3)
1285 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1286 (const_int 0)
1287 (minus:SI (match_dup 2) (match_dup 1))))
1288 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1289 "")
1290
1291 (define_expand "uminsi3"
1292 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1293 (match_dup 5)))
1294 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1295 (match_dup 5)))
1296 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1297 (const_int 0)
1298 (minus:SI (match_dup 4) (match_dup 3))))
1299 (set (match_operand:SI 0 "gpc_reg_operand" "")
1300 (minus:SI (match_dup 2) (match_dup 3)))]
1301 "TARGET_POWER || TARGET_ISEL"
1302 "
1303 {
1304 if (TARGET_ISEL)
1305 {
1306 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1307 DONE;
1308 }
1309 operands[3] = gen_reg_rtx (SImode);
1310 operands[4] = gen_reg_rtx (SImode);
1311 operands[5] = GEN_INT (-2147483647 - 1);
1312 }")
1313
1314 (define_expand "umaxsi3"
1315 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1316 (match_dup 5)))
1317 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1318 (match_dup 5)))
1319 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1320 (const_int 0)
1321 (minus:SI (match_dup 4) (match_dup 3))))
1322 (set (match_operand:SI 0 "gpc_reg_operand" "")
1323 (plus:SI (match_dup 3) (match_dup 1)))]
1324 "TARGET_POWER || TARGET_ISEL"
1325 "
1326 {
1327 if (TARGET_ISEL)
1328 {
1329 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1330 DONE;
1331 }
1332 operands[3] = gen_reg_rtx (SImode);
1333 operands[4] = gen_reg_rtx (SImode);
1334 operands[5] = GEN_INT (-2147483647 - 1);
1335 }")
1336
1337 (define_insn ""
1338 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1339 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1340 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1341 (const_int 0)
1342 (minus:SI (match_dup 2) (match_dup 1))))]
1343 "TARGET_POWER"
1344 "doz%I2 %0,%1,%2")
1345
1346 (define_insn ""
1347 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1348 (compare:CC
1349 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1350 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1351 (const_int 0)
1352 (minus:SI (match_dup 2) (match_dup 1)))
1353 (const_int 0)))
1354 (clobber (match_scratch:SI 3 "=r,r"))]
1355 "TARGET_POWER"
1356 "@
1357 doz%I2. %3,%1,%2
1358 #"
1359 [(set_attr "type" "delayed_compare")
1360 (set_attr "length" "4,8")])
1361
1362 (define_split
1363 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1364 (compare:CC
1365 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1366 (match_operand:SI 2 "reg_or_short_operand" ""))
1367 (const_int 0)
1368 (minus:SI (match_dup 2) (match_dup 1)))
1369 (const_int 0)))
1370 (clobber (match_scratch:SI 3 ""))]
1371 "TARGET_POWER && reload_completed"
1372 [(set (match_dup 3)
1373 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1374 (const_int 0)
1375 (minus:SI (match_dup 2) (match_dup 1))))
1376 (set (match_dup 0)
1377 (compare:CC (match_dup 3)
1378 (const_int 0)))]
1379 "")
1380
1381 (define_insn ""
1382 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1383 (compare:CC
1384 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1385 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1386 (const_int 0)
1387 (minus:SI (match_dup 2) (match_dup 1)))
1388 (const_int 0)))
1389 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1390 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1391 (const_int 0)
1392 (minus:SI (match_dup 2) (match_dup 1))))]
1393 "TARGET_POWER"
1394 "@
1395 doz%I2. %0,%1,%2
1396 #"
1397 [(set_attr "type" "delayed_compare")
1398 (set_attr "length" "4,8")])
1399
1400 (define_split
1401 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1402 (compare:CC
1403 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1404 (match_operand:SI 2 "reg_or_short_operand" ""))
1405 (const_int 0)
1406 (minus:SI (match_dup 2) (match_dup 1)))
1407 (const_int 0)))
1408 (set (match_operand:SI 0 "gpc_reg_operand" "")
1409 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1410 (const_int 0)
1411 (minus:SI (match_dup 2) (match_dup 1))))]
1412 "TARGET_POWER && reload_completed"
1413 [(set (match_dup 0)
1414 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1415 (const_int 0)
1416 (minus:SI (match_dup 2) (match_dup 1))))
1417 (set (match_dup 3)
1418 (compare:CC (match_dup 0)
1419 (const_int 0)))]
1420 "")
1421
1422 ;; We don't need abs with condition code because such comparisons should
1423 ;; never be done.
1424 (define_expand "abssi2"
1425 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1426 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1427 ""
1428 "
1429 {
1430 if (TARGET_ISEL)
1431 {
1432 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
1433 DONE;
1434 }
1435 else if (! TARGET_POWER)
1436 {
1437 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
1438 DONE;
1439 }
1440 }")
1441
1442 (define_insn "*abssi2_power"
1443 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1444 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1445 "TARGET_POWER"
1446 "abs %0,%1")
1447
1448 (define_insn_and_split "abssi2_isel"
1449 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1450 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
1451 (clobber (match_scratch:SI 2 "=&b"))
1452 (clobber (match_scratch:CC 3 "=y"))]
1453 "TARGET_ISEL"
1454 "#"
1455 "&& reload_completed"
1456 [(set (match_dup 2) (neg:SI (match_dup 1)))
1457 (set (match_dup 3)
1458 (compare:CC (match_dup 1)
1459 (const_int 0)))
1460 (set (match_dup 0)
1461 (if_then_else:SI (ge (match_dup 3)
1462 (const_int 0))
1463 (match_dup 1)
1464 (match_dup 2)))]
1465 "")
1466
1467 (define_insn_and_split "abssi2_nopower"
1468 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1469 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
1470 (clobber (match_scratch:SI 2 "=&r,&r"))]
1471 "! TARGET_POWER && ! TARGET_ISEL"
1472 "#"
1473 "&& reload_completed"
1474 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1475 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1476 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
1477 "")
1478
1479 (define_insn "*nabs_power"
1480 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1481 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
1482 "TARGET_POWER"
1483 "nabs %0,%1")
1484
1485 (define_insn_and_split "*nabs_nopower"
1486 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1487 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
1488 (clobber (match_scratch:SI 2 "=&r,&r"))]
1489 "! TARGET_POWER"
1490 "#"
1491 "&& reload_completed"
1492 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1493 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1494 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
1495 "")
1496
1497 (define_expand "neg<mode>2"
1498 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1499 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
1500 ""
1501 "")
1502
1503 (define_insn "*neg<mode>2_internal"
1504 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1505 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1506 ""
1507 "neg %0,%1")
1508
1509 (define_insn ""
1510 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1511 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1512 (const_int 0)))
1513 (clobber (match_scratch:P 2 "=r,r"))]
1514 ""
1515 "@
1516 neg. %2,%1
1517 #"
1518 [(set_attr "type" "fast_compare")
1519 (set_attr "length" "4,8")])
1520
1521 (define_split
1522 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1523 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
1524 (const_int 0)))
1525 (clobber (match_scratch:P 2 ""))]
1526 "reload_completed"
1527 [(set (match_dup 2)
1528 (neg:P (match_dup 1)))
1529 (set (match_dup 0)
1530 (compare:CC (match_dup 2)
1531 (const_int 0)))]
1532 "")
1533
1534 (define_insn ""
1535 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1536 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1537 (const_int 0)))
1538 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1539 (neg:P (match_dup 1)))]
1540 ""
1541 "@
1542 neg. %0,%1
1543 #"
1544 [(set_attr "type" "fast_compare")
1545 (set_attr "length" "4,8")])
1546
1547 (define_split
1548 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1549 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
1550 (const_int 0)))
1551 (set (match_operand:P 0 "gpc_reg_operand" "")
1552 (neg:P (match_dup 1)))]
1553 "reload_completed"
1554 [(set (match_dup 0)
1555 (neg:P (match_dup 1)))
1556 (set (match_dup 2)
1557 (compare:CC (match_dup 0)
1558 (const_int 0)))]
1559 "")
1560
1561 (define_insn "clz<mode>2"
1562 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1563 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1564 ""
1565 "{cntlz|cntlz<wd>} %0,%1")
1566
1567 (define_expand "ctz<mode>2"
1568 [(set (match_dup 2)
1569 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))
1570 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
1571 (match_dup 2)))
1572 (clobber (scratch:CC))])
1573 (set (match_dup 4) (clz:GPR (match_dup 3)))
1574 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1575 (minus:GPR (match_dup 5) (match_dup 4)))]
1576 ""
1577 {
1578 operands[2] = gen_reg_rtx (<MODE>mode);
1579 operands[3] = gen_reg_rtx (<MODE>mode);
1580 operands[4] = gen_reg_rtx (<MODE>mode);
1581 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
1582 })
1583
1584 (define_expand "ffs<mode>2"
1585 [(set (match_dup 2)
1586 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))
1587 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
1588 (match_dup 2)))
1589 (clobber (scratch:CC))])
1590 (set (match_dup 4) (clz:GPR (match_dup 3)))
1591 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1592 (minus:GPR (match_dup 5) (match_dup 4)))]
1593 ""
1594 {
1595 operands[2] = gen_reg_rtx (<MODE>mode);
1596 operands[3] = gen_reg_rtx (<MODE>mode);
1597 operands[4] = gen_reg_rtx (<MODE>mode);
1598 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
1599 })
1600
1601 (define_expand "popcount<mode>2"
1602 [(set (match_dup 2)
1603 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
1604 UNSPEC_POPCNTB))
1605 (set (match_dup 3)
1606 (mult:GPR (match_dup 2) (match_dup 4)))
1607 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1608 (lshiftrt:GPR (match_dup 3) (match_dup 5)))]
1609 "TARGET_POPCNTB"
1610 {
1611 operands[2] = gen_reg_rtx (<MODE>mode);
1612 operands[3] = gen_reg_rtx (<MODE>mode);
1613 operands[4] = force_reg (<MODE>mode,
1614 <MODE>mode == SImode
1615 ? GEN_INT (0x01010101)
1616 : GEN_INT ((HOST_WIDE_INT)
1617 0x01010101 << 32 | 0x01010101));
1618 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 8);
1619 })
1620
1621 (define_insn "popcntb<mode>2"
1622 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1623 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
1624 UNSPEC_POPCNTB))]
1625 "TARGET_POPCNTB"
1626 "popcntb %0,%1")
1627
1628 (define_expand "mulsi3"
1629 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1630 (use (match_operand:SI 1 "gpc_reg_operand" ""))
1631 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
1632 ""
1633 "
1634 {
1635 if (TARGET_POWER)
1636 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
1637 else
1638 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
1639 DONE;
1640 }")
1641
1642 (define_insn "mulsi3_mq"
1643 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1644 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1645 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
1646 (clobber (match_scratch:SI 3 "=q,q"))]
1647 "TARGET_POWER"
1648 "@
1649 {muls|mullw} %0,%1,%2
1650 {muli|mulli} %0,%1,%2"
1651 [(set (attr "type")
1652 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
1653 (const_string "imul3")
1654 (match_operand:SI 2 "short_cint_operand" "")
1655 (const_string "imul2")]
1656 (const_string "imul")))])
1657
1658 (define_insn "mulsi3_no_mq"
1659 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1660 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1661 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
1662 "! TARGET_POWER"
1663 "@
1664 {muls|mullw} %0,%1,%2
1665 {muli|mulli} %0,%1,%2"
1666 [(set (attr "type")
1667 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
1668 (const_string "imul3")
1669 (match_operand:SI 2 "short_cint_operand" "")
1670 (const_string "imul2")]
1671 (const_string "imul")))])
1672
1673 (define_insn "*mulsi3_mq_internal1"
1674 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1675 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1676 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1677 (const_int 0)))
1678 (clobber (match_scratch:SI 3 "=r,r"))
1679 (clobber (match_scratch:SI 4 "=q,q"))]
1680 "TARGET_POWER"
1681 "@
1682 {muls.|mullw.} %3,%1,%2
1683 #"
1684 [(set_attr "type" "imul_compare")
1685 (set_attr "length" "4,8")])
1686
1687 (define_split
1688 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1689 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1690 (match_operand:SI 2 "gpc_reg_operand" ""))
1691 (const_int 0)))
1692 (clobber (match_scratch:SI 3 ""))
1693 (clobber (match_scratch:SI 4 ""))]
1694 "TARGET_POWER && reload_completed"
1695 [(parallel [(set (match_dup 3)
1696 (mult:SI (match_dup 1) (match_dup 2)))
1697 (clobber (match_dup 4))])
1698 (set (match_dup 0)
1699 (compare:CC (match_dup 3)
1700 (const_int 0)))]
1701 "")
1702
1703 (define_insn "*mulsi3_no_mq_internal1"
1704 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1705 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1706 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1707 (const_int 0)))
1708 (clobber (match_scratch:SI 3 "=r,r"))]
1709 "! TARGET_POWER"
1710 "@
1711 {muls.|mullw.} %3,%1,%2
1712 #"
1713 [(set_attr "type" "imul_compare")
1714 (set_attr "length" "4,8")])
1715
1716 (define_split
1717 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1718 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1719 (match_operand:SI 2 "gpc_reg_operand" ""))
1720 (const_int 0)))
1721 (clobber (match_scratch:SI 3 ""))]
1722 "! TARGET_POWER && reload_completed"
1723 [(set (match_dup 3)
1724 (mult:SI (match_dup 1) (match_dup 2)))
1725 (set (match_dup 0)
1726 (compare:CC (match_dup 3)
1727 (const_int 0)))]
1728 "")
1729
1730 (define_insn "*mulsi3_mq_internal2"
1731 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1732 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1733 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1734 (const_int 0)))
1735 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1736 (mult:SI (match_dup 1) (match_dup 2)))
1737 (clobber (match_scratch:SI 4 "=q,q"))]
1738 "TARGET_POWER"
1739 "@
1740 {muls.|mullw.} %0,%1,%2
1741 #"
1742 [(set_attr "type" "imul_compare")
1743 (set_attr "length" "4,8")])
1744
1745 (define_split
1746 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1747 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1748 (match_operand:SI 2 "gpc_reg_operand" ""))
1749 (const_int 0)))
1750 (set (match_operand:SI 0 "gpc_reg_operand" "")
1751 (mult:SI (match_dup 1) (match_dup 2)))
1752 (clobber (match_scratch:SI 4 ""))]
1753 "TARGET_POWER && reload_completed"
1754 [(parallel [(set (match_dup 0)
1755 (mult:SI (match_dup 1) (match_dup 2)))
1756 (clobber (match_dup 4))])
1757 (set (match_dup 3)
1758 (compare:CC (match_dup 0)
1759 (const_int 0)))]
1760 "")
1761
1762 (define_insn "*mulsi3_no_mq_internal2"
1763 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1764 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1765 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1766 (const_int 0)))
1767 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1768 (mult:SI (match_dup 1) (match_dup 2)))]
1769 "! TARGET_POWER"
1770 "@
1771 {muls.|mullw.} %0,%1,%2
1772 #"
1773 [(set_attr "type" "imul_compare")
1774 (set_attr "length" "4,8")])
1775
1776 (define_split
1777 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1778 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1779 (match_operand:SI 2 "gpc_reg_operand" ""))
1780 (const_int 0)))
1781 (set (match_operand:SI 0 "gpc_reg_operand" "")
1782 (mult:SI (match_dup 1) (match_dup 2)))]
1783 "! TARGET_POWER && reload_completed"
1784 [(set (match_dup 0)
1785 (mult:SI (match_dup 1) (match_dup 2)))
1786 (set (match_dup 3)
1787 (compare:CC (match_dup 0)
1788 (const_int 0)))]
1789 "")
1790
1791 ;; Operand 1 is divided by operand 2; quotient goes to operand
1792 ;; 0 and remainder to operand 3.
1793 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
1794
1795 (define_expand "divmodsi4"
1796 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1797 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1798 (match_operand:SI 2 "gpc_reg_operand" "")))
1799 (set (match_operand:SI 3 "register_operand" "")
1800 (mod:SI (match_dup 1) (match_dup 2)))])]
1801 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
1802 "
1803 {
1804 if (! TARGET_POWER && ! TARGET_POWERPC)
1805 {
1806 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1807 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
1808 emit_insn (gen_divss_call ());
1809 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
1810 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
1811 DONE;
1812 }
1813 }")
1814
1815 (define_insn "*divmodsi4_internal"
1816 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1817 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1818 (match_operand:SI 2 "gpc_reg_operand" "r")))
1819 (set (match_operand:SI 3 "register_operand" "=q")
1820 (mod:SI (match_dup 1) (match_dup 2)))]
1821 "TARGET_POWER"
1822 "divs %0,%1,%2"
1823 [(set_attr "type" "idiv")])
1824
1825 (define_expand "udiv<mode>3"
1826 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1827 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1828 (match_operand:GPR 2 "gpc_reg_operand" "")))]
1829 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
1830 "
1831 {
1832 if (! TARGET_POWER && ! TARGET_POWERPC)
1833 {
1834 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1835 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
1836 emit_insn (gen_quous_call ());
1837 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
1838 DONE;
1839 }
1840 else if (TARGET_POWER)
1841 {
1842 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
1843 DONE;
1844 }
1845 }")
1846
1847 (define_insn "udivsi3_mq"
1848 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1849 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1850 (match_operand:SI 2 "gpc_reg_operand" "r")))
1851 (clobber (match_scratch:SI 3 "=q"))]
1852 "TARGET_POWERPC && TARGET_POWER"
1853 "divwu %0,%1,%2"
1854 [(set_attr "type" "idiv")])
1855
1856 (define_insn "*udivsi3_no_mq"
1857 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1858 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
1859 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
1860 "TARGET_POWERPC && ! TARGET_POWER"
1861 "div<wd>u %0,%1,%2"
1862 [(set_attr "type" "idiv")])
1863
1864 ;; For powers of two we can do srai/aze for divide and then adjust for
1865 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
1866 ;; used; for PowerPC, force operands into register and do a normal divide;
1867 ;; for AIX common-mode, use quoss call on register operands.
1868 (define_expand "div<mode>3"
1869 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1870 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1871 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
1872 ""
1873 "
1874 {
1875 if (GET_CODE (operands[2]) == CONST_INT
1876 && INTVAL (operands[2]) > 0
1877 && exact_log2 (INTVAL (operands[2])) >= 0)
1878 ;
1879 else if (TARGET_POWERPC)
1880 {
1881 operands[2] = force_reg (SImode, operands[2]);
1882 if (TARGET_POWER)
1883 {
1884 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
1885 DONE;
1886 }
1887 }
1888 else if (TARGET_POWER)
1889 FAIL;
1890 else
1891 {
1892 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1893 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
1894 emit_insn (gen_quoss_call ());
1895 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
1896 DONE;
1897 }
1898 }")
1899
1900 (define_insn "divsi3_mq"
1901 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1902 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1903 (match_operand:SI 2 "gpc_reg_operand" "r")))
1904 (clobber (match_scratch:SI 3 "=q"))]
1905 "TARGET_POWERPC && TARGET_POWER"
1906 "divw %0,%1,%2"
1907 [(set_attr "type" "idiv")])
1908
1909 (define_insn "*div<mode>3_no_mq"
1910 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1911 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
1912 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
1913 "TARGET_POWERPC && ! TARGET_POWER"
1914 "div<wd> %0,%1,%2"
1915 [(set_attr "type" "idiv")])
1916
1917 (define_expand "mod<mode>3"
1918 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
1919 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
1920 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
1921 ""
1922 "
1923 {
1924 int i;
1925 rtx temp1;
1926 rtx temp2;
1927
1928 if (GET_CODE (operands[2]) != CONST_INT
1929 || INTVAL (operands[2]) <= 0
1930 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
1931 FAIL;
1932
1933 temp1 = gen_reg_rtx (<MODE>mode);
1934 temp2 = gen_reg_rtx (<MODE>mode);
1935
1936 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
1937 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
1938 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
1939 DONE;
1940 }")
1941
1942 (define_insn ""
1943 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1944 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
1945 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
1946 ""
1947 "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
1948 [(set_attr "type" "two")
1949 (set_attr "length" "8")])
1950
1951 (define_insn ""
1952 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1953 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1954 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
1955 (const_int 0)))
1956 (clobber (match_scratch:P 3 "=r,r"))]
1957 ""
1958 "@
1959 {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
1960 #"
1961 [(set_attr "type" "compare")
1962 (set_attr "length" "8,12")])
1963
1964 (define_split
1965 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1966 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1967 (match_operand:GPR 2 "exact_log2_cint_operand"
1968 ""))
1969 (const_int 0)))
1970 (clobber (match_scratch:GPR 3 ""))]
1971 "reload_completed"
1972 [(set (match_dup 3)
1973 (div:<MODE> (match_dup 1) (match_dup 2)))
1974 (set (match_dup 0)
1975 (compare:CC (match_dup 3)
1976 (const_int 0)))]
1977 "")
1978
1979 (define_insn ""
1980 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1981 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1982 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
1983 (const_int 0)))
1984 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1985 (div:P (match_dup 1) (match_dup 2)))]
1986 ""
1987 "@
1988 {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
1989 #"
1990 [(set_attr "type" "compare")
1991 (set_attr "length" "8,12")])
1992
1993 (define_split
1994 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1995 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1996 (match_operand:GPR 2 "exact_log2_cint_operand"
1997 ""))
1998 (const_int 0)))
1999 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2000 (div:GPR (match_dup 1) (match_dup 2)))]
2001 "reload_completed"
2002 [(set (match_dup 0)
2003 (div:<MODE> (match_dup 1) (match_dup 2)))
2004 (set (match_dup 3)
2005 (compare:CC (match_dup 0)
2006 (const_int 0)))]
2007 "")
2008
2009 (define_insn ""
2010 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2011 (udiv:SI
2012 (plus:DI (ashift:DI
2013 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2014 (const_int 32))
2015 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2016 (match_operand:SI 3 "gpc_reg_operand" "r")))
2017 (set (match_operand:SI 2 "register_operand" "=*q")
2018 (umod:SI
2019 (plus:DI (ashift:DI
2020 (zero_extend:DI (match_dup 1)) (const_int 32))
2021 (zero_extend:DI (match_dup 4)))
2022 (match_dup 3)))]
2023 "TARGET_POWER"
2024 "div %0,%1,%3"
2025 [(set_attr "type" "idiv")])
2026
2027 ;; To do unsigned divide we handle the cases of the divisor looking like a
2028 ;; negative number. If it is a constant that is less than 2**31, we don't
2029 ;; have to worry about the branches. So make a few subroutines here.
2030 ;;
2031 ;; First comes the normal case.
2032 (define_expand "udivmodsi4_normal"
2033 [(set (match_dup 4) (const_int 0))
2034 (parallel [(set (match_operand:SI 0 "" "")
2035 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2036 (const_int 32))
2037 (zero_extend:DI (match_operand:SI 1 "" "")))
2038 (match_operand:SI 2 "" "")))
2039 (set (match_operand:SI 3 "" "")
2040 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2041 (const_int 32))
2042 (zero_extend:DI (match_dup 1)))
2043 (match_dup 2)))])]
2044 "TARGET_POWER"
2045 "
2046 { operands[4] = gen_reg_rtx (SImode); }")
2047
2048 ;; This handles the branches.
2049 (define_expand "udivmodsi4_tests"
2050 [(set (match_operand:SI 0 "" "") (const_int 0))
2051 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2052 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2053 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2054 (label_ref (match_operand:SI 4 "" "")) (pc)))
2055 (set (match_dup 0) (const_int 1))
2056 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2057 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2058 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2059 (label_ref (match_dup 4)) (pc)))]
2060 "TARGET_POWER"
2061 "
2062 { operands[5] = gen_reg_rtx (CCUNSmode);
2063 operands[6] = gen_reg_rtx (CCmode);
2064 }")
2065
2066 (define_expand "udivmodsi4"
2067 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2068 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2069 (match_operand:SI 2 "reg_or_cint_operand" "")))
2070 (set (match_operand:SI 3 "gpc_reg_operand" "")
2071 (umod:SI (match_dup 1) (match_dup 2)))])]
2072 ""
2073 "
2074 {
2075 rtx label = 0;
2076
2077 if (! TARGET_POWER)
2078 {
2079 if (! TARGET_POWERPC)
2080 {
2081 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2082 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2083 emit_insn (gen_divus_call ());
2084 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2085 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2086 DONE;
2087 }
2088 else
2089 FAIL;
2090 }
2091
2092 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2093 {
2094 operands[2] = force_reg (SImode, operands[2]);
2095 label = gen_label_rtx ();
2096 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2097 operands[3], label));
2098 }
2099 else
2100 operands[2] = force_reg (SImode, operands[2]);
2101
2102 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2103 operands[3]));
2104 if (label)
2105 emit_label (label);
2106
2107 DONE;
2108 }")
2109
2110 ;; AIX architecture-independent common-mode multiply (DImode),
2111 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2112 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2113 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2114 ;; assumed unused if generating common-mode, so ignore.
2115 (define_insn "mulh_call"
2116 [(set (reg:SI 3)
2117 (truncate:SI
2118 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2119 (sign_extend:DI (reg:SI 4)))
2120 (const_int 32))))
2121 (clobber (match_scratch:SI 0 "=l"))]
2122 "! TARGET_POWER && ! TARGET_POWERPC"
2123 "bla __mulh"
2124 [(set_attr "type" "imul")])
2125
2126 (define_insn "mull_call"
2127 [(set (reg:DI 3)
2128 (mult:DI (sign_extend:DI (reg:SI 3))
2129 (sign_extend:DI (reg:SI 4))))
2130 (clobber (match_scratch:SI 0 "=l"))
2131 (clobber (reg:SI 0))]
2132 "! TARGET_POWER && ! TARGET_POWERPC"
2133 "bla __mull"
2134 [(set_attr "type" "imul")])
2135
2136 (define_insn "divss_call"
2137 [(set (reg:SI 3)
2138 (div:SI (reg:SI 3) (reg:SI 4)))
2139 (set (reg:SI 4)
2140 (mod:SI (reg:SI 3) (reg:SI 4)))
2141 (clobber (match_scratch:SI 0 "=l"))
2142 (clobber (reg:SI 0))]
2143 "! TARGET_POWER && ! TARGET_POWERPC"
2144 "bla __divss"
2145 [(set_attr "type" "idiv")])
2146
2147 (define_insn "divus_call"
2148 [(set (reg:SI 3)
2149 (udiv:SI (reg:SI 3) (reg:SI 4)))
2150 (set (reg:SI 4)
2151 (umod:SI (reg:SI 3) (reg:SI 4)))
2152 (clobber (match_scratch:SI 0 "=l"))
2153 (clobber (reg:SI 0))
2154 (clobber (match_scratch:CC 1 "=x"))
2155 (clobber (reg:CC 69))]
2156 "! TARGET_POWER && ! TARGET_POWERPC"
2157 "bla __divus"
2158 [(set_attr "type" "idiv")])
2159
2160 (define_insn "quoss_call"
2161 [(set (reg:SI 3)
2162 (div:SI (reg:SI 3) (reg:SI 4)))
2163 (clobber (match_scratch:SI 0 "=l"))]
2164 "! TARGET_POWER && ! TARGET_POWERPC"
2165 "bla __quoss"
2166 [(set_attr "type" "idiv")])
2167
2168 (define_insn "quous_call"
2169 [(set (reg:SI 3)
2170 (udiv:SI (reg:SI 3) (reg:SI 4)))
2171 (clobber (match_scratch:SI 0 "=l"))
2172 (clobber (reg:SI 0))
2173 (clobber (match_scratch:CC 1 "=x"))
2174 (clobber (reg:CC 69))]
2175 "! TARGET_POWER && ! TARGET_POWERPC"
2176 "bla __quous"
2177 [(set_attr "type" "idiv")])
2178 \f
2179 ;; Logical instructions
2180 ;; The logical instructions are mostly combined by using match_operator,
2181 ;; but the plain AND insns are somewhat different because there is no
2182 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2183 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2184
2185 (define_insn "andsi3"
2186 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2187 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2188 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2189 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2190 ""
2191 "@
2192 and %0,%1,%2
2193 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2194 {andil.|andi.} %0,%1,%b2
2195 {andiu.|andis.} %0,%1,%u2"
2196 [(set_attr "type" "*,*,compare,compare")])
2197
2198 ;; Note to set cr's other than cr0 we do the and immediate and then
2199 ;; the test again -- this avoids a mfcr which on the higher end
2200 ;; machines causes an execution serialization
2201
2202 (define_insn "*andsi3_internal2"
2203 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2204 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2205 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2206 (const_int 0)))
2207 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2208 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2209 "TARGET_32BIT"
2210 "@
2211 and. %3,%1,%2
2212 {andil.|andi.} %3,%1,%b2
2213 {andiu.|andis.} %3,%1,%u2
2214 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2215 #
2216 #
2217 #
2218 #"
2219 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2220 (set_attr "length" "4,4,4,4,8,8,8,8")])
2221
2222 (define_insn "*andsi3_internal3"
2223 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2224 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2225 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2226 (const_int 0)))
2227 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2228 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2229 "TARGET_64BIT"
2230 "@
2231 #
2232 {andil.|andi.} %3,%1,%b2
2233 {andiu.|andis.} %3,%1,%u2
2234 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2235 #
2236 #
2237 #
2238 #"
2239 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2240 (set_attr "length" "8,4,4,4,8,8,8,8")])
2241
2242 (define_split
2243 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2244 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2245 (match_operand:GPR 2 "and_operand" ""))
2246 (const_int 0)))
2247 (clobber (match_scratch:GPR 3 ""))
2248 (clobber (match_scratch:CC 4 ""))]
2249 "reload_completed"
2250 [(parallel [(set (match_dup 3)
2251 (and:<MODE> (match_dup 1)
2252 (match_dup 2)))
2253 (clobber (match_dup 4))])
2254 (set (match_dup 0)
2255 (compare:CC (match_dup 3)
2256 (const_int 0)))]
2257 "")
2258
2259 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2260 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2261
2262 (define_split
2263 [(set (match_operand:CC 0 "cc_reg_operand" "")
2264 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2265 (match_operand:SI 2 "gpc_reg_operand" ""))
2266 (const_int 0)))
2267 (clobber (match_scratch:SI 3 ""))
2268 (clobber (match_scratch:CC 4 ""))]
2269 "TARGET_POWERPC64 && reload_completed"
2270 [(parallel [(set (match_dup 3)
2271 (and:SI (match_dup 1)
2272 (match_dup 2)))
2273 (clobber (match_dup 4))])
2274 (set (match_dup 0)
2275 (compare:CC (match_dup 3)
2276 (const_int 0)))]
2277 "")
2278
2279 (define_insn "*andsi3_internal4"
2280 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2281 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2282 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2283 (const_int 0)))
2284 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2285 (and:SI (match_dup 1)
2286 (match_dup 2)))
2287 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2288 "TARGET_32BIT"
2289 "@
2290 and. %0,%1,%2
2291 {andil.|andi.} %0,%1,%b2
2292 {andiu.|andis.} %0,%1,%u2
2293 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2294 #
2295 #
2296 #
2297 #"
2298 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2299 (set_attr "length" "4,4,4,4,8,8,8,8")])
2300
2301 (define_insn "*andsi3_internal5"
2302 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2303 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2304 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2305 (const_int 0)))
2306 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2307 (and:SI (match_dup 1)
2308 (match_dup 2)))
2309 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2310 "TARGET_64BIT"
2311 "@
2312 #
2313 {andil.|andi.} %0,%1,%b2
2314 {andiu.|andis.} %0,%1,%u2
2315 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2316 #
2317 #
2318 #
2319 #"
2320 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2321 (set_attr "length" "8,4,4,4,8,8,8,8")])
2322
2323 (define_split
2324 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2325 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2326 (match_operand:SI 2 "and_operand" ""))
2327 (const_int 0)))
2328 (set (match_operand:SI 0 "gpc_reg_operand" "")
2329 (and:SI (match_dup 1)
2330 (match_dup 2)))
2331 (clobber (match_scratch:CC 4 ""))]
2332 "reload_completed"
2333 [(parallel [(set (match_dup 0)
2334 (and:SI (match_dup 1)
2335 (match_dup 2)))
2336 (clobber (match_dup 4))])
2337 (set (match_dup 3)
2338 (compare:CC (match_dup 0)
2339 (const_int 0)))]
2340 "")
2341
2342 (define_split
2343 [(set (match_operand:CC 3 "cc_reg_operand" "")
2344 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2345 (match_operand:SI 2 "gpc_reg_operand" ""))
2346 (const_int 0)))
2347 (set (match_operand:SI 0 "gpc_reg_operand" "")
2348 (and:SI (match_dup 1)
2349 (match_dup 2)))
2350 (clobber (match_scratch:CC 4 ""))]
2351 "TARGET_POWERPC64 && reload_completed"
2352 [(parallel [(set (match_dup 0)
2353 (and:SI (match_dup 1)
2354 (match_dup 2)))
2355 (clobber (match_dup 4))])
2356 (set (match_dup 3)
2357 (compare:CC (match_dup 0)
2358 (const_int 0)))]
2359 "")
2360
2361 ;; Handle the PowerPC64 rlwinm corner case
2362
2363 (define_insn_and_split "*andsi3_internal6"
2364 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2365 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2366 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2367 "TARGET_POWERPC64"
2368 "#"
2369 "TARGET_POWERPC64"
2370 [(set (match_dup 0)
2371 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2372 (match_dup 4)))
2373 (set (match_dup 0)
2374 (rotate:SI (match_dup 0) (match_dup 5)))]
2375 "
2376 {
2377 int mb = extract_MB (operands[2]);
2378 int me = extract_ME (operands[2]);
2379 operands[3] = GEN_INT (me + 1);
2380 operands[5] = GEN_INT (32 - (me + 1));
2381 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2382 }"
2383 [(set_attr "length" "8")])
2384
2385 (define_expand "iorsi3"
2386 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2387 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
2388 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2389 ""
2390 "
2391 {
2392 if (GET_CODE (operands[2]) == CONST_INT
2393 && ! logical_operand (operands[2], SImode))
2394 {
2395 HOST_WIDE_INT value = INTVAL (operands[2]);
2396 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2397 ? operands[0] : gen_reg_rtx (SImode));
2398
2399 emit_insn (gen_iorsi3 (tmp, operands[1],
2400 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2401 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2402 DONE;
2403 }
2404 }")
2405
2406 (define_expand "xorsi3"
2407 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2408 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2409 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2410 ""
2411 "
2412 {
2413 if (GET_CODE (operands[2]) == CONST_INT
2414 && ! logical_operand (operands[2], SImode))
2415 {
2416 HOST_WIDE_INT value = INTVAL (operands[2]);
2417 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2418 ? operands[0] : gen_reg_rtx (SImode));
2419
2420 emit_insn (gen_xorsi3 (tmp, operands[1],
2421 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2422 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2423 DONE;
2424 }
2425 }")
2426
2427 (define_insn "*boolsi3_internal1"
2428 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2429 (match_operator:SI 3 "boolean_or_operator"
2430 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
2431 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
2432 ""
2433 "@
2434 %q3 %0,%1,%2
2435 {%q3il|%q3i} %0,%1,%b2
2436 {%q3iu|%q3is} %0,%1,%u2")
2437
2438 (define_insn "*boolsi3_internal2"
2439 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2440 (compare:CC (match_operator:SI 4 "boolean_or_operator"
2441 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2442 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2443 (const_int 0)))
2444 (clobber (match_scratch:SI 3 "=r,r"))]
2445 "TARGET_32BIT"
2446 "@
2447 %q4. %3,%1,%2
2448 #"
2449 [(set_attr "type" "compare")
2450 (set_attr "length" "4,8")])
2451
2452 (define_split
2453 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2454 (compare:CC (match_operator:SI 4 "boolean_operator"
2455 [(match_operand:SI 1 "gpc_reg_operand" "")
2456 (match_operand:SI 2 "gpc_reg_operand" "")])
2457 (const_int 0)))
2458 (clobber (match_scratch:SI 3 ""))]
2459 "TARGET_32BIT && reload_completed"
2460 [(set (match_dup 3) (match_dup 4))
2461 (set (match_dup 0)
2462 (compare:CC (match_dup 3)
2463 (const_int 0)))]
2464 "")
2465
2466 (define_insn "*boolsi3_internal3"
2467 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2468 (compare:CC (match_operator:SI 4 "boolean_operator"
2469 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2470 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2471 (const_int 0)))
2472 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2473 (match_dup 4))]
2474 "TARGET_32BIT"
2475 "@
2476 %q4. %0,%1,%2
2477 #"
2478 [(set_attr "type" "compare")
2479 (set_attr "length" "4,8")])
2480
2481 (define_split
2482 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2483 (compare:CC (match_operator:SI 4 "boolean_operator"
2484 [(match_operand:SI 1 "gpc_reg_operand" "")
2485 (match_operand:SI 2 "gpc_reg_operand" "")])
2486 (const_int 0)))
2487 (set (match_operand:SI 0 "gpc_reg_operand" "")
2488 (match_dup 4))]
2489 "TARGET_32BIT && reload_completed"
2490 [(set (match_dup 0) (match_dup 4))
2491 (set (match_dup 3)
2492 (compare:CC (match_dup 0)
2493 (const_int 0)))]
2494 "")
2495
2496 ;; Split a logical operation that we can't do in one insn into two insns,
2497 ;; each of which does one 16-bit part. This is used by combine.
2498
2499 (define_split
2500 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2501 (match_operator:SI 3 "boolean_or_operator"
2502 [(match_operand:SI 1 "gpc_reg_operand" "")
2503 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
2504 ""
2505 [(set (match_dup 0) (match_dup 4))
2506 (set (match_dup 0) (match_dup 5))]
2507 "
2508 {
2509 rtx i;
2510 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
2511 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
2512 operands[1], i);
2513 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
2514 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
2515 operands[0], i);
2516 }")
2517
2518 (define_insn "*boolcsi3_internal1"
2519 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2520 (match_operator:SI 3 "boolean_operator"
2521 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
2522 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
2523 ""
2524 "%q3 %0,%2,%1")
2525
2526 (define_insn "*boolcsi3_internal2"
2527 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2528 (compare:CC (match_operator:SI 4 "boolean_operator"
2529 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2530 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2531 (const_int 0)))
2532 (clobber (match_scratch:SI 3 "=r,r"))]
2533 "TARGET_32BIT"
2534 "@
2535 %q4. %3,%2,%1
2536 #"
2537 [(set_attr "type" "compare")
2538 (set_attr "length" "4,8")])
2539
2540 (define_split
2541 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2542 (compare:CC (match_operator:SI 4 "boolean_operator"
2543 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2544 (match_operand:SI 2 "gpc_reg_operand" "")])
2545 (const_int 0)))
2546 (clobber (match_scratch:SI 3 ""))]
2547 "TARGET_32BIT && reload_completed"
2548 [(set (match_dup 3) (match_dup 4))
2549 (set (match_dup 0)
2550 (compare:CC (match_dup 3)
2551 (const_int 0)))]
2552 "")
2553
2554 (define_insn "*boolcsi3_internal3"
2555 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2556 (compare:CC (match_operator:SI 4 "boolean_operator"
2557 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
2558 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2559 (const_int 0)))
2560 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2561 (match_dup 4))]
2562 "TARGET_32BIT"
2563 "@
2564 %q4. %0,%2,%1
2565 #"
2566 [(set_attr "type" "compare")
2567 (set_attr "length" "4,8")])
2568
2569 (define_split
2570 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2571 (compare:CC (match_operator:SI 4 "boolean_operator"
2572 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2573 (match_operand:SI 2 "gpc_reg_operand" "")])
2574 (const_int 0)))
2575 (set (match_operand:SI 0 "gpc_reg_operand" "")
2576 (match_dup 4))]
2577 "TARGET_32BIT && reload_completed"
2578 [(set (match_dup 0) (match_dup 4))
2579 (set (match_dup 3)
2580 (compare:CC (match_dup 0)
2581 (const_int 0)))]
2582 "")
2583
2584 (define_insn "*boolccsi3_internal1"
2585 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2586 (match_operator:SI 3 "boolean_operator"
2587 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
2588 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
2589 ""
2590 "%q3 %0,%1,%2")
2591
2592 (define_insn "*boolccsi3_internal2"
2593 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2594 (compare:CC (match_operator:SI 4 "boolean_operator"
2595 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2596 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
2597 (const_int 0)))
2598 (clobber (match_scratch:SI 3 "=r,r"))]
2599 "TARGET_32BIT"
2600 "@
2601 %q4. %3,%1,%2
2602 #"
2603 [(set_attr "type" "compare")
2604 (set_attr "length" "4,8")])
2605
2606 (define_split
2607 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2608 (compare:CC (match_operator:SI 4 "boolean_operator"
2609 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2610 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
2611 (const_int 0)))
2612 (clobber (match_scratch:SI 3 ""))]
2613 "TARGET_32BIT && reload_completed"
2614 [(set (match_dup 3) (match_dup 4))
2615 (set (match_dup 0)
2616 (compare:CC (match_dup 3)
2617 (const_int 0)))]
2618 "")
2619
2620 (define_insn "*boolccsi3_internal3"
2621 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2622 (compare:CC (match_operator:SI 4 "boolean_operator"
2623 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
2624 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
2625 (const_int 0)))
2626 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2627 (match_dup 4))]
2628 "TARGET_32BIT"
2629 "@
2630 %q4. %0,%1,%2
2631 #"
2632 [(set_attr "type" "compare")
2633 (set_attr "length" "4,8")])
2634
2635 (define_split
2636 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2637 (compare:CC (match_operator:SI 4 "boolean_operator"
2638 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2639 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
2640 (const_int 0)))
2641 (set (match_operand:SI 0 "gpc_reg_operand" "")
2642 (match_dup 4))]
2643 "TARGET_32BIT && reload_completed"
2644 [(set (match_dup 0) (match_dup 4))
2645 (set (match_dup 3)
2646 (compare:CC (match_dup 0)
2647 (const_int 0)))]
2648 "")
2649
2650 ;; maskir insn. We need four forms because things might be in arbitrary
2651 ;; orders. Don't define forms that only set CR fields because these
2652 ;; would modify an input register.
2653
2654 (define_insn "*maskir_internal1"
2655 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2656 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2657 (match_operand:SI 1 "gpc_reg_operand" "0"))
2658 (and:SI (match_dup 2)
2659 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
2660 "TARGET_POWER"
2661 "maskir %0,%3,%2")
2662
2663 (define_insn "*maskir_internal2"
2664 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2665 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2666 (match_operand:SI 1 "gpc_reg_operand" "0"))
2667 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2668 (match_dup 2))))]
2669 "TARGET_POWER"
2670 "maskir %0,%3,%2")
2671
2672 (define_insn "*maskir_internal3"
2673 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2674 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2675 (match_operand:SI 3 "gpc_reg_operand" "r"))
2676 (and:SI (not:SI (match_dup 2))
2677 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
2678 "TARGET_POWER"
2679 "maskir %0,%3,%2")
2680
2681 (define_insn "*maskir_internal4"
2682 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2683 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2684 (match_operand:SI 2 "gpc_reg_operand" "r"))
2685 (and:SI (not:SI (match_dup 2))
2686 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
2687 "TARGET_POWER"
2688 "maskir %0,%3,%2")
2689
2690 (define_insn "*maskir_internal5"
2691 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2692 (compare:CC
2693 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2694 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
2695 (and:SI (match_dup 2)
2696 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
2697 (const_int 0)))
2698 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2699 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2700 (and:SI (match_dup 2) (match_dup 3))))]
2701 "TARGET_POWER"
2702 "@
2703 maskir. %0,%3,%2
2704 #"
2705 [(set_attr "type" "compare")
2706 (set_attr "length" "4,8")])
2707
2708 (define_split
2709 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2710 (compare:CC
2711 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
2712 (match_operand:SI 1 "gpc_reg_operand" ""))
2713 (and:SI (match_dup 2)
2714 (match_operand:SI 3 "gpc_reg_operand" "")))
2715 (const_int 0)))
2716 (set (match_operand:SI 0 "gpc_reg_operand" "")
2717 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2718 (and:SI (match_dup 2) (match_dup 3))))]
2719 "TARGET_POWER && reload_completed"
2720 [(set (match_dup 0)
2721 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2722 (and:SI (match_dup 2) (match_dup 3))))
2723 (set (match_dup 4)
2724 (compare:CC (match_dup 0)
2725 (const_int 0)))]
2726 "")
2727
2728 (define_insn "*maskir_internal6"
2729 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2730 (compare:CC
2731 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2732 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
2733 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
2734 (match_dup 2)))
2735 (const_int 0)))
2736 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2737 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2738 (and:SI (match_dup 3) (match_dup 2))))]
2739 "TARGET_POWER"
2740 "@
2741 maskir. %0,%3,%2
2742 #"
2743 [(set_attr "type" "compare")
2744 (set_attr "length" "4,8")])
2745
2746 (define_split
2747 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2748 (compare:CC
2749 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
2750 (match_operand:SI 1 "gpc_reg_operand" ""))
2751 (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
2752 (match_dup 2)))
2753 (const_int 0)))
2754 (set (match_operand:SI 0 "gpc_reg_operand" "")
2755 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2756 (and:SI (match_dup 3) (match_dup 2))))]
2757 "TARGET_POWER && reload_completed"
2758 [(set (match_dup 0)
2759 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2760 (and:SI (match_dup 3) (match_dup 2))))
2761 (set (match_dup 4)
2762 (compare:CC (match_dup 0)
2763 (const_int 0)))]
2764 "")
2765
2766 (define_insn "*maskir_internal7"
2767 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2768 (compare:CC
2769 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
2770 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
2771 (and:SI (not:SI (match_dup 2))
2772 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
2773 (const_int 0)))
2774 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2775 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2776 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2777 "TARGET_POWER"
2778 "@
2779 maskir. %0,%3,%2
2780 #"
2781 [(set_attr "type" "compare")
2782 (set_attr "length" "4,8")])
2783
2784 (define_split
2785 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2786 (compare:CC
2787 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
2788 (match_operand:SI 3 "gpc_reg_operand" ""))
2789 (and:SI (not:SI (match_dup 2))
2790 (match_operand:SI 1 "gpc_reg_operand" "")))
2791 (const_int 0)))
2792 (set (match_operand:SI 0 "gpc_reg_operand" "")
2793 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2794 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2795 "TARGET_POWER && reload_completed"
2796 [(set (match_dup 0)
2797 (ior:SI (and:SI (match_dup 2) (match_dup 3))
2798 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
2799 (set (match_dup 4)
2800 (compare:CC (match_dup 0)
2801 (const_int 0)))]
2802 "")
2803
2804 (define_insn "*maskir_internal8"
2805 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2806 (compare:CC
2807 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
2808 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2809 (and:SI (not:SI (match_dup 2))
2810 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
2811 (const_int 0)))
2812 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2813 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2814 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2815 "TARGET_POWER"
2816 "@
2817 maskir. %0,%3,%2
2818 #"
2819 [(set_attr "type" "compare")
2820 (set_attr "length" "4,8")])
2821
2822 (define_split
2823 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2824 (compare:CC
2825 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
2826 (match_operand:SI 2 "gpc_reg_operand" ""))
2827 (and:SI (not:SI (match_dup 2))
2828 (match_operand:SI 1 "gpc_reg_operand" "")))
2829 (const_int 0)))
2830 (set (match_operand:SI 0 "gpc_reg_operand" "")
2831 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2832 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2833 "TARGET_POWER && reload_completed"
2834 [(set (match_dup 0)
2835 (ior:SI (and:SI (match_dup 3) (match_dup 2))
2836 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
2837 (set (match_dup 4)
2838 (compare:CC (match_dup 0)
2839 (const_int 0)))]
2840 "")
2841 \f
2842 ;; Rotate and shift insns, in all their variants. These support shifts,
2843 ;; field inserts and extracts, and various combinations thereof.
2844 (define_expand "insv"
2845 [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
2846 (match_operand:SI 1 "const_int_operand" "")
2847 (match_operand:SI 2 "const_int_operand" ""))
2848 (match_operand 3 "gpc_reg_operand" ""))]
2849 ""
2850 "
2851 {
2852 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
2853 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
2854 compiler if the address of the structure is taken later. */
2855 if (GET_CODE (operands[0]) == SUBREG
2856 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
2857 FAIL;
2858
2859 if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
2860 emit_insn (gen_insvdi (operands[0], operands[1], operands[2], operands[3]));
2861 else
2862 emit_insn (gen_insvsi (operands[0], operands[1], operands[2], operands[3]));
2863 DONE;
2864 }")
2865
2866 (define_insn "insvsi"
2867 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2868 (match_operand:SI 1 "const_int_operand" "i")
2869 (match_operand:SI 2 "const_int_operand" "i"))
2870 (match_operand:SI 3 "gpc_reg_operand" "r"))]
2871 ""
2872 "*
2873 {
2874 int start = INTVAL (operands[2]) & 31;
2875 int size = INTVAL (operands[1]) & 31;
2876
2877 operands[4] = GEN_INT (32 - start - size);
2878 operands[1] = GEN_INT (start + size - 1);
2879 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2880 }"
2881 [(set_attr "type" "insert_word")])
2882
2883 (define_insn "*insvsi_internal1"
2884 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2885 (match_operand:SI 1 "const_int_operand" "i")
2886 (match_operand:SI 2 "const_int_operand" "i"))
2887 (rotate:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2888 (match_operand:SI 4 "const_int_operand" "i")))]
2889 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
2890 "*
2891 {
2892 int shift = INTVAL (operands[4]) & 31;
2893 int start = INTVAL (operands[2]) & 31;
2894 int size = INTVAL (operands[1]) & 31;
2895
2896 operands[4] = GEN_INT (shift - start - size);
2897 operands[1] = GEN_INT (start + size - 1);
2898 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2899 }"
2900 [(set_attr "type" "insert_word")])
2901
2902 (define_insn "*insvsi_internal2"
2903 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2904 (match_operand:SI 1 "const_int_operand" "i")
2905 (match_operand:SI 2 "const_int_operand" "i"))
2906 (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2907 (match_operand:SI 4 "const_int_operand" "i")))]
2908 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
2909 "*
2910 {
2911 int shift = INTVAL (operands[4]) & 31;
2912 int start = INTVAL (operands[2]) & 31;
2913 int size = INTVAL (operands[1]) & 31;
2914
2915 operands[4] = GEN_INT (32 - shift - start - size);
2916 operands[1] = GEN_INT (start + size - 1);
2917 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2918 }"
2919 [(set_attr "type" "insert_word")])
2920
2921 (define_insn "*insvsi_internal3"
2922 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2923 (match_operand:SI 1 "const_int_operand" "i")
2924 (match_operand:SI 2 "const_int_operand" "i"))
2925 (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2926 (match_operand:SI 4 "const_int_operand" "i")))]
2927 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
2928 "*
2929 {
2930 int shift = INTVAL (operands[4]) & 31;
2931 int start = INTVAL (operands[2]) & 31;
2932 int size = INTVAL (operands[1]) & 31;
2933
2934 operands[4] = GEN_INT (32 - shift - start - size);
2935 operands[1] = GEN_INT (start + size - 1);
2936 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2937 }"
2938 [(set_attr "type" "insert_word")])
2939
2940 (define_insn "*insvsi_internal4"
2941 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2942 (match_operand:SI 1 "const_int_operand" "i")
2943 (match_operand:SI 2 "const_int_operand" "i"))
2944 (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2945 (match_operand:SI 4 "const_int_operand" "i")
2946 (match_operand:SI 5 "const_int_operand" "i")))]
2947 "INTVAL (operands[4]) >= INTVAL (operands[1])"
2948 "*
2949 {
2950 int extract_start = INTVAL (operands[5]) & 31;
2951 int extract_size = INTVAL (operands[4]) & 31;
2952 int insert_start = INTVAL (operands[2]) & 31;
2953 int insert_size = INTVAL (operands[1]) & 31;
2954
2955 /* Align extract field with insert field */
2956 operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
2957 operands[1] = GEN_INT (insert_start + insert_size - 1);
2958 return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
2959 }"
2960 [(set_attr "type" "insert_word")])
2961
2962 ;; combine patterns for rlwimi
2963 (define_insn "*insvsi_internal5"
2964 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2965 (ior:SI (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
2966 (match_operand:SI 1 "mask_operand" "i"))
2967 (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2968 (match_operand:SI 2 "const_int_operand" "i"))
2969 (match_operand:SI 5 "mask_operand" "i"))))]
2970 "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
2971 "*
2972 {
2973 int me = extract_ME(operands[5]);
2974 int mb = extract_MB(operands[5]);
2975 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
2976 operands[2] = GEN_INT(mb);
2977 operands[1] = GEN_INT(me);
2978 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2979 }"
2980 [(set_attr "type" "insert_word")])
2981
2982 (define_insn "*insvsi_internal6"
2983 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2984 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2985 (match_operand:SI 2 "const_int_operand" "i"))
2986 (match_operand:SI 5 "mask_operand" "i"))
2987 (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
2988 (match_operand:SI 1 "mask_operand" "i"))))]
2989 "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
2990 "*
2991 {
2992 int me = extract_ME(operands[5]);
2993 int mb = extract_MB(operands[5]);
2994 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
2995 operands[2] = GEN_INT(mb);
2996 operands[1] = GEN_INT(me);
2997 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2998 }"
2999 [(set_attr "type" "insert_word")])
3000
3001 (define_insn "insvdi"
3002 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3003 (match_operand:SI 1 "const_int_operand" "i")
3004 (match_operand:SI 2 "const_int_operand" "i"))
3005 (match_operand:DI 3 "gpc_reg_operand" "r"))]
3006 "TARGET_POWERPC64"
3007 "*
3008 {
3009 int start = INTVAL (operands[2]) & 63;
3010 int size = INTVAL (operands[1]) & 63;
3011
3012 operands[1] = GEN_INT (64 - start - size);
3013 return \"rldimi %0,%3,%H1,%H2\";
3014 }")
3015
3016 (define_insn "*insvdi_internal2"
3017 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3018 (match_operand:SI 1 "const_int_operand" "i")
3019 (match_operand:SI 2 "const_int_operand" "i"))
3020 (ashiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3021 (match_operand:SI 4 "const_int_operand" "i")))]
3022 "TARGET_POWERPC64
3023 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3024 "*
3025 {
3026 int shift = INTVAL (operands[4]) & 63;
3027 int start = (INTVAL (operands[2]) & 63) - 32;
3028 int size = INTVAL (operands[1]) & 63;
3029
3030 operands[4] = GEN_INT (64 - shift - start - size);
3031 operands[2] = GEN_INT (start);
3032 operands[1] = GEN_INT (start + size - 1);
3033 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3034 }")
3035
3036 (define_insn "*insvdi_internal3"
3037 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3038 (match_operand:SI 1 "const_int_operand" "i")
3039 (match_operand:SI 2 "const_int_operand" "i"))
3040 (lshiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3041 (match_operand:SI 4 "const_int_operand" "i")))]
3042 "TARGET_POWERPC64
3043 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3044 "*
3045 {
3046 int shift = INTVAL (operands[4]) & 63;
3047 int start = (INTVAL (operands[2]) & 63) - 32;
3048 int size = INTVAL (operands[1]) & 63;
3049
3050 operands[4] = GEN_INT (64 - shift - start - size);
3051 operands[2] = GEN_INT (start);
3052 operands[1] = GEN_INT (start + size - 1);
3053 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3054 }")
3055
3056 (define_expand "extzv"
3057 [(set (match_operand 0 "gpc_reg_operand" "")
3058 (zero_extract (match_operand 1 "gpc_reg_operand" "")
3059 (match_operand:SI 2 "const_int_operand" "")
3060 (match_operand:SI 3 "const_int_operand" "")))]
3061 ""
3062 "
3063 {
3064 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3065 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3066 compiler if the address of the structure is taken later. */
3067 if (GET_CODE (operands[0]) == SUBREG
3068 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3069 FAIL;
3070
3071 if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3072 emit_insn (gen_extzvdi (operands[0], operands[1], operands[2], operands[3]));
3073 else
3074 emit_insn (gen_extzvsi (operands[0], operands[1], operands[2], operands[3]));
3075 DONE;
3076 }")
3077
3078 (define_insn "extzvsi"
3079 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3080 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3081 (match_operand:SI 2 "const_int_operand" "i")
3082 (match_operand:SI 3 "const_int_operand" "i")))]
3083 ""
3084 "*
3085 {
3086 int start = INTVAL (operands[3]) & 31;
3087 int size = INTVAL (operands[2]) & 31;
3088
3089 if (start + size >= 32)
3090 operands[3] = const0_rtx;
3091 else
3092 operands[3] = GEN_INT (start + size);
3093 return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
3094 }")
3095
3096 (define_insn "*extzvsi_internal1"
3097 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3098 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3099 (match_operand:SI 2 "const_int_operand" "i,i")
3100 (match_operand:SI 3 "const_int_operand" "i,i"))
3101 (const_int 0)))
3102 (clobber (match_scratch:SI 4 "=r,r"))]
3103 ""
3104 "*
3105 {
3106 int start = INTVAL (operands[3]) & 31;
3107 int size = INTVAL (operands[2]) & 31;
3108
3109 /* Force split for non-cc0 compare. */
3110 if (which_alternative == 1)
3111 return \"#\";
3112
3113 /* If the bit-field being tested fits in the upper or lower half of a
3114 word, it is possible to use andiu. or andil. to test it. This is
3115 useful because the condition register set-use delay is smaller for
3116 andi[ul]. than for rlinm. This doesn't work when the starting bit
3117 position is 0 because the LT and GT bits may be set wrong. */
3118
3119 if ((start > 0 && start + size <= 16) || start >= 16)
3120 {
3121 operands[3] = GEN_INT (((1 << (16 - (start & 15)))
3122 - (1 << (16 - (start & 15) - size))));
3123 if (start < 16)
3124 return \"{andiu.|andis.} %4,%1,%3\";
3125 else
3126 return \"{andil.|andi.} %4,%1,%3\";
3127 }
3128
3129 if (start + size >= 32)
3130 operands[3] = const0_rtx;
3131 else
3132 operands[3] = GEN_INT (start + size);
3133 return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
3134 }"
3135 [(set_attr "type" "compare")
3136 (set_attr "length" "4,8")])
3137
3138 (define_split
3139 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3140 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3141 (match_operand:SI 2 "const_int_operand" "")
3142 (match_operand:SI 3 "const_int_operand" ""))
3143 (const_int 0)))
3144 (clobber (match_scratch:SI 4 ""))]
3145 "reload_completed"
3146 [(set (match_dup 4)
3147 (zero_extract:SI (match_dup 1) (match_dup 2)
3148 (match_dup 3)))
3149 (set (match_dup 0)
3150 (compare:CC (match_dup 4)
3151 (const_int 0)))]
3152 "")
3153
3154 (define_insn "*extzvsi_internal2"
3155 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3156 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3157 (match_operand:SI 2 "const_int_operand" "i,i")
3158 (match_operand:SI 3 "const_int_operand" "i,i"))
3159 (const_int 0)))
3160 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3161 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3162 ""
3163 "*
3164 {
3165 int start = INTVAL (operands[3]) & 31;
3166 int size = INTVAL (operands[2]) & 31;
3167
3168 /* Force split for non-cc0 compare. */
3169 if (which_alternative == 1)
3170 return \"#\";
3171
3172 /* Since we are using the output value, we can't ignore any need for
3173 a shift. The bit-field must end at the LSB. */
3174 if (start >= 16 && start + size == 32)
3175 {
3176 operands[3] = GEN_INT ((1 << size) - 1);
3177 return \"{andil.|andi.} %0,%1,%3\";
3178 }
3179
3180 if (start + size >= 32)
3181 operands[3] = const0_rtx;
3182 else
3183 operands[3] = GEN_INT (start + size);
3184 return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
3185 }"
3186 [(set_attr "type" "compare")
3187 (set_attr "length" "4,8")])
3188
3189 (define_split
3190 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3191 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3192 (match_operand:SI 2 "const_int_operand" "")
3193 (match_operand:SI 3 "const_int_operand" ""))
3194 (const_int 0)))
3195 (set (match_operand:SI 0 "gpc_reg_operand" "")
3196 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3197 "reload_completed"
3198 [(set (match_dup 0)
3199 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3200 (set (match_dup 4)
3201 (compare:CC (match_dup 0)
3202 (const_int 0)))]
3203 "")
3204
3205 (define_insn "extzvdi"
3206 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3207 (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3208 (match_operand:SI 2 "const_int_operand" "i")
3209 (match_operand:SI 3 "const_int_operand" "i")))]
3210 "TARGET_POWERPC64"
3211 "*
3212 {
3213 int start = INTVAL (operands[3]) & 63;
3214 int size = INTVAL (operands[2]) & 63;
3215
3216 if (start + size >= 64)
3217 operands[3] = const0_rtx;
3218 else
3219 operands[3] = GEN_INT (start + size);
3220 operands[2] = GEN_INT (64 - size);
3221 return \"rldicl %0,%1,%3,%2\";
3222 }")
3223
3224 (define_insn "*extzvdi_internal1"
3225 [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3226 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3227 (match_operand:SI 2 "const_int_operand" "i")
3228 (match_operand:SI 3 "const_int_operand" "i"))
3229 (const_int 0)))
3230 (clobber (match_scratch:DI 4 "=r"))]
3231 "TARGET_64BIT"
3232 "*
3233 {
3234 int start = INTVAL (operands[3]) & 63;
3235 int size = INTVAL (operands[2]) & 63;
3236
3237 if (start + size >= 64)
3238 operands[3] = const0_rtx;
3239 else
3240 operands[3] = GEN_INT (start + size);
3241 operands[2] = GEN_INT (64 - size);
3242 return \"rldicl. %4,%1,%3,%2\";
3243 }"
3244 [(set_attr "type" "compare")])
3245
3246 (define_insn "*extzvdi_internal2"
3247 [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3248 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3249 (match_operand:SI 2 "const_int_operand" "i")
3250 (match_operand:SI 3 "const_int_operand" "i"))
3251 (const_int 0)))
3252 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
3253 (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
3254 "TARGET_64BIT"
3255 "*
3256 {
3257 int start = INTVAL (operands[3]) & 63;
3258 int size = INTVAL (operands[2]) & 63;
3259
3260 if (start + size >= 64)
3261 operands[3] = const0_rtx;
3262 else
3263 operands[3] = GEN_INT (start + size);
3264 operands[2] = GEN_INT (64 - size);
3265 return \"rldicl. %0,%1,%3,%2\";
3266 }"
3267 [(set_attr "type" "compare")])
3268
3269 (define_insn "rotlsi3"
3270 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3271 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3272 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
3273 ""
3274 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffffffff")
3275
3276 (define_insn "*rotlsi3_internal2"
3277 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3278 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3279 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3280 (const_int 0)))
3281 (clobber (match_scratch:SI 3 "=r,r"))]
3282 ""
3283 "@
3284 {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffffffff
3285 #"
3286 [(set_attr "type" "delayed_compare")
3287 (set_attr "length" "4,8")])
3288
3289 (define_split
3290 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3291 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3292 (match_operand:SI 2 "reg_or_cint_operand" ""))
3293 (const_int 0)))
3294 (clobber (match_scratch:SI 3 ""))]
3295 "reload_completed"
3296 [(set (match_dup 3)
3297 (rotate:SI (match_dup 1) (match_dup 2)))
3298 (set (match_dup 0)
3299 (compare:CC (match_dup 3)
3300 (const_int 0)))]
3301 "")
3302
3303 (define_insn "*rotlsi3_internal3"
3304 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3305 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3306 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3307 (const_int 0)))
3308 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3309 (rotate:SI (match_dup 1) (match_dup 2)))]
3310 ""
3311 "@
3312 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffffffff
3313 #"
3314 [(set_attr "type" "delayed_compare")
3315 (set_attr "length" "4,8")])
3316
3317 (define_split
3318 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3319 (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3320 (match_operand:SI 2 "reg_or_cint_operand" ""))
3321 (const_int 0)))
3322 (set (match_operand:SI 0 "gpc_reg_operand" "")
3323 (rotate:SI (match_dup 1) (match_dup 2)))]
3324 "reload_completed"
3325 [(set (match_dup 0)
3326 (rotate:SI (match_dup 1) (match_dup 2)))
3327 (set (match_dup 3)
3328 (compare:CC (match_dup 0)
3329 (const_int 0)))]
3330 "")
3331
3332 (define_insn "*rotlsi3_internal4"
3333 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3334 (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3335 (match_operand:SI 2 "reg_or_cint_operand" "ri"))
3336 (match_operand:SI 3 "mask_operand" "n")))]
3337 ""
3338 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,%m3,%M3")
3339
3340 (define_insn "*rotlsi3_internal5"
3341 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3342 (compare:CC (and:SI
3343 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3344 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3345 (match_operand:SI 3 "mask_operand" "n,n"))
3346 (const_int 0)))
3347 (clobber (match_scratch:SI 4 "=r,r"))]
3348 ""
3349 "@
3350 {rl%I2nm.|rlw%I2nm.} %4,%1,%h2,%m3,%M3
3351 #"
3352 [(set_attr "type" "delayed_compare")
3353 (set_attr "length" "4,8")])
3354
3355 (define_split
3356 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3357 (compare:CC (and:SI
3358 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3359 (match_operand:SI 2 "reg_or_cint_operand" ""))
3360 (match_operand:SI 3 "mask_operand" ""))
3361 (const_int 0)))
3362 (clobber (match_scratch:SI 4 ""))]
3363 "reload_completed"
3364 [(set (match_dup 4)
3365 (and:SI (rotate:SI (match_dup 1)
3366 (match_dup 2))
3367 (match_dup 3)))
3368 (set (match_dup 0)
3369 (compare:CC (match_dup 4)
3370 (const_int 0)))]
3371 "")
3372
3373 (define_insn "*rotlsi3_internal6"
3374 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3375 (compare:CC (and:SI
3376 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3377 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3378 (match_operand:SI 3 "mask_operand" "n,n"))
3379 (const_int 0)))
3380 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3381 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3382 ""
3383 "@
3384 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,%m3,%M3
3385 #"
3386 [(set_attr "type" "delayed_compare")
3387 (set_attr "length" "4,8")])
3388
3389 (define_split
3390 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3391 (compare:CC (and:SI
3392 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3393 (match_operand:SI 2 "reg_or_cint_operand" ""))
3394 (match_operand:SI 3 "mask_operand" ""))
3395 (const_int 0)))
3396 (set (match_operand:SI 0 "gpc_reg_operand" "")
3397 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3398 "reload_completed"
3399 [(set (match_dup 0)
3400 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3401 (set (match_dup 4)
3402 (compare:CC (match_dup 0)
3403 (const_int 0)))]
3404 "")
3405
3406 (define_insn "*rotlsi3_internal7"
3407 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3408 (zero_extend:SI
3409 (subreg:QI
3410 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3411 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3412 ""
3413 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
3414
3415 (define_insn "*rotlsi3_internal8"
3416 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3417 (compare:CC (zero_extend:SI
3418 (subreg:QI
3419 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3420 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3421 (const_int 0)))
3422 (clobber (match_scratch:SI 3 "=r,r"))]
3423 ""
3424 "@
3425 {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xff
3426 #"
3427 [(set_attr "type" "delayed_compare")
3428 (set_attr "length" "4,8")])
3429
3430 (define_split
3431 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3432 (compare:CC (zero_extend:SI
3433 (subreg:QI
3434 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3435 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3436 (const_int 0)))
3437 (clobber (match_scratch:SI 3 ""))]
3438 "reload_completed"
3439 [(set (match_dup 3)
3440 (zero_extend:SI (subreg:QI
3441 (rotate:SI (match_dup 1)
3442 (match_dup 2)) 0)))
3443 (set (match_dup 0)
3444 (compare:CC (match_dup 3)
3445 (const_int 0)))]
3446 "")
3447
3448 (define_insn "*rotlsi3_internal9"
3449 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3450 (compare:CC (zero_extend:SI
3451 (subreg:QI
3452 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3453 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3454 (const_int 0)))
3455 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3456 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3457 ""
3458 "@
3459 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xff
3460 #"
3461 [(set_attr "type" "delayed_compare")
3462 (set_attr "length" "4,8")])
3463
3464 (define_split
3465 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3466 (compare:CC (zero_extend:SI
3467 (subreg:QI
3468 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3469 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3470 (const_int 0)))
3471 (set (match_operand:SI 0 "gpc_reg_operand" "")
3472 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3473 "reload_completed"
3474 [(set (match_dup 0)
3475 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3476 (set (match_dup 3)
3477 (compare:CC (match_dup 0)
3478 (const_int 0)))]
3479 "")
3480
3481 (define_insn "*rotlsi3_internal10"
3482 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3483 (zero_extend:SI
3484 (subreg:HI
3485 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3486 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3487 ""
3488 "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffff")
3489
3490 (define_insn "*rotlsi3_internal11"
3491 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3492 (compare:CC (zero_extend:SI
3493 (subreg:HI
3494 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3495 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3496 (const_int 0)))
3497 (clobber (match_scratch:SI 3 "=r,r"))]
3498 ""
3499 "@
3500 {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffff
3501 #"
3502 [(set_attr "type" "delayed_compare")
3503 (set_attr "length" "4,8")])
3504
3505 (define_split
3506 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3507 (compare:CC (zero_extend:SI
3508 (subreg:HI
3509 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3510 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3511 (const_int 0)))
3512 (clobber (match_scratch:SI 3 ""))]
3513 "reload_completed"
3514 [(set (match_dup 3)
3515 (zero_extend:SI (subreg:HI
3516 (rotate:SI (match_dup 1)
3517 (match_dup 2)) 0)))
3518 (set (match_dup 0)
3519 (compare:CC (match_dup 3)
3520 (const_int 0)))]
3521 "")
3522
3523 (define_insn "*rotlsi3_internal12"
3524 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3525 (compare:CC (zero_extend:SI
3526 (subreg:HI
3527 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3528 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3529 (const_int 0)))
3530 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3531 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3532 ""
3533 "@
3534 {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffff
3535 #"
3536 [(set_attr "type" "delayed_compare")
3537 (set_attr "length" "4,8")])
3538
3539 (define_split
3540 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3541 (compare:CC (zero_extend:SI
3542 (subreg:HI
3543 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3544 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3545 (const_int 0)))
3546 (set (match_operand:SI 0 "gpc_reg_operand" "")
3547 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3548 "reload_completed"
3549 [(set (match_dup 0)
3550 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3551 (set (match_dup 3)
3552 (compare:CC (match_dup 0)
3553 (const_int 0)))]
3554 "")
3555
3556 ;; Note that we use "sle." instead of "sl." so that we can set
3557 ;; SHIFT_COUNT_TRUNCATED.
3558
3559 (define_expand "ashlsi3"
3560 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
3561 (use (match_operand:SI 1 "gpc_reg_operand" ""))
3562 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
3563 ""
3564 "
3565 {
3566 if (TARGET_POWER)
3567 emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
3568 else
3569 emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
3570 DONE;
3571 }")
3572
3573 (define_insn "ashlsi3_power"
3574 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3575 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3576 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
3577 (clobber (match_scratch:SI 3 "=q,X"))]
3578 "TARGET_POWER"
3579 "@
3580 sle %0,%1,%2
3581 {sli|slwi} %0,%1,%h2")
3582
3583 (define_insn "ashlsi3_no_power"
3584 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3585 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3586 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
3587 "! TARGET_POWER"
3588 "{sl|slw}%I2 %0,%1,%h2")
3589
3590 (define_insn ""
3591 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3592 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3593 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
3594 (const_int 0)))
3595 (clobber (match_scratch:SI 3 "=r,r,r,r"))
3596 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
3597 "TARGET_POWER"
3598 "@
3599 sle. %3,%1,%2
3600 {sli.|slwi.} %3,%1,%h2
3601 #
3602 #"
3603 [(set_attr "type" "delayed_compare")
3604 (set_attr "length" "4,4,8,8")])
3605
3606 (define_split
3607 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3608 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3609 (match_operand:SI 2 "reg_or_cint_operand" ""))
3610 (const_int 0)))
3611 (clobber (match_scratch:SI 3 ""))
3612 (clobber (match_scratch:SI 4 ""))]
3613 "TARGET_POWER && reload_completed"
3614 [(parallel [(set (match_dup 3)
3615 (ashift:SI (match_dup 1) (match_dup 2)))
3616 (clobber (match_dup 4))])
3617 (set (match_dup 0)
3618 (compare:CC (match_dup 3)
3619 (const_int 0)))]
3620 "")
3621
3622 (define_insn ""
3623 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3624 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3625 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3626 (const_int 0)))
3627 (clobber (match_scratch:SI 3 "=r,r"))]
3628 "! TARGET_POWER && TARGET_32BIT"
3629 "@
3630 {sl|slw}%I2. %3,%1,%h2
3631 #"
3632 [(set_attr "type" "delayed_compare")
3633 (set_attr "length" "4,8")])
3634
3635 (define_split
3636 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3637 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3638 (match_operand:SI 2 "reg_or_cint_operand" ""))
3639 (const_int 0)))
3640 (clobber (match_scratch:SI 3 ""))]
3641 "! TARGET_POWER && TARGET_32BIT && reload_completed"
3642 [(set (match_dup 3)
3643 (ashift:SI (match_dup 1) (match_dup 2)))
3644 (set (match_dup 0)
3645 (compare:CC (match_dup 3)
3646 (const_int 0)))]
3647 "")
3648
3649 (define_insn ""
3650 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3651 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3652 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
3653 (const_int 0)))
3654 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
3655 (ashift:SI (match_dup 1) (match_dup 2)))
3656 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
3657 "TARGET_POWER"
3658 "@
3659 sle. %0,%1,%2
3660 {sli.|slwi.} %0,%1,%h2
3661 #
3662 #"
3663 [(set_attr "type" "delayed_compare")
3664 (set_attr "length" "4,4,8,8")])
3665
3666 (define_split
3667 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3668 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3669 (match_operand:SI 2 "reg_or_cint_operand" ""))
3670 (const_int 0)))
3671 (set (match_operand:SI 0 "gpc_reg_operand" "")
3672 (ashift:SI (match_dup 1) (match_dup 2)))
3673 (clobber (match_scratch:SI 4 ""))]
3674 "TARGET_POWER && reload_completed"
3675 [(parallel [(set (match_dup 0)
3676 (ashift:SI (match_dup 1) (match_dup 2)))
3677 (clobber (match_dup 4))])
3678 (set (match_dup 3)
3679 (compare:CC (match_dup 0)
3680 (const_int 0)))]
3681 "")
3682
3683 (define_insn ""
3684 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3685 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3686 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3687 (const_int 0)))
3688 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3689 (ashift:SI (match_dup 1) (match_dup 2)))]
3690 "! TARGET_POWER && TARGET_32BIT"
3691 "@
3692 {sl|slw}%I2. %0,%1,%h2
3693 #"
3694 [(set_attr "type" "delayed_compare")
3695 (set_attr "length" "4,8")])
3696
3697 (define_split
3698 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3699 (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3700 (match_operand:SI 2 "reg_or_cint_operand" ""))
3701 (const_int 0)))
3702 (set (match_operand:SI 0 "gpc_reg_operand" "")
3703 (ashift:SI (match_dup 1) (match_dup 2)))]
3704 "! TARGET_POWER && TARGET_32BIT && reload_completed"
3705 [(set (match_dup 0)
3706 (ashift:SI (match_dup 1) (match_dup 2)))
3707 (set (match_dup 3)
3708 (compare:CC (match_dup 0)
3709 (const_int 0)))]
3710 "")
3711
3712 (define_insn "rlwinm"
3713 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3714 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3715 (match_operand:SI 2 "const_int_operand" "i"))
3716 (match_operand:SI 3 "mask_operand" "n")))]
3717 "includes_lshift_p (operands[2], operands[3])"
3718 "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
3719
3720 (define_insn ""
3721 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3722 (compare:CC
3723 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3724 (match_operand:SI 2 "const_int_operand" "i,i"))
3725 (match_operand:SI 3 "mask_operand" "n,n"))
3726 (const_int 0)))
3727 (clobber (match_scratch:SI 4 "=r,r"))]
3728 "includes_lshift_p (operands[2], operands[3])"
3729 "@
3730 {rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3
3731 #"
3732 [(set_attr "type" "delayed_compare")
3733 (set_attr "length" "4,8")])
3734
3735 (define_split
3736 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3737 (compare:CC
3738 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3739 (match_operand:SI 2 "const_int_operand" ""))
3740 (match_operand:SI 3 "mask_operand" ""))
3741 (const_int 0)))
3742 (clobber (match_scratch:SI 4 ""))]
3743 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
3744 [(set (match_dup 4)
3745 (and:SI (ashift:SI (match_dup 1) (match_dup 2))
3746 (match_dup 3)))
3747 (set (match_dup 0)
3748 (compare:CC (match_dup 4)
3749 (const_int 0)))]
3750 "")
3751
3752 (define_insn ""
3753 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3754 (compare:CC
3755 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3756 (match_operand:SI 2 "const_int_operand" "i,i"))
3757 (match_operand:SI 3 "mask_operand" "n,n"))
3758 (const_int 0)))
3759 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3760 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3761 "includes_lshift_p (operands[2], operands[3])"
3762 "@
3763 {rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3
3764 #"
3765 [(set_attr "type" "delayed_compare")
3766 (set_attr "length" "4,8")])
3767
3768 (define_split
3769 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3770 (compare:CC
3771 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3772 (match_operand:SI 2 "const_int_operand" ""))
3773 (match_operand:SI 3 "mask_operand" ""))
3774 (const_int 0)))
3775 (set (match_operand:SI 0 "gpc_reg_operand" "")
3776 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3777 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
3778 [(set (match_dup 0)
3779 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3780 (set (match_dup 4)
3781 (compare:CC (match_dup 0)
3782 (const_int 0)))]
3783 "")
3784
3785 ;; The AIX assembler mis-handles "sri x,x,0", so write that case as
3786 ;; "sli x,x,0".
3787 (define_expand "lshrsi3"
3788 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
3789 (use (match_operand:SI 1 "gpc_reg_operand" ""))
3790 (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
3791 ""
3792 "
3793 {
3794 if (TARGET_POWER)
3795 emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
3796 else
3797 emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
3798 DONE;
3799 }")
3800
3801 (define_insn "lshrsi3_power"
3802 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
3803 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
3804 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i")))
3805 (clobber (match_scratch:SI 3 "=q,X,X"))]
3806 "TARGET_POWER"
3807 "@
3808 sre %0,%1,%2
3809 mr %0,%1
3810 {s%A2i|s%A2wi} %0,%1,%h2")
3811
3812 (define_insn "lshrsi3_no_power"
3813 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3814 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3815 (match_operand:SI 2 "reg_or_cint_operand" "O,ri")))]
3816 "! TARGET_POWER"
3817 "@
3818 mr %0,%1
3819 {sr|srw}%I2 %0,%1,%h2")
3820
3821 (define_insn ""
3822 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,?y,?y,?y")
3823 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
3824 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
3825 (const_int 0)))
3826 (clobber (match_scratch:SI 3 "=r,X,r,r,X,r"))
3827 (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
3828 "TARGET_POWER"
3829 "@
3830 sre. %3,%1,%2
3831 mr. %1,%1
3832 {s%A2i.|s%A2wi.} %3,%1,%h2
3833 #
3834 #
3835 #"
3836 [(set_attr "type" "delayed_compare")
3837 (set_attr "length" "4,4,4,8,8,8")])
3838
3839 (define_split
3840 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3841 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3842 (match_operand:SI 2 "reg_or_cint_operand" ""))
3843 (const_int 0)))
3844 (clobber (match_scratch:SI 3 ""))
3845 (clobber (match_scratch:SI 4 ""))]
3846 "TARGET_POWER && reload_completed"
3847 [(parallel [(set (match_dup 3)
3848 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3849 (clobber (match_dup 4))])
3850 (set (match_dup 0)
3851 (compare:CC (match_dup 3)
3852 (const_int 0)))]
3853 "")
3854
3855 (define_insn ""
3856 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3857 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3858 (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
3859 (const_int 0)))
3860 (clobber (match_scratch:SI 3 "=X,r,X,r"))]
3861 "! TARGET_POWER && TARGET_32BIT"
3862 "@
3863 mr. %1,%1
3864 {sr|srw}%I2. %3,%1,%h2
3865 #
3866 #"
3867 [(set_attr "type" "delayed_compare")
3868 (set_attr "length" "4,4,8,8")])
3869
3870 (define_split
3871 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3872 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3873 (match_operand:SI 2 "reg_or_cint_operand" ""))
3874 (const_int 0)))
3875 (clobber (match_scratch:SI 3 ""))]
3876 "! TARGET_POWER && TARGET_32BIT && reload_completed"
3877 [(set (match_dup 3)
3878 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3879 (set (match_dup 0)
3880 (compare:CC (match_dup 3)
3881 (const_int 0)))]
3882 "")
3883
3884 (define_insn ""
3885 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,?y,?y,?y")
3886 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
3887 (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
3888 (const_int 0)))
3889 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
3890 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3891 (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
3892 "TARGET_POWER"
3893 "@
3894 sre. %0,%1,%2
3895 mr. %0,%1
3896 {s%A2i.|s%A2wi.} %0,%1,%h2
3897 #
3898 #
3899 #"
3900 [(set_attr "type" "delayed_compare")
3901 (set_attr "length" "4,4,4,8,8,8")])
3902
3903 (define_split
3904 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3905 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3906 (match_operand:SI 2 "reg_or_cint_operand" ""))
3907 (const_int 0)))
3908 (set (match_operand:SI 0 "gpc_reg_operand" "")
3909 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3910 (clobber (match_scratch:SI 4 ""))]
3911 "TARGET_POWER && reload_completed"
3912 [(parallel [(set (match_dup 0)
3913 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3914 (clobber (match_dup 4))])
3915 (set (match_dup 3)
3916 (compare:CC (match_dup 0)
3917 (const_int 0)))]
3918 "")
3919
3920 (define_insn ""
3921 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3922 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3923 (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
3924 (const_int 0)))
3925 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
3926 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
3927 "! TARGET_POWER && TARGET_32BIT"
3928 "@
3929 mr. %0,%1
3930 {sr|srw}%I2. %0,%1,%h2
3931 #
3932 #"
3933 [(set_attr "type" "delayed_compare")
3934 (set_attr "length" "4,4,8,8")])
3935
3936 (define_split
3937 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3938 (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3939 (match_operand:SI 2 "reg_or_cint_operand" ""))
3940 (const_int 0)))
3941 (set (match_operand:SI 0 "gpc_reg_operand" "")
3942 (lshiftrt:SI (match_dup 1) (match_dup 2)))]
3943 "! TARGET_POWER && TARGET_32BIT && reload_completed"
3944 [(set (match_dup 0)
3945 (lshiftrt:SI (match_dup 1) (match_dup 2)))
3946 (set (match_dup 3)
3947 (compare:CC (match_dup 0)
3948 (const_int 0)))]
3949 "")
3950
3951 (define_insn ""
3952 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3953 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3954 (match_operand:SI 2 "const_int_operand" "i"))
3955 (match_operand:SI 3 "mask_operand" "n")))]
3956 "includes_rshift_p (operands[2], operands[3])"
3957 "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
3958
3959 (define_insn ""
3960 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3961 (compare:CC
3962 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3963 (match_operand:SI 2 "const_int_operand" "i,i"))
3964 (match_operand:SI 3 "mask_operand" "n,n"))
3965 (const_int 0)))
3966 (clobber (match_scratch:SI 4 "=r,r"))]
3967 "includes_rshift_p (operands[2], operands[3])"
3968 "@
3969 {rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3
3970 #"
3971 [(set_attr "type" "delayed_compare")
3972 (set_attr "length" "4,8")])
3973
3974 (define_split
3975 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3976 (compare:CC
3977 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3978 (match_operand:SI 2 "const_int_operand" ""))
3979 (match_operand:SI 3 "mask_operand" ""))
3980 (const_int 0)))
3981 (clobber (match_scratch:SI 4 ""))]
3982 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
3983 [(set (match_dup 4)
3984 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
3985 (match_dup 3)))
3986 (set (match_dup 0)
3987 (compare:CC (match_dup 4)
3988 (const_int 0)))]
3989 "")
3990
3991 (define_insn ""
3992 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3993 (compare:CC
3994 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3995 (match_operand:SI 2 "const_int_operand" "i,i"))
3996 (match_operand:SI 3 "mask_operand" "n,n"))
3997 (const_int 0)))
3998 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3999 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4000 "includes_rshift_p (operands[2], operands[3])"
4001 "@
4002 {rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3
4003 #"
4004 [(set_attr "type" "delayed_compare")
4005 (set_attr "length" "4,8")])
4006
4007 (define_split
4008 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4009 (compare:CC
4010 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4011 (match_operand:SI 2 "const_int_operand" ""))
4012 (match_operand:SI 3 "mask_operand" ""))
4013 (const_int 0)))
4014 (set (match_operand:SI 0 "gpc_reg_operand" "")
4015 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4016 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4017 [(set (match_dup 0)
4018 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4019 (set (match_dup 4)
4020 (compare:CC (match_dup 0)
4021 (const_int 0)))]
4022 "")
4023
4024 (define_insn ""
4025 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4026 (zero_extend:SI
4027 (subreg:QI
4028 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4029 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4030 "includes_rshift_p (operands[2], GEN_INT (255))"
4031 "{rlinm|rlwinm} %0,%1,%s2,0xff")
4032
4033 (define_insn ""
4034 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4035 (compare:CC
4036 (zero_extend:SI
4037 (subreg:QI
4038 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4039 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4040 (const_int 0)))
4041 (clobber (match_scratch:SI 3 "=r,r"))]
4042 "includes_rshift_p (operands[2], GEN_INT (255))"
4043 "@
4044 {rlinm.|rlwinm.} %3,%1,%s2,0xff
4045 #"
4046 [(set_attr "type" "delayed_compare")
4047 (set_attr "length" "4,8")])
4048
4049 (define_split
4050 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4051 (compare:CC
4052 (zero_extend:SI
4053 (subreg:QI
4054 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4055 (match_operand:SI 2 "const_int_operand" "")) 0))
4056 (const_int 0)))
4057 (clobber (match_scratch:SI 3 ""))]
4058 "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4059 [(set (match_dup 3)
4060 (zero_extend:SI (subreg:QI
4061 (lshiftrt:SI (match_dup 1)
4062 (match_dup 2)) 0)))
4063 (set (match_dup 0)
4064 (compare:CC (match_dup 3)
4065 (const_int 0)))]
4066 "")
4067
4068 (define_insn ""
4069 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4070 (compare:CC
4071 (zero_extend:SI
4072 (subreg:QI
4073 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4074 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4075 (const_int 0)))
4076 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4077 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4078 "includes_rshift_p (operands[2], GEN_INT (255))"
4079 "@
4080 {rlinm.|rlwinm.} %0,%1,%s2,0xff
4081 #"
4082 [(set_attr "type" "delayed_compare")
4083 (set_attr "length" "4,8")])
4084
4085 (define_split
4086 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4087 (compare:CC
4088 (zero_extend:SI
4089 (subreg:QI
4090 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4091 (match_operand:SI 2 "const_int_operand" "")) 0))
4092 (const_int 0)))
4093 (set (match_operand:SI 0 "gpc_reg_operand" "")
4094 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4095 "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4096 [(set (match_dup 0)
4097 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4098 (set (match_dup 3)
4099 (compare:CC (match_dup 0)
4100 (const_int 0)))]
4101 "")
4102
4103 (define_insn ""
4104 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4105 (zero_extend:SI
4106 (subreg:HI
4107 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4108 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4109 "includes_rshift_p (operands[2], GEN_INT (65535))"
4110 "{rlinm|rlwinm} %0,%1,%s2,0xffff")
4111
4112 (define_insn ""
4113 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4114 (compare:CC
4115 (zero_extend:SI
4116 (subreg:HI
4117 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4118 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4119 (const_int 0)))
4120 (clobber (match_scratch:SI 3 "=r,r"))]
4121 "includes_rshift_p (operands[2], GEN_INT (65535))"
4122 "@
4123 {rlinm.|rlwinm.} %3,%1,%s2,0xffff
4124 #"
4125 [(set_attr "type" "delayed_compare")
4126 (set_attr "length" "4,8")])
4127
4128 (define_split
4129 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4130 (compare:CC
4131 (zero_extend:SI
4132 (subreg:HI
4133 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4134 (match_operand:SI 2 "const_int_operand" "")) 0))
4135 (const_int 0)))
4136 (clobber (match_scratch:SI 3 ""))]
4137 "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4138 [(set (match_dup 3)
4139 (zero_extend:SI (subreg:HI
4140 (lshiftrt:SI (match_dup 1)
4141 (match_dup 2)) 0)))
4142 (set (match_dup 0)
4143 (compare:CC (match_dup 3)
4144 (const_int 0)))]
4145 "")
4146
4147 (define_insn ""
4148 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4149 (compare:CC
4150 (zero_extend:SI
4151 (subreg:HI
4152 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4153 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4154 (const_int 0)))
4155 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4156 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4157 "includes_rshift_p (operands[2], GEN_INT (65535))"
4158 "@
4159 {rlinm.|rlwinm.} %0,%1,%s2,0xffff
4160 #"
4161 [(set_attr "type" "delayed_compare")
4162 (set_attr "length" "4,8")])
4163
4164 (define_split
4165 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4166 (compare:CC
4167 (zero_extend:SI
4168 (subreg:HI
4169 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4170 (match_operand:SI 2 "const_int_operand" "")) 0))
4171 (const_int 0)))
4172 (set (match_operand:SI 0 "gpc_reg_operand" "")
4173 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4174 "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4175 [(set (match_dup 0)
4176 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4177 (set (match_dup 3)
4178 (compare:CC (match_dup 0)
4179 (const_int 0)))]
4180 "")
4181
4182 (define_insn ""
4183 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4184 (const_int 1)
4185 (match_operand:SI 1 "gpc_reg_operand" "r"))
4186 (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4187 (const_int 31)))]
4188 "TARGET_POWER"
4189 "rrib %0,%1,%2")
4190
4191 (define_insn ""
4192 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4193 (const_int 1)
4194 (match_operand:SI 1 "gpc_reg_operand" "r"))
4195 (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4196 (const_int 31)))]
4197 "TARGET_POWER"
4198 "rrib %0,%1,%2")
4199
4200 (define_insn ""
4201 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4202 (const_int 1)
4203 (match_operand:SI 1 "gpc_reg_operand" "r"))
4204 (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4205 (const_int 1)
4206 (const_int 0)))]
4207 "TARGET_POWER"
4208 "rrib %0,%1,%2")
4209
4210 (define_expand "ashrsi3"
4211 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4212 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4213 (match_operand:SI 2 "reg_or_cint_operand" "")))]
4214 ""
4215 "
4216 {
4217 if (TARGET_POWER)
4218 emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
4219 else
4220 emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
4221 DONE;
4222 }")
4223
4224 (define_insn "ashrsi3_power"
4225 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4226 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4227 (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4228 (clobber (match_scratch:SI 3 "=q,X"))]
4229 "TARGET_POWER"
4230 "@
4231 srea %0,%1,%2
4232 {srai|srawi} %0,%1,%h2")
4233
4234 (define_insn "ashrsi3_no_power"
4235 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4236 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4237 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4238 "! TARGET_POWER"
4239 "{sra|sraw}%I2 %0,%1,%h2")
4240
4241 (define_insn ""
4242 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4243 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4244 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4245 (const_int 0)))
4246 (clobber (match_scratch:SI 3 "=r,r,r,r"))
4247 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4248 "TARGET_POWER"
4249 "@
4250 srea. %3,%1,%2
4251 {srai.|srawi.} %3,%1,%h2
4252 #
4253 #"
4254 [(set_attr "type" "delayed_compare")
4255 (set_attr "length" "4,4,8,8")])
4256
4257 (define_split
4258 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4259 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4260 (match_operand:SI 2 "reg_or_cint_operand" ""))
4261 (const_int 0)))
4262 (clobber (match_scratch:SI 3 ""))
4263 (clobber (match_scratch:SI 4 ""))]
4264 "TARGET_POWER && reload_completed"
4265 [(parallel [(set (match_dup 3)
4266 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4267 (clobber (match_dup 4))])
4268 (set (match_dup 0)
4269 (compare:CC (match_dup 3)
4270 (const_int 0)))]
4271 "")
4272
4273 (define_insn ""
4274 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4275 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4276 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4277 (const_int 0)))
4278 (clobber (match_scratch:SI 3 "=r,r"))]
4279 "! TARGET_POWER"
4280 "@
4281 {sra|sraw}%I2. %3,%1,%h2
4282 #"
4283 [(set_attr "type" "delayed_compare")
4284 (set_attr "length" "4,8")])
4285
4286 (define_split
4287 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4288 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4289 (match_operand:SI 2 "reg_or_cint_operand" ""))
4290 (const_int 0)))
4291 (clobber (match_scratch:SI 3 ""))]
4292 "! TARGET_POWER && reload_completed"
4293 [(set (match_dup 3)
4294 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4295 (set (match_dup 0)
4296 (compare:CC (match_dup 3)
4297 (const_int 0)))]
4298 "")
4299
4300 (define_insn ""
4301 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4302 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4303 (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4304 (const_int 0)))
4305 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4306 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4307 (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4308 "TARGET_POWER"
4309 "@
4310 srea. %0,%1,%2
4311 {srai.|srawi.} %0,%1,%h2
4312 #
4313 #"
4314 [(set_attr "type" "delayed_compare")
4315 (set_attr "length" "4,4,8,8")])
4316
4317 (define_split
4318 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4319 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4320 (match_operand:SI 2 "reg_or_cint_operand" ""))
4321 (const_int 0)))
4322 (set (match_operand:SI 0 "gpc_reg_operand" "")
4323 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4324 (clobber (match_scratch:SI 4 ""))]
4325 "TARGET_POWER && reload_completed"
4326 [(parallel [(set (match_dup 0)
4327 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4328 (clobber (match_dup 4))])
4329 (set (match_dup 3)
4330 (compare:CC (match_dup 0)
4331 (const_int 0)))]
4332 "")
4333
4334 (define_insn ""
4335 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4336 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4337 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4338 (const_int 0)))
4339 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4340 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
4341 "! TARGET_POWER"
4342 "@
4343 {sra|sraw}%I2. %0,%1,%h2
4344 #"
4345 [(set_attr "type" "delayed_compare")
4346 (set_attr "length" "4,8")])
4347 \f
4348 (define_split
4349 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4350 (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4351 (match_operand:SI 2 "reg_or_cint_operand" ""))
4352 (const_int 0)))
4353 (set (match_operand:SI 0 "gpc_reg_operand" "")
4354 (ashiftrt:SI (match_dup 1) (match_dup 2)))]
4355 "! TARGET_POWER && reload_completed"
4356 [(set (match_dup 0)
4357 (ashiftrt:SI (match_dup 1) (match_dup 2)))
4358 (set (match_dup 3)
4359 (compare:CC (match_dup 0)
4360 (const_int 0)))]
4361 "")
4362
4363 ;; Floating-point insns, excluding normal data motion.
4364 ;;
4365 ;; PowerPC has a full set of single-precision floating point instructions.
4366 ;;
4367 ;; For the POWER architecture, we pretend that we have both SFmode and
4368 ;; DFmode insns, while, in fact, all fp insns are actually done in double.
4369 ;; The only conversions we will do will be when storing to memory. In that
4370 ;; case, we will use the "frsp" instruction before storing.
4371 ;;
4372 ;; Note that when we store into a single-precision memory location, we need to
4373 ;; use the frsp insn first. If the register being stored isn't dead, we
4374 ;; need a scratch register for the frsp. But this is difficult when the store
4375 ;; is done by reload. It is not incorrect to do the frsp on the register in
4376 ;; this case, we just lose precision that we would have otherwise gotten but
4377 ;; is not guaranteed. Perhaps this should be tightened up at some point.
4378
4379 (define_expand "extendsfdf2"
4380 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4381 (float_extend:DF (match_operand:SF 1 "reg_or_none500mem_operand" "")))]
4382 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4383 "")
4384
4385 (define_insn_and_split "*extendsfdf2_fpr"
4386 [(set (match_operand:DF 0 "gpc_reg_operand" "=f,?f,f")
4387 (float_extend:DF (match_operand:SF 1 "reg_or_mem_operand" "0,f,m")))]
4388 "TARGET_HARD_FLOAT && TARGET_FPRS"
4389 "@
4390 #
4391 fmr %0,%1
4392 lfs%U1%X1 %0,%1"
4393 "&& reload_completed && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])"
4394 [(const_int 0)]
4395 {
4396 emit_note (NOTE_INSN_DELETED);
4397 DONE;
4398 }
4399 [(set_attr "type" "fp,fp,fpload")])
4400
4401 (define_expand "truncdfsf2"
4402 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4403 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "")))]
4404 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4405 "")
4406
4407 (define_insn "*truncdfsf2_fpr"
4408 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4409 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
4410 "TARGET_HARD_FLOAT && TARGET_FPRS"
4411 "frsp %0,%1"
4412 [(set_attr "type" "fp")])
4413
4414 (define_insn "aux_truncdfsf2"
4415 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4416 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRSP))]
4417 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4418 "frsp %0,%1"
4419 [(set_attr "type" "fp")])
4420
4421 (define_expand "negsf2"
4422 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4423 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4424 "TARGET_HARD_FLOAT"
4425 "")
4426
4427 (define_insn "*negsf2"
4428 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4429 (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4430 "TARGET_HARD_FLOAT && TARGET_FPRS"
4431 "fneg %0,%1"
4432 [(set_attr "type" "fp")])
4433
4434 (define_expand "abssf2"
4435 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4436 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4437 "TARGET_HARD_FLOAT"
4438 "")
4439
4440 (define_insn "*abssf2"
4441 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4442 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4443 "TARGET_HARD_FLOAT && TARGET_FPRS"
4444 "fabs %0,%1"
4445 [(set_attr "type" "fp")])
4446
4447 (define_insn ""
4448 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4449 (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
4450 "TARGET_HARD_FLOAT && TARGET_FPRS"
4451 "fnabs %0,%1"
4452 [(set_attr "type" "fp")])
4453
4454 (define_expand "addsf3"
4455 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4456 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4457 (match_operand:SF 2 "gpc_reg_operand" "")))]
4458 "TARGET_HARD_FLOAT"
4459 "")
4460
4461 (define_insn ""
4462 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4463 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4464 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4465 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4466 "fadds %0,%1,%2"
4467 [(set_attr "type" "fp")])
4468
4469 (define_insn ""
4470 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4471 (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4472 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4473 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4474 "{fa|fadd} %0,%1,%2"
4475 [(set_attr "type" "fp")])
4476
4477 (define_expand "subsf3"
4478 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4479 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4480 (match_operand:SF 2 "gpc_reg_operand" "")))]
4481 "TARGET_HARD_FLOAT"
4482 "")
4483
4484 (define_insn ""
4485 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4486 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4487 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4488 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4489 "fsubs %0,%1,%2"
4490 [(set_attr "type" "fp")])
4491
4492 (define_insn ""
4493 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4494 (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4495 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4496 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4497 "{fs|fsub} %0,%1,%2"
4498 [(set_attr "type" "fp")])
4499
4500 (define_expand "mulsf3"
4501 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4502 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
4503 (match_operand:SF 2 "gpc_reg_operand" "")))]
4504 "TARGET_HARD_FLOAT"
4505 "")
4506
4507 (define_insn ""
4508 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4509 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4510 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4511 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4512 "fmuls %0,%1,%2"
4513 [(set_attr "type" "fp")])
4514
4515 (define_insn ""
4516 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4517 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4518 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4519 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4520 "{fm|fmul} %0,%1,%2"
4521 [(set_attr "type" "dmul")])
4522
4523 (define_insn "fres"
4524 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4525 (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRES))]
4526 "TARGET_PPC_GFXOPT && flag_finite_math_only"
4527 "fres %0,%1"
4528 [(set_attr "type" "fp")])
4529
4530 (define_expand "divsf3"
4531 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4532 (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
4533 (match_operand:SF 2 "gpc_reg_operand" "")))]
4534 "TARGET_HARD_FLOAT"
4535 {
4536 if (swdiv && !optimize_size && TARGET_PPC_GFXOPT
4537 && flag_finite_math_only && !flag_trapping_math)
4538 {
4539 rs6000_emit_swdivsf (operands[0], operands[1], operands[2]);
4540 DONE;
4541 }
4542 })
4543
4544 (define_insn ""
4545 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4546 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4547 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4548 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4549 "fdivs %0,%1,%2"
4550 [(set_attr "type" "sdiv")])
4551
4552 (define_insn ""
4553 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4554 (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4555 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4556 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4557 "{fd|fdiv} %0,%1,%2"
4558 [(set_attr "type" "ddiv")])
4559
4560 (define_insn ""
4561 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4562 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4563 (match_operand:SF 2 "gpc_reg_operand" "f"))
4564 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4565 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4566 "fmadds %0,%1,%2,%3"
4567 [(set_attr "type" "fp")])
4568
4569 (define_insn ""
4570 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4571 (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4572 (match_operand:SF 2 "gpc_reg_operand" "f"))
4573 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4574 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4575 "{fma|fmadd} %0,%1,%2,%3"
4576 [(set_attr "type" "dmul")])
4577
4578 (define_insn ""
4579 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4580 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4581 (match_operand:SF 2 "gpc_reg_operand" "f"))
4582 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4583 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4584 "fmsubs %0,%1,%2,%3"
4585 [(set_attr "type" "fp")])
4586
4587 (define_insn ""
4588 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4589 (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4590 (match_operand:SF 2 "gpc_reg_operand" "f"))
4591 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4592 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4593 "{fms|fmsub} %0,%1,%2,%3"
4594 [(set_attr "type" "dmul")])
4595
4596 (define_insn ""
4597 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4598 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4599 (match_operand:SF 2 "gpc_reg_operand" "f"))
4600 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4601 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4602 && HONOR_SIGNED_ZEROS (SFmode)"
4603 "fnmadds %0,%1,%2,%3"
4604 [(set_attr "type" "fp")])
4605
4606 (define_insn ""
4607 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4608 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
4609 (match_operand:SF 2 "gpc_reg_operand" "f"))
4610 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4611 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4612 && ! HONOR_SIGNED_ZEROS (SFmode)"
4613 "fnmadds %0,%1,%2,%3"
4614 [(set_attr "type" "fp")])
4615
4616 (define_insn ""
4617 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4618 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4619 (match_operand:SF 2 "gpc_reg_operand" "f"))
4620 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4621 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4622 "{fnma|fnmadd} %0,%1,%2,%3"
4623 [(set_attr "type" "dmul")])
4624
4625 (define_insn ""
4626 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4627 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
4628 (match_operand:SF 2 "gpc_reg_operand" "f"))
4629 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4630 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4631 && ! HONOR_SIGNED_ZEROS (SFmode)"
4632 "{fnma|fnmadd} %0,%1,%2,%3"
4633 [(set_attr "type" "dmul")])
4634
4635 (define_insn ""
4636 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4637 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4638 (match_operand:SF 2 "gpc_reg_operand" "f"))
4639 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4640 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4641 && HONOR_SIGNED_ZEROS (SFmode)"
4642 "fnmsubs %0,%1,%2,%3"
4643 [(set_attr "type" "fp")])
4644
4645 (define_insn ""
4646 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4647 (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
4648 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4649 (match_operand:SF 2 "gpc_reg_operand" "f"))))]
4650 "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4651 && ! HONOR_SIGNED_ZEROS (SFmode)"
4652 "fnmsubs %0,%1,%2,%3"
4653 [(set_attr "type" "fp")])
4654
4655 (define_insn ""
4656 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4657 (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4658 (match_operand:SF 2 "gpc_reg_operand" "f"))
4659 (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4660 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4661 "{fnms|fnmsub} %0,%1,%2,%3"
4662 [(set_attr "type" "dmul")])
4663
4664 (define_insn ""
4665 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4666 (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
4667 (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4668 (match_operand:SF 2 "gpc_reg_operand" "f"))))]
4669 "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4670 && ! HONOR_SIGNED_ZEROS (SFmode)"
4671 "{fnms|fnmsub} %0,%1,%2,%3"
4672 [(set_attr "type" "fp")])
4673
4674 (define_expand "sqrtsf2"
4675 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4676 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4677 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
4678 "")
4679
4680 (define_insn ""
4681 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4682 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4683 "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4684 "fsqrts %0,%1"
4685 [(set_attr "type" "ssqrt")])
4686
4687 (define_insn ""
4688 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4689 (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4690 "TARGET_POWER2 && TARGET_HARD_FLOAT && TARGET_FPRS"
4691 "fsqrt %0,%1"
4692 [(set_attr "type" "dsqrt")])
4693
4694 (define_expand "copysignsf3"
4695 [(set (match_dup 3)
4696 (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))
4697 (set (match_dup 4)
4698 (neg:SF (abs:SF (match_dup 1))))
4699 (set (match_operand:SF 0 "gpc_reg_operand" "")
4700 (if_then_else:SF (ge (match_operand:SF 2 "gpc_reg_operand" "")
4701 (match_dup 5))
4702 (match_dup 3)
4703 (match_dup 4)))]
4704 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS
4705 && !HONOR_NANS (SFmode) && !HONOR_SIGNED_ZEROS (SFmode)"
4706 {
4707 operands[3] = gen_reg_rtx (SFmode);
4708 operands[4] = gen_reg_rtx (SFmode);
4709 operands[5] = CONST0_RTX (SFmode);
4710 })
4711
4712 (define_expand "copysigndf3"
4713 [(set (match_dup 3)
4714 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "")))
4715 (set (match_dup 4)
4716 (neg:DF (abs:DF (match_dup 1))))
4717 (set (match_operand:DF 0 "gpc_reg_operand" "")
4718 (if_then_else:DF (ge (match_operand:DF 2 "gpc_reg_operand" "")
4719 (match_dup 5))
4720 (match_dup 3)
4721 (match_dup 4)))]
4722 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS
4723 && !HONOR_NANS (DFmode) && !HONOR_SIGNED_ZEROS (DFmode)"
4724 {
4725 operands[3] = gen_reg_rtx (DFmode);
4726 operands[4] = gen_reg_rtx (DFmode);
4727 operands[5] = CONST0_RTX (DFmode);
4728 })
4729
4730 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
4731 ;; fsel instruction and some auxiliary computations. Then we just have a
4732 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
4733 ;; combine.
4734 (define_expand "smaxsf3"
4735 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4736 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
4737 (match_operand:SF 2 "gpc_reg_operand" ""))
4738 (match_dup 1)
4739 (match_dup 2)))]
4740 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
4741 "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
4742
4743 (define_expand "sminsf3"
4744 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4745 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
4746 (match_operand:SF 2 "gpc_reg_operand" ""))
4747 (match_dup 2)
4748 (match_dup 1)))]
4749 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
4750 "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
4751
4752 (define_split
4753 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4754 (match_operator:SF 3 "min_max_operator"
4755 [(match_operand:SF 1 "gpc_reg_operand" "")
4756 (match_operand:SF 2 "gpc_reg_operand" "")]))]
4757 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
4758 [(const_int 0)]
4759 "
4760 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
4761 operands[1], operands[2]);
4762 DONE;
4763 }")
4764
4765 (define_expand "movsicc"
4766 [(set (match_operand:SI 0 "gpc_reg_operand" "")
4767 (if_then_else:SI (match_operand 1 "comparison_operator" "")
4768 (match_operand:SI 2 "gpc_reg_operand" "")
4769 (match_operand:SI 3 "gpc_reg_operand" "")))]
4770 "TARGET_ISEL"
4771 "
4772 {
4773 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
4774 DONE;
4775 else
4776 FAIL;
4777 }")
4778
4779 ;; We use the BASE_REGS for the isel input operands because, if rA is
4780 ;; 0, the value of 0 is placed in rD upon truth. Similarly for rB
4781 ;; because we may switch the operands and rB may end up being rA.
4782 ;;
4783 ;; We need 2 patterns: an unsigned and a signed pattern. We could
4784 ;; leave out the mode in operand 4 and use one pattern, but reload can
4785 ;; change the mode underneath our feet and then gets confused trying
4786 ;; to reload the value.
4787 (define_insn "isel_signed"
4788 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4789 (if_then_else:SI
4790 (match_operator 1 "comparison_operator"
4791 [(match_operand:CC 4 "cc_reg_operand" "y")
4792 (const_int 0)])
4793 (match_operand:SI 2 "gpc_reg_operand" "b")
4794 (match_operand:SI 3 "gpc_reg_operand" "b")))]
4795 "TARGET_ISEL"
4796 "*
4797 { return output_isel (operands); }"
4798 [(set_attr "length" "4")])
4799
4800 (define_insn "isel_unsigned"
4801 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4802 (if_then_else:SI
4803 (match_operator 1 "comparison_operator"
4804 [(match_operand:CCUNS 4 "cc_reg_operand" "y")
4805 (const_int 0)])
4806 (match_operand:SI 2 "gpc_reg_operand" "b")
4807 (match_operand:SI 3 "gpc_reg_operand" "b")))]
4808 "TARGET_ISEL"
4809 "*
4810 { return output_isel (operands); }"
4811 [(set_attr "length" "4")])
4812
4813 (define_expand "movsfcc"
4814 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4815 (if_then_else:SF (match_operand 1 "comparison_operator" "")
4816 (match_operand:SF 2 "gpc_reg_operand" "")
4817 (match_operand:SF 3 "gpc_reg_operand" "")))]
4818 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4819 "
4820 {
4821 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
4822 DONE;
4823 else
4824 FAIL;
4825 }")
4826
4827 (define_insn "*fselsfsf4"
4828 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4829 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
4830 (match_operand:SF 4 "zero_fp_constant" "F"))
4831 (match_operand:SF 2 "gpc_reg_operand" "f")
4832 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4833 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4834 "fsel %0,%1,%2,%3"
4835 [(set_attr "type" "fp")])
4836
4837 (define_insn "*fseldfsf4"
4838 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4839 (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
4840 (match_operand:DF 4 "zero_fp_constant" "F"))
4841 (match_operand:SF 2 "gpc_reg_operand" "f")
4842 (match_operand:SF 3 "gpc_reg_operand" "f")))]
4843 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4844 "fsel %0,%1,%2,%3"
4845 [(set_attr "type" "fp")])
4846
4847 (define_expand "negdf2"
4848 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4849 (neg:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
4850 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4851 "")
4852
4853 (define_insn "*negdf2_fpr"
4854 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4855 (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
4856 "TARGET_HARD_FLOAT && TARGET_FPRS"
4857 "fneg %0,%1"
4858 [(set_attr "type" "fp")])
4859
4860 (define_expand "absdf2"
4861 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4862 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
4863 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4864 "")
4865
4866 (define_insn "*absdf2_fpr"
4867 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4868 (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
4869 "TARGET_HARD_FLOAT && TARGET_FPRS"
4870 "fabs %0,%1"
4871 [(set_attr "type" "fp")])
4872
4873 (define_insn "*nabsdf2_fpr"
4874 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4875 (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
4876 "TARGET_HARD_FLOAT && TARGET_FPRS"
4877 "fnabs %0,%1"
4878 [(set_attr "type" "fp")])
4879
4880 (define_expand "adddf3"
4881 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4882 (plus:DF (match_operand:DF 1 "gpc_reg_operand" "")
4883 (match_operand:DF 2 "gpc_reg_operand" "")))]
4884 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4885 "")
4886
4887 (define_insn "*adddf3_fpr"
4888 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4889 (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4890 (match_operand:DF 2 "gpc_reg_operand" "f")))]
4891 "TARGET_HARD_FLOAT && TARGET_FPRS"
4892 "{fa|fadd} %0,%1,%2"
4893 [(set_attr "type" "fp")])
4894
4895 (define_expand "subdf3"
4896 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4897 (minus:DF (match_operand:DF 1 "gpc_reg_operand" "")
4898 (match_operand:DF 2 "gpc_reg_operand" "")))]
4899 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4900 "")
4901
4902 (define_insn "*subdf3_fpr"
4903 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4904 (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
4905 (match_operand:DF 2 "gpc_reg_operand" "f")))]
4906 "TARGET_HARD_FLOAT && TARGET_FPRS"
4907 "{fs|fsub} %0,%1,%2"
4908 [(set_attr "type" "fp")])
4909
4910 (define_expand "muldf3"
4911 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4912 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "")
4913 (match_operand:DF 2 "gpc_reg_operand" "")))]
4914 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4915 "")
4916
4917 (define_insn "*muldf3_fpr"
4918 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4919 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4920 (match_operand:DF 2 "gpc_reg_operand" "f")))]
4921 "TARGET_HARD_FLOAT && TARGET_FPRS"
4922 "{fm|fmul} %0,%1,%2"
4923 [(set_attr "type" "dmul")])
4924
4925 (define_insn "fred"
4926 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4927 (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")] UNSPEC_FRES))]
4928 "TARGET_POPCNTB && flag_finite_math_only"
4929 "fre %0,%1"
4930 [(set_attr "type" "fp")])
4931
4932 (define_expand "divdf3"
4933 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4934 (div:DF (match_operand:DF 1 "gpc_reg_operand" "")
4935 (match_operand:DF 2 "gpc_reg_operand" "")))]
4936 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4937 {
4938 if (swdiv && !optimize_size && TARGET_POPCNTB
4939 && flag_finite_math_only && !flag_trapping_math)
4940 {
4941 rs6000_emit_swdivdf (operands[0], operands[1], operands[2]);
4942 DONE;
4943 }
4944 })
4945
4946 (define_insn "*divdf3_fpr"
4947 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4948 (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
4949 (match_operand:DF 2 "gpc_reg_operand" "f")))]
4950 "TARGET_HARD_FLOAT && TARGET_FPRS"
4951 "{fd|fdiv} %0,%1,%2"
4952 [(set_attr "type" "ddiv")])
4953
4954 (define_insn ""
4955 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4956 (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4957 (match_operand:DF 2 "gpc_reg_operand" "f"))
4958 (match_operand:DF 3 "gpc_reg_operand" "f")))]
4959 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4960 "{fma|fmadd} %0,%1,%2,%3"
4961 [(set_attr "type" "dmul")])
4962
4963 (define_insn ""
4964 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4965 (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4966 (match_operand:DF 2 "gpc_reg_operand" "f"))
4967 (match_operand:DF 3 "gpc_reg_operand" "f")))]
4968 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4969 "{fms|fmsub} %0,%1,%2,%3"
4970 [(set_attr "type" "dmul")])
4971
4972 (define_insn ""
4973 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4974 (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4975 (match_operand:DF 2 "gpc_reg_operand" "f"))
4976 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
4977 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4978 && HONOR_SIGNED_ZEROS (DFmode)"
4979 "{fnma|fnmadd} %0,%1,%2,%3"
4980 [(set_attr "type" "dmul")])
4981
4982 (define_insn ""
4983 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4984 (minus:DF (mult:DF (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f"))
4985 (match_operand:DF 2 "gpc_reg_operand" "f"))
4986 (match_operand:DF 3 "gpc_reg_operand" "f")))]
4987 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4988 && ! HONOR_SIGNED_ZEROS (DFmode)"
4989 "{fnma|fnmadd} %0,%1,%2,%3"
4990 [(set_attr "type" "dmul")])
4991
4992 (define_insn ""
4993 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4994 (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4995 (match_operand:DF 2 "gpc_reg_operand" "f"))
4996 (match_operand:DF 3 "gpc_reg_operand" "f"))))]
4997 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4998 && HONOR_SIGNED_ZEROS (DFmode)"
4999 "{fnms|fnmsub} %0,%1,%2,%3"
5000 [(set_attr "type" "dmul")])
5001
5002 (define_insn ""
5003 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5004 (minus:DF (match_operand:DF 3 "gpc_reg_operand" "f")
5005 (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5006 (match_operand:DF 2 "gpc_reg_operand" "f"))))]
5007 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5008 && ! HONOR_SIGNED_ZEROS (DFmode)"
5009 "{fnms|fnmsub} %0,%1,%2,%3"
5010 [(set_attr "type" "dmul")])
5011
5012 (define_insn "sqrtdf2"
5013 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5014 (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5015 "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
5016 "fsqrt %0,%1"
5017 [(set_attr "type" "dsqrt")])
5018
5019 ;; The conditional move instructions allow us to perform max and min
5020 ;; operations even when
5021
5022 (define_expand "smaxdf3"
5023 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5024 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5025 (match_operand:DF 2 "gpc_reg_operand" ""))
5026 (match_dup 1)
5027 (match_dup 2)))]
5028 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
5029 "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
5030
5031 (define_expand "smindf3"
5032 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5033 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5034 (match_operand:DF 2 "gpc_reg_operand" ""))
5035 (match_dup 2)
5036 (match_dup 1)))]
5037 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
5038 "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
5039
5040 (define_split
5041 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5042 (match_operator:DF 3 "min_max_operator"
5043 [(match_operand:DF 1 "gpc_reg_operand" "")
5044 (match_operand:DF 2 "gpc_reg_operand" "")]))]
5045 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
5046 [(const_int 0)]
5047 "
5048 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
5049 operands[1], operands[2]);
5050 DONE;
5051 }")
5052
5053 (define_expand "movdfcc"
5054 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5055 (if_then_else:DF (match_operand 1 "comparison_operator" "")
5056 (match_operand:DF 2 "gpc_reg_operand" "")
5057 (match_operand:DF 3 "gpc_reg_operand" "")))]
5058 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5059 "
5060 {
5061 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5062 DONE;
5063 else
5064 FAIL;
5065 }")
5066
5067 (define_insn "*fseldfdf4"
5068 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5069 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
5070 (match_operand:DF 4 "zero_fp_constant" "F"))
5071 (match_operand:DF 2 "gpc_reg_operand" "f")
5072 (match_operand:DF 3 "gpc_reg_operand" "f")))]
5073 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5074 "fsel %0,%1,%2,%3"
5075 [(set_attr "type" "fp")])
5076
5077 (define_insn "*fselsfdf4"
5078 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5079 (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5080 (match_operand:SF 4 "zero_fp_constant" "F"))
5081 (match_operand:DF 2 "gpc_reg_operand" "f")
5082 (match_operand:DF 3 "gpc_reg_operand" "f")))]
5083 "TARGET_PPC_GFXOPT"
5084 "fsel %0,%1,%2,%3"
5085 [(set_attr "type" "fp")])
5086 \f
5087 ;; Conversions to and from floating-point.
5088
5089 (define_expand "fixuns_truncsfsi2"
5090 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5091 (unsigned_fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
5092 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5093 "")
5094
5095 (define_expand "fix_truncsfsi2"
5096 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5097 (fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
5098 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5099 "")
5100
5101 ; For each of these conversions, there is a define_expand, a define_insn
5102 ; with a '#' template, and a define_split (with C code). The idea is
5103 ; to allow constant folding with the template of the define_insn,
5104 ; then to have the insns split later (between sched1 and final).
5105
5106 (define_expand "floatsidf2"
5107 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5108 (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5109 (use (match_dup 2))
5110 (use (match_dup 3))
5111 (clobber (match_dup 4))
5112 (clobber (match_dup 5))
5113 (clobber (match_dup 6))])]
5114 "TARGET_HARD_FLOAT && TARGET_FPRS"
5115 "
5116 {
5117 if (TARGET_E500_DOUBLE)
5118 {
5119 emit_insn (gen_spe_floatsidf2 (operands[0], operands[1]));
5120 DONE;
5121 }
5122 if (TARGET_POWERPC64)
5123 {
5124 rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5125 rtx t1 = gen_reg_rtx (DImode);
5126 rtx t2 = gen_reg_rtx (DImode);
5127 emit_insn (gen_floatsidf_ppc64 (operands[0], operands[1], mem, t1, t2));
5128 DONE;
5129 }
5130
5131 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5132 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503601774854144\", DFmode));
5133 operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5134 operands[5] = gen_reg_rtx (DFmode);
5135 operands[6] = gen_reg_rtx (SImode);
5136 }")
5137
5138 (define_insn_and_split "*floatsidf2_internal"
5139 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5140 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5141 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5142 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5143 (clobber (match_operand:DF 4 "memory_operand" "=o"))
5144 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))
5145 (clobber (match_operand:SI 6 "gpc_reg_operand" "=&r"))]
5146 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5147 "#"
5148 "&& (!no_new_pseudos || offsettable_nonstrict_memref_p (operands[4]))"
5149 [(pc)]
5150 "
5151 {
5152 rtx lowword, highword;
5153 gcc_assert (MEM_P (operands[4]));
5154 highword = adjust_address (operands[4], SImode, 0);
5155 lowword = adjust_address (operands[4], SImode, 4);
5156 if (! WORDS_BIG_ENDIAN)
5157 {
5158 rtx tmp;
5159 tmp = highword; highword = lowword; lowword = tmp;
5160 }
5161
5162 emit_insn (gen_xorsi3 (operands[6], operands[1],
5163 GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
5164 emit_move_insn (lowword, operands[6]);
5165 emit_move_insn (highword, operands[2]);
5166 emit_move_insn (operands[5], operands[4]);
5167 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5168 DONE;
5169 }"
5170 [(set_attr "length" "24")])
5171
5172 (define_expand "floatunssisf2"
5173 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5174 (unsigned_float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5175 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5176 "")
5177
5178 (define_expand "floatunssidf2"
5179 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5180 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5181 (use (match_dup 2))
5182 (use (match_dup 3))
5183 (clobber (match_dup 4))
5184 (clobber (match_dup 5))])]
5185 "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5186 "
5187 {
5188 if (TARGET_E500_DOUBLE)
5189 {
5190 emit_insn (gen_spe_floatunssidf2 (operands[0], operands[1]));
5191 DONE;
5192 }
5193 if (TARGET_POWERPC64)
5194 {
5195 rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5196 rtx t1 = gen_reg_rtx (DImode);
5197 rtx t2 = gen_reg_rtx (DImode);
5198 emit_insn (gen_floatunssidf_ppc64 (operands[0], operands[1], mem,
5199 t1, t2));
5200 DONE;
5201 }
5202
5203 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5204 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503599627370496\", DFmode));
5205 operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5206 operands[5] = gen_reg_rtx (DFmode);
5207 }")
5208
5209 (define_insn_and_split "*floatunssidf2_internal"
5210 [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5211 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5212 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5213 (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5214 (clobber (match_operand:DF 4 "memory_operand" "=o"))
5215 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))]
5216 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5217 "#"
5218 "&& (!no_new_pseudos || offsettable_nonstrict_memref_p (operands[4]))"
5219 [(pc)]
5220 "
5221 {
5222 rtx lowword, highword;
5223 gcc_assert (MEM_P (operands[4]));
5224 highword = adjust_address (operands[4], SImode, 0);
5225 lowword = adjust_address (operands[4], SImode, 4);
5226 if (! WORDS_BIG_ENDIAN)
5227 {
5228 rtx tmp;
5229 tmp = highword; highword = lowword; lowword = tmp;
5230 }
5231
5232 emit_move_insn (lowword, operands[1]);
5233 emit_move_insn (highword, operands[2]);
5234 emit_move_insn (operands[5], operands[4]);
5235 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5236 DONE;
5237 }"
5238 [(set_attr "length" "20")])
5239
5240 (define_expand "fix_truncdfsi2"
5241 [(parallel [(set (match_operand:SI 0 "fix_trunc_dest_operand" "")
5242 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5243 (clobber (match_dup 2))
5244 (clobber (match_dup 3))])]
5245 "(TARGET_POWER2 || TARGET_POWERPC)
5246 && TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5247 "
5248 {
5249 if (TARGET_E500_DOUBLE)
5250 {
5251 emit_insn (gen_spe_fix_truncdfsi2 (operands[0], operands[1]));
5252 DONE;
5253 }
5254 operands[2] = gen_reg_rtx (DImode);
5255 if (TARGET_PPC_GFXOPT)
5256 {
5257 rtx orig_dest = operands[0];
5258 if (! memory_operand (orig_dest, GET_MODE (orig_dest)))
5259 operands[0] = assign_stack_temp (SImode, GET_MODE_SIZE (SImode), 0);
5260 emit_insn (gen_fix_truncdfsi2_internal_gfxopt (operands[0], operands[1],
5261 operands[2]));
5262 if (operands[0] != orig_dest)
5263 emit_move_insn (orig_dest, operands[0]);
5264 DONE;
5265 }
5266 operands[3] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5267 }")
5268
5269 (define_insn_and_split "*fix_truncdfsi2_internal"
5270 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5271 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
5272 (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
5273 (clobber (match_operand:DI 3 "memory_operand" "=o"))]
5274 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5275 "#"
5276 "&& (!no_new_pseudos || offsettable_nonstrict_memref_p (operands[3]))"
5277 [(pc)]
5278 "
5279 {
5280 rtx lowword;
5281 gcc_assert (MEM_P (operands[3]));
5282 lowword = adjust_address (operands[3], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
5283
5284 emit_insn (gen_fctiwz (operands[2], operands[1]));
5285 emit_move_insn (operands[3], operands[2]);
5286 emit_move_insn (operands[0], lowword);
5287 DONE;
5288 }"
5289 [(set_attr "length" "16")])
5290
5291 (define_insn_and_split "fix_truncdfsi2_internal_gfxopt"
5292 [(set (match_operand:SI 0 "memory_operand" "=Z")
5293 (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
5294 (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))]
5295 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS
5296 && TARGET_PPC_GFXOPT"
5297 "#"
5298 "&& 1"
5299 [(pc)]
5300 "
5301 {
5302 emit_insn (gen_fctiwz (operands[2], operands[1]));
5303 emit_insn (gen_stfiwx (operands[0], operands[2]));
5304 DONE;
5305 }"
5306 [(set_attr "length" "16")])
5307
5308 ; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] UNSPEC_FCTIWZ))
5309 ; rather than (set (subreg:SI (reg)) (fix:SI ...))
5310 ; because the first makes it clear that operand 0 is not live
5311 ; before the instruction.
5312 (define_insn "fctiwz"
5313 [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
5314 (unspec:DI [(fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))]
5315 UNSPEC_FCTIWZ))]
5316 "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5317 "{fcirz|fctiwz} %0,%1"
5318 [(set_attr "type" "fp")])
5319
5320 ; An UNSPEC is used so we don't have to support SImode in FP registers.
5321 (define_insn "stfiwx"
5322 [(set (match_operand:SI 0 "memory_operand" "=Z")
5323 (unspec:SI [(match_operand:DI 1 "gpc_reg_operand" "f")]
5324 UNSPEC_STFIWX))]
5325 "TARGET_PPC_GFXOPT"
5326 "stfiwx %1,%y0"
5327 [(set_attr "type" "fpstore")])
5328
5329 (define_expand "floatsisf2"
5330 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5331 (float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5332 "TARGET_HARD_FLOAT && !TARGET_FPRS"
5333 "")
5334
5335 (define_insn "floatdidf2"
5336 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5337 (float:DF (match_operand:DI 1 "gpc_reg_operand" "*f")))]
5338 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5339 "fcfid %0,%1"
5340 [(set_attr "type" "fp")])
5341
5342 (define_insn_and_split "floatsidf_ppc64"
5343 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5344 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5345 (clobber (match_operand:DI 2 "memory_operand" "=o"))
5346 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5347 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
5348 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5349 "#"
5350 "&& 1"
5351 [(set (match_dup 3) (sign_extend:DI (match_dup 1)))
5352 (set (match_dup 2) (match_dup 3))
5353 (set (match_dup 4) (match_dup 2))
5354 (set (match_dup 0) (float:DF (match_dup 4)))]
5355 "")
5356
5357 (define_insn_and_split "floatunssidf_ppc64"
5358 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5359 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5360 (clobber (match_operand:DI 2 "memory_operand" "=o"))
5361 (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5362 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
5363 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5364 "#"
5365 "&& 1"
5366 [(set (match_dup 3) (zero_extend:DI (match_dup 1)))
5367 (set (match_dup 2) (match_dup 3))
5368 (set (match_dup 4) (match_dup 2))
5369 (set (match_dup 0) (float:DF (match_dup 4)))]
5370 "")
5371
5372 (define_insn "fix_truncdfdi2"
5373 [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
5374 (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
5375 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5376 "fctidz %0,%1"
5377 [(set_attr "type" "fp")])
5378
5379 (define_expand "floatdisf2"
5380 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5381 (float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
5382 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5383 "
5384 {
5385 rtx val = operands[1];
5386 if (!flag_unsafe_math_optimizations)
5387 {
5388 rtx label = gen_label_rtx ();
5389 val = gen_reg_rtx (DImode);
5390 emit_insn (gen_floatdisf2_internal2 (val, operands[1], label));
5391 emit_label (label);
5392 }
5393 emit_insn (gen_floatdisf2_internal1 (operands[0], val));
5394 DONE;
5395 }")
5396
5397 ;; This is not IEEE compliant if rounding mode is "round to nearest".
5398 ;; If the DI->DF conversion is inexact, then it's possible to suffer
5399 ;; from double rounding.
5400 (define_insn_and_split "floatdisf2_internal1"
5401 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5402 (float:SF (match_operand:DI 1 "gpc_reg_operand" "*f")))
5403 (clobber (match_scratch:DF 2 "=f"))]
5404 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5405 "#"
5406 "&& reload_completed"
5407 [(set (match_dup 2)
5408 (float:DF (match_dup 1)))
5409 (set (match_dup 0)
5410 (float_truncate:SF (match_dup 2)))]
5411 "")
5412
5413 ;; Twiddles bits to avoid double rounding.
5414 ;; Bits that might be truncated when converting to DFmode are replaced
5415 ;; by a bit that won't be lost at that stage, but is below the SFmode
5416 ;; rounding position.
5417 (define_expand "floatdisf2_internal2"
5418 [(set (match_dup 3) (ashiftrt:DI (match_operand:DI 1 "" "")
5419 (const_int 53)))
5420 (parallel [(set (match_operand:DI 0 "" "") (and:DI (match_dup 1)
5421 (const_int 2047)))
5422 (clobber (scratch:CC))])
5423 (set (match_dup 3) (plus:DI (match_dup 3)
5424 (const_int 1)))
5425 (set (match_dup 0) (plus:DI (match_dup 0)
5426 (const_int 2047)))
5427 (set (match_dup 4) (compare:CCUNS (match_dup 3)
5428 (const_int 3)))
5429 (set (match_dup 0) (ior:DI (match_dup 0)
5430 (match_dup 1)))
5431 (parallel [(set (match_dup 0) (and:DI (match_dup 0)
5432 (const_int -2048)))
5433 (clobber (scratch:CC))])
5434 (set (pc) (if_then_else (geu (match_dup 4) (const_int 0))
5435 (label_ref (match_operand:DI 2 "" ""))
5436 (pc)))
5437 (set (match_dup 0) (match_dup 1))]
5438 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5439 "
5440 {
5441 operands[3] = gen_reg_rtx (DImode);
5442 operands[4] = gen_reg_rtx (CCUNSmode);
5443 }")
5444 \f
5445 ;; Define the DImode operations that can be done in a small number
5446 ;; of instructions. The & constraints are to prevent the register
5447 ;; allocator from allocating registers that overlap with the inputs
5448 ;; (for example, having an input in 7,8 and an output in 6,7). We
5449 ;; also allow for the output being the same as one of the inputs.
5450
5451 (define_insn "*adddi3_noppc64"
5452 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
5453 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
5454 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
5455 "! TARGET_POWERPC64"
5456 "*
5457 {
5458 if (WORDS_BIG_ENDIAN)
5459 return (GET_CODE (operands[2])) != CONST_INT
5460 ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
5461 : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
5462 else
5463 return (GET_CODE (operands[2])) != CONST_INT
5464 ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
5465 : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
5466 }"
5467 [(set_attr "type" "two")
5468 (set_attr "length" "8")])
5469
5470 (define_insn "*subdi3_noppc64"
5471 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
5472 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
5473 (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
5474 "! TARGET_POWERPC64"
5475 "*
5476 {
5477 if (WORDS_BIG_ENDIAN)
5478 return (GET_CODE (operands[1]) != CONST_INT)
5479 ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
5480 : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
5481 else
5482 return (GET_CODE (operands[1]) != CONST_INT)
5483 ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
5484 : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
5485 }"
5486 [(set_attr "type" "two")
5487 (set_attr "length" "8")])
5488
5489 (define_insn "*negdi2_noppc64"
5490 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5491 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
5492 "! TARGET_POWERPC64"
5493 "*
5494 {
5495 return (WORDS_BIG_ENDIAN)
5496 ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
5497 : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
5498 }"
5499 [(set_attr "type" "two")
5500 (set_attr "length" "8")])
5501
5502 (define_expand "mulsidi3"
5503 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5504 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5505 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5506 "! TARGET_POWERPC64"
5507 "
5508 {
5509 if (! TARGET_POWER && ! TARGET_POWERPC)
5510 {
5511 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5512 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
5513 emit_insn (gen_mull_call ());
5514 if (WORDS_BIG_ENDIAN)
5515 emit_move_insn (operands[0], gen_rtx_REG (DImode, 3));
5516 else
5517 {
5518 emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
5519 gen_rtx_REG (SImode, 3));
5520 emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
5521 gen_rtx_REG (SImode, 4));
5522 }
5523 DONE;
5524 }
5525 else if (TARGET_POWER)
5526 {
5527 emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
5528 DONE;
5529 }
5530 }")
5531
5532 (define_insn "mulsidi3_mq"
5533 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5534 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5535 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
5536 (clobber (match_scratch:SI 3 "=q"))]
5537 "TARGET_POWER"
5538 "mul %0,%1,%2\;mfmq %L0"
5539 [(set_attr "type" "imul")
5540 (set_attr "length" "8")])
5541
5542 (define_insn "*mulsidi3_no_mq"
5543 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5544 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5545 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
5546 "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5547 "*
5548 {
5549 return (WORDS_BIG_ENDIAN)
5550 ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
5551 : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
5552 }"
5553 [(set_attr "type" "imul")
5554 (set_attr "length" "8")])
5555
5556 (define_split
5557 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5558 (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5559 (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5560 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
5561 [(set (match_dup 3)
5562 (truncate:SI
5563 (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
5564 (sign_extend:DI (match_dup 2)))
5565 (const_int 32))))
5566 (set (match_dup 4)
5567 (mult:SI (match_dup 1)
5568 (match_dup 2)))]
5569 "
5570 {
5571 int endian = (WORDS_BIG_ENDIAN == 0);
5572 operands[3] = operand_subword (operands[0], endian, 0, DImode);
5573 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5574 }")
5575
5576 (define_expand "umulsidi3"
5577 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5578 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5579 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5580 "TARGET_POWERPC && ! TARGET_POWERPC64"
5581 "
5582 {
5583 if (TARGET_POWER)
5584 {
5585 emit_insn (gen_umulsidi3_mq (operands[0], operands[1], operands[2]));
5586 DONE;
5587 }
5588 }")
5589
5590 (define_insn "umulsidi3_mq"
5591 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5592 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5593 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
5594 (clobber (match_scratch:SI 3 "=q"))]
5595 "TARGET_POWERPC && TARGET_POWER"
5596 "*
5597 {
5598 return (WORDS_BIG_ENDIAN)
5599 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5600 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5601 }"
5602 [(set_attr "type" "imul")
5603 (set_attr "length" "8")])
5604
5605 (define_insn "*umulsidi3_no_mq"
5606 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5607 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5608 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
5609 "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5610 "*
5611 {
5612 return (WORDS_BIG_ENDIAN)
5613 ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5614 : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5615 }"
5616 [(set_attr "type" "imul")
5617 (set_attr "length" "8")])
5618
5619 (define_split
5620 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5621 (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5622 (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5623 "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
5624 [(set (match_dup 3)
5625 (truncate:SI
5626 (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
5627 (zero_extend:DI (match_dup 2)))
5628 (const_int 32))))
5629 (set (match_dup 4)
5630 (mult:SI (match_dup 1)
5631 (match_dup 2)))]
5632 "
5633 {
5634 int endian = (WORDS_BIG_ENDIAN == 0);
5635 operands[3] = operand_subword (operands[0], endian, 0, DImode);
5636 operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5637 }")
5638
5639 (define_expand "smulsi3_highpart"
5640 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5641 (truncate:SI
5642 (lshiftrt:DI (mult:DI (sign_extend:DI
5643 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5644 (sign_extend:DI
5645 (match_operand:SI 2 "gpc_reg_operand" "r")))
5646 (const_int 32))))]
5647 ""
5648 "
5649 {
5650 if (! TARGET_POWER && ! TARGET_POWERPC)
5651 {
5652 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5653 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
5654 emit_insn (gen_mulh_call ());
5655 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
5656 DONE;
5657 }
5658 else if (TARGET_POWER)
5659 {
5660 emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5661 DONE;
5662 }
5663 }")
5664
5665 (define_insn "smulsi3_highpart_mq"
5666 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5667 (truncate:SI
5668 (lshiftrt:DI (mult:DI (sign_extend:DI
5669 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5670 (sign_extend:DI
5671 (match_operand:SI 2 "gpc_reg_operand" "r")))
5672 (const_int 32))))
5673 (clobber (match_scratch:SI 3 "=q"))]
5674 "TARGET_POWER"
5675 "mul %0,%1,%2"
5676 [(set_attr "type" "imul")])
5677
5678 (define_insn "*smulsi3_highpart_no_mq"
5679 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5680 (truncate:SI
5681 (lshiftrt:DI (mult:DI (sign_extend:DI
5682 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5683 (sign_extend:DI
5684 (match_operand:SI 2 "gpc_reg_operand" "r")))
5685 (const_int 32))))]
5686 "TARGET_POWERPC && ! TARGET_POWER"
5687 "mulhw %0,%1,%2"
5688 [(set_attr "type" "imul")])
5689
5690 (define_expand "umulsi3_highpart"
5691 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5692 (truncate:SI
5693 (lshiftrt:DI (mult:DI (zero_extend:DI
5694 (match_operand:SI 1 "gpc_reg_operand" ""))
5695 (zero_extend:DI
5696 (match_operand:SI 2 "gpc_reg_operand" "")))
5697 (const_int 32))))]
5698 "TARGET_POWERPC"
5699 "
5700 {
5701 if (TARGET_POWER)
5702 {
5703 emit_insn (gen_umulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5704 DONE;
5705 }
5706 }")
5707
5708 (define_insn "umulsi3_highpart_mq"
5709 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5710 (truncate:SI
5711 (lshiftrt:DI (mult:DI (zero_extend:DI
5712 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5713 (zero_extend:DI
5714 (match_operand:SI 2 "gpc_reg_operand" "r")))
5715 (const_int 32))))
5716 (clobber (match_scratch:SI 3 "=q"))]
5717 "TARGET_POWERPC && TARGET_POWER"
5718 "mulhwu %0,%1,%2"
5719 [(set_attr "type" "imul")])
5720
5721 (define_insn "*umulsi3_highpart_no_mq"
5722 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5723 (truncate:SI
5724 (lshiftrt:DI (mult:DI (zero_extend:DI
5725 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5726 (zero_extend:DI
5727 (match_operand:SI 2 "gpc_reg_operand" "r")))
5728 (const_int 32))))]
5729 "TARGET_POWERPC && ! TARGET_POWER"
5730 "mulhwu %0,%1,%2"
5731 [(set_attr "type" "imul")])
5732
5733 ;; If operands 0 and 2 are in the same register, we have a problem. But
5734 ;; operands 0 and 1 (the usual case) can be in the same register. That's
5735 ;; why we have the strange constraints below.
5736 (define_insn "ashldi3_power"
5737 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
5738 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5739 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5740 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5741 "TARGET_POWER"
5742 "@
5743 {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
5744 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5745 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5746 sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
5747 [(set_attr "length" "8")])
5748
5749 (define_insn "lshrdi3_power"
5750 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
5751 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5752 (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5753 (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5754 "TARGET_POWER"
5755 "@
5756 {s%A2i|s%A2wi} %L0,%1,%h2\;{cal %0,0(0)|li %0,0}
5757 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5758 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5759 sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
5760 [(set_attr "length" "8")])
5761
5762 ;; Shift by a variable amount is too complex to be worth open-coding. We
5763 ;; just handle shifts by constants.
5764 (define_insn "ashrdi3_power"
5765 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5766 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5767 (match_operand:SI 2 "const_int_operand" "M,i")))
5768 (clobber (match_scratch:SI 3 "=X,q"))]
5769 "TARGET_POWER"
5770 "@
5771 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5772 sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
5773 [(set_attr "length" "8")])
5774
5775 (define_insn "ashrdi3_no_power"
5776 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
5777 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5778 (match_operand:SI 2 "const_int_operand" "M,i")))]
5779 "TARGET_32BIT && !TARGET_POWERPC64 && !TARGET_POWER && WORDS_BIG_ENDIAN"
5780 "@
5781 {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5782 {sri|srwi} %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;{srai|srawi} %0,%1,%h2"
5783 [(set_attr "type" "two,three")
5784 (set_attr "length" "8,12")])
5785
5786 (define_insn "*ashrdisi3_noppc64"
5787 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5788 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
5789 (const_int 32)) 4))]
5790 "TARGET_32BIT && !TARGET_POWERPC64"
5791 "*
5792 {
5793 if (REGNO (operands[0]) == REGNO (operands[1]))
5794 return \"\";
5795 else
5796 return \"mr %0,%1\";
5797 }"
5798 [(set_attr "length" "4")])
5799
5800 \f
5801 ;; PowerPC64 DImode operations.
5802
5803 (define_insn_and_split "absdi2"
5804 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5805 (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
5806 (clobber (match_scratch:DI 2 "=&r,&r"))]
5807 "TARGET_POWERPC64"
5808 "#"
5809 "&& reload_completed"
5810 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
5811 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
5812 (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
5813 "")
5814
5815 (define_insn_and_split "*nabsdi2"
5816 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5817 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
5818 (clobber (match_scratch:DI 2 "=&r,&r"))]
5819 "TARGET_POWERPC64"
5820 "#"
5821 "&& reload_completed"
5822 [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
5823 (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
5824 (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
5825 "")
5826
5827 (define_insn "muldi3"
5828 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5829 (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
5830 (match_operand:DI 2 "gpc_reg_operand" "r")))]
5831 "TARGET_POWERPC64"
5832 "mulld %0,%1,%2"
5833 [(set_attr "type" "lmul")])
5834
5835 (define_insn "*muldi3_internal1"
5836 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5837 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
5838 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
5839 (const_int 0)))
5840 (clobber (match_scratch:DI 3 "=r,r"))]
5841 "TARGET_POWERPC64"
5842 "@
5843 mulld. %3,%1,%2
5844 #"
5845 [(set_attr "type" "lmul_compare")
5846 (set_attr "length" "4,8")])
5847
5848 (define_split
5849 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5850 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
5851 (match_operand:DI 2 "gpc_reg_operand" ""))
5852 (const_int 0)))
5853 (clobber (match_scratch:DI 3 ""))]
5854 "TARGET_POWERPC64 && reload_completed"
5855 [(set (match_dup 3)
5856 (mult:DI (match_dup 1) (match_dup 2)))
5857 (set (match_dup 0)
5858 (compare:CC (match_dup 3)
5859 (const_int 0)))]
5860 "")
5861
5862 (define_insn "*muldi3_internal2"
5863 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
5864 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
5865 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
5866 (const_int 0)))
5867 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
5868 (mult:DI (match_dup 1) (match_dup 2)))]
5869 "TARGET_POWERPC64"
5870 "@
5871 mulld. %0,%1,%2
5872 #"
5873 [(set_attr "type" "lmul_compare")
5874 (set_attr "length" "4,8")])
5875
5876 (define_split
5877 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5878 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
5879 (match_operand:DI 2 "gpc_reg_operand" ""))
5880 (const_int 0)))
5881 (set (match_operand:DI 0 "gpc_reg_operand" "")
5882 (mult:DI (match_dup 1) (match_dup 2)))]
5883 "TARGET_POWERPC64 && reload_completed"
5884 [(set (match_dup 0)
5885 (mult:DI (match_dup 1) (match_dup 2)))
5886 (set (match_dup 3)
5887 (compare:CC (match_dup 0)
5888 (const_int 0)))]
5889 "")
5890
5891 (define_insn "smuldi3_highpart"
5892 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5893 (truncate:DI
5894 (lshiftrt:TI (mult:TI (sign_extend:TI
5895 (match_operand:DI 1 "gpc_reg_operand" "%r"))
5896 (sign_extend:TI
5897 (match_operand:DI 2 "gpc_reg_operand" "r")))
5898 (const_int 64))))]
5899 "TARGET_POWERPC64"
5900 "mulhd %0,%1,%2"
5901 [(set_attr "type" "lmul")])
5902
5903 (define_insn "umuldi3_highpart"
5904 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5905 (truncate:DI
5906 (lshiftrt:TI (mult:TI (zero_extend:TI
5907 (match_operand:DI 1 "gpc_reg_operand" "%r"))
5908 (zero_extend:TI
5909 (match_operand:DI 2 "gpc_reg_operand" "r")))
5910 (const_int 64))))]
5911 "TARGET_POWERPC64"
5912 "mulhdu %0,%1,%2"
5913 [(set_attr "type" "lmul")])
5914
5915 (define_insn "rotldi3"
5916 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5917 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
5918 (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
5919 "TARGET_POWERPC64"
5920 "rld%I2cl %0,%1,%H2,0")
5921
5922 (define_insn "*rotldi3_internal2"
5923 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5924 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5925 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
5926 (const_int 0)))
5927 (clobber (match_scratch:DI 3 "=r,r"))]
5928 "TARGET_64BIT"
5929 "@
5930 rld%I2cl. %3,%1,%H2,0
5931 #"
5932 [(set_attr "type" "delayed_compare")
5933 (set_attr "length" "4,8")])
5934
5935 (define_split
5936 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5937 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
5938 (match_operand:DI 2 "reg_or_cint_operand" ""))
5939 (const_int 0)))
5940 (clobber (match_scratch:DI 3 ""))]
5941 "TARGET_POWERPC64 && reload_completed"
5942 [(set (match_dup 3)
5943 (rotate:DI (match_dup 1) (match_dup 2)))
5944 (set (match_dup 0)
5945 (compare:CC (match_dup 3)
5946 (const_int 0)))]
5947 "")
5948
5949 (define_insn "*rotldi3_internal3"
5950 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
5951 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5952 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
5953 (const_int 0)))
5954 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
5955 (rotate:DI (match_dup 1) (match_dup 2)))]
5956 "TARGET_64BIT"
5957 "@
5958 rld%I2cl. %0,%1,%H2,0
5959 #"
5960 [(set_attr "type" "delayed_compare")
5961 (set_attr "length" "4,8")])
5962
5963 (define_split
5964 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5965 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
5966 (match_operand:DI 2 "reg_or_cint_operand" ""))
5967 (const_int 0)))
5968 (set (match_operand:DI 0 "gpc_reg_operand" "")
5969 (rotate:DI (match_dup 1) (match_dup 2)))]
5970 "TARGET_POWERPC64 && reload_completed"
5971 [(set (match_dup 0)
5972 (rotate:DI (match_dup 1) (match_dup 2)))
5973 (set (match_dup 3)
5974 (compare:CC (match_dup 0)
5975 (const_int 0)))]
5976 "")
5977
5978 (define_insn "*rotldi3_internal4"
5979 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5980 (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
5981 (match_operand:DI 2 "reg_or_cint_operand" "ri"))
5982 (match_operand:DI 3 "mask_operand" "n")))]
5983 "TARGET_POWERPC64"
5984 "rld%I2c%B3 %0,%1,%H2,%S3")
5985
5986 (define_insn "*rotldi3_internal5"
5987 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5988 (compare:CC (and:DI
5989 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5990 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
5991 (match_operand:DI 3 "mask_operand" "n,n"))
5992 (const_int 0)))
5993 (clobber (match_scratch:DI 4 "=r,r"))]
5994 "TARGET_64BIT"
5995 "@
5996 rld%I2c%B3. %4,%1,%H2,%S3
5997 #"
5998 [(set_attr "type" "delayed_compare")
5999 (set_attr "length" "4,8")])
6000
6001 (define_split
6002 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6003 (compare:CC (and:DI
6004 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6005 (match_operand:DI 2 "reg_or_cint_operand" ""))
6006 (match_operand:DI 3 "mask_operand" ""))
6007 (const_int 0)))
6008 (clobber (match_scratch:DI 4 ""))]
6009 "TARGET_POWERPC64 && reload_completed"
6010 [(set (match_dup 4)
6011 (and:DI (rotate:DI (match_dup 1)
6012 (match_dup 2))
6013 (match_dup 3)))
6014 (set (match_dup 0)
6015 (compare:CC (match_dup 4)
6016 (const_int 0)))]
6017 "")
6018
6019 (define_insn "*rotldi3_internal6"
6020 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6021 (compare:CC (and:DI
6022 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6023 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6024 (match_operand:DI 3 "mask_operand" "n,n"))
6025 (const_int 0)))
6026 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6027 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6028 "TARGET_64BIT"
6029 "@
6030 rld%I2c%B3. %0,%1,%H2,%S3
6031 #"
6032 [(set_attr "type" "delayed_compare")
6033 (set_attr "length" "4,8")])
6034
6035 (define_split
6036 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6037 (compare:CC (and:DI
6038 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6039 (match_operand:DI 2 "reg_or_cint_operand" ""))
6040 (match_operand:DI 3 "mask_operand" ""))
6041 (const_int 0)))
6042 (set (match_operand:DI 0 "gpc_reg_operand" "")
6043 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6044 "TARGET_POWERPC64 && reload_completed"
6045 [(set (match_dup 0)
6046 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6047 (set (match_dup 4)
6048 (compare:CC (match_dup 0)
6049 (const_int 0)))]
6050 "")
6051
6052 (define_insn "*rotldi3_internal7"
6053 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6054 (zero_extend:DI
6055 (subreg:QI
6056 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6057 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6058 "TARGET_POWERPC64"
6059 "rld%I2cl %0,%1,%H2,56")
6060
6061 (define_insn "*rotldi3_internal8"
6062 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6063 (compare:CC (zero_extend:DI
6064 (subreg:QI
6065 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6066 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6067 (const_int 0)))
6068 (clobber (match_scratch:DI 3 "=r,r"))]
6069 "TARGET_64BIT"
6070 "@
6071 rld%I2cl. %3,%1,%H2,56
6072 #"
6073 [(set_attr "type" "delayed_compare")
6074 (set_attr "length" "4,8")])
6075
6076 (define_split
6077 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6078 (compare:CC (zero_extend:DI
6079 (subreg:QI
6080 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6081 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6082 (const_int 0)))
6083 (clobber (match_scratch:DI 3 ""))]
6084 "TARGET_POWERPC64 && reload_completed"
6085 [(set (match_dup 3)
6086 (zero_extend:DI (subreg:QI
6087 (rotate:DI (match_dup 1)
6088 (match_dup 2)) 0)))
6089 (set (match_dup 0)
6090 (compare:CC (match_dup 3)
6091 (const_int 0)))]
6092 "")
6093
6094 (define_insn "*rotldi3_internal9"
6095 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6096 (compare:CC (zero_extend:DI
6097 (subreg:QI
6098 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6099 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6100 (const_int 0)))
6101 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6102 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6103 "TARGET_64BIT"
6104 "@
6105 rld%I2cl. %0,%1,%H2,56
6106 #"
6107 [(set_attr "type" "delayed_compare")
6108 (set_attr "length" "4,8")])
6109
6110 (define_split
6111 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6112 (compare:CC (zero_extend:DI
6113 (subreg:QI
6114 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6115 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6116 (const_int 0)))
6117 (set (match_operand:DI 0 "gpc_reg_operand" "")
6118 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6119 "TARGET_POWERPC64 && reload_completed"
6120 [(set (match_dup 0)
6121 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6122 (set (match_dup 3)
6123 (compare:CC (match_dup 0)
6124 (const_int 0)))]
6125 "")
6126
6127 (define_insn "*rotldi3_internal10"
6128 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6129 (zero_extend:DI
6130 (subreg:HI
6131 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6132 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6133 "TARGET_POWERPC64"
6134 "rld%I2cl %0,%1,%H2,48")
6135
6136 (define_insn "*rotldi3_internal11"
6137 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6138 (compare:CC (zero_extend:DI
6139 (subreg:HI
6140 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6141 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6142 (const_int 0)))
6143 (clobber (match_scratch:DI 3 "=r,r"))]
6144 "TARGET_64BIT"
6145 "@
6146 rld%I2cl. %3,%1,%H2,48
6147 #"
6148 [(set_attr "type" "delayed_compare")
6149 (set_attr "length" "4,8")])
6150
6151 (define_split
6152 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6153 (compare:CC (zero_extend:DI
6154 (subreg:HI
6155 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6156 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6157 (const_int 0)))
6158 (clobber (match_scratch:DI 3 ""))]
6159 "TARGET_POWERPC64 && reload_completed"
6160 [(set (match_dup 3)
6161 (zero_extend:DI (subreg:HI
6162 (rotate:DI (match_dup 1)
6163 (match_dup 2)) 0)))
6164 (set (match_dup 0)
6165 (compare:CC (match_dup 3)
6166 (const_int 0)))]
6167 "")
6168
6169 (define_insn "*rotldi3_internal12"
6170 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6171 (compare:CC (zero_extend:DI
6172 (subreg:HI
6173 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6174 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6175 (const_int 0)))
6176 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6177 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6178 "TARGET_64BIT"
6179 "@
6180 rld%I2cl. %0,%1,%H2,48
6181 #"
6182 [(set_attr "type" "delayed_compare")
6183 (set_attr "length" "4,8")])
6184
6185 (define_split
6186 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6187 (compare:CC (zero_extend:DI
6188 (subreg:HI
6189 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6190 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6191 (const_int 0)))
6192 (set (match_operand:DI 0 "gpc_reg_operand" "")
6193 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6194 "TARGET_POWERPC64 && reload_completed"
6195 [(set (match_dup 0)
6196 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6197 (set (match_dup 3)
6198 (compare:CC (match_dup 0)
6199 (const_int 0)))]
6200 "")
6201
6202 (define_insn "*rotldi3_internal13"
6203 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6204 (zero_extend:DI
6205 (subreg:SI
6206 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6207 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6208 "TARGET_POWERPC64"
6209 "rld%I2cl %0,%1,%H2,32")
6210
6211 (define_insn "*rotldi3_internal14"
6212 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6213 (compare:CC (zero_extend:DI
6214 (subreg:SI
6215 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6216 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6217 (const_int 0)))
6218 (clobber (match_scratch:DI 3 "=r,r"))]
6219 "TARGET_64BIT"
6220 "@
6221 rld%I2cl. %3,%1,%H2,32
6222 #"
6223 [(set_attr "type" "delayed_compare")
6224 (set_attr "length" "4,8")])
6225
6226 (define_split
6227 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6228 (compare:CC (zero_extend:DI
6229 (subreg:SI
6230 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6231 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6232 (const_int 0)))
6233 (clobber (match_scratch:DI 3 ""))]
6234 "TARGET_POWERPC64 && reload_completed"
6235 [(set (match_dup 3)
6236 (zero_extend:DI (subreg:SI
6237 (rotate:DI (match_dup 1)
6238 (match_dup 2)) 0)))
6239 (set (match_dup 0)
6240 (compare:CC (match_dup 3)
6241 (const_int 0)))]
6242 "")
6243
6244 (define_insn "*rotldi3_internal15"
6245 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6246 (compare:CC (zero_extend:DI
6247 (subreg:SI
6248 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6249 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6250 (const_int 0)))
6251 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6252 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6253 "TARGET_64BIT"
6254 "@
6255 rld%I2cl. %0,%1,%H2,32
6256 #"
6257 [(set_attr "type" "delayed_compare")
6258 (set_attr "length" "4,8")])
6259
6260 (define_split
6261 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6262 (compare:CC (zero_extend:DI
6263 (subreg:SI
6264 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6265 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6266 (const_int 0)))
6267 (set (match_operand:DI 0 "gpc_reg_operand" "")
6268 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6269 "TARGET_POWERPC64 && reload_completed"
6270 [(set (match_dup 0)
6271 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6272 (set (match_dup 3)
6273 (compare:CC (match_dup 0)
6274 (const_int 0)))]
6275 "")
6276
6277 (define_expand "ashldi3"
6278 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6279 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6280 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6281 "TARGET_POWERPC64 || TARGET_POWER"
6282 "
6283 {
6284 if (TARGET_POWERPC64)
6285 ;
6286 else if (TARGET_POWER)
6287 {
6288 emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
6289 DONE;
6290 }
6291 else
6292 FAIL;
6293 }")
6294
6295 (define_insn "*ashldi3_internal1"
6296 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6297 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6298 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6299 "TARGET_POWERPC64"
6300 "sld%I2 %0,%1,%H2")
6301
6302 (define_insn "*ashldi3_internal2"
6303 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6304 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6305 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6306 (const_int 0)))
6307 (clobber (match_scratch:DI 3 "=r,r"))]
6308 "TARGET_64BIT"
6309 "@
6310 sld%I2. %3,%1,%H2
6311 #"
6312 [(set_attr "type" "delayed_compare")
6313 (set_attr "length" "4,8")])
6314
6315 (define_split
6316 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6317 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6318 (match_operand:SI 2 "reg_or_cint_operand" ""))
6319 (const_int 0)))
6320 (clobber (match_scratch:DI 3 ""))]
6321 "TARGET_POWERPC64 && reload_completed"
6322 [(set (match_dup 3)
6323 (ashift:DI (match_dup 1) (match_dup 2)))
6324 (set (match_dup 0)
6325 (compare:CC (match_dup 3)
6326 (const_int 0)))]
6327 "")
6328
6329 (define_insn "*ashldi3_internal3"
6330 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6331 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6332 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6333 (const_int 0)))
6334 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6335 (ashift:DI (match_dup 1) (match_dup 2)))]
6336 "TARGET_64BIT"
6337 "@
6338 sld%I2. %0,%1,%H2
6339 #"
6340 [(set_attr "type" "delayed_compare")
6341 (set_attr "length" "4,8")])
6342
6343 (define_split
6344 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6345 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6346 (match_operand:SI 2 "reg_or_cint_operand" ""))
6347 (const_int 0)))
6348 (set (match_operand:DI 0 "gpc_reg_operand" "")
6349 (ashift:DI (match_dup 1) (match_dup 2)))]
6350 "TARGET_POWERPC64 && reload_completed"
6351 [(set (match_dup 0)
6352 (ashift:DI (match_dup 1) (match_dup 2)))
6353 (set (match_dup 3)
6354 (compare:CC (match_dup 0)
6355 (const_int 0)))]
6356 "")
6357
6358 (define_insn "*ashldi3_internal4"
6359 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6360 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6361 (match_operand:SI 2 "const_int_operand" "i"))
6362 (match_operand:DI 3 "const_int_operand" "n")))]
6363 "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6364 "rldic %0,%1,%H2,%W3")
6365
6366 (define_insn "ashldi3_internal5"
6367 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6368 (compare:CC
6369 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6370 (match_operand:SI 2 "const_int_operand" "i,i"))
6371 (match_operand:DI 3 "const_int_operand" "n,n"))
6372 (const_int 0)))
6373 (clobber (match_scratch:DI 4 "=r,r"))]
6374 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
6375 "@
6376 rldic. %4,%1,%H2,%W3
6377 #"
6378 [(set_attr "type" "delayed_compare")
6379 (set_attr "length" "4,8")])
6380
6381 (define_split
6382 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6383 (compare:CC
6384 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6385 (match_operand:SI 2 "const_int_operand" ""))
6386 (match_operand:DI 3 "const_int_operand" ""))
6387 (const_int 0)))
6388 (clobber (match_scratch:DI 4 ""))]
6389 "TARGET_POWERPC64 && reload_completed
6390 && includes_rldic_lshift_p (operands[2], operands[3])"
6391 [(set (match_dup 4)
6392 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6393 (match_dup 3)))
6394 (set (match_dup 0)
6395 (compare:CC (match_dup 4)
6396 (const_int 0)))]
6397 "")
6398
6399 (define_insn "*ashldi3_internal6"
6400 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6401 (compare:CC
6402 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6403 (match_operand:SI 2 "const_int_operand" "i,i"))
6404 (match_operand:DI 3 "const_int_operand" "n,n"))
6405 (const_int 0)))
6406 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6407 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6408 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
6409 "@
6410 rldic. %0,%1,%H2,%W3
6411 #"
6412 [(set_attr "type" "delayed_compare")
6413 (set_attr "length" "4,8")])
6414
6415 (define_split
6416 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6417 (compare:CC
6418 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6419 (match_operand:SI 2 "const_int_operand" ""))
6420 (match_operand:DI 3 "const_int_operand" ""))
6421 (const_int 0)))
6422 (set (match_operand:DI 0 "gpc_reg_operand" "")
6423 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6424 "TARGET_POWERPC64 && reload_completed
6425 && includes_rldic_lshift_p (operands[2], operands[3])"
6426 [(set (match_dup 0)
6427 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6428 (match_dup 3)))
6429 (set (match_dup 4)
6430 (compare:CC (match_dup 0)
6431 (const_int 0)))]
6432 "")
6433
6434 (define_insn "*ashldi3_internal7"
6435 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6436 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6437 (match_operand:SI 2 "const_int_operand" "i"))
6438 (match_operand:DI 3 "mask_operand" "n")))]
6439 "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
6440 "rldicr %0,%1,%H2,%S3")
6441
6442 (define_insn "ashldi3_internal8"
6443 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6444 (compare:CC
6445 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6446 (match_operand:SI 2 "const_int_operand" "i,i"))
6447 (match_operand:DI 3 "mask_operand" "n,n"))
6448 (const_int 0)))
6449 (clobber (match_scratch:DI 4 "=r,r"))]
6450 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
6451 "@
6452 rldicr. %4,%1,%H2,%S3
6453 #"
6454 [(set_attr "type" "delayed_compare")
6455 (set_attr "length" "4,8")])
6456
6457 (define_split
6458 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6459 (compare:CC
6460 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6461 (match_operand:SI 2 "const_int_operand" ""))
6462 (match_operand:DI 3 "mask_operand" ""))
6463 (const_int 0)))
6464 (clobber (match_scratch:DI 4 ""))]
6465 "TARGET_POWERPC64 && reload_completed
6466 && includes_rldicr_lshift_p (operands[2], operands[3])"
6467 [(set (match_dup 4)
6468 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6469 (match_dup 3)))
6470 (set (match_dup 0)
6471 (compare:CC (match_dup 4)
6472 (const_int 0)))]
6473 "")
6474
6475 (define_insn "*ashldi3_internal9"
6476 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6477 (compare:CC
6478 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6479 (match_operand:SI 2 "const_int_operand" "i,i"))
6480 (match_operand:DI 3 "mask_operand" "n,n"))
6481 (const_int 0)))
6482 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6483 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6484 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
6485 "@
6486 rldicr. %0,%1,%H2,%S3
6487 #"
6488 [(set_attr "type" "delayed_compare")
6489 (set_attr "length" "4,8")])
6490
6491 (define_split
6492 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6493 (compare:CC
6494 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6495 (match_operand:SI 2 "const_int_operand" ""))
6496 (match_operand:DI 3 "mask_operand" ""))
6497 (const_int 0)))
6498 (set (match_operand:DI 0 "gpc_reg_operand" "")
6499 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6500 "TARGET_POWERPC64 && reload_completed
6501 && includes_rldicr_lshift_p (operands[2], operands[3])"
6502 [(set (match_dup 0)
6503 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6504 (match_dup 3)))
6505 (set (match_dup 4)
6506 (compare:CC (match_dup 0)
6507 (const_int 0)))]
6508 "")
6509
6510 (define_expand "lshrdi3"
6511 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6512 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6513 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6514 "TARGET_POWERPC64 || TARGET_POWER"
6515 "
6516 {
6517 if (TARGET_POWERPC64)
6518 ;
6519 else if (TARGET_POWER)
6520 {
6521 emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
6522 DONE;
6523 }
6524 else
6525 FAIL;
6526 }")
6527
6528 (define_insn "*lshrdi3_internal1"
6529 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6530 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6531 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6532 "TARGET_POWERPC64"
6533 "srd%I2 %0,%1,%H2")
6534
6535 (define_insn "*lshrdi3_internal2"
6536 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6537 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6538 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6539 (const_int 0)))
6540 (clobber (match_scratch:DI 3 "=r,r"))]
6541 "TARGET_64BIT "
6542 "@
6543 srd%I2. %3,%1,%H2
6544 #"
6545 [(set_attr "type" "delayed_compare")
6546 (set_attr "length" "4,8")])
6547
6548 (define_split
6549 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6550 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6551 (match_operand:SI 2 "reg_or_cint_operand" ""))
6552 (const_int 0)))
6553 (clobber (match_scratch:DI 3 ""))]
6554 "TARGET_POWERPC64 && reload_completed"
6555 [(set (match_dup 3)
6556 (lshiftrt:DI (match_dup 1) (match_dup 2)))
6557 (set (match_dup 0)
6558 (compare:CC (match_dup 3)
6559 (const_int 0)))]
6560 "")
6561
6562 (define_insn "*lshrdi3_internal3"
6563 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6564 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6565 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6566 (const_int 0)))
6567 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6568 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
6569 "TARGET_64BIT"
6570 "@
6571 srd%I2. %0,%1,%H2
6572 #"
6573 [(set_attr "type" "delayed_compare")
6574 (set_attr "length" "4,8")])
6575
6576 (define_split
6577 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6578 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6579 (match_operand:SI 2 "reg_or_cint_operand" ""))
6580 (const_int 0)))
6581 (set (match_operand:DI 0 "gpc_reg_operand" "")
6582 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
6583 "TARGET_POWERPC64 && reload_completed"
6584 [(set (match_dup 0)
6585 (lshiftrt:DI (match_dup 1) (match_dup 2)))
6586 (set (match_dup 3)
6587 (compare:CC (match_dup 0)
6588 (const_int 0)))]
6589 "")
6590
6591 (define_expand "ashrdi3"
6592 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6593 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6594 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6595 "WORDS_BIG_ENDIAN"
6596 "
6597 {
6598 if (TARGET_POWERPC64)
6599 ;
6600 else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
6601 {
6602 emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
6603 DONE;
6604 }
6605 else if (TARGET_32BIT && GET_CODE (operands[2]) == CONST_INT
6606 && WORDS_BIG_ENDIAN)
6607 {
6608 emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
6609 DONE;
6610 }
6611 else
6612 FAIL;
6613 }")
6614
6615 (define_insn "*ashrdi3_internal1"
6616 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6617 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6618 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6619 "TARGET_POWERPC64"
6620 "srad%I2 %0,%1,%H2")
6621
6622 (define_insn "*ashrdi3_internal2"
6623 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6624 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6625 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6626 (const_int 0)))
6627 (clobber (match_scratch:DI 3 "=r,r"))]
6628 "TARGET_64BIT"
6629 "@
6630 srad%I2. %3,%1,%H2
6631 #"
6632 [(set_attr "type" "delayed_compare")
6633 (set_attr "length" "4,8")])
6634
6635 (define_split
6636 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6637 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6638 (match_operand:SI 2 "reg_or_cint_operand" ""))
6639 (const_int 0)))
6640 (clobber (match_scratch:DI 3 ""))]
6641 "TARGET_POWERPC64 && reload_completed"
6642 [(set (match_dup 3)
6643 (ashiftrt:DI (match_dup 1) (match_dup 2)))
6644 (set (match_dup 0)
6645 (compare:CC (match_dup 3)
6646 (const_int 0)))]
6647 "")
6648
6649 (define_insn "*ashrdi3_internal3"
6650 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6651 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6652 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6653 (const_int 0)))
6654 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6655 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6656 "TARGET_64BIT"
6657 "@
6658 srad%I2. %0,%1,%H2
6659 #"
6660 [(set_attr "type" "delayed_compare")
6661 (set_attr "length" "4,8")])
6662
6663 (define_split
6664 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6665 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6666 (match_operand:SI 2 "reg_or_cint_operand" ""))
6667 (const_int 0)))
6668 (set (match_operand:DI 0 "gpc_reg_operand" "")
6669 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6670 "TARGET_POWERPC64 && reload_completed"
6671 [(set (match_dup 0)
6672 (ashiftrt:DI (match_dup 1) (match_dup 2)))
6673 (set (match_dup 3)
6674 (compare:CC (match_dup 0)
6675 (const_int 0)))]
6676 "")
6677
6678 (define_insn "anddi3"
6679 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
6680 (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r")
6681 (match_operand:DI 2 "and64_2_operand" "?r,S,T,K,J,t")))
6682 (clobber (match_scratch:CC 3 "=X,X,X,x,x,X"))]
6683 "TARGET_POWERPC64"
6684 "@
6685 and %0,%1,%2
6686 rldic%B2 %0,%1,0,%S2
6687 rlwinm %0,%1,0,%m2,%M2
6688 andi. %0,%1,%b2
6689 andis. %0,%1,%u2
6690 #"
6691 [(set_attr "type" "*,*,*,compare,compare,*")
6692 (set_attr "length" "4,4,4,4,4,8")])
6693
6694 (define_split
6695 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6696 (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
6697 (match_operand:DI 2 "mask64_2_operand" "")))
6698 (clobber (match_scratch:CC 3 ""))]
6699 "TARGET_POWERPC64
6700 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
6701 && !mask_operand (operands[2], DImode)"
6702 [(set (match_dup 0)
6703 (and:DI (rotate:DI (match_dup 1)
6704 (match_dup 4))
6705 (match_dup 5)))
6706 (set (match_dup 0)
6707 (and:DI (rotate:DI (match_dup 0)
6708 (match_dup 6))
6709 (match_dup 7)))]
6710 {
6711 build_mask64_2_operands (operands[2], &operands[4]);
6712 })
6713
6714 (define_insn "*anddi3_internal2"
6715 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
6716 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
6717 (match_operand:DI 2 "and64_2_operand" "r,S,K,J,t,r,S,K,J,t"))
6718 (const_int 0)))
6719 (clobber (match_scratch:DI 3 "=r,r,r,r,r,r,r,r,r,r"))
6720 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
6721 "TARGET_64BIT"
6722 "@
6723 and. %3,%1,%2
6724 rldic%B2. %3,%1,0,%S2
6725 andi. %3,%1,%b2
6726 andis. %3,%1,%u2
6727 #
6728 #
6729 #
6730 #
6731 #
6732 #"
6733 [(set_attr "type" "compare,delayed_compare,compare,compare,delayed_compare,compare,compare,compare,compare,compare")
6734 (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
6735
6736 (define_split
6737 [(set (match_operand:CC 0 "cc_reg_operand" "")
6738 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
6739 (match_operand:DI 2 "mask64_2_operand" ""))
6740 (const_int 0)))
6741 (clobber (match_scratch:DI 3 ""))
6742 (clobber (match_scratch:CC 4 ""))]
6743 "TARGET_POWERPC64 && reload_completed
6744 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
6745 && !mask_operand (operands[2], DImode)"
6746 [(set (match_dup 3)
6747 (and:DI (rotate:DI (match_dup 1)
6748 (match_dup 5))
6749 (match_dup 6)))
6750 (parallel [(set (match_dup 0)
6751 (compare:CC (and:DI (rotate:DI (match_dup 3)
6752 (match_dup 7))
6753 (match_dup 8))
6754 (const_int 0)))
6755 (clobber (match_dup 3))])]
6756 "
6757 {
6758 build_mask64_2_operands (operands[2], &operands[5]);
6759 }")
6760
6761 (define_insn "*anddi3_internal3"
6762 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
6763 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
6764 (match_operand:DI 2 "and64_2_operand" "r,S,K,J,t,r,S,K,J,t"))
6765 (const_int 0)))
6766 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
6767 (and:DI (match_dup 1) (match_dup 2)))
6768 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
6769 "TARGET_64BIT"
6770 "@
6771 and. %0,%1,%2
6772 rldic%B2. %0,%1,0,%S2
6773 andi. %0,%1,%b2
6774 andis. %0,%1,%u2
6775 #
6776 #
6777 #
6778 #
6779 #
6780 #"
6781 [(set_attr "type" "compare,delayed_compare,compare,compare,delayed_compare,compare,compare,compare,compare,compare")
6782 (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
6783
6784 (define_split
6785 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6786 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
6787 (match_operand:DI 2 "and_operand" ""))
6788 (const_int 0)))
6789 (set (match_operand:DI 0 "gpc_reg_operand" "")
6790 (and:DI (match_dup 1) (match_dup 2)))
6791 (clobber (match_scratch:CC 4 ""))]
6792 "TARGET_POWERPC64 && reload_completed"
6793 [(parallel [(set (match_dup 0)
6794 (and:DI (match_dup 1) (match_dup 2)))
6795 (clobber (match_dup 4))])
6796 (set (match_dup 3)
6797 (compare:CC (match_dup 0)
6798 (const_int 0)))]
6799 "")
6800
6801 (define_split
6802 [(set (match_operand:CC 3 "cc_reg_operand" "")
6803 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
6804 (match_operand:DI 2 "mask64_2_operand" ""))
6805 (const_int 0)))
6806 (set (match_operand:DI 0 "gpc_reg_operand" "")
6807 (and:DI (match_dup 1) (match_dup 2)))
6808 (clobber (match_scratch:CC 4 ""))]
6809 "TARGET_POWERPC64 && reload_completed
6810 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
6811 && !mask_operand (operands[2], DImode)"
6812 [(set (match_dup 0)
6813 (and:DI (rotate:DI (match_dup 1)
6814 (match_dup 5))
6815 (match_dup 6)))
6816 (parallel [(set (match_dup 3)
6817 (compare:CC (and:DI (rotate:DI (match_dup 0)
6818 (match_dup 7))
6819 (match_dup 8))
6820 (const_int 0)))
6821 (set (match_dup 0)
6822 (and:DI (rotate:DI (match_dup 0)
6823 (match_dup 7))
6824 (match_dup 8)))])]
6825 "
6826 {
6827 build_mask64_2_operands (operands[2], &operands[5]);
6828 }")
6829
6830 (define_expand "iordi3"
6831 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6832 (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
6833 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
6834 "TARGET_POWERPC64"
6835 "
6836 {
6837 if (non_logical_cint_operand (operands[2], DImode))
6838 {
6839 HOST_WIDE_INT value;
6840 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
6841 ? operands[0] : gen_reg_rtx (DImode));
6842
6843 if (GET_CODE (operands[2]) == CONST_INT)
6844 {
6845 value = INTVAL (operands[2]);
6846 emit_insn (gen_iordi3 (tmp, operands[1],
6847 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
6848 }
6849 else
6850 {
6851 value = CONST_DOUBLE_LOW (operands[2]);
6852 emit_insn (gen_iordi3 (tmp, operands[1],
6853 immed_double_const (value
6854 & (~ (HOST_WIDE_INT) 0xffff),
6855 0, DImode)));
6856 }
6857
6858 emit_insn (gen_iordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
6859 DONE;
6860 }
6861 }")
6862
6863 (define_expand "xordi3"
6864 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6865 (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
6866 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
6867 "TARGET_POWERPC64"
6868 "
6869 {
6870 if (non_logical_cint_operand (operands[2], DImode))
6871 {
6872 HOST_WIDE_INT value;
6873 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
6874 ? operands[0] : gen_reg_rtx (DImode));
6875
6876 if (GET_CODE (operands[2]) == CONST_INT)
6877 {
6878 value = INTVAL (operands[2]);
6879 emit_insn (gen_xordi3 (tmp, operands[1],
6880 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
6881 }
6882 else
6883 {
6884 value = CONST_DOUBLE_LOW (operands[2]);
6885 emit_insn (gen_xordi3 (tmp, operands[1],
6886 immed_double_const (value
6887 & (~ (HOST_WIDE_INT) 0xffff),
6888 0, DImode)));
6889 }
6890
6891 emit_insn (gen_xordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
6892 DONE;
6893 }
6894 }")
6895
6896 (define_insn "*booldi3_internal1"
6897 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
6898 (match_operator:DI 3 "boolean_or_operator"
6899 [(match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
6900 (match_operand:DI 2 "logical_operand" "r,K,JF")]))]
6901 "TARGET_POWERPC64"
6902 "@
6903 %q3 %0,%1,%2
6904 %q3i %0,%1,%b2
6905 %q3is %0,%1,%u2")
6906
6907 (define_insn "*booldi3_internal2"
6908 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6909 (compare:CC (match_operator:DI 4 "boolean_or_operator"
6910 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
6911 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
6912 (const_int 0)))
6913 (clobber (match_scratch:DI 3 "=r,r"))]
6914 "TARGET_64BIT"
6915 "@
6916 %q4. %3,%1,%2
6917 #"
6918 [(set_attr "type" "compare")
6919 (set_attr "length" "4,8")])
6920
6921 (define_split
6922 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6923 (compare:CC (match_operator:DI 4 "boolean_operator"
6924 [(match_operand:DI 1 "gpc_reg_operand" "")
6925 (match_operand:DI 2 "gpc_reg_operand" "")])
6926 (const_int 0)))
6927 (clobber (match_scratch:DI 3 ""))]
6928 "TARGET_POWERPC64 && reload_completed"
6929 [(set (match_dup 3) (match_dup 4))
6930 (set (match_dup 0)
6931 (compare:CC (match_dup 3)
6932 (const_int 0)))]
6933 "")
6934
6935 (define_insn "*booldi3_internal3"
6936 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6937 (compare:CC (match_operator:DI 4 "boolean_operator"
6938 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
6939 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
6940 (const_int 0)))
6941 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6942 (match_dup 4))]
6943 "TARGET_64BIT"
6944 "@
6945 %q4. %0,%1,%2
6946 #"
6947 [(set_attr "type" "compare")
6948 (set_attr "length" "4,8")])
6949
6950 (define_split
6951 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6952 (compare:CC (match_operator:DI 4 "boolean_operator"
6953 [(match_operand:DI 1 "gpc_reg_operand" "")
6954 (match_operand:DI 2 "gpc_reg_operand" "")])
6955 (const_int 0)))
6956 (set (match_operand:DI 0 "gpc_reg_operand" "")
6957 (match_dup 4))]
6958 "TARGET_POWERPC64 && reload_completed"
6959 [(set (match_dup 0) (match_dup 4))
6960 (set (match_dup 3)
6961 (compare:CC (match_dup 0)
6962 (const_int 0)))]
6963 "")
6964
6965 ;; Split a logical operation that we can't do in one insn into two insns,
6966 ;; each of which does one 16-bit part. This is used by combine.
6967
6968 (define_split
6969 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6970 (match_operator:DI 3 "boolean_or_operator"
6971 [(match_operand:DI 1 "gpc_reg_operand" "")
6972 (match_operand:DI 2 "non_logical_cint_operand" "")]))]
6973 "TARGET_POWERPC64"
6974 [(set (match_dup 0) (match_dup 4))
6975 (set (match_dup 0) (match_dup 5))]
6976 "
6977 {
6978 rtx i3,i4;
6979
6980 if (GET_CODE (operands[2]) == CONST_DOUBLE)
6981 {
6982 HOST_WIDE_INT value = CONST_DOUBLE_LOW (operands[2]);
6983 i3 = immed_double_const (value & (~ (HOST_WIDE_INT) 0xffff),
6984 0, DImode);
6985 i4 = GEN_INT (value & 0xffff);
6986 }
6987 else
6988 {
6989 i3 = GEN_INT (INTVAL (operands[2])
6990 & (~ (HOST_WIDE_INT) 0xffff));
6991 i4 = GEN_INT (INTVAL (operands[2]) & 0xffff);
6992 }
6993 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
6994 operands[1], i3);
6995 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
6996 operands[0], i4);
6997 }")
6998
6999 (define_insn "*boolcdi3_internal1"
7000 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7001 (match_operator:DI 3 "boolean_operator"
7002 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7003 (match_operand:DI 2 "gpc_reg_operand" "r")]))]
7004 "TARGET_POWERPC64"
7005 "%q3 %0,%2,%1")
7006
7007 (define_insn "*boolcdi3_internal2"
7008 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7009 (compare:CC (match_operator:DI 4 "boolean_operator"
7010 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7011 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7012 (const_int 0)))
7013 (clobber (match_scratch:DI 3 "=r,r"))]
7014 "TARGET_64BIT"
7015 "@
7016 %q4. %3,%2,%1
7017 #"
7018 [(set_attr "type" "compare")
7019 (set_attr "length" "4,8")])
7020
7021 (define_split
7022 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7023 (compare:CC (match_operator:DI 4 "boolean_operator"
7024 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7025 (match_operand:DI 2 "gpc_reg_operand" "")])
7026 (const_int 0)))
7027 (clobber (match_scratch:DI 3 ""))]
7028 "TARGET_POWERPC64 && reload_completed"
7029 [(set (match_dup 3) (match_dup 4))
7030 (set (match_dup 0)
7031 (compare:CC (match_dup 3)
7032 (const_int 0)))]
7033 "")
7034
7035 (define_insn "*boolcdi3_internal3"
7036 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7037 (compare:CC (match_operator:DI 4 "boolean_operator"
7038 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7039 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7040 (const_int 0)))
7041 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7042 (match_dup 4))]
7043 "TARGET_64BIT"
7044 "@
7045 %q4. %0,%2,%1
7046 #"
7047 [(set_attr "type" "compare")
7048 (set_attr "length" "4,8")])
7049
7050 (define_split
7051 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7052 (compare:CC (match_operator:DI 4 "boolean_operator"
7053 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7054 (match_operand:DI 2 "gpc_reg_operand" "")])
7055 (const_int 0)))
7056 (set (match_operand:DI 0 "gpc_reg_operand" "")
7057 (match_dup 4))]
7058 "TARGET_POWERPC64 && reload_completed"
7059 [(set (match_dup 0) (match_dup 4))
7060 (set (match_dup 3)
7061 (compare:CC (match_dup 0)
7062 (const_int 0)))]
7063 "")
7064
7065 (define_insn "*boolccdi3_internal1"
7066 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7067 (match_operator:DI 3 "boolean_operator"
7068 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7069 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))]))]
7070 "TARGET_POWERPC64"
7071 "%q3 %0,%1,%2")
7072
7073 (define_insn "*boolccdi3_internal2"
7074 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7075 (compare:CC (match_operator:DI 4 "boolean_operator"
7076 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7077 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7078 (const_int 0)))
7079 (clobber (match_scratch:DI 3 "=r,r"))]
7080 "TARGET_64BIT"
7081 "@
7082 %q4. %3,%1,%2
7083 #"
7084 [(set_attr "type" "compare")
7085 (set_attr "length" "4,8")])
7086
7087 (define_split
7088 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7089 (compare:CC (match_operator:DI 4 "boolean_operator"
7090 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7091 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7092 (const_int 0)))
7093 (clobber (match_scratch:DI 3 ""))]
7094 "TARGET_POWERPC64 && reload_completed"
7095 [(set (match_dup 3) (match_dup 4))
7096 (set (match_dup 0)
7097 (compare:CC (match_dup 3)
7098 (const_int 0)))]
7099 "")
7100
7101 (define_insn "*boolccdi3_internal3"
7102 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7103 (compare:CC (match_operator:DI 4 "boolean_operator"
7104 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7105 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7106 (const_int 0)))
7107 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7108 (match_dup 4))]
7109 "TARGET_64BIT"
7110 "@
7111 %q4. %0,%1,%2
7112 #"
7113 [(set_attr "type" "compare")
7114 (set_attr "length" "4,8")])
7115
7116 (define_split
7117 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7118 (compare:CC (match_operator:DI 4 "boolean_operator"
7119 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7120 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7121 (const_int 0)))
7122 (set (match_operand:DI 0 "gpc_reg_operand" "")
7123 (match_dup 4))]
7124 "TARGET_POWERPC64 && reload_completed"
7125 [(set (match_dup 0) (match_dup 4))
7126 (set (match_dup 3)
7127 (compare:CC (match_dup 0)
7128 (const_int 0)))]
7129 "")
7130 \f
7131 ;; Now define ways of moving data around.
7132
7133 ;; Set up a register with a value from the GOT table
7134
7135 (define_expand "movsi_got"
7136 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7137 (unspec:SI [(match_operand:SI 1 "got_operand" "")
7138 (match_dup 2)] UNSPEC_MOVSI_GOT))]
7139 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7140 "
7141 {
7142 if (GET_CODE (operands[1]) == CONST)
7143 {
7144 rtx offset = const0_rtx;
7145 HOST_WIDE_INT value;
7146
7147 operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
7148 value = INTVAL (offset);
7149 if (value != 0)
7150 {
7151 rtx tmp = (no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode));
7152 emit_insn (gen_movsi_got (tmp, operands[1]));
7153 emit_insn (gen_addsi3 (operands[0], tmp, offset));
7154 DONE;
7155 }
7156 }
7157
7158 operands[2] = rs6000_got_register (operands[1]);
7159 }")
7160
7161 (define_insn "*movsi_got_internal"
7162 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7163 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7164 (match_operand:SI 2 "gpc_reg_operand" "b")]
7165 UNSPEC_MOVSI_GOT))]
7166 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7167 "{l|lwz} %0,%a1@got(%2)"
7168 [(set_attr "type" "load")])
7169
7170 ;; Used by sched, shorten_branches and final when the GOT pseudo reg
7171 ;; didn't get allocated to a hard register.
7172 (define_split
7173 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7174 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7175 (match_operand:SI 2 "memory_operand" "")]
7176 UNSPEC_MOVSI_GOT))]
7177 "DEFAULT_ABI == ABI_V4
7178 && flag_pic == 1
7179 && (reload_in_progress || reload_completed)"
7180 [(set (match_dup 0) (match_dup 2))
7181 (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)]
7182 UNSPEC_MOVSI_GOT))]
7183 "")
7184
7185 ;; For SI, we special-case integers that can't be loaded in one insn. We
7186 ;; do the load 16-bits at a time. We could do this by loading from memory,
7187 ;; and this is even supposed to be faster, but it is simpler not to get
7188 ;; integers in the TOC.
7189 (define_insn "movsi_low"
7190 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7191 (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7192 (match_operand 2 "" ""))))]
7193 "TARGET_MACHO && ! TARGET_64BIT"
7194 "{l|lwz} %0,lo16(%2)(%1)"
7195 [(set_attr "type" "load")
7196 (set_attr "length" "4")])
7197
7198 (define_insn "*movsi_internal1"
7199 [(set (match_operand:SI 0 "rs6000_nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
7200 (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,R,*h,r,r,r,0"))]
7201 "gpc_reg_operand (operands[0], SImode)
7202 || gpc_reg_operand (operands[1], SImode)"
7203 "@
7204 mr %0,%1
7205 {cal|la} %0,%a1
7206 {l%U1%X1|lwz%U1%X1} %0,%1
7207 {st%U0%X0|stw%U0%X0} %1,%0
7208 {lil|li} %0,%1
7209 {liu|lis} %0,%v1
7210 #
7211 {cal|la} %0,%a1
7212 mf%1 %0
7213 mt%0 %1
7214 mt%0 %1
7215 mt%0 %1
7216 {cror 0,0,0|nop}"
7217 [(set_attr "type" "*,*,load,store,*,*,*,*,mfjmpr,*,mtjmpr,*,*")
7218 (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
7219
7220 ;; Split a load of a large constant into the appropriate two-insn
7221 ;; sequence.
7222
7223 (define_split
7224 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7225 (match_operand:SI 1 "const_int_operand" ""))]
7226 "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
7227 && (INTVAL (operands[1]) & 0xffff) != 0"
7228 [(set (match_dup 0)
7229 (match_dup 2))
7230 (set (match_dup 0)
7231 (ior:SI (match_dup 0)
7232 (match_dup 3)))]
7233 "
7234 { rtx tem = rs6000_emit_set_const (operands[0], SImode, operands[1], 2);
7235
7236 if (tem == operands[0])
7237 DONE;
7238 else
7239 FAIL;
7240 }")
7241
7242 (define_insn "*mov<mode>_internal2"
7243 [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
7244 (compare:CC (match_operand:P 1 "gpc_reg_operand" "0,r,r")
7245 (const_int 0)))
7246 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
7247 ""
7248 "@
7249 {cmpi|cmp<wd>i} %2,%0,0
7250 mr. %0,%1
7251 #"
7252 [(set_attr "type" "cmp,compare,cmp")
7253 (set_attr "length" "4,4,8")])
7254
7255 (define_split
7256 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
7257 (compare:CC (match_operand:P 1 "gpc_reg_operand" "")
7258 (const_int 0)))
7259 (set (match_operand:P 0 "gpc_reg_operand" "") (match_dup 1))]
7260 "reload_completed"
7261 [(set (match_dup 0) (match_dup 1))
7262 (set (match_dup 2)
7263 (compare:CC (match_dup 0)
7264 (const_int 0)))]
7265 "")
7266 \f
7267 (define_insn "*movhi_internal"
7268 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7269 (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
7270 "gpc_reg_operand (operands[0], HImode)
7271 || gpc_reg_operand (operands[1], HImode)"
7272 "@
7273 mr %0,%1
7274 lhz%U1%X1 %0,%1
7275 sth%U0%X0 %1,%0
7276 {lil|li} %0,%w1
7277 mf%1 %0
7278 mt%0 %1
7279 mt%0 %1
7280 {cror 0,0,0|nop}"
7281 [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
7282
7283 (define_expand "mov<mode>"
7284 [(set (match_operand:INT 0 "general_operand" "")
7285 (match_operand:INT 1 "any_operand" ""))]
7286 ""
7287 "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
7288
7289 (define_insn "*movqi_internal"
7290 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7291 (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
7292 "gpc_reg_operand (operands[0], QImode)
7293 || gpc_reg_operand (operands[1], QImode)"
7294 "@
7295 mr %0,%1
7296 lbz%U1%X1 %0,%1
7297 stb%U0%X0 %1,%0
7298 {lil|li} %0,%1
7299 mf%1 %0
7300 mt%0 %1
7301 mt%0 %1
7302 {cror 0,0,0|nop}"
7303 [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
7304 \f
7305 ;; Here is how to move condition codes around. When we store CC data in
7306 ;; an integer register or memory, we store just the high-order 4 bits.
7307 ;; This lets us not shift in the most common case of CR0.
7308 (define_expand "movcc"
7309 [(set (match_operand:CC 0 "nonimmediate_operand" "")
7310 (match_operand:CC 1 "nonimmediate_operand" ""))]
7311 ""
7312 "")
7313
7314 (define_insn "*movcc_internal1"
7315 [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,?y,r,r,r,r,q,cl,r,m")
7316 (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,h,r,r,m,r"))]
7317 "register_operand (operands[0], CCmode)
7318 || register_operand (operands[1], CCmode)"
7319 "@
7320 mcrf %0,%1
7321 mtcrf 128,%1
7322 {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
7323 mfcr %0%Q1
7324 mfcr %0%Q1\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
7325 mr %0,%1
7326 mf%1 %0
7327 mt%0 %1
7328 mt%0 %1
7329 {l%U1%X1|lwz%U1%X1} %0,%1
7330 {st%U0%U1|stw%U0%U1} %1,%0"
7331 [(set (attr "type")
7332 (cond [(eq_attr "alternative" "0")
7333 (const_string "cr_logical")
7334 (eq_attr "alternative" "1,2")
7335 (const_string "mtcr")
7336 (eq_attr "alternative" "5,7")
7337 (const_string "integer")
7338 (eq_attr "alternative" "6")
7339 (const_string "mfjmpr")
7340 (eq_attr "alternative" "8")
7341 (const_string "mtjmpr")
7342 (eq_attr "alternative" "9")
7343 (const_string "load")
7344 (eq_attr "alternative" "10")
7345 (const_string "store")
7346 (ne (symbol_ref "TARGET_MFCRF") (const_int 0))
7347 (const_string "mfcrf")
7348 ]
7349 (const_string "mfcr")))
7350 (set_attr "length" "4,4,12,4,8,4,4,4,4,4,4")])
7351 \f
7352 ;; For floating-point, we normally deal with the floating-point registers
7353 ;; unless -msoft-float is used. The sole exception is that parameter passing
7354 ;; can produce floating-point values in fixed-point registers. Unless the
7355 ;; value is a simple constant or already in memory, we deal with this by
7356 ;; allocating memory and copying the value explicitly via that memory location.
7357 (define_expand "movsf"
7358 [(set (match_operand:SF 0 "nonimmediate_operand" "")
7359 (match_operand:SF 1 "any_operand" ""))]
7360 ""
7361 "{ rs6000_emit_move (operands[0], operands[1], SFmode); DONE; }")
7362
7363 (define_split
7364 [(set (match_operand:SF 0 "gpc_reg_operand" "")
7365 (match_operand:SF 1 "const_double_operand" ""))]
7366 "reload_completed
7367 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7368 || (GET_CODE (operands[0]) == SUBREG
7369 && GET_CODE (SUBREG_REG (operands[0])) == REG
7370 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7371 [(set (match_dup 2) (match_dup 3))]
7372 "
7373 {
7374 long l;
7375 REAL_VALUE_TYPE rv;
7376
7377 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7378 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
7379
7380 if (! TARGET_POWERPC64)
7381 operands[2] = operand_subword (operands[0], 0, 0, SFmode);
7382 else
7383 operands[2] = gen_lowpart (SImode, operands[0]);
7384
7385 operands[3] = gen_int_mode (l, SImode);
7386 }")
7387
7388 (define_insn "*movsf_hardfloat"
7389 [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,!cl,!q,!r,!h,!r,!r")
7390 (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,r,r,h,0,G,Fn"))]
7391 "(gpc_reg_operand (operands[0], SFmode)
7392 || gpc_reg_operand (operands[1], SFmode))
7393 && (TARGET_HARD_FLOAT && TARGET_FPRS)"
7394 "@
7395 mr %0,%1
7396 {l%U1%X1|lwz%U1%X1} %0,%1
7397 {st%U0%X0|stw%U0%X0} %1,%0
7398 fmr %0,%1
7399 lfs%U1%X1 %0,%1
7400 stfs%U0%X0 %1,%0
7401 mt%0 %1
7402 mt%0 %1
7403 mf%1 %0
7404 {cror 0,0,0|nop}
7405 #
7406 #"
7407 [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,mtjmpr,*,*,*,*")
7408 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,8")])
7409
7410 (define_insn "*movsf_softfloat"
7411 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,cl,q,r,r,m,r,r,r,r,r,*h")
7412 (match_operand:SF 1 "input_operand" "r,r,r,h,m,r,I,L,R,G,Fn,0"))]
7413 "(gpc_reg_operand (operands[0], SFmode)
7414 || gpc_reg_operand (operands[1], SFmode))
7415 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
7416 "@
7417 mr %0,%1
7418 mt%0 %1
7419 mt%0 %1
7420 mf%1 %0
7421 {l%U1%X1|lwz%U1%X1} %0,%1
7422 {st%U0%X0|stw%U0%X0} %1,%0
7423 {lil|li} %0,%1
7424 {liu|lis} %0,%v1
7425 {cal|la} %0,%a1
7426 #
7427 #
7428 {cror 0,0,0|nop}"
7429 [(set_attr "type" "*,mtjmpr,*,*,load,store,*,*,*,*,*,*")
7430 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8,4")])
7431
7432 \f
7433 (define_expand "movdf"
7434 [(set (match_operand:DF 0 "nonimmediate_operand" "")
7435 (match_operand:DF 1 "any_operand" ""))]
7436 ""
7437 "{ rs6000_emit_move (operands[0], operands[1], DFmode); DONE; }")
7438
7439 (define_split
7440 [(set (match_operand:DF 0 "gpc_reg_operand" "")
7441 (match_operand:DF 1 "const_int_operand" ""))]
7442 "! TARGET_POWERPC64 && reload_completed
7443 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7444 || (GET_CODE (operands[0]) == SUBREG
7445 && GET_CODE (SUBREG_REG (operands[0])) == REG
7446 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7447 [(set (match_dup 2) (match_dup 4))
7448 (set (match_dup 3) (match_dup 1))]
7449 "
7450 {
7451 int endian = (WORDS_BIG_ENDIAN == 0);
7452 HOST_WIDE_INT value = INTVAL (operands[1]);
7453
7454 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
7455 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
7456 #if HOST_BITS_PER_WIDE_INT == 32
7457 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
7458 #else
7459 operands[4] = GEN_INT (value >> 32);
7460 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
7461 #endif
7462 }")
7463
7464 (define_split
7465 [(set (match_operand:DF 0 "gpc_reg_operand" "")
7466 (match_operand:DF 1 "const_double_operand" ""))]
7467 "! TARGET_POWERPC64 && reload_completed
7468 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7469 || (GET_CODE (operands[0]) == SUBREG
7470 && GET_CODE (SUBREG_REG (operands[0])) == REG
7471 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7472 [(set (match_dup 2) (match_dup 4))
7473 (set (match_dup 3) (match_dup 5))]
7474 "
7475 {
7476 int endian = (WORDS_BIG_ENDIAN == 0);
7477 long l[2];
7478 REAL_VALUE_TYPE rv;
7479
7480 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7481 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
7482
7483 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
7484 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
7485 operands[4] = gen_int_mode (l[endian], SImode);
7486 operands[5] = gen_int_mode (l[1 - endian], SImode);
7487 }")
7488
7489 (define_split
7490 [(set (match_operand:DF 0 "gpc_reg_operand" "")
7491 (match_operand:DF 1 "easy_fp_constant" ""))]
7492 "TARGET_POWERPC64 && reload_completed
7493 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7494 || (GET_CODE (operands[0]) == SUBREG
7495 && GET_CODE (SUBREG_REG (operands[0])) == REG
7496 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7497 [(set (match_dup 2) (match_dup 3))]
7498 "
7499 {
7500 int endian = (WORDS_BIG_ENDIAN == 0);
7501 long l[2];
7502 REAL_VALUE_TYPE rv;
7503 #if HOST_BITS_PER_WIDE_INT >= 64
7504 HOST_WIDE_INT val;
7505 #endif
7506
7507 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7508 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
7509
7510 operands[2] = gen_lowpart (DImode, operands[0]);
7511 /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN. */
7512 #if HOST_BITS_PER_WIDE_INT >= 64
7513 val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32
7514 | ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
7515
7516 operands[3] = gen_int_mode (val, DImode);
7517 #else
7518 operands[3] = immed_double_const (l[1 - endian], l[endian], DImode);
7519 #endif
7520 }")
7521
7522 ;; Don't have reload use general registers to load a constant. First,
7523 ;; it might not work if the output operand is the equivalent of
7524 ;; a non-offsettable memref, but also it is less efficient than loading
7525 ;; the constant into an FP register, since it will probably be used there.
7526 ;; The "??" is a kludge until we can figure out a more reasonable way
7527 ;; of handling these non-offsettable values.
7528 (define_insn "*movdf_hardfloat32"
7529 [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,f,f,m,!r,!r,!r")
7530 (match_operand:DF 1 "input_operand" "r,m,r,f,m,f,G,H,F"))]
7531 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
7532 && (gpc_reg_operand (operands[0], DFmode)
7533 || gpc_reg_operand (operands[1], DFmode))"
7534 "*
7535 {
7536 switch (which_alternative)
7537 {
7538 default:
7539 gcc_unreachable ();
7540 case 0:
7541 /* We normally copy the low-numbered register first. However, if
7542 the first register operand 0 is the same as the second register
7543 of operand 1, we must copy in the opposite order. */
7544 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
7545 return \"mr %L0,%L1\;mr %0,%1\";
7546 else
7547 return \"mr %0,%1\;mr %L0,%L1\";
7548 case 1:
7549 if (GET_CODE (operands[1]) == MEM
7550 && (rs6000_legitimate_offset_address_p (DFmode, XEXP (operands[1], 0),
7551 reload_completed || reload_in_progress)
7552 || rs6000_legitimate_small_data_p (DFmode, XEXP (operands[1], 0))
7553 || GET_CODE (XEXP (operands[1], 0)) == REG
7554 || GET_CODE (XEXP (operands[1], 0)) == LO_SUM
7555 || GET_CODE (XEXP (operands[1], 0)) == PRE_INC
7556 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC))
7557 {
7558 /* If the low-address word is used in the address, we must load
7559 it last. Otherwise, load it first. Note that we cannot have
7560 auto-increment in that case since the address register is
7561 known to be dead. */
7562 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
7563 operands[1], 0))
7564 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
7565 else
7566 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
7567 }
7568 else
7569 {
7570 rtx addreg;
7571
7572 addreg = find_addr_reg (XEXP (operands[1], 0));
7573 if (refers_to_regno_p (REGNO (operands[0]),
7574 REGNO (operands[0]) + 1,
7575 operands[1], 0))
7576 {
7577 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
7578 output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
7579 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
7580 return \"{lx|lwzx} %0,%1\";
7581 }
7582 else
7583 {
7584 output_asm_insn (\"{lx|lwzx} %0,%1\", operands);
7585 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
7586 output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
7587 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
7588 return \"\";
7589 }
7590 }
7591 case 2:
7592 if (GET_CODE (operands[0]) == MEM
7593 && (rs6000_legitimate_offset_address_p (DFmode, XEXP (operands[0], 0),
7594 reload_completed || reload_in_progress)
7595 || rs6000_legitimate_small_data_p (DFmode, XEXP (operands[0], 0))
7596 || GET_CODE (XEXP (operands[0], 0)) == REG
7597 || GET_CODE (XEXP (operands[0], 0)) == LO_SUM
7598 || GET_CODE (XEXP (operands[0], 0)) == PRE_INC
7599 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC))
7600 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
7601 else
7602 {
7603 rtx addreg;
7604
7605 addreg = find_addr_reg (XEXP (operands[0], 0));
7606 output_asm_insn (\"{stx|stwx} %1,%0\", operands);
7607 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
7608 output_asm_insn (\"{stx|stwx} %L1,%0\", operands);
7609 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
7610 return \"\";
7611 }
7612 case 3:
7613 return \"fmr %0,%1\";
7614 case 4:
7615 return \"lfd%U1%X1 %0,%1\";
7616 case 5:
7617 return \"stfd%U0%X0 %1,%0\";
7618 case 6:
7619 case 7:
7620 case 8:
7621 return \"#\";
7622 }
7623 }"
7624 [(set_attr "type" "two,load,store,fp,fpload,fpstore,*,*,*")
7625 (set_attr "length" "8,16,16,4,4,4,8,12,16")])
7626
7627 (define_insn "*movdf_softfloat32"
7628 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
7629 (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
7630 "! TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || TARGET_E500_SINGLE)
7631 && (gpc_reg_operand (operands[0], DFmode)
7632 || gpc_reg_operand (operands[1], DFmode))"
7633 "*
7634 {
7635 switch (which_alternative)
7636 {
7637 default:
7638 gcc_unreachable ();
7639 case 0:
7640 /* We normally copy the low-numbered register first. However, if
7641 the first register operand 0 is the same as the second register of
7642 operand 1, we must copy in the opposite order. */
7643 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
7644 return \"mr %L0,%L1\;mr %0,%1\";
7645 else
7646 return \"mr %0,%1\;mr %L0,%L1\";
7647 case 1:
7648 /* If the low-address word is used in the address, we must load
7649 it last. Otherwise, load it first. Note that we cannot have
7650 auto-increment in that case since the address register is
7651 known to be dead. */
7652 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
7653 operands[1], 0))
7654 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
7655 else
7656 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
7657 case 2:
7658 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
7659 case 3:
7660 case 4:
7661 case 5:
7662 return \"#\";
7663 }
7664 }"
7665 [(set_attr "type" "two,load,store,*,*,*")
7666 (set_attr "length" "8,8,8,8,12,16")])
7667
7668 ; ld/std require word-aligned displacements -> 'Y' constraint.
7669 ; List Y->r and r->Y before r->r for reload.
7670 (define_insn "*movdf_hardfloat64"
7671 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,r,!r,f,f,m,!cl,!r,!h,!r,!r,!r")
7672 (match_operand:DF 1 "input_operand" "r,Y,r,f,m,f,r,h,0,G,H,F"))]
7673 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
7674 && (gpc_reg_operand (operands[0], DFmode)
7675 || gpc_reg_operand (operands[1], DFmode))"
7676 "@
7677 std%U0%X0 %1,%0
7678 ld%U1%X1 %0,%1
7679 mr %0,%1
7680 fmr %0,%1
7681 lfd%U1%X1 %0,%1
7682 stfd%U0%X0 %1,%0
7683 mt%0 %1
7684 mf%1 %0
7685 {cror 0,0,0|nop}
7686 #
7687 #
7688 #"
7689 [(set_attr "type" "*,load,store,fp,fpload,fpstore,mtjmpr,*,*,*,*,*")
7690 (set_attr "length" "4,4,4,4,4,4,4,4,4,8,12,16")])
7691
7692 (define_insn "*movdf_softfloat64"
7693 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,Y,r,cl,r,r,r,r,*h")
7694 (match_operand:DF 1 "input_operand" "Y,r,r,r,h,G,H,F,0"))]
7695 "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
7696 && (gpc_reg_operand (operands[0], DFmode)
7697 || gpc_reg_operand (operands[1], DFmode))"
7698 "@
7699 ld%U1%X1 %0,%1
7700 std%U0%X0 %1,%0
7701 mr %0,%1
7702 mt%0 %1
7703 mf%1 %0
7704 #
7705 #
7706 #
7707 {cror 0,0,0|nop}"
7708 [(set_attr "type" "load,store,*,*,*,*,*,*,*")
7709 (set_attr "length" "4,4,4,4,4,8,12,16,4")])
7710 \f
7711 (define_expand "movtf"
7712 [(set (match_operand:TF 0 "general_operand" "")
7713 (match_operand:TF 1 "any_operand" ""))]
7714 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7715 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7716 "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
7717
7718 ; It's important to list the o->f and f->o moves before f->f because
7719 ; otherwise reload, given m->f, will try to pick f->f and reload it,
7720 ; which doesn't make progress. Likewise r->Y must be before r->r.
7721 (define_insn_and_split "*movtf_internal"
7722 [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,f,r,Y,r")
7723 (match_operand:TF 1 "input_operand" "f,o,f,YGHF,r,r"))]
7724 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7725 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128
7726 && (gpc_reg_operand (operands[0], TFmode)
7727 || gpc_reg_operand (operands[1], TFmode))"
7728 "#"
7729 "&& reload_completed"
7730 [(pc)]
7731 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
7732 [(set_attr "length" "8,8,8,20,20,16")])
7733
7734 (define_expand "extenddftf2"
7735 [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
7736 (float_extend:TF (match_operand:DF 1 "input_operand" "")))
7737 (use (match_dup 2))])]
7738 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7739 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7740 {
7741 operands[2] = CONST0_RTX (DFmode);
7742 })
7743
7744 (define_insn_and_split "*extenddftf2_internal"
7745 [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,&f,r")
7746 (float_extend:TF (match_operand:DF 1 "input_operand" "fr,mf,mf,rmGHF")))
7747 (use (match_operand:DF 2 "zero_reg_mem_operand" "rf,m,f,n"))]
7748 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7749 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7750 "#"
7751 "&& reload_completed"
7752 [(pc)]
7753 {
7754 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
7755 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
7756 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word),
7757 operands[1]);
7758 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word),
7759 operands[2]);
7760 DONE;
7761 })
7762
7763 (define_expand "extendsftf2"
7764 [(set (match_operand:TF 0 "nonimmediate_operand" "")
7765 (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "")))]
7766 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7767 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7768 {
7769 rtx tmp = gen_reg_rtx (DFmode);
7770 emit_insn (gen_extendsfdf2 (tmp, operands[1]));
7771 emit_insn (gen_extenddftf2 (operands[0], tmp));
7772 DONE;
7773 })
7774
7775 (define_expand "trunctfdf2"
7776 [(set (match_operand:DF 0 "gpc_reg_operand" "")
7777 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))]
7778 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7779 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7780 "")
7781
7782 (define_insn_and_split "trunctfdf2_internal1"
7783 [(set (match_operand:DF 0 "gpc_reg_operand" "=f,?f")
7784 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "0,f")))]
7785 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && !TARGET_XL_COMPAT
7786 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7787 "@
7788 #
7789 fmr %0,%1"
7790 "&& reload_completed && REGNO (operands[0]) == REGNO (operands[1])"
7791 [(const_int 0)]
7792 {
7793 emit_note (NOTE_INSN_DELETED);
7794 DONE;
7795 }
7796 [(set_attr "type" "fp")])
7797
7798 (define_insn "trunctfdf2_internal2"
7799 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
7800 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "f")))]
7801 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && TARGET_XL_COMPAT
7802 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7803 "fadd %0,%1,%L1"
7804 [(set_attr "type" "fp")])
7805
7806 (define_insn_and_split "trunctfsf2"
7807 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
7808 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "f")))
7809 (clobber (match_scratch:DF 2 "=f"))]
7810 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7811 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7812 "#"
7813 "&& reload_completed"
7814 [(set (match_dup 2)
7815 (float_truncate:DF (match_dup 1)))
7816 (set (match_dup 0)
7817 (float_truncate:SF (match_dup 2)))]
7818 "")
7819
7820 (define_expand "floatsitf2"
7821 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
7822 (float:TF (match_operand:SI 1 "gpc_reg_operand" "r")))]
7823 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7824 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7825 {
7826 rtx tmp = gen_reg_rtx (DFmode);
7827 expand_float (tmp, operands[1], false);
7828 emit_insn (gen_extenddftf2 (operands[0], tmp));
7829 DONE;
7830 })
7831
7832 ; fadd, but rounding towards zero.
7833 ; This is probably not the optimal code sequence.
7834 (define_insn "fix_trunc_helper"
7835 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
7836 (unspec:DF [(match_operand:TF 1 "gpc_reg_operand" "f")]
7837 UNSPEC_FIX_TRUNC_TF))
7838 (clobber (match_operand:DF 2 "gpc_reg_operand" "=&f"))]
7839 "TARGET_HARD_FLOAT && TARGET_FPRS"
7840 "mffs %2\n\tmtfsb1 31\n\tmtfsb0 30\n\tfadd %0,%1,%L1\n\tmtfsf 1,%2"
7841 [(set_attr "type" "fp")
7842 (set_attr "length" "20")])
7843
7844 (define_expand "fix_trunctfsi2"
7845 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
7846 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))
7847 (clobber (match_dup 2))
7848 (clobber (match_dup 3))
7849 (clobber (match_dup 4))
7850 (clobber (match_dup 5))])]
7851 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7852 && (TARGET_POWER2 || TARGET_POWERPC)
7853 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7854 {
7855 operands[2] = gen_reg_rtx (DFmode);
7856 operands[3] = gen_reg_rtx (DFmode);
7857 operands[4] = gen_reg_rtx (DImode);
7858 operands[5] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
7859 })
7860
7861 (define_insn_and_split "*fix_trunctfsi2_internal"
7862 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7863 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "f")))
7864 (clobber (match_operand:DF 2 "gpc_reg_operand" "=f"))
7865 (clobber (match_operand:DF 3 "gpc_reg_operand" "=&f"))
7866 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))
7867 (clobber (match_operand:DI 5 "memory_operand" "=o"))]
7868 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7869 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7870 "#"
7871 "&& (!no_new_pseudos || offsettable_nonstrict_memref_p (operands[5]))"
7872 [(pc)]
7873 {
7874 rtx lowword;
7875 emit_insn (gen_fix_trunc_helper (operands[2], operands[1], operands[3]));
7876
7877 gcc_assert (MEM_P (operands[5]));
7878 lowword = adjust_address (operands[5], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
7879
7880 emit_insn (gen_fctiwz (operands[4], operands[2]));
7881 emit_move_insn (operands[5], operands[4]);
7882 emit_move_insn (operands[0], lowword);
7883 DONE;
7884 })
7885
7886 (define_insn "negtf2"
7887 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
7888 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
7889 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7890 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7891 "*
7892 {
7893 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
7894 return \"fneg %L0,%L1\;fneg %0,%1\";
7895 else
7896 return \"fneg %0,%1\;fneg %L0,%L1\";
7897 }"
7898 [(set_attr "type" "fp")
7899 (set_attr "length" "8")])
7900
7901 (define_expand "abstf2"
7902 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
7903 (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
7904 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7905 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7906 "
7907 {
7908 rtx label = gen_label_rtx ();
7909 emit_insn (gen_abstf2_internal (operands[0], operands[1], label));
7910 emit_label (label);
7911 DONE;
7912 }")
7913
7914 (define_expand "abstf2_internal"
7915 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
7916 (match_operand:TF 1 "gpc_reg_operand" "f"))
7917 (set (match_dup 3) (match_dup 5))
7918 (set (match_dup 5) (abs:DF (match_dup 5)))
7919 (set (match_dup 4) (compare:CCFP (match_dup 3) (match_dup 5)))
7920 (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
7921 (label_ref (match_operand 2 "" ""))
7922 (pc)))
7923 (set (match_dup 6) (neg:DF (match_dup 6)))]
7924 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7925 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7926 "
7927 {
7928 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
7929 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
7930 operands[3] = gen_reg_rtx (DFmode);
7931 operands[4] = gen_reg_rtx (CCFPmode);
7932 operands[5] = simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word);
7933 operands[6] = simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word);
7934 }")
7935 \f
7936 ;; Next come the multi-word integer load and store and the load and store
7937 ;; multiple insns.
7938
7939 ; List r->r after r->"o<>", otherwise reload will try to reload a
7940 ; non-offsettable address by using r->r which won't make progress.
7941 (define_insn "*movdi_internal32"
7942 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,r,r,*f,*f,m,r")
7943 (match_operand:DI 1 "input_operand" "r,r,m,f,m,f,IJKnGHF"))]
7944 "! TARGET_POWERPC64
7945 && (gpc_reg_operand (operands[0], DImode)
7946 || gpc_reg_operand (operands[1], DImode))"
7947 "@
7948 #
7949 #
7950 #
7951 fmr %0,%1
7952 lfd%U1%X1 %0,%1
7953 stfd%U0%X0 %1,%0
7954 #"
7955 [(set_attr "type" "load,*,store,fp,fpload,fpstore,*")])
7956
7957 (define_split
7958 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7959 (match_operand:DI 1 "const_int_operand" ""))]
7960 "! TARGET_POWERPC64 && reload_completed"
7961 [(set (match_dup 2) (match_dup 4))
7962 (set (match_dup 3) (match_dup 1))]
7963 "
7964 {
7965 HOST_WIDE_INT value = INTVAL (operands[1]);
7966 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
7967 DImode);
7968 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
7969 DImode);
7970 #if HOST_BITS_PER_WIDE_INT == 32
7971 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
7972 #else
7973 operands[4] = GEN_INT (value >> 32);
7974 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
7975 #endif
7976 }")
7977
7978 (define_split
7979 [(set (match_operand:DI 0 "nonimmediate_operand" "")
7980 (match_operand:DI 1 "input_operand" ""))]
7981 "reload_completed && !TARGET_POWERPC64
7982 && gpr_or_gpr_p (operands[0], operands[1])"
7983 [(pc)]
7984 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
7985
7986 (define_insn "*movdi_internal64"
7987 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,*f,*f,m,r,*h,*h")
7988 (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0"))]
7989 "TARGET_POWERPC64
7990 && (gpc_reg_operand (operands[0], DImode)
7991 || gpc_reg_operand (operands[1], DImode))"
7992 "@
7993 mr %0,%1
7994 ld%U1%X1 %0,%1
7995 std%U0%X0 %1,%0
7996 li %0,%1
7997 lis %0,%v1
7998 #
7999 {cal|la} %0,%a1
8000 fmr %0,%1
8001 lfd%U1%X1 %0,%1
8002 stfd%U0%X0 %1,%0
8003 mf%1 %0
8004 mt%0 %1
8005 {cror 0,0,0|nop}"
8006 [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,mfjmpr,mtjmpr,*")
8007 (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
8008
8009 ;; immediate value valid for a single instruction hiding in a const_double
8010 (define_insn ""
8011 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
8012 (match_operand:DI 1 "const_double_operand" "F"))]
8013 "HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64
8014 && GET_CODE (operands[1]) == CONST_DOUBLE
8015 && num_insns_constant (operands[1], DImode) == 1"
8016 "*
8017 {
8018 return ((unsigned HOST_WIDE_INT)
8019 (CONST_DOUBLE_LOW (operands[1]) + 0x8000) < 0x10000)
8020 ? \"li %0,%1\" : \"lis %0,%v1\";
8021 }")
8022
8023 ;; Generate all one-bits and clear left or right.
8024 ;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
8025 (define_split
8026 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8027 (match_operand:DI 1 "mask_operand" ""))]
8028 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8029 [(set (match_dup 0) (const_int -1))
8030 (set (match_dup 0)
8031 (and:DI (rotate:DI (match_dup 0)
8032 (const_int 0))
8033 (match_dup 1)))]
8034 "")
8035
8036 ;; Split a load of a large constant into the appropriate five-instruction
8037 ;; sequence. Handle anything in a constant number of insns.
8038 ;; When non-easy constants can go in the TOC, this should use
8039 ;; easy_fp_constant predicate.
8040 (define_split
8041 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8042 (match_operand:DI 1 "const_int_operand" ""))]
8043 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8044 [(set (match_dup 0) (match_dup 2))
8045 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8046 "
8047 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8048
8049 if (tem == operands[0])
8050 DONE;
8051 else
8052 FAIL;
8053 }")
8054
8055 (define_split
8056 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8057 (match_operand:DI 1 "const_double_operand" ""))]
8058 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8059 [(set (match_dup 0) (match_dup 2))
8060 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8061 "
8062 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8063
8064 if (tem == operands[0])
8065 DONE;
8066 else
8067 FAIL;
8068 }")
8069 \f
8070 ;; TImode is similar, except that we usually want to compute the address into
8071 ;; a register and use lsi/stsi (the exception is during reload). MQ is also
8072 ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
8073
8074 ;; We say that MQ is clobbered in the last alternative because the first
8075 ;; alternative would never get used otherwise since it would need a reload
8076 ;; while the 2nd alternative would not. We put memory cases first so they
8077 ;; are preferred. Otherwise, we'd try to reload the output instead of
8078 ;; giving the SCRATCH mq.
8079
8080 (define_insn "*movti_power"
8081 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r,r")
8082 (match_operand:TI 1 "input_operand" "r,r,r,Q,m,n"))
8083 (clobber (match_scratch:SI 2 "=q,q#X,X,X,X,X"))]
8084 "TARGET_POWER && ! TARGET_POWERPC64
8085 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8086 "*
8087 {
8088 switch (which_alternative)
8089 {
8090 default:
8091 gcc_unreachable ();
8092
8093 case 0:
8094 if (TARGET_STRING)
8095 return \"{stsi|stswi} %1,%P0,16\";
8096 case 1:
8097 case 2:
8098 return \"#\";
8099 case 3:
8100 /* If the address is not used in the output, we can use lsi. Otherwise,
8101 fall through to generating four loads. */
8102 if (TARGET_STRING
8103 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
8104 return \"{lsi|lswi} %0,%P1,16\";
8105 /* ... fall through ... */
8106 case 4:
8107 case 5:
8108 return \"#\";
8109 }
8110 }"
8111 [(set_attr "type" "store,store,*,load,load,*")])
8112
8113 (define_insn "*movti_string"
8114 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,o<>,????r,????r,????r,r")
8115 (match_operand:TI 1 "input_operand" "r,r,r,Q,m,n"))]
8116 "! TARGET_POWER && ! TARGET_POWERPC64
8117 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8118 "*
8119 {
8120 switch (which_alternative)
8121 {
8122 default:
8123 gcc_unreachable ();
8124 case 0:
8125 if (TARGET_STRING)
8126 return \"{stsi|stswi} %1,%P0,16\";
8127 case 1:
8128 case 2:
8129 return \"#\";
8130 case 3:
8131 /* If the address is not used in the output, we can use lsi. Otherwise,
8132 fall through to generating four loads. */
8133 if (TARGET_STRING
8134 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
8135 return \"{lsi|lswi} %0,%P1,16\";
8136 /* ... fall through ... */
8137 case 4:
8138 case 5:
8139 return \"#\";
8140 }
8141 }"
8142 [(set_attr "type" "store,store,*,load,load,*")])
8143
8144 (define_insn "*movti_ppc64"
8145 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o<>,r")
8146 (match_operand:TI 1 "input_operand" "r,r,m"))]
8147 "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
8148 || gpc_reg_operand (operands[1], TImode))"
8149 "#"
8150 [(set_attr "type" "*,load,store")])
8151
8152 (define_split
8153 [(set (match_operand:TI 0 "gpc_reg_operand" "")
8154 (match_operand:TI 1 "const_double_operand" ""))]
8155 "TARGET_POWERPC64"
8156 [(set (match_dup 2) (match_dup 4))
8157 (set (match_dup 3) (match_dup 5))]
8158 "
8159 {
8160 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8161 TImode);
8162 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8163 TImode);
8164 if (GET_CODE (operands[1]) == CONST_DOUBLE)
8165 {
8166 operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
8167 operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
8168 }
8169 else if (GET_CODE (operands[1]) == CONST_INT)
8170 {
8171 operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
8172 operands[5] = operands[1];
8173 }
8174 else
8175 FAIL;
8176 }")
8177
8178 (define_split
8179 [(set (match_operand:TI 0 "nonimmediate_operand" "")
8180 (match_operand:TI 1 "input_operand" ""))]
8181 "reload_completed
8182 && gpr_or_gpr_p (operands[0], operands[1])"
8183 [(pc)]
8184 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8185 \f
8186 (define_expand "load_multiple"
8187 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8188 (match_operand:SI 1 "" ""))
8189 (use (match_operand:SI 2 "" ""))])]
8190 "TARGET_STRING && !TARGET_POWERPC64"
8191 "
8192 {
8193 int regno;
8194 int count;
8195 rtx op1;
8196 int i;
8197
8198 /* Support only loading a constant number of fixed-point registers from
8199 memory and only bother with this if more than two; the machine
8200 doesn't support more than eight. */
8201 if (GET_CODE (operands[2]) != CONST_INT
8202 || INTVAL (operands[2]) <= 2
8203 || INTVAL (operands[2]) > 8
8204 || GET_CODE (operands[1]) != MEM
8205 || GET_CODE (operands[0]) != REG
8206 || REGNO (operands[0]) >= 32)
8207 FAIL;
8208
8209 count = INTVAL (operands[2]);
8210 regno = REGNO (operands[0]);
8211
8212 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
8213 op1 = replace_equiv_address (operands[1],
8214 force_reg (SImode, XEXP (operands[1], 0)));
8215
8216 for (i = 0; i < count; i++)
8217 XVECEXP (operands[3], 0, i)
8218 = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
8219 adjust_address_nv (op1, SImode, i * 4));
8220 }")
8221
8222 (define_insn "*ldmsi8"
8223 [(match_parallel 0 "load_multiple_operation"
8224 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8225 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8226 (set (match_operand:SI 3 "gpc_reg_operand" "")
8227 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8228 (set (match_operand:SI 4 "gpc_reg_operand" "")
8229 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8230 (set (match_operand:SI 5 "gpc_reg_operand" "")
8231 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8232 (set (match_operand:SI 6 "gpc_reg_operand" "")
8233 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8234 (set (match_operand:SI 7 "gpc_reg_operand" "")
8235 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8236 (set (match_operand:SI 8 "gpc_reg_operand" "")
8237 (mem:SI (plus:SI (match_dup 1) (const_int 24))))
8238 (set (match_operand:SI 9 "gpc_reg_operand" "")
8239 (mem:SI (plus:SI (match_dup 1) (const_int 28))))])]
8240 "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
8241 "*
8242 { return rs6000_output_load_multiple (operands); }"
8243 [(set_attr "type" "load")
8244 (set_attr "length" "32")])
8245
8246 (define_insn "*ldmsi7"
8247 [(match_parallel 0 "load_multiple_operation"
8248 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8249 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8250 (set (match_operand:SI 3 "gpc_reg_operand" "")
8251 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8252 (set (match_operand:SI 4 "gpc_reg_operand" "")
8253 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8254 (set (match_operand:SI 5 "gpc_reg_operand" "")
8255 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8256 (set (match_operand:SI 6 "gpc_reg_operand" "")
8257 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8258 (set (match_operand:SI 7 "gpc_reg_operand" "")
8259 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8260 (set (match_operand:SI 8 "gpc_reg_operand" "")
8261 (mem:SI (plus:SI (match_dup 1) (const_int 24))))])]
8262 "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
8263 "*
8264 { return rs6000_output_load_multiple (operands); }"
8265 [(set_attr "type" "load")
8266 (set_attr "length" "32")])
8267
8268 (define_insn "*ldmsi6"
8269 [(match_parallel 0 "load_multiple_operation"
8270 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8271 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8272 (set (match_operand:SI 3 "gpc_reg_operand" "")
8273 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8274 (set (match_operand:SI 4 "gpc_reg_operand" "")
8275 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8276 (set (match_operand:SI 5 "gpc_reg_operand" "")
8277 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8278 (set (match_operand:SI 6 "gpc_reg_operand" "")
8279 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8280 (set (match_operand:SI 7 "gpc_reg_operand" "")
8281 (mem:SI (plus:SI (match_dup 1) (const_int 20))))])]
8282 "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
8283 "*
8284 { return rs6000_output_load_multiple (operands); }"
8285 [(set_attr "type" "load")
8286 (set_attr "length" "32")])
8287
8288 (define_insn "*ldmsi5"
8289 [(match_parallel 0 "load_multiple_operation"
8290 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8291 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8292 (set (match_operand:SI 3 "gpc_reg_operand" "")
8293 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8294 (set (match_operand:SI 4 "gpc_reg_operand" "")
8295 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8296 (set (match_operand:SI 5 "gpc_reg_operand" "")
8297 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8298 (set (match_operand:SI 6 "gpc_reg_operand" "")
8299 (mem:SI (plus:SI (match_dup 1) (const_int 16))))])]
8300 "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
8301 "*
8302 { return rs6000_output_load_multiple (operands); }"
8303 [(set_attr "type" "load")
8304 (set_attr "length" "32")])
8305
8306 (define_insn "*ldmsi4"
8307 [(match_parallel 0 "load_multiple_operation"
8308 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8309 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8310 (set (match_operand:SI 3 "gpc_reg_operand" "")
8311 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8312 (set (match_operand:SI 4 "gpc_reg_operand" "")
8313 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8314 (set (match_operand:SI 5 "gpc_reg_operand" "")
8315 (mem:SI (plus:SI (match_dup 1) (const_int 12))))])]
8316 "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
8317 "*
8318 { return rs6000_output_load_multiple (operands); }"
8319 [(set_attr "type" "load")
8320 (set_attr "length" "32")])
8321
8322 (define_insn "*ldmsi3"
8323 [(match_parallel 0 "load_multiple_operation"
8324 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8325 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8326 (set (match_operand:SI 3 "gpc_reg_operand" "")
8327 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8328 (set (match_operand:SI 4 "gpc_reg_operand" "")
8329 (mem:SI (plus:SI (match_dup 1) (const_int 8))))])]
8330 "TARGET_STRING && XVECLEN (operands[0], 0) == 3"
8331 "*
8332 { return rs6000_output_load_multiple (operands); }"
8333 [(set_attr "type" "load")
8334 (set_attr "length" "32")])
8335
8336 (define_expand "store_multiple"
8337 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8338 (match_operand:SI 1 "" ""))
8339 (clobber (scratch:SI))
8340 (use (match_operand:SI 2 "" ""))])]
8341 "TARGET_STRING && !TARGET_POWERPC64"
8342 "
8343 {
8344 int regno;
8345 int count;
8346 rtx to;
8347 rtx op0;
8348 int i;
8349
8350 /* Support only storing a constant number of fixed-point registers to
8351 memory and only bother with this if more than two; the machine
8352 doesn't support more than eight. */
8353 if (GET_CODE (operands[2]) != CONST_INT
8354 || INTVAL (operands[2]) <= 2
8355 || INTVAL (operands[2]) > 8
8356 || GET_CODE (operands[0]) != MEM
8357 || GET_CODE (operands[1]) != REG
8358 || REGNO (operands[1]) >= 32)
8359 FAIL;
8360
8361 count = INTVAL (operands[2]);
8362 regno = REGNO (operands[1]);
8363
8364 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
8365 to = force_reg (SImode, XEXP (operands[0], 0));
8366 op0 = replace_equiv_address (operands[0], to);
8367
8368 XVECEXP (operands[3], 0, 0)
8369 = gen_rtx_SET (VOIDmode, adjust_address_nv (op0, SImode, 0), operands[1]);
8370 XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
8371 gen_rtx_SCRATCH (SImode));
8372
8373 for (i = 1; i < count; i++)
8374 XVECEXP (operands[3], 0, i + 1)
8375 = gen_rtx_SET (VOIDmode,
8376 adjust_address_nv (op0, SImode, i * 4),
8377 gen_rtx_REG (SImode, regno + i));
8378 }")
8379
8380 (define_insn "*store_multiple_power"
8381 [(match_parallel 0 "store_multiple_operation"
8382 [(set (match_operand:SI 1 "indirect_operand" "=Q")
8383 (match_operand:SI 2 "gpc_reg_operand" "r"))
8384 (clobber (match_scratch:SI 3 "=q"))])]
8385 "TARGET_STRING && TARGET_POWER"
8386 "{stsi|stswi} %2,%P1,%O0"
8387 [(set_attr "type" "store")])
8388
8389 (define_insn "*stmsi8"
8390 [(match_parallel 0 "store_multiple_operation"
8391 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8392 (match_operand:SI 2 "gpc_reg_operand" "r"))
8393 (clobber (match_scratch:SI 3 "X"))
8394 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8395 (match_operand:SI 4 "gpc_reg_operand" "r"))
8396 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8397 (match_operand:SI 5 "gpc_reg_operand" "r"))
8398 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
8399 (match_operand:SI 6 "gpc_reg_operand" "r"))
8400 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
8401 (match_operand:SI 7 "gpc_reg_operand" "r"))
8402 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
8403 (match_operand:SI 8 "gpc_reg_operand" "r"))
8404 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
8405 (match_operand:SI 9 "gpc_reg_operand" "r"))
8406 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
8407 (match_operand:SI 10 "gpc_reg_operand" "r"))])]
8408 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 9"
8409 "{stsi|stswi} %2,%1,%O0"
8410 [(set_attr "type" "store")])
8411
8412 (define_insn "*stmsi7"
8413 [(match_parallel 0 "store_multiple_operation"
8414 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8415 (match_operand:SI 2 "gpc_reg_operand" "r"))
8416 (clobber (match_scratch:SI 3 "X"))
8417 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8418 (match_operand:SI 4 "gpc_reg_operand" "r"))
8419 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8420 (match_operand:SI 5 "gpc_reg_operand" "r"))
8421 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
8422 (match_operand:SI 6 "gpc_reg_operand" "r"))
8423 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
8424 (match_operand:SI 7 "gpc_reg_operand" "r"))
8425 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
8426 (match_operand:SI 8 "gpc_reg_operand" "r"))
8427 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
8428 (match_operand:SI 9 "gpc_reg_operand" "r"))])]
8429 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 8"
8430 "{stsi|stswi} %2,%1,%O0"
8431 [(set_attr "type" "store")])
8432
8433 (define_insn "*stmsi6"
8434 [(match_parallel 0 "store_multiple_operation"
8435 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8436 (match_operand:SI 2 "gpc_reg_operand" "r"))
8437 (clobber (match_scratch:SI 3 "X"))
8438 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8439 (match_operand:SI 4 "gpc_reg_operand" "r"))
8440 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8441 (match_operand:SI 5 "gpc_reg_operand" "r"))
8442 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
8443 (match_operand:SI 6 "gpc_reg_operand" "r"))
8444 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
8445 (match_operand:SI 7 "gpc_reg_operand" "r"))
8446 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
8447 (match_operand:SI 8 "gpc_reg_operand" "r"))])]
8448 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 7"
8449 "{stsi|stswi} %2,%1,%O0"
8450 [(set_attr "type" "store")])
8451
8452 (define_insn "*stmsi5"
8453 [(match_parallel 0 "store_multiple_operation"
8454 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8455 (match_operand:SI 2 "gpc_reg_operand" "r"))
8456 (clobber (match_scratch:SI 3 "X"))
8457 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8458 (match_operand:SI 4 "gpc_reg_operand" "r"))
8459 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8460 (match_operand:SI 5 "gpc_reg_operand" "r"))
8461 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
8462 (match_operand:SI 6 "gpc_reg_operand" "r"))
8463 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
8464 (match_operand:SI 7 "gpc_reg_operand" "r"))])]
8465 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 6"
8466 "{stsi|stswi} %2,%1,%O0"
8467 [(set_attr "type" "store")])
8468
8469 (define_insn "*stmsi4"
8470 [(match_parallel 0 "store_multiple_operation"
8471 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8472 (match_operand:SI 2 "gpc_reg_operand" "r"))
8473 (clobber (match_scratch:SI 3 "X"))
8474 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8475 (match_operand:SI 4 "gpc_reg_operand" "r"))
8476 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8477 (match_operand:SI 5 "gpc_reg_operand" "r"))
8478 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
8479 (match_operand:SI 6 "gpc_reg_operand" "r"))])]
8480 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 5"
8481 "{stsi|stswi} %2,%1,%O0"
8482 [(set_attr "type" "store")])
8483
8484 (define_insn "*stmsi3"
8485 [(match_parallel 0 "store_multiple_operation"
8486 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8487 (match_operand:SI 2 "gpc_reg_operand" "r"))
8488 (clobber (match_scratch:SI 3 "X"))
8489 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8490 (match_operand:SI 4 "gpc_reg_operand" "r"))
8491 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8492 (match_operand:SI 5 "gpc_reg_operand" "r"))])]
8493 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 4"
8494 "{stsi|stswi} %2,%1,%O0"
8495 [(set_attr "type" "store")])
8496 \f
8497 (define_expand "setmemsi"
8498 [(parallel [(set (match_operand:BLK 0 "" "")
8499 (match_operand 2 "const_int_operand" ""))
8500 (use (match_operand:SI 1 "" ""))
8501 (use (match_operand:SI 3 "" ""))])]
8502 ""
8503 "
8504 {
8505 /* If value to set is not zero, use the library routine. */
8506 if (operands[2] != const0_rtx)
8507 FAIL;
8508
8509 if (expand_block_clear (operands))
8510 DONE;
8511 else
8512 FAIL;
8513 }")
8514
8515 ;; String/block move insn.
8516 ;; Argument 0 is the destination
8517 ;; Argument 1 is the source
8518 ;; Argument 2 is the length
8519 ;; Argument 3 is the alignment
8520
8521 (define_expand "movmemsi"
8522 [(parallel [(set (match_operand:BLK 0 "" "")
8523 (match_operand:BLK 1 "" ""))
8524 (use (match_operand:SI 2 "" ""))
8525 (use (match_operand:SI 3 "" ""))])]
8526 ""
8527 "
8528 {
8529 if (expand_block_move (operands))
8530 DONE;
8531 else
8532 FAIL;
8533 }")
8534
8535 ;; Move up to 32 bytes at a time. The fixed registers are needed because the
8536 ;; register allocator doesn't have a clue about allocating 8 word registers.
8537 ;; rD/rS = r5 is preferred, efficient form.
8538 (define_expand "movmemsi_8reg"
8539 [(parallel [(set (match_operand 0 "" "")
8540 (match_operand 1 "" ""))
8541 (use (match_operand 2 "" ""))
8542 (use (match_operand 3 "" ""))
8543 (clobber (reg:SI 5))
8544 (clobber (reg:SI 6))
8545 (clobber (reg:SI 7))
8546 (clobber (reg:SI 8))
8547 (clobber (reg:SI 9))
8548 (clobber (reg:SI 10))
8549 (clobber (reg:SI 11))
8550 (clobber (reg:SI 12))
8551 (clobber (match_scratch:SI 4 ""))])]
8552 "TARGET_STRING"
8553 "")
8554
8555 (define_insn ""
8556 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8557 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8558 (use (match_operand:SI 2 "immediate_operand" "i"))
8559 (use (match_operand:SI 3 "immediate_operand" "i"))
8560 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8561 (clobber (reg:SI 6))
8562 (clobber (reg:SI 7))
8563 (clobber (reg:SI 8))
8564 (clobber (reg:SI 9))
8565 (clobber (reg:SI 10))
8566 (clobber (reg:SI 11))
8567 (clobber (reg:SI 12))
8568 (clobber (match_scratch:SI 5 "=q"))]
8569 "TARGET_STRING && TARGET_POWER
8570 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
8571 || INTVAL (operands[2]) == 0)
8572 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
8573 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
8574 && REGNO (operands[4]) == 5"
8575 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8576 [(set_attr "type" "load")
8577 (set_attr "length" "8")])
8578
8579 (define_insn ""
8580 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
8581 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
8582 (use (match_operand:SI 2 "immediate_operand" "i"))
8583 (use (match_operand:SI 3 "immediate_operand" "i"))
8584 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8585 (clobber (reg:SI 6))
8586 (clobber (reg:SI 7))
8587 (clobber (reg:SI 8))
8588 (clobber (reg:SI 9))
8589 (clobber (reg:SI 10))
8590 (clobber (reg:SI 11))
8591 (clobber (reg:SI 12))
8592 (clobber (match_scratch:SI 5 "X"))]
8593 "TARGET_STRING && ! TARGET_POWER
8594 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
8595 || INTVAL (operands[2]) == 0)
8596 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
8597 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
8598 && REGNO (operands[4]) == 5"
8599 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8600 [(set_attr "type" "load")
8601 (set_attr "length" "8")])
8602
8603 ;; Move up to 24 bytes at a time. The fixed registers are needed because the
8604 ;; register allocator doesn't have a clue about allocating 6 word registers.
8605 ;; rD/rS = r5 is preferred, efficient form.
8606 (define_expand "movmemsi_6reg"
8607 [(parallel [(set (match_operand 0 "" "")
8608 (match_operand 1 "" ""))
8609 (use (match_operand 2 "" ""))
8610 (use (match_operand 3 "" ""))
8611 (clobber (reg:SI 5))
8612 (clobber (reg:SI 6))
8613 (clobber (reg:SI 7))
8614 (clobber (reg:SI 8))
8615 (clobber (reg:SI 9))
8616 (clobber (reg:SI 10))
8617 (clobber (match_scratch:SI 4 ""))])]
8618 "TARGET_STRING"
8619 "")
8620
8621 (define_insn ""
8622 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8623 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8624 (use (match_operand:SI 2 "immediate_operand" "i"))
8625 (use (match_operand:SI 3 "immediate_operand" "i"))
8626 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8627 (clobber (reg:SI 6))
8628 (clobber (reg:SI 7))
8629 (clobber (reg:SI 8))
8630 (clobber (reg:SI 9))
8631 (clobber (reg:SI 10))
8632 (clobber (match_scratch:SI 5 "=q"))]
8633 "TARGET_STRING && TARGET_POWER
8634 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
8635 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
8636 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
8637 && REGNO (operands[4]) == 5"
8638 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8639 [(set_attr "type" "load")
8640 (set_attr "length" "8")])
8641
8642 (define_insn ""
8643 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
8644 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
8645 (use (match_operand:SI 2 "immediate_operand" "i"))
8646 (use (match_operand:SI 3 "immediate_operand" "i"))
8647 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8648 (clobber (reg:SI 6))
8649 (clobber (reg:SI 7))
8650 (clobber (reg:SI 8))
8651 (clobber (reg:SI 9))
8652 (clobber (reg:SI 10))
8653 (clobber (match_scratch:SI 5 "X"))]
8654 "TARGET_STRING && ! TARGET_POWER
8655 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
8656 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
8657 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
8658 && REGNO (operands[4]) == 5"
8659 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8660 [(set_attr "type" "load")
8661 (set_attr "length" "8")])
8662
8663 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
8664 ;; problems with TImode.
8665 ;; rD/rS = r5 is preferred, efficient form.
8666 (define_expand "movmemsi_4reg"
8667 [(parallel [(set (match_operand 0 "" "")
8668 (match_operand 1 "" ""))
8669 (use (match_operand 2 "" ""))
8670 (use (match_operand 3 "" ""))
8671 (clobber (reg:SI 5))
8672 (clobber (reg:SI 6))
8673 (clobber (reg:SI 7))
8674 (clobber (reg:SI 8))
8675 (clobber (match_scratch:SI 4 ""))])]
8676 "TARGET_STRING"
8677 "")
8678
8679 (define_insn ""
8680 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8681 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8682 (use (match_operand:SI 2 "immediate_operand" "i"))
8683 (use (match_operand:SI 3 "immediate_operand" "i"))
8684 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8685 (clobber (reg:SI 6))
8686 (clobber (reg:SI 7))
8687 (clobber (reg:SI 8))
8688 (clobber (match_scratch:SI 5 "=q"))]
8689 "TARGET_STRING && TARGET_POWER
8690 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
8691 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
8692 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
8693 && REGNO (operands[4]) == 5"
8694 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8695 [(set_attr "type" "load")
8696 (set_attr "length" "8")])
8697
8698 (define_insn ""
8699 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
8700 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
8701 (use (match_operand:SI 2 "immediate_operand" "i"))
8702 (use (match_operand:SI 3 "immediate_operand" "i"))
8703 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8704 (clobber (reg:SI 6))
8705 (clobber (reg:SI 7))
8706 (clobber (reg:SI 8))
8707 (clobber (match_scratch:SI 5 "X"))]
8708 "TARGET_STRING && ! TARGET_POWER
8709 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
8710 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
8711 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
8712 && REGNO (operands[4]) == 5"
8713 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8714 [(set_attr "type" "load")
8715 (set_attr "length" "8")])
8716
8717 ;; Move up to 8 bytes at a time.
8718 (define_expand "movmemsi_2reg"
8719 [(parallel [(set (match_operand 0 "" "")
8720 (match_operand 1 "" ""))
8721 (use (match_operand 2 "" ""))
8722 (use (match_operand 3 "" ""))
8723 (clobber (match_scratch:DI 4 ""))
8724 (clobber (match_scratch:SI 5 ""))])]
8725 "TARGET_STRING && ! TARGET_POWERPC64"
8726 "")
8727
8728 (define_insn ""
8729 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8730 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8731 (use (match_operand:SI 2 "immediate_operand" "i"))
8732 (use (match_operand:SI 3 "immediate_operand" "i"))
8733 (clobber (match_scratch:DI 4 "=&r"))
8734 (clobber (match_scratch:SI 5 "=q"))]
8735 "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
8736 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
8737 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8738 [(set_attr "type" "load")
8739 (set_attr "length" "8")])
8740
8741 (define_insn ""
8742 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8743 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8744 (use (match_operand:SI 2 "immediate_operand" "i"))
8745 (use (match_operand:SI 3 "immediate_operand" "i"))
8746 (clobber (match_scratch:DI 4 "=&r"))
8747 (clobber (match_scratch:SI 5 "X"))]
8748 "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
8749 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
8750 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8751 [(set_attr "type" "load")
8752 (set_attr "length" "8")])
8753
8754 ;; Move up to 4 bytes at a time.
8755 (define_expand "movmemsi_1reg"
8756 [(parallel [(set (match_operand 0 "" "")
8757 (match_operand 1 "" ""))
8758 (use (match_operand 2 "" ""))
8759 (use (match_operand 3 "" ""))
8760 (clobber (match_scratch:SI 4 ""))
8761 (clobber (match_scratch:SI 5 ""))])]
8762 "TARGET_STRING"
8763 "")
8764
8765 (define_insn ""
8766 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8767 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8768 (use (match_operand:SI 2 "immediate_operand" "i"))
8769 (use (match_operand:SI 3 "immediate_operand" "i"))
8770 (clobber (match_scratch:SI 4 "=&r"))
8771 (clobber (match_scratch:SI 5 "=q"))]
8772 "TARGET_STRING && TARGET_POWER
8773 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
8774 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8775 [(set_attr "type" "load")
8776 (set_attr "length" "8")])
8777
8778 (define_insn ""
8779 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
8780 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
8781 (use (match_operand:SI 2 "immediate_operand" "i"))
8782 (use (match_operand:SI 3 "immediate_operand" "i"))
8783 (clobber (match_scratch:SI 4 "=&r"))
8784 (clobber (match_scratch:SI 5 "X"))]
8785 "TARGET_STRING && ! TARGET_POWER
8786 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
8787 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8788 [(set_attr "type" "load")
8789 (set_attr "length" "8")])
8790 \f
8791 ;; Define insns that do load or store with update. Some of these we can
8792 ;; get by using pre-decrement or pre-increment, but the hardware can also
8793 ;; do cases where the increment is not the size of the object.
8794 ;;
8795 ;; In all these cases, we use operands 0 and 1 for the register being
8796 ;; incremented because those are the operands that local-alloc will
8797 ;; tie and these are the pair most likely to be tieable (and the ones
8798 ;; that will benefit the most).
8799
8800 (define_insn "*movdi_update1"
8801 [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
8802 (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
8803 (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
8804 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
8805 (plus:DI (match_dup 1) (match_dup 2)))]
8806 "TARGET_POWERPC64 && TARGET_UPDATE"
8807 "@
8808 ldux %3,%0,%2
8809 ldu %3,%2(%0)"
8810 [(set_attr "type" "load_ux,load_u")])
8811
8812 (define_insn "movdi_<mode>_update"
8813 [(set (mem:DI (plus:P (match_operand:P 1 "gpc_reg_operand" "0,0")
8814 (match_operand:P 2 "reg_or_aligned_short_operand" "r,I")))
8815 (match_operand:DI 3 "gpc_reg_operand" "r,r"))
8816 (set (match_operand:P 0 "gpc_reg_operand" "=b,b")
8817 (plus:P (match_dup 1) (match_dup 2)))]
8818 "TARGET_POWERPC64 && TARGET_UPDATE"
8819 "@
8820 stdux %3,%0,%2
8821 stdu %3,%2(%0)"
8822 [(set_attr "type" "store_ux,store_u")])
8823
8824 (define_insn "*movsi_update1"
8825 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
8826 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8827 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
8828 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8829 (plus:SI (match_dup 1) (match_dup 2)))]
8830 "TARGET_UPDATE"
8831 "@
8832 {lux|lwzux} %3,%0,%2
8833 {lu|lwzu} %3,%2(%0)"
8834 [(set_attr "type" "load_ux,load_u")])
8835
8836 (define_insn "*movsi_update2"
8837 [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
8838 (sign_extend:DI
8839 (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
8840 (match_operand:DI 2 "gpc_reg_operand" "r")))))
8841 (set (match_operand:DI 0 "gpc_reg_operand" "=b")
8842 (plus:DI (match_dup 1) (match_dup 2)))]
8843 "TARGET_POWERPC64"
8844 "lwaux %3,%0,%2"
8845 [(set_attr "type" "load_ext_ux")])
8846
8847 (define_insn "movsi_update"
8848 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8849 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
8850 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8851 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8852 (plus:SI (match_dup 1) (match_dup 2)))]
8853 "TARGET_UPDATE"
8854 "@
8855 {stux|stwux} %3,%0,%2
8856 {stu|stwu} %3,%2(%0)"
8857 [(set_attr "type" "store_ux,store_u")])
8858
8859 (define_insn "*movhi_update1"
8860 [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
8861 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8862 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
8863 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8864 (plus:SI (match_dup 1) (match_dup 2)))]
8865 "TARGET_UPDATE"
8866 "@
8867 lhzux %3,%0,%2
8868 lhzu %3,%2(%0)"
8869 [(set_attr "type" "load_ux,load_u")])
8870
8871 (define_insn "*movhi_update2"
8872 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
8873 (zero_extend:SI
8874 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8875 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
8876 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8877 (plus:SI (match_dup 1) (match_dup 2)))]
8878 "TARGET_UPDATE"
8879 "@
8880 lhzux %3,%0,%2
8881 lhzu %3,%2(%0)"
8882 [(set_attr "type" "load_ux,load_u")])
8883
8884 (define_insn "*movhi_update3"
8885 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
8886 (sign_extend:SI
8887 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8888 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
8889 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8890 (plus:SI (match_dup 1) (match_dup 2)))]
8891 "TARGET_UPDATE"
8892 "@
8893 lhaux %3,%0,%2
8894 lhau %3,%2(%0)"
8895 [(set_attr "type" "load_ext_ux,load_ext_u")])
8896
8897 (define_insn "*movhi_update4"
8898 [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8899 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
8900 (match_operand:HI 3 "gpc_reg_operand" "r,r"))
8901 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8902 (plus:SI (match_dup 1) (match_dup 2)))]
8903 "TARGET_UPDATE"
8904 "@
8905 sthux %3,%0,%2
8906 sthu %3,%2(%0)"
8907 [(set_attr "type" "store_ux,store_u")])
8908
8909 (define_insn "*movqi_update1"
8910 [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
8911 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8912 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
8913 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8914 (plus:SI (match_dup 1) (match_dup 2)))]
8915 "TARGET_UPDATE"
8916 "@
8917 lbzux %3,%0,%2
8918 lbzu %3,%2(%0)"
8919 [(set_attr "type" "load_ux,load_u")])
8920
8921 (define_insn "*movqi_update2"
8922 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
8923 (zero_extend:SI
8924 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8925 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
8926 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8927 (plus:SI (match_dup 1) (match_dup 2)))]
8928 "TARGET_UPDATE"
8929 "@
8930 lbzux %3,%0,%2
8931 lbzu %3,%2(%0)"
8932 [(set_attr "type" "load_ux,load_u")])
8933
8934 (define_insn "*movqi_update3"
8935 [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8936 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
8937 (match_operand:QI 3 "gpc_reg_operand" "r,r"))
8938 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8939 (plus:SI (match_dup 1) (match_dup 2)))]
8940 "TARGET_UPDATE"
8941 "@
8942 stbux %3,%0,%2
8943 stbu %3,%2(%0)"
8944 [(set_attr "type" "store_ux,store_u")])
8945
8946 (define_insn "*movsf_update1"
8947 [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
8948 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8949 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
8950 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8951 (plus:SI (match_dup 1) (match_dup 2)))]
8952 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
8953 "@
8954 lfsux %3,%0,%2
8955 lfsu %3,%2(%0)"
8956 [(set_attr "type" "fpload_ux,fpload_u")])
8957
8958 (define_insn "*movsf_update2"
8959 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8960 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
8961 (match_operand:SF 3 "gpc_reg_operand" "f,f"))
8962 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8963 (plus:SI (match_dup 1) (match_dup 2)))]
8964 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
8965 "@
8966 stfsux %3,%0,%2
8967 stfsu %3,%2(%0)"
8968 [(set_attr "type" "fpstore_ux,fpstore_u")])
8969
8970 (define_insn "*movsf_update3"
8971 [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
8972 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8973 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
8974 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8975 (plus:SI (match_dup 1) (match_dup 2)))]
8976 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
8977 "@
8978 {lux|lwzux} %3,%0,%2
8979 {lu|lwzu} %3,%2(%0)"
8980 [(set_attr "type" "load_ux,load_u")])
8981
8982 (define_insn "*movsf_update4"
8983 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8984 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
8985 (match_operand:SF 3 "gpc_reg_operand" "r,r"))
8986 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8987 (plus:SI (match_dup 1) (match_dup 2)))]
8988 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
8989 "@
8990 {stux|stwux} %3,%0,%2
8991 {stu|stwu} %3,%2(%0)"
8992 [(set_attr "type" "store_ux,store_u")])
8993
8994 (define_insn "*movdf_update1"
8995 [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
8996 (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8997 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
8998 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8999 (plus:SI (match_dup 1) (match_dup 2)))]
9000 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9001 "@
9002 lfdux %3,%0,%2
9003 lfdu %3,%2(%0)"
9004 [(set_attr "type" "fpload_ux,fpload_u")])
9005
9006 (define_insn "*movdf_update2"
9007 [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9008 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9009 (match_operand:DF 3 "gpc_reg_operand" "f,f"))
9010 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9011 (plus:SI (match_dup 1) (match_dup 2)))]
9012 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9013 "@
9014 stfdux %3,%0,%2
9015 stfdu %3,%2(%0)"
9016 [(set_attr "type" "fpstore_ux,fpstore_u")])
9017
9018 ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
9019
9020 (define_insn "*lfq_power2"
9021 [(set (match_operand:V2DF 0 "gpc_reg_operand" "=f")
9022 (match_operand:V2DF 1 "memory_operand" ""))]
9023 "TARGET_POWER2
9024 && TARGET_HARD_FLOAT && TARGET_FPRS"
9025 "lfq%U1%X1 %0,%1")
9026
9027 (define_peephole2
9028 [(set (match_operand:DF 0 "gpc_reg_operand" "")
9029 (match_operand:DF 1 "memory_operand" ""))
9030 (set (match_operand:DF 2 "gpc_reg_operand" "")
9031 (match_operand:DF 3 "memory_operand" ""))]
9032 "TARGET_POWER2
9033 && TARGET_HARD_FLOAT && TARGET_FPRS
9034 && registers_ok_for_quad_peep (operands[0], operands[2])
9035 && mems_ok_for_quad_peep (operands[1], operands[3])"
9036 [(set (match_dup 0)
9037 (match_dup 1))]
9038 "operands[1] = widen_memory_access (operands[1], V2DFmode, 0);
9039 operands[0] = gen_rtx_REG (V2DFmode, REGNO (operands[0]));")
9040
9041 (define_insn "*stfq_power2"
9042 [(set (match_operand:V2DF 0 "memory_operand" "")
9043 (match_operand:V2DF 1 "gpc_reg_operand" "f"))]
9044 "TARGET_POWER2
9045 && TARGET_HARD_FLOAT && TARGET_FPRS"
9046 "stfq%U0%X0 %1,%0")
9047
9048
9049 (define_peephole2
9050 [(set (match_operand:DF 0 "memory_operand" "")
9051 (match_operand:DF 1 "gpc_reg_operand" ""))
9052 (set (match_operand:DF 2 "memory_operand" "")
9053 (match_operand:DF 3 "gpc_reg_operand" ""))]
9054 "TARGET_POWER2
9055 && TARGET_HARD_FLOAT && TARGET_FPRS
9056 && registers_ok_for_quad_peep (operands[1], operands[3])
9057 && mems_ok_for_quad_peep (operands[0], operands[2])"
9058 [(set (match_dup 0)
9059 (match_dup 1))]
9060 "operands[0] = widen_memory_access (operands[0], V2DFmode, 0);
9061 operands[1] = gen_rtx_REG (V2DFmode, REGNO (operands[1]));")
9062
9063 ;; after inserting conditional returns we can sometimes have
9064 ;; unnecessary register moves. Unfortunately we cannot have a
9065 ;; modeless peephole here, because some single SImode sets have early
9066 ;; clobber outputs. Although those sets expand to multi-ppc-insn
9067 ;; sequences, using get_attr_length here will smash the operands
9068 ;; array. Neither is there an early_cobbler_p predicate.
9069 (define_peephole2
9070 [(set (match_operand:DF 0 "gpc_reg_operand" "")
9071 (match_operand:DF 1 "any_operand" ""))
9072 (set (match_operand:DF 2 "gpc_reg_operand" "")
9073 (match_dup 0))]
9074 "peep2_reg_dead_p (2, operands[0])"
9075 [(set (match_dup 2) (match_dup 1))])
9076
9077 (define_peephole2
9078 [(set (match_operand:SF 0 "gpc_reg_operand" "")
9079 (match_operand:SF 1 "any_operand" ""))
9080 (set (match_operand:SF 2 "gpc_reg_operand" "")
9081 (match_dup 0))]
9082 "peep2_reg_dead_p (2, operands[0])"
9083 [(set (match_dup 2) (match_dup 1))])
9084
9085 \f
9086 ;; TLS support.
9087
9088 ;; "b" output constraint here and on tls_ld to support tls linker optimization.
9089 (define_insn "tls_gd_32"
9090 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9091 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9092 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9093 UNSPEC_TLSGD))]
9094 "HAVE_AS_TLS && !TARGET_64BIT"
9095 "addi %0,%1,%2@got@tlsgd")
9096
9097 (define_insn "tls_gd_64"
9098 [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
9099 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9100 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9101 UNSPEC_TLSGD))]
9102 "HAVE_AS_TLS && TARGET_64BIT"
9103 "addi %0,%1,%2@got@tlsgd")
9104
9105 (define_insn "tls_ld_32"
9106 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9107 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")]
9108 UNSPEC_TLSLD))]
9109 "HAVE_AS_TLS && !TARGET_64BIT"
9110 "addi %0,%1,%&@got@tlsld")
9111
9112 (define_insn "tls_ld_64"
9113 [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
9114 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")]
9115 UNSPEC_TLSLD))]
9116 "HAVE_AS_TLS && TARGET_64BIT"
9117 "addi %0,%1,%&@got@tlsld")
9118
9119 (define_insn "tls_dtprel_32"
9120 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9121 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9122 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9123 UNSPEC_TLSDTPREL))]
9124 "HAVE_AS_TLS && !TARGET_64BIT"
9125 "addi %0,%1,%2@dtprel")
9126
9127 (define_insn "tls_dtprel_64"
9128 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9129 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9130 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9131 UNSPEC_TLSDTPREL))]
9132 "HAVE_AS_TLS && TARGET_64BIT"
9133 "addi %0,%1,%2@dtprel")
9134
9135 (define_insn "tls_dtprel_ha_32"
9136 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9137 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9138 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9139 UNSPEC_TLSDTPRELHA))]
9140 "HAVE_AS_TLS && !TARGET_64BIT"
9141 "addis %0,%1,%2@dtprel@ha")
9142
9143 (define_insn "tls_dtprel_ha_64"
9144 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9145 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9146 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9147 UNSPEC_TLSDTPRELHA))]
9148 "HAVE_AS_TLS && TARGET_64BIT"
9149 "addis %0,%1,%2@dtprel@ha")
9150
9151 (define_insn "tls_dtprel_lo_32"
9152 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9153 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9154 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9155 UNSPEC_TLSDTPRELLO))]
9156 "HAVE_AS_TLS && !TARGET_64BIT"
9157 "addi %0,%1,%2@dtprel@l")
9158
9159 (define_insn "tls_dtprel_lo_64"
9160 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9161 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9162 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9163 UNSPEC_TLSDTPRELLO))]
9164 "HAVE_AS_TLS && TARGET_64BIT"
9165 "addi %0,%1,%2@dtprel@l")
9166
9167 (define_insn "tls_got_dtprel_32"
9168 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9169 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9170 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9171 UNSPEC_TLSGOTDTPREL))]
9172 "HAVE_AS_TLS && !TARGET_64BIT"
9173 "lwz %0,%2@got@dtprel(%1)")
9174
9175 (define_insn "tls_got_dtprel_64"
9176 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9177 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9178 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9179 UNSPEC_TLSGOTDTPREL))]
9180 "HAVE_AS_TLS && TARGET_64BIT"
9181 "ld %0,%2@got@dtprel(%1)")
9182
9183 (define_insn "tls_tprel_32"
9184 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9185 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9186 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9187 UNSPEC_TLSTPREL))]
9188 "HAVE_AS_TLS && !TARGET_64BIT"
9189 "addi %0,%1,%2@tprel")
9190
9191 (define_insn "tls_tprel_64"
9192 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9193 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9194 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9195 UNSPEC_TLSTPREL))]
9196 "HAVE_AS_TLS && TARGET_64BIT"
9197 "addi %0,%1,%2@tprel")
9198
9199 (define_insn "tls_tprel_ha_32"
9200 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9201 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9202 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9203 UNSPEC_TLSTPRELHA))]
9204 "HAVE_AS_TLS && !TARGET_64BIT"
9205 "addis %0,%1,%2@tprel@ha")
9206
9207 (define_insn "tls_tprel_ha_64"
9208 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9209 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9210 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9211 UNSPEC_TLSTPRELHA))]
9212 "HAVE_AS_TLS && TARGET_64BIT"
9213 "addis %0,%1,%2@tprel@ha")
9214
9215 (define_insn "tls_tprel_lo_32"
9216 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9217 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9218 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9219 UNSPEC_TLSTPRELLO))]
9220 "HAVE_AS_TLS && !TARGET_64BIT"
9221 "addi %0,%1,%2@tprel@l")
9222
9223 (define_insn "tls_tprel_lo_64"
9224 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9225 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9226 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9227 UNSPEC_TLSTPRELLO))]
9228 "HAVE_AS_TLS && TARGET_64BIT"
9229 "addi %0,%1,%2@tprel@l")
9230
9231 ;; "b" output constraint here and on tls_tls input to support linker tls
9232 ;; optimization. The linker may edit the instructions emitted by a
9233 ;; tls_got_tprel/tls_tls pair to addis,addi.
9234 (define_insn "tls_got_tprel_32"
9235 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9236 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9237 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9238 UNSPEC_TLSGOTTPREL))]
9239 "HAVE_AS_TLS && !TARGET_64BIT"
9240 "lwz %0,%2@got@tprel(%1)")
9241
9242 (define_insn "tls_got_tprel_64"
9243 [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
9244 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9245 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9246 UNSPEC_TLSGOTTPREL))]
9247 "HAVE_AS_TLS && TARGET_64BIT"
9248 "ld %0,%2@got@tprel(%1)")
9249
9250 (define_insn "tls_tls_32"
9251 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9252 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9253 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9254 UNSPEC_TLSTLS))]
9255 "HAVE_AS_TLS && !TARGET_64BIT"
9256 "add %0,%1,%2@tls")
9257
9258 (define_insn "tls_tls_64"
9259 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9260 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9261 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9262 UNSPEC_TLSTLS))]
9263 "HAVE_AS_TLS && TARGET_64BIT"
9264 "add %0,%1,%2@tls")
9265 \f
9266 ;; Next come insns related to the calling sequence.
9267 ;;
9268 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
9269 ;; We move the back-chain and decrement the stack pointer.
9270
9271 (define_expand "allocate_stack"
9272 [(set (match_operand 0 "gpc_reg_operand" "=r")
9273 (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
9274 (set (reg 1)
9275 (minus (reg 1) (match_dup 1)))]
9276 ""
9277 "
9278 { rtx chain = gen_reg_rtx (Pmode);
9279 rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
9280 rtx neg_op0;
9281
9282 emit_move_insn (chain, stack_bot);
9283
9284 /* Check stack bounds if necessary. */
9285 if (current_function_limit_stack)
9286 {
9287 rtx available;
9288 available = expand_binop (Pmode, sub_optab,
9289 stack_pointer_rtx, stack_limit_rtx,
9290 NULL_RTX, 1, OPTAB_WIDEN);
9291 emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
9292 }
9293
9294 if (GET_CODE (operands[1]) != CONST_INT
9295 || INTVAL (operands[1]) < -32767
9296 || INTVAL (operands[1]) > 32768)
9297 {
9298 neg_op0 = gen_reg_rtx (Pmode);
9299 if (TARGET_32BIT)
9300 emit_insn (gen_negsi2 (neg_op0, operands[1]));
9301 else
9302 emit_insn (gen_negdi2 (neg_op0, operands[1]));
9303 }
9304 else
9305 neg_op0 = GEN_INT (- INTVAL (operands[1]));
9306
9307 if (TARGET_UPDATE)
9308 emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_di_update))
9309 (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
9310
9311 else
9312 {
9313 emit_insn ((* ((TARGET_32BIT) ? gen_addsi3 : gen_adddi3))
9314 (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
9315 emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), chain);
9316 }
9317
9318 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9319 DONE;
9320 }")
9321
9322 ;; These patterns say how to save and restore the stack pointer. We need not
9323 ;; save the stack pointer at function level since we are careful to
9324 ;; preserve the backchain. At block level, we have to restore the backchain
9325 ;; when we restore the stack pointer.
9326 ;;
9327 ;; For nonlocal gotos, we must save both the stack pointer and its
9328 ;; backchain and restore both. Note that in the nonlocal case, the
9329 ;; save area is a memory location.
9330
9331 (define_expand "save_stack_function"
9332 [(match_operand 0 "any_operand" "")
9333 (match_operand 1 "any_operand" "")]
9334 ""
9335 "DONE;")
9336
9337 (define_expand "restore_stack_function"
9338 [(match_operand 0 "any_operand" "")
9339 (match_operand 1 "any_operand" "")]
9340 ""
9341 "DONE;")
9342
9343 (define_expand "restore_stack_block"
9344 [(use (match_operand 0 "register_operand" ""))
9345 (set (match_dup 2) (match_dup 3))
9346 (set (match_dup 0) (match_operand 1 "register_operand" ""))
9347 (set (match_dup 3) (match_dup 2))]
9348 ""
9349 "
9350 {
9351 operands[2] = gen_reg_rtx (Pmode);
9352 operands[3] = gen_rtx_MEM (Pmode, operands[0]);
9353 }")
9354
9355 (define_expand "save_stack_nonlocal"
9356 [(match_operand 0 "memory_operand" "")
9357 (match_operand 1 "register_operand" "")]
9358 ""
9359 "
9360 {
9361 rtx temp = gen_reg_rtx (Pmode);
9362 int units_per_word = (TARGET_32BIT) ? 4 : 8;
9363
9364 /* Copy the backchain to the first word, sp to the second. */
9365 emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
9366 emit_move_insn (adjust_address_nv (operands[0], Pmode, 0), temp);
9367 emit_move_insn (adjust_address_nv (operands[0], Pmode, units_per_word),
9368 operands[1]);
9369 DONE;
9370 }")
9371
9372 (define_expand "restore_stack_nonlocal"
9373 [(match_operand 0 "register_operand" "")
9374 (match_operand 1 "memory_operand" "")]
9375 ""
9376 "
9377 {
9378 rtx temp = gen_reg_rtx (Pmode);
9379 int units_per_word = (TARGET_32BIT) ? 4 : 8;
9380
9381 /* Restore the backchain from the first word, sp from the second. */
9382 emit_move_insn (temp,
9383 adjust_address_nv (operands[1], Pmode, 0));
9384 emit_move_insn (operands[0],
9385 adjust_address_nv (operands[1], Pmode, units_per_word));
9386 emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
9387 DONE;
9388 }")
9389 \f
9390 ;; TOC register handling.
9391
9392 ;; Code to initialize the TOC register...
9393
9394 (define_insn "load_toc_aix_si"
9395 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9396 (unspec:SI [(const_int 0)] UNSPEC_TOC))
9397 (use (reg:SI 2))])]
9398 "DEFAULT_ABI == ABI_AIX && TARGET_32BIT"
9399 "*
9400 {
9401 char buf[30];
9402 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
9403 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9404 operands[2] = gen_rtx_REG (Pmode, 2);
9405 return \"{l|lwz} %0,%1(%2)\";
9406 }"
9407 [(set_attr "type" "load")])
9408
9409 (define_insn "load_toc_aix_di"
9410 [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9411 (unspec:DI [(const_int 0)] UNSPEC_TOC))
9412 (use (reg:DI 2))])]
9413 "DEFAULT_ABI == ABI_AIX && TARGET_64BIT"
9414 "*
9415 {
9416 char buf[30];
9417 #ifdef TARGET_RELOCATABLE
9418 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
9419 !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
9420 #else
9421 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
9422 #endif
9423 if (TARGET_ELF)
9424 strcat (buf, \"@toc\");
9425 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9426 operands[2] = gen_rtx_REG (Pmode, 2);
9427 return \"ld %0,%1(%2)\";
9428 }"
9429 [(set_attr "type" "load")])
9430
9431 (define_insn "load_toc_v4_pic_si"
9432 [(set (match_operand:SI 0 "register_operand" "=l")
9433 (unspec:SI [(const_int 0)] UNSPEC_TOC))]
9434 "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
9435 "bl _GLOBAL_OFFSET_TABLE_@local-4"
9436 [(set_attr "type" "branch")
9437 (set_attr "length" "4")])
9438
9439 (define_insn "load_toc_v4_PIC_1"
9440 [(set (match_operand:SI 0 "register_operand" "=l")
9441 (match_operand:SI 1 "immediate_operand" "s"))
9442 (use (unspec [(match_dup 1)] UNSPEC_TOC))]
9443 "TARGET_ELF && DEFAULT_ABI != ABI_AIX
9444 && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
9445 "bcl 20,31,%1\\n%1:"
9446 [(set_attr "type" "branch")
9447 (set_attr "length" "4")])
9448
9449 (define_insn "load_toc_v4_PIC_1b"
9450 [(set (match_operand:SI 0 "register_operand" "=l")
9451 (unspec:SI [(match_operand:SI 1 "immediate_operand" "s")]
9452 UNSPEC_TOCPTR))]
9453 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
9454 "bcl 20,31,$+8\\n\\t.long %1-$"
9455 [(set_attr "type" "branch")
9456 (set_attr "length" "8")])
9457
9458 (define_insn "load_toc_v4_PIC_2"
9459 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9460 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
9461 (minus:SI (match_operand:SI 2 "immediate_operand" "s")
9462 (match_operand:SI 3 "immediate_operand" "s")))))]
9463 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
9464 "{l|lwz} %0,%2-%3(%1)"
9465 [(set_attr "type" "load")])
9466
9467 (define_insn "load_toc_v4_PIC_3b"
9468 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9469 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
9470 (high:SI
9471 (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
9472 (match_operand:SI 3 "symbol_ref_operand" "s")))))]
9473 "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI != ABI_AIX && flag_pic"
9474 "{cau|addis} %0,%1,%2-%3@ha")
9475
9476 (define_insn "load_toc_v4_PIC_3c"
9477 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9478 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
9479 (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
9480 (match_operand:SI 3 "symbol_ref_operand" "s"))))]
9481 "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI != ABI_AIX && flag_pic"
9482 "{cal|addi} %0,%1,%2-%3@l")
9483
9484 ;; If the TOC is shared over a translation unit, as happens with all
9485 ;; the kinds of PIC that we support, we need to restore the TOC
9486 ;; pointer only when jumping over units of translation.
9487 ;; On Darwin, we need to reload the picbase.
9488
9489 (define_expand "builtin_setjmp_receiver"
9490 [(use (label_ref (match_operand 0 "" "")))]
9491 "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
9492 || (TARGET_TOC && TARGET_MINIMAL_TOC)
9493 || (DEFAULT_ABI == ABI_DARWIN && flag_pic)"
9494 "
9495 {
9496 #if TARGET_MACHO
9497 if (DEFAULT_ABI == ABI_DARWIN)
9498 {
9499 const char *picbase = machopic_function_base_name ();
9500 rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (picbase));
9501 rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
9502 rtx tmplabrtx;
9503 char tmplab[20];
9504
9505 ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\",
9506 CODE_LABEL_NUMBER (operands[0]));
9507 tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
9508
9509 emit_insn (gen_load_macho_picbase (picreg, tmplabrtx));
9510 emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
9511 }
9512 else
9513 #endif
9514 rs6000_emit_load_toc_table (FALSE);
9515 DONE;
9516 }")
9517
9518 ;; Elf specific ways of loading addresses for non-PIC code.
9519 ;; The output of this could be r0, but we make a very strong
9520 ;; preference for a base register because it will usually
9521 ;; be needed there.
9522 (define_insn "elf_high"
9523 [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
9524 (high:SI (match_operand 1 "" "")))]
9525 "TARGET_ELF && ! TARGET_64BIT"
9526 "{liu|lis} %0,%1@ha")
9527
9528 (define_insn "elf_low"
9529 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
9530 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
9531 (match_operand 2 "" "")))]
9532 "TARGET_ELF && ! TARGET_64BIT"
9533 "@
9534 {cal|la} %0,%2@l(%1)
9535 {ai|addic} %0,%1,%K2")
9536 \f
9537 ;; A function pointer under AIX is a pointer to a data area whose first word
9538 ;; contains the actual address of the function, whose second word contains a
9539 ;; pointer to its TOC, and whose third word contains a value to place in the
9540 ;; static chain register (r11). Note that if we load the static chain, our
9541 ;; "trampoline" need not have any executable code.
9542
9543 (define_expand "call_indirect_aix32"
9544 [(set (match_dup 2)
9545 (mem:SI (match_operand:SI 0 "gpc_reg_operand" "")))
9546 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
9547 (reg:SI 2))
9548 (set (reg:SI 2)
9549 (mem:SI (plus:SI (match_dup 0)
9550 (const_int 4))))
9551 (set (reg:SI 11)
9552 (mem:SI (plus:SI (match_dup 0)
9553 (const_int 8))))
9554 (parallel [(call (mem:SI (match_dup 2))
9555 (match_operand 1 "" ""))
9556 (use (reg:SI 2))
9557 (use (reg:SI 11))
9558 (set (reg:SI 2)
9559 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9560 (clobber (scratch:SI))])]
9561 "TARGET_32BIT"
9562 "
9563 { operands[2] = gen_reg_rtx (SImode); }")
9564
9565 (define_expand "call_indirect_aix64"
9566 [(set (match_dup 2)
9567 (mem:DI (match_operand:DI 0 "gpc_reg_operand" "")))
9568 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
9569 (reg:DI 2))
9570 (set (reg:DI 2)
9571 (mem:DI (plus:DI (match_dup 0)
9572 (const_int 8))))
9573 (set (reg:DI 11)
9574 (mem:DI (plus:DI (match_dup 0)
9575 (const_int 16))))
9576 (parallel [(call (mem:SI (match_dup 2))
9577 (match_operand 1 "" ""))
9578 (use (reg:DI 2))
9579 (use (reg:DI 11))
9580 (set (reg:DI 2)
9581 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9582 (clobber (scratch:SI))])]
9583 "TARGET_64BIT"
9584 "
9585 { operands[2] = gen_reg_rtx (DImode); }")
9586
9587 (define_expand "call_value_indirect_aix32"
9588 [(set (match_dup 3)
9589 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
9590 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
9591 (reg:SI 2))
9592 (set (reg:SI 2)
9593 (mem:SI (plus:SI (match_dup 1)
9594 (const_int 4))))
9595 (set (reg:SI 11)
9596 (mem:SI (plus:SI (match_dup 1)
9597 (const_int 8))))
9598 (parallel [(set (match_operand 0 "" "")
9599 (call (mem:SI (match_dup 3))
9600 (match_operand 2 "" "")))
9601 (use (reg:SI 2))
9602 (use (reg:SI 11))
9603 (set (reg:SI 2)
9604 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9605 (clobber (scratch:SI))])]
9606 "TARGET_32BIT"
9607 "
9608 { operands[3] = gen_reg_rtx (SImode); }")
9609
9610 (define_expand "call_value_indirect_aix64"
9611 [(set (match_dup 3)
9612 (mem:DI (match_operand:DI 1 "gpc_reg_operand" "")))
9613 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
9614 (reg:DI 2))
9615 (set (reg:DI 2)
9616 (mem:DI (plus:DI (match_dup 1)
9617 (const_int 8))))
9618 (set (reg:DI 11)
9619 (mem:DI (plus:DI (match_dup 1)
9620 (const_int 16))))
9621 (parallel [(set (match_operand 0 "" "")
9622 (call (mem:SI (match_dup 3))
9623 (match_operand 2 "" "")))
9624 (use (reg:DI 2))
9625 (use (reg:DI 11))
9626 (set (reg:DI 2)
9627 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9628 (clobber (scratch:SI))])]
9629 "TARGET_64BIT"
9630 "
9631 { operands[3] = gen_reg_rtx (DImode); }")
9632
9633 ;; Now the definitions for the call and call_value insns
9634 (define_expand "call"
9635 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
9636 (match_operand 1 "" ""))
9637 (use (match_operand 2 "" ""))
9638 (clobber (scratch:SI))])]
9639 ""
9640 "
9641 {
9642 #if TARGET_MACHO
9643 if (MACHOPIC_INDIRECT)
9644 operands[0] = machopic_indirect_call_target (operands[0]);
9645 #endif
9646
9647 gcc_assert (GET_CODE (operands[0]) == MEM);
9648 gcc_assert (GET_CODE (operands[1]) == CONST_INT);
9649
9650 operands[0] = XEXP (operands[0], 0);
9651
9652 if (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT
9653 && flag_pic
9654 && GET_CODE (operands[0]) == SYMBOL_REF
9655 && !SYMBOL_REF_LOCAL_P (operands[0]))
9656 {
9657 rtx call;
9658 rtvec tmp;
9659
9660 tmp = gen_rtvec (3,
9661 gen_rtx_CALL (VOIDmode,
9662 gen_rtx_MEM (SImode, operands[0]),
9663 operands[1]),
9664 gen_rtx_USE (VOIDmode, operands[2]),
9665 gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (SImode)));
9666 call = emit_call_insn (gen_rtx_PARALLEL (VOIDmode, tmp));
9667 use_reg (&CALL_INSN_FUNCTION_USAGE (call), pic_offset_table_rtx);
9668 DONE;
9669 }
9670
9671 if (GET_CODE (operands[0]) != SYMBOL_REF
9672 || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[0]))
9673 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[2]) & CALL_LONG) != 0))
9674 {
9675 if (INTVAL (operands[2]) & CALL_LONG)
9676 operands[0] = rs6000_longcall_ref (operands[0]);
9677
9678 switch (DEFAULT_ABI)
9679 {
9680 case ABI_V4:
9681 case ABI_DARWIN:
9682 operands[0] = force_reg (Pmode, operands[0]);
9683 break;
9684
9685 case ABI_AIX:
9686 /* AIX function pointers are really pointers to a three word
9687 area. */
9688 emit_call_insn (TARGET_32BIT
9689 ? gen_call_indirect_aix32 (force_reg (SImode,
9690 operands[0]),
9691 operands[1])
9692 : gen_call_indirect_aix64 (force_reg (DImode,
9693 operands[0]),
9694 operands[1]));
9695 DONE;
9696
9697 default:
9698 gcc_unreachable ();
9699 }
9700 }
9701 }")
9702
9703 (define_expand "call_value"
9704 [(parallel [(set (match_operand 0 "" "")
9705 (call (mem:SI (match_operand 1 "address_operand" ""))
9706 (match_operand 2 "" "")))
9707 (use (match_operand 3 "" ""))
9708 (clobber (scratch:SI))])]
9709 ""
9710 "
9711 {
9712 #if TARGET_MACHO
9713 if (MACHOPIC_INDIRECT)
9714 operands[1] = machopic_indirect_call_target (operands[1]);
9715 #endif
9716
9717 gcc_assert (GET_CODE (operands[1]) == MEM);
9718 gcc_assert (GET_CODE (operands[2]) == CONST_INT);
9719
9720 operands[1] = XEXP (operands[1], 0);
9721
9722 if (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT
9723 && flag_pic
9724 && GET_CODE (operands[1]) == SYMBOL_REF
9725 && !SYMBOL_REF_LOCAL_P (operands[1]))
9726 {
9727 rtx call;
9728 rtvec tmp;
9729
9730 tmp = gen_rtvec (3,
9731 gen_rtx_SET (VOIDmode,
9732 operands[0],
9733 gen_rtx_CALL (VOIDmode,
9734 gen_rtx_MEM (SImode,
9735 operands[1]),
9736 operands[2])),
9737 gen_rtx_USE (VOIDmode, operands[3]),
9738 gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (SImode)));
9739 call = emit_call_insn (gen_rtx_PARALLEL (VOIDmode, tmp));
9740 use_reg (&CALL_INSN_FUNCTION_USAGE (call), pic_offset_table_rtx);
9741 DONE;
9742 }
9743
9744 if (GET_CODE (operands[1]) != SYMBOL_REF
9745 || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[1]))
9746 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[3]) & CALL_LONG) != 0))
9747 {
9748 if (INTVAL (operands[3]) & CALL_LONG)
9749 operands[1] = rs6000_longcall_ref (operands[1]);
9750
9751 switch (DEFAULT_ABI)
9752 {
9753 case ABI_V4:
9754 case ABI_DARWIN:
9755 operands[1] = force_reg (Pmode, operands[1]);
9756 break;
9757
9758 case ABI_AIX:
9759 /* AIX function pointers are really pointers to a three word
9760 area. */
9761 emit_call_insn (TARGET_32BIT
9762 ? gen_call_value_indirect_aix32 (operands[0],
9763 force_reg (SImode,
9764 operands[1]),
9765 operands[2])
9766 : gen_call_value_indirect_aix64 (operands[0],
9767 force_reg (DImode,
9768 operands[1]),
9769 operands[2]));
9770 DONE;
9771
9772 default:
9773 gcc_unreachable ();
9774 }
9775 }
9776 }")
9777
9778 ;; Call to function in current module. No TOC pointer reload needed.
9779 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
9780 ;; either the function was not prototyped, or it was prototyped as a
9781 ;; variable argument function. It is > 0 if FP registers were passed
9782 ;; and < 0 if they were not.
9783
9784 (define_insn "*call_local32"
9785 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
9786 (match_operand 1 "" "g,g"))
9787 (use (match_operand:SI 2 "immediate_operand" "O,n"))
9788 (clobber (match_scratch:SI 3 "=l,l"))]
9789 "(INTVAL (operands[2]) & CALL_LONG) == 0"
9790 "*
9791 {
9792 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
9793 output_asm_insn (\"crxor 6,6,6\", operands);
9794
9795 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
9796 output_asm_insn (\"creqv 6,6,6\", operands);
9797
9798 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
9799 }"
9800 [(set_attr "type" "branch")
9801 (set_attr "length" "4,8")])
9802
9803 (define_insn "*call_local64"
9804 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
9805 (match_operand 1 "" "g,g"))
9806 (use (match_operand:SI 2 "immediate_operand" "O,n"))
9807 (clobber (match_scratch:SI 3 "=l,l"))]
9808 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
9809 "*
9810 {
9811 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
9812 output_asm_insn (\"crxor 6,6,6\", operands);
9813
9814 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
9815 output_asm_insn (\"creqv 6,6,6\", operands);
9816
9817 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
9818 }"
9819 [(set_attr "type" "branch")
9820 (set_attr "length" "4,8")])
9821
9822 (define_insn "*call_value_local32"
9823 [(set (match_operand 0 "" "")
9824 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
9825 (match_operand 2 "" "g,g")))
9826 (use (match_operand:SI 3 "immediate_operand" "O,n"))
9827 (clobber (match_scratch:SI 4 "=l,l"))]
9828 "(INTVAL (operands[3]) & CALL_LONG) == 0"
9829 "*
9830 {
9831 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
9832 output_asm_insn (\"crxor 6,6,6\", operands);
9833
9834 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
9835 output_asm_insn (\"creqv 6,6,6\", operands);
9836
9837 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
9838 }"
9839 [(set_attr "type" "branch")
9840 (set_attr "length" "4,8")])
9841
9842
9843 (define_insn "*call_value_local64"
9844 [(set (match_operand 0 "" "")
9845 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
9846 (match_operand 2 "" "g,g")))
9847 (use (match_operand:SI 3 "immediate_operand" "O,n"))
9848 (clobber (match_scratch:SI 4 "=l,l"))]
9849 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
9850 "*
9851 {
9852 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
9853 output_asm_insn (\"crxor 6,6,6\", operands);
9854
9855 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
9856 output_asm_insn (\"creqv 6,6,6\", operands);
9857
9858 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
9859 }"
9860 [(set_attr "type" "branch")
9861 (set_attr "length" "4,8")])
9862
9863 ;; Call to function which may be in another module. Restore the TOC
9864 ;; pointer (r2) after the call unless this is System V.
9865 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
9866 ;; either the function was not prototyped, or it was prototyped as a
9867 ;; variable argument function. It is > 0 if FP registers were passed
9868 ;; and < 0 if they were not.
9869
9870 (define_insn "*call_indirect_nonlocal_aix32"
9871 [(call (mem:SI (match_operand:SI 0 "register_operand" "c,*l"))
9872 (match_operand 1 "" "g,g"))
9873 (use (reg:SI 2))
9874 (use (reg:SI 11))
9875 (set (reg:SI 2)
9876 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9877 (clobber (match_scratch:SI 2 "=l,l"))]
9878 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
9879 "b%T0l\;{l|lwz} 2,20(1)"
9880 [(set_attr "type" "jmpreg")
9881 (set_attr "length" "8")])
9882
9883 (define_insn "*call_nonlocal_aix32"
9884 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
9885 (match_operand 1 "" "g"))
9886 (use (match_operand:SI 2 "immediate_operand" "O"))
9887 (clobber (match_scratch:SI 3 "=l"))]
9888 "TARGET_32BIT
9889 && DEFAULT_ABI == ABI_AIX
9890 && (INTVAL (operands[2]) & CALL_LONG) == 0"
9891 "bl %z0\;%."
9892 [(set_attr "type" "branch")
9893 (set_attr "length" "8")])
9894
9895 (define_insn "*call_indirect_nonlocal_aix64"
9896 [(call (mem:SI (match_operand:DI 0 "register_operand" "c,*l"))
9897 (match_operand 1 "" "g,g"))
9898 (use (reg:DI 2))
9899 (use (reg:DI 11))
9900 (set (reg:DI 2)
9901 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9902 (clobber (match_scratch:SI 2 "=l,l"))]
9903 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
9904 "b%T0l\;ld 2,40(1)"
9905 [(set_attr "type" "jmpreg")
9906 (set_attr "length" "8")])
9907
9908 (define_insn "*call_nonlocal_aix64"
9909 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
9910 (match_operand 1 "" "g"))
9911 (use (match_operand:SI 2 "immediate_operand" "O"))
9912 (clobber (match_scratch:SI 3 "=l"))]
9913 "TARGET_64BIT
9914 && DEFAULT_ABI == ABI_AIX
9915 && (INTVAL (operands[2]) & CALL_LONG) == 0"
9916 "bl %z0\;%."
9917 [(set_attr "type" "branch")
9918 (set_attr "length" "8")])
9919
9920 (define_insn "*call_value_indirect_nonlocal_aix32"
9921 [(set (match_operand 0 "" "")
9922 (call (mem:SI (match_operand:SI 1 "register_operand" "c,*l"))
9923 (match_operand 2 "" "g,g")))
9924 (use (reg:SI 2))
9925 (use (reg:SI 11))
9926 (set (reg:SI 2)
9927 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9928 (clobber (match_scratch:SI 3 "=l,l"))]
9929 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
9930 "b%T1l\;{l|lwz} 2,20(1)"
9931 [(set_attr "type" "jmpreg")
9932 (set_attr "length" "8")])
9933
9934 (define_insn "*call_value_nonlocal_aix32"
9935 [(set (match_operand 0 "" "")
9936 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
9937 (match_operand 2 "" "g")))
9938 (use (match_operand:SI 3 "immediate_operand" "O"))
9939 (clobber (match_scratch:SI 4 "=l"))]
9940 "TARGET_32BIT
9941 && DEFAULT_ABI == ABI_AIX
9942 && (INTVAL (operands[3]) & CALL_LONG) == 0"
9943 "bl %z1\;%."
9944 [(set_attr "type" "branch")
9945 (set_attr "length" "8")])
9946
9947 (define_insn "*call_value_indirect_nonlocal_aix64"
9948 [(set (match_operand 0 "" "")
9949 (call (mem:SI (match_operand:DI 1 "register_operand" "c,*l"))
9950 (match_operand 2 "" "g,g")))
9951 (use (reg:DI 2))
9952 (use (reg:DI 11))
9953 (set (reg:DI 2)
9954 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9955 (clobber (match_scratch:SI 3 "=l,l"))]
9956 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
9957 "b%T1l\;ld 2,40(1)"
9958 [(set_attr "type" "jmpreg")
9959 (set_attr "length" "8")])
9960
9961 (define_insn "*call_value_nonlocal_aix64"
9962 [(set (match_operand 0 "" "")
9963 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
9964 (match_operand 2 "" "g")))
9965 (use (match_operand:SI 3 "immediate_operand" "O"))
9966 (clobber (match_scratch:SI 4 "=l"))]
9967 "TARGET_64BIT
9968 && DEFAULT_ABI == ABI_AIX
9969 && (INTVAL (operands[3]) & CALL_LONG) == 0"
9970 "bl %z1\;%."
9971 [(set_attr "type" "branch")
9972 (set_attr "length" "8")])
9973
9974 ;; A function pointer under System V is just a normal pointer
9975 ;; operands[0] is the function pointer
9976 ;; operands[1] is the stack size to clean up
9977 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
9978 ;; which indicates how to set cr1
9979
9980 (define_insn "*call_indirect_nonlocal_sysv"
9981 [(call (mem:SI (match_operand:SI 0 "register_operand" "c,*l,c,*l"))
9982 (match_operand 1 "" "g,g,g,g"))
9983 (use (match_operand:SI 2 "immediate_operand" "O,O,n,n"))
9984 (clobber (match_scratch:SI 3 "=l,l,l,l"))]
9985 "DEFAULT_ABI == ABI_V4
9986 || DEFAULT_ABI == ABI_DARWIN"
9987 {
9988 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
9989 output_asm_insn ("crxor 6,6,6", operands);
9990
9991 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
9992 output_asm_insn ("creqv 6,6,6", operands);
9993
9994 return "b%T0l";
9995 }
9996 [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
9997 (set_attr "length" "4,4,8,8")])
9998
9999 (define_insn "*call_nonlocal_sysv"
10000 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10001 (match_operand 1 "" "g,g"))
10002 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10003 (clobber (match_scratch:SI 3 "=l,l"))]
10004 "(DEFAULT_ABI == ABI_DARWIN
10005 || (DEFAULT_ABI == ABI_V4
10006 && (INTVAL (operands[2]) & CALL_LONG) == 0))"
10007 {
10008 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10009 output_asm_insn ("crxor 6,6,6", operands);
10010
10011 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10012 output_asm_insn ("creqv 6,6,6", operands);
10013
10014 #if TARGET_MACHO
10015 return output_call(insn, operands, 0, 2);
10016 #else
10017 if (DEFAULT_ABI == ABI_V4 && flag_pic)
10018 {
10019 if (TARGET_SECURE_PLT && flag_pic == 2)
10020 /* The magic 32768 offset here and in the other sysv call insns
10021 corresponds to the offset of r30 in .got2, as given by LCTOC1.
10022 See sysv4.h:toc_section. */
10023 return "bl %z0+32768@plt";
10024 else
10025 return "bl %z0@plt";
10026 }
10027 else
10028 return "bl %z0";
10029 #endif
10030 }
10031 [(set_attr "type" "branch,branch")
10032 (set_attr "length" "4,8")])
10033
10034 (define_insn "*call_value_indirect_nonlocal_sysv"
10035 [(set (match_operand 0 "" "")
10036 (call (mem:SI (match_operand:SI 1 "register_operand" "c,*l,c,*l"))
10037 (match_operand 2 "" "g,g,g,g")))
10038 (use (match_operand:SI 3 "immediate_operand" "O,O,n,n"))
10039 (clobber (match_scratch:SI 4 "=l,l,l,l"))]
10040 "DEFAULT_ABI == ABI_V4
10041 || DEFAULT_ABI == ABI_DARWIN"
10042 {
10043 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10044 output_asm_insn ("crxor 6,6,6", operands);
10045
10046 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10047 output_asm_insn ("creqv 6,6,6", operands);
10048
10049 return "b%T1l";
10050 }
10051 [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
10052 (set_attr "length" "4,4,8,8")])
10053
10054 (define_insn "*call_value_nonlocal_sysv"
10055 [(set (match_operand 0 "" "")
10056 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10057 (match_operand 2 "" "g,g")))
10058 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10059 (clobber (match_scratch:SI 4 "=l,l"))]
10060 "(DEFAULT_ABI == ABI_DARWIN
10061 || (DEFAULT_ABI == ABI_V4
10062 && (INTVAL (operands[3]) & CALL_LONG) == 0))"
10063 {
10064 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10065 output_asm_insn ("crxor 6,6,6", operands);
10066
10067 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10068 output_asm_insn ("creqv 6,6,6", operands);
10069
10070 #if TARGET_MACHO
10071 return output_call(insn, operands, 1, 3);
10072 #else
10073 if (DEFAULT_ABI == ABI_V4 && flag_pic)
10074 {
10075 if (TARGET_SECURE_PLT && flag_pic == 2)
10076 return "bl %z1+32768@plt";
10077 else
10078 return "bl %z1@plt";
10079 }
10080 else
10081 return "bl %z1";
10082 #endif
10083 }
10084 [(set_attr "type" "branch,branch")
10085 (set_attr "length" "4,8")])
10086
10087 ;; Call subroutine returning any type.
10088 (define_expand "untyped_call"
10089 [(parallel [(call (match_operand 0 "" "")
10090 (const_int 0))
10091 (match_operand 1 "" "")
10092 (match_operand 2 "" "")])]
10093 ""
10094 "
10095 {
10096 int i;
10097
10098 emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
10099
10100 for (i = 0; i < XVECLEN (operands[2], 0); i++)
10101 {
10102 rtx set = XVECEXP (operands[2], 0, i);
10103 emit_move_insn (SET_DEST (set), SET_SRC (set));
10104 }
10105
10106 /* The optimizer does not know that the call sets the function value
10107 registers we stored in the result block. We avoid problems by
10108 claiming that all hard registers are used and clobbered at this
10109 point. */
10110 emit_insn (gen_blockage ());
10111
10112 DONE;
10113 }")
10114
10115 ;; sibling call patterns
10116 (define_expand "sibcall"
10117 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10118 (match_operand 1 "" ""))
10119 (use (match_operand 2 "" ""))
10120 (use (match_operand 3 "" ""))
10121 (return)])]
10122 ""
10123 "
10124 {
10125 #if TARGET_MACHO
10126 if (MACHOPIC_INDIRECT)
10127 operands[0] = machopic_indirect_call_target (operands[0]);
10128 #endif
10129
10130 gcc_assert (GET_CODE (operands[0]) == MEM);
10131 gcc_assert (GET_CODE (operands[1]) == CONST_INT);
10132
10133 operands[0] = XEXP (operands[0], 0);
10134 operands[3] = gen_reg_rtx (SImode);
10135
10136 }")
10137
10138 ;; this and similar patterns must be marked as using LR, otherwise
10139 ;; dataflow will try to delete the store into it. This is true
10140 ;; even when the actual reg to jump to is in CTR, when LR was
10141 ;; saved and restored around the PIC-setting BCL.
10142 (define_insn "*sibcall_local32"
10143 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10144 (match_operand 1 "" "g,g"))
10145 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10146 (use (match_operand:SI 3 "register_operand" "l,l"))
10147 (return)]
10148 "(INTVAL (operands[2]) & CALL_LONG) == 0"
10149 "*
10150 {
10151 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10152 output_asm_insn (\"crxor 6,6,6\", operands);
10153
10154 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10155 output_asm_insn (\"creqv 6,6,6\", operands);
10156
10157 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10158 }"
10159 [(set_attr "type" "branch")
10160 (set_attr "length" "4,8")])
10161
10162 (define_insn "*sibcall_local64"
10163 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10164 (match_operand 1 "" "g,g"))
10165 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10166 (use (match_operand:SI 3 "register_operand" "l,l"))
10167 (return)]
10168 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10169 "*
10170 {
10171 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10172 output_asm_insn (\"crxor 6,6,6\", operands);
10173
10174 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10175 output_asm_insn (\"creqv 6,6,6\", operands);
10176
10177 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10178 }"
10179 [(set_attr "type" "branch")
10180 (set_attr "length" "4,8")])
10181
10182 (define_insn "*sibcall_value_local32"
10183 [(set (match_operand 0 "" "")
10184 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10185 (match_operand 2 "" "g,g")))
10186 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10187 (use (match_operand:SI 4 "register_operand" "l,l"))
10188 (return)]
10189 "(INTVAL (operands[3]) & CALL_LONG) == 0"
10190 "*
10191 {
10192 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10193 output_asm_insn (\"crxor 6,6,6\", operands);
10194
10195 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10196 output_asm_insn (\"creqv 6,6,6\", operands);
10197
10198 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10199 }"
10200 [(set_attr "type" "branch")
10201 (set_attr "length" "4,8")])
10202
10203
10204 (define_insn "*sibcall_value_local64"
10205 [(set (match_operand 0 "" "")
10206 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10207 (match_operand 2 "" "g,g")))
10208 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10209 (use (match_operand:SI 4 "register_operand" "l,l"))
10210 (return)]
10211 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10212 "*
10213 {
10214 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10215 output_asm_insn (\"crxor 6,6,6\", operands);
10216
10217 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10218 output_asm_insn (\"creqv 6,6,6\", operands);
10219
10220 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10221 }"
10222 [(set_attr "type" "branch")
10223 (set_attr "length" "4,8")])
10224
10225 (define_insn "*sibcall_nonlocal_aix32"
10226 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
10227 (match_operand 1 "" "g"))
10228 (use (match_operand:SI 2 "immediate_operand" "O"))
10229 (use (match_operand:SI 3 "register_operand" "l"))
10230 (return)]
10231 "TARGET_32BIT
10232 && DEFAULT_ABI == ABI_AIX
10233 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10234 "b %z0"
10235 [(set_attr "type" "branch")
10236 (set_attr "length" "4")])
10237
10238 (define_insn "*sibcall_nonlocal_aix64"
10239 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
10240 (match_operand 1 "" "g"))
10241 (use (match_operand:SI 2 "immediate_operand" "O"))
10242 (use (match_operand:SI 3 "register_operand" "l"))
10243 (return)]
10244 "TARGET_64BIT
10245 && DEFAULT_ABI == ABI_AIX
10246 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10247 "b %z0"
10248 [(set_attr "type" "branch")
10249 (set_attr "length" "4")])
10250
10251 (define_insn "*sibcall_value_nonlocal_aix32"
10252 [(set (match_operand 0 "" "")
10253 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
10254 (match_operand 2 "" "g")))
10255 (use (match_operand:SI 3 "immediate_operand" "O"))
10256 (use (match_operand:SI 4 "register_operand" "l"))
10257 (return)]
10258 "TARGET_32BIT
10259 && DEFAULT_ABI == ABI_AIX
10260 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10261 "b %z1"
10262 [(set_attr "type" "branch")
10263 (set_attr "length" "4")])
10264
10265 (define_insn "*sibcall_value_nonlocal_aix64"
10266 [(set (match_operand 0 "" "")
10267 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
10268 (match_operand 2 "" "g")))
10269 (use (match_operand:SI 3 "immediate_operand" "O"))
10270 (use (match_operand:SI 4 "register_operand" "l"))
10271 (return)]
10272 "TARGET_64BIT
10273 && DEFAULT_ABI == ABI_AIX
10274 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10275 "b %z1"
10276 [(set_attr "type" "branch")
10277 (set_attr "length" "4")])
10278
10279 (define_insn "*sibcall_nonlocal_sysv"
10280 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10281 (match_operand 1 "" ""))
10282 (use (match_operand 2 "immediate_operand" "O,n"))
10283 (use (match_operand:SI 3 "register_operand" "l,l"))
10284 (return)]
10285 "(DEFAULT_ABI == ABI_DARWIN
10286 || DEFAULT_ABI == ABI_V4)
10287 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10288 "*
10289 {
10290 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10291 output_asm_insn (\"crxor 6,6,6\", operands);
10292
10293 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10294 output_asm_insn (\"creqv 6,6,6\", operands);
10295
10296 if (DEFAULT_ABI == ABI_V4 && flag_pic)
10297 {
10298 if (TARGET_SECURE_PLT && flag_pic == 2)
10299 return \"b %z0+32768@plt\";
10300 else
10301 return \"b %z0@plt\";
10302 }
10303 else
10304 return \"b %z0\";
10305 }"
10306 [(set_attr "type" "branch,branch")
10307 (set_attr "length" "4,8")])
10308
10309 (define_expand "sibcall_value"
10310 [(parallel [(set (match_operand 0 "register_operand" "")
10311 (call (mem:SI (match_operand 1 "address_operand" ""))
10312 (match_operand 2 "" "")))
10313 (use (match_operand 3 "" ""))
10314 (use (match_operand 4 "" ""))
10315 (return)])]
10316 ""
10317 "
10318 {
10319 #if TARGET_MACHO
10320 if (MACHOPIC_INDIRECT)
10321 operands[1] = machopic_indirect_call_target (operands[1]);
10322 #endif
10323
10324 gcc_assert (GET_CODE (operands[1]) == MEM);
10325 gcc_assert (GET_CODE (operands[2]) == CONST_INT);
10326
10327 operands[1] = XEXP (operands[1], 0);
10328 operands[4] = gen_reg_rtx (SImode);
10329
10330 }")
10331
10332 (define_insn "*sibcall_value_nonlocal_sysv"
10333 [(set (match_operand 0 "" "")
10334 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10335 (match_operand 2 "" "")))
10336 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10337 (use (match_operand:SI 4 "register_operand" "l,l"))
10338 (return)]
10339 "(DEFAULT_ABI == ABI_DARWIN
10340 || DEFAULT_ABI == ABI_V4)
10341 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10342 "*
10343 {
10344 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10345 output_asm_insn (\"crxor 6,6,6\", operands);
10346
10347 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10348 output_asm_insn (\"creqv 6,6,6\", operands);
10349
10350 if (DEFAULT_ABI == ABI_V4 && flag_pic)
10351 {
10352 if (TARGET_SECURE_PLT && flag_pic == 2)
10353 return \"b %z1+32768@plt\";
10354 else
10355 return \"b %z1@plt\";
10356 }
10357 else
10358 return \"b %z1\";
10359 }"
10360 [(set_attr "type" "branch,branch")
10361 (set_attr "length" "4,8")])
10362
10363 (define_expand "sibcall_epilogue"
10364 [(use (const_int 0))]
10365 "TARGET_SCHED_PROLOG"
10366 "
10367 {
10368 rs6000_emit_epilogue (TRUE);
10369 DONE;
10370 }")
10371
10372 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
10373 ;; all of memory. This blocks insns from being moved across this point.
10374
10375 (define_insn "blockage"
10376 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCK)]
10377 ""
10378 "")
10379 \f
10380 ;; Compare insns are next. Note that the RS/6000 has two types of compares,
10381 ;; signed & unsigned, and one type of branch.
10382 ;;
10383 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
10384 ;; insns, and branches. We store the operands of compares until we see
10385 ;; how it is used.
10386 (define_expand "cmp<mode>"
10387 [(set (cc0)
10388 (compare (match_operand:GPR 0 "gpc_reg_operand" "")
10389 (match_operand:GPR 1 "reg_or_short_operand" "")))]
10390 ""
10391 "
10392 {
10393 /* Take care of the possibility that operands[1] might be negative but
10394 this might be a logical operation. That insn doesn't exist. */
10395 if (GET_CODE (operands[1]) == CONST_INT
10396 && INTVAL (operands[1]) < 0)
10397 operands[1] = force_reg (<MODE>mode, operands[1]);
10398
10399 rs6000_compare_op0 = operands[0];
10400 rs6000_compare_op1 = operands[1];
10401 rs6000_compare_fp_p = 0;
10402 DONE;
10403 }")
10404
10405 (define_expand "cmp<mode>"
10406 [(set (cc0) (compare (match_operand:FP 0 "gpc_reg_operand" "")
10407 (match_operand:FP 1 "gpc_reg_operand" "")))]
10408 ""
10409 "
10410 {
10411 rs6000_compare_op0 = operands[0];
10412 rs6000_compare_op1 = operands[1];
10413 rs6000_compare_fp_p = 1;
10414 DONE;
10415 }")
10416
10417 (define_expand "beq"
10418 [(use (match_operand 0 "" ""))]
10419 ""
10420 "{ rs6000_emit_cbranch (EQ, operands[0]); DONE; }")
10421
10422 (define_expand "bne"
10423 [(use (match_operand 0 "" ""))]
10424 ""
10425 "{ rs6000_emit_cbranch (NE, operands[0]); DONE; }")
10426
10427 (define_expand "bge"
10428 [(use (match_operand 0 "" ""))]
10429 ""
10430 "{ rs6000_emit_cbranch (GE, operands[0]); DONE; }")
10431
10432 (define_expand "bgt"
10433 [(use (match_operand 0 "" ""))]
10434 ""
10435 "{ rs6000_emit_cbranch (GT, operands[0]); DONE; }")
10436
10437 (define_expand "ble"
10438 [(use (match_operand 0 "" ""))]
10439 ""
10440 "{ rs6000_emit_cbranch (LE, operands[0]); DONE; }")
10441
10442 (define_expand "blt"
10443 [(use (match_operand 0 "" ""))]
10444 ""
10445 "{ rs6000_emit_cbranch (LT, operands[0]); DONE; }")
10446
10447 (define_expand "bgeu"
10448 [(use (match_operand 0 "" ""))]
10449 ""
10450 "{ rs6000_emit_cbranch (GEU, operands[0]); DONE; }")
10451
10452 (define_expand "bgtu"
10453 [(use (match_operand 0 "" ""))]
10454 ""
10455 "{ rs6000_emit_cbranch (GTU, operands[0]); DONE; }")
10456
10457 (define_expand "bleu"
10458 [(use (match_operand 0 "" ""))]
10459 ""
10460 "{ rs6000_emit_cbranch (LEU, operands[0]); DONE; }")
10461
10462 (define_expand "bltu"
10463 [(use (match_operand 0 "" ""))]
10464 ""
10465 "{ rs6000_emit_cbranch (LTU, operands[0]); DONE; }")
10466
10467 (define_expand "bunordered"
10468 [(use (match_operand 0 "" ""))]
10469 "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
10470 "{ rs6000_emit_cbranch (UNORDERED, operands[0]); DONE; }")
10471
10472 (define_expand "bordered"
10473 [(use (match_operand 0 "" ""))]
10474 "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
10475 "{ rs6000_emit_cbranch (ORDERED, operands[0]); DONE; }")
10476
10477 (define_expand "buneq"
10478 [(use (match_operand 0 "" ""))]
10479 ""
10480 "{ rs6000_emit_cbranch (UNEQ, operands[0]); DONE; }")
10481
10482 (define_expand "bunge"
10483 [(use (match_operand 0 "" ""))]
10484 ""
10485 "{ rs6000_emit_cbranch (UNGE, operands[0]); DONE; }")
10486
10487 (define_expand "bungt"
10488 [(use (match_operand 0 "" ""))]
10489 ""
10490 "{ rs6000_emit_cbranch (UNGT, operands[0]); DONE; }")
10491
10492 (define_expand "bunle"
10493 [(use (match_operand 0 "" ""))]
10494 ""
10495 "{ rs6000_emit_cbranch (UNLE, operands[0]); DONE; }")
10496
10497 (define_expand "bunlt"
10498 [(use (match_operand 0 "" ""))]
10499 ""
10500 "{ rs6000_emit_cbranch (UNLT, operands[0]); DONE; }")
10501
10502 (define_expand "bltgt"
10503 [(use (match_operand 0 "" ""))]
10504 ""
10505 "{ rs6000_emit_cbranch (LTGT, operands[0]); DONE; }")
10506
10507 ;; For SNE, we would prefer that the xor/abs sequence be used for integers.
10508 ;; For SEQ, likewise, except that comparisons with zero should be done
10509 ;; with an scc insns. However, due to the order that combine see the
10510 ;; resulting insns, we must, in fact, allow SEQ for integers. Fail in
10511 ;; the cases we don't want to handle.
10512 (define_expand "seq"
10513 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10514 ""
10515 "{ rs6000_emit_sCOND (EQ, operands[0]); DONE; }")
10516
10517 (define_expand "sne"
10518 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10519 ""
10520 "
10521 {
10522 if (! rs6000_compare_fp_p)
10523 FAIL;
10524
10525 rs6000_emit_sCOND (NE, operands[0]);
10526 DONE;
10527 }")
10528
10529 ;; A >= 0 is best done the portable way for A an integer.
10530 (define_expand "sge"
10531 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10532 ""
10533 "
10534 {
10535 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
10536 FAIL;
10537
10538 rs6000_emit_sCOND (GE, operands[0]);
10539 DONE;
10540 }")
10541
10542 ;; A > 0 is best done using the portable sequence, so fail in that case.
10543 (define_expand "sgt"
10544 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10545 ""
10546 "
10547 {
10548 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
10549 FAIL;
10550
10551 rs6000_emit_sCOND (GT, operands[0]);
10552 DONE;
10553 }")
10554
10555 ;; A <= 0 is best done the portable way for A an integer.
10556 (define_expand "sle"
10557 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10558 ""
10559 "
10560 {
10561 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
10562 FAIL;
10563
10564 rs6000_emit_sCOND (LE, operands[0]);
10565 DONE;
10566 }")
10567
10568 ;; A < 0 is best done in the portable way for A an integer.
10569 (define_expand "slt"
10570 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10571 ""
10572 "
10573 {
10574 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
10575 FAIL;
10576
10577 rs6000_emit_sCOND (LT, operands[0]);
10578 DONE;
10579 }")
10580
10581 (define_expand "sgeu"
10582 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10583 ""
10584 "{ rs6000_emit_sCOND (GEU, operands[0]); DONE; }")
10585
10586 (define_expand "sgtu"
10587 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10588 ""
10589 "{ rs6000_emit_sCOND (GTU, operands[0]); DONE; }")
10590
10591 (define_expand "sleu"
10592 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10593 ""
10594 "{ rs6000_emit_sCOND (LEU, operands[0]); DONE; }")
10595
10596 (define_expand "sltu"
10597 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10598 ""
10599 "{ rs6000_emit_sCOND (LTU, operands[0]); DONE; }")
10600
10601 (define_expand "sunordered"
10602 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10603 "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
10604 "{ rs6000_emit_sCOND (UNORDERED, operands[0]); DONE; }")
10605
10606 (define_expand "sordered"
10607 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10608 "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
10609 "{ rs6000_emit_sCOND (ORDERED, operands[0]); DONE; }")
10610
10611 (define_expand "suneq"
10612 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10613 ""
10614 "{ rs6000_emit_sCOND (UNEQ, operands[0]); DONE; }")
10615
10616 (define_expand "sunge"
10617 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10618 ""
10619 "{ rs6000_emit_sCOND (UNGE, operands[0]); DONE; }")
10620
10621 (define_expand "sungt"
10622 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10623 ""
10624 "{ rs6000_emit_sCOND (UNGT, operands[0]); DONE; }")
10625
10626 (define_expand "sunle"
10627 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10628 ""
10629 "{ rs6000_emit_sCOND (UNLE, operands[0]); DONE; }")
10630
10631 (define_expand "sunlt"
10632 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10633 ""
10634 "{ rs6000_emit_sCOND (UNLT, operands[0]); DONE; }")
10635
10636 (define_expand "sltgt"
10637 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10638 ""
10639 "{ rs6000_emit_sCOND (LTGT, operands[0]); DONE; }")
10640
10641 (define_expand "stack_protect_set"
10642 [(match_operand 0 "memory_operand" "")
10643 (match_operand 1 "memory_operand" "")]
10644 ""
10645 {
10646 #ifdef TARGET_THREAD_SSP_OFFSET
10647 rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
10648 rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
10649 operands[1] = gen_rtx_MEM (Pmode, addr);
10650 #endif
10651 if (TARGET_64BIT)
10652 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
10653 else
10654 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
10655 DONE;
10656 })
10657
10658 (define_insn "stack_protect_setsi"
10659 [(set (match_operand:SI 0 "memory_operand" "=m")
10660 (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET))
10661 (set (match_scratch:SI 2 "=&r") (const_int 0))]
10662 "TARGET_32BIT"
10663 "{l%U1%X1|lwz%U1%X1} %2,%1\;{st%U0%X0|stw%U0%X0} %2,%0\;{lil|li} %2,0"
10664 [(set_attr "type" "three")
10665 (set_attr "length" "12")])
10666
10667 (define_insn "stack_protect_setdi"
10668 [(set (match_operand:DI 0 "memory_operand" "=m")
10669 (unspec:DI [(match_operand:DI 1 "memory_operand" "m")] UNSPEC_SP_SET))
10670 (set (match_scratch:DI 2 "=&r") (const_int 0))]
10671 "TARGET_64BIT"
10672 "ld%U1%X1 %2,%1\;std%U0%X0 %2,%0\;{lil|li} %2,0"
10673 [(set_attr "type" "three")
10674 (set_attr "length" "12")])
10675
10676 (define_expand "stack_protect_test"
10677 [(match_operand 0 "memory_operand" "")
10678 (match_operand 1 "memory_operand" "")
10679 (match_operand 2 "" "")]
10680 ""
10681 {
10682 #ifdef TARGET_THREAD_SSP_OFFSET
10683 rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
10684 rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
10685 operands[1] = gen_rtx_MEM (Pmode, addr);
10686 #endif
10687 rs6000_compare_op0 = operands[0];
10688 rs6000_compare_op1 = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, operands[1]),
10689 UNSPEC_SP_TEST);
10690 rs6000_compare_fp_p = 0;
10691 emit_jump_insn (gen_beq (operands[2]));
10692 DONE;
10693 })
10694
10695 (define_insn "stack_protect_testsi"
10696 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
10697 (unspec:CCEQ [(match_operand:SI 1 "memory_operand" "m,m")
10698 (match_operand:SI 2 "memory_operand" "m,m")]
10699 UNSPEC_SP_TEST))
10700 (set (match_scratch:SI 4 "=r,r") (const_int 0))
10701 (clobber (match_scratch:SI 3 "=&r,&r"))]
10702 "TARGET_32BIT"
10703 "@
10704 {l%U1%X1|lwz%U1%X1} %3,%1\;{l%U2%X2|lwz%U2%X2} %4,%2\;xor. %3,%3,%4\;{lil|li} %4,0
10705 {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"
10706 [(set_attr "length" "16,20")])
10707
10708 (define_insn "stack_protect_testdi"
10709 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
10710 (unspec:CCEQ [(match_operand:DI 1 "memory_operand" "m,m")
10711 (match_operand:DI 2 "memory_operand" "m,m")]
10712 UNSPEC_SP_TEST))
10713 (set (match_scratch:DI 4 "=r,r") (const_int 0))
10714 (clobber (match_scratch:DI 3 "=&r,&r"))]
10715 "TARGET_64BIT"
10716 "@
10717 ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;xor. %3,%3,%4\;{lil|li} %4,0
10718 ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;cmpld %0,%3,%4\;{lil|li} %3,0\;{lil|li} %4,0"
10719 [(set_attr "length" "16,20")])
10720
10721 \f
10722 ;; Here are the actual compare insns.
10723 (define_insn "*cmp<mode>_internal1"
10724 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
10725 (compare:CC (match_operand:GPR 1 "gpc_reg_operand" "r")
10726 (match_operand:GPR 2 "reg_or_short_operand" "rI")))]
10727 ""
10728 "{cmp%I2|cmp<wd>%I2} %0,%1,%2"
10729 [(set_attr "type" "cmp")])
10730
10731 ;; If we are comparing a register for equality with a large constant,
10732 ;; we can do this with an XOR followed by a compare. But we need a scratch
10733 ;; register for the result of the XOR.
10734
10735 (define_split
10736 [(set (match_operand:CC 0 "cc_reg_operand" "")
10737 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
10738 (match_operand:SI 2 "non_short_cint_operand" "")))
10739 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
10740 "find_single_use (operands[0], insn, 0)
10741 && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
10742 || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
10743 [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
10744 (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
10745 "
10746 {
10747 /* Get the constant we are comparing against, C, and see what it looks like
10748 sign-extended to 16 bits. Then see what constant could be XOR'ed
10749 with C to get the sign-extended value. */
10750
10751 HOST_WIDE_INT c = INTVAL (operands[2]);
10752 HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
10753 HOST_WIDE_INT xorv = c ^ sextc;
10754
10755 operands[4] = GEN_INT (xorv);
10756 operands[5] = GEN_INT (sextc);
10757 }")
10758
10759 (define_insn "*cmpsi_internal2"
10760 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
10761 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
10762 (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
10763 ""
10764 "{cmpl%I2|cmplw%I2} %0,%1,%b2"
10765 [(set_attr "type" "cmp")])
10766
10767 (define_insn "*cmpdi_internal2"
10768 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
10769 (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
10770 (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
10771 ""
10772 "cmpld%I2 %0,%1,%b2"
10773 [(set_attr "type" "cmp")])
10774
10775 ;; The following two insns don't exist as single insns, but if we provide
10776 ;; them, we can swap an add and compare, which will enable us to overlap more
10777 ;; of the required delay between a compare and branch. We generate code for
10778 ;; them by splitting.
10779
10780 (define_insn ""
10781 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
10782 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
10783 (match_operand:SI 2 "short_cint_operand" "i")))
10784 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
10785 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
10786 ""
10787 "#"
10788 [(set_attr "length" "8")])
10789
10790 (define_insn ""
10791 [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
10792 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
10793 (match_operand:SI 2 "u_short_cint_operand" "i")))
10794 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
10795 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
10796 ""
10797 "#"
10798 [(set_attr "length" "8")])
10799
10800 (define_split
10801 [(set (match_operand:CC 3 "cc_reg_operand" "")
10802 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
10803 (match_operand:SI 2 "short_cint_operand" "")))
10804 (set (match_operand:SI 0 "gpc_reg_operand" "")
10805 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
10806 ""
10807 [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
10808 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
10809
10810 (define_split
10811 [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
10812 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
10813 (match_operand:SI 2 "u_short_cint_operand" "")))
10814 (set (match_operand:SI 0 "gpc_reg_operand" "")
10815 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
10816 ""
10817 [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
10818 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
10819
10820 (define_insn "*cmpsf_internal1"
10821 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10822 (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
10823 (match_operand:SF 2 "gpc_reg_operand" "f")))]
10824 "TARGET_HARD_FLOAT && TARGET_FPRS"
10825 "fcmpu %0,%1,%2"
10826 [(set_attr "type" "fpcompare")])
10827
10828 (define_insn "*cmpdf_internal1"
10829 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10830 (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
10831 (match_operand:DF 2 "gpc_reg_operand" "f")))]
10832 "TARGET_HARD_FLOAT && TARGET_FPRS"
10833 "fcmpu %0,%1,%2"
10834 [(set_attr "type" "fpcompare")])
10835
10836 ;; Only need to compare second words if first words equal
10837 (define_insn "*cmptf_internal1"
10838 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10839 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
10840 (match_operand:TF 2 "gpc_reg_operand" "f")))]
10841 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && !TARGET_XL_COMPAT
10842 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
10843 "fcmpu %0,%1,%2\;bne %0,$+8\;fcmpu %0,%L1,%L2"
10844 [(set_attr "type" "fpcompare")
10845 (set_attr "length" "12")])
10846
10847 (define_insn_and_split "*cmptf_internal2"
10848 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10849 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
10850 (match_operand:TF 2 "gpc_reg_operand" "f")))
10851 (clobber (match_scratch:DF 3 "=f"))
10852 (clobber (match_scratch:DF 4 "=f"))
10853 (clobber (match_scratch:DF 5 "=f"))
10854 (clobber (match_scratch:DF 6 "=f"))
10855 (clobber (match_scratch:DF 7 "=f"))
10856 (clobber (match_scratch:DF 8 "=f"))
10857 (clobber (match_scratch:DF 9 "=f"))
10858 (clobber (match_scratch:DF 10 "=f"))]
10859 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && TARGET_XL_COMPAT
10860 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
10861 "#"
10862 "&& reload_completed"
10863 [(set (match_dup 3) (match_dup 13))
10864 (set (match_dup 4) (match_dup 14))
10865 (set (match_dup 9) (abs:DF (match_dup 5)))
10866 (set (match_dup 0) (compare:CCFP (match_dup 9) (match_dup 3)))
10867 (set (pc) (if_then_else (ne (match_dup 0) (const_int 0))
10868 (label_ref (match_dup 11))
10869 (pc)))
10870 (set (match_dup 0) (compare:CCFP (match_dup 5) (match_dup 7)))
10871 (set (pc) (label_ref (match_dup 12)))
10872 (match_dup 11)
10873 (set (match_dup 10) (minus:DF (match_dup 5) (match_dup 7)))
10874 (set (match_dup 9) (minus:DF (match_dup 6) (match_dup 8)))
10875 (set (match_dup 9) (plus:DF (match_dup 10) (match_dup 9)))
10876 (set (match_dup 0) (compare:CCFP (match_dup 7) (match_dup 4)))
10877 (match_dup 12)]
10878 {
10879 REAL_VALUE_TYPE rv;
10880 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
10881 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
10882
10883 operands[5] = simplify_gen_subreg (DFmode, operands[1], TFmode, hi_word);
10884 operands[6] = simplify_gen_subreg (DFmode, operands[1], TFmode, lo_word);
10885 operands[7] = simplify_gen_subreg (DFmode, operands[2], TFmode, hi_word);
10886 operands[8] = simplify_gen_subreg (DFmode, operands[2], TFmode, lo_word);
10887 operands[11] = gen_label_rtx ();
10888 operands[12] = gen_label_rtx ();
10889 real_inf (&rv);
10890 operands[13] = force_const_mem (DFmode,
10891 CONST_DOUBLE_FROM_REAL_VALUE (rv, DFmode));
10892 operands[14] = force_const_mem (DFmode,
10893 CONST_DOUBLE_FROM_REAL_VALUE (dconst0,
10894 DFmode));
10895 if (TARGET_TOC)
10896 {
10897 operands[13] = gen_const_mem (DFmode,
10898 create_TOC_reference (XEXP (operands[13], 0)));
10899 operands[14] = gen_const_mem (DFmode,
10900 create_TOC_reference (XEXP (operands[14], 0)));
10901 set_mem_alias_set (operands[13], get_TOC_alias_set ());
10902 set_mem_alias_set (operands[14], get_TOC_alias_set ());
10903 }
10904 })
10905 \f
10906 ;; Now we have the scc insns. We can do some combinations because of the
10907 ;; way the machine works.
10908 ;;
10909 ;; Note that this is probably faster if we can put an insn between the
10910 ;; mfcr and rlinm, but this is tricky. Let's leave it for now. In most
10911 ;; cases the insns below which don't use an intermediate CR field will
10912 ;; be used instead.
10913 (define_insn ""
10914 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10915 (match_operator:SI 1 "scc_comparison_operator"
10916 [(match_operand 2 "cc_reg_operand" "y")
10917 (const_int 0)]))]
10918 ""
10919 "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
10920 [(set (attr "type")
10921 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
10922 (const_string "mfcrf")
10923 ]
10924 (const_string "mfcr")))
10925 (set_attr "length" "8")])
10926
10927 ;; Same as above, but get the GT bit.
10928 (define_insn "move_from_CR_gt_bit"
10929 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10930 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_GT))]
10931 "TARGET_E500"
10932 "mfcr %0\;{rlinm|rlwinm} %0,%0,%D1,31,31"
10933 [(set_attr "type" "mfcr")
10934 (set_attr "length" "8")])
10935
10936 ;; Same as above, but get the OV/ORDERED bit.
10937 (define_insn "move_from_CR_ov_bit"
10938 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10939 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_OV))]
10940 "TARGET_ISEL"
10941 "mfcr %0\;{rlinm|rlwinm} %0,%0,%t1,1"
10942 [(set_attr "type" "mfcr")
10943 (set_attr "length" "8")])
10944
10945 (define_insn ""
10946 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10947 (match_operator:DI 1 "scc_comparison_operator"
10948 [(match_operand 2 "cc_reg_operand" "y")
10949 (const_int 0)]))]
10950 "TARGET_POWERPC64"
10951 "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
10952 [(set (attr "type")
10953 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
10954 (const_string "mfcrf")
10955 ]
10956 (const_string "mfcr")))
10957 (set_attr "length" "8")])
10958
10959 (define_insn ""
10960 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
10961 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
10962 [(match_operand 2 "cc_reg_operand" "y,y")
10963 (const_int 0)])
10964 (const_int 0)))
10965 (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
10966 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
10967 "TARGET_32BIT"
10968 "@
10969 mfcr %3%Q2\;{rlinm.|rlwinm.} %3,%3,%J1,1
10970 #"
10971 [(set_attr "type" "delayed_compare")
10972 (set_attr "length" "8,16")])
10973
10974 (define_split
10975 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
10976 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
10977 [(match_operand 2 "cc_reg_operand" "")
10978 (const_int 0)])
10979 (const_int 0)))
10980 (set (match_operand:SI 3 "gpc_reg_operand" "")
10981 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
10982 "TARGET_32BIT && reload_completed"
10983 [(set (match_dup 3)
10984 (match_op_dup 1 [(match_dup 2) (const_int 0)]))
10985 (set (match_dup 0)
10986 (compare:CC (match_dup 3)
10987 (const_int 0)))]
10988 "")
10989
10990 (define_insn ""
10991 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10992 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
10993 [(match_operand 2 "cc_reg_operand" "y")
10994 (const_int 0)])
10995 (match_operand:SI 3 "const_int_operand" "n")))]
10996 ""
10997 "*
10998 {
10999 int is_bit = ccr_bit (operands[1], 1);
11000 int put_bit = 31 - (INTVAL (operands[3]) & 31);
11001 int count;
11002
11003 if (is_bit >= put_bit)
11004 count = is_bit - put_bit;
11005 else
11006 count = 32 - (put_bit - is_bit);
11007
11008 operands[4] = GEN_INT (count);
11009 operands[5] = GEN_INT (put_bit);
11010
11011 return \"mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
11012 }"
11013 [(set (attr "type")
11014 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
11015 (const_string "mfcrf")
11016 ]
11017 (const_string "mfcr")))
11018 (set_attr "length" "8")])
11019
11020 (define_insn ""
11021 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11022 (compare:CC
11023 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11024 [(match_operand 2 "cc_reg_operand" "y,y")
11025 (const_int 0)])
11026 (match_operand:SI 3 "const_int_operand" "n,n"))
11027 (const_int 0)))
11028 (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
11029 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11030 (match_dup 3)))]
11031 ""
11032 "*
11033 {
11034 int is_bit = ccr_bit (operands[1], 1);
11035 int put_bit = 31 - (INTVAL (operands[3]) & 31);
11036 int count;
11037
11038 /* Force split for non-cc0 compare. */
11039 if (which_alternative == 1)
11040 return \"#\";
11041
11042 if (is_bit >= put_bit)
11043 count = is_bit - put_bit;
11044 else
11045 count = 32 - (put_bit - is_bit);
11046
11047 operands[5] = GEN_INT (count);
11048 operands[6] = GEN_INT (put_bit);
11049
11050 return \"mfcr %4%Q2\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
11051 }"
11052 [(set_attr "type" "delayed_compare")
11053 (set_attr "length" "8,16")])
11054
11055 (define_split
11056 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11057 (compare:CC
11058 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11059 [(match_operand 2 "cc_reg_operand" "")
11060 (const_int 0)])
11061 (match_operand:SI 3 "const_int_operand" ""))
11062 (const_int 0)))
11063 (set (match_operand:SI 4 "gpc_reg_operand" "")
11064 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11065 (match_dup 3)))]
11066 "reload_completed"
11067 [(set (match_dup 4)
11068 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11069 (match_dup 3)))
11070 (set (match_dup 0)
11071 (compare:CC (match_dup 4)
11072 (const_int 0)))]
11073 "")
11074
11075 ;; There is a 3 cycle delay between consecutive mfcr instructions
11076 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
11077
11078 (define_peephole
11079 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11080 (match_operator:SI 1 "scc_comparison_operator"
11081 [(match_operand 2 "cc_reg_operand" "y")
11082 (const_int 0)]))
11083 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
11084 (match_operator:SI 4 "scc_comparison_operator"
11085 [(match_operand 5 "cc_reg_operand" "y")
11086 (const_int 0)]))]
11087 "REGNO (operands[2]) != REGNO (operands[5])"
11088 "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
11089 [(set_attr "type" "mfcr")
11090 (set_attr "length" "12")])
11091
11092 (define_peephole
11093 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11094 (match_operator:DI 1 "scc_comparison_operator"
11095 [(match_operand 2 "cc_reg_operand" "y")
11096 (const_int 0)]))
11097 (set (match_operand:DI 3 "gpc_reg_operand" "=r")
11098 (match_operator:DI 4 "scc_comparison_operator"
11099 [(match_operand 5 "cc_reg_operand" "y")
11100 (const_int 0)]))]
11101 "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
11102 "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
11103 [(set_attr "type" "mfcr")
11104 (set_attr "length" "12")])
11105
11106 ;; There are some scc insns that can be done directly, without a compare.
11107 ;; These are faster because they don't involve the communications between
11108 ;; the FXU and branch units. In fact, we will be replacing all of the
11109 ;; integer scc insns here or in the portable methods in emit_store_flag.
11110 ;;
11111 ;; Also support (neg (scc ..)) since that construct is used to replace
11112 ;; branches, (plus (scc ..) ..) since that construct is common and
11113 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
11114 ;; cases where it is no more expensive than (neg (scc ..)).
11115
11116 ;; Have reload force a constant into a register for the simple insns that
11117 ;; otherwise won't accept constants. We do this because it is faster than
11118 ;; the cmp/mfcr sequence we would otherwise generate.
11119
11120 (define_mode_attr scc_eq_op2 [(SI "rKLI")
11121 (DI "rKJI")])
11122
11123 (define_insn_and_split "*eq<mode>"
11124 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
11125 (eq:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
11126 (match_operand:GPR 2 "scc_eq_operand" "<scc_eq_op2>")))]
11127 ""
11128 "#"
11129 ""
11130 [(set (match_dup 0)
11131 (clz:GPR (match_dup 3)))
11132 (set (match_dup 0)
11133 (lshiftrt:GPR (match_dup 0) (match_dup 4)))]
11134 {
11135 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
11136 {
11137 /* Use output operand as intermediate. */
11138 operands[3] = operands[0];
11139
11140 if (logical_operand (operands[2], <MODE>mode))
11141 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
11142 gen_rtx_XOR (<MODE>mode,
11143 operands[1], operands[2])));
11144 else
11145 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
11146 gen_rtx_PLUS (<MODE>mode, operands[1],
11147 negate_rtx (<MODE>mode,
11148 operands[2]))));
11149 }
11150 else
11151 operands[3] = operands[1];
11152
11153 operands[4] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
11154 })
11155
11156 (define_insn_and_split "*eq<mode>_compare"
11157 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
11158 (compare:CC
11159 (eq:P (match_operand:P 1 "gpc_reg_operand" "=r")
11160 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))
11161 (const_int 0)))
11162 (set (match_operand:P 0 "gpc_reg_operand" "=r")
11163 (eq:P (match_dup 1) (match_dup 2)))]
11164 ""
11165 "#"
11166 ""
11167 [(set (match_dup 0)
11168 (clz:P (match_dup 4)))
11169 (parallel [(set (match_dup 3)
11170 (compare:CC (lshiftrt:P (match_dup 0) (match_dup 5))
11171 (const_int 0)))
11172 (set (match_dup 0)
11173 (lshiftrt:P (match_dup 0) (match_dup 5)))])]
11174 {
11175 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
11176 {
11177 /* Use output operand as intermediate. */
11178 operands[4] = operands[0];
11179
11180 if (logical_operand (operands[2], <MODE>mode))
11181 emit_insn (gen_rtx_SET (VOIDmode, operands[4],
11182 gen_rtx_XOR (<MODE>mode,
11183 operands[1], operands[2])));
11184 else
11185 emit_insn (gen_rtx_SET (VOIDmode, operands[4],
11186 gen_rtx_PLUS (<MODE>mode, operands[1],
11187 negate_rtx (<MODE>mode,
11188 operands[2]))));
11189 }
11190 else
11191 operands[4] = operands[1];
11192
11193 operands[5] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
11194 })
11195
11196 ;; We have insns of the form shown by the first define_insn below. If
11197 ;; there is something inside the comparison operation, we must split it.
11198 (define_split
11199 [(set (match_operand:SI 0 "gpc_reg_operand" "")
11200 (plus:SI (match_operator 1 "comparison_operator"
11201 [(match_operand:SI 2 "" "")
11202 (match_operand:SI 3
11203 "reg_or_cint_operand" "")])
11204 (match_operand:SI 4 "gpc_reg_operand" "")))
11205 (clobber (match_operand:SI 5 "register_operand" ""))]
11206 "! gpc_reg_operand (operands[2], SImode)"
11207 [(set (match_dup 5) (match_dup 2))
11208 (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
11209 (match_dup 4)))])
11210
11211 (define_insn ""
11212 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
11213 (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11214 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I"))
11215 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
11216 "TARGET_32BIT"
11217 "@
11218 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11219 {sfi|subfic} %0,%1,0\;{aze|addze} %0,%3
11220 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11221 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11222 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
11223 [(set_attr "type" "three,two,three,three,three")
11224 (set_attr "length" "12,8,12,12,12")])
11225
11226 (define_insn ""
11227 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11228 (compare:CC
11229 (plus:SI
11230 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11231 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
11232 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
11233 (const_int 0)))
11234 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
11235 "TARGET_32BIT"
11236 "@
11237 xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11238 {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
11239 {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11240 {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11241 {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11242 #
11243 #
11244 #
11245 #
11246 #"
11247 [(set_attr "type" "compare")
11248 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11249
11250 (define_split
11251 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11252 (compare:CC
11253 (plus:SI
11254 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11255 (match_operand:SI 2 "scc_eq_operand" ""))
11256 (match_operand:SI 3 "gpc_reg_operand" ""))
11257 (const_int 0)))
11258 (clobber (match_scratch:SI 4 ""))]
11259 "TARGET_32BIT && reload_completed"
11260 [(set (match_dup 4)
11261 (plus:SI (eq:SI (match_dup 1)
11262 (match_dup 2))
11263 (match_dup 3)))
11264 (set (match_dup 0)
11265 (compare:CC (match_dup 4)
11266 (const_int 0)))]
11267 "")
11268
11269 (define_insn ""
11270 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11271 (compare:CC
11272 (plus:SI
11273 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11274 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
11275 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
11276 (const_int 0)))
11277 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
11278 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11279 "TARGET_32BIT"
11280 "@
11281 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11282 {sfi|subfic} %0,%1,0\;{aze.|addze.} %0,%3
11283 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11284 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11285 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11286 #
11287 #
11288 #
11289 #
11290 #"
11291 [(set_attr "type" "compare")
11292 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11293
11294 (define_split
11295 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11296 (compare:CC
11297 (plus:SI
11298 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11299 (match_operand:SI 2 "scc_eq_operand" ""))
11300 (match_operand:SI 3 "gpc_reg_operand" ""))
11301 (const_int 0)))
11302 (set (match_operand:SI 0 "gpc_reg_operand" "")
11303 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11304 "TARGET_32BIT && reload_completed"
11305 [(set (match_dup 0)
11306 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11307 (set (match_dup 4)
11308 (compare:CC (match_dup 0)
11309 (const_int 0)))]
11310 "")
11311
11312 (define_insn "*neg_eq0<mode>"
11313 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
11314 (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "r")
11315 (const_int 0))))]
11316 ""
11317 "{ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0"
11318 [(set_attr "type" "two")
11319 (set_attr "length" "8")])
11320
11321 (define_insn_and_split "*neg_eq<mode>"
11322 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
11323 (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "%r")
11324 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))))]
11325 ""
11326 "#"
11327 ""
11328 [(set (match_dup 0) (neg:P (eq:P (match_dup 3) (const_int 0))))]
11329 {
11330 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
11331 {
11332 /* Use output operand as intermediate. */
11333 operands[3] = operands[0];
11334
11335 if (logical_operand (operands[2], <MODE>mode))
11336 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
11337 gen_rtx_XOR (<MODE>mode,
11338 operands[1], operands[2])));
11339 else
11340 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
11341 gen_rtx_PLUS (<MODE>mode, operands[1],
11342 negate_rtx (<MODE>mode,
11343 operands[2]))));
11344 }
11345 else
11346 operands[3] = operands[1];
11347 })
11348
11349 ;; Simplify (ne X (const_int 0)) on the PowerPC. No need to on the Power,
11350 ;; since it nabs/sr is just as fast.
11351 (define_insn "*ne0si"
11352 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
11353 (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11354 (const_int 31)))
11355 (clobber (match_scratch:SI 2 "=&r"))]
11356 "! TARGET_POWER && TARGET_32BIT && !TARGET_ISEL"
11357 "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
11358 [(set_attr "type" "two")
11359 (set_attr "length" "8")])
11360
11361 (define_insn "*ne0di"
11362 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11363 (lshiftrt:DI (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11364 (const_int 63)))
11365 (clobber (match_scratch:DI 2 "=&r"))]
11366 "TARGET_64BIT"
11367 "addic %2,%1,-1\;subfe %0,%2,%1"
11368 [(set_attr "type" "two")
11369 (set_attr "length" "8")])
11370
11371 ;; This is what (plus (ne X (const_int 0)) Y) looks like.
11372 (define_insn ""
11373 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11374 (plus:SI (lshiftrt:SI
11375 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11376 (const_int 31))
11377 (match_operand:SI 2 "gpc_reg_operand" "r")))
11378 (clobber (match_scratch:SI 3 "=&r"))]
11379 "TARGET_32BIT"
11380 "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
11381 [(set_attr "type" "two")
11382 (set_attr "length" "8")])
11383
11384 (define_insn ""
11385 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11386 (plus:DI (lshiftrt:DI
11387 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11388 (const_int 63))
11389 (match_operand:DI 2 "gpc_reg_operand" "r")))
11390 (clobber (match_scratch:DI 3 "=&r"))]
11391 "TARGET_64BIT"
11392 "addic %3,%1,-1\;addze %0,%2"
11393 [(set_attr "type" "two")
11394 (set_attr "length" "8")])
11395
11396 (define_insn ""
11397 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11398 (compare:CC
11399 (plus:SI (lshiftrt:SI
11400 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11401 (const_int 31))
11402 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11403 (const_int 0)))
11404 (clobber (match_scratch:SI 3 "=&r,&r"))
11405 (clobber (match_scratch:SI 4 "=X,&r"))]
11406 "TARGET_32BIT"
11407 "@
11408 {ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2
11409 #"
11410 [(set_attr "type" "compare")
11411 (set_attr "length" "8,12")])
11412
11413 (define_split
11414 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11415 (compare:CC
11416 (plus:SI (lshiftrt:SI
11417 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11418 (const_int 31))
11419 (match_operand:SI 2 "gpc_reg_operand" ""))
11420 (const_int 0)))
11421 (clobber (match_scratch:SI 3 ""))
11422 (clobber (match_scratch:SI 4 ""))]
11423 "TARGET_32BIT && reload_completed"
11424 [(parallel [(set (match_dup 3)
11425 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1)))
11426 (const_int 31))
11427 (match_dup 2)))
11428 (clobber (match_dup 4))])
11429 (set (match_dup 0)
11430 (compare:CC (match_dup 3)
11431 (const_int 0)))]
11432 "")
11433
11434 (define_insn ""
11435 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11436 (compare:CC
11437 (plus:DI (lshiftrt:DI
11438 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
11439 (const_int 63))
11440 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
11441 (const_int 0)))
11442 (clobber (match_scratch:DI 3 "=&r,&r"))]
11443 "TARGET_64BIT"
11444 "@
11445 addic %3,%1,-1\;addze. %3,%2
11446 #"
11447 [(set_attr "type" "compare")
11448 (set_attr "length" "8,12")])
11449
11450 (define_split
11451 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11452 (compare:CC
11453 (plus:DI (lshiftrt:DI
11454 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11455 (const_int 63))
11456 (match_operand:DI 2 "gpc_reg_operand" ""))
11457 (const_int 0)))
11458 (clobber (match_scratch:DI 3 ""))]
11459 "TARGET_64BIT && reload_completed"
11460 [(set (match_dup 3)
11461 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1)))
11462 (const_int 63))
11463 (match_dup 2)))
11464 (set (match_dup 0)
11465 (compare:CC (match_dup 3)
11466 (const_int 0)))]
11467 "")
11468
11469 (define_insn ""
11470 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11471 (compare:CC
11472 (plus:SI (lshiftrt:SI
11473 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11474 (const_int 31))
11475 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11476 (const_int 0)))
11477 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11478 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11479 (match_dup 2)))
11480 (clobber (match_scratch:SI 3 "=&r,&r"))]
11481 "TARGET_32BIT"
11482 "@
11483 {ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2
11484 #"
11485 [(set_attr "type" "compare")
11486 (set_attr "length" "8,12")])
11487
11488 (define_split
11489 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11490 (compare:CC
11491 (plus:SI (lshiftrt:SI
11492 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11493 (const_int 31))
11494 (match_operand:SI 2 "gpc_reg_operand" ""))
11495 (const_int 0)))
11496 (set (match_operand:SI 0 "gpc_reg_operand" "")
11497 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11498 (match_dup 2)))
11499 (clobber (match_scratch:SI 3 ""))]
11500 "TARGET_32BIT && reload_completed"
11501 [(parallel [(set (match_dup 0)
11502 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11503 (match_dup 2)))
11504 (clobber (match_dup 3))])
11505 (set (match_dup 4)
11506 (compare:CC (match_dup 0)
11507 (const_int 0)))]
11508 "")
11509
11510 (define_insn ""
11511 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11512 (compare:CC
11513 (plus:DI (lshiftrt:DI
11514 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
11515 (const_int 63))
11516 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
11517 (const_int 0)))
11518 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
11519 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11520 (match_dup 2)))
11521 (clobber (match_scratch:DI 3 "=&r,&r"))]
11522 "TARGET_64BIT"
11523 "@
11524 addic %3,%1,-1\;addze. %0,%2
11525 #"
11526 [(set_attr "type" "compare")
11527 (set_attr "length" "8,12")])
11528
11529 (define_split
11530 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11531 (compare:CC
11532 (plus:DI (lshiftrt:DI
11533 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11534 (const_int 63))
11535 (match_operand:DI 2 "gpc_reg_operand" ""))
11536 (const_int 0)))
11537 (set (match_operand:DI 0 "gpc_reg_operand" "")
11538 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11539 (match_dup 2)))
11540 (clobber (match_scratch:DI 3 ""))]
11541 "TARGET_64BIT && reload_completed"
11542 [(parallel [(set (match_dup 0)
11543 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11544 (match_dup 2)))
11545 (clobber (match_dup 3))])
11546 (set (match_dup 4)
11547 (compare:CC (match_dup 0)
11548 (const_int 0)))]
11549 "")
11550
11551 (define_insn ""
11552 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11553 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11554 (match_operand:SI 2 "reg_or_short_operand" "r,O")))
11555 (clobber (match_scratch:SI 3 "=r,X"))]
11556 "TARGET_POWER"
11557 "@
11558 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
11559 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
11560 [(set_attr "length" "12")])
11561
11562 (define_insn ""
11563 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
11564 (compare:CC
11565 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11566 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11567 (const_int 0)))
11568 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
11569 (le:SI (match_dup 1) (match_dup 2)))
11570 (clobber (match_scratch:SI 3 "=r,X,r,X"))]
11571 "TARGET_POWER"
11572 "@
11573 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
11574 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31
11575 #
11576 #"
11577 [(set_attr "type" "compare,delayed_compare,compare,delayed_compare")
11578 (set_attr "length" "12,12,16,16")])
11579
11580 (define_split
11581 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11582 (compare:CC
11583 (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11584 (match_operand:SI 2 "reg_or_short_operand" ""))
11585 (const_int 0)))
11586 (set (match_operand:SI 0 "gpc_reg_operand" "")
11587 (le:SI (match_dup 1) (match_dup 2)))
11588 (clobber (match_scratch:SI 3 ""))]
11589 "TARGET_POWER && reload_completed"
11590 [(parallel [(set (match_dup 0)
11591 (le:SI (match_dup 1) (match_dup 2)))
11592 (clobber (match_dup 3))])
11593 (set (match_dup 4)
11594 (compare:CC (match_dup 0)
11595 (const_int 0)))]
11596 "")
11597
11598 (define_insn ""
11599 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
11600 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11601 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
11602 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
11603 "TARGET_POWER"
11604 "@
11605 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11606 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze|addze} %0,%3"
11607 [(set_attr "length" "12")])
11608
11609 (define_insn ""
11610 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
11611 (compare:CC
11612 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11613 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11614 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11615 (const_int 0)))
11616 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
11617 "TARGET_POWER"
11618 "@
11619 doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11620 {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3
11621 #
11622 #"
11623 [(set_attr "type" "compare")
11624 (set_attr "length" "12,12,16,16")])
11625
11626 (define_split
11627 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11628 (compare:CC
11629 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11630 (match_operand:SI 2 "reg_or_short_operand" ""))
11631 (match_operand:SI 3 "gpc_reg_operand" ""))
11632 (const_int 0)))
11633 (clobber (match_scratch:SI 4 ""))]
11634 "TARGET_POWER && reload_completed"
11635 [(set (match_dup 4)
11636 (plus:SI (le:SI (match_dup 1) (match_dup 2))
11637 (match_dup 3)))
11638 (set (match_dup 0)
11639 (compare:CC (match_dup 4)
11640 (const_int 0)))]
11641 "")
11642
11643 (define_insn ""
11644 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
11645 (compare:CC
11646 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11647 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11648 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11649 (const_int 0)))
11650 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
11651 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11652 "TARGET_POWER"
11653 "@
11654 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11655 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze.|addze.} %0,%3
11656 #
11657 #"
11658 [(set_attr "type" "compare")
11659 (set_attr "length" "12,12,16,16")])
11660
11661 (define_split
11662 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11663 (compare:CC
11664 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11665 (match_operand:SI 2 "reg_or_short_operand" ""))
11666 (match_operand:SI 3 "gpc_reg_operand" ""))
11667 (const_int 0)))
11668 (set (match_operand:SI 0 "gpc_reg_operand" "")
11669 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11670 "TARGET_POWER && reload_completed"
11671 [(set (match_dup 0)
11672 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11673 (set (match_dup 4)
11674 (compare:CC (match_dup 0)
11675 (const_int 0)))]
11676 "")
11677
11678 (define_insn ""
11679 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11680 (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11681 (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
11682 "TARGET_POWER"
11683 "@
11684 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11685 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
11686 [(set_attr "length" "12")])
11687
11688 (define_insn "*leu<mode>"
11689 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
11690 (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
11691 (match_operand:P 2 "reg_or_short_operand" "rI")))]
11692 ""
11693 "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
11694 [(set_attr "type" "three")
11695 (set_attr "length" "12")])
11696
11697 (define_insn "*leu<mode>_compare"
11698 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11699 (compare:CC
11700 (leu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
11701 (match_operand:P 2 "reg_or_short_operand" "rI,rI"))
11702 (const_int 0)))
11703 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
11704 (leu:P (match_dup 1) (match_dup 2)))]
11705 ""
11706 "@
11707 {sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
11708 #"
11709 [(set_attr "type" "compare")
11710 (set_attr "length" "12,16")])
11711
11712 (define_split
11713 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11714 (compare:CC
11715 (leu:P (match_operand:P 1 "gpc_reg_operand" "")
11716 (match_operand:P 2 "reg_or_short_operand" ""))
11717 (const_int 0)))
11718 (set (match_operand:P 0 "gpc_reg_operand" "")
11719 (leu:P (match_dup 1) (match_dup 2)))]
11720 "reload_completed"
11721 [(set (match_dup 0)
11722 (leu:P (match_dup 1) (match_dup 2)))
11723 (set (match_dup 3)
11724 (compare:CC (match_dup 0)
11725 (const_int 0)))]
11726 "")
11727
11728 (define_insn "*plus_leu<mode>"
11729 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
11730 (plus:P (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
11731 (match_operand:P 2 "reg_or_short_operand" "rI"))
11732 (match_operand:P 3 "gpc_reg_operand" "r")))]
11733 ""
11734 "{sf%I2|subf%I2c} %0,%1,%2\;{aze|addze} %0,%3"
11735 [(set_attr "type" "two")
11736 (set_attr "length" "8")])
11737
11738 (define_insn ""
11739 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11740 (compare:CC
11741 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11742 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11743 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11744 (const_int 0)))
11745 (clobber (match_scratch:SI 4 "=&r,&r"))]
11746 "TARGET_32BIT"
11747 "@
11748 {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3
11749 #"
11750 [(set_attr "type" "compare")
11751 (set_attr "length" "8,12")])
11752
11753 (define_split
11754 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11755 (compare:CC
11756 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11757 (match_operand:SI 2 "reg_or_short_operand" ""))
11758 (match_operand:SI 3 "gpc_reg_operand" ""))
11759 (const_int 0)))
11760 (clobber (match_scratch:SI 4 ""))]
11761 "TARGET_32BIT && reload_completed"
11762 [(set (match_dup 4)
11763 (plus:SI (leu:SI (match_dup 1) (match_dup 2))
11764 (match_dup 3)))
11765 (set (match_dup 0)
11766 (compare:CC (match_dup 4)
11767 (const_int 0)))]
11768 "")
11769
11770 (define_insn ""
11771 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11772 (compare:CC
11773 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11774 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11775 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11776 (const_int 0)))
11777 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
11778 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11779 "TARGET_32BIT"
11780 "@
11781 {sf%I2|subf%I2c} %0,%1,%2\;{aze.|addze.} %0,%3
11782 #"
11783 [(set_attr "type" "compare")
11784 (set_attr "length" "8,12")])
11785
11786 (define_split
11787 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11788 (compare:CC
11789 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11790 (match_operand:SI 2 "reg_or_short_operand" ""))
11791 (match_operand:SI 3 "gpc_reg_operand" ""))
11792 (const_int 0)))
11793 (set (match_operand:SI 0 "gpc_reg_operand" "")
11794 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11795 "TARGET_32BIT && reload_completed"
11796 [(set (match_dup 0)
11797 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11798 (set (match_dup 4)
11799 (compare:CC (match_dup 0)
11800 (const_int 0)))]
11801 "")
11802
11803 (define_insn "*neg_leu<mode>"
11804 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
11805 (neg:P (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
11806 (match_operand:P 2 "reg_or_short_operand" "rI"))))]
11807 ""
11808 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
11809 [(set_attr "type" "three")
11810 (set_attr "length" "12")])
11811
11812 (define_insn "*and_neg_leu<mode>"
11813 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
11814 (and:P (neg:P
11815 (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
11816 (match_operand:P 2 "reg_or_short_operand" "rI")))
11817 (match_operand:P 3 "gpc_reg_operand" "r")))]
11818 ""
11819 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
11820 [(set_attr "type" "three")
11821 (set_attr "length" "12")])
11822
11823 (define_insn ""
11824 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11825 (compare:CC
11826 (and:SI (neg:SI
11827 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11828 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
11829 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11830 (const_int 0)))
11831 (clobber (match_scratch:SI 4 "=&r,&r"))]
11832 "TARGET_32BIT"
11833 "@
11834 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
11835 #"
11836 [(set_attr "type" "compare")
11837 (set_attr "length" "12,16")])
11838
11839 (define_split
11840 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11841 (compare:CC
11842 (and:SI (neg:SI
11843 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11844 (match_operand:SI 2 "reg_or_short_operand" "")))
11845 (match_operand:SI 3 "gpc_reg_operand" ""))
11846 (const_int 0)))
11847 (clobber (match_scratch:SI 4 ""))]
11848 "TARGET_32BIT && reload_completed"
11849 [(set (match_dup 4)
11850 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
11851 (match_dup 3)))
11852 (set (match_dup 0)
11853 (compare:CC (match_dup 4)
11854 (const_int 0)))]
11855 "")
11856
11857 (define_insn ""
11858 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11859 (compare:CC
11860 (and:SI (neg:SI
11861 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11862 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
11863 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11864 (const_int 0)))
11865 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
11866 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
11867 "TARGET_32BIT"
11868 "@
11869 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
11870 #"
11871 [(set_attr "type" "compare")
11872 (set_attr "length" "12,16")])
11873
11874 (define_split
11875 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11876 (compare:CC
11877 (and:SI (neg:SI
11878 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11879 (match_operand:SI 2 "reg_or_short_operand" "")))
11880 (match_operand:SI 3 "gpc_reg_operand" ""))
11881 (const_int 0)))
11882 (set (match_operand:SI 0 "gpc_reg_operand" "")
11883 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
11884 "TARGET_32BIT && reload_completed"
11885 [(set (match_dup 0)
11886 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
11887 (match_dup 3)))
11888 (set (match_dup 4)
11889 (compare:CC (match_dup 0)
11890 (const_int 0)))]
11891 "")
11892
11893 (define_insn ""
11894 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11895 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11896 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
11897 "TARGET_POWER"
11898 "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
11899 [(set_attr "length" "12")])
11900
11901 (define_insn ""
11902 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11903 (compare:CC
11904 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11905 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11906 (const_int 0)))
11907 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11908 (lt:SI (match_dup 1) (match_dup 2)))]
11909 "TARGET_POWER"
11910 "@
11911 doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
11912 #"
11913 [(set_attr "type" "delayed_compare")
11914 (set_attr "length" "12,16")])
11915
11916 (define_split
11917 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11918 (compare:CC
11919 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
11920 (match_operand:SI 2 "reg_or_short_operand" ""))
11921 (const_int 0)))
11922 (set (match_operand:SI 0 "gpc_reg_operand" "")
11923 (lt:SI (match_dup 1) (match_dup 2)))]
11924 "TARGET_POWER && reload_completed"
11925 [(set (match_dup 0)
11926 (lt:SI (match_dup 1) (match_dup 2)))
11927 (set (match_dup 3)
11928 (compare:CC (match_dup 0)
11929 (const_int 0)))]
11930 "")
11931
11932 (define_insn ""
11933 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
11934 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11935 (match_operand:SI 2 "reg_or_short_operand" "rI"))
11936 (match_operand:SI 3 "gpc_reg_operand" "r")))]
11937 "TARGET_POWER"
11938 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
11939 [(set_attr "length" "12")])
11940
11941 (define_insn ""
11942 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11943 (compare:CC
11944 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11945 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11946 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11947 (const_int 0)))
11948 (clobber (match_scratch:SI 4 "=&r,&r"))]
11949 "TARGET_POWER"
11950 "@
11951 doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
11952 #"
11953 [(set_attr "type" "compare")
11954 (set_attr "length" "12,16")])
11955
11956 (define_split
11957 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11958 (compare:CC
11959 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
11960 (match_operand:SI 2 "reg_or_short_operand" ""))
11961 (match_operand:SI 3 "gpc_reg_operand" ""))
11962 (const_int 0)))
11963 (clobber (match_scratch:SI 4 ""))]
11964 "TARGET_POWER && reload_completed"
11965 [(set (match_dup 4)
11966 (plus:SI (lt:SI (match_dup 1) (match_dup 2))
11967 (match_dup 3)))
11968 (set (match_dup 0)
11969 (compare:CC (match_dup 4)
11970 (const_int 0)))]
11971 "")
11972
11973 (define_insn ""
11974 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11975 (compare:CC
11976 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11977 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11978 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11979 (const_int 0)))
11980 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
11981 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11982 "TARGET_POWER"
11983 "@
11984 doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
11985 #"
11986 [(set_attr "type" "compare")
11987 (set_attr "length" "12,16")])
11988
11989 (define_split
11990 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11991 (compare:CC
11992 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
11993 (match_operand:SI 2 "reg_or_short_operand" ""))
11994 (match_operand:SI 3 "gpc_reg_operand" ""))
11995 (const_int 0)))
11996 (set (match_operand:SI 0 "gpc_reg_operand" "")
11997 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11998 "TARGET_POWER && reload_completed"
11999 [(set (match_dup 0)
12000 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12001 (set (match_dup 4)
12002 (compare:CC (match_dup 0)
12003 (const_int 0)))]
12004 "")
12005
12006 (define_insn ""
12007 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12008 (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12009 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12010 "TARGET_POWER"
12011 "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
12012 [(set_attr "length" "12")])
12013
12014 (define_insn_and_split "*ltu<mode>"
12015 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12016 (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12017 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))]
12018 ""
12019 "#"
12020 ""
12021 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12022 (set (match_dup 0) (neg:P (match_dup 0)))]
12023 "")
12024
12025 (define_insn_and_split "*ltu<mode>_compare"
12026 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12027 (compare:CC
12028 (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12029 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
12030 (const_int 0)))
12031 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
12032 (ltu:P (match_dup 1) (match_dup 2)))]
12033 ""
12034 "#"
12035 ""
12036 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12037 (parallel [(set (match_dup 3)
12038 (compare:CC (neg:P (match_dup 0)) (const_int 0)))
12039 (set (match_dup 0) (neg:P (match_dup 0)))])]
12040 "")
12041
12042 (define_insn_and_split "*plus_ltu<mode>"
12043 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,r")
12044 (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12045 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
12046 (match_operand:P 3 "reg_or_short_operand" "rI,rI")))]
12047 ""
12048 "#"
12049 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12050 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12051 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))]
12052 "")
12053
12054 (define_insn_and_split "*plus_ltu<mode>_compare"
12055 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12056 (compare:CC
12057 (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12058 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
12059 (match_operand:P 3 "gpc_reg_operand" "r,r,r,r"))
12060 (const_int 0)))
12061 (set (match_operand:P 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12062 (plus:P (ltu:P (match_dup 1) (match_dup 2)) (match_dup 3)))]
12063 ""
12064 "#"
12065 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12066 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12067 (parallel [(set (match_dup 4)
12068 (compare:CC (minus:P (match_dup 3) (match_dup 0))
12069 (const_int 0)))
12070 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))])]
12071 "")
12072
12073 (define_insn "*neg_ltu<mode>"
12074 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12075 (neg:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12076 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))))]
12077 ""
12078 "@
12079 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
12080 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
12081 [(set_attr "type" "two")
12082 (set_attr "length" "8")])
12083
12084 (define_insn ""
12085 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12086 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12087 (match_operand:SI 2 "reg_or_short_operand" "rI")))
12088 (clobber (match_scratch:SI 3 "=r"))]
12089 "TARGET_POWER"
12090 "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
12091 [(set_attr "length" "12")])
12092
12093 (define_insn ""
12094 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12095 (compare:CC
12096 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12097 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12098 (const_int 0)))
12099 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12100 (ge:SI (match_dup 1) (match_dup 2)))
12101 (clobber (match_scratch:SI 3 "=r,r"))]
12102 "TARGET_POWER"
12103 "@
12104 doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
12105 #"
12106 [(set_attr "type" "compare")
12107 (set_attr "length" "12,16")])
12108
12109 (define_split
12110 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12111 (compare:CC
12112 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12113 (match_operand:SI 2 "reg_or_short_operand" ""))
12114 (const_int 0)))
12115 (set (match_operand:SI 0 "gpc_reg_operand" "")
12116 (ge:SI (match_dup 1) (match_dup 2)))
12117 (clobber (match_scratch:SI 3 ""))]
12118 "TARGET_POWER && reload_completed"
12119 [(parallel [(set (match_dup 0)
12120 (ge:SI (match_dup 1) (match_dup 2)))
12121 (clobber (match_dup 3))])
12122 (set (match_dup 4)
12123 (compare:CC (match_dup 0)
12124 (const_int 0)))]
12125 "")
12126
12127 (define_insn ""
12128 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12129 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12130 (match_operand:SI 2 "reg_or_short_operand" "rI"))
12131 (match_operand:SI 3 "gpc_reg_operand" "r")))]
12132 "TARGET_POWER"
12133 "doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
12134 [(set_attr "length" "12")])
12135
12136 (define_insn ""
12137 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12138 (compare:CC
12139 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12140 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12141 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12142 (const_int 0)))
12143 (clobber (match_scratch:SI 4 "=&r,&r"))]
12144 "TARGET_POWER"
12145 "@
12146 doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12147 #"
12148 [(set_attr "type" "compare")
12149 (set_attr "length" "12,16")])
12150
12151 (define_split
12152 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12153 (compare:CC
12154 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12155 (match_operand:SI 2 "reg_or_short_operand" ""))
12156 (match_operand:SI 3 "gpc_reg_operand" ""))
12157 (const_int 0)))
12158 (clobber (match_scratch:SI 4 ""))]
12159 "TARGET_POWER && reload_completed"
12160 [(set (match_dup 4)
12161 (plus:SI (ge:SI (match_dup 1) (match_dup 2))
12162 (match_dup 3)))
12163 (set (match_dup 0)
12164 (compare:CC (match_dup 4)
12165 (const_int 0)))]
12166 "")
12167
12168 (define_insn ""
12169 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12170 (compare:CC
12171 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12172 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12173 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12174 (const_int 0)))
12175 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12176 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12177 "TARGET_POWER"
12178 "@
12179 doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12180 #"
12181 [(set_attr "type" "compare")
12182 (set_attr "length" "12,16")])
12183
12184 (define_split
12185 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12186 (compare:CC
12187 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12188 (match_operand:SI 2 "reg_or_short_operand" ""))
12189 (match_operand:SI 3 "gpc_reg_operand" ""))
12190 (const_int 0)))
12191 (set (match_operand:SI 0 "gpc_reg_operand" "")
12192 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12193 "TARGET_POWER && reload_completed"
12194 [(set (match_dup 0)
12195 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12196 (set (match_dup 4)
12197 (compare:CC (match_dup 0)
12198 (const_int 0)))]
12199 "")
12200
12201 (define_insn ""
12202 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12203 (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12204 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12205 "TARGET_POWER"
12206 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
12207 [(set_attr "length" "12")])
12208
12209 (define_insn "*geu<mode>"
12210 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12211 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12212 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))]
12213 ""
12214 "@
12215 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
12216 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
12217 [(set_attr "type" "three")
12218 (set_attr "length" "12")])
12219
12220 (define_insn "*geu<mode>_compare"
12221 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12222 (compare:CC
12223 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12224 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
12225 (const_int 0)))
12226 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
12227 (geu:P (match_dup 1) (match_dup 2)))]
12228 ""
12229 "@
12230 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12231 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12232 #
12233 #"
12234 [(set_attr "type" "compare")
12235 (set_attr "length" "12,12,16,16")])
12236
12237 (define_split
12238 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12239 (compare:CC
12240 (geu:P (match_operand:P 1 "gpc_reg_operand" "")
12241 (match_operand:P 2 "reg_or_neg_short_operand" ""))
12242 (const_int 0)))
12243 (set (match_operand:P 0 "gpc_reg_operand" "")
12244 (geu:P (match_dup 1) (match_dup 2)))]
12245 "reload_completed"
12246 [(set (match_dup 0)
12247 (geu:P (match_dup 1) (match_dup 2)))
12248 (set (match_dup 3)
12249 (compare:CC (match_dup 0)
12250 (const_int 0)))]
12251 "")
12252
12253 (define_insn "*plus_geu<mode>"
12254 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,&r")
12255 (plus:P (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12256 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
12257 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
12258 ""
12259 "@
12260 {sf|subfc} %0,%2,%1\;{aze|addze} %0,%3
12261 {ai|addic} %0,%1,%n2\;{aze|addze} %0,%3"
12262 [(set_attr "type" "two")
12263 (set_attr "length" "8")])
12264
12265 (define_insn ""
12266 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12267 (compare:CC
12268 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12269 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12270 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12271 (const_int 0)))
12272 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12273 "TARGET_32BIT"
12274 "@
12275 {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
12276 {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3
12277 #
12278 #"
12279 [(set_attr "type" "compare")
12280 (set_attr "length" "8,8,12,12")])
12281
12282 (define_split
12283 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12284 (compare:CC
12285 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12286 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12287 (match_operand:SI 3 "gpc_reg_operand" ""))
12288 (const_int 0)))
12289 (clobber (match_scratch:SI 4 ""))]
12290 "TARGET_32BIT && reload_completed"
12291 [(set (match_dup 4)
12292 (plus:SI (geu:SI (match_dup 1) (match_dup 2))
12293 (match_dup 3)))
12294 (set (match_dup 0)
12295 (compare:CC (match_dup 4)
12296 (const_int 0)))]
12297 "")
12298
12299 (define_insn ""
12300 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12301 (compare:CC
12302 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12303 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12304 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12305 (const_int 0)))
12306 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12307 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12308 "TARGET_32BIT"
12309 "@
12310 {sf|subfc} %0,%2,%1\;{aze.|addze.} %0,%3
12311 {ai|addic} %0,%1,%n2\;{aze.|addze.} %0,%3
12312 #
12313 #"
12314 [(set_attr "type" "compare")
12315 (set_attr "length" "8,8,12,12")])
12316
12317 (define_split
12318 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12319 (compare:CC
12320 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12321 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12322 (match_operand:SI 3 "gpc_reg_operand" ""))
12323 (const_int 0)))
12324 (set (match_operand:SI 0 "gpc_reg_operand" "")
12325 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12326 "TARGET_32BIT && reload_completed"
12327 [(set (match_dup 0)
12328 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12329 (set (match_dup 4)
12330 (compare:CC (match_dup 0)
12331 (const_int 0)))]
12332 "")
12333
12334 (define_insn "*neg_geu<mode>"
12335 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12336 (neg:P (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12337 (match_operand:P 2 "reg_or_short_operand" "r,I"))))]
12338 ""
12339 "@
12340 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
12341 {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
12342 [(set_attr "type" "three")
12343 (set_attr "length" "12")])
12344
12345 (define_insn "*and_neg_geu<mode>"
12346 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,&r")
12347 (and:P (neg:P
12348 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12349 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))
12350 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
12351 ""
12352 "@
12353 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0
12354 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
12355 [(set_attr "type" "three")
12356 (set_attr "length" "12")])
12357
12358 (define_insn ""
12359 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12360 (compare:CC
12361 (and:SI (neg:SI
12362 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12363 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12364 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12365 (const_int 0)))
12366 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12367 "TARGET_32BIT"
12368 "@
12369 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12370 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12371 #
12372 #"
12373 [(set_attr "type" "compare")
12374 (set_attr "length" "12,12,16,16")])
12375
12376 (define_split
12377 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12378 (compare:CC
12379 (and:SI (neg:SI
12380 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12381 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12382 (match_operand:SI 3 "gpc_reg_operand" ""))
12383 (const_int 0)))
12384 (clobber (match_scratch:SI 4 ""))]
12385 "TARGET_32BIT && reload_completed"
12386 [(set (match_dup 4)
12387 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2)))
12388 (match_dup 3)))
12389 (set (match_dup 0)
12390 (compare:CC (match_dup 4)
12391 (const_int 0)))]
12392 "")
12393
12394 (define_insn ""
12395 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12396 (compare:CC
12397 (and:SI (neg:SI
12398 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12399 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12400 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12401 (const_int 0)))
12402 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12403 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12404 "TARGET_32BIT"
12405 "@
12406 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
12407 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
12408 #
12409 #"
12410 [(set_attr "type" "compare")
12411 (set_attr "length" "12,12,16,16")])
12412
12413 (define_split
12414 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12415 (compare:CC
12416 (and:SI (neg:SI
12417 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12418 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12419 (match_operand:SI 3 "gpc_reg_operand" ""))
12420 (const_int 0)))
12421 (set (match_operand:SI 0 "gpc_reg_operand" "")
12422 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12423 "TARGET_32BIT && reload_completed"
12424 [(set (match_dup 0)
12425 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
12426 (set (match_dup 4)
12427 (compare:CC (match_dup 0)
12428 (const_int 0)))]
12429 "")
12430
12431 (define_insn ""
12432 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12433 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12434 (match_operand:SI 2 "reg_or_short_operand" "r")))]
12435 "TARGET_POWER"
12436 "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
12437 [(set_attr "length" "12")])
12438
12439 (define_insn ""
12440 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12441 (compare:CC
12442 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12443 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12444 (const_int 0)))
12445 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12446 (gt:SI (match_dup 1) (match_dup 2)))]
12447 "TARGET_POWER"
12448 "@
12449 doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
12450 #"
12451 [(set_attr "type" "delayed_compare")
12452 (set_attr "length" "12,16")])
12453
12454 (define_split
12455 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12456 (compare:CC
12457 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12458 (match_operand:SI 2 "reg_or_short_operand" ""))
12459 (const_int 0)))
12460 (set (match_operand:SI 0 "gpc_reg_operand" "")
12461 (gt:SI (match_dup 1) (match_dup 2)))]
12462 "TARGET_POWER && reload_completed"
12463 [(set (match_dup 0)
12464 (gt:SI (match_dup 1) (match_dup 2)))
12465 (set (match_dup 3)
12466 (compare:CC (match_dup 0)
12467 (const_int 0)))]
12468 "")
12469
12470 (define_insn "*plus_gt0<mode>"
12471 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12472 (plus:P (gt:P (match_operand:P 1 "gpc_reg_operand" "r")
12473 (const_int 0))
12474 (match_operand:P 2 "gpc_reg_operand" "r")))]
12475 ""
12476 "{a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze|addze} %0,%2"
12477 [(set_attr "type" "three")
12478 (set_attr "length" "12")])
12479
12480 (define_insn ""
12481 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12482 (compare:CC
12483 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12484 (const_int 0))
12485 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12486 (const_int 0)))
12487 (clobber (match_scratch:SI 3 "=&r,&r"))]
12488 "TARGET_32BIT"
12489 "@
12490 {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
12491 #"
12492 [(set_attr "type" "compare")
12493 (set_attr "length" "12,16")])
12494
12495 (define_split
12496 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12497 (compare:CC
12498 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12499 (const_int 0))
12500 (match_operand:SI 2 "gpc_reg_operand" ""))
12501 (const_int 0)))
12502 (clobber (match_scratch:SI 3 ""))]
12503 "TARGET_32BIT && reload_completed"
12504 [(set (match_dup 3)
12505 (plus:SI (gt:SI (match_dup 1) (const_int 0))
12506 (match_dup 2)))
12507 (set (match_dup 0)
12508 (compare:CC (match_dup 3)
12509 (const_int 0)))]
12510 "")
12511
12512 (define_insn ""
12513 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12514 (compare:CC
12515 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12516 (const_int 0))
12517 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12518 (const_int 0)))
12519 (clobber (match_scratch:DI 3 "=&r,&r"))]
12520 "TARGET_64BIT"
12521 "@
12522 addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
12523 #"
12524 [(set_attr "type" "compare")
12525 (set_attr "length" "12,16")])
12526
12527 (define_split
12528 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12529 (compare:CC
12530 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12531 (const_int 0))
12532 (match_operand:DI 2 "gpc_reg_operand" ""))
12533 (const_int 0)))
12534 (clobber (match_scratch:DI 3 ""))]
12535 "TARGET_64BIT && reload_completed"
12536 [(set (match_dup 3)
12537 (plus:DI (gt:DI (match_dup 1) (const_int 0))
12538 (match_dup 2)))
12539 (set (match_dup 0)
12540 (compare:CC (match_dup 3)
12541 (const_int 0)))]
12542 "")
12543
12544 (define_insn ""
12545 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12546 (compare:CC
12547 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12548 (const_int 0))
12549 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12550 (const_int 0)))
12551 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12552 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
12553 "TARGET_32BIT"
12554 "@
12555 {a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze.|addze.} %0,%2
12556 #"
12557 [(set_attr "type" "compare")
12558 (set_attr "length" "12,16")])
12559
12560 (define_split
12561 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12562 (compare:CC
12563 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12564 (const_int 0))
12565 (match_operand:SI 2 "gpc_reg_operand" ""))
12566 (const_int 0)))
12567 (set (match_operand:SI 0 "gpc_reg_operand" "")
12568 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
12569 "TARGET_32BIT && reload_completed"
12570 [(set (match_dup 0)
12571 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
12572 (set (match_dup 3)
12573 (compare:CC (match_dup 0)
12574 (const_int 0)))]
12575 "")
12576
12577 (define_insn ""
12578 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12579 (compare:CC
12580 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12581 (const_int 0))
12582 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12583 (const_int 0)))
12584 (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
12585 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
12586 "TARGET_64BIT"
12587 "@
12588 addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
12589 #"
12590 [(set_attr "type" "compare")
12591 (set_attr "length" "12,16")])
12592
12593 (define_split
12594 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12595 (compare:CC
12596 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12597 (const_int 0))
12598 (match_operand:DI 2 "gpc_reg_operand" ""))
12599 (const_int 0)))
12600 (set (match_operand:DI 0 "gpc_reg_operand" "")
12601 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
12602 "TARGET_64BIT && reload_completed"
12603 [(set (match_dup 0)
12604 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
12605 (set (match_dup 3)
12606 (compare:CC (match_dup 0)
12607 (const_int 0)))]
12608 "")
12609
12610 (define_insn ""
12611 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12612 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12613 (match_operand:SI 2 "reg_or_short_operand" "r"))
12614 (match_operand:SI 3 "gpc_reg_operand" "r")))]
12615 "TARGET_POWER"
12616 "doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
12617 [(set_attr "length" "12")])
12618
12619 (define_insn ""
12620 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12621 (compare:CC
12622 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12623 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12624 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12625 (const_int 0)))
12626 (clobber (match_scratch:SI 4 "=&r,&r"))]
12627 "TARGET_POWER"
12628 "@
12629 doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
12630 #"
12631 [(set_attr "type" "compare")
12632 (set_attr "length" "12,16")])
12633
12634 (define_split
12635 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12636 (compare:CC
12637 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12638 (match_operand:SI 2 "reg_or_short_operand" ""))
12639 (match_operand:SI 3 "gpc_reg_operand" ""))
12640 (const_int 0)))
12641 (clobber (match_scratch:SI 4 ""))]
12642 "TARGET_POWER && reload_completed"
12643 [(set (match_dup 4)
12644 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12645 (set (match_dup 0)
12646 (compare:CC (match_dup 4)
12647 (const_int 0)))]
12648 "")
12649
12650 (define_insn ""
12651 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12652 (compare:CC
12653 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12654 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12655 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12656 (const_int 0)))
12657 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12658 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12659 "TARGET_POWER"
12660 "@
12661 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
12662 #"
12663 [(set_attr "type" "compare")
12664 (set_attr "length" "12,16")])
12665
12666 (define_split
12667 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12668 (compare:CC
12669 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12670 (match_operand:SI 2 "reg_or_short_operand" ""))
12671 (match_operand:SI 3 "gpc_reg_operand" ""))
12672 (const_int 0)))
12673 (set (match_operand:SI 0 "gpc_reg_operand" "")
12674 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12675 "TARGET_POWER && reload_completed"
12676 [(set (match_dup 0)
12677 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12678 (set (match_dup 4)
12679 (compare:CC (match_dup 0)
12680 (const_int 0)))]
12681 "")
12682
12683 (define_insn ""
12684 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12685 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12686 (match_operand:SI 2 "reg_or_short_operand" "r"))))]
12687 "TARGET_POWER"
12688 "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
12689 [(set_attr "length" "12")])
12690
12691 (define_insn_and_split "*gtu<mode>"
12692 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12693 (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
12694 (match_operand:P 2 "reg_or_short_operand" "rI")))]
12695 ""
12696 "#"
12697 ""
12698 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
12699 (set (match_dup 0) (neg:P (match_dup 0)))]
12700 "")
12701
12702 (define_insn_and_split "*gtu<mode>_compare"
12703 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12704 (compare:CC
12705 (gtu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12706 (match_operand:P 2 "reg_or_short_operand" "rI,rI"))
12707 (const_int 0)))
12708 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12709 (gtu:P (match_dup 1) (match_dup 2)))]
12710 ""
12711 "#"
12712 ""
12713 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
12714 (parallel [(set (match_dup 3)
12715 (compare:CC (neg:P (match_dup 0)) (const_int 0)))
12716 (set (match_dup 0) (neg:P (match_dup 0)))])]
12717 "")
12718
12719 (define_insn_and_split "*plus_gtu<mode>"
12720 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12721 (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
12722 (match_operand:P 2 "reg_or_short_operand" "rI"))
12723 (match_operand:P 3 "reg_or_short_operand" "rI")))]
12724 ""
12725 "#"
12726 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12727 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
12728 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))]
12729 "")
12730
12731 (define_insn_and_split "*plus_gtu<mode>_compare"
12732 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12733 (compare:CC
12734 (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12735 (match_operand:P 2 "reg_or_short_operand" "I,r,I,r"))
12736 (match_operand:P 3 "gpc_reg_operand" "r,r,r,r"))
12737 (const_int 0)))
12738 (set (match_operand:P 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12739 (plus:P (gtu:P (match_dup 1) (match_dup 2)) (match_dup 3)))]
12740 ""
12741 "#"
12742 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12743 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
12744 (parallel [(set (match_dup 4)
12745 (compare:CC (minus:P (match_dup 3) (match_dup 0))
12746 (const_int 0)))
12747 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))])]
12748 "")
12749
12750 (define_insn "*neg_gtu<mode>"
12751 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12752 (neg:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
12753 (match_operand:P 2 "reg_or_short_operand" "rI"))))]
12754 ""
12755 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
12756 [(set_attr "type" "two")
12757 (set_attr "length" "8")])
12758
12759 \f
12760 ;; Define both directions of branch and return. If we need a reload
12761 ;; register, we'd rather use CR0 since it is much easier to copy a
12762 ;; register CC value to there.
12763
12764 (define_insn ""
12765 [(set (pc)
12766 (if_then_else (match_operator 1 "branch_comparison_operator"
12767 [(match_operand 2
12768 "cc_reg_operand" "y")
12769 (const_int 0)])
12770 (label_ref (match_operand 0 "" ""))
12771 (pc)))]
12772 ""
12773 "*
12774 {
12775 return output_cbranch (operands[1], \"%l0\", 0, insn);
12776 }"
12777 [(set_attr "type" "branch")])
12778
12779 (define_insn ""
12780 [(set (pc)
12781 (if_then_else (match_operator 0 "branch_comparison_operator"
12782 [(match_operand 1
12783 "cc_reg_operand" "y")
12784 (const_int 0)])
12785 (return)
12786 (pc)))]
12787 "direct_return ()"
12788 "*
12789 {
12790 return output_cbranch (operands[0], NULL, 0, insn);
12791 }"
12792 [(set_attr "type" "branch")
12793 (set_attr "length" "4")])
12794
12795 (define_insn ""
12796 [(set (pc)
12797 (if_then_else (match_operator 1 "branch_comparison_operator"
12798 [(match_operand 2
12799 "cc_reg_operand" "y")
12800 (const_int 0)])
12801 (pc)
12802 (label_ref (match_operand 0 "" ""))))]
12803 ""
12804 "*
12805 {
12806 return output_cbranch (operands[1], \"%l0\", 1, insn);
12807 }"
12808 [(set_attr "type" "branch")])
12809
12810 (define_insn ""
12811 [(set (pc)
12812 (if_then_else (match_operator 0 "branch_comparison_operator"
12813 [(match_operand 1
12814 "cc_reg_operand" "y")
12815 (const_int 0)])
12816 (pc)
12817 (return)))]
12818 "direct_return ()"
12819 "*
12820 {
12821 return output_cbranch (operands[0], NULL, 1, insn);
12822 }"
12823 [(set_attr "type" "branch")
12824 (set_attr "length" "4")])
12825
12826 ;; Logic on condition register values.
12827
12828 ; This pattern matches things like
12829 ; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
12830 ; (eq:SI (reg:CCFP 68) (const_int 0)))
12831 ; (const_int 1)))
12832 ; which are generated by the branch logic.
12833 ; Prefer destructive operations where BT = BB (for crXX BT,BA,BB)
12834
12835 (define_insn "*cceq_ior_compare"
12836 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
12837 (compare:CCEQ (match_operator:SI 1 "boolean_operator"
12838 [(match_operator:SI 2
12839 "branch_positive_comparison_operator"
12840 [(match_operand 3
12841 "cc_reg_operand" "y,y")
12842 (const_int 0)])
12843 (match_operator:SI 4
12844 "branch_positive_comparison_operator"
12845 [(match_operand 5
12846 "cc_reg_operand" "0,y")
12847 (const_int 0)])])
12848 (const_int 1)))]
12849 ""
12850 "cr%q1 %E0,%j2,%j4"
12851 [(set_attr "type" "cr_logical,delayed_cr")])
12852
12853 ; Why is the constant -1 here, but 1 in the previous pattern?
12854 ; Because ~1 has all but the low bit set.
12855 (define_insn ""
12856 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
12857 (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
12858 [(not:SI (match_operator:SI 2
12859 "branch_positive_comparison_operator"
12860 [(match_operand 3
12861 "cc_reg_operand" "y,y")
12862 (const_int 0)]))
12863 (match_operator:SI 4
12864 "branch_positive_comparison_operator"
12865 [(match_operand 5
12866 "cc_reg_operand" "0,y")
12867 (const_int 0)])])
12868 (const_int -1)))]
12869 ""
12870 "cr%q1 %E0,%j2,%j4"
12871 [(set_attr "type" "cr_logical,delayed_cr")])
12872
12873 (define_insn "*cceq_rev_compare"
12874 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
12875 (compare:CCEQ (match_operator:SI 1
12876 "branch_positive_comparison_operator"
12877 [(match_operand 2
12878 "cc_reg_operand" "0,y")
12879 (const_int 0)])
12880 (const_int 0)))]
12881 ""
12882 "{crnor %E0,%j1,%j1|crnot %E0,%j1}"
12883 [(set_attr "type" "cr_logical,delayed_cr")])
12884
12885 ;; If we are comparing the result of two comparisons, this can be done
12886 ;; using creqv or crxor.
12887
12888 (define_insn_and_split ""
12889 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
12890 (compare:CCEQ (match_operator 1 "branch_comparison_operator"
12891 [(match_operand 2 "cc_reg_operand" "y")
12892 (const_int 0)])
12893 (match_operator 3 "branch_comparison_operator"
12894 [(match_operand 4 "cc_reg_operand" "y")
12895 (const_int 0)])))]
12896 ""
12897 "#"
12898 ""
12899 [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
12900 (match_dup 5)))]
12901 "
12902 {
12903 int positive_1, positive_2;
12904
12905 positive_1 = branch_positive_comparison_operator (operands[1],
12906 GET_MODE (operands[1]));
12907 positive_2 = branch_positive_comparison_operator (operands[3],
12908 GET_MODE (operands[3]));
12909
12910 if (! positive_1)
12911 operands[1] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[2]),
12912 GET_CODE (operands[1])),
12913 SImode,
12914 operands[2], const0_rtx);
12915 else if (GET_MODE (operands[1]) != SImode)
12916 operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode,
12917 operands[2], const0_rtx);
12918
12919 if (! positive_2)
12920 operands[3] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[4]),
12921 GET_CODE (operands[3])),
12922 SImode,
12923 operands[4], const0_rtx);
12924 else if (GET_MODE (operands[3]) != SImode)
12925 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
12926 operands[4], const0_rtx);
12927
12928 if (positive_1 == positive_2)
12929 {
12930 operands[1] = gen_rtx_NOT (SImode, operands[1]);
12931 operands[5] = constm1_rtx;
12932 }
12933 else
12934 {
12935 operands[5] = const1_rtx;
12936 }
12937 }")
12938
12939 ;; Unconditional branch and return.
12940
12941 (define_insn "jump"
12942 [(set (pc)
12943 (label_ref (match_operand 0 "" "")))]
12944 ""
12945 "b %l0"
12946 [(set_attr "type" "branch")])
12947
12948 (define_insn "return"
12949 [(return)]
12950 "direct_return ()"
12951 "{br|blr}"
12952 [(set_attr "type" "jmpreg")])
12953
12954 (define_expand "indirect_jump"
12955 [(set (pc) (match_operand 0 "register_operand" ""))])
12956
12957 (define_insn "*indirect_jump<mode>"
12958 [(set (pc) (match_operand:P 0 "register_operand" "c,*l"))]
12959 ""
12960 "@
12961 bctr
12962 {br|blr}"
12963 [(set_attr "type" "jmpreg")])
12964
12965 ;; Table jump for switch statements:
12966 (define_expand "tablejump"
12967 [(use (match_operand 0 "" ""))
12968 (use (label_ref (match_operand 1 "" "")))]
12969 ""
12970 "
12971 {
12972 if (TARGET_32BIT)
12973 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
12974 else
12975 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
12976 DONE;
12977 }")
12978
12979 (define_expand "tablejumpsi"
12980 [(set (match_dup 3)
12981 (plus:SI (match_operand:SI 0 "" "")
12982 (match_dup 2)))
12983 (parallel [(set (pc) (match_dup 3))
12984 (use (label_ref (match_operand 1 "" "")))])]
12985 "TARGET_32BIT"
12986 "
12987 { operands[0] = force_reg (SImode, operands[0]);
12988 operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
12989 operands[3] = gen_reg_rtx (SImode);
12990 }")
12991
12992 (define_expand "tablejumpdi"
12993 [(set (match_dup 4)
12994 (sign_extend:DI (match_operand:SI 0 "lwa_operand" "rm")))
12995 (set (match_dup 3)
12996 (plus:DI (match_dup 4)
12997 (match_dup 2)))
12998 (parallel [(set (pc) (match_dup 3))
12999 (use (label_ref (match_operand 1 "" "")))])]
13000 "TARGET_64BIT"
13001 "
13002 { operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
13003 operands[3] = gen_reg_rtx (DImode);
13004 operands[4] = gen_reg_rtx (DImode);
13005 }")
13006
13007 (define_insn "*tablejump<mode>_internal1"
13008 [(set (pc)
13009 (match_operand:P 0 "register_operand" "c,*l"))
13010 (use (label_ref (match_operand 1 "" "")))]
13011 ""
13012 "@
13013 bctr
13014 {br|blr}"
13015 [(set_attr "type" "jmpreg")])
13016
13017 (define_insn "nop"
13018 [(const_int 0)]
13019 ""
13020 "{cror 0,0,0|nop}")
13021 \f
13022 ;; Define the subtract-one-and-jump insns, starting with the template
13023 ;; so loop.c knows what to generate.
13024
13025 (define_expand "doloop_end"
13026 [(use (match_operand 0 "" "")) ; loop pseudo
13027 (use (match_operand 1 "" "")) ; iterations; zero if unknown
13028 (use (match_operand 2 "" "")) ; max iterations
13029 (use (match_operand 3 "" "")) ; loop level
13030 (use (match_operand 4 "" ""))] ; label
13031 ""
13032 "
13033 {
13034 /* Only use this on innermost loops. */
13035 if (INTVAL (operands[3]) > 1)
13036 FAIL;
13037 if (TARGET_64BIT)
13038 {
13039 if (GET_MODE (operands[0]) != DImode)
13040 FAIL;
13041 emit_jump_insn (gen_ctrdi (operands[0], operands[4]));
13042 }
13043 else
13044 {
13045 if (GET_MODE (operands[0]) != SImode)
13046 FAIL;
13047 emit_jump_insn (gen_ctrsi (operands[0], operands[4]));
13048 }
13049 DONE;
13050 }")
13051
13052 (define_expand "ctr<mode>"
13053 [(parallel [(set (pc)
13054 (if_then_else (ne (match_operand:P 0 "register_operand" "")
13055 (const_int 1))
13056 (label_ref (match_operand 1 "" ""))
13057 (pc)))
13058 (set (match_dup 0)
13059 (plus:P (match_dup 0)
13060 (const_int -1)))
13061 (clobber (match_scratch:CC 2 ""))
13062 (clobber (match_scratch:P 3 ""))])]
13063 ""
13064 "")
13065
13066 ;; We need to be able to do this for any operand, including MEM, or we
13067 ;; will cause reload to blow up since we don't allow output reloads on
13068 ;; JUMP_INSNs.
13069 ;; For the length attribute to be calculated correctly, the
13070 ;; label MUST be operand 0.
13071
13072 (define_insn "*ctr<mode>_internal1"
13073 [(set (pc)
13074 (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13075 (const_int 1))
13076 (label_ref (match_operand 0 "" ""))
13077 (pc)))
13078 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
13079 (plus:P (match_dup 1)
13080 (const_int -1)))
13081 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13082 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13083 ""
13084 "*
13085 {
13086 if (which_alternative != 0)
13087 return \"#\";
13088 else if (get_attr_length (insn) == 4)
13089 return \"{bdn|bdnz} %l0\";
13090 else
13091 return \"bdz $+8\;b %l0\";
13092 }"
13093 [(set_attr "type" "branch")
13094 (set_attr "length" "*,12,16,16")])
13095
13096 (define_insn "*ctr<mode>_internal2"
13097 [(set (pc)
13098 (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13099 (const_int 1))
13100 (pc)
13101 (label_ref (match_operand 0 "" ""))))
13102 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
13103 (plus:P (match_dup 1)
13104 (const_int -1)))
13105 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13106 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13107 ""
13108 "*
13109 {
13110 if (which_alternative != 0)
13111 return \"#\";
13112 else if (get_attr_length (insn) == 4)
13113 return \"bdz %l0\";
13114 else
13115 return \"{bdn|bdnz} $+8\;b %l0\";
13116 }"
13117 [(set_attr "type" "branch")
13118 (set_attr "length" "*,12,16,16")])
13119
13120 ;; Similar but use EQ
13121
13122 (define_insn "*ctr<mode>_internal5"
13123 [(set (pc)
13124 (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13125 (const_int 1))
13126 (label_ref (match_operand 0 "" ""))
13127 (pc)))
13128 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
13129 (plus:P (match_dup 1)
13130 (const_int -1)))
13131 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13132 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13133 ""
13134 "*
13135 {
13136 if (which_alternative != 0)
13137 return \"#\";
13138 else if (get_attr_length (insn) == 4)
13139 return \"bdz %l0\";
13140 else
13141 return \"{bdn|bdnz} $+8\;b %l0\";
13142 }"
13143 [(set_attr "type" "branch")
13144 (set_attr "length" "*,12,16,16")])
13145
13146 (define_insn "*ctr<mode>_internal6"
13147 [(set (pc)
13148 (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13149 (const_int 1))
13150 (pc)
13151 (label_ref (match_operand 0 "" ""))))
13152 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
13153 (plus:P (match_dup 1)
13154 (const_int -1)))
13155 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13156 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13157 ""
13158 "*
13159 {
13160 if (which_alternative != 0)
13161 return \"#\";
13162 else if (get_attr_length (insn) == 4)
13163 return \"{bdn|bdnz} %l0\";
13164 else
13165 return \"bdz $+8\;b %l0\";
13166 }"
13167 [(set_attr "type" "branch")
13168 (set_attr "length" "*,12,16,16")])
13169
13170 ;; Now the splitters if we could not allocate the CTR register
13171
13172 (define_split
13173 [(set (pc)
13174 (if_then_else (match_operator 2 "comparison_operator"
13175 [(match_operand:P 1 "gpc_reg_operand" "")
13176 (const_int 1)])
13177 (match_operand 5 "" "")
13178 (match_operand 6 "" "")))
13179 (set (match_operand:P 0 "gpc_reg_operand" "")
13180 (plus:P (match_dup 1) (const_int -1)))
13181 (clobber (match_scratch:CC 3 ""))
13182 (clobber (match_scratch:P 4 ""))]
13183 "reload_completed"
13184 [(parallel [(set (match_dup 3)
13185 (compare:CC (plus:P (match_dup 1)
13186 (const_int -1))
13187 (const_int 0)))
13188 (set (match_dup 0)
13189 (plus:P (match_dup 1)
13190 (const_int -1)))])
13191 (set (pc) (if_then_else (match_dup 7)
13192 (match_dup 5)
13193 (match_dup 6)))]
13194 "
13195 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
13196 operands[3], const0_rtx); }")
13197
13198 (define_split
13199 [(set (pc)
13200 (if_then_else (match_operator 2 "comparison_operator"
13201 [(match_operand:P 1 "gpc_reg_operand" "")
13202 (const_int 1)])
13203 (match_operand 5 "" "")
13204 (match_operand 6 "" "")))
13205 (set (match_operand:P 0 "nonimmediate_operand" "")
13206 (plus:P (match_dup 1) (const_int -1)))
13207 (clobber (match_scratch:CC 3 ""))
13208 (clobber (match_scratch:P 4 ""))]
13209 "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
13210 [(parallel [(set (match_dup 3)
13211 (compare:CC (plus:P (match_dup 1)
13212 (const_int -1))
13213 (const_int 0)))
13214 (set (match_dup 4)
13215 (plus:P (match_dup 1)
13216 (const_int -1)))])
13217 (set (match_dup 0)
13218 (match_dup 4))
13219 (set (pc) (if_then_else (match_dup 7)
13220 (match_dup 5)
13221 (match_dup 6)))]
13222 "
13223 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
13224 operands[3], const0_rtx); }")
13225 \f
13226 (define_insn "trap"
13227 [(trap_if (const_int 1) (const_int 0))]
13228 ""
13229 "{t 31,0,0|trap}")
13230
13231 (define_expand "conditional_trap"
13232 [(trap_if (match_operator 0 "trap_comparison_operator"
13233 [(match_dup 2) (match_dup 3)])
13234 (match_operand 1 "const_int_operand" ""))]
13235 ""
13236 "if (rs6000_compare_fp_p || operands[1] != const0_rtx) FAIL;
13237 operands[2] = rs6000_compare_op0;
13238 operands[3] = rs6000_compare_op1;")
13239
13240 (define_insn ""
13241 [(trap_if (match_operator 0 "trap_comparison_operator"
13242 [(match_operand:GPR 1 "register_operand" "r")
13243 (match_operand:GPR 2 "reg_or_short_operand" "rI")])
13244 (const_int 0))]
13245 ""
13246 "{t|t<wd>}%V0%I2 %1,%2")
13247 \f
13248 ;; Insns related to generating the function prologue and epilogue.
13249
13250 (define_expand "prologue"
13251 [(use (const_int 0))]
13252 "TARGET_SCHED_PROLOG"
13253 "
13254 {
13255 rs6000_emit_prologue ();
13256 DONE;
13257 }")
13258
13259 (define_insn "*movesi_from_cr_one"
13260 [(match_parallel 0 "mfcr_operation"
13261 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
13262 (unspec:SI [(match_operand:CC 2 "cc_reg_operand" "y")
13263 (match_operand 3 "immediate_operand" "n")]
13264 UNSPEC_MOVESI_FROM_CR))])]
13265 "TARGET_MFCRF"
13266 "*
13267 {
13268 int mask = 0;
13269 int i;
13270 for (i = 0; i < XVECLEN (operands[0], 0); i++)
13271 {
13272 mask = INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
13273 operands[4] = GEN_INT (mask);
13274 output_asm_insn (\"mfcr %1,%4\", operands);
13275 }
13276 return \"\";
13277 }"
13278 [(set_attr "type" "mfcrf")])
13279
13280 (define_insn "movesi_from_cr"
13281 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13282 (unspec:SI [(reg:CC 68) (reg:CC 69) (reg:CC 70) (reg:CC 71)
13283 (reg:CC 72) (reg:CC 73) (reg:CC 74) (reg:CC 75)]
13284 UNSPEC_MOVESI_FROM_CR))]
13285 ""
13286 "mfcr %0"
13287 [(set_attr "type" "mfcr")])
13288
13289 (define_insn "*stmw"
13290 [(match_parallel 0 "stmw_operation"
13291 [(set (match_operand:SI 1 "memory_operand" "=m")
13292 (match_operand:SI 2 "gpc_reg_operand" "r"))])]
13293 "TARGET_MULTIPLE"
13294 "{stm|stmw} %2,%1")
13295
13296 (define_insn "*save_fpregs_<mode>"
13297 [(match_parallel 0 "any_parallel_operand"
13298 [(clobber (match_operand:P 1 "register_operand" "=l"))
13299 (use (match_operand:P 2 "call_operand" "s"))
13300 (set (match_operand:DF 3 "memory_operand" "=m")
13301 (match_operand:DF 4 "gpc_reg_operand" "f"))])]
13302 ""
13303 "bl %z2"
13304 [(set_attr "type" "branch")
13305 (set_attr "length" "4")])
13306
13307 ; These are to explain that changes to the stack pointer should
13308 ; not be moved over stores to stack memory.
13309 (define_insn "stack_tie"
13310 [(set (match_operand:BLK 0 "memory_operand" "+m")
13311 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
13312 ""
13313 ""
13314 [(set_attr "length" "0")])
13315
13316
13317 (define_expand "epilogue"
13318 [(use (const_int 0))]
13319 "TARGET_SCHED_PROLOG"
13320 "
13321 {
13322 rs6000_emit_epilogue (FALSE);
13323 DONE;
13324 }")
13325
13326 ; On some processors, doing the mtcrf one CC register at a time is
13327 ; faster (like on the 604e). On others, doing them all at once is
13328 ; faster; for instance, on the 601 and 750.
13329
13330 (define_expand "movsi_to_cr_one"
13331 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
13332 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
13333 (match_dup 2)] UNSPEC_MOVESI_TO_CR))]
13334 ""
13335 "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
13336
13337 (define_insn "*movsi_to_cr"
13338 [(match_parallel 0 "mtcrf_operation"
13339 [(set (match_operand:CC 1 "cc_reg_operand" "=y")
13340 (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
13341 (match_operand 3 "immediate_operand" "n")]
13342 UNSPEC_MOVESI_TO_CR))])]
13343 ""
13344 "*
13345 {
13346 int mask = 0;
13347 int i;
13348 for (i = 0; i < XVECLEN (operands[0], 0); i++)
13349 mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
13350 operands[4] = GEN_INT (mask);
13351 return \"mtcrf %4,%2\";
13352 }"
13353 [(set_attr "type" "mtcr")])
13354
13355 (define_insn "*mtcrfsi"
13356 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
13357 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
13358 (match_operand 2 "immediate_operand" "n")]
13359 UNSPEC_MOVESI_TO_CR))]
13360 "GET_CODE (operands[0]) == REG
13361 && CR_REGNO_P (REGNO (operands[0]))
13362 && GET_CODE (operands[2]) == CONST_INT
13363 && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
13364 "mtcrf %R0,%1"
13365 [(set_attr "type" "mtcr")])
13366
13367 ; The load-multiple instructions have similar properties.
13368 ; Note that "load_multiple" is a name known to the machine-independent
13369 ; code that actually corresponds to the powerpc load-string.
13370
13371 (define_insn "*lmw"
13372 [(match_parallel 0 "lmw_operation"
13373 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
13374 (match_operand:SI 2 "memory_operand" "m"))])]
13375 "TARGET_MULTIPLE"
13376 "{lm|lmw} %1,%2")
13377
13378 (define_insn "*return_internal_<mode>"
13379 [(return)
13380 (use (match_operand:P 0 "register_operand" "lc"))]
13381 ""
13382 "b%T0"
13383 [(set_attr "type" "jmpreg")])
13384
13385 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
13386 ; stuff was in GCC. Oh, and "any_parallel_operand" is a bit flexible...
13387
13388 (define_insn "*return_and_restore_fpregs_<mode>"
13389 [(match_parallel 0 "any_parallel_operand"
13390 [(return)
13391 (use (match_operand:P 1 "register_operand" "l"))
13392 (use (match_operand:P 2 "call_operand" "s"))
13393 (set (match_operand:DF 3 "gpc_reg_operand" "=f")
13394 (match_operand:DF 4 "memory_operand" "m"))])]
13395 ""
13396 "b %z2")
13397
13398 ; This is used in compiling the unwind routines.
13399 (define_expand "eh_return"
13400 [(use (match_operand 0 "general_operand" ""))]
13401 ""
13402 "
13403 {
13404 if (TARGET_32BIT)
13405 emit_insn (gen_eh_set_lr_si (operands[0]));
13406 else
13407 emit_insn (gen_eh_set_lr_di (operands[0]));
13408 DONE;
13409 }")
13410
13411 ; We can't expand this before we know where the link register is stored.
13412 (define_insn "eh_set_lr_<mode>"
13413 [(unspec_volatile [(match_operand:P 0 "register_operand" "r")]
13414 UNSPECV_EH_RR)
13415 (clobber (match_scratch:P 1 "=&b"))]
13416 ""
13417 "#")
13418
13419 (define_split
13420 [(unspec_volatile [(match_operand 0 "register_operand" "")] UNSPECV_EH_RR)
13421 (clobber (match_scratch 1 ""))]
13422 "reload_completed"
13423 [(const_int 0)]
13424 "
13425 {
13426 rs6000_emit_eh_reg_restore (operands[0], operands[1]);
13427 DONE;
13428 }")
13429
13430 (define_insn "prefetch"
13431 [(prefetch (match_operand 0 "indexed_or_indirect_address" "a")
13432 (match_operand:SI 1 "const_int_operand" "n")
13433 (match_operand:SI 2 "const_int_operand" "n"))]
13434 "TARGET_POWERPC"
13435 "*
13436 {
13437 if (GET_CODE (operands[0]) == REG)
13438 return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
13439 return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
13440 }"
13441 [(set_attr "type" "load")])
13442 \f
13443
13444 (include "sync.md")
13445 (include "altivec.md")
13446 (include "spe.md")