]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/rs6000/rs6000.md
rs6000.c: Include params.h
[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" "dmul")])
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 2)))
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,r")
5829 (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
5830 (match_operand:DI 2 "reg_or_short_operand" "r,I")))]
5831 "TARGET_POWERPC64"
5832 "@
5833 mulld %0,%1,%2
5834 mulli %0,%1,%2"
5835 [(set (attr "type")
5836 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
5837 (const_string "imul3")
5838 (match_operand:SI 2 "short_cint_operand" "")
5839 (const_string "imul2")]
5840 (const_string "lmul")))])
5841
5842 (define_insn "*muldi3_internal1"
5843 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5844 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
5845 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
5846 (const_int 0)))
5847 (clobber (match_scratch:DI 3 "=r,r"))]
5848 "TARGET_POWERPC64"
5849 "@
5850 mulld. %3,%1,%2
5851 #"
5852 [(set_attr "type" "lmul_compare")
5853 (set_attr "length" "4,8")])
5854
5855 (define_split
5856 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5857 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
5858 (match_operand:DI 2 "gpc_reg_operand" ""))
5859 (const_int 0)))
5860 (clobber (match_scratch:DI 3 ""))]
5861 "TARGET_POWERPC64 && reload_completed"
5862 [(set (match_dup 3)
5863 (mult:DI (match_dup 1) (match_dup 2)))
5864 (set (match_dup 0)
5865 (compare:CC (match_dup 3)
5866 (const_int 0)))]
5867 "")
5868
5869 (define_insn "*muldi3_internal2"
5870 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
5871 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
5872 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
5873 (const_int 0)))
5874 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
5875 (mult:DI (match_dup 1) (match_dup 2)))]
5876 "TARGET_POWERPC64"
5877 "@
5878 mulld. %0,%1,%2
5879 #"
5880 [(set_attr "type" "lmul_compare")
5881 (set_attr "length" "4,8")])
5882
5883 (define_split
5884 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5885 (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
5886 (match_operand:DI 2 "gpc_reg_operand" ""))
5887 (const_int 0)))
5888 (set (match_operand:DI 0 "gpc_reg_operand" "")
5889 (mult:DI (match_dup 1) (match_dup 2)))]
5890 "TARGET_POWERPC64 && reload_completed"
5891 [(set (match_dup 0)
5892 (mult:DI (match_dup 1) (match_dup 2)))
5893 (set (match_dup 3)
5894 (compare:CC (match_dup 0)
5895 (const_int 0)))]
5896 "")
5897
5898 (define_insn "smuldi3_highpart"
5899 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5900 (truncate:DI
5901 (lshiftrt:TI (mult:TI (sign_extend:TI
5902 (match_operand:DI 1 "gpc_reg_operand" "%r"))
5903 (sign_extend:TI
5904 (match_operand:DI 2 "gpc_reg_operand" "r")))
5905 (const_int 64))))]
5906 "TARGET_POWERPC64"
5907 "mulhd %0,%1,%2"
5908 [(set_attr "type" "lmul")])
5909
5910 (define_insn "umuldi3_highpart"
5911 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5912 (truncate:DI
5913 (lshiftrt:TI (mult:TI (zero_extend:TI
5914 (match_operand:DI 1 "gpc_reg_operand" "%r"))
5915 (zero_extend:TI
5916 (match_operand:DI 2 "gpc_reg_operand" "r")))
5917 (const_int 64))))]
5918 "TARGET_POWERPC64"
5919 "mulhdu %0,%1,%2"
5920 [(set_attr "type" "lmul")])
5921
5922 (define_insn "rotldi3"
5923 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5924 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
5925 (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
5926 "TARGET_POWERPC64"
5927 "rld%I2cl %0,%1,%H2,0")
5928
5929 (define_insn "*rotldi3_internal2"
5930 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5931 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5932 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
5933 (const_int 0)))
5934 (clobber (match_scratch:DI 3 "=r,r"))]
5935 "TARGET_64BIT"
5936 "@
5937 rld%I2cl. %3,%1,%H2,0
5938 #"
5939 [(set_attr "type" "delayed_compare")
5940 (set_attr "length" "4,8")])
5941
5942 (define_split
5943 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5944 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
5945 (match_operand:DI 2 "reg_or_cint_operand" ""))
5946 (const_int 0)))
5947 (clobber (match_scratch:DI 3 ""))]
5948 "TARGET_POWERPC64 && reload_completed"
5949 [(set (match_dup 3)
5950 (rotate:DI (match_dup 1) (match_dup 2)))
5951 (set (match_dup 0)
5952 (compare:CC (match_dup 3)
5953 (const_int 0)))]
5954 "")
5955
5956 (define_insn "*rotldi3_internal3"
5957 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
5958 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5959 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
5960 (const_int 0)))
5961 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
5962 (rotate:DI (match_dup 1) (match_dup 2)))]
5963 "TARGET_64BIT"
5964 "@
5965 rld%I2cl. %0,%1,%H2,0
5966 #"
5967 [(set_attr "type" "delayed_compare")
5968 (set_attr "length" "4,8")])
5969
5970 (define_split
5971 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5972 (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
5973 (match_operand:DI 2 "reg_or_cint_operand" ""))
5974 (const_int 0)))
5975 (set (match_operand:DI 0 "gpc_reg_operand" "")
5976 (rotate:DI (match_dup 1) (match_dup 2)))]
5977 "TARGET_POWERPC64 && reload_completed"
5978 [(set (match_dup 0)
5979 (rotate:DI (match_dup 1) (match_dup 2)))
5980 (set (match_dup 3)
5981 (compare:CC (match_dup 0)
5982 (const_int 0)))]
5983 "")
5984
5985 (define_insn "*rotldi3_internal4"
5986 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5987 (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
5988 (match_operand:DI 2 "reg_or_cint_operand" "ri"))
5989 (match_operand:DI 3 "mask64_operand" "n")))]
5990 "TARGET_POWERPC64"
5991 "rld%I2c%B3 %0,%1,%H2,%S3")
5992
5993 (define_insn "*rotldi3_internal5"
5994 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5995 (compare:CC (and:DI
5996 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5997 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
5998 (match_operand:DI 3 "mask64_operand" "n,n"))
5999 (const_int 0)))
6000 (clobber (match_scratch:DI 4 "=r,r"))]
6001 "TARGET_64BIT"
6002 "@
6003 rld%I2c%B3. %4,%1,%H2,%S3
6004 #"
6005 [(set_attr "type" "delayed_compare")
6006 (set_attr "length" "4,8")])
6007
6008 (define_split
6009 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6010 (compare:CC (and:DI
6011 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6012 (match_operand:DI 2 "reg_or_cint_operand" ""))
6013 (match_operand:DI 3 "mask64_operand" ""))
6014 (const_int 0)))
6015 (clobber (match_scratch:DI 4 ""))]
6016 "TARGET_POWERPC64 && reload_completed"
6017 [(set (match_dup 4)
6018 (and:DI (rotate:DI (match_dup 1)
6019 (match_dup 2))
6020 (match_dup 3)))
6021 (set (match_dup 0)
6022 (compare:CC (match_dup 4)
6023 (const_int 0)))]
6024 "")
6025
6026 (define_insn "*rotldi3_internal6"
6027 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6028 (compare:CC (and:DI
6029 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6030 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6031 (match_operand:DI 3 "mask64_operand" "n,n"))
6032 (const_int 0)))
6033 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6034 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6035 "TARGET_64BIT"
6036 "@
6037 rld%I2c%B3. %0,%1,%H2,%S3
6038 #"
6039 [(set_attr "type" "delayed_compare")
6040 (set_attr "length" "4,8")])
6041
6042 (define_split
6043 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6044 (compare:CC (and:DI
6045 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6046 (match_operand:DI 2 "reg_or_cint_operand" ""))
6047 (match_operand:DI 3 "mask64_operand" ""))
6048 (const_int 0)))
6049 (set (match_operand:DI 0 "gpc_reg_operand" "")
6050 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6051 "TARGET_POWERPC64 && reload_completed"
6052 [(set (match_dup 0)
6053 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6054 (set (match_dup 4)
6055 (compare:CC (match_dup 0)
6056 (const_int 0)))]
6057 "")
6058
6059 (define_insn "*rotldi3_internal7"
6060 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6061 (zero_extend:DI
6062 (subreg:QI
6063 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6064 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6065 "TARGET_POWERPC64"
6066 "rld%I2cl %0,%1,%H2,56")
6067
6068 (define_insn "*rotldi3_internal8"
6069 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6070 (compare:CC (zero_extend:DI
6071 (subreg:QI
6072 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6073 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6074 (const_int 0)))
6075 (clobber (match_scratch:DI 3 "=r,r"))]
6076 "TARGET_64BIT"
6077 "@
6078 rld%I2cl. %3,%1,%H2,56
6079 #"
6080 [(set_attr "type" "delayed_compare")
6081 (set_attr "length" "4,8")])
6082
6083 (define_split
6084 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6085 (compare:CC (zero_extend:DI
6086 (subreg:QI
6087 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6088 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6089 (const_int 0)))
6090 (clobber (match_scratch:DI 3 ""))]
6091 "TARGET_POWERPC64 && reload_completed"
6092 [(set (match_dup 3)
6093 (zero_extend:DI (subreg:QI
6094 (rotate:DI (match_dup 1)
6095 (match_dup 2)) 0)))
6096 (set (match_dup 0)
6097 (compare:CC (match_dup 3)
6098 (const_int 0)))]
6099 "")
6100
6101 (define_insn "*rotldi3_internal9"
6102 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6103 (compare:CC (zero_extend:DI
6104 (subreg:QI
6105 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6106 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6107 (const_int 0)))
6108 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6109 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6110 "TARGET_64BIT"
6111 "@
6112 rld%I2cl. %0,%1,%H2,56
6113 #"
6114 [(set_attr "type" "delayed_compare")
6115 (set_attr "length" "4,8")])
6116
6117 (define_split
6118 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6119 (compare:CC (zero_extend:DI
6120 (subreg:QI
6121 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6122 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6123 (const_int 0)))
6124 (set (match_operand:DI 0 "gpc_reg_operand" "")
6125 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6126 "TARGET_POWERPC64 && reload_completed"
6127 [(set (match_dup 0)
6128 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6129 (set (match_dup 3)
6130 (compare:CC (match_dup 0)
6131 (const_int 0)))]
6132 "")
6133
6134 (define_insn "*rotldi3_internal10"
6135 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6136 (zero_extend:DI
6137 (subreg:HI
6138 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6139 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6140 "TARGET_POWERPC64"
6141 "rld%I2cl %0,%1,%H2,48")
6142
6143 (define_insn "*rotldi3_internal11"
6144 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6145 (compare:CC (zero_extend:DI
6146 (subreg:HI
6147 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6148 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6149 (const_int 0)))
6150 (clobber (match_scratch:DI 3 "=r,r"))]
6151 "TARGET_64BIT"
6152 "@
6153 rld%I2cl. %3,%1,%H2,48
6154 #"
6155 [(set_attr "type" "delayed_compare")
6156 (set_attr "length" "4,8")])
6157
6158 (define_split
6159 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6160 (compare:CC (zero_extend:DI
6161 (subreg:HI
6162 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6163 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6164 (const_int 0)))
6165 (clobber (match_scratch:DI 3 ""))]
6166 "TARGET_POWERPC64 && reload_completed"
6167 [(set (match_dup 3)
6168 (zero_extend:DI (subreg:HI
6169 (rotate:DI (match_dup 1)
6170 (match_dup 2)) 0)))
6171 (set (match_dup 0)
6172 (compare:CC (match_dup 3)
6173 (const_int 0)))]
6174 "")
6175
6176 (define_insn "*rotldi3_internal12"
6177 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6178 (compare:CC (zero_extend:DI
6179 (subreg:HI
6180 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6181 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6182 (const_int 0)))
6183 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6184 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6185 "TARGET_64BIT"
6186 "@
6187 rld%I2cl. %0,%1,%H2,48
6188 #"
6189 [(set_attr "type" "delayed_compare")
6190 (set_attr "length" "4,8")])
6191
6192 (define_split
6193 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6194 (compare:CC (zero_extend:DI
6195 (subreg:HI
6196 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6197 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6198 (const_int 0)))
6199 (set (match_operand:DI 0 "gpc_reg_operand" "")
6200 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6201 "TARGET_POWERPC64 && reload_completed"
6202 [(set (match_dup 0)
6203 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6204 (set (match_dup 3)
6205 (compare:CC (match_dup 0)
6206 (const_int 0)))]
6207 "")
6208
6209 (define_insn "*rotldi3_internal13"
6210 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6211 (zero_extend:DI
6212 (subreg:SI
6213 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6214 (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6215 "TARGET_POWERPC64"
6216 "rld%I2cl %0,%1,%H2,32")
6217
6218 (define_insn "*rotldi3_internal14"
6219 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6220 (compare:CC (zero_extend:DI
6221 (subreg:SI
6222 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6223 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6224 (const_int 0)))
6225 (clobber (match_scratch:DI 3 "=r,r"))]
6226 "TARGET_64BIT"
6227 "@
6228 rld%I2cl. %3,%1,%H2,32
6229 #"
6230 [(set_attr "type" "delayed_compare")
6231 (set_attr "length" "4,8")])
6232
6233 (define_split
6234 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6235 (compare:CC (zero_extend:DI
6236 (subreg:SI
6237 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6238 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6239 (const_int 0)))
6240 (clobber (match_scratch:DI 3 ""))]
6241 "TARGET_POWERPC64 && reload_completed"
6242 [(set (match_dup 3)
6243 (zero_extend:DI (subreg:SI
6244 (rotate:DI (match_dup 1)
6245 (match_dup 2)) 0)))
6246 (set (match_dup 0)
6247 (compare:CC (match_dup 3)
6248 (const_int 0)))]
6249 "")
6250
6251 (define_insn "*rotldi3_internal15"
6252 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6253 (compare:CC (zero_extend:DI
6254 (subreg:SI
6255 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6256 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6257 (const_int 0)))
6258 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6259 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6260 "TARGET_64BIT"
6261 "@
6262 rld%I2cl. %0,%1,%H2,32
6263 #"
6264 [(set_attr "type" "delayed_compare")
6265 (set_attr "length" "4,8")])
6266
6267 (define_split
6268 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6269 (compare:CC (zero_extend:DI
6270 (subreg:SI
6271 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6272 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6273 (const_int 0)))
6274 (set (match_operand:DI 0 "gpc_reg_operand" "")
6275 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6276 "TARGET_POWERPC64 && reload_completed"
6277 [(set (match_dup 0)
6278 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6279 (set (match_dup 3)
6280 (compare:CC (match_dup 0)
6281 (const_int 0)))]
6282 "")
6283
6284 (define_expand "ashldi3"
6285 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6286 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6287 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6288 "TARGET_POWERPC64 || TARGET_POWER"
6289 "
6290 {
6291 if (TARGET_POWERPC64)
6292 ;
6293 else if (TARGET_POWER)
6294 {
6295 emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
6296 DONE;
6297 }
6298 else
6299 FAIL;
6300 }")
6301
6302 (define_insn "*ashldi3_internal1"
6303 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6304 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6305 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6306 "TARGET_POWERPC64"
6307 "sld%I2 %0,%1,%H2")
6308
6309 (define_insn "*ashldi3_internal2"
6310 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6311 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6312 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6313 (const_int 0)))
6314 (clobber (match_scratch:DI 3 "=r,r"))]
6315 "TARGET_64BIT"
6316 "@
6317 sld%I2. %3,%1,%H2
6318 #"
6319 [(set_attr "type" "delayed_compare")
6320 (set_attr "length" "4,8")])
6321
6322 (define_split
6323 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6324 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6325 (match_operand:SI 2 "reg_or_cint_operand" ""))
6326 (const_int 0)))
6327 (clobber (match_scratch:DI 3 ""))]
6328 "TARGET_POWERPC64 && reload_completed"
6329 [(set (match_dup 3)
6330 (ashift:DI (match_dup 1) (match_dup 2)))
6331 (set (match_dup 0)
6332 (compare:CC (match_dup 3)
6333 (const_int 0)))]
6334 "")
6335
6336 (define_insn "*ashldi3_internal3"
6337 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6338 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6339 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6340 (const_int 0)))
6341 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6342 (ashift:DI (match_dup 1) (match_dup 2)))]
6343 "TARGET_64BIT"
6344 "@
6345 sld%I2. %0,%1,%H2
6346 #"
6347 [(set_attr "type" "delayed_compare")
6348 (set_attr "length" "4,8")])
6349
6350 (define_split
6351 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6352 (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6353 (match_operand:SI 2 "reg_or_cint_operand" ""))
6354 (const_int 0)))
6355 (set (match_operand:DI 0 "gpc_reg_operand" "")
6356 (ashift:DI (match_dup 1) (match_dup 2)))]
6357 "TARGET_POWERPC64 && reload_completed"
6358 [(set (match_dup 0)
6359 (ashift:DI (match_dup 1) (match_dup 2)))
6360 (set (match_dup 3)
6361 (compare:CC (match_dup 0)
6362 (const_int 0)))]
6363 "")
6364
6365 (define_insn "*ashldi3_internal4"
6366 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6367 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6368 (match_operand:SI 2 "const_int_operand" "i"))
6369 (match_operand:DI 3 "const_int_operand" "n")))]
6370 "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6371 "rldic %0,%1,%H2,%W3")
6372
6373 (define_insn "ashldi3_internal5"
6374 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6375 (compare:CC
6376 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6377 (match_operand:SI 2 "const_int_operand" "i,i"))
6378 (match_operand:DI 3 "const_int_operand" "n,n"))
6379 (const_int 0)))
6380 (clobber (match_scratch:DI 4 "=r,r"))]
6381 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
6382 "@
6383 rldic. %4,%1,%H2,%W3
6384 #"
6385 [(set_attr "type" "compare")
6386 (set_attr "length" "4,8")])
6387
6388 (define_split
6389 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6390 (compare:CC
6391 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6392 (match_operand:SI 2 "const_int_operand" ""))
6393 (match_operand:DI 3 "const_int_operand" ""))
6394 (const_int 0)))
6395 (clobber (match_scratch:DI 4 ""))]
6396 "TARGET_POWERPC64 && reload_completed
6397 && includes_rldic_lshift_p (operands[2], operands[3])"
6398 [(set (match_dup 4)
6399 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6400 (match_dup 3)))
6401 (set (match_dup 0)
6402 (compare:CC (match_dup 4)
6403 (const_int 0)))]
6404 "")
6405
6406 (define_insn "*ashldi3_internal6"
6407 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6408 (compare:CC
6409 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6410 (match_operand:SI 2 "const_int_operand" "i,i"))
6411 (match_operand:DI 3 "const_int_operand" "n,n"))
6412 (const_int 0)))
6413 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6414 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6415 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
6416 "@
6417 rldic. %0,%1,%H2,%W3
6418 #"
6419 [(set_attr "type" "compare")
6420 (set_attr "length" "4,8")])
6421
6422 (define_split
6423 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6424 (compare:CC
6425 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6426 (match_operand:SI 2 "const_int_operand" ""))
6427 (match_operand:DI 3 "const_int_operand" ""))
6428 (const_int 0)))
6429 (set (match_operand:DI 0 "gpc_reg_operand" "")
6430 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6431 "TARGET_POWERPC64 && reload_completed
6432 && includes_rldic_lshift_p (operands[2], operands[3])"
6433 [(set (match_dup 0)
6434 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6435 (match_dup 3)))
6436 (set (match_dup 4)
6437 (compare:CC (match_dup 0)
6438 (const_int 0)))]
6439 "")
6440
6441 (define_insn "*ashldi3_internal7"
6442 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6443 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6444 (match_operand:SI 2 "const_int_operand" "i"))
6445 (match_operand:DI 3 "mask64_operand" "n")))]
6446 "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
6447 "rldicr %0,%1,%H2,%S3")
6448
6449 (define_insn "ashldi3_internal8"
6450 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6451 (compare:CC
6452 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6453 (match_operand:SI 2 "const_int_operand" "i,i"))
6454 (match_operand:DI 3 "mask64_operand" "n,n"))
6455 (const_int 0)))
6456 (clobber (match_scratch:DI 4 "=r,r"))]
6457 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
6458 "@
6459 rldicr. %4,%1,%H2,%S3
6460 #"
6461 [(set_attr "type" "compare")
6462 (set_attr "length" "4,8")])
6463
6464 (define_split
6465 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6466 (compare:CC
6467 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6468 (match_operand:SI 2 "const_int_operand" ""))
6469 (match_operand:DI 3 "mask64_operand" ""))
6470 (const_int 0)))
6471 (clobber (match_scratch:DI 4 ""))]
6472 "TARGET_POWERPC64 && reload_completed
6473 && includes_rldicr_lshift_p (operands[2], operands[3])"
6474 [(set (match_dup 4)
6475 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6476 (match_dup 3)))
6477 (set (match_dup 0)
6478 (compare:CC (match_dup 4)
6479 (const_int 0)))]
6480 "")
6481
6482 (define_insn "*ashldi3_internal9"
6483 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6484 (compare:CC
6485 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6486 (match_operand:SI 2 "const_int_operand" "i,i"))
6487 (match_operand:DI 3 "mask64_operand" "n,n"))
6488 (const_int 0)))
6489 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6490 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6491 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
6492 "@
6493 rldicr. %0,%1,%H2,%S3
6494 #"
6495 [(set_attr "type" "compare")
6496 (set_attr "length" "4,8")])
6497
6498 (define_split
6499 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6500 (compare:CC
6501 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6502 (match_operand:SI 2 "const_int_operand" ""))
6503 (match_operand:DI 3 "mask64_operand" ""))
6504 (const_int 0)))
6505 (set (match_operand:DI 0 "gpc_reg_operand" "")
6506 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6507 "TARGET_POWERPC64 && reload_completed
6508 && includes_rldicr_lshift_p (operands[2], operands[3])"
6509 [(set (match_dup 0)
6510 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6511 (match_dup 3)))
6512 (set (match_dup 4)
6513 (compare:CC (match_dup 0)
6514 (const_int 0)))]
6515 "")
6516
6517 (define_expand "lshrdi3"
6518 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6519 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6520 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6521 "TARGET_POWERPC64 || TARGET_POWER"
6522 "
6523 {
6524 if (TARGET_POWERPC64)
6525 ;
6526 else if (TARGET_POWER)
6527 {
6528 emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
6529 DONE;
6530 }
6531 else
6532 FAIL;
6533 }")
6534
6535 (define_insn "*lshrdi3_internal1"
6536 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6537 (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6538 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6539 "TARGET_POWERPC64"
6540 "srd%I2 %0,%1,%H2")
6541
6542 (define_insn "*lshrdi3_internal2"
6543 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6544 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6545 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6546 (const_int 0)))
6547 (clobber (match_scratch:DI 3 "=r,r"))]
6548 "TARGET_64BIT "
6549 "@
6550 srd%I2. %3,%1,%H2
6551 #"
6552 [(set_attr "type" "delayed_compare")
6553 (set_attr "length" "4,8")])
6554
6555 (define_split
6556 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6557 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6558 (match_operand:SI 2 "reg_or_cint_operand" ""))
6559 (const_int 0)))
6560 (clobber (match_scratch:DI 3 ""))]
6561 "TARGET_POWERPC64 && reload_completed"
6562 [(set (match_dup 3)
6563 (lshiftrt:DI (match_dup 1) (match_dup 2)))
6564 (set (match_dup 0)
6565 (compare:CC (match_dup 3)
6566 (const_int 0)))]
6567 "")
6568
6569 (define_insn "*lshrdi3_internal3"
6570 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6571 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6572 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6573 (const_int 0)))
6574 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6575 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
6576 "TARGET_64BIT"
6577 "@
6578 srd%I2. %0,%1,%H2
6579 #"
6580 [(set_attr "type" "delayed_compare")
6581 (set_attr "length" "4,8")])
6582
6583 (define_split
6584 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6585 (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6586 (match_operand:SI 2 "reg_or_cint_operand" ""))
6587 (const_int 0)))
6588 (set (match_operand:DI 0 "gpc_reg_operand" "")
6589 (lshiftrt:DI (match_dup 1) (match_dup 2)))]
6590 "TARGET_POWERPC64 && reload_completed"
6591 [(set (match_dup 0)
6592 (lshiftrt:DI (match_dup 1) (match_dup 2)))
6593 (set (match_dup 3)
6594 (compare:CC (match_dup 0)
6595 (const_int 0)))]
6596 "")
6597
6598 (define_expand "ashrdi3"
6599 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6600 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6601 (match_operand:SI 2 "reg_or_cint_operand" "")))]
6602 "WORDS_BIG_ENDIAN"
6603 "
6604 {
6605 if (TARGET_POWERPC64)
6606 ;
6607 else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
6608 {
6609 emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
6610 DONE;
6611 }
6612 else if (TARGET_32BIT && GET_CODE (operands[2]) == CONST_INT
6613 && WORDS_BIG_ENDIAN)
6614 {
6615 emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
6616 DONE;
6617 }
6618 else
6619 FAIL;
6620 }")
6621
6622 (define_insn "*ashrdi3_internal1"
6623 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6624 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6625 (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6626 "TARGET_POWERPC64"
6627 "srad%I2 %0,%1,%H2")
6628
6629 (define_insn "*ashrdi3_internal2"
6630 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6631 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6632 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6633 (const_int 0)))
6634 (clobber (match_scratch:DI 3 "=r,r"))]
6635 "TARGET_64BIT"
6636 "@
6637 srad%I2. %3,%1,%H2
6638 #"
6639 [(set_attr "type" "delayed_compare")
6640 (set_attr "length" "4,8")])
6641
6642 (define_split
6643 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6644 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6645 (match_operand:SI 2 "reg_or_cint_operand" ""))
6646 (const_int 0)))
6647 (clobber (match_scratch:DI 3 ""))]
6648 "TARGET_POWERPC64 && reload_completed"
6649 [(set (match_dup 3)
6650 (ashiftrt:DI (match_dup 1) (match_dup 2)))
6651 (set (match_dup 0)
6652 (compare:CC (match_dup 3)
6653 (const_int 0)))]
6654 "")
6655
6656 (define_insn "*ashrdi3_internal3"
6657 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6658 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6659 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6660 (const_int 0)))
6661 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6662 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6663 "TARGET_64BIT"
6664 "@
6665 srad%I2. %0,%1,%H2
6666 #"
6667 [(set_attr "type" "delayed_compare")
6668 (set_attr "length" "4,8")])
6669
6670 (define_split
6671 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6672 (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6673 (match_operand:SI 2 "reg_or_cint_operand" ""))
6674 (const_int 0)))
6675 (set (match_operand:DI 0 "gpc_reg_operand" "")
6676 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6677 "TARGET_POWERPC64 && reload_completed"
6678 [(set (match_dup 0)
6679 (ashiftrt:DI (match_dup 1) (match_dup 2)))
6680 (set (match_dup 3)
6681 (compare:CC (match_dup 0)
6682 (const_int 0)))]
6683 "")
6684
6685 (define_insn "anddi3"
6686 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
6687 (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r")
6688 (match_operand:DI 2 "and64_2_operand" "?r,S,T,K,J,t")))
6689 (clobber (match_scratch:CC 3 "=X,X,X,x,x,X"))]
6690 "TARGET_POWERPC64"
6691 "@
6692 and %0,%1,%2
6693 rldic%B2 %0,%1,0,%S2
6694 rlwinm %0,%1,0,%m2,%M2
6695 andi. %0,%1,%b2
6696 andis. %0,%1,%u2
6697 #"
6698 [(set_attr "type" "*,*,*,compare,compare,*")
6699 (set_attr "length" "4,4,4,4,4,8")])
6700
6701 (define_split
6702 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6703 (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
6704 (match_operand:DI 2 "mask64_2_operand" "")))
6705 (clobber (match_scratch:CC 3 ""))]
6706 "TARGET_POWERPC64
6707 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
6708 && !mask_operand (operands[2], DImode)
6709 && !mask64_operand (operands[2], DImode)"
6710 [(set (match_dup 0)
6711 (and:DI (rotate:DI (match_dup 1)
6712 (match_dup 4))
6713 (match_dup 5)))
6714 (set (match_dup 0)
6715 (and:DI (rotate:DI (match_dup 0)
6716 (match_dup 6))
6717 (match_dup 7)))]
6718 {
6719 build_mask64_2_operands (operands[2], &operands[4]);
6720 })
6721
6722 (define_insn "*anddi3_internal2"
6723 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,x,?y,?y,?y,??y,??y,?y")
6724 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r,r,r")
6725 (match_operand:DI 2 "and64_2_operand" "r,S,T,K,J,t,r,S,T,K,J,t"))
6726 (const_int 0)))
6727 (clobber (match_scratch:DI 3 "=r,r,r,r,r,r,r,r,r,r,r,r"))
6728 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,X,X,x,x,X"))]
6729 "TARGET_64BIT"
6730 "@
6731 and. %3,%1,%2
6732 rldic%B2. %3,%1,0,%S2
6733 rlwinm. %3,%1,0,%m2,%M2
6734 andi. %3,%1,%b2
6735 andis. %3,%1,%u2
6736 #
6737 #
6738 #
6739 #
6740 #
6741 #
6742 #"
6743 [(set_attr "type" "compare,compare,compare,compare,compare,compare,compare,compare,compare,compare,compare,compare")
6744 (set_attr "length" "4,4,4,4,4,8,8,8,8,8,8,12")])
6745
6746 (define_split
6747 [(set (match_operand:CC 0 "cc_reg_operand" "")
6748 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
6749 (match_operand:DI 2 "mask64_2_operand" ""))
6750 (const_int 0)))
6751 (clobber (match_scratch:DI 3 ""))
6752 (clobber (match_scratch:CC 4 ""))]
6753 "TARGET_64BIT && reload_completed
6754 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
6755 && !mask_operand (operands[2], DImode)
6756 && !mask64_operand (operands[2], DImode)"
6757 [(set (match_dup 3)
6758 (and:DI (rotate:DI (match_dup 1)
6759 (match_dup 5))
6760 (match_dup 6)))
6761 (parallel [(set (match_dup 0)
6762 (compare:CC (and:DI (rotate:DI (match_dup 3)
6763 (match_dup 7))
6764 (match_dup 8))
6765 (const_int 0)))
6766 (clobber (match_dup 3))])]
6767 "
6768 {
6769 build_mask64_2_operands (operands[2], &operands[5]);
6770 }")
6771
6772 (define_insn "*anddi3_internal3"
6773 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,x,x,?y,?y,?y,??y,??y,?y")
6774 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r,r,r")
6775 (match_operand:DI 2 "and64_2_operand" "r,S,T,K,J,t,r,S,T,K,J,t"))
6776 (const_int 0)))
6777 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r,r,r")
6778 (and:DI (match_dup 1) (match_dup 2)))
6779 (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,X,X,x,x,X"))]
6780 "TARGET_64BIT"
6781 "@
6782 and. %0,%1,%2
6783 rldic%B2. %0,%1,0,%S2
6784 rlwinm. %0,%1,0,%m2,%M2
6785 andi. %0,%1,%b2
6786 andis. %0,%1,%u2
6787 #
6788 #
6789 #
6790 #
6791 #
6792 #
6793 #"
6794 [(set_attr "type" "compare,compare,compare,compare,compare,compare,compare,compare,compare,compare,compare,compare")
6795 (set_attr "length" "4,4,4,4,4,8,8,8,8,8,8,12")])
6796
6797 (define_split
6798 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6799 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
6800 (match_operand:DI 2 "and64_2_operand" ""))
6801 (const_int 0)))
6802 (set (match_operand:DI 0 "gpc_reg_operand" "")
6803 (and:DI (match_dup 1) (match_dup 2)))
6804 (clobber (match_scratch:CC 4 ""))]
6805 "TARGET_64BIT && reload_completed"
6806 [(parallel [(set (match_dup 0)
6807 (and:DI (match_dup 1) (match_dup 2)))
6808 (clobber (match_dup 4))])
6809 (set (match_dup 3)
6810 (compare:CC (match_dup 0)
6811 (const_int 0)))]
6812 "")
6813
6814 (define_split
6815 [(set (match_operand:CC 3 "cc_reg_operand" "")
6816 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
6817 (match_operand:DI 2 "mask64_2_operand" ""))
6818 (const_int 0)))
6819 (set (match_operand:DI 0 "gpc_reg_operand" "")
6820 (and:DI (match_dup 1) (match_dup 2)))
6821 (clobber (match_scratch:CC 4 ""))]
6822 "TARGET_64BIT && reload_completed
6823 && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
6824 && !mask_operand (operands[2], DImode)
6825 && !mask64_operand (operands[2], DImode)"
6826 [(set (match_dup 0)
6827 (and:DI (rotate:DI (match_dup 1)
6828 (match_dup 5))
6829 (match_dup 6)))
6830 (parallel [(set (match_dup 3)
6831 (compare:CC (and:DI (rotate:DI (match_dup 0)
6832 (match_dup 7))
6833 (match_dup 8))
6834 (const_int 0)))
6835 (set (match_dup 0)
6836 (and:DI (rotate:DI (match_dup 0)
6837 (match_dup 7))
6838 (match_dup 8)))])]
6839 "
6840 {
6841 build_mask64_2_operands (operands[2], &operands[5]);
6842 }")
6843
6844 (define_expand "iordi3"
6845 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6846 (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
6847 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
6848 "TARGET_POWERPC64"
6849 "
6850 {
6851 if (non_logical_cint_operand (operands[2], DImode))
6852 {
6853 HOST_WIDE_INT value;
6854 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
6855 ? operands[0] : gen_reg_rtx (DImode));
6856
6857 if (GET_CODE (operands[2]) == CONST_INT)
6858 {
6859 value = INTVAL (operands[2]);
6860 emit_insn (gen_iordi3 (tmp, operands[1],
6861 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
6862 }
6863 else
6864 {
6865 value = CONST_DOUBLE_LOW (operands[2]);
6866 emit_insn (gen_iordi3 (tmp, operands[1],
6867 immed_double_const (value
6868 & (~ (HOST_WIDE_INT) 0xffff),
6869 0, DImode)));
6870 }
6871
6872 emit_insn (gen_iordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
6873 DONE;
6874 }
6875 }")
6876
6877 (define_expand "xordi3"
6878 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6879 (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
6880 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
6881 "TARGET_POWERPC64"
6882 "
6883 {
6884 if (non_logical_cint_operand (operands[2], DImode))
6885 {
6886 HOST_WIDE_INT value;
6887 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
6888 ? operands[0] : gen_reg_rtx (DImode));
6889
6890 if (GET_CODE (operands[2]) == CONST_INT)
6891 {
6892 value = INTVAL (operands[2]);
6893 emit_insn (gen_xordi3 (tmp, operands[1],
6894 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
6895 }
6896 else
6897 {
6898 value = CONST_DOUBLE_LOW (operands[2]);
6899 emit_insn (gen_xordi3 (tmp, operands[1],
6900 immed_double_const (value
6901 & (~ (HOST_WIDE_INT) 0xffff),
6902 0, DImode)));
6903 }
6904
6905 emit_insn (gen_xordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
6906 DONE;
6907 }
6908 }")
6909
6910 (define_insn "*booldi3_internal1"
6911 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
6912 (match_operator:DI 3 "boolean_or_operator"
6913 [(match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
6914 (match_operand:DI 2 "logical_operand" "r,K,JF")]))]
6915 "TARGET_POWERPC64"
6916 "@
6917 %q3 %0,%1,%2
6918 %q3i %0,%1,%b2
6919 %q3is %0,%1,%u2")
6920
6921 (define_insn "*booldi3_internal2"
6922 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6923 (compare:CC (match_operator:DI 4 "boolean_or_operator"
6924 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
6925 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
6926 (const_int 0)))
6927 (clobber (match_scratch:DI 3 "=r,r"))]
6928 "TARGET_64BIT"
6929 "@
6930 %q4. %3,%1,%2
6931 #"
6932 [(set_attr "type" "compare")
6933 (set_attr "length" "4,8")])
6934
6935 (define_split
6936 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6937 (compare:CC (match_operator:DI 4 "boolean_operator"
6938 [(match_operand:DI 1 "gpc_reg_operand" "")
6939 (match_operand:DI 2 "gpc_reg_operand" "")])
6940 (const_int 0)))
6941 (clobber (match_scratch:DI 3 ""))]
6942 "TARGET_POWERPC64 && reload_completed"
6943 [(set (match_dup 3) (match_dup 4))
6944 (set (match_dup 0)
6945 (compare:CC (match_dup 3)
6946 (const_int 0)))]
6947 "")
6948
6949 (define_insn "*booldi3_internal3"
6950 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6951 (compare:CC (match_operator:DI 4 "boolean_operator"
6952 [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
6953 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
6954 (const_int 0)))
6955 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6956 (match_dup 4))]
6957 "TARGET_64BIT"
6958 "@
6959 %q4. %0,%1,%2
6960 #"
6961 [(set_attr "type" "compare")
6962 (set_attr "length" "4,8")])
6963
6964 (define_split
6965 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6966 (compare:CC (match_operator:DI 4 "boolean_operator"
6967 [(match_operand:DI 1 "gpc_reg_operand" "")
6968 (match_operand:DI 2 "gpc_reg_operand" "")])
6969 (const_int 0)))
6970 (set (match_operand:DI 0 "gpc_reg_operand" "")
6971 (match_dup 4))]
6972 "TARGET_POWERPC64 && reload_completed"
6973 [(set (match_dup 0) (match_dup 4))
6974 (set (match_dup 3)
6975 (compare:CC (match_dup 0)
6976 (const_int 0)))]
6977 "")
6978
6979 ;; Split a logical operation that we can't do in one insn into two insns,
6980 ;; each of which does one 16-bit part. This is used by combine.
6981
6982 (define_split
6983 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6984 (match_operator:DI 3 "boolean_or_operator"
6985 [(match_operand:DI 1 "gpc_reg_operand" "")
6986 (match_operand:DI 2 "non_logical_cint_operand" "")]))]
6987 "TARGET_POWERPC64"
6988 [(set (match_dup 0) (match_dup 4))
6989 (set (match_dup 0) (match_dup 5))]
6990 "
6991 {
6992 rtx i3,i4;
6993
6994 if (GET_CODE (operands[2]) == CONST_DOUBLE)
6995 {
6996 HOST_WIDE_INT value = CONST_DOUBLE_LOW (operands[2]);
6997 i3 = immed_double_const (value & (~ (HOST_WIDE_INT) 0xffff),
6998 0, DImode);
6999 i4 = GEN_INT (value & 0xffff);
7000 }
7001 else
7002 {
7003 i3 = GEN_INT (INTVAL (operands[2])
7004 & (~ (HOST_WIDE_INT) 0xffff));
7005 i4 = GEN_INT (INTVAL (operands[2]) & 0xffff);
7006 }
7007 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
7008 operands[1], i3);
7009 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
7010 operands[0], i4);
7011 }")
7012
7013 (define_insn "*boolcdi3_internal1"
7014 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7015 (match_operator:DI 3 "boolean_operator"
7016 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7017 (match_operand:DI 2 "gpc_reg_operand" "r")]))]
7018 "TARGET_POWERPC64"
7019 "%q3 %0,%2,%1")
7020
7021 (define_insn "*boolcdi3_internal2"
7022 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7023 (compare:CC (match_operator:DI 4 "boolean_operator"
7024 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7025 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7026 (const_int 0)))
7027 (clobber (match_scratch:DI 3 "=r,r"))]
7028 "TARGET_64BIT"
7029 "@
7030 %q4. %3,%2,%1
7031 #"
7032 [(set_attr "type" "compare")
7033 (set_attr "length" "4,8")])
7034
7035 (define_split
7036 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7037 (compare:CC (match_operator:DI 4 "boolean_operator"
7038 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7039 (match_operand:DI 2 "gpc_reg_operand" "")])
7040 (const_int 0)))
7041 (clobber (match_scratch:DI 3 ""))]
7042 "TARGET_POWERPC64 && reload_completed"
7043 [(set (match_dup 3) (match_dup 4))
7044 (set (match_dup 0)
7045 (compare:CC (match_dup 3)
7046 (const_int 0)))]
7047 "")
7048
7049 (define_insn "*boolcdi3_internal3"
7050 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7051 (compare:CC (match_operator:DI 4 "boolean_operator"
7052 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7053 (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7054 (const_int 0)))
7055 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7056 (match_dup 4))]
7057 "TARGET_64BIT"
7058 "@
7059 %q4. %0,%2,%1
7060 #"
7061 [(set_attr "type" "compare")
7062 (set_attr "length" "4,8")])
7063
7064 (define_split
7065 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7066 (compare:CC (match_operator:DI 4 "boolean_operator"
7067 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7068 (match_operand:DI 2 "gpc_reg_operand" "")])
7069 (const_int 0)))
7070 (set (match_operand:DI 0 "gpc_reg_operand" "")
7071 (match_dup 4))]
7072 "TARGET_POWERPC64 && reload_completed"
7073 [(set (match_dup 0) (match_dup 4))
7074 (set (match_dup 3)
7075 (compare:CC (match_dup 0)
7076 (const_int 0)))]
7077 "")
7078
7079 (define_insn "*boolccdi3_internal1"
7080 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7081 (match_operator:DI 3 "boolean_operator"
7082 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7083 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))]))]
7084 "TARGET_POWERPC64"
7085 "%q3 %0,%1,%2")
7086
7087 (define_insn "*boolccdi3_internal2"
7088 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7089 (compare:CC (match_operator:DI 4 "boolean_operator"
7090 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7091 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7092 (const_int 0)))
7093 (clobber (match_scratch:DI 3 "=r,r"))]
7094 "TARGET_64BIT"
7095 "@
7096 %q4. %3,%1,%2
7097 #"
7098 [(set_attr "type" "compare")
7099 (set_attr "length" "4,8")])
7100
7101 (define_split
7102 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7103 (compare:CC (match_operator:DI 4 "boolean_operator"
7104 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7105 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7106 (const_int 0)))
7107 (clobber (match_scratch:DI 3 ""))]
7108 "TARGET_POWERPC64 && reload_completed"
7109 [(set (match_dup 3) (match_dup 4))
7110 (set (match_dup 0)
7111 (compare:CC (match_dup 3)
7112 (const_int 0)))]
7113 "")
7114
7115 (define_insn "*boolccdi3_internal3"
7116 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7117 (compare:CC (match_operator:DI 4 "boolean_operator"
7118 [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7119 (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7120 (const_int 0)))
7121 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7122 (match_dup 4))]
7123 "TARGET_64BIT"
7124 "@
7125 %q4. %0,%1,%2
7126 #"
7127 [(set_attr "type" "compare")
7128 (set_attr "length" "4,8")])
7129
7130 (define_split
7131 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7132 (compare:CC (match_operator:DI 4 "boolean_operator"
7133 [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7134 (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7135 (const_int 0)))
7136 (set (match_operand:DI 0 "gpc_reg_operand" "")
7137 (match_dup 4))]
7138 "TARGET_POWERPC64 && reload_completed"
7139 [(set (match_dup 0) (match_dup 4))
7140 (set (match_dup 3)
7141 (compare:CC (match_dup 0)
7142 (const_int 0)))]
7143 "")
7144 \f
7145 ;; Now define ways of moving data around.
7146
7147 ;; Set up a register with a value from the GOT table
7148
7149 (define_expand "movsi_got"
7150 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7151 (unspec:SI [(match_operand:SI 1 "got_operand" "")
7152 (match_dup 2)] UNSPEC_MOVSI_GOT))]
7153 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7154 "
7155 {
7156 if (GET_CODE (operands[1]) == CONST)
7157 {
7158 rtx offset = const0_rtx;
7159 HOST_WIDE_INT value;
7160
7161 operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
7162 value = INTVAL (offset);
7163 if (value != 0)
7164 {
7165 rtx tmp = (no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode));
7166 emit_insn (gen_movsi_got (tmp, operands[1]));
7167 emit_insn (gen_addsi3 (operands[0], tmp, offset));
7168 DONE;
7169 }
7170 }
7171
7172 operands[2] = rs6000_got_register (operands[1]);
7173 }")
7174
7175 (define_insn "*movsi_got_internal"
7176 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7177 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7178 (match_operand:SI 2 "gpc_reg_operand" "b")]
7179 UNSPEC_MOVSI_GOT))]
7180 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7181 "{l|lwz} %0,%a1@got(%2)"
7182 [(set_attr "type" "load")])
7183
7184 ;; Used by sched, shorten_branches and final when the GOT pseudo reg
7185 ;; didn't get allocated to a hard register.
7186 (define_split
7187 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7188 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7189 (match_operand:SI 2 "memory_operand" "")]
7190 UNSPEC_MOVSI_GOT))]
7191 "DEFAULT_ABI == ABI_V4
7192 && flag_pic == 1
7193 && (reload_in_progress || reload_completed)"
7194 [(set (match_dup 0) (match_dup 2))
7195 (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)]
7196 UNSPEC_MOVSI_GOT))]
7197 "")
7198
7199 ;; For SI, we special-case integers that can't be loaded in one insn. We
7200 ;; do the load 16-bits at a time. We could do this by loading from memory,
7201 ;; and this is even supposed to be faster, but it is simpler not to get
7202 ;; integers in the TOC.
7203 (define_insn "movsi_low"
7204 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7205 (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7206 (match_operand 2 "" ""))))]
7207 "TARGET_MACHO && ! TARGET_64BIT"
7208 "{l|lwz} %0,lo16(%2)(%1)"
7209 [(set_attr "type" "load")
7210 (set_attr "length" "4")])
7211
7212 (define_insn "*movsi_internal1"
7213 [(set (match_operand:SI 0 "rs6000_nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
7214 (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,R,*h,r,r,r,0"))]
7215 "gpc_reg_operand (operands[0], SImode)
7216 || gpc_reg_operand (operands[1], SImode)"
7217 "@
7218 mr %0,%1
7219 {cal|la} %0,%a1
7220 {l%U1%X1|lwz%U1%X1} %0,%1
7221 {st%U0%X0|stw%U0%X0} %1,%0
7222 {lil|li} %0,%1
7223 {liu|lis} %0,%v1
7224 #
7225 {cal|la} %0,%a1
7226 mf%1 %0
7227 mt%0 %1
7228 mt%0 %1
7229 mt%0 %1
7230 {cror 0,0,0|nop}"
7231 [(set_attr "type" "*,*,load,store,*,*,*,*,mfjmpr,*,mtjmpr,*,*")
7232 (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
7233
7234 ;; Split a load of a large constant into the appropriate two-insn
7235 ;; sequence.
7236
7237 (define_split
7238 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7239 (match_operand:SI 1 "const_int_operand" ""))]
7240 "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
7241 && (INTVAL (operands[1]) & 0xffff) != 0"
7242 [(set (match_dup 0)
7243 (match_dup 2))
7244 (set (match_dup 0)
7245 (ior:SI (match_dup 0)
7246 (match_dup 3)))]
7247 "
7248 { rtx tem = rs6000_emit_set_const (operands[0], SImode, operands[1], 2);
7249
7250 if (tem == operands[0])
7251 DONE;
7252 else
7253 FAIL;
7254 }")
7255
7256 (define_insn "*mov<mode>_internal2"
7257 [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
7258 (compare:CC (match_operand:P 1 "gpc_reg_operand" "0,r,r")
7259 (const_int 0)))
7260 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
7261 ""
7262 "@
7263 {cmpi|cmp<wd>i} %2,%0,0
7264 mr. %0,%1
7265 #"
7266 [(set_attr "type" "cmp,compare,cmp")
7267 (set_attr "length" "4,4,8")])
7268
7269 (define_split
7270 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
7271 (compare:CC (match_operand:P 1 "gpc_reg_operand" "")
7272 (const_int 0)))
7273 (set (match_operand:P 0 "gpc_reg_operand" "") (match_dup 1))]
7274 "reload_completed"
7275 [(set (match_dup 0) (match_dup 1))
7276 (set (match_dup 2)
7277 (compare:CC (match_dup 0)
7278 (const_int 0)))]
7279 "")
7280 \f
7281 (define_insn "*movhi_internal"
7282 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7283 (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
7284 "gpc_reg_operand (operands[0], HImode)
7285 || gpc_reg_operand (operands[1], HImode)"
7286 "@
7287 mr %0,%1
7288 lhz%U1%X1 %0,%1
7289 sth%U0%X0 %1,%0
7290 {lil|li} %0,%w1
7291 mf%1 %0
7292 mt%0 %1
7293 mt%0 %1
7294 {cror 0,0,0|nop}"
7295 [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
7296
7297 (define_expand "mov<mode>"
7298 [(set (match_operand:INT 0 "general_operand" "")
7299 (match_operand:INT 1 "any_operand" ""))]
7300 ""
7301 "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
7302
7303 (define_insn "*movqi_internal"
7304 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7305 (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
7306 "gpc_reg_operand (operands[0], QImode)
7307 || gpc_reg_operand (operands[1], QImode)"
7308 "@
7309 mr %0,%1
7310 lbz%U1%X1 %0,%1
7311 stb%U0%X0 %1,%0
7312 {lil|li} %0,%1
7313 mf%1 %0
7314 mt%0 %1
7315 mt%0 %1
7316 {cror 0,0,0|nop}"
7317 [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
7318 \f
7319 ;; Here is how to move condition codes around. When we store CC data in
7320 ;; an integer register or memory, we store just the high-order 4 bits.
7321 ;; This lets us not shift in the most common case of CR0.
7322 (define_expand "movcc"
7323 [(set (match_operand:CC 0 "nonimmediate_operand" "")
7324 (match_operand:CC 1 "nonimmediate_operand" ""))]
7325 ""
7326 "")
7327
7328 (define_insn "*movcc_internal1"
7329 [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,?y,r,r,r,r,q,cl,r,m")
7330 (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,h,r,r,m,r"))]
7331 "register_operand (operands[0], CCmode)
7332 || register_operand (operands[1], CCmode)"
7333 "@
7334 mcrf %0,%1
7335 mtcrf 128,%1
7336 {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
7337 mfcr %0%Q1
7338 mfcr %0%Q1\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
7339 mr %0,%1
7340 mf%1 %0
7341 mt%0 %1
7342 mt%0 %1
7343 {l%U1%X1|lwz%U1%X1} %0,%1
7344 {st%U0%U1|stw%U0%U1} %1,%0"
7345 [(set (attr "type")
7346 (cond [(eq_attr "alternative" "0")
7347 (const_string "cr_logical")
7348 (eq_attr "alternative" "1,2")
7349 (const_string "mtcr")
7350 (eq_attr "alternative" "5,7")
7351 (const_string "integer")
7352 (eq_attr "alternative" "6")
7353 (const_string "mfjmpr")
7354 (eq_attr "alternative" "8")
7355 (const_string "mtjmpr")
7356 (eq_attr "alternative" "9")
7357 (const_string "load")
7358 (eq_attr "alternative" "10")
7359 (const_string "store")
7360 (ne (symbol_ref "TARGET_MFCRF") (const_int 0))
7361 (const_string "mfcrf")
7362 ]
7363 (const_string "mfcr")))
7364 (set_attr "length" "4,4,12,4,8,4,4,4,4,4,4")])
7365 \f
7366 ;; For floating-point, we normally deal with the floating-point registers
7367 ;; unless -msoft-float is used. The sole exception is that parameter passing
7368 ;; can produce floating-point values in fixed-point registers. Unless the
7369 ;; value is a simple constant or already in memory, we deal with this by
7370 ;; allocating memory and copying the value explicitly via that memory location.
7371 (define_expand "movsf"
7372 [(set (match_operand:SF 0 "nonimmediate_operand" "")
7373 (match_operand:SF 1 "any_operand" ""))]
7374 ""
7375 "{ rs6000_emit_move (operands[0], operands[1], SFmode); DONE; }")
7376
7377 (define_split
7378 [(set (match_operand:SF 0 "gpc_reg_operand" "")
7379 (match_operand:SF 1 "const_double_operand" ""))]
7380 "reload_completed
7381 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7382 || (GET_CODE (operands[0]) == SUBREG
7383 && GET_CODE (SUBREG_REG (operands[0])) == REG
7384 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7385 [(set (match_dup 2) (match_dup 3))]
7386 "
7387 {
7388 long l;
7389 REAL_VALUE_TYPE rv;
7390
7391 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7392 REAL_VALUE_TO_TARGET_SINGLE (rv, l);
7393
7394 if (! TARGET_POWERPC64)
7395 operands[2] = operand_subword (operands[0], 0, 0, SFmode);
7396 else
7397 operands[2] = gen_lowpart (SImode, operands[0]);
7398
7399 operands[3] = gen_int_mode (l, SImode);
7400 }")
7401
7402 (define_insn "*movsf_hardfloat"
7403 [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,*c*l,*q,!r,*h,!r,!r")
7404 (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,r,r,h,0,G,Fn"))]
7405 "(gpc_reg_operand (operands[0], SFmode)
7406 || gpc_reg_operand (operands[1], SFmode))
7407 && (TARGET_HARD_FLOAT && TARGET_FPRS)"
7408 "@
7409 mr %0,%1
7410 {l%U1%X1|lwz%U1%X1} %0,%1
7411 {st%U0%X0|stw%U0%X0} %1,%0
7412 fmr %0,%1
7413 lfs%U1%X1 %0,%1
7414 stfs%U0%X0 %1,%0
7415 mt%0 %1
7416 mt%0 %1
7417 mf%1 %0
7418 {cror 0,0,0|nop}
7419 #
7420 #"
7421 [(set_attr "type" "*,load,store,fp,fpload,fpstore,mtjmpr,*,mfjmpr,*,*,*")
7422 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,8")])
7423
7424 (define_insn "*movsf_softfloat"
7425 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,cl,q,r,r,m,r,r,r,r,r,*h")
7426 (match_operand:SF 1 "input_operand" "r,r,r,h,m,r,I,L,R,G,Fn,0"))]
7427 "(gpc_reg_operand (operands[0], SFmode)
7428 || gpc_reg_operand (operands[1], SFmode))
7429 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
7430 "@
7431 mr %0,%1
7432 mt%0 %1
7433 mt%0 %1
7434 mf%1 %0
7435 {l%U1%X1|lwz%U1%X1} %0,%1
7436 {st%U0%X0|stw%U0%X0} %1,%0
7437 {lil|li} %0,%1
7438 {liu|lis} %0,%v1
7439 {cal|la} %0,%a1
7440 #
7441 #
7442 {cror 0,0,0|nop}"
7443 [(set_attr "type" "*,mtjmpr,*,mfjmpr,load,store,*,*,*,*,*,*")
7444 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8,4")])
7445
7446 \f
7447 (define_expand "movdf"
7448 [(set (match_operand:DF 0 "nonimmediate_operand" "")
7449 (match_operand:DF 1 "any_operand" ""))]
7450 ""
7451 "{ rs6000_emit_move (operands[0], operands[1], DFmode); DONE; }")
7452
7453 (define_split
7454 [(set (match_operand:DF 0 "gpc_reg_operand" "")
7455 (match_operand:DF 1 "const_int_operand" ""))]
7456 "! TARGET_POWERPC64 && reload_completed
7457 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7458 || (GET_CODE (operands[0]) == SUBREG
7459 && GET_CODE (SUBREG_REG (operands[0])) == REG
7460 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7461 [(set (match_dup 2) (match_dup 4))
7462 (set (match_dup 3) (match_dup 1))]
7463 "
7464 {
7465 int endian = (WORDS_BIG_ENDIAN == 0);
7466 HOST_WIDE_INT value = INTVAL (operands[1]);
7467
7468 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
7469 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
7470 #if HOST_BITS_PER_WIDE_INT == 32
7471 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
7472 #else
7473 operands[4] = GEN_INT (value >> 32);
7474 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
7475 #endif
7476 }")
7477
7478 (define_split
7479 [(set (match_operand:DF 0 "gpc_reg_operand" "")
7480 (match_operand:DF 1 "const_double_operand" ""))]
7481 "! TARGET_POWERPC64 && reload_completed
7482 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7483 || (GET_CODE (operands[0]) == SUBREG
7484 && GET_CODE (SUBREG_REG (operands[0])) == REG
7485 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7486 [(set (match_dup 2) (match_dup 4))
7487 (set (match_dup 3) (match_dup 5))]
7488 "
7489 {
7490 int endian = (WORDS_BIG_ENDIAN == 0);
7491 long l[2];
7492 REAL_VALUE_TYPE rv;
7493
7494 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7495 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
7496
7497 operands[2] = operand_subword (operands[0], endian, 0, DFmode);
7498 operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
7499 operands[4] = gen_int_mode (l[endian], SImode);
7500 operands[5] = gen_int_mode (l[1 - endian], SImode);
7501 }")
7502
7503 (define_split
7504 [(set (match_operand:DF 0 "gpc_reg_operand" "")
7505 (match_operand:DF 1 "const_double_operand" ""))]
7506 "TARGET_POWERPC64 && reload_completed
7507 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7508 || (GET_CODE (operands[0]) == SUBREG
7509 && GET_CODE (SUBREG_REG (operands[0])) == REG
7510 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7511 [(set (match_dup 2) (match_dup 3))]
7512 "
7513 {
7514 int endian = (WORDS_BIG_ENDIAN == 0);
7515 long l[2];
7516 REAL_VALUE_TYPE rv;
7517 #if HOST_BITS_PER_WIDE_INT >= 64
7518 HOST_WIDE_INT val;
7519 #endif
7520
7521 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7522 REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
7523
7524 operands[2] = gen_lowpart (DImode, operands[0]);
7525 /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN. */
7526 #if HOST_BITS_PER_WIDE_INT >= 64
7527 val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32
7528 | ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
7529
7530 operands[3] = gen_int_mode (val, DImode);
7531 #else
7532 operands[3] = immed_double_const (l[1 - endian], l[endian], DImode);
7533 #endif
7534 }")
7535
7536 ;; Don't have reload use general registers to load a constant. First,
7537 ;; it might not work if the output operand is the equivalent of
7538 ;; a non-offsettable memref, but also it is less efficient than loading
7539 ;; the constant into an FP register, since it will probably be used there.
7540 ;; The "??" is a kludge until we can figure out a more reasonable way
7541 ;; of handling these non-offsettable values.
7542 (define_insn "*movdf_hardfloat32"
7543 [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,f,f,m,!r,!r,!r")
7544 (match_operand:DF 1 "input_operand" "r,m,r,f,m,f,G,H,F"))]
7545 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
7546 && (gpc_reg_operand (operands[0], DFmode)
7547 || gpc_reg_operand (operands[1], DFmode))"
7548 "*
7549 {
7550 switch (which_alternative)
7551 {
7552 default:
7553 gcc_unreachable ();
7554 case 0:
7555 /* We normally copy the low-numbered register first. However, if
7556 the first register operand 0 is the same as the second register
7557 of operand 1, we must copy in the opposite order. */
7558 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
7559 return \"mr %L0,%L1\;mr %0,%1\";
7560 else
7561 return \"mr %0,%1\;mr %L0,%L1\";
7562 case 1:
7563 if (GET_CODE (operands[1]) == MEM
7564 && (rs6000_legitimate_offset_address_p (DFmode, XEXP (operands[1], 0),
7565 reload_completed || reload_in_progress)
7566 || rs6000_legitimate_small_data_p (DFmode, XEXP (operands[1], 0))
7567 || GET_CODE (XEXP (operands[1], 0)) == REG
7568 || GET_CODE (XEXP (operands[1], 0)) == LO_SUM
7569 || GET_CODE (XEXP (operands[1], 0)) == PRE_INC
7570 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC))
7571 {
7572 /* If the low-address word is used in the address, we must load
7573 it last. Otherwise, load it first. Note that we cannot have
7574 auto-increment in that case since the address register is
7575 known to be dead. */
7576 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
7577 operands[1], 0))
7578 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
7579 else
7580 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
7581 }
7582 else
7583 {
7584 rtx addreg;
7585
7586 addreg = find_addr_reg (XEXP (operands[1], 0));
7587 if (refers_to_regno_p (REGNO (operands[0]),
7588 REGNO (operands[0]) + 1,
7589 operands[1], 0))
7590 {
7591 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
7592 output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
7593 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
7594 return \"{lx|lwzx} %0,%1\";
7595 }
7596 else
7597 {
7598 output_asm_insn (\"{lx|lwzx} %0,%1\", operands);
7599 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
7600 output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
7601 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
7602 return \"\";
7603 }
7604 }
7605 case 2:
7606 if (GET_CODE (operands[0]) == MEM
7607 && (rs6000_legitimate_offset_address_p (DFmode, XEXP (operands[0], 0),
7608 reload_completed || reload_in_progress)
7609 || rs6000_legitimate_small_data_p (DFmode, XEXP (operands[0], 0))
7610 || GET_CODE (XEXP (operands[0], 0)) == REG
7611 || GET_CODE (XEXP (operands[0], 0)) == LO_SUM
7612 || GET_CODE (XEXP (operands[0], 0)) == PRE_INC
7613 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC))
7614 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
7615 else
7616 {
7617 rtx addreg;
7618
7619 addreg = find_addr_reg (XEXP (operands[0], 0));
7620 output_asm_insn (\"{stx|stwx} %1,%0\", operands);
7621 output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
7622 output_asm_insn (\"{stx|stwx} %L1,%0\", operands);
7623 output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
7624 return \"\";
7625 }
7626 case 3:
7627 return \"fmr %0,%1\";
7628 case 4:
7629 return \"lfd%U1%X1 %0,%1\";
7630 case 5:
7631 return \"stfd%U0%X0 %1,%0\";
7632 case 6:
7633 case 7:
7634 case 8:
7635 return \"#\";
7636 }
7637 }"
7638 [(set_attr "type" "two,load,store,fp,fpload,fpstore,*,*,*")
7639 (set_attr "length" "8,16,16,4,4,4,8,12,16")])
7640
7641 (define_insn "*movdf_softfloat32"
7642 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
7643 (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
7644 "! TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || TARGET_E500_SINGLE)
7645 && (gpc_reg_operand (operands[0], DFmode)
7646 || gpc_reg_operand (operands[1], DFmode))"
7647 "*
7648 {
7649 switch (which_alternative)
7650 {
7651 default:
7652 gcc_unreachable ();
7653 case 0:
7654 /* We normally copy the low-numbered register first. However, if
7655 the first register operand 0 is the same as the second register of
7656 operand 1, we must copy in the opposite order. */
7657 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
7658 return \"mr %L0,%L1\;mr %0,%1\";
7659 else
7660 return \"mr %0,%1\;mr %L0,%L1\";
7661 case 1:
7662 /* If the low-address word is used in the address, we must load
7663 it last. Otherwise, load it first. Note that we cannot have
7664 auto-increment in that case since the address register is
7665 known to be dead. */
7666 if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
7667 operands[1], 0))
7668 return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
7669 else
7670 return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
7671 case 2:
7672 return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
7673 case 3:
7674 case 4:
7675 case 5:
7676 return \"#\";
7677 }
7678 }"
7679 [(set_attr "type" "two,load,store,*,*,*")
7680 (set_attr "length" "8,8,8,8,12,16")])
7681
7682 ; ld/std require word-aligned displacements -> 'Y' constraint.
7683 ; List Y->r and r->Y before r->r for reload.
7684 (define_insn "*movdf_hardfloat64"
7685 [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,r,!r,f,f,m,*c*l,!r,*h,!r,!r,!r")
7686 (match_operand:DF 1 "input_operand" "r,Y,r,f,m,f,r,h,0,G,H,F"))]
7687 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
7688 && (gpc_reg_operand (operands[0], DFmode)
7689 || gpc_reg_operand (operands[1], DFmode))"
7690 "@
7691 std%U0%X0 %1,%0
7692 ld%U1%X1 %0,%1
7693 mr %0,%1
7694 fmr %0,%1
7695 lfd%U1%X1 %0,%1
7696 stfd%U0%X0 %1,%0
7697 mt%0 %1
7698 mf%1 %0
7699 {cror 0,0,0|nop}
7700 #
7701 #
7702 #"
7703 [(set_attr "type" "store,load,*,fp,fpload,fpstore,mtjmpr,mfjmpr,*,*,*,*")
7704 (set_attr "length" "4,4,4,4,4,4,4,4,4,8,12,16")])
7705
7706 (define_insn "*movdf_softfloat64"
7707 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,Y,r,cl,r,r,r,r,*h")
7708 (match_operand:DF 1 "input_operand" "Y,r,r,r,h,G,H,F,0"))]
7709 "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
7710 && (gpc_reg_operand (operands[0], DFmode)
7711 || gpc_reg_operand (operands[1], DFmode))"
7712 "@
7713 ld%U1%X1 %0,%1
7714 std%U0%X0 %1,%0
7715 mr %0,%1
7716 mt%0 %1
7717 mf%1 %0
7718 #
7719 #
7720 #
7721 {cror 0,0,0|nop}"
7722 [(set_attr "type" "load,store,*,mtjmpr,mfjmpr,*,*,*,*")
7723 (set_attr "length" "4,4,4,4,4,8,12,16,4")])
7724 \f
7725 (define_expand "movtf"
7726 [(set (match_operand:TF 0 "general_operand" "")
7727 (match_operand:TF 1 "any_operand" ""))]
7728 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7729 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7730 "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
7731
7732 ; It's important to list the o->f and f->o moves before f->f because
7733 ; otherwise reload, given m->f, will try to pick f->f and reload it,
7734 ; which doesn't make progress. Likewise r->Y must be before r->r.
7735 (define_insn_and_split "*movtf_internal"
7736 [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,f,r,Y,r")
7737 (match_operand:TF 1 "input_operand" "f,o,f,YGHF,r,r"))]
7738 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7739 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128
7740 && (gpc_reg_operand (operands[0], TFmode)
7741 || gpc_reg_operand (operands[1], TFmode))"
7742 "#"
7743 "&& reload_completed"
7744 [(pc)]
7745 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
7746 [(set_attr "length" "8,8,8,20,20,16")])
7747
7748 (define_expand "extenddftf2"
7749 [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
7750 (float_extend:TF (match_operand:DF 1 "input_operand" "")))
7751 (use (match_dup 2))])]
7752 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7753 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7754 {
7755 operands[2] = CONST0_RTX (DFmode);
7756 })
7757
7758 (define_insn_and_split "*extenddftf2_internal"
7759 [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,&f,r")
7760 (float_extend:TF (match_operand:DF 1 "input_operand" "fr,mf,mf,rmGHF")))
7761 (use (match_operand:DF 2 "zero_reg_mem_operand" "rf,m,f,n"))]
7762 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7763 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7764 "#"
7765 "&& reload_completed"
7766 [(pc)]
7767 {
7768 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
7769 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
7770 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word),
7771 operands[1]);
7772 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word),
7773 operands[2]);
7774 DONE;
7775 })
7776
7777 (define_expand "extendsftf2"
7778 [(set (match_operand:TF 0 "nonimmediate_operand" "")
7779 (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "")))]
7780 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7781 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7782 {
7783 rtx tmp = gen_reg_rtx (DFmode);
7784 emit_insn (gen_extendsfdf2 (tmp, operands[1]));
7785 emit_insn (gen_extenddftf2 (operands[0], tmp));
7786 DONE;
7787 })
7788
7789 (define_expand "trunctfdf2"
7790 [(set (match_operand:DF 0 "gpc_reg_operand" "")
7791 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))]
7792 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7793 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7794 "")
7795
7796 (define_insn_and_split "trunctfdf2_internal1"
7797 [(set (match_operand:DF 0 "gpc_reg_operand" "=f,?f")
7798 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "0,f")))]
7799 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && !TARGET_XL_COMPAT
7800 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7801 "@
7802 #
7803 fmr %0,%1"
7804 "&& reload_completed && REGNO (operands[0]) == REGNO (operands[1])"
7805 [(const_int 0)]
7806 {
7807 emit_note (NOTE_INSN_DELETED);
7808 DONE;
7809 }
7810 [(set_attr "type" "fp")])
7811
7812 (define_insn "trunctfdf2_internal2"
7813 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
7814 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "f")))]
7815 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && TARGET_XL_COMPAT
7816 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7817 "fadd %0,%1,%L1"
7818 [(set_attr "type" "fp")])
7819
7820 (define_insn_and_split "trunctfsf2"
7821 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
7822 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "f")))
7823 (clobber (match_scratch:DF 2 "=f"))]
7824 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7825 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7826 "#"
7827 "&& reload_completed"
7828 [(set (match_dup 2)
7829 (float_truncate:DF (match_dup 1)))
7830 (set (match_dup 0)
7831 (float_truncate:SF (match_dup 2)))]
7832 "")
7833
7834 (define_expand "floatsitf2"
7835 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
7836 (float:TF (match_operand:SI 1 "gpc_reg_operand" "r")))]
7837 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7838 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7839 {
7840 rtx tmp = gen_reg_rtx (DFmode);
7841 expand_float (tmp, operands[1], false);
7842 emit_insn (gen_extenddftf2 (operands[0], tmp));
7843 DONE;
7844 })
7845
7846 ; fadd, but rounding towards zero.
7847 ; This is probably not the optimal code sequence.
7848 (define_insn "fix_trunc_helper"
7849 [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
7850 (unspec:DF [(match_operand:TF 1 "gpc_reg_operand" "f")]
7851 UNSPEC_FIX_TRUNC_TF))
7852 (clobber (match_operand:DF 2 "gpc_reg_operand" "=&f"))]
7853 "TARGET_HARD_FLOAT && TARGET_FPRS"
7854 "mffs %2\n\tmtfsb1 31\n\tmtfsb0 30\n\tfadd %0,%1,%L1\n\tmtfsf 1,%2"
7855 [(set_attr "type" "fp")
7856 (set_attr "length" "20")])
7857
7858 (define_expand "fix_trunctfsi2"
7859 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
7860 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))
7861 (clobber (match_dup 2))
7862 (clobber (match_dup 3))
7863 (clobber (match_dup 4))
7864 (clobber (match_dup 5))])]
7865 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7866 && (TARGET_POWER2 || TARGET_POWERPC)
7867 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7868 {
7869 operands[2] = gen_reg_rtx (DFmode);
7870 operands[3] = gen_reg_rtx (DFmode);
7871 operands[4] = gen_reg_rtx (DImode);
7872 operands[5] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
7873 })
7874
7875 (define_insn_and_split "*fix_trunctfsi2_internal"
7876 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7877 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "f")))
7878 (clobber (match_operand:DF 2 "gpc_reg_operand" "=f"))
7879 (clobber (match_operand:DF 3 "gpc_reg_operand" "=&f"))
7880 (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))
7881 (clobber (match_operand:DI 5 "memory_operand" "=o"))]
7882 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7883 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7884 "#"
7885 "&& (!no_new_pseudos || offsettable_nonstrict_memref_p (operands[5]))"
7886 [(pc)]
7887 {
7888 rtx lowword;
7889 emit_insn (gen_fix_trunc_helper (operands[2], operands[1], operands[3]));
7890
7891 gcc_assert (MEM_P (operands[5]));
7892 lowword = adjust_address (operands[5], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
7893
7894 emit_insn (gen_fctiwz (operands[4], operands[2]));
7895 emit_move_insn (operands[5], operands[4]);
7896 emit_move_insn (operands[0], lowword);
7897 DONE;
7898 })
7899
7900 (define_insn "negtf2"
7901 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
7902 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
7903 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7904 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7905 "*
7906 {
7907 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
7908 return \"fneg %L0,%L1\;fneg %0,%1\";
7909 else
7910 return \"fneg %0,%1\;fneg %L0,%L1\";
7911 }"
7912 [(set_attr "type" "fp")
7913 (set_attr "length" "8")])
7914
7915 (define_expand "abstf2"
7916 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
7917 (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
7918 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7919 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7920 "
7921 {
7922 rtx label = gen_label_rtx ();
7923 emit_insn (gen_abstf2_internal (operands[0], operands[1], label));
7924 emit_label (label);
7925 DONE;
7926 }")
7927
7928 (define_expand "abstf2_internal"
7929 [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
7930 (match_operand:TF 1 "gpc_reg_operand" "f"))
7931 (set (match_dup 3) (match_dup 5))
7932 (set (match_dup 5) (abs:DF (match_dup 5)))
7933 (set (match_dup 4) (compare:CCFP (match_dup 3) (match_dup 5)))
7934 (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
7935 (label_ref (match_operand 2 "" ""))
7936 (pc)))
7937 (set (match_dup 6) (neg:DF (match_dup 6)))]
7938 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
7939 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
7940 "
7941 {
7942 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
7943 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
7944 operands[3] = gen_reg_rtx (DFmode);
7945 operands[4] = gen_reg_rtx (CCFPmode);
7946 operands[5] = simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word);
7947 operands[6] = simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word);
7948 }")
7949 \f
7950 ;; Next come the multi-word integer load and store and the load and store
7951 ;; multiple insns.
7952
7953 ; List r->r after r->"o<>", otherwise reload will try to reload a
7954 ; non-offsettable address by using r->r which won't make progress.
7955 (define_insn "*movdi_internal32"
7956 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,r,r,*f,*f,m,r")
7957 (match_operand:DI 1 "input_operand" "r,r,m,f,m,f,IJKnGHF"))]
7958 "! TARGET_POWERPC64
7959 && (gpc_reg_operand (operands[0], DImode)
7960 || gpc_reg_operand (operands[1], DImode))"
7961 "@
7962 #
7963 #
7964 #
7965 fmr %0,%1
7966 lfd%U1%X1 %0,%1
7967 stfd%U0%X0 %1,%0
7968 #"
7969 [(set_attr "type" "load,*,store,fp,fpload,fpstore,*")])
7970
7971 (define_split
7972 [(set (match_operand:DI 0 "gpc_reg_operand" "")
7973 (match_operand:DI 1 "const_int_operand" ""))]
7974 "! TARGET_POWERPC64 && reload_completed"
7975 [(set (match_dup 2) (match_dup 4))
7976 (set (match_dup 3) (match_dup 1))]
7977 "
7978 {
7979 HOST_WIDE_INT value = INTVAL (operands[1]);
7980 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
7981 DImode);
7982 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
7983 DImode);
7984 #if HOST_BITS_PER_WIDE_INT == 32
7985 operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
7986 #else
7987 operands[4] = GEN_INT (value >> 32);
7988 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
7989 #endif
7990 }")
7991
7992 (define_split
7993 [(set (match_operand:DI 0 "nonimmediate_operand" "")
7994 (match_operand:DI 1 "input_operand" ""))]
7995 "reload_completed && !TARGET_POWERPC64
7996 && gpr_or_gpr_p (operands[0], operands[1])"
7997 [(pc)]
7998 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
7999
8000 (define_insn "*movdi_internal64"
8001 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,*f,*f,m,r,*h,*h")
8002 (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0"))]
8003 "TARGET_POWERPC64
8004 && (gpc_reg_operand (operands[0], DImode)
8005 || gpc_reg_operand (operands[1], DImode))"
8006 "@
8007 mr %0,%1
8008 ld%U1%X1 %0,%1
8009 std%U0%X0 %1,%0
8010 li %0,%1
8011 lis %0,%v1
8012 #
8013 {cal|la} %0,%a1
8014 fmr %0,%1
8015 lfd%U1%X1 %0,%1
8016 stfd%U0%X0 %1,%0
8017 mf%1 %0
8018 mt%0 %1
8019 {cror 0,0,0|nop}"
8020 [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,mfjmpr,mtjmpr,*")
8021 (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
8022
8023 ;; immediate value valid for a single instruction hiding in a const_double
8024 (define_insn ""
8025 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
8026 (match_operand:DI 1 "const_double_operand" "F"))]
8027 "HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64
8028 && GET_CODE (operands[1]) == CONST_DOUBLE
8029 && num_insns_constant (operands[1], DImode) == 1"
8030 "*
8031 {
8032 return ((unsigned HOST_WIDE_INT)
8033 (CONST_DOUBLE_LOW (operands[1]) + 0x8000) < 0x10000)
8034 ? \"li %0,%1\" : \"lis %0,%v1\";
8035 }")
8036
8037 ;; Generate all one-bits and clear left or right.
8038 ;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
8039 (define_split
8040 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8041 (match_operand:DI 1 "mask64_operand" ""))]
8042 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8043 [(set (match_dup 0) (const_int -1))
8044 (set (match_dup 0)
8045 (and:DI (rotate:DI (match_dup 0)
8046 (const_int 0))
8047 (match_dup 1)))]
8048 "")
8049
8050 ;; Split a load of a large constant into the appropriate five-instruction
8051 ;; sequence. Handle anything in a constant number of insns.
8052 ;; When non-easy constants can go in the TOC, this should use
8053 ;; easy_fp_constant predicate.
8054 (define_split
8055 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8056 (match_operand:DI 1 "const_int_operand" ""))]
8057 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8058 [(set (match_dup 0) (match_dup 2))
8059 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8060 "
8061 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8062
8063 if (tem == operands[0])
8064 DONE;
8065 else
8066 FAIL;
8067 }")
8068
8069 (define_split
8070 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8071 (match_operand:DI 1 "const_double_operand" ""))]
8072 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8073 [(set (match_dup 0) (match_dup 2))
8074 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8075 "
8076 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8077
8078 if (tem == operands[0])
8079 DONE;
8080 else
8081 FAIL;
8082 }")
8083 \f
8084 ;; TImode is similar, except that we usually want to compute the address into
8085 ;; a register and use lsi/stsi (the exception is during reload). MQ is also
8086 ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
8087
8088 ;; We say that MQ is clobbered in the last alternative because the first
8089 ;; alternative would never get used otherwise since it would need a reload
8090 ;; while the 2nd alternative would not. We put memory cases first so they
8091 ;; are preferred. Otherwise, we'd try to reload the output instead of
8092 ;; giving the SCRATCH mq.
8093
8094 (define_insn "*movti_power"
8095 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r,r")
8096 (match_operand:TI 1 "input_operand" "r,r,r,Q,m,n"))
8097 (clobber (match_scratch:SI 2 "=q,q#X,X,X,X,X"))]
8098 "TARGET_POWER && ! TARGET_POWERPC64
8099 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8100 "*
8101 {
8102 switch (which_alternative)
8103 {
8104 default:
8105 gcc_unreachable ();
8106
8107 case 0:
8108 if (TARGET_STRING)
8109 return \"{stsi|stswi} %1,%P0,16\";
8110 case 1:
8111 case 2:
8112 return \"#\";
8113 case 3:
8114 /* If the address is not used in the output, we can use lsi. Otherwise,
8115 fall through to generating four loads. */
8116 if (TARGET_STRING
8117 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
8118 return \"{lsi|lswi} %0,%P1,16\";
8119 /* ... fall through ... */
8120 case 4:
8121 case 5:
8122 return \"#\";
8123 }
8124 }"
8125 [(set_attr "type" "store,store,*,load,load,*")])
8126
8127 (define_insn "*movti_string"
8128 [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,o<>,????r,????r,????r,r")
8129 (match_operand:TI 1 "input_operand" "r,r,r,Q,m,n"))]
8130 "! TARGET_POWER && ! TARGET_POWERPC64
8131 && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8132 "*
8133 {
8134 switch (which_alternative)
8135 {
8136 default:
8137 gcc_unreachable ();
8138 case 0:
8139 if (TARGET_STRING)
8140 return \"{stsi|stswi} %1,%P0,16\";
8141 case 1:
8142 case 2:
8143 return \"#\";
8144 case 3:
8145 /* If the address is not used in the output, we can use lsi. Otherwise,
8146 fall through to generating four loads. */
8147 if (TARGET_STRING
8148 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
8149 return \"{lsi|lswi} %0,%P1,16\";
8150 /* ... fall through ... */
8151 case 4:
8152 case 5:
8153 return \"#\";
8154 }
8155 }"
8156 [(set_attr "type" "store_ux,store_ux,*,load_ux,load_ux,*")])
8157
8158 (define_insn "*movti_ppc64"
8159 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o<>,r")
8160 (match_operand:TI 1 "input_operand" "r,r,m"))]
8161 "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
8162 || gpc_reg_operand (operands[1], TImode))"
8163 "#"
8164 [(set_attr "type" "*,load,store")])
8165
8166 (define_split
8167 [(set (match_operand:TI 0 "gpc_reg_operand" "")
8168 (match_operand:TI 1 "const_double_operand" ""))]
8169 "TARGET_POWERPC64"
8170 [(set (match_dup 2) (match_dup 4))
8171 (set (match_dup 3) (match_dup 5))]
8172 "
8173 {
8174 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8175 TImode);
8176 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8177 TImode);
8178 if (GET_CODE (operands[1]) == CONST_DOUBLE)
8179 {
8180 operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
8181 operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
8182 }
8183 else if (GET_CODE (operands[1]) == CONST_INT)
8184 {
8185 operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
8186 operands[5] = operands[1];
8187 }
8188 else
8189 FAIL;
8190 }")
8191
8192 (define_split
8193 [(set (match_operand:TI 0 "nonimmediate_operand" "")
8194 (match_operand:TI 1 "input_operand" ""))]
8195 "reload_completed
8196 && gpr_or_gpr_p (operands[0], operands[1])"
8197 [(pc)]
8198 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8199 \f
8200 (define_expand "load_multiple"
8201 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8202 (match_operand:SI 1 "" ""))
8203 (use (match_operand:SI 2 "" ""))])]
8204 "TARGET_STRING && !TARGET_POWERPC64"
8205 "
8206 {
8207 int regno;
8208 int count;
8209 rtx op1;
8210 int i;
8211
8212 /* Support only loading a constant number of fixed-point registers from
8213 memory and only bother with this if more than two; the machine
8214 doesn't support more than eight. */
8215 if (GET_CODE (operands[2]) != CONST_INT
8216 || INTVAL (operands[2]) <= 2
8217 || INTVAL (operands[2]) > 8
8218 || GET_CODE (operands[1]) != MEM
8219 || GET_CODE (operands[0]) != REG
8220 || REGNO (operands[0]) >= 32)
8221 FAIL;
8222
8223 count = INTVAL (operands[2]);
8224 regno = REGNO (operands[0]);
8225
8226 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
8227 op1 = replace_equiv_address (operands[1],
8228 force_reg (SImode, XEXP (operands[1], 0)));
8229
8230 for (i = 0; i < count; i++)
8231 XVECEXP (operands[3], 0, i)
8232 = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
8233 adjust_address_nv (op1, SImode, i * 4));
8234 }")
8235
8236 (define_insn "*ldmsi8"
8237 [(match_parallel 0 "load_multiple_operation"
8238 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8239 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8240 (set (match_operand:SI 3 "gpc_reg_operand" "")
8241 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8242 (set (match_operand:SI 4 "gpc_reg_operand" "")
8243 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8244 (set (match_operand:SI 5 "gpc_reg_operand" "")
8245 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8246 (set (match_operand:SI 6 "gpc_reg_operand" "")
8247 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8248 (set (match_operand:SI 7 "gpc_reg_operand" "")
8249 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8250 (set (match_operand:SI 8 "gpc_reg_operand" "")
8251 (mem:SI (plus:SI (match_dup 1) (const_int 24))))
8252 (set (match_operand:SI 9 "gpc_reg_operand" "")
8253 (mem:SI (plus:SI (match_dup 1) (const_int 28))))])]
8254 "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
8255 "*
8256 { return rs6000_output_load_multiple (operands); }"
8257 [(set_attr "type" "load_ux")
8258 (set_attr "length" "32")])
8259
8260 (define_insn "*ldmsi7"
8261 [(match_parallel 0 "load_multiple_operation"
8262 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8263 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8264 (set (match_operand:SI 3 "gpc_reg_operand" "")
8265 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8266 (set (match_operand:SI 4 "gpc_reg_operand" "")
8267 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8268 (set (match_operand:SI 5 "gpc_reg_operand" "")
8269 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8270 (set (match_operand:SI 6 "gpc_reg_operand" "")
8271 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8272 (set (match_operand:SI 7 "gpc_reg_operand" "")
8273 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8274 (set (match_operand:SI 8 "gpc_reg_operand" "")
8275 (mem:SI (plus:SI (match_dup 1) (const_int 24))))])]
8276 "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
8277 "*
8278 { return rs6000_output_load_multiple (operands); }"
8279 [(set_attr "type" "load_ux")
8280 (set_attr "length" "32")])
8281
8282 (define_insn "*ldmsi6"
8283 [(match_parallel 0 "load_multiple_operation"
8284 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8285 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8286 (set (match_operand:SI 3 "gpc_reg_operand" "")
8287 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8288 (set (match_operand:SI 4 "gpc_reg_operand" "")
8289 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8290 (set (match_operand:SI 5 "gpc_reg_operand" "")
8291 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8292 (set (match_operand:SI 6 "gpc_reg_operand" "")
8293 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8294 (set (match_operand:SI 7 "gpc_reg_operand" "")
8295 (mem:SI (plus:SI (match_dup 1) (const_int 20))))])]
8296 "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
8297 "*
8298 { return rs6000_output_load_multiple (operands); }"
8299 [(set_attr "type" "load_ux")
8300 (set_attr "length" "32")])
8301
8302 (define_insn "*ldmsi5"
8303 [(match_parallel 0 "load_multiple_operation"
8304 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8305 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8306 (set (match_operand:SI 3 "gpc_reg_operand" "")
8307 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8308 (set (match_operand:SI 4 "gpc_reg_operand" "")
8309 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8310 (set (match_operand:SI 5 "gpc_reg_operand" "")
8311 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8312 (set (match_operand:SI 6 "gpc_reg_operand" "")
8313 (mem:SI (plus:SI (match_dup 1) (const_int 16))))])]
8314 "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
8315 "*
8316 { return rs6000_output_load_multiple (operands); }"
8317 [(set_attr "type" "load_ux")
8318 (set_attr "length" "32")])
8319
8320 (define_insn "*ldmsi4"
8321 [(match_parallel 0 "load_multiple_operation"
8322 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8323 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8324 (set (match_operand:SI 3 "gpc_reg_operand" "")
8325 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8326 (set (match_operand:SI 4 "gpc_reg_operand" "")
8327 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8328 (set (match_operand:SI 5 "gpc_reg_operand" "")
8329 (mem:SI (plus:SI (match_dup 1) (const_int 12))))])]
8330 "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
8331 "*
8332 { return rs6000_output_load_multiple (operands); }"
8333 [(set_attr "type" "load_ux")
8334 (set_attr "length" "32")])
8335
8336 (define_insn "*ldmsi3"
8337 [(match_parallel 0 "load_multiple_operation"
8338 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8339 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8340 (set (match_operand:SI 3 "gpc_reg_operand" "")
8341 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8342 (set (match_operand:SI 4 "gpc_reg_operand" "")
8343 (mem:SI (plus:SI (match_dup 1) (const_int 8))))])]
8344 "TARGET_STRING && XVECLEN (operands[0], 0) == 3"
8345 "*
8346 { return rs6000_output_load_multiple (operands); }"
8347 [(set_attr "type" "load_ux")
8348 (set_attr "length" "32")])
8349
8350 (define_expand "store_multiple"
8351 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8352 (match_operand:SI 1 "" ""))
8353 (clobber (scratch:SI))
8354 (use (match_operand:SI 2 "" ""))])]
8355 "TARGET_STRING && !TARGET_POWERPC64"
8356 "
8357 {
8358 int regno;
8359 int count;
8360 rtx to;
8361 rtx op0;
8362 int i;
8363
8364 /* Support only storing a constant number of fixed-point registers to
8365 memory and only bother with this if more than two; the machine
8366 doesn't support more than eight. */
8367 if (GET_CODE (operands[2]) != CONST_INT
8368 || INTVAL (operands[2]) <= 2
8369 || INTVAL (operands[2]) > 8
8370 || GET_CODE (operands[0]) != MEM
8371 || GET_CODE (operands[1]) != REG
8372 || REGNO (operands[1]) >= 32)
8373 FAIL;
8374
8375 count = INTVAL (operands[2]);
8376 regno = REGNO (operands[1]);
8377
8378 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
8379 to = force_reg (SImode, XEXP (operands[0], 0));
8380 op0 = replace_equiv_address (operands[0], to);
8381
8382 XVECEXP (operands[3], 0, 0)
8383 = gen_rtx_SET (VOIDmode, adjust_address_nv (op0, SImode, 0), operands[1]);
8384 XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
8385 gen_rtx_SCRATCH (SImode));
8386
8387 for (i = 1; i < count; i++)
8388 XVECEXP (operands[3], 0, i + 1)
8389 = gen_rtx_SET (VOIDmode,
8390 adjust_address_nv (op0, SImode, i * 4),
8391 gen_rtx_REG (SImode, regno + i));
8392 }")
8393
8394 (define_insn "*store_multiple_power"
8395 [(match_parallel 0 "store_multiple_operation"
8396 [(set (match_operand:SI 1 "indirect_operand" "=Q")
8397 (match_operand:SI 2 "gpc_reg_operand" "r"))
8398 (clobber (match_scratch:SI 3 "=q"))])]
8399 "TARGET_STRING && TARGET_POWER"
8400 "{stsi|stswi} %2,%P1,%O0"
8401 [(set_attr "type" "store")])
8402
8403 (define_insn "*stmsi8"
8404 [(match_parallel 0 "store_multiple_operation"
8405 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8406 (match_operand:SI 2 "gpc_reg_operand" "r"))
8407 (clobber (match_scratch:SI 3 "X"))
8408 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8409 (match_operand:SI 4 "gpc_reg_operand" "r"))
8410 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8411 (match_operand:SI 5 "gpc_reg_operand" "r"))
8412 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
8413 (match_operand:SI 6 "gpc_reg_operand" "r"))
8414 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
8415 (match_operand:SI 7 "gpc_reg_operand" "r"))
8416 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
8417 (match_operand:SI 8 "gpc_reg_operand" "r"))
8418 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
8419 (match_operand:SI 9 "gpc_reg_operand" "r"))
8420 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
8421 (match_operand:SI 10 "gpc_reg_operand" "r"))])]
8422 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 9"
8423 "{stsi|stswi} %2,%1,%O0"
8424 [(set_attr "type" "store_ux")])
8425
8426 (define_insn "*stmsi7"
8427 [(match_parallel 0 "store_multiple_operation"
8428 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8429 (match_operand:SI 2 "gpc_reg_operand" "r"))
8430 (clobber (match_scratch:SI 3 "X"))
8431 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8432 (match_operand:SI 4 "gpc_reg_operand" "r"))
8433 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8434 (match_operand:SI 5 "gpc_reg_operand" "r"))
8435 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
8436 (match_operand:SI 6 "gpc_reg_operand" "r"))
8437 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
8438 (match_operand:SI 7 "gpc_reg_operand" "r"))
8439 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
8440 (match_operand:SI 8 "gpc_reg_operand" "r"))
8441 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
8442 (match_operand:SI 9 "gpc_reg_operand" "r"))])]
8443 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 8"
8444 "{stsi|stswi} %2,%1,%O0"
8445 [(set_attr "type" "store_ux")])
8446
8447 (define_insn "*stmsi6"
8448 [(match_parallel 0 "store_multiple_operation"
8449 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8450 (match_operand:SI 2 "gpc_reg_operand" "r"))
8451 (clobber (match_scratch:SI 3 "X"))
8452 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8453 (match_operand:SI 4 "gpc_reg_operand" "r"))
8454 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8455 (match_operand:SI 5 "gpc_reg_operand" "r"))
8456 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
8457 (match_operand:SI 6 "gpc_reg_operand" "r"))
8458 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
8459 (match_operand:SI 7 "gpc_reg_operand" "r"))
8460 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
8461 (match_operand:SI 8 "gpc_reg_operand" "r"))])]
8462 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 7"
8463 "{stsi|stswi} %2,%1,%O0"
8464 [(set_attr "type" "store_ux")])
8465
8466 (define_insn "*stmsi5"
8467 [(match_parallel 0 "store_multiple_operation"
8468 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8469 (match_operand:SI 2 "gpc_reg_operand" "r"))
8470 (clobber (match_scratch:SI 3 "X"))
8471 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8472 (match_operand:SI 4 "gpc_reg_operand" "r"))
8473 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8474 (match_operand:SI 5 "gpc_reg_operand" "r"))
8475 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
8476 (match_operand:SI 6 "gpc_reg_operand" "r"))
8477 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
8478 (match_operand:SI 7 "gpc_reg_operand" "r"))])]
8479 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 6"
8480 "{stsi|stswi} %2,%1,%O0"
8481 [(set_attr "type" "store_ux")])
8482
8483 (define_insn "*stmsi4"
8484 [(match_parallel 0 "store_multiple_operation"
8485 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8486 (match_operand:SI 2 "gpc_reg_operand" "r"))
8487 (clobber (match_scratch:SI 3 "X"))
8488 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8489 (match_operand:SI 4 "gpc_reg_operand" "r"))
8490 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8491 (match_operand:SI 5 "gpc_reg_operand" "r"))
8492 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
8493 (match_operand:SI 6 "gpc_reg_operand" "r"))])]
8494 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 5"
8495 "{stsi|stswi} %2,%1,%O0"
8496 [(set_attr "type" "store_ux")])
8497
8498 (define_insn "*stmsi3"
8499 [(match_parallel 0 "store_multiple_operation"
8500 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8501 (match_operand:SI 2 "gpc_reg_operand" "r"))
8502 (clobber (match_scratch:SI 3 "X"))
8503 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
8504 (match_operand:SI 4 "gpc_reg_operand" "r"))
8505 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
8506 (match_operand:SI 5 "gpc_reg_operand" "r"))])]
8507 "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 4"
8508 "{stsi|stswi} %2,%1,%O0"
8509 [(set_attr "type" "store_ux")])
8510 \f
8511 (define_expand "setmemsi"
8512 [(parallel [(set (match_operand:BLK 0 "" "")
8513 (match_operand 2 "const_int_operand" ""))
8514 (use (match_operand:SI 1 "" ""))
8515 (use (match_operand:SI 3 "" ""))])]
8516 ""
8517 "
8518 {
8519 /* If value to set is not zero, use the library routine. */
8520 if (operands[2] != const0_rtx)
8521 FAIL;
8522
8523 if (expand_block_clear (operands))
8524 DONE;
8525 else
8526 FAIL;
8527 }")
8528
8529 ;; String/block move insn.
8530 ;; Argument 0 is the destination
8531 ;; Argument 1 is the source
8532 ;; Argument 2 is the length
8533 ;; Argument 3 is the alignment
8534
8535 (define_expand "movmemsi"
8536 [(parallel [(set (match_operand:BLK 0 "" "")
8537 (match_operand:BLK 1 "" ""))
8538 (use (match_operand:SI 2 "" ""))
8539 (use (match_operand:SI 3 "" ""))])]
8540 ""
8541 "
8542 {
8543 if (expand_block_move (operands))
8544 DONE;
8545 else
8546 FAIL;
8547 }")
8548
8549 ;; Move up to 32 bytes at a time. The fixed registers are needed because the
8550 ;; register allocator doesn't have a clue about allocating 8 word registers.
8551 ;; rD/rS = r5 is preferred, efficient form.
8552 (define_expand "movmemsi_8reg"
8553 [(parallel [(set (match_operand 0 "" "")
8554 (match_operand 1 "" ""))
8555 (use (match_operand 2 "" ""))
8556 (use (match_operand 3 "" ""))
8557 (clobber (reg:SI 5))
8558 (clobber (reg:SI 6))
8559 (clobber (reg:SI 7))
8560 (clobber (reg:SI 8))
8561 (clobber (reg:SI 9))
8562 (clobber (reg:SI 10))
8563 (clobber (reg:SI 11))
8564 (clobber (reg:SI 12))
8565 (clobber (match_scratch:SI 4 ""))])]
8566 "TARGET_STRING"
8567 "")
8568
8569 (define_insn ""
8570 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8571 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8572 (use (match_operand:SI 2 "immediate_operand" "i"))
8573 (use (match_operand:SI 3 "immediate_operand" "i"))
8574 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8575 (clobber (reg:SI 6))
8576 (clobber (reg:SI 7))
8577 (clobber (reg:SI 8))
8578 (clobber (reg:SI 9))
8579 (clobber (reg:SI 10))
8580 (clobber (reg:SI 11))
8581 (clobber (reg:SI 12))
8582 (clobber (match_scratch:SI 5 "=q"))]
8583 "TARGET_STRING && TARGET_POWER
8584 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
8585 || INTVAL (operands[2]) == 0)
8586 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
8587 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
8588 && REGNO (operands[4]) == 5"
8589 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8590 [(set_attr "type" "store_ux")
8591 (set_attr "length" "8")])
8592
8593 (define_insn ""
8594 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
8595 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
8596 (use (match_operand:SI 2 "immediate_operand" "i"))
8597 (use (match_operand:SI 3 "immediate_operand" "i"))
8598 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8599 (clobber (reg:SI 6))
8600 (clobber (reg:SI 7))
8601 (clobber (reg:SI 8))
8602 (clobber (reg:SI 9))
8603 (clobber (reg:SI 10))
8604 (clobber (reg:SI 11))
8605 (clobber (reg:SI 12))
8606 (clobber (match_scratch:SI 5 "X"))]
8607 "TARGET_STRING && ! TARGET_POWER
8608 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
8609 || INTVAL (operands[2]) == 0)
8610 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
8611 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
8612 && REGNO (operands[4]) == 5"
8613 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8614 [(set_attr "type" "store_ux")
8615 (set_attr "length" "8")])
8616
8617 ;; Move up to 24 bytes at a time. The fixed registers are needed because the
8618 ;; register allocator doesn't have a clue about allocating 6 word registers.
8619 ;; rD/rS = r5 is preferred, efficient form.
8620 (define_expand "movmemsi_6reg"
8621 [(parallel [(set (match_operand 0 "" "")
8622 (match_operand 1 "" ""))
8623 (use (match_operand 2 "" ""))
8624 (use (match_operand 3 "" ""))
8625 (clobber (reg:SI 5))
8626 (clobber (reg:SI 6))
8627 (clobber (reg:SI 7))
8628 (clobber (reg:SI 8))
8629 (clobber (reg:SI 9))
8630 (clobber (reg:SI 10))
8631 (clobber (match_scratch:SI 4 ""))])]
8632 "TARGET_STRING"
8633 "")
8634
8635 (define_insn ""
8636 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8637 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8638 (use (match_operand:SI 2 "immediate_operand" "i"))
8639 (use (match_operand:SI 3 "immediate_operand" "i"))
8640 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8641 (clobber (reg:SI 6))
8642 (clobber (reg:SI 7))
8643 (clobber (reg:SI 8))
8644 (clobber (reg:SI 9))
8645 (clobber (reg:SI 10))
8646 (clobber (match_scratch:SI 5 "=q"))]
8647 "TARGET_STRING && TARGET_POWER
8648 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
8649 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
8650 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
8651 && REGNO (operands[4]) == 5"
8652 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8653 [(set_attr "type" "store_ux")
8654 (set_attr "length" "8")])
8655
8656 (define_insn ""
8657 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
8658 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
8659 (use (match_operand:SI 2 "immediate_operand" "i"))
8660 (use (match_operand:SI 3 "immediate_operand" "i"))
8661 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8662 (clobber (reg:SI 6))
8663 (clobber (reg:SI 7))
8664 (clobber (reg:SI 8))
8665 (clobber (reg:SI 9))
8666 (clobber (reg:SI 10))
8667 (clobber (match_scratch:SI 5 "X"))]
8668 "TARGET_STRING && ! TARGET_POWER
8669 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
8670 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
8671 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
8672 && REGNO (operands[4]) == 5"
8673 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8674 [(set_attr "type" "store_ux")
8675 (set_attr "length" "8")])
8676
8677 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
8678 ;; problems with TImode.
8679 ;; rD/rS = r5 is preferred, efficient form.
8680 (define_expand "movmemsi_4reg"
8681 [(parallel [(set (match_operand 0 "" "")
8682 (match_operand 1 "" ""))
8683 (use (match_operand 2 "" ""))
8684 (use (match_operand 3 "" ""))
8685 (clobber (reg:SI 5))
8686 (clobber (reg:SI 6))
8687 (clobber (reg:SI 7))
8688 (clobber (reg:SI 8))
8689 (clobber (match_scratch:SI 4 ""))])]
8690 "TARGET_STRING"
8691 "")
8692
8693 (define_insn ""
8694 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8695 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8696 (use (match_operand:SI 2 "immediate_operand" "i"))
8697 (use (match_operand:SI 3 "immediate_operand" "i"))
8698 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8699 (clobber (reg:SI 6))
8700 (clobber (reg:SI 7))
8701 (clobber (reg:SI 8))
8702 (clobber (match_scratch:SI 5 "=q"))]
8703 "TARGET_STRING && TARGET_POWER
8704 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
8705 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
8706 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
8707 && REGNO (operands[4]) == 5"
8708 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8709 [(set_attr "type" "store_ux")
8710 (set_attr "length" "8")])
8711
8712 (define_insn ""
8713 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
8714 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
8715 (use (match_operand:SI 2 "immediate_operand" "i"))
8716 (use (match_operand:SI 3 "immediate_operand" "i"))
8717 (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8718 (clobber (reg:SI 6))
8719 (clobber (reg:SI 7))
8720 (clobber (reg:SI 8))
8721 (clobber (match_scratch:SI 5 "X"))]
8722 "TARGET_STRING && ! TARGET_POWER
8723 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
8724 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
8725 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
8726 && REGNO (operands[4]) == 5"
8727 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8728 [(set_attr "type" "store_ux")
8729 (set_attr "length" "8")])
8730
8731 ;; Move up to 8 bytes at a time.
8732 (define_expand "movmemsi_2reg"
8733 [(parallel [(set (match_operand 0 "" "")
8734 (match_operand 1 "" ""))
8735 (use (match_operand 2 "" ""))
8736 (use (match_operand 3 "" ""))
8737 (clobber (match_scratch:DI 4 ""))
8738 (clobber (match_scratch:SI 5 ""))])]
8739 "TARGET_STRING && ! TARGET_POWERPC64"
8740 "")
8741
8742 (define_insn ""
8743 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8744 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8745 (use (match_operand:SI 2 "immediate_operand" "i"))
8746 (use (match_operand:SI 3 "immediate_operand" "i"))
8747 (clobber (match_scratch:DI 4 "=&r"))
8748 (clobber (match_scratch:SI 5 "=q"))]
8749 "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
8750 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
8751 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8752 [(set_attr "type" "store_ux")
8753 (set_attr "length" "8")])
8754
8755 (define_insn ""
8756 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8757 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8758 (use (match_operand:SI 2 "immediate_operand" "i"))
8759 (use (match_operand:SI 3 "immediate_operand" "i"))
8760 (clobber (match_scratch:DI 4 "=&r"))
8761 (clobber (match_scratch:SI 5 "X"))]
8762 "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
8763 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
8764 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8765 [(set_attr "type" "store_ux")
8766 (set_attr "length" "8")])
8767
8768 ;; Move up to 4 bytes at a time.
8769 (define_expand "movmemsi_1reg"
8770 [(parallel [(set (match_operand 0 "" "")
8771 (match_operand 1 "" ""))
8772 (use (match_operand 2 "" ""))
8773 (use (match_operand 3 "" ""))
8774 (clobber (match_scratch:SI 4 ""))
8775 (clobber (match_scratch:SI 5 ""))])]
8776 "TARGET_STRING"
8777 "")
8778
8779 (define_insn ""
8780 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8781 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8782 (use (match_operand:SI 2 "immediate_operand" "i"))
8783 (use (match_operand:SI 3 "immediate_operand" "i"))
8784 (clobber (match_scratch:SI 4 "=&r"))
8785 (clobber (match_scratch:SI 5 "=q"))]
8786 "TARGET_STRING && TARGET_POWER
8787 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
8788 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8789 [(set_attr "type" "store_ux")
8790 (set_attr "length" "8")])
8791
8792 (define_insn ""
8793 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
8794 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
8795 (use (match_operand:SI 2 "immediate_operand" "i"))
8796 (use (match_operand:SI 3 "immediate_operand" "i"))
8797 (clobber (match_scratch:SI 4 "=&r"))
8798 (clobber (match_scratch:SI 5 "X"))]
8799 "TARGET_STRING && ! TARGET_POWER
8800 && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
8801 "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8802 [(set_attr "type" "store_ux")
8803 (set_attr "length" "8")])
8804 \f
8805 ;; Define insns that do load or store with update. Some of these we can
8806 ;; get by using pre-decrement or pre-increment, but the hardware can also
8807 ;; do cases where the increment is not the size of the object.
8808 ;;
8809 ;; In all these cases, we use operands 0 and 1 for the register being
8810 ;; incremented because those are the operands that local-alloc will
8811 ;; tie and these are the pair most likely to be tieable (and the ones
8812 ;; that will benefit the most).
8813
8814 (define_insn "*movdi_update1"
8815 [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
8816 (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
8817 (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
8818 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
8819 (plus:DI (match_dup 1) (match_dup 2)))]
8820 "TARGET_POWERPC64 && TARGET_UPDATE"
8821 "@
8822 ldux %3,%0,%2
8823 ldu %3,%2(%0)"
8824 [(set_attr "type" "load_ux,load_u")])
8825
8826 (define_insn "movdi_<mode>_update"
8827 [(set (mem:DI (plus:P (match_operand:P 1 "gpc_reg_operand" "0,0")
8828 (match_operand:P 2 "reg_or_aligned_short_operand" "r,I")))
8829 (match_operand:DI 3 "gpc_reg_operand" "r,r"))
8830 (set (match_operand:P 0 "gpc_reg_operand" "=b,b")
8831 (plus:P (match_dup 1) (match_dup 2)))]
8832 "TARGET_POWERPC64 && TARGET_UPDATE"
8833 "@
8834 stdux %3,%0,%2
8835 stdu %3,%2(%0)"
8836 [(set_attr "type" "store_ux,store_u")])
8837
8838 (define_insn "*movsi_update1"
8839 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
8840 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8841 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
8842 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8843 (plus:SI (match_dup 1) (match_dup 2)))]
8844 "TARGET_UPDATE"
8845 "@
8846 {lux|lwzux} %3,%0,%2
8847 {lu|lwzu} %3,%2(%0)"
8848 [(set_attr "type" "load_ux,load_u")])
8849
8850 (define_insn "*movsi_update2"
8851 [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
8852 (sign_extend:DI
8853 (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
8854 (match_operand:DI 2 "gpc_reg_operand" "r")))))
8855 (set (match_operand:DI 0 "gpc_reg_operand" "=b")
8856 (plus:DI (match_dup 1) (match_dup 2)))]
8857 "TARGET_POWERPC64"
8858 "lwaux %3,%0,%2"
8859 [(set_attr "type" "load_ext_ux")])
8860
8861 (define_insn "movsi_update"
8862 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8863 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
8864 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
8865 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8866 (plus:SI (match_dup 1) (match_dup 2)))]
8867 "TARGET_UPDATE"
8868 "@
8869 {stux|stwux} %3,%0,%2
8870 {stu|stwu} %3,%2(%0)"
8871 [(set_attr "type" "store_ux,store_u")])
8872
8873 (define_insn "*movhi_update1"
8874 [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
8875 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8876 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
8877 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8878 (plus:SI (match_dup 1) (match_dup 2)))]
8879 "TARGET_UPDATE"
8880 "@
8881 lhzux %3,%0,%2
8882 lhzu %3,%2(%0)"
8883 [(set_attr "type" "load_ux,load_u")])
8884
8885 (define_insn "*movhi_update2"
8886 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
8887 (zero_extend:SI
8888 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8889 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
8890 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8891 (plus:SI (match_dup 1) (match_dup 2)))]
8892 "TARGET_UPDATE"
8893 "@
8894 lhzux %3,%0,%2
8895 lhzu %3,%2(%0)"
8896 [(set_attr "type" "load_ux,load_u")])
8897
8898 (define_insn "*movhi_update3"
8899 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
8900 (sign_extend:SI
8901 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8902 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
8903 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8904 (plus:SI (match_dup 1) (match_dup 2)))]
8905 "TARGET_UPDATE"
8906 "@
8907 lhaux %3,%0,%2
8908 lhau %3,%2(%0)"
8909 [(set_attr "type" "load_ext_ux,load_ext_u")])
8910
8911 (define_insn "*movhi_update4"
8912 [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8913 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
8914 (match_operand:HI 3 "gpc_reg_operand" "r,r"))
8915 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8916 (plus:SI (match_dup 1) (match_dup 2)))]
8917 "TARGET_UPDATE"
8918 "@
8919 sthux %3,%0,%2
8920 sthu %3,%2(%0)"
8921 [(set_attr "type" "store_ux,store_u")])
8922
8923 (define_insn "*movqi_update1"
8924 [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
8925 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8926 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
8927 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8928 (plus:SI (match_dup 1) (match_dup 2)))]
8929 "TARGET_UPDATE"
8930 "@
8931 lbzux %3,%0,%2
8932 lbzu %3,%2(%0)"
8933 [(set_attr "type" "load_ux,load_u")])
8934
8935 (define_insn "*movqi_update2"
8936 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
8937 (zero_extend:SI
8938 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8939 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
8940 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8941 (plus:SI (match_dup 1) (match_dup 2)))]
8942 "TARGET_UPDATE"
8943 "@
8944 lbzux %3,%0,%2
8945 lbzu %3,%2(%0)"
8946 [(set_attr "type" "load_ux,load_u")])
8947
8948 (define_insn "*movqi_update3"
8949 [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8950 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
8951 (match_operand:QI 3 "gpc_reg_operand" "r,r"))
8952 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8953 (plus:SI (match_dup 1) (match_dup 2)))]
8954 "TARGET_UPDATE"
8955 "@
8956 stbux %3,%0,%2
8957 stbu %3,%2(%0)"
8958 [(set_attr "type" "store_ux,store_u")])
8959
8960 (define_insn "*movsf_update1"
8961 [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
8962 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8963 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
8964 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8965 (plus:SI (match_dup 1) (match_dup 2)))]
8966 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
8967 "@
8968 lfsux %3,%0,%2
8969 lfsu %3,%2(%0)"
8970 [(set_attr "type" "fpload_ux,fpload_u")])
8971
8972 (define_insn "*movsf_update2"
8973 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8974 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
8975 (match_operand:SF 3 "gpc_reg_operand" "f,f"))
8976 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8977 (plus:SI (match_dup 1) (match_dup 2)))]
8978 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
8979 "@
8980 stfsux %3,%0,%2
8981 stfsu %3,%2(%0)"
8982 [(set_attr "type" "fpstore_ux,fpstore_u")])
8983
8984 (define_insn "*movsf_update3"
8985 [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
8986 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8987 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
8988 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
8989 (plus:SI (match_dup 1) (match_dup 2)))]
8990 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
8991 "@
8992 {lux|lwzux} %3,%0,%2
8993 {lu|lwzu} %3,%2(%0)"
8994 [(set_attr "type" "load_ux,load_u")])
8995
8996 (define_insn "*movsf_update4"
8997 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
8998 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
8999 (match_operand:SF 3 "gpc_reg_operand" "r,r"))
9000 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9001 (plus:SI (match_dup 1) (match_dup 2)))]
9002 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
9003 "@
9004 {stux|stwux} %3,%0,%2
9005 {stu|stwu} %3,%2(%0)"
9006 [(set_attr "type" "store_ux,store_u")])
9007
9008 (define_insn "*movdf_update1"
9009 [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
9010 (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9011 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9012 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9013 (plus:SI (match_dup 1) (match_dup 2)))]
9014 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9015 "@
9016 lfdux %3,%0,%2
9017 lfdu %3,%2(%0)"
9018 [(set_attr "type" "fpload_ux,fpload_u")])
9019
9020 (define_insn "*movdf_update2"
9021 [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9022 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9023 (match_operand:DF 3 "gpc_reg_operand" "f,f"))
9024 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9025 (plus:SI (match_dup 1) (match_dup 2)))]
9026 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9027 "@
9028 stfdux %3,%0,%2
9029 stfdu %3,%2(%0)"
9030 [(set_attr "type" "fpstore_ux,fpstore_u")])
9031
9032 ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
9033
9034 (define_insn "*lfq_power2"
9035 [(set (match_operand:V2DF 0 "gpc_reg_operand" "=f")
9036 (match_operand:V2DF 1 "memory_operand" ""))]
9037 "TARGET_POWER2
9038 && TARGET_HARD_FLOAT && TARGET_FPRS"
9039 "lfq%U1%X1 %0,%1")
9040
9041 (define_peephole2
9042 [(set (match_operand:DF 0 "gpc_reg_operand" "")
9043 (match_operand:DF 1 "memory_operand" ""))
9044 (set (match_operand:DF 2 "gpc_reg_operand" "")
9045 (match_operand:DF 3 "memory_operand" ""))]
9046 "TARGET_POWER2
9047 && TARGET_HARD_FLOAT && TARGET_FPRS
9048 && registers_ok_for_quad_peep (operands[0], operands[2])
9049 && mems_ok_for_quad_peep (operands[1], operands[3])"
9050 [(set (match_dup 0)
9051 (match_dup 1))]
9052 "operands[1] = widen_memory_access (operands[1], V2DFmode, 0);
9053 operands[0] = gen_rtx_REG (V2DFmode, REGNO (operands[0]));")
9054
9055 (define_insn "*stfq_power2"
9056 [(set (match_operand:V2DF 0 "memory_operand" "")
9057 (match_operand:V2DF 1 "gpc_reg_operand" "f"))]
9058 "TARGET_POWER2
9059 && TARGET_HARD_FLOAT && TARGET_FPRS"
9060 "stfq%U0%X0 %1,%0")
9061
9062
9063 (define_peephole2
9064 [(set (match_operand:DF 0 "memory_operand" "")
9065 (match_operand:DF 1 "gpc_reg_operand" ""))
9066 (set (match_operand:DF 2 "memory_operand" "")
9067 (match_operand:DF 3 "gpc_reg_operand" ""))]
9068 "TARGET_POWER2
9069 && TARGET_HARD_FLOAT && TARGET_FPRS
9070 && registers_ok_for_quad_peep (operands[1], operands[3])
9071 && mems_ok_for_quad_peep (operands[0], operands[2])"
9072 [(set (match_dup 0)
9073 (match_dup 1))]
9074 "operands[0] = widen_memory_access (operands[0], V2DFmode, 0);
9075 operands[1] = gen_rtx_REG (V2DFmode, REGNO (operands[1]));")
9076
9077 ;; after inserting conditional returns we can sometimes have
9078 ;; unnecessary register moves. Unfortunately we cannot have a
9079 ;; modeless peephole here, because some single SImode sets have early
9080 ;; clobber outputs. Although those sets expand to multi-ppc-insn
9081 ;; sequences, using get_attr_length here will smash the operands
9082 ;; array. Neither is there an early_cobbler_p predicate.
9083 (define_peephole2
9084 [(set (match_operand:DF 0 "gpc_reg_operand" "")
9085 (match_operand:DF 1 "any_operand" ""))
9086 (set (match_operand:DF 2 "gpc_reg_operand" "")
9087 (match_dup 0))]
9088 "peep2_reg_dead_p (2, operands[0])"
9089 [(set (match_dup 2) (match_dup 1))])
9090
9091 (define_peephole2
9092 [(set (match_operand:SF 0 "gpc_reg_operand" "")
9093 (match_operand:SF 1 "any_operand" ""))
9094 (set (match_operand:SF 2 "gpc_reg_operand" "")
9095 (match_dup 0))]
9096 "peep2_reg_dead_p (2, operands[0])"
9097 [(set (match_dup 2) (match_dup 1))])
9098
9099 \f
9100 ;; TLS support.
9101
9102 ;; "b" output constraint here and on tls_ld to support tls linker optimization.
9103 (define_insn "tls_gd_32"
9104 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9105 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9106 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9107 UNSPEC_TLSGD))]
9108 "HAVE_AS_TLS && !TARGET_64BIT"
9109 "addi %0,%1,%2@got@tlsgd")
9110
9111 (define_insn "tls_gd_64"
9112 [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
9113 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9114 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9115 UNSPEC_TLSGD))]
9116 "HAVE_AS_TLS && TARGET_64BIT"
9117 "addi %0,%1,%2@got@tlsgd")
9118
9119 (define_insn "tls_ld_32"
9120 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9121 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")]
9122 UNSPEC_TLSLD))]
9123 "HAVE_AS_TLS && !TARGET_64BIT"
9124 "addi %0,%1,%&@got@tlsld")
9125
9126 (define_insn "tls_ld_64"
9127 [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
9128 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")]
9129 UNSPEC_TLSLD))]
9130 "HAVE_AS_TLS && TARGET_64BIT"
9131 "addi %0,%1,%&@got@tlsld")
9132
9133 (define_insn "tls_dtprel_32"
9134 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9135 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9136 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9137 UNSPEC_TLSDTPREL))]
9138 "HAVE_AS_TLS && !TARGET_64BIT"
9139 "addi %0,%1,%2@dtprel")
9140
9141 (define_insn "tls_dtprel_64"
9142 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9143 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9144 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9145 UNSPEC_TLSDTPREL))]
9146 "HAVE_AS_TLS && TARGET_64BIT"
9147 "addi %0,%1,%2@dtprel")
9148
9149 (define_insn "tls_dtprel_ha_32"
9150 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9151 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9152 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9153 UNSPEC_TLSDTPRELHA))]
9154 "HAVE_AS_TLS && !TARGET_64BIT"
9155 "addis %0,%1,%2@dtprel@ha")
9156
9157 (define_insn "tls_dtprel_ha_64"
9158 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9159 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9160 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9161 UNSPEC_TLSDTPRELHA))]
9162 "HAVE_AS_TLS && TARGET_64BIT"
9163 "addis %0,%1,%2@dtprel@ha")
9164
9165 (define_insn "tls_dtprel_lo_32"
9166 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9167 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9168 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9169 UNSPEC_TLSDTPRELLO))]
9170 "HAVE_AS_TLS && !TARGET_64BIT"
9171 "addi %0,%1,%2@dtprel@l")
9172
9173 (define_insn "tls_dtprel_lo_64"
9174 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9175 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9176 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9177 UNSPEC_TLSDTPRELLO))]
9178 "HAVE_AS_TLS && TARGET_64BIT"
9179 "addi %0,%1,%2@dtprel@l")
9180
9181 (define_insn "tls_got_dtprel_32"
9182 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9183 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9184 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9185 UNSPEC_TLSGOTDTPREL))]
9186 "HAVE_AS_TLS && !TARGET_64BIT"
9187 "lwz %0,%2@got@dtprel(%1)")
9188
9189 (define_insn "tls_got_dtprel_64"
9190 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9191 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9192 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9193 UNSPEC_TLSGOTDTPREL))]
9194 "HAVE_AS_TLS && TARGET_64BIT"
9195 "ld %0,%2@got@dtprel(%1)")
9196
9197 (define_insn "tls_tprel_32"
9198 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9199 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9200 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9201 UNSPEC_TLSTPREL))]
9202 "HAVE_AS_TLS && !TARGET_64BIT"
9203 "addi %0,%1,%2@tprel")
9204
9205 (define_insn "tls_tprel_64"
9206 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9207 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9208 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9209 UNSPEC_TLSTPREL))]
9210 "HAVE_AS_TLS && TARGET_64BIT"
9211 "addi %0,%1,%2@tprel")
9212
9213 (define_insn "tls_tprel_ha_32"
9214 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9215 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9216 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9217 UNSPEC_TLSTPRELHA))]
9218 "HAVE_AS_TLS && !TARGET_64BIT"
9219 "addis %0,%1,%2@tprel@ha")
9220
9221 (define_insn "tls_tprel_ha_64"
9222 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9223 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9224 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9225 UNSPEC_TLSTPRELHA))]
9226 "HAVE_AS_TLS && TARGET_64BIT"
9227 "addis %0,%1,%2@tprel@ha")
9228
9229 (define_insn "tls_tprel_lo_32"
9230 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9231 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9232 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9233 UNSPEC_TLSTPRELLO))]
9234 "HAVE_AS_TLS && !TARGET_64BIT"
9235 "addi %0,%1,%2@tprel@l")
9236
9237 (define_insn "tls_tprel_lo_64"
9238 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9239 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9240 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9241 UNSPEC_TLSTPRELLO))]
9242 "HAVE_AS_TLS && TARGET_64BIT"
9243 "addi %0,%1,%2@tprel@l")
9244
9245 ;; "b" output constraint here and on tls_tls input to support linker tls
9246 ;; optimization. The linker may edit the instructions emitted by a
9247 ;; tls_got_tprel/tls_tls pair to addis,addi.
9248 (define_insn "tls_got_tprel_32"
9249 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9250 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9251 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9252 UNSPEC_TLSGOTTPREL))]
9253 "HAVE_AS_TLS && !TARGET_64BIT"
9254 "lwz %0,%2@got@tprel(%1)")
9255
9256 (define_insn "tls_got_tprel_64"
9257 [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
9258 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9259 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9260 UNSPEC_TLSGOTTPREL))]
9261 "HAVE_AS_TLS && TARGET_64BIT"
9262 "ld %0,%2@got@tprel(%1)")
9263
9264 (define_insn "tls_tls_32"
9265 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9266 (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9267 (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9268 UNSPEC_TLSTLS))]
9269 "HAVE_AS_TLS && !TARGET_64BIT"
9270 "add %0,%1,%2@tls")
9271
9272 (define_insn "tls_tls_64"
9273 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9274 (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9275 (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9276 UNSPEC_TLSTLS))]
9277 "HAVE_AS_TLS && TARGET_64BIT"
9278 "add %0,%1,%2@tls")
9279 \f
9280 ;; Next come insns related to the calling sequence.
9281 ;;
9282 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
9283 ;; We move the back-chain and decrement the stack pointer.
9284
9285 (define_expand "allocate_stack"
9286 [(set (match_operand 0 "gpc_reg_operand" "=r")
9287 (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
9288 (set (reg 1)
9289 (minus (reg 1) (match_dup 1)))]
9290 ""
9291 "
9292 { rtx chain = gen_reg_rtx (Pmode);
9293 rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
9294 rtx neg_op0;
9295
9296 emit_move_insn (chain, stack_bot);
9297
9298 /* Check stack bounds if necessary. */
9299 if (current_function_limit_stack)
9300 {
9301 rtx available;
9302 available = expand_binop (Pmode, sub_optab,
9303 stack_pointer_rtx, stack_limit_rtx,
9304 NULL_RTX, 1, OPTAB_WIDEN);
9305 emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
9306 }
9307
9308 if (GET_CODE (operands[1]) != CONST_INT
9309 || INTVAL (operands[1]) < -32767
9310 || INTVAL (operands[1]) > 32768)
9311 {
9312 neg_op0 = gen_reg_rtx (Pmode);
9313 if (TARGET_32BIT)
9314 emit_insn (gen_negsi2 (neg_op0, operands[1]));
9315 else
9316 emit_insn (gen_negdi2 (neg_op0, operands[1]));
9317 }
9318 else
9319 neg_op0 = GEN_INT (- INTVAL (operands[1]));
9320
9321 if (TARGET_UPDATE)
9322 emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_di_update))
9323 (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
9324
9325 else
9326 {
9327 emit_insn ((* ((TARGET_32BIT) ? gen_addsi3 : gen_adddi3))
9328 (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
9329 emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), chain);
9330 }
9331
9332 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9333 DONE;
9334 }")
9335
9336 ;; These patterns say how to save and restore the stack pointer. We need not
9337 ;; save the stack pointer at function level since we are careful to
9338 ;; preserve the backchain. At block level, we have to restore the backchain
9339 ;; when we restore the stack pointer.
9340 ;;
9341 ;; For nonlocal gotos, we must save both the stack pointer and its
9342 ;; backchain and restore both. Note that in the nonlocal case, the
9343 ;; save area is a memory location.
9344
9345 (define_expand "save_stack_function"
9346 [(match_operand 0 "any_operand" "")
9347 (match_operand 1 "any_operand" "")]
9348 ""
9349 "DONE;")
9350
9351 (define_expand "restore_stack_function"
9352 [(match_operand 0 "any_operand" "")
9353 (match_operand 1 "any_operand" "")]
9354 ""
9355 "DONE;")
9356
9357 ;; Adjust stack pointer (op0) to a new value (op1).
9358 ;; First copy old stack backchain to new location, and ensure that the
9359 ;; scheduler won't reorder the sp assignment before the backchain write.
9360 (define_expand "restore_stack_block"
9361 [(set (match_dup 2) (match_dup 3))
9362 (set (match_dup 4) (match_dup 2))
9363 (set (match_dup 5) (unspec:BLK [(match_dup 5)] UNSPEC_TIE))
9364 (set (match_operand 0 "register_operand" "")
9365 (match_operand 1 "register_operand" ""))]
9366 ""
9367 "
9368 {
9369 operands[2] = gen_reg_rtx (Pmode);
9370 operands[3] = gen_frame_mem (Pmode, operands[0]);
9371 operands[4] = gen_frame_mem (Pmode, operands[1]);
9372 operands[5] = gen_frame_mem (BLKmode, operands[0]);
9373 }")
9374
9375 (define_expand "save_stack_nonlocal"
9376 [(set (match_dup 3) (match_dup 4))
9377 (set (match_operand 0 "memory_operand" "") (match_dup 3))
9378 (set (match_dup 2) (match_operand 1 "register_operand" ""))]
9379 ""
9380 "
9381 {
9382 int units_per_word = (TARGET_32BIT) ? 4 : 8;
9383
9384 /* Copy the backchain to the first word, sp to the second. */
9385 operands[0] = adjust_address_nv (operands[0], Pmode, 0);
9386 operands[2] = adjust_address_nv (operands[0], Pmode, units_per_word);
9387 operands[3] = gen_reg_rtx (Pmode);
9388 operands[4] = gen_frame_mem (Pmode, operands[1]);
9389 }")
9390
9391 (define_expand "restore_stack_nonlocal"
9392 [(set (match_dup 2) (match_operand 1 "memory_operand" ""))
9393 (set (match_dup 3) (match_dup 4))
9394 (set (match_dup 5) (match_dup 2))
9395 (set (match_dup 6) (unspec:BLK [(match_dup 6)] UNSPEC_TIE))
9396 (set (match_operand 0 "register_operand" "") (match_dup 3))]
9397 ""
9398 "
9399 {
9400 int units_per_word = (TARGET_32BIT) ? 4 : 8;
9401
9402 /* Restore the backchain from the first word, sp from the second. */
9403 operands[2] = gen_reg_rtx (Pmode);
9404 operands[3] = gen_reg_rtx (Pmode);
9405 operands[1] = adjust_address_nv (operands[1], Pmode, 0);
9406 operands[4] = adjust_address_nv (operands[1], Pmode, units_per_word);
9407 operands[5] = gen_frame_mem (Pmode, operands[3]);
9408 operands[6] = gen_frame_mem (BLKmode, operands[0]);
9409 }")
9410 \f
9411 ;; TOC register handling.
9412
9413 ;; Code to initialize the TOC register...
9414
9415 (define_insn "load_toc_aix_si"
9416 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9417 (unspec:SI [(const_int 0)] UNSPEC_TOC))
9418 (use (reg:SI 2))])]
9419 "DEFAULT_ABI == ABI_AIX && TARGET_32BIT"
9420 "*
9421 {
9422 char buf[30];
9423 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
9424 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9425 operands[2] = gen_rtx_REG (Pmode, 2);
9426 return \"{l|lwz} %0,%1(%2)\";
9427 }"
9428 [(set_attr "type" "load")])
9429
9430 (define_insn "load_toc_aix_di"
9431 [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9432 (unspec:DI [(const_int 0)] UNSPEC_TOC))
9433 (use (reg:DI 2))])]
9434 "DEFAULT_ABI == ABI_AIX && TARGET_64BIT"
9435 "*
9436 {
9437 char buf[30];
9438 #ifdef TARGET_RELOCATABLE
9439 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
9440 !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
9441 #else
9442 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
9443 #endif
9444 if (TARGET_ELF)
9445 strcat (buf, \"@toc\");
9446 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9447 operands[2] = gen_rtx_REG (Pmode, 2);
9448 return \"ld %0,%1(%2)\";
9449 }"
9450 [(set_attr "type" "load")])
9451
9452 (define_insn "load_toc_v4_pic_si"
9453 [(set (match_operand:SI 0 "register_operand" "=l")
9454 (unspec:SI [(const_int 0)] UNSPEC_TOC))]
9455 "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
9456 "bl _GLOBAL_OFFSET_TABLE_@local-4"
9457 [(set_attr "type" "branch")
9458 (set_attr "length" "4")])
9459
9460 (define_insn "load_toc_v4_PIC_1"
9461 [(set (match_operand:SI 0 "register_operand" "=l")
9462 (match_operand:SI 1 "immediate_operand" "s"))
9463 (use (unspec [(match_dup 1)] UNSPEC_TOC))]
9464 "TARGET_ELF && DEFAULT_ABI != ABI_AIX
9465 && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
9466 "bcl 20,31,%1\\n%1:"
9467 [(set_attr "type" "branch")
9468 (set_attr "length" "4")])
9469
9470 (define_insn "load_toc_v4_PIC_1b"
9471 [(set (match_operand:SI 0 "register_operand" "=l")
9472 (unspec:SI [(match_operand:SI 1 "immediate_operand" "s")]
9473 UNSPEC_TOCPTR))]
9474 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
9475 "bcl 20,31,$+8\\n\\t.long %1-$"
9476 [(set_attr "type" "branch")
9477 (set_attr "length" "8")])
9478
9479 (define_insn "load_toc_v4_PIC_2"
9480 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9481 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
9482 (minus:SI (match_operand:SI 2 "immediate_operand" "s")
9483 (match_operand:SI 3 "immediate_operand" "s")))))]
9484 "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
9485 "{l|lwz} %0,%2-%3(%1)"
9486 [(set_attr "type" "load")])
9487
9488 (define_insn "load_toc_v4_PIC_3b"
9489 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9490 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
9491 (high:SI
9492 (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
9493 (match_operand:SI 3 "symbol_ref_operand" "s")))))]
9494 "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI != ABI_AIX && flag_pic"
9495 "{cau|addis} %0,%1,%2-%3@ha")
9496
9497 (define_insn "load_toc_v4_PIC_3c"
9498 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9499 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
9500 (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
9501 (match_operand:SI 3 "symbol_ref_operand" "s"))))]
9502 "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI != ABI_AIX && flag_pic"
9503 "{cal|addi} %0,%1,%2-%3@l")
9504
9505 ;; If the TOC is shared over a translation unit, as happens with all
9506 ;; the kinds of PIC that we support, we need to restore the TOC
9507 ;; pointer only when jumping over units of translation.
9508 ;; On Darwin, we need to reload the picbase.
9509
9510 (define_expand "builtin_setjmp_receiver"
9511 [(use (label_ref (match_operand 0 "" "")))]
9512 "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
9513 || (TARGET_TOC && TARGET_MINIMAL_TOC)
9514 || (DEFAULT_ABI == ABI_DARWIN && flag_pic)"
9515 "
9516 {
9517 #if TARGET_MACHO
9518 if (DEFAULT_ABI == ABI_DARWIN)
9519 {
9520 const char *picbase = machopic_function_base_name ();
9521 rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (picbase));
9522 rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
9523 rtx tmplabrtx;
9524 char tmplab[20];
9525
9526 ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\",
9527 CODE_LABEL_NUMBER (operands[0]));
9528 tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
9529
9530 emit_insn (gen_load_macho_picbase (picreg, tmplabrtx));
9531 emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
9532 }
9533 else
9534 #endif
9535 rs6000_emit_load_toc_table (FALSE);
9536 DONE;
9537 }")
9538
9539 ;; Elf specific ways of loading addresses for non-PIC code.
9540 ;; The output of this could be r0, but we make a very strong
9541 ;; preference for a base register because it will usually
9542 ;; be needed there.
9543 (define_insn "elf_high"
9544 [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
9545 (high:SI (match_operand 1 "" "")))]
9546 "TARGET_ELF && ! TARGET_64BIT"
9547 "{liu|lis} %0,%1@ha")
9548
9549 (define_insn "elf_low"
9550 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
9551 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
9552 (match_operand 2 "" "")))]
9553 "TARGET_ELF && ! TARGET_64BIT"
9554 "@
9555 {cal|la} %0,%2@l(%1)
9556 {ai|addic} %0,%1,%K2")
9557 \f
9558 ;; A function pointer under AIX is a pointer to a data area whose first word
9559 ;; contains the actual address of the function, whose second word contains a
9560 ;; pointer to its TOC, and whose third word contains a value to place in the
9561 ;; static chain register (r11). Note that if we load the static chain, our
9562 ;; "trampoline" need not have any executable code.
9563
9564 (define_expand "call_indirect_aix32"
9565 [(set (match_dup 2)
9566 (mem:SI (match_operand:SI 0 "gpc_reg_operand" "")))
9567 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
9568 (reg:SI 2))
9569 (set (reg:SI 2)
9570 (mem:SI (plus:SI (match_dup 0)
9571 (const_int 4))))
9572 (set (reg:SI 11)
9573 (mem:SI (plus:SI (match_dup 0)
9574 (const_int 8))))
9575 (parallel [(call (mem:SI (match_dup 2))
9576 (match_operand 1 "" ""))
9577 (use (reg:SI 2))
9578 (use (reg:SI 11))
9579 (set (reg:SI 2)
9580 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9581 (clobber (scratch:SI))])]
9582 "TARGET_32BIT"
9583 "
9584 { operands[2] = gen_reg_rtx (SImode); }")
9585
9586 (define_expand "call_indirect_aix64"
9587 [(set (match_dup 2)
9588 (mem:DI (match_operand:DI 0 "gpc_reg_operand" "")))
9589 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
9590 (reg:DI 2))
9591 (set (reg:DI 2)
9592 (mem:DI (plus:DI (match_dup 0)
9593 (const_int 8))))
9594 (set (reg:DI 11)
9595 (mem:DI (plus:DI (match_dup 0)
9596 (const_int 16))))
9597 (parallel [(call (mem:SI (match_dup 2))
9598 (match_operand 1 "" ""))
9599 (use (reg:DI 2))
9600 (use (reg:DI 11))
9601 (set (reg:DI 2)
9602 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9603 (clobber (scratch:SI))])]
9604 "TARGET_64BIT"
9605 "
9606 { operands[2] = gen_reg_rtx (DImode); }")
9607
9608 (define_expand "call_value_indirect_aix32"
9609 [(set (match_dup 3)
9610 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
9611 (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
9612 (reg:SI 2))
9613 (set (reg:SI 2)
9614 (mem:SI (plus:SI (match_dup 1)
9615 (const_int 4))))
9616 (set (reg:SI 11)
9617 (mem:SI (plus:SI (match_dup 1)
9618 (const_int 8))))
9619 (parallel [(set (match_operand 0 "" "")
9620 (call (mem:SI (match_dup 3))
9621 (match_operand 2 "" "")))
9622 (use (reg:SI 2))
9623 (use (reg:SI 11))
9624 (set (reg:SI 2)
9625 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9626 (clobber (scratch:SI))])]
9627 "TARGET_32BIT"
9628 "
9629 { operands[3] = gen_reg_rtx (SImode); }")
9630
9631 (define_expand "call_value_indirect_aix64"
9632 [(set (match_dup 3)
9633 (mem:DI (match_operand:DI 1 "gpc_reg_operand" "")))
9634 (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
9635 (reg:DI 2))
9636 (set (reg:DI 2)
9637 (mem:DI (plus:DI (match_dup 1)
9638 (const_int 8))))
9639 (set (reg:DI 11)
9640 (mem:DI (plus:DI (match_dup 1)
9641 (const_int 16))))
9642 (parallel [(set (match_operand 0 "" "")
9643 (call (mem:SI (match_dup 3))
9644 (match_operand 2 "" "")))
9645 (use (reg:DI 2))
9646 (use (reg:DI 11))
9647 (set (reg:DI 2)
9648 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9649 (clobber (scratch:SI))])]
9650 "TARGET_64BIT"
9651 "
9652 { operands[3] = gen_reg_rtx (DImode); }")
9653
9654 ;; Now the definitions for the call and call_value insns
9655 (define_expand "call"
9656 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
9657 (match_operand 1 "" ""))
9658 (use (match_operand 2 "" ""))
9659 (clobber (scratch:SI))])]
9660 ""
9661 "
9662 {
9663 #if TARGET_MACHO
9664 if (MACHOPIC_INDIRECT)
9665 operands[0] = machopic_indirect_call_target (operands[0]);
9666 #endif
9667
9668 gcc_assert (GET_CODE (operands[0]) == MEM);
9669 gcc_assert (GET_CODE (operands[1]) == CONST_INT);
9670
9671 operands[0] = XEXP (operands[0], 0);
9672
9673 if (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT
9674 && flag_pic
9675 && GET_CODE (operands[0]) == SYMBOL_REF
9676 && !SYMBOL_REF_LOCAL_P (operands[0]))
9677 {
9678 rtx call;
9679 rtvec tmp;
9680
9681 tmp = gen_rtvec (3,
9682 gen_rtx_CALL (VOIDmode,
9683 gen_rtx_MEM (SImode, operands[0]),
9684 operands[1]),
9685 gen_rtx_USE (VOIDmode, operands[2]),
9686 gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (SImode)));
9687 call = emit_call_insn (gen_rtx_PARALLEL (VOIDmode, tmp));
9688 use_reg (&CALL_INSN_FUNCTION_USAGE (call), pic_offset_table_rtx);
9689 DONE;
9690 }
9691
9692 if (GET_CODE (operands[0]) != SYMBOL_REF
9693 || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[0]))
9694 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[2]) & CALL_LONG) != 0))
9695 {
9696 if (INTVAL (operands[2]) & CALL_LONG)
9697 operands[0] = rs6000_longcall_ref (operands[0]);
9698
9699 switch (DEFAULT_ABI)
9700 {
9701 case ABI_V4:
9702 case ABI_DARWIN:
9703 operands[0] = force_reg (Pmode, operands[0]);
9704 break;
9705
9706 case ABI_AIX:
9707 /* AIX function pointers are really pointers to a three word
9708 area. */
9709 emit_call_insn (TARGET_32BIT
9710 ? gen_call_indirect_aix32 (force_reg (SImode,
9711 operands[0]),
9712 operands[1])
9713 : gen_call_indirect_aix64 (force_reg (DImode,
9714 operands[0]),
9715 operands[1]));
9716 DONE;
9717
9718 default:
9719 gcc_unreachable ();
9720 }
9721 }
9722 }")
9723
9724 (define_expand "call_value"
9725 [(parallel [(set (match_operand 0 "" "")
9726 (call (mem:SI (match_operand 1 "address_operand" ""))
9727 (match_operand 2 "" "")))
9728 (use (match_operand 3 "" ""))
9729 (clobber (scratch:SI))])]
9730 ""
9731 "
9732 {
9733 #if TARGET_MACHO
9734 if (MACHOPIC_INDIRECT)
9735 operands[1] = machopic_indirect_call_target (operands[1]);
9736 #endif
9737
9738 gcc_assert (GET_CODE (operands[1]) == MEM);
9739 gcc_assert (GET_CODE (operands[2]) == CONST_INT);
9740
9741 operands[1] = XEXP (operands[1], 0);
9742
9743 if (DEFAULT_ABI == ABI_V4 && TARGET_SECURE_PLT
9744 && flag_pic
9745 && GET_CODE (operands[1]) == SYMBOL_REF
9746 && !SYMBOL_REF_LOCAL_P (operands[1]))
9747 {
9748 rtx call;
9749 rtvec tmp;
9750
9751 tmp = gen_rtvec (3,
9752 gen_rtx_SET (VOIDmode,
9753 operands[0],
9754 gen_rtx_CALL (VOIDmode,
9755 gen_rtx_MEM (SImode,
9756 operands[1]),
9757 operands[2])),
9758 gen_rtx_USE (VOIDmode, operands[3]),
9759 gen_rtx_CLOBBER (VOIDmode, gen_rtx_SCRATCH (SImode)));
9760 call = emit_call_insn (gen_rtx_PARALLEL (VOIDmode, tmp));
9761 use_reg (&CALL_INSN_FUNCTION_USAGE (call), pic_offset_table_rtx);
9762 DONE;
9763 }
9764
9765 if (GET_CODE (operands[1]) != SYMBOL_REF
9766 || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[1]))
9767 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[3]) & CALL_LONG) != 0))
9768 {
9769 if (INTVAL (operands[3]) & CALL_LONG)
9770 operands[1] = rs6000_longcall_ref (operands[1]);
9771
9772 switch (DEFAULT_ABI)
9773 {
9774 case ABI_V4:
9775 case ABI_DARWIN:
9776 operands[1] = force_reg (Pmode, operands[1]);
9777 break;
9778
9779 case ABI_AIX:
9780 /* AIX function pointers are really pointers to a three word
9781 area. */
9782 emit_call_insn (TARGET_32BIT
9783 ? gen_call_value_indirect_aix32 (operands[0],
9784 force_reg (SImode,
9785 operands[1]),
9786 operands[2])
9787 : gen_call_value_indirect_aix64 (operands[0],
9788 force_reg (DImode,
9789 operands[1]),
9790 operands[2]));
9791 DONE;
9792
9793 default:
9794 gcc_unreachable ();
9795 }
9796 }
9797 }")
9798
9799 ;; Call to function in current module. No TOC pointer reload needed.
9800 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
9801 ;; either the function was not prototyped, or it was prototyped as a
9802 ;; variable argument function. It is > 0 if FP registers were passed
9803 ;; and < 0 if they were not.
9804
9805 (define_insn "*call_local32"
9806 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
9807 (match_operand 1 "" "g,g"))
9808 (use (match_operand:SI 2 "immediate_operand" "O,n"))
9809 (clobber (match_scratch:SI 3 "=l,l"))]
9810 "(INTVAL (operands[2]) & CALL_LONG) == 0"
9811 "*
9812 {
9813 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
9814 output_asm_insn (\"crxor 6,6,6\", operands);
9815
9816 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
9817 output_asm_insn (\"creqv 6,6,6\", operands);
9818
9819 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
9820 }"
9821 [(set_attr "type" "branch")
9822 (set_attr "length" "4,8")])
9823
9824 (define_insn "*call_local64"
9825 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
9826 (match_operand 1 "" "g,g"))
9827 (use (match_operand:SI 2 "immediate_operand" "O,n"))
9828 (clobber (match_scratch:SI 3 "=l,l"))]
9829 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
9830 "*
9831 {
9832 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
9833 output_asm_insn (\"crxor 6,6,6\", operands);
9834
9835 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
9836 output_asm_insn (\"creqv 6,6,6\", operands);
9837
9838 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
9839 }"
9840 [(set_attr "type" "branch")
9841 (set_attr "length" "4,8")])
9842
9843 (define_insn "*call_value_local32"
9844 [(set (match_operand 0 "" "")
9845 (call (mem:SI (match_operand:SI 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 "(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
9864 (define_insn "*call_value_local64"
9865 [(set (match_operand 0 "" "")
9866 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
9867 (match_operand 2 "" "g,g")))
9868 (use (match_operand:SI 3 "immediate_operand" "O,n"))
9869 (clobber (match_scratch:SI 4 "=l,l"))]
9870 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
9871 "*
9872 {
9873 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
9874 output_asm_insn (\"crxor 6,6,6\", operands);
9875
9876 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
9877 output_asm_insn (\"creqv 6,6,6\", operands);
9878
9879 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
9880 }"
9881 [(set_attr "type" "branch")
9882 (set_attr "length" "4,8")])
9883
9884 ;; Call to function which may be in another module. Restore the TOC
9885 ;; pointer (r2) after the call unless this is System V.
9886 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
9887 ;; either the function was not prototyped, or it was prototyped as a
9888 ;; variable argument function. It is > 0 if FP registers were passed
9889 ;; and < 0 if they were not.
9890
9891 (define_insn "*call_indirect_nonlocal_aix32"
9892 [(call (mem:SI (match_operand:SI 0 "register_operand" "c,*l"))
9893 (match_operand 1 "" "g,g"))
9894 (use (reg:SI 2))
9895 (use (reg:SI 11))
9896 (set (reg:SI 2)
9897 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9898 (clobber (match_scratch:SI 2 "=l,l"))]
9899 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
9900 "b%T0l\;{l|lwz} 2,20(1)"
9901 [(set_attr "type" "jmpreg")
9902 (set_attr "length" "8")])
9903
9904 (define_insn "*call_nonlocal_aix32"
9905 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
9906 (match_operand 1 "" "g"))
9907 (use (match_operand:SI 2 "immediate_operand" "O"))
9908 (clobber (match_scratch:SI 3 "=l"))]
9909 "TARGET_32BIT
9910 && DEFAULT_ABI == ABI_AIX
9911 && (INTVAL (operands[2]) & CALL_LONG) == 0"
9912 "bl %z0\;%."
9913 [(set_attr "type" "branch")
9914 (set_attr "length" "8")])
9915
9916 (define_insn "*call_indirect_nonlocal_aix64"
9917 [(call (mem:SI (match_operand:DI 0 "register_operand" "c,*l"))
9918 (match_operand 1 "" "g,g"))
9919 (use (reg:DI 2))
9920 (use (reg:DI 11))
9921 (set (reg:DI 2)
9922 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9923 (clobber (match_scratch:SI 2 "=l,l"))]
9924 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
9925 "b%T0l\;ld 2,40(1)"
9926 [(set_attr "type" "jmpreg")
9927 (set_attr "length" "8")])
9928
9929 (define_insn "*call_nonlocal_aix64"
9930 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
9931 (match_operand 1 "" "g"))
9932 (use (match_operand:SI 2 "immediate_operand" "O"))
9933 (clobber (match_scratch:SI 3 "=l"))]
9934 "TARGET_64BIT
9935 && DEFAULT_ABI == ABI_AIX
9936 && (INTVAL (operands[2]) & CALL_LONG) == 0"
9937 "bl %z0\;%."
9938 [(set_attr "type" "branch")
9939 (set_attr "length" "8")])
9940
9941 (define_insn "*call_value_indirect_nonlocal_aix32"
9942 [(set (match_operand 0 "" "")
9943 (call (mem:SI (match_operand:SI 1 "register_operand" "c,*l"))
9944 (match_operand 2 "" "g,g")))
9945 (use (reg:SI 2))
9946 (use (reg:SI 11))
9947 (set (reg:SI 2)
9948 (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9949 (clobber (match_scratch:SI 3 "=l,l"))]
9950 "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
9951 "b%T1l\;{l|lwz} 2,20(1)"
9952 [(set_attr "type" "jmpreg")
9953 (set_attr "length" "8")])
9954
9955 (define_insn "*call_value_nonlocal_aix32"
9956 [(set (match_operand 0 "" "")
9957 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
9958 (match_operand 2 "" "g")))
9959 (use (match_operand:SI 3 "immediate_operand" "O"))
9960 (clobber (match_scratch:SI 4 "=l"))]
9961 "TARGET_32BIT
9962 && DEFAULT_ABI == ABI_AIX
9963 && (INTVAL (operands[3]) & CALL_LONG) == 0"
9964 "bl %z1\;%."
9965 [(set_attr "type" "branch")
9966 (set_attr "length" "8")])
9967
9968 (define_insn "*call_value_indirect_nonlocal_aix64"
9969 [(set (match_operand 0 "" "")
9970 (call (mem:SI (match_operand:DI 1 "register_operand" "c,*l"))
9971 (match_operand 2 "" "g,g")))
9972 (use (reg:DI 2))
9973 (use (reg:DI 11))
9974 (set (reg:DI 2)
9975 (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9976 (clobber (match_scratch:SI 3 "=l,l"))]
9977 "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
9978 "b%T1l\;ld 2,40(1)"
9979 [(set_attr "type" "jmpreg")
9980 (set_attr "length" "8")])
9981
9982 (define_insn "*call_value_nonlocal_aix64"
9983 [(set (match_operand 0 "" "")
9984 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
9985 (match_operand 2 "" "g")))
9986 (use (match_operand:SI 3 "immediate_operand" "O"))
9987 (clobber (match_scratch:SI 4 "=l"))]
9988 "TARGET_64BIT
9989 && DEFAULT_ABI == ABI_AIX
9990 && (INTVAL (operands[3]) & CALL_LONG) == 0"
9991 "bl %z1\;%."
9992 [(set_attr "type" "branch")
9993 (set_attr "length" "8")])
9994
9995 ;; A function pointer under System V is just a normal pointer
9996 ;; operands[0] is the function pointer
9997 ;; operands[1] is the stack size to clean up
9998 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
9999 ;; which indicates how to set cr1
10000
10001 (define_insn "*call_indirect_nonlocal_sysv"
10002 [(call (mem:SI (match_operand:SI 0 "register_operand" "c,*l,c,*l"))
10003 (match_operand 1 "" "g,g,g,g"))
10004 (use (match_operand:SI 2 "immediate_operand" "O,O,n,n"))
10005 (clobber (match_scratch:SI 3 "=l,l,l,l"))]
10006 "DEFAULT_ABI == ABI_V4
10007 || DEFAULT_ABI == ABI_DARWIN"
10008 {
10009 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10010 output_asm_insn ("crxor 6,6,6", operands);
10011
10012 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10013 output_asm_insn ("creqv 6,6,6", operands);
10014
10015 return "b%T0l";
10016 }
10017 [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
10018 (set_attr "length" "4,4,8,8")])
10019
10020 (define_insn "*call_nonlocal_sysv"
10021 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10022 (match_operand 1 "" "g,g"))
10023 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10024 (clobber (match_scratch:SI 3 "=l,l"))]
10025 "(DEFAULT_ABI == ABI_DARWIN
10026 || (DEFAULT_ABI == ABI_V4
10027 && (INTVAL (operands[2]) & CALL_LONG) == 0))"
10028 {
10029 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10030 output_asm_insn ("crxor 6,6,6", operands);
10031
10032 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10033 output_asm_insn ("creqv 6,6,6", operands);
10034
10035 #if TARGET_MACHO
10036 return output_call(insn, operands, 0, 2);
10037 #else
10038 if (DEFAULT_ABI == ABI_V4 && flag_pic)
10039 {
10040 if (TARGET_SECURE_PLT && flag_pic == 2)
10041 /* The magic 32768 offset here and in the other sysv call insns
10042 corresponds to the offset of r30 in .got2, as given by LCTOC1.
10043 See sysv4.h:toc_section. */
10044 return "bl %z0+32768@plt";
10045 else
10046 return "bl %z0@plt";
10047 }
10048 else
10049 return "bl %z0";
10050 #endif
10051 }
10052 [(set_attr "type" "branch,branch")
10053 (set_attr "length" "4,8")])
10054
10055 (define_insn "*call_value_indirect_nonlocal_sysv"
10056 [(set (match_operand 0 "" "")
10057 (call (mem:SI (match_operand:SI 1 "register_operand" "c,*l,c,*l"))
10058 (match_operand 2 "" "g,g,g,g")))
10059 (use (match_operand:SI 3 "immediate_operand" "O,O,n,n"))
10060 (clobber (match_scratch:SI 4 "=l,l,l,l"))]
10061 "DEFAULT_ABI == ABI_V4
10062 || DEFAULT_ABI == ABI_DARWIN"
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 return "b%T1l";
10071 }
10072 [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
10073 (set_attr "length" "4,4,8,8")])
10074
10075 (define_insn "*call_value_nonlocal_sysv"
10076 [(set (match_operand 0 "" "")
10077 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10078 (match_operand 2 "" "g,g")))
10079 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10080 (clobber (match_scratch:SI 4 "=l,l"))]
10081 "(DEFAULT_ABI == ABI_DARWIN
10082 || (DEFAULT_ABI == ABI_V4
10083 && (INTVAL (operands[3]) & CALL_LONG) == 0))"
10084 {
10085 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10086 output_asm_insn ("crxor 6,6,6", operands);
10087
10088 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10089 output_asm_insn ("creqv 6,6,6", operands);
10090
10091 #if TARGET_MACHO
10092 return output_call(insn, operands, 1, 3);
10093 #else
10094 if (DEFAULT_ABI == ABI_V4 && flag_pic)
10095 {
10096 if (TARGET_SECURE_PLT && flag_pic == 2)
10097 return "bl %z1+32768@plt";
10098 else
10099 return "bl %z1@plt";
10100 }
10101 else
10102 return "bl %z1";
10103 #endif
10104 }
10105 [(set_attr "type" "branch,branch")
10106 (set_attr "length" "4,8")])
10107
10108 ;; Call subroutine returning any type.
10109 (define_expand "untyped_call"
10110 [(parallel [(call (match_operand 0 "" "")
10111 (const_int 0))
10112 (match_operand 1 "" "")
10113 (match_operand 2 "" "")])]
10114 ""
10115 "
10116 {
10117 int i;
10118
10119 emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
10120
10121 for (i = 0; i < XVECLEN (operands[2], 0); i++)
10122 {
10123 rtx set = XVECEXP (operands[2], 0, i);
10124 emit_move_insn (SET_DEST (set), SET_SRC (set));
10125 }
10126
10127 /* The optimizer does not know that the call sets the function value
10128 registers we stored in the result block. We avoid problems by
10129 claiming that all hard registers are used and clobbered at this
10130 point. */
10131 emit_insn (gen_blockage ());
10132
10133 DONE;
10134 }")
10135
10136 ;; sibling call patterns
10137 (define_expand "sibcall"
10138 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10139 (match_operand 1 "" ""))
10140 (use (match_operand 2 "" ""))
10141 (use (match_operand 3 "" ""))
10142 (return)])]
10143 ""
10144 "
10145 {
10146 #if TARGET_MACHO
10147 if (MACHOPIC_INDIRECT)
10148 operands[0] = machopic_indirect_call_target (operands[0]);
10149 #endif
10150
10151 gcc_assert (GET_CODE (operands[0]) == MEM);
10152 gcc_assert (GET_CODE (operands[1]) == CONST_INT);
10153
10154 operands[0] = XEXP (operands[0], 0);
10155 operands[3] = gen_reg_rtx (SImode);
10156
10157 }")
10158
10159 ;; this and similar patterns must be marked as using LR, otherwise
10160 ;; dataflow will try to delete the store into it. This is true
10161 ;; even when the actual reg to jump to is in CTR, when LR was
10162 ;; saved and restored around the PIC-setting BCL.
10163 (define_insn "*sibcall_local32"
10164 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10165 (match_operand 1 "" "g,g"))
10166 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10167 (use (match_operand:SI 3 "register_operand" "l,l"))
10168 (return)]
10169 "(INTVAL (operands[2]) & CALL_LONG) == 0"
10170 "*
10171 {
10172 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10173 output_asm_insn (\"crxor 6,6,6\", operands);
10174
10175 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10176 output_asm_insn (\"creqv 6,6,6\", operands);
10177
10178 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10179 }"
10180 [(set_attr "type" "branch")
10181 (set_attr "length" "4,8")])
10182
10183 (define_insn "*sibcall_local64"
10184 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10185 (match_operand 1 "" "g,g"))
10186 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10187 (use (match_operand:SI 3 "register_operand" "l,l"))
10188 (return)]
10189 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10190 "*
10191 {
10192 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10193 output_asm_insn (\"crxor 6,6,6\", operands);
10194
10195 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10196 output_asm_insn (\"creqv 6,6,6\", operands);
10197
10198 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10199 }"
10200 [(set_attr "type" "branch")
10201 (set_attr "length" "4,8")])
10202
10203 (define_insn "*sibcall_value_local32"
10204 [(set (match_operand 0 "" "")
10205 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10206 (match_operand 2 "" "g,g")))
10207 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10208 (use (match_operand:SI 4 "register_operand" "l,l"))
10209 (return)]
10210 "(INTVAL (operands[3]) & CALL_LONG) == 0"
10211 "*
10212 {
10213 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10214 output_asm_insn (\"crxor 6,6,6\", operands);
10215
10216 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10217 output_asm_insn (\"creqv 6,6,6\", operands);
10218
10219 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10220 }"
10221 [(set_attr "type" "branch")
10222 (set_attr "length" "4,8")])
10223
10224
10225 (define_insn "*sibcall_value_local64"
10226 [(set (match_operand 0 "" "")
10227 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10228 (match_operand 2 "" "g,g")))
10229 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10230 (use (match_operand:SI 4 "register_operand" "l,l"))
10231 (return)]
10232 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10233 "*
10234 {
10235 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10236 output_asm_insn (\"crxor 6,6,6\", operands);
10237
10238 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10239 output_asm_insn (\"creqv 6,6,6\", operands);
10240
10241 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10242 }"
10243 [(set_attr "type" "branch")
10244 (set_attr "length" "4,8")])
10245
10246 (define_insn "*sibcall_nonlocal_aix32"
10247 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
10248 (match_operand 1 "" "g"))
10249 (use (match_operand:SI 2 "immediate_operand" "O"))
10250 (use (match_operand:SI 3 "register_operand" "l"))
10251 (return)]
10252 "TARGET_32BIT
10253 && DEFAULT_ABI == ABI_AIX
10254 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10255 "b %z0"
10256 [(set_attr "type" "branch")
10257 (set_attr "length" "4")])
10258
10259 (define_insn "*sibcall_nonlocal_aix64"
10260 [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
10261 (match_operand 1 "" "g"))
10262 (use (match_operand:SI 2 "immediate_operand" "O"))
10263 (use (match_operand:SI 3 "register_operand" "l"))
10264 (return)]
10265 "TARGET_64BIT
10266 && DEFAULT_ABI == ABI_AIX
10267 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10268 "b %z0"
10269 [(set_attr "type" "branch")
10270 (set_attr "length" "4")])
10271
10272 (define_insn "*sibcall_value_nonlocal_aix32"
10273 [(set (match_operand 0 "" "")
10274 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
10275 (match_operand 2 "" "g")))
10276 (use (match_operand:SI 3 "immediate_operand" "O"))
10277 (use (match_operand:SI 4 "register_operand" "l"))
10278 (return)]
10279 "TARGET_32BIT
10280 && DEFAULT_ABI == ABI_AIX
10281 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10282 "b %z1"
10283 [(set_attr "type" "branch")
10284 (set_attr "length" "4")])
10285
10286 (define_insn "*sibcall_value_nonlocal_aix64"
10287 [(set (match_operand 0 "" "")
10288 (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
10289 (match_operand 2 "" "g")))
10290 (use (match_operand:SI 3 "immediate_operand" "O"))
10291 (use (match_operand:SI 4 "register_operand" "l"))
10292 (return)]
10293 "TARGET_64BIT
10294 && DEFAULT_ABI == ABI_AIX
10295 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10296 "b %z1"
10297 [(set_attr "type" "branch")
10298 (set_attr "length" "4")])
10299
10300 (define_insn "*sibcall_nonlocal_sysv"
10301 [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10302 (match_operand 1 "" ""))
10303 (use (match_operand 2 "immediate_operand" "O,n"))
10304 (use (match_operand:SI 3 "register_operand" "l,l"))
10305 (return)]
10306 "(DEFAULT_ABI == ABI_DARWIN
10307 || DEFAULT_ABI == ABI_V4)
10308 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10309 "*
10310 {
10311 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10312 output_asm_insn (\"crxor 6,6,6\", operands);
10313
10314 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10315 output_asm_insn (\"creqv 6,6,6\", operands);
10316
10317 if (DEFAULT_ABI == ABI_V4 && flag_pic)
10318 {
10319 if (TARGET_SECURE_PLT && flag_pic == 2)
10320 return \"b %z0+32768@plt\";
10321 else
10322 return \"b %z0@plt\";
10323 }
10324 else
10325 return \"b %z0\";
10326 }"
10327 [(set_attr "type" "branch,branch")
10328 (set_attr "length" "4,8")])
10329
10330 (define_expand "sibcall_value"
10331 [(parallel [(set (match_operand 0 "register_operand" "")
10332 (call (mem:SI (match_operand 1 "address_operand" ""))
10333 (match_operand 2 "" "")))
10334 (use (match_operand 3 "" ""))
10335 (use (match_operand 4 "" ""))
10336 (return)])]
10337 ""
10338 "
10339 {
10340 #if TARGET_MACHO
10341 if (MACHOPIC_INDIRECT)
10342 operands[1] = machopic_indirect_call_target (operands[1]);
10343 #endif
10344
10345 gcc_assert (GET_CODE (operands[1]) == MEM);
10346 gcc_assert (GET_CODE (operands[2]) == CONST_INT);
10347
10348 operands[1] = XEXP (operands[1], 0);
10349 operands[4] = gen_reg_rtx (SImode);
10350
10351 }")
10352
10353 (define_insn "*sibcall_value_nonlocal_sysv"
10354 [(set (match_operand 0 "" "")
10355 (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10356 (match_operand 2 "" "")))
10357 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10358 (use (match_operand:SI 4 "register_operand" "l,l"))
10359 (return)]
10360 "(DEFAULT_ABI == ABI_DARWIN
10361 || DEFAULT_ABI == ABI_V4)
10362 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10363 "*
10364 {
10365 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10366 output_asm_insn (\"crxor 6,6,6\", operands);
10367
10368 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10369 output_asm_insn (\"creqv 6,6,6\", operands);
10370
10371 if (DEFAULT_ABI == ABI_V4 && flag_pic)
10372 {
10373 if (TARGET_SECURE_PLT && flag_pic == 2)
10374 return \"b %z1+32768@plt\";
10375 else
10376 return \"b %z1@plt\";
10377 }
10378 else
10379 return \"b %z1\";
10380 }"
10381 [(set_attr "type" "branch,branch")
10382 (set_attr "length" "4,8")])
10383
10384 (define_expand "sibcall_epilogue"
10385 [(use (const_int 0))]
10386 "TARGET_SCHED_PROLOG"
10387 "
10388 {
10389 rs6000_emit_epilogue (TRUE);
10390 DONE;
10391 }")
10392
10393 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
10394 ;; all of memory. This blocks insns from being moved across this point.
10395
10396 (define_insn "blockage"
10397 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCK)]
10398 ""
10399 "")
10400 \f
10401 ;; Compare insns are next. Note that the RS/6000 has two types of compares,
10402 ;; signed & unsigned, and one type of branch.
10403 ;;
10404 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
10405 ;; insns, and branches. We store the operands of compares until we see
10406 ;; how it is used.
10407 (define_expand "cmp<mode>"
10408 [(set (cc0)
10409 (compare (match_operand:GPR 0 "gpc_reg_operand" "")
10410 (match_operand:GPR 1 "reg_or_short_operand" "")))]
10411 ""
10412 "
10413 {
10414 /* Take care of the possibility that operands[1] might be negative but
10415 this might be a logical operation. That insn doesn't exist. */
10416 if (GET_CODE (operands[1]) == CONST_INT
10417 && INTVAL (operands[1]) < 0)
10418 operands[1] = force_reg (<MODE>mode, operands[1]);
10419
10420 rs6000_compare_op0 = operands[0];
10421 rs6000_compare_op1 = operands[1];
10422 rs6000_compare_fp_p = 0;
10423 DONE;
10424 }")
10425
10426 (define_expand "cmp<mode>"
10427 [(set (cc0) (compare (match_operand:FP 0 "gpc_reg_operand" "")
10428 (match_operand:FP 1 "gpc_reg_operand" "")))]
10429 ""
10430 "
10431 {
10432 rs6000_compare_op0 = operands[0];
10433 rs6000_compare_op1 = operands[1];
10434 rs6000_compare_fp_p = 1;
10435 DONE;
10436 }")
10437
10438 (define_expand "beq"
10439 [(use (match_operand 0 "" ""))]
10440 ""
10441 "{ rs6000_emit_cbranch (EQ, operands[0]); DONE; }")
10442
10443 (define_expand "bne"
10444 [(use (match_operand 0 "" ""))]
10445 ""
10446 "{ rs6000_emit_cbranch (NE, operands[0]); DONE; }")
10447
10448 (define_expand "bge"
10449 [(use (match_operand 0 "" ""))]
10450 ""
10451 "{ rs6000_emit_cbranch (GE, operands[0]); DONE; }")
10452
10453 (define_expand "bgt"
10454 [(use (match_operand 0 "" ""))]
10455 ""
10456 "{ rs6000_emit_cbranch (GT, operands[0]); DONE; }")
10457
10458 (define_expand "ble"
10459 [(use (match_operand 0 "" ""))]
10460 ""
10461 "{ rs6000_emit_cbranch (LE, operands[0]); DONE; }")
10462
10463 (define_expand "blt"
10464 [(use (match_operand 0 "" ""))]
10465 ""
10466 "{ rs6000_emit_cbranch (LT, operands[0]); DONE; }")
10467
10468 (define_expand "bgeu"
10469 [(use (match_operand 0 "" ""))]
10470 ""
10471 "{ rs6000_emit_cbranch (GEU, operands[0]); DONE; }")
10472
10473 (define_expand "bgtu"
10474 [(use (match_operand 0 "" ""))]
10475 ""
10476 "{ rs6000_emit_cbranch (GTU, operands[0]); DONE; }")
10477
10478 (define_expand "bleu"
10479 [(use (match_operand 0 "" ""))]
10480 ""
10481 "{ rs6000_emit_cbranch (LEU, operands[0]); DONE; }")
10482
10483 (define_expand "bltu"
10484 [(use (match_operand 0 "" ""))]
10485 ""
10486 "{ rs6000_emit_cbranch (LTU, operands[0]); DONE; }")
10487
10488 (define_expand "bunordered"
10489 [(use (match_operand 0 "" ""))]
10490 "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
10491 "{ rs6000_emit_cbranch (UNORDERED, operands[0]); DONE; }")
10492
10493 (define_expand "bordered"
10494 [(use (match_operand 0 "" ""))]
10495 "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
10496 "{ rs6000_emit_cbranch (ORDERED, operands[0]); DONE; }")
10497
10498 (define_expand "buneq"
10499 [(use (match_operand 0 "" ""))]
10500 ""
10501 "{ rs6000_emit_cbranch (UNEQ, operands[0]); DONE; }")
10502
10503 (define_expand "bunge"
10504 [(use (match_operand 0 "" ""))]
10505 ""
10506 "{ rs6000_emit_cbranch (UNGE, operands[0]); DONE; }")
10507
10508 (define_expand "bungt"
10509 [(use (match_operand 0 "" ""))]
10510 ""
10511 "{ rs6000_emit_cbranch (UNGT, operands[0]); DONE; }")
10512
10513 (define_expand "bunle"
10514 [(use (match_operand 0 "" ""))]
10515 ""
10516 "{ rs6000_emit_cbranch (UNLE, operands[0]); DONE; }")
10517
10518 (define_expand "bunlt"
10519 [(use (match_operand 0 "" ""))]
10520 ""
10521 "{ rs6000_emit_cbranch (UNLT, operands[0]); DONE; }")
10522
10523 (define_expand "bltgt"
10524 [(use (match_operand 0 "" ""))]
10525 ""
10526 "{ rs6000_emit_cbranch (LTGT, operands[0]); DONE; }")
10527
10528 ;; For SNE, we would prefer that the xor/abs sequence be used for integers.
10529 ;; For SEQ, likewise, except that comparisons with zero should be done
10530 ;; with an scc insns. However, due to the order that combine see the
10531 ;; resulting insns, we must, in fact, allow SEQ for integers. Fail in
10532 ;; the cases we don't want to handle.
10533 (define_expand "seq"
10534 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10535 ""
10536 "{ rs6000_emit_sCOND (EQ, operands[0]); DONE; }")
10537
10538 (define_expand "sne"
10539 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10540 ""
10541 "
10542 {
10543 if (! rs6000_compare_fp_p)
10544 FAIL;
10545
10546 rs6000_emit_sCOND (NE, operands[0]);
10547 DONE;
10548 }")
10549
10550 ;; A >= 0 is best done the portable way for A an integer.
10551 (define_expand "sge"
10552 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10553 ""
10554 "
10555 {
10556 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
10557 FAIL;
10558
10559 rs6000_emit_sCOND (GE, operands[0]);
10560 DONE;
10561 }")
10562
10563 ;; A > 0 is best done using the portable sequence, so fail in that case.
10564 (define_expand "sgt"
10565 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10566 ""
10567 "
10568 {
10569 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
10570 FAIL;
10571
10572 rs6000_emit_sCOND (GT, operands[0]);
10573 DONE;
10574 }")
10575
10576 ;; A <= 0 is best done the portable way for A an integer.
10577 (define_expand "sle"
10578 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10579 ""
10580 "
10581 {
10582 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
10583 FAIL;
10584
10585 rs6000_emit_sCOND (LE, operands[0]);
10586 DONE;
10587 }")
10588
10589 ;; A < 0 is best done in the portable way for A an integer.
10590 (define_expand "slt"
10591 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10592 ""
10593 "
10594 {
10595 if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
10596 FAIL;
10597
10598 rs6000_emit_sCOND (LT, operands[0]);
10599 DONE;
10600 }")
10601
10602 (define_expand "sgeu"
10603 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10604 ""
10605 "{ rs6000_emit_sCOND (GEU, operands[0]); DONE; }")
10606
10607 (define_expand "sgtu"
10608 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10609 ""
10610 "{ rs6000_emit_sCOND (GTU, operands[0]); DONE; }")
10611
10612 (define_expand "sleu"
10613 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10614 ""
10615 "{ rs6000_emit_sCOND (LEU, operands[0]); DONE; }")
10616
10617 (define_expand "sltu"
10618 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10619 ""
10620 "{ rs6000_emit_sCOND (LTU, operands[0]); DONE; }")
10621
10622 (define_expand "sunordered"
10623 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10624 "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
10625 "{ rs6000_emit_sCOND (UNORDERED, operands[0]); DONE; }")
10626
10627 (define_expand "sordered"
10628 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10629 "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
10630 "{ rs6000_emit_sCOND (ORDERED, operands[0]); DONE; }")
10631
10632 (define_expand "suneq"
10633 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10634 ""
10635 "{ rs6000_emit_sCOND (UNEQ, operands[0]); DONE; }")
10636
10637 (define_expand "sunge"
10638 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10639 ""
10640 "{ rs6000_emit_sCOND (UNGE, operands[0]); DONE; }")
10641
10642 (define_expand "sungt"
10643 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10644 ""
10645 "{ rs6000_emit_sCOND (UNGT, operands[0]); DONE; }")
10646
10647 (define_expand "sunle"
10648 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10649 ""
10650 "{ rs6000_emit_sCOND (UNLE, operands[0]); DONE; }")
10651
10652 (define_expand "sunlt"
10653 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10654 ""
10655 "{ rs6000_emit_sCOND (UNLT, operands[0]); DONE; }")
10656
10657 (define_expand "sltgt"
10658 [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10659 ""
10660 "{ rs6000_emit_sCOND (LTGT, operands[0]); DONE; }")
10661
10662 (define_expand "stack_protect_set"
10663 [(match_operand 0 "memory_operand" "")
10664 (match_operand 1 "memory_operand" "")]
10665 ""
10666 {
10667 #ifdef TARGET_THREAD_SSP_OFFSET
10668 rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
10669 rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
10670 operands[1] = gen_rtx_MEM (Pmode, addr);
10671 #endif
10672 if (TARGET_64BIT)
10673 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
10674 else
10675 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
10676 DONE;
10677 })
10678
10679 (define_insn "stack_protect_setsi"
10680 [(set (match_operand:SI 0 "memory_operand" "=m")
10681 (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET))
10682 (set (match_scratch:SI 2 "=&r") (const_int 0))]
10683 "TARGET_32BIT"
10684 "{l%U1%X1|lwz%U1%X1} %2,%1\;{st%U0%X0|stw%U0%X0} %2,%0\;{lil|li} %2,0"
10685 [(set_attr "type" "three")
10686 (set_attr "length" "12")])
10687
10688 (define_insn "stack_protect_setdi"
10689 [(set (match_operand:DI 0 "memory_operand" "=m")
10690 (unspec:DI [(match_operand:DI 1 "memory_operand" "m")] UNSPEC_SP_SET))
10691 (set (match_scratch:DI 2 "=&r") (const_int 0))]
10692 "TARGET_64BIT"
10693 "ld%U1%X1 %2,%1\;std%U0%X0 %2,%0\;{lil|li} %2,0"
10694 [(set_attr "type" "three")
10695 (set_attr "length" "12")])
10696
10697 (define_expand "stack_protect_test"
10698 [(match_operand 0 "memory_operand" "")
10699 (match_operand 1 "memory_operand" "")
10700 (match_operand 2 "" "")]
10701 ""
10702 {
10703 #ifdef TARGET_THREAD_SSP_OFFSET
10704 rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
10705 rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
10706 operands[1] = gen_rtx_MEM (Pmode, addr);
10707 #endif
10708 rs6000_compare_op0 = operands[0];
10709 rs6000_compare_op1 = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, operands[1]),
10710 UNSPEC_SP_TEST);
10711 rs6000_compare_fp_p = 0;
10712 emit_jump_insn (gen_beq (operands[2]));
10713 DONE;
10714 })
10715
10716 (define_insn "stack_protect_testsi"
10717 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
10718 (unspec:CCEQ [(match_operand:SI 1 "memory_operand" "m,m")
10719 (match_operand:SI 2 "memory_operand" "m,m")]
10720 UNSPEC_SP_TEST))
10721 (set (match_scratch:SI 4 "=r,r") (const_int 0))
10722 (clobber (match_scratch:SI 3 "=&r,&r"))]
10723 "TARGET_32BIT"
10724 "@
10725 {l%U1%X1|lwz%U1%X1} %3,%1\;{l%U2%X2|lwz%U2%X2} %4,%2\;xor. %3,%3,%4\;{lil|li} %4,0
10726 {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"
10727 [(set_attr "length" "16,20")])
10728
10729 (define_insn "stack_protect_testdi"
10730 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
10731 (unspec:CCEQ [(match_operand:DI 1 "memory_operand" "m,m")
10732 (match_operand:DI 2 "memory_operand" "m,m")]
10733 UNSPEC_SP_TEST))
10734 (set (match_scratch:DI 4 "=r,r") (const_int 0))
10735 (clobber (match_scratch:DI 3 "=&r,&r"))]
10736 "TARGET_64BIT"
10737 "@
10738 ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;xor. %3,%3,%4\;{lil|li} %4,0
10739 ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;cmpld %0,%3,%4\;{lil|li} %3,0\;{lil|li} %4,0"
10740 [(set_attr "length" "16,20")])
10741
10742 \f
10743 ;; Here are the actual compare insns.
10744 (define_insn "*cmp<mode>_internal1"
10745 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
10746 (compare:CC (match_operand:GPR 1 "gpc_reg_operand" "r")
10747 (match_operand:GPR 2 "reg_or_short_operand" "rI")))]
10748 ""
10749 "{cmp%I2|cmp<wd>%I2} %0,%1,%2"
10750 [(set_attr "type" "cmp")])
10751
10752 ;; If we are comparing a register for equality with a large constant,
10753 ;; we can do this with an XOR followed by a compare. But this is profitable
10754 ;; only if the large constant is only used for the comparison (and in this
10755 ;; case we already have a register to reuse as scratch).
10756 ;;
10757 ;; For 64-bit registers, we could only do so if the constant's bit 15 is clear:
10758 ;; otherwise we'd need to XOR with FFFFFFFF????0000 which is not available.
10759
10760 (define_peephole2
10761 [(set (match_operand:SI 0 "register_operand")
10762 (match_operand:SI 1 "logical_operand" ""))
10763 (set (match_dup 0) (match_operator:SI 3 "boolean_or_operator"
10764 [(match_dup 0)
10765 (match_operand:SI 2 "logical_operand" "")]))
10766 (set (match_operand:CC 4 "cc_reg_operand" "")
10767 (compare:CC (match_operand:SI 5 "gpc_reg_operand" "")
10768 (match_dup 0)))
10769 (set (pc)
10770 (if_then_else (match_operator 6 "equality_operator"
10771 [(match_dup 4) (const_int 0)])
10772 (match_operand 7 "" "")
10773 (match_operand 8 "" "")))]
10774 "peep2_reg_dead_p (3, operands[0])
10775 && peep2_reg_dead_p (4, operands[4])"
10776 [(set (match_dup 0) (xor:SI (match_dup 5) (match_dup 9)))
10777 (set (match_dup 4) (compare:CC (match_dup 0) (match_dup 10)))
10778 (set (pc) (if_then_else (match_dup 6) (match_dup 7) (match_dup 8)))]
10779
10780 {
10781 /* Get the constant we are comparing against, and see what it looks like
10782 when sign-extended from 16 to 32 bits. Then see what constant we could
10783 XOR with SEXTC to get the sign-extended value. */
10784 rtx cnst = simplify_const_binary_operation (GET_CODE (operands[3]),
10785 SImode,
10786 operands[1], operands[2]);
10787 HOST_WIDE_INT c = INTVAL (cnst);
10788 HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
10789 HOST_WIDE_INT xorv = c ^ sextc;
10790
10791 operands[9] = GEN_INT (xorv);
10792 operands[10] = GEN_INT (sextc);
10793 })
10794
10795 (define_insn "*cmpsi_internal2"
10796 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
10797 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
10798 (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
10799 ""
10800 "{cmpl%I2|cmplw%I2} %0,%1,%b2"
10801 [(set_attr "type" "cmp")])
10802
10803 (define_insn "*cmpdi_internal2"
10804 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
10805 (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
10806 (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
10807 ""
10808 "cmpld%I2 %0,%1,%b2"
10809 [(set_attr "type" "cmp")])
10810
10811 ;; The following two insns don't exist as single insns, but if we provide
10812 ;; them, we can swap an add and compare, which will enable us to overlap more
10813 ;; of the required delay between a compare and branch. We generate code for
10814 ;; them by splitting.
10815
10816 (define_insn ""
10817 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
10818 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
10819 (match_operand:SI 2 "short_cint_operand" "i")))
10820 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
10821 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
10822 ""
10823 "#"
10824 [(set_attr "length" "8")])
10825
10826 (define_insn ""
10827 [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
10828 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
10829 (match_operand:SI 2 "u_short_cint_operand" "i")))
10830 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
10831 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
10832 ""
10833 "#"
10834 [(set_attr "length" "8")])
10835
10836 (define_split
10837 [(set (match_operand:CC 3 "cc_reg_operand" "")
10838 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
10839 (match_operand:SI 2 "short_cint_operand" "")))
10840 (set (match_operand:SI 0 "gpc_reg_operand" "")
10841 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
10842 ""
10843 [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
10844 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
10845
10846 (define_split
10847 [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
10848 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
10849 (match_operand:SI 2 "u_short_cint_operand" "")))
10850 (set (match_operand:SI 0 "gpc_reg_operand" "")
10851 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
10852 ""
10853 [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
10854 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
10855
10856 (define_insn "*cmpsf_internal1"
10857 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10858 (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
10859 (match_operand:SF 2 "gpc_reg_operand" "f")))]
10860 "TARGET_HARD_FLOAT && TARGET_FPRS"
10861 "fcmpu %0,%1,%2"
10862 [(set_attr "type" "fpcompare")])
10863
10864 (define_insn "*cmpdf_internal1"
10865 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10866 (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
10867 (match_operand:DF 2 "gpc_reg_operand" "f")))]
10868 "TARGET_HARD_FLOAT && TARGET_FPRS"
10869 "fcmpu %0,%1,%2"
10870 [(set_attr "type" "fpcompare")])
10871
10872 ;; Only need to compare second words if first words equal
10873 (define_insn "*cmptf_internal1"
10874 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10875 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
10876 (match_operand:TF 2 "gpc_reg_operand" "f")))]
10877 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && !TARGET_XL_COMPAT
10878 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
10879 "fcmpu %0,%1,%2\;bne %0,$+8\;fcmpu %0,%L1,%L2"
10880 [(set_attr "type" "fpcompare")
10881 (set_attr "length" "12")])
10882
10883 (define_insn_and_split "*cmptf_internal2"
10884 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10885 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
10886 (match_operand:TF 2 "gpc_reg_operand" "f")))
10887 (clobber (match_scratch:DF 3 "=f"))
10888 (clobber (match_scratch:DF 4 "=f"))
10889 (clobber (match_scratch:DF 5 "=f"))
10890 (clobber (match_scratch:DF 6 "=f"))
10891 (clobber (match_scratch:DF 7 "=f"))
10892 (clobber (match_scratch:DF 8 "=f"))
10893 (clobber (match_scratch:DF 9 "=f"))
10894 (clobber (match_scratch:DF 10 "=f"))]
10895 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && TARGET_XL_COMPAT
10896 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
10897 "#"
10898 "&& reload_completed"
10899 [(set (match_dup 3) (match_dup 13))
10900 (set (match_dup 4) (match_dup 14))
10901 (set (match_dup 9) (abs:DF (match_dup 5)))
10902 (set (match_dup 0) (compare:CCFP (match_dup 9) (match_dup 3)))
10903 (set (pc) (if_then_else (ne (match_dup 0) (const_int 0))
10904 (label_ref (match_dup 11))
10905 (pc)))
10906 (set (match_dup 0) (compare:CCFP (match_dup 5) (match_dup 7)))
10907 (set (pc) (label_ref (match_dup 12)))
10908 (match_dup 11)
10909 (set (match_dup 10) (minus:DF (match_dup 5) (match_dup 7)))
10910 (set (match_dup 9) (minus:DF (match_dup 6) (match_dup 8)))
10911 (set (match_dup 9) (plus:DF (match_dup 10) (match_dup 9)))
10912 (set (match_dup 0) (compare:CCFP (match_dup 7) (match_dup 4)))
10913 (match_dup 12)]
10914 {
10915 REAL_VALUE_TYPE rv;
10916 const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
10917 const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
10918
10919 operands[5] = simplify_gen_subreg (DFmode, operands[1], TFmode, hi_word);
10920 operands[6] = simplify_gen_subreg (DFmode, operands[1], TFmode, lo_word);
10921 operands[7] = simplify_gen_subreg (DFmode, operands[2], TFmode, hi_word);
10922 operands[8] = simplify_gen_subreg (DFmode, operands[2], TFmode, lo_word);
10923 operands[11] = gen_label_rtx ();
10924 operands[12] = gen_label_rtx ();
10925 real_inf (&rv);
10926 operands[13] = force_const_mem (DFmode,
10927 CONST_DOUBLE_FROM_REAL_VALUE (rv, DFmode));
10928 operands[14] = force_const_mem (DFmode,
10929 CONST_DOUBLE_FROM_REAL_VALUE (dconst0,
10930 DFmode));
10931 if (TARGET_TOC)
10932 {
10933 operands[13] = gen_const_mem (DFmode,
10934 create_TOC_reference (XEXP (operands[13], 0)));
10935 operands[14] = gen_const_mem (DFmode,
10936 create_TOC_reference (XEXP (operands[14], 0)));
10937 set_mem_alias_set (operands[13], get_TOC_alias_set ());
10938 set_mem_alias_set (operands[14], get_TOC_alias_set ());
10939 }
10940 })
10941 \f
10942 ;; Now we have the scc insns. We can do some combinations because of the
10943 ;; way the machine works.
10944 ;;
10945 ;; Note that this is probably faster if we can put an insn between the
10946 ;; mfcr and rlinm, but this is tricky. Let's leave it for now. In most
10947 ;; cases the insns below which don't use an intermediate CR field will
10948 ;; be used instead.
10949 (define_insn ""
10950 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10951 (match_operator:SI 1 "scc_comparison_operator"
10952 [(match_operand 2 "cc_reg_operand" "y")
10953 (const_int 0)]))]
10954 ""
10955 "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
10956 [(set (attr "type")
10957 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
10958 (const_string "mfcrf")
10959 ]
10960 (const_string "mfcr")))
10961 (set_attr "length" "8")])
10962
10963 ;; Same as above, but get the GT bit.
10964 (define_insn "move_from_CR_gt_bit"
10965 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10966 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_GT))]
10967 "TARGET_E500"
10968 "mfcr %0\;{rlinm|rlwinm} %0,%0,%D1,31,31"
10969 [(set_attr "type" "mfcr")
10970 (set_attr "length" "8")])
10971
10972 ;; Same as above, but get the OV/ORDERED bit.
10973 (define_insn "move_from_CR_ov_bit"
10974 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10975 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_OV))]
10976 "TARGET_ISEL"
10977 "mfcr %0\;{rlinm|rlwinm} %0,%0,%t1,1"
10978 [(set_attr "type" "mfcr")
10979 (set_attr "length" "8")])
10980
10981 (define_insn ""
10982 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10983 (match_operator:DI 1 "scc_comparison_operator"
10984 [(match_operand 2 "cc_reg_operand" "y")
10985 (const_int 0)]))]
10986 "TARGET_POWERPC64"
10987 "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
10988 [(set (attr "type")
10989 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
10990 (const_string "mfcrf")
10991 ]
10992 (const_string "mfcr")))
10993 (set_attr "length" "8")])
10994
10995 (define_insn ""
10996 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
10997 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
10998 [(match_operand 2 "cc_reg_operand" "y,y")
10999 (const_int 0)])
11000 (const_int 0)))
11001 (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
11002 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11003 "TARGET_32BIT"
11004 "@
11005 mfcr %3%Q2\;{rlinm.|rlwinm.} %3,%3,%J1,1
11006 #"
11007 [(set_attr "type" "delayed_compare")
11008 (set_attr "length" "8,16")])
11009
11010 (define_split
11011 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11012 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11013 [(match_operand 2 "cc_reg_operand" "")
11014 (const_int 0)])
11015 (const_int 0)))
11016 (set (match_operand:SI 3 "gpc_reg_operand" "")
11017 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11018 "TARGET_32BIT && reload_completed"
11019 [(set (match_dup 3)
11020 (match_op_dup 1 [(match_dup 2) (const_int 0)]))
11021 (set (match_dup 0)
11022 (compare:CC (match_dup 3)
11023 (const_int 0)))]
11024 "")
11025
11026 (define_insn ""
11027 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11028 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11029 [(match_operand 2 "cc_reg_operand" "y")
11030 (const_int 0)])
11031 (match_operand:SI 3 "const_int_operand" "n")))]
11032 ""
11033 "*
11034 {
11035 int is_bit = ccr_bit (operands[1], 1);
11036 int put_bit = 31 - (INTVAL (operands[3]) & 31);
11037 int count;
11038
11039 if (is_bit >= put_bit)
11040 count = is_bit - put_bit;
11041 else
11042 count = 32 - (put_bit - is_bit);
11043
11044 operands[4] = GEN_INT (count);
11045 operands[5] = GEN_INT (put_bit);
11046
11047 return \"mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
11048 }"
11049 [(set (attr "type")
11050 (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
11051 (const_string "mfcrf")
11052 ]
11053 (const_string "mfcr")))
11054 (set_attr "length" "8")])
11055
11056 (define_insn ""
11057 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11058 (compare:CC
11059 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11060 [(match_operand 2 "cc_reg_operand" "y,y")
11061 (const_int 0)])
11062 (match_operand:SI 3 "const_int_operand" "n,n"))
11063 (const_int 0)))
11064 (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
11065 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11066 (match_dup 3)))]
11067 ""
11068 "*
11069 {
11070 int is_bit = ccr_bit (operands[1], 1);
11071 int put_bit = 31 - (INTVAL (operands[3]) & 31);
11072 int count;
11073
11074 /* Force split for non-cc0 compare. */
11075 if (which_alternative == 1)
11076 return \"#\";
11077
11078 if (is_bit >= put_bit)
11079 count = is_bit - put_bit;
11080 else
11081 count = 32 - (put_bit - is_bit);
11082
11083 operands[5] = GEN_INT (count);
11084 operands[6] = GEN_INT (put_bit);
11085
11086 return \"mfcr %4%Q2\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
11087 }"
11088 [(set_attr "type" "delayed_compare")
11089 (set_attr "length" "8,16")])
11090
11091 (define_split
11092 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11093 (compare:CC
11094 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11095 [(match_operand 2 "cc_reg_operand" "")
11096 (const_int 0)])
11097 (match_operand:SI 3 "const_int_operand" ""))
11098 (const_int 0)))
11099 (set (match_operand:SI 4 "gpc_reg_operand" "")
11100 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11101 (match_dup 3)))]
11102 "reload_completed"
11103 [(set (match_dup 4)
11104 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11105 (match_dup 3)))
11106 (set (match_dup 0)
11107 (compare:CC (match_dup 4)
11108 (const_int 0)))]
11109 "")
11110
11111 ;; There is a 3 cycle delay between consecutive mfcr instructions
11112 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
11113
11114 (define_peephole
11115 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11116 (match_operator:SI 1 "scc_comparison_operator"
11117 [(match_operand 2 "cc_reg_operand" "y")
11118 (const_int 0)]))
11119 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
11120 (match_operator:SI 4 "scc_comparison_operator"
11121 [(match_operand 5 "cc_reg_operand" "y")
11122 (const_int 0)]))]
11123 "REGNO (operands[2]) != REGNO (operands[5])"
11124 "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
11125 [(set_attr "type" "mfcr")
11126 (set_attr "length" "12")])
11127
11128 (define_peephole
11129 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11130 (match_operator:DI 1 "scc_comparison_operator"
11131 [(match_operand 2 "cc_reg_operand" "y")
11132 (const_int 0)]))
11133 (set (match_operand:DI 3 "gpc_reg_operand" "=r")
11134 (match_operator:DI 4 "scc_comparison_operator"
11135 [(match_operand 5 "cc_reg_operand" "y")
11136 (const_int 0)]))]
11137 "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
11138 "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
11139 [(set_attr "type" "mfcr")
11140 (set_attr "length" "12")])
11141
11142 ;; There are some scc insns that can be done directly, without a compare.
11143 ;; These are faster because they don't involve the communications between
11144 ;; the FXU and branch units. In fact, we will be replacing all of the
11145 ;; integer scc insns here or in the portable methods in emit_store_flag.
11146 ;;
11147 ;; Also support (neg (scc ..)) since that construct is used to replace
11148 ;; branches, (plus (scc ..) ..) since that construct is common and
11149 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
11150 ;; cases where it is no more expensive than (neg (scc ..)).
11151
11152 ;; Have reload force a constant into a register for the simple insns that
11153 ;; otherwise won't accept constants. We do this because it is faster than
11154 ;; the cmp/mfcr sequence we would otherwise generate.
11155
11156 (define_mode_attr scc_eq_op2 [(SI "rKLI")
11157 (DI "rKJI")])
11158
11159 (define_insn_and_split "*eq<mode>"
11160 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
11161 (eq:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
11162 (match_operand:GPR 2 "scc_eq_operand" "<scc_eq_op2>")))]
11163 "!TARGET_POWER"
11164 "#"
11165 "!TARGET_POWER"
11166 [(set (match_dup 0)
11167 (clz:GPR (match_dup 3)))
11168 (set (match_dup 0)
11169 (lshiftrt:GPR (match_dup 0) (match_dup 4)))]
11170 {
11171 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
11172 {
11173 /* Use output operand as intermediate. */
11174 operands[3] = operands[0];
11175
11176 if (logical_operand (operands[2], <MODE>mode))
11177 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
11178 gen_rtx_XOR (<MODE>mode,
11179 operands[1], operands[2])));
11180 else
11181 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
11182 gen_rtx_PLUS (<MODE>mode, operands[1],
11183 negate_rtx (<MODE>mode,
11184 operands[2]))));
11185 }
11186 else
11187 operands[3] = operands[1];
11188
11189 operands[4] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
11190 })
11191
11192 (define_insn_and_split "*eq<mode>_compare"
11193 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
11194 (compare:CC
11195 (eq:P (match_operand:P 1 "gpc_reg_operand" "=r")
11196 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))
11197 (const_int 0)))
11198 (set (match_operand:P 0 "gpc_reg_operand" "=r")
11199 (eq:P (match_dup 1) (match_dup 2)))]
11200 "!TARGET_POWER && optimize_size"
11201 "#"
11202 "!TARGET_POWER && optimize_size"
11203 [(set (match_dup 0)
11204 (clz:P (match_dup 4)))
11205 (parallel [(set (match_dup 3)
11206 (compare:CC (lshiftrt:P (match_dup 0) (match_dup 5))
11207 (const_int 0)))
11208 (set (match_dup 0)
11209 (lshiftrt:P (match_dup 0) (match_dup 5)))])]
11210 {
11211 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
11212 {
11213 /* Use output operand as intermediate. */
11214 operands[4] = operands[0];
11215
11216 if (logical_operand (operands[2], <MODE>mode))
11217 emit_insn (gen_rtx_SET (VOIDmode, operands[4],
11218 gen_rtx_XOR (<MODE>mode,
11219 operands[1], operands[2])));
11220 else
11221 emit_insn (gen_rtx_SET (VOIDmode, operands[4],
11222 gen_rtx_PLUS (<MODE>mode, operands[1],
11223 negate_rtx (<MODE>mode,
11224 operands[2]))));
11225 }
11226 else
11227 operands[4] = operands[1];
11228
11229 operands[5] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
11230 })
11231
11232 (define_insn "*eqsi_power"
11233 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
11234 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11235 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I")))
11236 (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
11237 "TARGET_POWER"
11238 "@
11239 xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11240 {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
11241 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11242 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11243 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
11244 [(set_attr "type" "three,two,three,three,three")
11245 (set_attr "length" "12,8,12,12,12")])
11246
11247 ;; We have insns of the form shown by the first define_insn below. If
11248 ;; there is something inside the comparison operation, we must split it.
11249 (define_split
11250 [(set (match_operand:SI 0 "gpc_reg_operand" "")
11251 (plus:SI (match_operator 1 "comparison_operator"
11252 [(match_operand:SI 2 "" "")
11253 (match_operand:SI 3
11254 "reg_or_cint_operand" "")])
11255 (match_operand:SI 4 "gpc_reg_operand" "")))
11256 (clobber (match_operand:SI 5 "register_operand" ""))]
11257 "! gpc_reg_operand (operands[2], SImode)"
11258 [(set (match_dup 5) (match_dup 2))
11259 (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
11260 (match_dup 4)))])
11261
11262 (define_insn "*plus_eqsi"
11263 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
11264 (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11265 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I"))
11266 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
11267 "TARGET_32BIT"
11268 "@
11269 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11270 {sfi|subfic} %0,%1,0\;{aze|addze} %0,%3
11271 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11272 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11273 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
11274 [(set_attr "type" "three,two,three,three,three")
11275 (set_attr "length" "12,8,12,12,12")])
11276
11277 (define_insn "*compare_plus_eqsi"
11278 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11279 (compare:CC
11280 (plus:SI
11281 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11282 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
11283 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
11284 (const_int 0)))
11285 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
11286 "TARGET_32BIT && optimize_size"
11287 "@
11288 xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11289 {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
11290 {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11291 {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11292 {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11293 #
11294 #
11295 #
11296 #
11297 #"
11298 [(set_attr "type" "compare")
11299 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11300
11301 (define_split
11302 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11303 (compare:CC
11304 (plus:SI
11305 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11306 (match_operand:SI 2 "scc_eq_operand" ""))
11307 (match_operand:SI 3 "gpc_reg_operand" ""))
11308 (const_int 0)))
11309 (clobber (match_scratch:SI 4 ""))]
11310 "TARGET_32BIT && optimize_size && reload_completed"
11311 [(set (match_dup 4)
11312 (plus:SI (eq:SI (match_dup 1)
11313 (match_dup 2))
11314 (match_dup 3)))
11315 (set (match_dup 0)
11316 (compare:CC (match_dup 4)
11317 (const_int 0)))]
11318 "")
11319
11320 (define_insn "*plus_eqsi_compare"
11321 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11322 (compare:CC
11323 (plus:SI
11324 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11325 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
11326 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
11327 (const_int 0)))
11328 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
11329 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11330 "TARGET_32BIT && optimize_size"
11331 "@
11332 xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11333 {sfi|subfic} %0,%1,0\;{aze.|addze.} %0,%3
11334 {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11335 {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11336 {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11337 #
11338 #
11339 #
11340 #
11341 #"
11342 [(set_attr "type" "compare")
11343 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11344
11345 (define_split
11346 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11347 (compare:CC
11348 (plus:SI
11349 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11350 (match_operand:SI 2 "scc_eq_operand" ""))
11351 (match_operand:SI 3 "gpc_reg_operand" ""))
11352 (const_int 0)))
11353 (set (match_operand:SI 0 "gpc_reg_operand" "")
11354 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11355 "TARGET_32BIT && optimize_size && reload_completed"
11356 [(set (match_dup 0)
11357 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11358 (set (match_dup 4)
11359 (compare:CC (match_dup 0)
11360 (const_int 0)))]
11361 "")
11362
11363 (define_insn "*neg_eq0<mode>"
11364 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
11365 (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "r")
11366 (const_int 0))))]
11367 ""
11368 "{ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0"
11369 [(set_attr "type" "two")
11370 (set_attr "length" "8")])
11371
11372 (define_insn_and_split "*neg_eq<mode>"
11373 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
11374 (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "%r")
11375 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))))]
11376 ""
11377 "#"
11378 ""
11379 [(set (match_dup 0) (neg:P (eq:P (match_dup 3) (const_int 0))))]
11380 {
11381 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
11382 {
11383 /* Use output operand as intermediate. */
11384 operands[3] = operands[0];
11385
11386 if (logical_operand (operands[2], <MODE>mode))
11387 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
11388 gen_rtx_XOR (<MODE>mode,
11389 operands[1], operands[2])));
11390 else
11391 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
11392 gen_rtx_PLUS (<MODE>mode, operands[1],
11393 negate_rtx (<MODE>mode,
11394 operands[2]))));
11395 }
11396 else
11397 operands[3] = operands[1];
11398 })
11399
11400 ;; Simplify (ne X (const_int 0)) on the PowerPC. No need to on the Power,
11401 ;; since it nabs/sr is just as fast.
11402 (define_insn "*ne0si"
11403 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
11404 (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11405 (const_int 31)))
11406 (clobber (match_scratch:SI 2 "=&r"))]
11407 "! TARGET_POWER && TARGET_32BIT && !TARGET_ISEL"
11408 "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
11409 [(set_attr "type" "two")
11410 (set_attr "length" "8")])
11411
11412 (define_insn "*ne0di"
11413 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11414 (lshiftrt:DI (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11415 (const_int 63)))
11416 (clobber (match_scratch:DI 2 "=&r"))]
11417 "TARGET_64BIT"
11418 "addic %2,%1,-1\;subfe %0,%2,%1"
11419 [(set_attr "type" "two")
11420 (set_attr "length" "8")])
11421
11422 ;; This is what (plus (ne X (const_int 0)) Y) looks like.
11423 (define_insn "*plus_ne0si"
11424 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11425 (plus:SI (lshiftrt:SI
11426 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11427 (const_int 31))
11428 (match_operand:SI 2 "gpc_reg_operand" "r")))
11429 (clobber (match_scratch:SI 3 "=&r"))]
11430 "TARGET_32BIT"
11431 "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
11432 [(set_attr "type" "two")
11433 (set_attr "length" "8")])
11434
11435 (define_insn "*plus_ne0di"
11436 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11437 (plus:DI (lshiftrt:DI
11438 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11439 (const_int 63))
11440 (match_operand:DI 2 "gpc_reg_operand" "r")))
11441 (clobber (match_scratch:DI 3 "=&r"))]
11442 "TARGET_64BIT"
11443 "addic %3,%1,-1\;addze %0,%2"
11444 [(set_attr "type" "two")
11445 (set_attr "length" "8")])
11446
11447 (define_insn "*compare_plus_ne0si"
11448 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11449 (compare:CC
11450 (plus:SI (lshiftrt:SI
11451 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11452 (const_int 31))
11453 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11454 (const_int 0)))
11455 (clobber (match_scratch:SI 3 "=&r,&r"))
11456 (clobber (match_scratch:SI 4 "=X,&r"))]
11457 "TARGET_32BIT"
11458 "@
11459 {ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2
11460 #"
11461 [(set_attr "type" "compare")
11462 (set_attr "length" "8,12")])
11463
11464 (define_split
11465 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11466 (compare:CC
11467 (plus:SI (lshiftrt:SI
11468 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11469 (const_int 31))
11470 (match_operand:SI 2 "gpc_reg_operand" ""))
11471 (const_int 0)))
11472 (clobber (match_scratch:SI 3 ""))
11473 (clobber (match_scratch:SI 4 ""))]
11474 "TARGET_32BIT && reload_completed"
11475 [(parallel [(set (match_dup 3)
11476 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1)))
11477 (const_int 31))
11478 (match_dup 2)))
11479 (clobber (match_dup 4))])
11480 (set (match_dup 0)
11481 (compare:CC (match_dup 3)
11482 (const_int 0)))]
11483 "")
11484
11485 (define_insn "*compare_plus_ne0di"
11486 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11487 (compare:CC
11488 (plus:DI (lshiftrt:DI
11489 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
11490 (const_int 63))
11491 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
11492 (const_int 0)))
11493 (clobber (match_scratch:DI 3 "=&r,&r"))]
11494 "TARGET_64BIT"
11495 "@
11496 addic %3,%1,-1\;addze. %3,%2
11497 #"
11498 [(set_attr "type" "compare")
11499 (set_attr "length" "8,12")])
11500
11501 (define_split
11502 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11503 (compare:CC
11504 (plus:DI (lshiftrt:DI
11505 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11506 (const_int 63))
11507 (match_operand:DI 2 "gpc_reg_operand" ""))
11508 (const_int 0)))
11509 (clobber (match_scratch:DI 3 ""))]
11510 "TARGET_64BIT && reload_completed"
11511 [(set (match_dup 3)
11512 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1)))
11513 (const_int 63))
11514 (match_dup 2)))
11515 (set (match_dup 0)
11516 (compare:CC (match_dup 3)
11517 (const_int 0)))]
11518 "")
11519
11520 (define_insn "*plus_ne0si_compare"
11521 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11522 (compare:CC
11523 (plus:SI (lshiftrt:SI
11524 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11525 (const_int 31))
11526 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11527 (const_int 0)))
11528 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11529 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11530 (match_dup 2)))
11531 (clobber (match_scratch:SI 3 "=&r,&r"))]
11532 "TARGET_32BIT"
11533 "@
11534 {ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2
11535 #"
11536 [(set_attr "type" "compare")
11537 (set_attr "length" "8,12")])
11538
11539 (define_split
11540 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11541 (compare:CC
11542 (plus:SI (lshiftrt:SI
11543 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11544 (const_int 31))
11545 (match_operand:SI 2 "gpc_reg_operand" ""))
11546 (const_int 0)))
11547 (set (match_operand:SI 0 "gpc_reg_operand" "")
11548 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11549 (match_dup 2)))
11550 (clobber (match_scratch:SI 3 ""))]
11551 "TARGET_32BIT && reload_completed"
11552 [(parallel [(set (match_dup 0)
11553 (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11554 (match_dup 2)))
11555 (clobber (match_dup 3))])
11556 (set (match_dup 4)
11557 (compare:CC (match_dup 0)
11558 (const_int 0)))]
11559 "")
11560
11561 (define_insn "*plus_ne0di_compare"
11562 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11563 (compare:CC
11564 (plus:DI (lshiftrt:DI
11565 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
11566 (const_int 63))
11567 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
11568 (const_int 0)))
11569 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
11570 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11571 (match_dup 2)))
11572 (clobber (match_scratch:DI 3 "=&r,&r"))]
11573 "TARGET_64BIT"
11574 "@
11575 addic %3,%1,-1\;addze. %0,%2
11576 #"
11577 [(set_attr "type" "compare")
11578 (set_attr "length" "8,12")])
11579
11580 (define_split
11581 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11582 (compare:CC
11583 (plus:DI (lshiftrt:DI
11584 (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11585 (const_int 63))
11586 (match_operand:DI 2 "gpc_reg_operand" ""))
11587 (const_int 0)))
11588 (set (match_operand:DI 0 "gpc_reg_operand" "")
11589 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11590 (match_dup 2)))
11591 (clobber (match_scratch:DI 3 ""))]
11592 "TARGET_64BIT && reload_completed"
11593 [(parallel [(set (match_dup 0)
11594 (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11595 (match_dup 2)))
11596 (clobber (match_dup 3))])
11597 (set (match_dup 4)
11598 (compare:CC (match_dup 0)
11599 (const_int 0)))]
11600 "")
11601
11602 (define_insn ""
11603 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11604 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11605 (match_operand:SI 2 "reg_or_short_operand" "r,O")))
11606 (clobber (match_scratch:SI 3 "=r,X"))]
11607 "TARGET_POWER"
11608 "@
11609 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
11610 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
11611 [(set_attr "length" "12")])
11612
11613 (define_insn ""
11614 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
11615 (compare:CC
11616 (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11617 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11618 (const_int 0)))
11619 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
11620 (le:SI (match_dup 1) (match_dup 2)))
11621 (clobber (match_scratch:SI 3 "=r,X,r,X"))]
11622 "TARGET_POWER"
11623 "@
11624 doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
11625 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31
11626 #
11627 #"
11628 [(set_attr "type" "compare,delayed_compare,compare,delayed_compare")
11629 (set_attr "length" "12,12,16,16")])
11630
11631 (define_split
11632 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11633 (compare:CC
11634 (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11635 (match_operand:SI 2 "reg_or_short_operand" ""))
11636 (const_int 0)))
11637 (set (match_operand:SI 0 "gpc_reg_operand" "")
11638 (le:SI (match_dup 1) (match_dup 2)))
11639 (clobber (match_scratch:SI 3 ""))]
11640 "TARGET_POWER && reload_completed"
11641 [(parallel [(set (match_dup 0)
11642 (le:SI (match_dup 1) (match_dup 2)))
11643 (clobber (match_dup 3))])
11644 (set (match_dup 4)
11645 (compare:CC (match_dup 0)
11646 (const_int 0)))]
11647 "")
11648
11649 (define_insn ""
11650 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
11651 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11652 (match_operand:SI 2 "reg_or_short_operand" "r,O"))
11653 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
11654 "TARGET_POWER"
11655 "@
11656 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11657 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze|addze} %0,%3"
11658 [(set_attr "length" "12")])
11659
11660 (define_insn ""
11661 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
11662 (compare:CC
11663 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11664 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11665 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11666 (const_int 0)))
11667 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
11668 "TARGET_POWER"
11669 "@
11670 doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11671 {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3
11672 #
11673 #"
11674 [(set_attr "type" "compare")
11675 (set_attr "length" "12,12,16,16")])
11676
11677 (define_split
11678 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11679 (compare:CC
11680 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11681 (match_operand:SI 2 "reg_or_short_operand" ""))
11682 (match_operand:SI 3 "gpc_reg_operand" ""))
11683 (const_int 0)))
11684 (clobber (match_scratch:SI 4 ""))]
11685 "TARGET_POWER && reload_completed"
11686 [(set (match_dup 4)
11687 (plus:SI (le:SI (match_dup 1) (match_dup 2))
11688 (match_dup 3)))
11689 (set (match_dup 0)
11690 (compare:CC (match_dup 4)
11691 (const_int 0)))]
11692 "")
11693
11694 (define_insn ""
11695 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
11696 (compare:CC
11697 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11698 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11699 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11700 (const_int 0)))
11701 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
11702 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11703 "TARGET_POWER"
11704 "@
11705 doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11706 {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze.|addze.} %0,%3
11707 #
11708 #"
11709 [(set_attr "type" "compare")
11710 (set_attr "length" "12,12,16,16")])
11711
11712 (define_split
11713 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11714 (compare:CC
11715 (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11716 (match_operand:SI 2 "reg_or_short_operand" ""))
11717 (match_operand:SI 3 "gpc_reg_operand" ""))
11718 (const_int 0)))
11719 (set (match_operand:SI 0 "gpc_reg_operand" "")
11720 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11721 "TARGET_POWER && reload_completed"
11722 [(set (match_dup 0)
11723 (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11724 (set (match_dup 4)
11725 (compare:CC (match_dup 0)
11726 (const_int 0)))]
11727 "")
11728
11729 (define_insn ""
11730 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11731 (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11732 (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
11733 "TARGET_POWER"
11734 "@
11735 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11736 {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
11737 [(set_attr "length" "12")])
11738
11739 (define_insn "*leu<mode>"
11740 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
11741 (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
11742 (match_operand:P 2 "reg_or_short_operand" "rI")))]
11743 ""
11744 "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
11745 [(set_attr "type" "three")
11746 (set_attr "length" "12")])
11747
11748 (define_insn "*leu<mode>_compare"
11749 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11750 (compare:CC
11751 (leu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
11752 (match_operand:P 2 "reg_or_short_operand" "rI,rI"))
11753 (const_int 0)))
11754 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
11755 (leu:P (match_dup 1) (match_dup 2)))]
11756 ""
11757 "@
11758 {sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
11759 #"
11760 [(set_attr "type" "compare")
11761 (set_attr "length" "12,16")])
11762
11763 (define_split
11764 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11765 (compare:CC
11766 (leu:P (match_operand:P 1 "gpc_reg_operand" "")
11767 (match_operand:P 2 "reg_or_short_operand" ""))
11768 (const_int 0)))
11769 (set (match_operand:P 0 "gpc_reg_operand" "")
11770 (leu:P (match_dup 1) (match_dup 2)))]
11771 "reload_completed"
11772 [(set (match_dup 0)
11773 (leu:P (match_dup 1) (match_dup 2)))
11774 (set (match_dup 3)
11775 (compare:CC (match_dup 0)
11776 (const_int 0)))]
11777 "")
11778
11779 (define_insn "*plus_leu<mode>"
11780 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
11781 (plus:P (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
11782 (match_operand:P 2 "reg_or_short_operand" "rI"))
11783 (match_operand:P 3 "gpc_reg_operand" "r")))]
11784 ""
11785 "{sf%I2|subf%I2c} %0,%1,%2\;{aze|addze} %0,%3"
11786 [(set_attr "type" "two")
11787 (set_attr "length" "8")])
11788
11789 (define_insn ""
11790 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11791 (compare:CC
11792 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11793 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11794 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11795 (const_int 0)))
11796 (clobber (match_scratch:SI 4 "=&r,&r"))]
11797 "TARGET_32BIT"
11798 "@
11799 {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3
11800 #"
11801 [(set_attr "type" "compare")
11802 (set_attr "length" "8,12")])
11803
11804 (define_split
11805 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11806 (compare:CC
11807 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11808 (match_operand:SI 2 "reg_or_short_operand" ""))
11809 (match_operand:SI 3 "gpc_reg_operand" ""))
11810 (const_int 0)))
11811 (clobber (match_scratch:SI 4 ""))]
11812 "TARGET_32BIT && reload_completed"
11813 [(set (match_dup 4)
11814 (plus:SI (leu:SI (match_dup 1) (match_dup 2))
11815 (match_dup 3)))
11816 (set (match_dup 0)
11817 (compare:CC (match_dup 4)
11818 (const_int 0)))]
11819 "")
11820
11821 (define_insn ""
11822 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11823 (compare:CC
11824 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11825 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11826 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11827 (const_int 0)))
11828 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
11829 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11830 "TARGET_32BIT"
11831 "@
11832 {sf%I2|subf%I2c} %0,%1,%2\;{aze.|addze.} %0,%3
11833 #"
11834 [(set_attr "type" "compare")
11835 (set_attr "length" "8,12")])
11836
11837 (define_split
11838 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11839 (compare:CC
11840 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11841 (match_operand:SI 2 "reg_or_short_operand" ""))
11842 (match_operand:SI 3 "gpc_reg_operand" ""))
11843 (const_int 0)))
11844 (set (match_operand:SI 0 "gpc_reg_operand" "")
11845 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11846 "TARGET_32BIT && reload_completed"
11847 [(set (match_dup 0)
11848 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11849 (set (match_dup 4)
11850 (compare:CC (match_dup 0)
11851 (const_int 0)))]
11852 "")
11853
11854 (define_insn "*neg_leu<mode>"
11855 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
11856 (neg:P (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
11857 (match_operand:P 2 "reg_or_short_operand" "rI"))))]
11858 ""
11859 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
11860 [(set_attr "type" "three")
11861 (set_attr "length" "12")])
11862
11863 (define_insn "*and_neg_leu<mode>"
11864 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
11865 (and:P (neg:P
11866 (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
11867 (match_operand:P 2 "reg_or_short_operand" "rI")))
11868 (match_operand:P 3 "gpc_reg_operand" "r")))]
11869 ""
11870 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
11871 [(set_attr "type" "three")
11872 (set_attr "length" "12")])
11873
11874 (define_insn ""
11875 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11876 (compare:CC
11877 (and:SI (neg:SI
11878 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11879 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
11880 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11881 (const_int 0)))
11882 (clobber (match_scratch:SI 4 "=&r,&r"))]
11883 "TARGET_32BIT"
11884 "@
11885 {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
11886 #"
11887 [(set_attr "type" "compare")
11888 (set_attr "length" "12,16")])
11889
11890 (define_split
11891 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11892 (compare:CC
11893 (and:SI (neg:SI
11894 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11895 (match_operand:SI 2 "reg_or_short_operand" "")))
11896 (match_operand:SI 3 "gpc_reg_operand" ""))
11897 (const_int 0)))
11898 (clobber (match_scratch:SI 4 ""))]
11899 "TARGET_32BIT && reload_completed"
11900 [(set (match_dup 4)
11901 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
11902 (match_dup 3)))
11903 (set (match_dup 0)
11904 (compare:CC (match_dup 4)
11905 (const_int 0)))]
11906 "")
11907
11908 (define_insn ""
11909 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11910 (compare:CC
11911 (and:SI (neg:SI
11912 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11913 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
11914 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11915 (const_int 0)))
11916 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
11917 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
11918 "TARGET_32BIT"
11919 "@
11920 {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
11921 #"
11922 [(set_attr "type" "compare")
11923 (set_attr "length" "12,16")])
11924
11925 (define_split
11926 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11927 (compare:CC
11928 (and:SI (neg:SI
11929 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11930 (match_operand:SI 2 "reg_or_short_operand" "")))
11931 (match_operand:SI 3 "gpc_reg_operand" ""))
11932 (const_int 0)))
11933 (set (match_operand:SI 0 "gpc_reg_operand" "")
11934 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
11935 "TARGET_32BIT && reload_completed"
11936 [(set (match_dup 0)
11937 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
11938 (match_dup 3)))
11939 (set (match_dup 4)
11940 (compare:CC (match_dup 0)
11941 (const_int 0)))]
11942 "")
11943
11944 (define_insn ""
11945 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11946 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11947 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
11948 "TARGET_POWER"
11949 "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
11950 [(set_attr "length" "12")])
11951
11952 (define_insn ""
11953 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11954 (compare:CC
11955 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11956 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11957 (const_int 0)))
11958 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11959 (lt:SI (match_dup 1) (match_dup 2)))]
11960 "TARGET_POWER"
11961 "@
11962 doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
11963 #"
11964 [(set_attr "type" "delayed_compare")
11965 (set_attr "length" "12,16")])
11966
11967 (define_split
11968 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11969 (compare:CC
11970 (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
11971 (match_operand:SI 2 "reg_or_short_operand" ""))
11972 (const_int 0)))
11973 (set (match_operand:SI 0 "gpc_reg_operand" "")
11974 (lt:SI (match_dup 1) (match_dup 2)))]
11975 "TARGET_POWER && reload_completed"
11976 [(set (match_dup 0)
11977 (lt:SI (match_dup 1) (match_dup 2)))
11978 (set (match_dup 3)
11979 (compare:CC (match_dup 0)
11980 (const_int 0)))]
11981 "")
11982
11983 (define_insn ""
11984 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
11985 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11986 (match_operand:SI 2 "reg_or_short_operand" "rI"))
11987 (match_operand:SI 3 "gpc_reg_operand" "r")))]
11988 "TARGET_POWER"
11989 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
11990 [(set_attr "length" "12")])
11991
11992 (define_insn ""
11993 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11994 (compare:CC
11995 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11996 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11997 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11998 (const_int 0)))
11999 (clobber (match_scratch:SI 4 "=&r,&r"))]
12000 "TARGET_POWER"
12001 "@
12002 doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
12003 #"
12004 [(set_attr "type" "compare")
12005 (set_attr "length" "12,16")])
12006
12007 (define_split
12008 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12009 (compare:CC
12010 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12011 (match_operand:SI 2 "reg_or_short_operand" ""))
12012 (match_operand:SI 3 "gpc_reg_operand" ""))
12013 (const_int 0)))
12014 (clobber (match_scratch:SI 4 ""))]
12015 "TARGET_POWER && reload_completed"
12016 [(set (match_dup 4)
12017 (plus:SI (lt:SI (match_dup 1) (match_dup 2))
12018 (match_dup 3)))
12019 (set (match_dup 0)
12020 (compare:CC (match_dup 4)
12021 (const_int 0)))]
12022 "")
12023
12024 (define_insn ""
12025 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12026 (compare:CC
12027 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12028 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12029 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12030 (const_int 0)))
12031 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12032 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12033 "TARGET_POWER"
12034 "@
12035 doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
12036 #"
12037 [(set_attr "type" "compare")
12038 (set_attr "length" "12,16")])
12039
12040 (define_split
12041 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12042 (compare:CC
12043 (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12044 (match_operand:SI 2 "reg_or_short_operand" ""))
12045 (match_operand:SI 3 "gpc_reg_operand" ""))
12046 (const_int 0)))
12047 (set (match_operand:SI 0 "gpc_reg_operand" "")
12048 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12049 "TARGET_POWER && reload_completed"
12050 [(set (match_dup 0)
12051 (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12052 (set (match_dup 4)
12053 (compare:CC (match_dup 0)
12054 (const_int 0)))]
12055 "")
12056
12057 (define_insn ""
12058 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12059 (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12060 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12061 "TARGET_POWER"
12062 "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
12063 [(set_attr "length" "12")])
12064
12065 (define_insn_and_split "*ltu<mode>"
12066 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12067 (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12068 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))]
12069 ""
12070 "#"
12071 ""
12072 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12073 (set (match_dup 0) (neg:P (match_dup 0)))]
12074 "")
12075
12076 (define_insn_and_split "*ltu<mode>_compare"
12077 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12078 (compare:CC
12079 (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12080 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
12081 (const_int 0)))
12082 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
12083 (ltu:P (match_dup 1) (match_dup 2)))]
12084 ""
12085 "#"
12086 ""
12087 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12088 (parallel [(set (match_dup 3)
12089 (compare:CC (neg:P (match_dup 0)) (const_int 0)))
12090 (set (match_dup 0) (neg:P (match_dup 0)))])]
12091 "")
12092
12093 (define_insn_and_split "*plus_ltu<mode>"
12094 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,r")
12095 (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12096 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
12097 (match_operand:P 3 "reg_or_short_operand" "rI,rI")))]
12098 ""
12099 "#"
12100 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12101 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12102 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))]
12103 "")
12104
12105 (define_insn_and_split "*plus_ltu<mode>_compare"
12106 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12107 (compare:CC
12108 (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12109 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
12110 (match_operand:P 3 "gpc_reg_operand" "r,r,r,r"))
12111 (const_int 0)))
12112 (set (match_operand:P 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12113 (plus:P (ltu:P (match_dup 1) (match_dup 2)) (match_dup 3)))]
12114 ""
12115 "#"
12116 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12117 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12118 (parallel [(set (match_dup 4)
12119 (compare:CC (minus:P (match_dup 3) (match_dup 0))
12120 (const_int 0)))
12121 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))])]
12122 "")
12123
12124 (define_insn "*neg_ltu<mode>"
12125 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12126 (neg:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12127 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))))]
12128 ""
12129 "@
12130 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
12131 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
12132 [(set_attr "type" "two")
12133 (set_attr "length" "8")])
12134
12135 (define_insn ""
12136 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12137 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12138 (match_operand:SI 2 "reg_or_short_operand" "rI")))
12139 (clobber (match_scratch:SI 3 "=r"))]
12140 "TARGET_POWER"
12141 "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
12142 [(set_attr "length" "12")])
12143
12144 (define_insn ""
12145 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12146 (compare:CC
12147 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12148 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12149 (const_int 0)))
12150 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12151 (ge:SI (match_dup 1) (match_dup 2)))
12152 (clobber (match_scratch:SI 3 "=r,r"))]
12153 "TARGET_POWER"
12154 "@
12155 doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
12156 #"
12157 [(set_attr "type" "compare")
12158 (set_attr "length" "12,16")])
12159
12160 (define_split
12161 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12162 (compare:CC
12163 (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12164 (match_operand:SI 2 "reg_or_short_operand" ""))
12165 (const_int 0)))
12166 (set (match_operand:SI 0 "gpc_reg_operand" "")
12167 (ge:SI (match_dup 1) (match_dup 2)))
12168 (clobber (match_scratch:SI 3 ""))]
12169 "TARGET_POWER && reload_completed"
12170 [(parallel [(set (match_dup 0)
12171 (ge:SI (match_dup 1) (match_dup 2)))
12172 (clobber (match_dup 3))])
12173 (set (match_dup 4)
12174 (compare:CC (match_dup 0)
12175 (const_int 0)))]
12176 "")
12177
12178 (define_insn ""
12179 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12180 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12181 (match_operand:SI 2 "reg_or_short_operand" "rI"))
12182 (match_operand:SI 3 "gpc_reg_operand" "r")))]
12183 "TARGET_POWER"
12184 "doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
12185 [(set_attr "length" "12")])
12186
12187 (define_insn ""
12188 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12189 (compare:CC
12190 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12191 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12192 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12193 (const_int 0)))
12194 (clobber (match_scratch:SI 4 "=&r,&r"))]
12195 "TARGET_POWER"
12196 "@
12197 doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12198 #"
12199 [(set_attr "type" "compare")
12200 (set_attr "length" "12,16")])
12201
12202 (define_split
12203 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12204 (compare:CC
12205 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12206 (match_operand:SI 2 "reg_or_short_operand" ""))
12207 (match_operand:SI 3 "gpc_reg_operand" ""))
12208 (const_int 0)))
12209 (clobber (match_scratch:SI 4 ""))]
12210 "TARGET_POWER && reload_completed"
12211 [(set (match_dup 4)
12212 (plus:SI (ge:SI (match_dup 1) (match_dup 2))
12213 (match_dup 3)))
12214 (set (match_dup 0)
12215 (compare:CC (match_dup 4)
12216 (const_int 0)))]
12217 "")
12218
12219 (define_insn ""
12220 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12221 (compare:CC
12222 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12223 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12224 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12225 (const_int 0)))
12226 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12227 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12228 "TARGET_POWER"
12229 "@
12230 doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12231 #"
12232 [(set_attr "type" "compare")
12233 (set_attr "length" "12,16")])
12234
12235 (define_split
12236 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12237 (compare:CC
12238 (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12239 (match_operand:SI 2 "reg_or_short_operand" ""))
12240 (match_operand:SI 3 "gpc_reg_operand" ""))
12241 (const_int 0)))
12242 (set (match_operand:SI 0 "gpc_reg_operand" "")
12243 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12244 "TARGET_POWER && reload_completed"
12245 [(set (match_dup 0)
12246 (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12247 (set (match_dup 4)
12248 (compare:CC (match_dup 0)
12249 (const_int 0)))]
12250 "")
12251
12252 (define_insn ""
12253 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12254 (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12255 (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12256 "TARGET_POWER"
12257 "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
12258 [(set_attr "length" "12")])
12259
12260 (define_insn "*geu<mode>"
12261 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12262 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12263 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))]
12264 ""
12265 "@
12266 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
12267 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
12268 [(set_attr "type" "three")
12269 (set_attr "length" "12")])
12270
12271 (define_insn "*geu<mode>_compare"
12272 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12273 (compare:CC
12274 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12275 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
12276 (const_int 0)))
12277 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
12278 (geu:P (match_dup 1) (match_dup 2)))]
12279 ""
12280 "@
12281 {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12282 {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12283 #
12284 #"
12285 [(set_attr "type" "compare")
12286 (set_attr "length" "12,12,16,16")])
12287
12288 (define_split
12289 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12290 (compare:CC
12291 (geu:P (match_operand:P 1 "gpc_reg_operand" "")
12292 (match_operand:P 2 "reg_or_neg_short_operand" ""))
12293 (const_int 0)))
12294 (set (match_operand:P 0 "gpc_reg_operand" "")
12295 (geu:P (match_dup 1) (match_dup 2)))]
12296 "reload_completed"
12297 [(set (match_dup 0)
12298 (geu:P (match_dup 1) (match_dup 2)))
12299 (set (match_dup 3)
12300 (compare:CC (match_dup 0)
12301 (const_int 0)))]
12302 "")
12303
12304 (define_insn "*plus_geu<mode>"
12305 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,&r")
12306 (plus:P (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12307 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
12308 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
12309 ""
12310 "@
12311 {sf|subfc} %0,%2,%1\;{aze|addze} %0,%3
12312 {ai|addic} %0,%1,%n2\;{aze|addze} %0,%3"
12313 [(set_attr "type" "two")
12314 (set_attr "length" "8")])
12315
12316 (define_insn ""
12317 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12318 (compare:CC
12319 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12320 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12321 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12322 (const_int 0)))
12323 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12324 "TARGET_32BIT"
12325 "@
12326 {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
12327 {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3
12328 #
12329 #"
12330 [(set_attr "type" "compare")
12331 (set_attr "length" "8,8,12,12")])
12332
12333 (define_split
12334 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12335 (compare:CC
12336 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12337 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12338 (match_operand:SI 3 "gpc_reg_operand" ""))
12339 (const_int 0)))
12340 (clobber (match_scratch:SI 4 ""))]
12341 "TARGET_32BIT && reload_completed"
12342 [(set (match_dup 4)
12343 (plus:SI (geu:SI (match_dup 1) (match_dup 2))
12344 (match_dup 3)))
12345 (set (match_dup 0)
12346 (compare:CC (match_dup 4)
12347 (const_int 0)))]
12348 "")
12349
12350 (define_insn ""
12351 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12352 (compare:CC
12353 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12354 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12355 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12356 (const_int 0)))
12357 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12358 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12359 "TARGET_32BIT"
12360 "@
12361 {sf|subfc} %0,%2,%1\;{aze.|addze.} %0,%3
12362 {ai|addic} %0,%1,%n2\;{aze.|addze.} %0,%3
12363 #
12364 #"
12365 [(set_attr "type" "compare")
12366 (set_attr "length" "8,8,12,12")])
12367
12368 (define_split
12369 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12370 (compare:CC
12371 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12372 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12373 (match_operand:SI 3 "gpc_reg_operand" ""))
12374 (const_int 0)))
12375 (set (match_operand:SI 0 "gpc_reg_operand" "")
12376 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12377 "TARGET_32BIT && reload_completed"
12378 [(set (match_dup 0)
12379 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12380 (set (match_dup 4)
12381 (compare:CC (match_dup 0)
12382 (const_int 0)))]
12383 "")
12384
12385 (define_insn "*neg_geu<mode>"
12386 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12387 (neg:P (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12388 (match_operand:P 2 "reg_or_short_operand" "r,I"))))]
12389 ""
12390 "@
12391 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
12392 {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
12393 [(set_attr "type" "three")
12394 (set_attr "length" "12")])
12395
12396 (define_insn "*and_neg_geu<mode>"
12397 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,&r")
12398 (and:P (neg:P
12399 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12400 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))
12401 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
12402 ""
12403 "@
12404 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0
12405 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
12406 [(set_attr "type" "three")
12407 (set_attr "length" "12")])
12408
12409 (define_insn ""
12410 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12411 (compare:CC
12412 (and:SI (neg:SI
12413 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12414 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12415 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12416 (const_int 0)))
12417 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12418 "TARGET_32BIT"
12419 "@
12420 {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12421 {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12422 #
12423 #"
12424 [(set_attr "type" "compare")
12425 (set_attr "length" "12,12,16,16")])
12426
12427 (define_split
12428 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12429 (compare:CC
12430 (and:SI (neg:SI
12431 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12432 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12433 (match_operand:SI 3 "gpc_reg_operand" ""))
12434 (const_int 0)))
12435 (clobber (match_scratch:SI 4 ""))]
12436 "TARGET_32BIT && reload_completed"
12437 [(set (match_dup 4)
12438 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2)))
12439 (match_dup 3)))
12440 (set (match_dup 0)
12441 (compare:CC (match_dup 4)
12442 (const_int 0)))]
12443 "")
12444
12445 (define_insn ""
12446 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12447 (compare:CC
12448 (and:SI (neg:SI
12449 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12450 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12451 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12452 (const_int 0)))
12453 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12454 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12455 "TARGET_32BIT"
12456 "@
12457 {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
12458 {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
12459 #
12460 #"
12461 [(set_attr "type" "compare")
12462 (set_attr "length" "12,12,16,16")])
12463
12464 (define_split
12465 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12466 (compare:CC
12467 (and:SI (neg:SI
12468 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12469 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12470 (match_operand:SI 3 "gpc_reg_operand" ""))
12471 (const_int 0)))
12472 (set (match_operand:SI 0 "gpc_reg_operand" "")
12473 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12474 "TARGET_32BIT && reload_completed"
12475 [(set (match_dup 0)
12476 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
12477 (set (match_dup 4)
12478 (compare:CC (match_dup 0)
12479 (const_int 0)))]
12480 "")
12481
12482 (define_insn ""
12483 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12484 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12485 (match_operand:SI 2 "reg_or_short_operand" "r")))]
12486 "TARGET_POWER"
12487 "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
12488 [(set_attr "length" "12")])
12489
12490 (define_insn ""
12491 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12492 (compare:CC
12493 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12494 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12495 (const_int 0)))
12496 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12497 (gt:SI (match_dup 1) (match_dup 2)))]
12498 "TARGET_POWER"
12499 "@
12500 doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
12501 #"
12502 [(set_attr "type" "delayed_compare")
12503 (set_attr "length" "12,16")])
12504
12505 (define_split
12506 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12507 (compare:CC
12508 (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12509 (match_operand:SI 2 "reg_or_short_operand" ""))
12510 (const_int 0)))
12511 (set (match_operand:SI 0 "gpc_reg_operand" "")
12512 (gt:SI (match_dup 1) (match_dup 2)))]
12513 "TARGET_POWER && reload_completed"
12514 [(set (match_dup 0)
12515 (gt:SI (match_dup 1) (match_dup 2)))
12516 (set (match_dup 3)
12517 (compare:CC (match_dup 0)
12518 (const_int 0)))]
12519 "")
12520
12521 (define_insn "*plus_gt0<mode>"
12522 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12523 (plus:P (gt:P (match_operand:P 1 "gpc_reg_operand" "r")
12524 (const_int 0))
12525 (match_operand:P 2 "gpc_reg_operand" "r")))]
12526 ""
12527 "{a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze|addze} %0,%2"
12528 [(set_attr "type" "three")
12529 (set_attr "length" "12")])
12530
12531 (define_insn ""
12532 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12533 (compare:CC
12534 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12535 (const_int 0))
12536 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12537 (const_int 0)))
12538 (clobber (match_scratch:SI 3 "=&r,&r"))]
12539 "TARGET_32BIT"
12540 "@
12541 {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
12542 #"
12543 [(set_attr "type" "compare")
12544 (set_attr "length" "12,16")])
12545
12546 (define_split
12547 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12548 (compare:CC
12549 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12550 (const_int 0))
12551 (match_operand:SI 2 "gpc_reg_operand" ""))
12552 (const_int 0)))
12553 (clobber (match_scratch:SI 3 ""))]
12554 "TARGET_32BIT && reload_completed"
12555 [(set (match_dup 3)
12556 (plus:SI (gt:SI (match_dup 1) (const_int 0))
12557 (match_dup 2)))
12558 (set (match_dup 0)
12559 (compare:CC (match_dup 3)
12560 (const_int 0)))]
12561 "")
12562
12563 (define_insn ""
12564 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12565 (compare:CC
12566 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12567 (const_int 0))
12568 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12569 (const_int 0)))
12570 (clobber (match_scratch:DI 3 "=&r,&r"))]
12571 "TARGET_64BIT"
12572 "@
12573 addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
12574 #"
12575 [(set_attr "type" "compare")
12576 (set_attr "length" "12,16")])
12577
12578 (define_split
12579 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12580 (compare:CC
12581 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12582 (const_int 0))
12583 (match_operand:DI 2 "gpc_reg_operand" ""))
12584 (const_int 0)))
12585 (clobber (match_scratch:DI 3 ""))]
12586 "TARGET_64BIT && reload_completed"
12587 [(set (match_dup 3)
12588 (plus:DI (gt:DI (match_dup 1) (const_int 0))
12589 (match_dup 2)))
12590 (set (match_dup 0)
12591 (compare:CC (match_dup 3)
12592 (const_int 0)))]
12593 "")
12594
12595 (define_insn ""
12596 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12597 (compare:CC
12598 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12599 (const_int 0))
12600 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12601 (const_int 0)))
12602 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12603 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
12604 "TARGET_32BIT"
12605 "@
12606 {a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze.|addze.} %0,%2
12607 #"
12608 [(set_attr "type" "compare")
12609 (set_attr "length" "12,16")])
12610
12611 (define_split
12612 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12613 (compare:CC
12614 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12615 (const_int 0))
12616 (match_operand:SI 2 "gpc_reg_operand" ""))
12617 (const_int 0)))
12618 (set (match_operand:SI 0 "gpc_reg_operand" "")
12619 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
12620 "TARGET_32BIT && reload_completed"
12621 [(set (match_dup 0)
12622 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
12623 (set (match_dup 3)
12624 (compare:CC (match_dup 0)
12625 (const_int 0)))]
12626 "")
12627
12628 (define_insn ""
12629 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12630 (compare:CC
12631 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12632 (const_int 0))
12633 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12634 (const_int 0)))
12635 (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
12636 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
12637 "TARGET_64BIT"
12638 "@
12639 addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
12640 #"
12641 [(set_attr "type" "compare")
12642 (set_attr "length" "12,16")])
12643
12644 (define_split
12645 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12646 (compare:CC
12647 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12648 (const_int 0))
12649 (match_operand:DI 2 "gpc_reg_operand" ""))
12650 (const_int 0)))
12651 (set (match_operand:DI 0 "gpc_reg_operand" "")
12652 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
12653 "TARGET_64BIT && reload_completed"
12654 [(set (match_dup 0)
12655 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
12656 (set (match_dup 3)
12657 (compare:CC (match_dup 0)
12658 (const_int 0)))]
12659 "")
12660
12661 (define_insn ""
12662 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12663 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12664 (match_operand:SI 2 "reg_or_short_operand" "r"))
12665 (match_operand:SI 3 "gpc_reg_operand" "r")))]
12666 "TARGET_POWER"
12667 "doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
12668 [(set_attr "length" "12")])
12669
12670 (define_insn ""
12671 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12672 (compare:CC
12673 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12674 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12675 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12676 (const_int 0)))
12677 (clobber (match_scratch:SI 4 "=&r,&r"))]
12678 "TARGET_POWER"
12679 "@
12680 doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
12681 #"
12682 [(set_attr "type" "compare")
12683 (set_attr "length" "12,16")])
12684
12685 (define_split
12686 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12687 (compare:CC
12688 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12689 (match_operand:SI 2 "reg_or_short_operand" ""))
12690 (match_operand:SI 3 "gpc_reg_operand" ""))
12691 (const_int 0)))
12692 (clobber (match_scratch:SI 4 ""))]
12693 "TARGET_POWER && reload_completed"
12694 [(set (match_dup 4)
12695 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12696 (set (match_dup 0)
12697 (compare:CC (match_dup 4)
12698 (const_int 0)))]
12699 "")
12700
12701 (define_insn ""
12702 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12703 (compare:CC
12704 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12705 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12706 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12707 (const_int 0)))
12708 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12709 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12710 "TARGET_POWER"
12711 "@
12712 doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
12713 #"
12714 [(set_attr "type" "compare")
12715 (set_attr "length" "12,16")])
12716
12717 (define_split
12718 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12719 (compare:CC
12720 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12721 (match_operand:SI 2 "reg_or_short_operand" ""))
12722 (match_operand:SI 3 "gpc_reg_operand" ""))
12723 (const_int 0)))
12724 (set (match_operand:SI 0 "gpc_reg_operand" "")
12725 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12726 "TARGET_POWER && reload_completed"
12727 [(set (match_dup 0)
12728 (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12729 (set (match_dup 4)
12730 (compare:CC (match_dup 0)
12731 (const_int 0)))]
12732 "")
12733
12734 (define_insn ""
12735 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12736 (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12737 (match_operand:SI 2 "reg_or_short_operand" "r"))))]
12738 "TARGET_POWER"
12739 "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
12740 [(set_attr "length" "12")])
12741
12742 (define_insn_and_split "*gtu<mode>"
12743 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12744 (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
12745 (match_operand:P 2 "reg_or_short_operand" "rI")))]
12746 ""
12747 "#"
12748 ""
12749 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
12750 (set (match_dup 0) (neg:P (match_dup 0)))]
12751 "")
12752
12753 (define_insn_and_split "*gtu<mode>_compare"
12754 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12755 (compare:CC
12756 (gtu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12757 (match_operand:P 2 "reg_or_short_operand" "rI,rI"))
12758 (const_int 0)))
12759 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12760 (gtu:P (match_dup 1) (match_dup 2)))]
12761 ""
12762 "#"
12763 ""
12764 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
12765 (parallel [(set (match_dup 3)
12766 (compare:CC (neg:P (match_dup 0)) (const_int 0)))
12767 (set (match_dup 0) (neg:P (match_dup 0)))])]
12768 "")
12769
12770 (define_insn_and_split "*plus_gtu<mode>"
12771 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12772 (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
12773 (match_operand:P 2 "reg_or_short_operand" "rI"))
12774 (match_operand:P 3 "reg_or_short_operand" "rI")))]
12775 ""
12776 "#"
12777 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12778 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
12779 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))]
12780 "")
12781
12782 (define_insn_and_split "*plus_gtu<mode>_compare"
12783 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12784 (compare:CC
12785 (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12786 (match_operand:P 2 "reg_or_short_operand" "I,r,I,r"))
12787 (match_operand:P 3 "gpc_reg_operand" "r,r,r,r"))
12788 (const_int 0)))
12789 (set (match_operand:P 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12790 (plus:P (gtu:P (match_dup 1) (match_dup 2)) (match_dup 3)))]
12791 ""
12792 "#"
12793 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12794 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
12795 (parallel [(set (match_dup 4)
12796 (compare:CC (minus:P (match_dup 3) (match_dup 0))
12797 (const_int 0)))
12798 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))])]
12799 "")
12800
12801 (define_insn "*neg_gtu<mode>"
12802 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12803 (neg:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
12804 (match_operand:P 2 "reg_or_short_operand" "rI"))))]
12805 ""
12806 "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
12807 [(set_attr "type" "two")
12808 (set_attr "length" "8")])
12809
12810 \f
12811 ;; Define both directions of branch and return. If we need a reload
12812 ;; register, we'd rather use CR0 since it is much easier to copy a
12813 ;; register CC value to there.
12814
12815 (define_insn ""
12816 [(set (pc)
12817 (if_then_else (match_operator 1 "branch_comparison_operator"
12818 [(match_operand 2
12819 "cc_reg_operand" "y")
12820 (const_int 0)])
12821 (label_ref (match_operand 0 "" ""))
12822 (pc)))]
12823 ""
12824 "*
12825 {
12826 return output_cbranch (operands[1], \"%l0\", 0, insn);
12827 }"
12828 [(set_attr "type" "branch")])
12829
12830 (define_insn ""
12831 [(set (pc)
12832 (if_then_else (match_operator 0 "branch_comparison_operator"
12833 [(match_operand 1
12834 "cc_reg_operand" "y")
12835 (const_int 0)])
12836 (return)
12837 (pc)))]
12838 "direct_return ()"
12839 "*
12840 {
12841 return output_cbranch (operands[0], NULL, 0, insn);
12842 }"
12843 [(set_attr "type" "jmpreg")
12844 (set_attr "length" "4")])
12845
12846 (define_insn ""
12847 [(set (pc)
12848 (if_then_else (match_operator 1 "branch_comparison_operator"
12849 [(match_operand 2
12850 "cc_reg_operand" "y")
12851 (const_int 0)])
12852 (pc)
12853 (label_ref (match_operand 0 "" ""))))]
12854 ""
12855 "*
12856 {
12857 return output_cbranch (operands[1], \"%l0\", 1, insn);
12858 }"
12859 [(set_attr "type" "branch")])
12860
12861 (define_insn ""
12862 [(set (pc)
12863 (if_then_else (match_operator 0 "branch_comparison_operator"
12864 [(match_operand 1
12865 "cc_reg_operand" "y")
12866 (const_int 0)])
12867 (pc)
12868 (return)))]
12869 "direct_return ()"
12870 "*
12871 {
12872 return output_cbranch (operands[0], NULL, 1, insn);
12873 }"
12874 [(set_attr "type" "jmpreg")
12875 (set_attr "length" "4")])
12876
12877 ;; Logic on condition register values.
12878
12879 ; This pattern matches things like
12880 ; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
12881 ; (eq:SI (reg:CCFP 68) (const_int 0)))
12882 ; (const_int 1)))
12883 ; which are generated by the branch logic.
12884 ; Prefer destructive operations where BT = BB (for crXX BT,BA,BB)
12885
12886 (define_insn "*cceq_ior_compare"
12887 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
12888 (compare:CCEQ (match_operator:SI 1 "boolean_operator"
12889 [(match_operator:SI 2
12890 "branch_positive_comparison_operator"
12891 [(match_operand 3
12892 "cc_reg_operand" "y,y")
12893 (const_int 0)])
12894 (match_operator:SI 4
12895 "branch_positive_comparison_operator"
12896 [(match_operand 5
12897 "cc_reg_operand" "0,y")
12898 (const_int 0)])])
12899 (const_int 1)))]
12900 ""
12901 "cr%q1 %E0,%j2,%j4"
12902 [(set_attr "type" "cr_logical,delayed_cr")])
12903
12904 ; Why is the constant -1 here, but 1 in the previous pattern?
12905 ; Because ~1 has all but the low bit set.
12906 (define_insn ""
12907 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
12908 (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
12909 [(not:SI (match_operator:SI 2
12910 "branch_positive_comparison_operator"
12911 [(match_operand 3
12912 "cc_reg_operand" "y,y")
12913 (const_int 0)]))
12914 (match_operator:SI 4
12915 "branch_positive_comparison_operator"
12916 [(match_operand 5
12917 "cc_reg_operand" "0,y")
12918 (const_int 0)])])
12919 (const_int -1)))]
12920 ""
12921 "cr%q1 %E0,%j2,%j4"
12922 [(set_attr "type" "cr_logical,delayed_cr")])
12923
12924 (define_insn "*cceq_rev_compare"
12925 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
12926 (compare:CCEQ (match_operator:SI 1
12927 "branch_positive_comparison_operator"
12928 [(match_operand 2
12929 "cc_reg_operand" "0,y")
12930 (const_int 0)])
12931 (const_int 0)))]
12932 ""
12933 "{crnor %E0,%j1,%j1|crnot %E0,%j1}"
12934 [(set_attr "type" "cr_logical,delayed_cr")])
12935
12936 ;; If we are comparing the result of two comparisons, this can be done
12937 ;; using creqv or crxor.
12938
12939 (define_insn_and_split ""
12940 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
12941 (compare:CCEQ (match_operator 1 "branch_comparison_operator"
12942 [(match_operand 2 "cc_reg_operand" "y")
12943 (const_int 0)])
12944 (match_operator 3 "branch_comparison_operator"
12945 [(match_operand 4 "cc_reg_operand" "y")
12946 (const_int 0)])))]
12947 ""
12948 "#"
12949 ""
12950 [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
12951 (match_dup 5)))]
12952 "
12953 {
12954 int positive_1, positive_2;
12955
12956 positive_1 = branch_positive_comparison_operator (operands[1],
12957 GET_MODE (operands[1]));
12958 positive_2 = branch_positive_comparison_operator (operands[3],
12959 GET_MODE (operands[3]));
12960
12961 if (! positive_1)
12962 operands[1] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[2]),
12963 GET_CODE (operands[1])),
12964 SImode,
12965 operands[2], const0_rtx);
12966 else if (GET_MODE (operands[1]) != SImode)
12967 operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode,
12968 operands[2], const0_rtx);
12969
12970 if (! positive_2)
12971 operands[3] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[4]),
12972 GET_CODE (operands[3])),
12973 SImode,
12974 operands[4], const0_rtx);
12975 else if (GET_MODE (operands[3]) != SImode)
12976 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
12977 operands[4], const0_rtx);
12978
12979 if (positive_1 == positive_2)
12980 {
12981 operands[1] = gen_rtx_NOT (SImode, operands[1]);
12982 operands[5] = constm1_rtx;
12983 }
12984 else
12985 {
12986 operands[5] = const1_rtx;
12987 }
12988 }")
12989
12990 ;; Unconditional branch and return.
12991
12992 (define_insn "jump"
12993 [(set (pc)
12994 (label_ref (match_operand 0 "" "")))]
12995 ""
12996 "b %l0"
12997 [(set_attr "type" "branch")])
12998
12999 (define_insn "return"
13000 [(return)]
13001 "direct_return ()"
13002 "{br|blr}"
13003 [(set_attr "type" "jmpreg")])
13004
13005 (define_expand "indirect_jump"
13006 [(set (pc) (match_operand 0 "register_operand" ""))])
13007
13008 (define_insn "*indirect_jump<mode>"
13009 [(set (pc) (match_operand:P 0 "register_operand" "c,*l"))]
13010 ""
13011 "@
13012 bctr
13013 {br|blr}"
13014 [(set_attr "type" "jmpreg")])
13015
13016 ;; Table jump for switch statements:
13017 (define_expand "tablejump"
13018 [(use (match_operand 0 "" ""))
13019 (use (label_ref (match_operand 1 "" "")))]
13020 ""
13021 "
13022 {
13023 if (TARGET_32BIT)
13024 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
13025 else
13026 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
13027 DONE;
13028 }")
13029
13030 (define_expand "tablejumpsi"
13031 [(set (match_dup 3)
13032 (plus:SI (match_operand:SI 0 "" "")
13033 (match_dup 2)))
13034 (parallel [(set (pc) (match_dup 3))
13035 (use (label_ref (match_operand 1 "" "")))])]
13036 "TARGET_32BIT"
13037 "
13038 { operands[0] = force_reg (SImode, operands[0]);
13039 operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
13040 operands[3] = gen_reg_rtx (SImode);
13041 }")
13042
13043 (define_expand "tablejumpdi"
13044 [(set (match_dup 4)
13045 (sign_extend:DI (match_operand:SI 0 "lwa_operand" "rm")))
13046 (set (match_dup 3)
13047 (plus:DI (match_dup 4)
13048 (match_dup 2)))
13049 (parallel [(set (pc) (match_dup 3))
13050 (use (label_ref (match_operand 1 "" "")))])]
13051 "TARGET_64BIT"
13052 "
13053 { operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
13054 operands[3] = gen_reg_rtx (DImode);
13055 operands[4] = gen_reg_rtx (DImode);
13056 }")
13057
13058 (define_insn "*tablejump<mode>_internal1"
13059 [(set (pc)
13060 (match_operand:P 0 "register_operand" "c,*l"))
13061 (use (label_ref (match_operand 1 "" "")))]
13062 ""
13063 "@
13064 bctr
13065 {br|blr}"
13066 [(set_attr "type" "jmpreg")])
13067
13068 (define_insn "nop"
13069 [(const_int 0)]
13070 ""
13071 "{cror 0,0,0|nop}")
13072 \f
13073 ;; Define the subtract-one-and-jump insns, starting with the template
13074 ;; so loop.c knows what to generate.
13075
13076 (define_expand "doloop_end"
13077 [(use (match_operand 0 "" "")) ; loop pseudo
13078 (use (match_operand 1 "" "")) ; iterations; zero if unknown
13079 (use (match_operand 2 "" "")) ; max iterations
13080 (use (match_operand 3 "" "")) ; loop level
13081 (use (match_operand 4 "" ""))] ; label
13082 ""
13083 "
13084 {
13085 /* Only use this on innermost loops. */
13086 if (INTVAL (operands[3]) > 1)
13087 FAIL;
13088 if (TARGET_64BIT)
13089 {
13090 if (GET_MODE (operands[0]) != DImode)
13091 FAIL;
13092 emit_jump_insn (gen_ctrdi (operands[0], operands[4]));
13093 }
13094 else
13095 {
13096 if (GET_MODE (operands[0]) != SImode)
13097 FAIL;
13098 emit_jump_insn (gen_ctrsi (operands[0], operands[4]));
13099 }
13100 DONE;
13101 }")
13102
13103 (define_expand "ctr<mode>"
13104 [(parallel [(set (pc)
13105 (if_then_else (ne (match_operand:P 0 "register_operand" "")
13106 (const_int 1))
13107 (label_ref (match_operand 1 "" ""))
13108 (pc)))
13109 (set (match_dup 0)
13110 (plus:P (match_dup 0)
13111 (const_int -1)))
13112 (clobber (match_scratch:CC 2 ""))
13113 (clobber (match_scratch:P 3 ""))])]
13114 ""
13115 "")
13116
13117 ;; We need to be able to do this for any operand, including MEM, or we
13118 ;; will cause reload to blow up since we don't allow output reloads on
13119 ;; JUMP_INSNs.
13120 ;; For the length attribute to be calculated correctly, the
13121 ;; label MUST be operand 0.
13122
13123 (define_insn "*ctr<mode>_internal1"
13124 [(set (pc)
13125 (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13126 (const_int 1))
13127 (label_ref (match_operand 0 "" ""))
13128 (pc)))
13129 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
13130 (plus:P (match_dup 1)
13131 (const_int -1)))
13132 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13133 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13134 ""
13135 "*
13136 {
13137 if (which_alternative != 0)
13138 return \"#\";
13139 else if (get_attr_length (insn) == 4)
13140 return \"{bdn|bdnz} %l0\";
13141 else
13142 return \"bdz $+8\;b %l0\";
13143 }"
13144 [(set_attr "type" "branch")
13145 (set_attr "length" "*,12,16,16")])
13146
13147 (define_insn "*ctr<mode>_internal2"
13148 [(set (pc)
13149 (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13150 (const_int 1))
13151 (pc)
13152 (label_ref (match_operand 0 "" ""))))
13153 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
13154 (plus:P (match_dup 1)
13155 (const_int -1)))
13156 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13157 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13158 ""
13159 "*
13160 {
13161 if (which_alternative != 0)
13162 return \"#\";
13163 else if (get_attr_length (insn) == 4)
13164 return \"bdz %l0\";
13165 else
13166 return \"{bdn|bdnz} $+8\;b %l0\";
13167 }"
13168 [(set_attr "type" "branch")
13169 (set_attr "length" "*,12,16,16")])
13170
13171 ;; Similar but use EQ
13172
13173 (define_insn "*ctr<mode>_internal5"
13174 [(set (pc)
13175 (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13176 (const_int 1))
13177 (label_ref (match_operand 0 "" ""))
13178 (pc)))
13179 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
13180 (plus:P (match_dup 1)
13181 (const_int -1)))
13182 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13183 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13184 ""
13185 "*
13186 {
13187 if (which_alternative != 0)
13188 return \"#\";
13189 else if (get_attr_length (insn) == 4)
13190 return \"bdz %l0\";
13191 else
13192 return \"{bdn|bdnz} $+8\;b %l0\";
13193 }"
13194 [(set_attr "type" "branch")
13195 (set_attr "length" "*,12,16,16")])
13196
13197 (define_insn "*ctr<mode>_internal6"
13198 [(set (pc)
13199 (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13200 (const_int 1))
13201 (pc)
13202 (label_ref (match_operand 0 "" ""))))
13203 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
13204 (plus:P (match_dup 1)
13205 (const_int -1)))
13206 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13207 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13208 ""
13209 "*
13210 {
13211 if (which_alternative != 0)
13212 return \"#\";
13213 else if (get_attr_length (insn) == 4)
13214 return \"{bdn|bdnz} %l0\";
13215 else
13216 return \"bdz $+8\;b %l0\";
13217 }"
13218 [(set_attr "type" "branch")
13219 (set_attr "length" "*,12,16,16")])
13220
13221 ;; Now the splitters if we could not allocate the CTR register
13222
13223 (define_split
13224 [(set (pc)
13225 (if_then_else (match_operator 2 "comparison_operator"
13226 [(match_operand:P 1 "gpc_reg_operand" "")
13227 (const_int 1)])
13228 (match_operand 5 "" "")
13229 (match_operand 6 "" "")))
13230 (set (match_operand:P 0 "gpc_reg_operand" "")
13231 (plus:P (match_dup 1) (const_int -1)))
13232 (clobber (match_scratch:CC 3 ""))
13233 (clobber (match_scratch:P 4 ""))]
13234 "reload_completed"
13235 [(parallel [(set (match_dup 3)
13236 (compare:CC (plus:P (match_dup 1)
13237 (const_int -1))
13238 (const_int 0)))
13239 (set (match_dup 0)
13240 (plus:P (match_dup 1)
13241 (const_int -1)))])
13242 (set (pc) (if_then_else (match_dup 7)
13243 (match_dup 5)
13244 (match_dup 6)))]
13245 "
13246 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
13247 operands[3], const0_rtx); }")
13248
13249 (define_split
13250 [(set (pc)
13251 (if_then_else (match_operator 2 "comparison_operator"
13252 [(match_operand:P 1 "gpc_reg_operand" "")
13253 (const_int 1)])
13254 (match_operand 5 "" "")
13255 (match_operand 6 "" "")))
13256 (set (match_operand:P 0 "nonimmediate_operand" "")
13257 (plus:P (match_dup 1) (const_int -1)))
13258 (clobber (match_scratch:CC 3 ""))
13259 (clobber (match_scratch:P 4 ""))]
13260 "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
13261 [(parallel [(set (match_dup 3)
13262 (compare:CC (plus:P (match_dup 1)
13263 (const_int -1))
13264 (const_int 0)))
13265 (set (match_dup 4)
13266 (plus:P (match_dup 1)
13267 (const_int -1)))])
13268 (set (match_dup 0)
13269 (match_dup 4))
13270 (set (pc) (if_then_else (match_dup 7)
13271 (match_dup 5)
13272 (match_dup 6)))]
13273 "
13274 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
13275 operands[3], const0_rtx); }")
13276 \f
13277 (define_insn "trap"
13278 [(trap_if (const_int 1) (const_int 0))]
13279 ""
13280 "{t 31,0,0|trap}")
13281
13282 (define_expand "conditional_trap"
13283 [(trap_if (match_operator 0 "trap_comparison_operator"
13284 [(match_dup 2) (match_dup 3)])
13285 (match_operand 1 "const_int_operand" ""))]
13286 ""
13287 "if (rs6000_compare_fp_p || operands[1] != const0_rtx) FAIL;
13288 operands[2] = rs6000_compare_op0;
13289 operands[3] = rs6000_compare_op1;")
13290
13291 (define_insn ""
13292 [(trap_if (match_operator 0 "trap_comparison_operator"
13293 [(match_operand:GPR 1 "register_operand" "r")
13294 (match_operand:GPR 2 "reg_or_short_operand" "rI")])
13295 (const_int 0))]
13296 ""
13297 "{t|t<wd>}%V0%I2 %1,%2")
13298 \f
13299 ;; Insns related to generating the function prologue and epilogue.
13300
13301 (define_expand "prologue"
13302 [(use (const_int 0))]
13303 "TARGET_SCHED_PROLOG"
13304 "
13305 {
13306 rs6000_emit_prologue ();
13307 DONE;
13308 }")
13309
13310 (define_insn "*movesi_from_cr_one"
13311 [(match_parallel 0 "mfcr_operation"
13312 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
13313 (unspec:SI [(match_operand:CC 2 "cc_reg_operand" "y")
13314 (match_operand 3 "immediate_operand" "n")]
13315 UNSPEC_MOVESI_FROM_CR))])]
13316 "TARGET_MFCRF"
13317 "*
13318 {
13319 int mask = 0;
13320 int i;
13321 for (i = 0; i < XVECLEN (operands[0], 0); i++)
13322 {
13323 mask = INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
13324 operands[4] = GEN_INT (mask);
13325 output_asm_insn (\"mfcr %1,%4\", operands);
13326 }
13327 return \"\";
13328 }"
13329 [(set_attr "type" "mfcrf")])
13330
13331 (define_insn "movesi_from_cr"
13332 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13333 (unspec:SI [(reg:CC 68) (reg:CC 69) (reg:CC 70) (reg:CC 71)
13334 (reg:CC 72) (reg:CC 73) (reg:CC 74) (reg:CC 75)]
13335 UNSPEC_MOVESI_FROM_CR))]
13336 ""
13337 "mfcr %0"
13338 [(set_attr "type" "mfcr")])
13339
13340 (define_insn "*stmw"
13341 [(match_parallel 0 "stmw_operation"
13342 [(set (match_operand:SI 1 "memory_operand" "=m")
13343 (match_operand:SI 2 "gpc_reg_operand" "r"))])]
13344 "TARGET_MULTIPLE"
13345 "{stm|stmw} %2,%1"
13346 [(set_attr "type" "store_ux")])
13347
13348 (define_insn "*save_fpregs_<mode>"
13349 [(match_parallel 0 "any_parallel_operand"
13350 [(clobber (match_operand:P 1 "register_operand" "=l"))
13351 (use (match_operand:P 2 "call_operand" "s"))
13352 (set (match_operand:DF 3 "memory_operand" "=m")
13353 (match_operand:DF 4 "gpc_reg_operand" "f"))])]
13354 ""
13355 "bl %z2"
13356 [(set_attr "type" "branch")
13357 (set_attr "length" "4")])
13358
13359 ; These are to explain that changes to the stack pointer should
13360 ; not be moved over stores to stack memory.
13361 (define_insn "stack_tie"
13362 [(set (match_operand:BLK 0 "memory_operand" "+m")
13363 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
13364 ""
13365 ""
13366 [(set_attr "length" "0")])
13367
13368
13369 (define_expand "epilogue"
13370 [(use (const_int 0))]
13371 "TARGET_SCHED_PROLOG"
13372 "
13373 {
13374 rs6000_emit_epilogue (FALSE);
13375 DONE;
13376 }")
13377
13378 ; On some processors, doing the mtcrf one CC register at a time is
13379 ; faster (like on the 604e). On others, doing them all at once is
13380 ; faster; for instance, on the 601 and 750.
13381
13382 (define_expand "movsi_to_cr_one"
13383 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
13384 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
13385 (match_dup 2)] UNSPEC_MOVESI_TO_CR))]
13386 ""
13387 "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
13388
13389 (define_insn "*movsi_to_cr"
13390 [(match_parallel 0 "mtcrf_operation"
13391 [(set (match_operand:CC 1 "cc_reg_operand" "=y")
13392 (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
13393 (match_operand 3 "immediate_operand" "n")]
13394 UNSPEC_MOVESI_TO_CR))])]
13395 ""
13396 "*
13397 {
13398 int mask = 0;
13399 int i;
13400 for (i = 0; i < XVECLEN (operands[0], 0); i++)
13401 mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
13402 operands[4] = GEN_INT (mask);
13403 return \"mtcrf %4,%2\";
13404 }"
13405 [(set_attr "type" "mtcr")])
13406
13407 (define_insn "*mtcrfsi"
13408 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
13409 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
13410 (match_operand 2 "immediate_operand" "n")]
13411 UNSPEC_MOVESI_TO_CR))]
13412 "GET_CODE (operands[0]) == REG
13413 && CR_REGNO_P (REGNO (operands[0]))
13414 && GET_CODE (operands[2]) == CONST_INT
13415 && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
13416 "mtcrf %R0,%1"
13417 [(set_attr "type" "mtcr")])
13418
13419 ; The load-multiple instructions have similar properties.
13420 ; Note that "load_multiple" is a name known to the machine-independent
13421 ; code that actually corresponds to the PowerPC load-string.
13422
13423 (define_insn "*lmw"
13424 [(match_parallel 0 "lmw_operation"
13425 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
13426 (match_operand:SI 2 "memory_operand" "m"))])]
13427 "TARGET_MULTIPLE"
13428 "{lm|lmw} %1,%2"
13429 [(set_attr "type" "load_ux")])
13430
13431 (define_insn "*return_internal_<mode>"
13432 [(return)
13433 (use (match_operand:P 0 "register_operand" "lc"))]
13434 ""
13435 "b%T0"
13436 [(set_attr "type" "jmpreg")])
13437
13438 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
13439 ; stuff was in GCC. Oh, and "any_parallel_operand" is a bit flexible...
13440
13441 (define_insn "*return_and_restore_fpregs_<mode>"
13442 [(match_parallel 0 "any_parallel_operand"
13443 [(return)
13444 (use (match_operand:P 1 "register_operand" "l"))
13445 (use (match_operand:P 2 "call_operand" "s"))
13446 (set (match_operand:DF 3 "gpc_reg_operand" "=f")
13447 (match_operand:DF 4 "memory_operand" "m"))])]
13448 ""
13449 "b %z2")
13450
13451 ; This is used in compiling the unwind routines.
13452 (define_expand "eh_return"
13453 [(use (match_operand 0 "general_operand" ""))]
13454 ""
13455 "
13456 {
13457 if (TARGET_32BIT)
13458 emit_insn (gen_eh_set_lr_si (operands[0]));
13459 else
13460 emit_insn (gen_eh_set_lr_di (operands[0]));
13461 DONE;
13462 }")
13463
13464 ; We can't expand this before we know where the link register is stored.
13465 (define_insn "eh_set_lr_<mode>"
13466 [(unspec_volatile [(match_operand:P 0 "register_operand" "r")]
13467 UNSPECV_EH_RR)
13468 (clobber (match_scratch:P 1 "=&b"))]
13469 ""
13470 "#")
13471
13472 (define_split
13473 [(unspec_volatile [(match_operand 0 "register_operand" "")] UNSPECV_EH_RR)
13474 (clobber (match_scratch 1 ""))]
13475 "reload_completed"
13476 [(const_int 0)]
13477 "
13478 {
13479 rs6000_emit_eh_reg_restore (operands[0], operands[1]);
13480 DONE;
13481 }")
13482
13483 (define_insn "prefetch"
13484 [(prefetch (match_operand 0 "indexed_or_indirect_address" "a")
13485 (match_operand:SI 1 "const_int_operand" "n")
13486 (match_operand:SI 2 "const_int_operand" "n"))]
13487 "TARGET_POWERPC"
13488 "*
13489 {
13490 if (GET_CODE (operands[0]) == REG)
13491 return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
13492 return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
13493 }"
13494 [(set_attr "type" "load")])
13495 \f
13496
13497 (include "sync.md")
13498 (include "altivec.md")
13499 (include "spe.md")