1 ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
2 ;; Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
4 ;; Free Software Foundation, Inc.
5 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
7 ;; This file is part of GCC.
9 ;; GCC is free software; you can redistribute it and/or modify it
10 ;; under the terms of the GNU General Public License as published
11 ;; by the Free Software Foundation; either version 2, or (at your
12 ;; option) any later version.
14 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
15 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 ;; License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
22 ;; MA 02110-1301, USA.
24 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
31 [(UNSPEC_FRSP 0) ; frsp for POWER machines
32 (UNSPEC_TIE 5) ; tie stack contents and stack pointer
33 (UNSPEC_TOCPTR 6) ; address of a word pointing to the TOC
34 (UNSPEC_TOC 7) ; address of the TOC (more-or-less)
36 (UNSPEC_MV_CR_OV 9) ; move_from_CR_ov_bit
42 (UNSPEC_LD_MPIC 15) ; load_macho_picbase
43 (UNSPEC_MPIC_CORRECT 16) ; macho_correct_pic
46 (UNSPEC_MOVESI_FROM_CR 19)
47 (UNSPEC_MOVESI_TO_CR 20)
49 (UNSPEC_TLSDTPRELHA 22)
50 (UNSPEC_TLSDTPRELLO 23)
51 (UNSPEC_TLSGOTDTPREL 24)
53 (UNSPEC_TLSTPRELHA 26)
54 (UNSPEC_TLSTPRELLO 27)
55 (UNSPEC_TLSGOTTPREL 28)
57 (UNSPEC_FIX_TRUNC_TF 30) ; fadd, rounding towards zero
58 (UNSPEC_MV_CR_GT 31) ; move_from_CR_gt_bit
74 (UNSPEC_DLMZB_STRLEN 47)
78 ;; UNSPEC_VOLATILE usage
83 (UNSPECV_LL 1) ; load-locked
84 (UNSPECV_SC 2) ; store-conditional
85 (UNSPECV_EH_RR 9) ; eh_reg_restore
88 ;; Define an insn type attribute. This is used in function unit delay
90 (define_attr "type" "integer,two,three,load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,store,store_ux,store_u,fpload,fpload_ux,fpload_u,fpstore,fpstore_ux,fpstore_u,vecload,vecstore,imul,imul2,imul3,lmul,idiv,ldiv,insert_word,branch,cmp,fast_compare,compare,var_delayed_compare,delayed_compare,imul_compare,lmul_compare,fpcompare,cr_logical,delayed_cr,mfcr,mfcrf,mtcr,mfjmpr,mtjmpr,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg,brinc,vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,vecfloat,vecfdiv,isync,sync,load_l,store_c,shift,trap,insert_dword,var_shift_rotate,cntlz,exts,mffgpr,mftgpr"
91 (const_string "integer"))
94 ; '(pc)' in the following doesn't include the instruction itself; it is
95 ; calculated as if the instruction had zero size.
96 (define_attr "length" ""
97 (if_then_else (eq_attr "type" "branch")
98 (if_then_else (and (ge (minus (match_dup 0) (pc))
100 (lt (minus (match_dup 0) (pc))
106 ;; Processor type -- this attribute must exactly match the processor_type
107 ;; enumeration in rs6000.h.
109 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4,power5,power6"
110 (const (symbol_ref "rs6000_cpu_attr")))
112 (automata_option "ndfa")
125 (include "power4.md")
126 (include "power5.md")
127 (include "power6.md")
129 (include "predicates.md")
130 (include "constraints.md")
132 (include "darwin.md")
137 ; This mode macro allows :GPR to be used to indicate the allowable size
138 ; of whole values in GPRs.
139 (define_mode_macro GPR [SI (DI "TARGET_POWERPC64")])
141 ; Any supported integer mode.
142 (define_mode_macro INT [QI HI SI DI TI])
144 ; Any supported integer mode that fits in one register.
145 (define_mode_macro INT1 [QI HI SI (DI "TARGET_POWERPC64")])
147 ; extend modes for DImode
148 (define_mode_macro QHSI [QI HI SI])
150 ; SImode or DImode, even if DImode doesn't fit in GPRs.
151 (define_mode_macro SDI [SI DI])
153 ; The size of a pointer. Also, the size of the value that a record-condition
154 ; (one with a '.') will compare.
155 (define_mode_macro P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
157 ; Any hardware-supported floating-point mode
158 (define_mode_macro FP [(SF "TARGET_HARD_FLOAT")
159 (DF "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)")
160 (TF "!TARGET_IEEEQUAD
161 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128")])
163 ; Various instructions that come in SI and DI forms.
164 ; A generic w/d attribute, for things like cmpw/cmpd.
165 (define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
168 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
171 ;; Start with fixed-point load and store insns. Here we put only the more
172 ;; complex forms. Basic data transfer is done later.
174 (define_expand "zero_extend<mode>di2"
175 [(set (match_operand:DI 0 "gpc_reg_operand" "")
176 (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "")))]
180 (define_insn "*zero_extend<mode>di2_internal1"
181 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
182 (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
186 rldicl %0,%1,0,<dbits>"
187 [(set_attr "type" "load,*")])
189 (define_insn "*zero_extend<mode>di2_internal2"
190 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
191 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
193 (clobber (match_scratch:DI 2 "=r,r"))]
196 rldicl. %2,%1,0,<dbits>
198 [(set_attr "type" "compare")
199 (set_attr "length" "4,8")])
202 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
203 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
205 (clobber (match_scratch:DI 2 ""))]
206 "TARGET_POWERPC64 && reload_completed"
208 (zero_extend:DI (match_dup 1)))
210 (compare:CC (match_dup 2)
214 (define_insn "*zero_extend<mode>di2_internal3"
215 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
216 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
218 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
219 (zero_extend:DI (match_dup 1)))]
222 rldicl. %0,%1,0,<dbits>
224 [(set_attr "type" "compare")
225 (set_attr "length" "4,8")])
228 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
229 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
231 (set (match_operand:DI 0 "gpc_reg_operand" "")
232 (zero_extend:DI (match_dup 1)))]
233 "TARGET_POWERPC64 && reload_completed"
235 (zero_extend:DI (match_dup 1)))
237 (compare:CC (match_dup 0)
241 (define_insn "extendqidi2"
242 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
243 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
246 [(set_attr "type" "exts")])
249 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
250 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
252 (clobber (match_scratch:DI 2 "=r,r"))]
257 [(set_attr "type" "compare")
258 (set_attr "length" "4,8")])
261 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
262 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
264 (clobber (match_scratch:DI 2 ""))]
265 "TARGET_POWERPC64 && reload_completed"
267 (sign_extend:DI (match_dup 1)))
269 (compare:CC (match_dup 2)
274 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
275 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
277 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
278 (sign_extend:DI (match_dup 1)))]
283 [(set_attr "type" "compare")
284 (set_attr "length" "4,8")])
287 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
288 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
290 (set (match_operand:DI 0 "gpc_reg_operand" "")
291 (sign_extend:DI (match_dup 1)))]
292 "TARGET_POWERPC64 && reload_completed"
294 (sign_extend:DI (match_dup 1)))
296 (compare:CC (match_dup 0)
300 (define_expand "extendhidi2"
301 [(set (match_operand:DI 0 "gpc_reg_operand" "")
302 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
307 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
308 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
313 [(set_attr "type" "load_ext,exts")])
316 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
317 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
319 (clobber (match_scratch:DI 2 "=r,r"))]
324 [(set_attr "type" "compare")
325 (set_attr "length" "4,8")])
328 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
329 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
331 (clobber (match_scratch:DI 2 ""))]
332 "TARGET_POWERPC64 && reload_completed"
334 (sign_extend:DI (match_dup 1)))
336 (compare:CC (match_dup 2)
341 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
342 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
344 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
345 (sign_extend:DI (match_dup 1)))]
350 [(set_attr "type" "compare")
351 (set_attr "length" "4,8")])
354 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
355 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
357 (set (match_operand:DI 0 "gpc_reg_operand" "")
358 (sign_extend:DI (match_dup 1)))]
359 "TARGET_POWERPC64 && reload_completed"
361 (sign_extend:DI (match_dup 1)))
363 (compare:CC (match_dup 0)
367 (define_expand "extendsidi2"
368 [(set (match_operand:DI 0 "gpc_reg_operand" "")
369 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
374 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
375 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
380 [(set_attr "type" "load_ext,exts")])
383 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
384 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
386 (clobber (match_scratch:DI 2 "=r,r"))]
391 [(set_attr "type" "compare")
392 (set_attr "length" "4,8")])
395 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
396 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
398 (clobber (match_scratch:DI 2 ""))]
399 "TARGET_POWERPC64 && reload_completed"
401 (sign_extend:DI (match_dup 1)))
403 (compare:CC (match_dup 2)
408 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
409 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
411 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
412 (sign_extend:DI (match_dup 1)))]
417 [(set_attr "type" "compare")
418 (set_attr "length" "4,8")])
421 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
422 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
424 (set (match_operand:DI 0 "gpc_reg_operand" "")
425 (sign_extend:DI (match_dup 1)))]
426 "TARGET_POWERPC64 && reload_completed"
428 (sign_extend:DI (match_dup 1)))
430 (compare:CC (match_dup 0)
434 (define_expand "zero_extendqisi2"
435 [(set (match_operand:SI 0 "gpc_reg_operand" "")
436 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
441 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
442 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
446 {rlinm|rlwinm} %0,%1,0,0xff"
447 [(set_attr "type" "load,*")])
450 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
451 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
453 (clobber (match_scratch:SI 2 "=r,r"))]
456 {andil.|andi.} %2,%1,0xff
458 [(set_attr "type" "compare")
459 (set_attr "length" "4,8")])
462 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
463 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
465 (clobber (match_scratch:SI 2 ""))]
468 (zero_extend:SI (match_dup 1)))
470 (compare:CC (match_dup 2)
475 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
476 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
478 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
479 (zero_extend:SI (match_dup 1)))]
482 {andil.|andi.} %0,%1,0xff
484 [(set_attr "type" "compare")
485 (set_attr "length" "4,8")])
488 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
489 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
491 (set (match_operand:SI 0 "gpc_reg_operand" "")
492 (zero_extend:SI (match_dup 1)))]
495 (zero_extend:SI (match_dup 1)))
497 (compare:CC (match_dup 0)
501 (define_expand "extendqisi2"
502 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
503 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
508 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
509 else if (TARGET_POWER)
510 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
512 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
516 (define_insn "extendqisi2_ppc"
517 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
518 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
521 [(set_attr "type" "exts")])
524 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
525 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
527 (clobber (match_scratch:SI 2 "=r,r"))]
532 [(set_attr "type" "compare")
533 (set_attr "length" "4,8")])
536 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
537 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
539 (clobber (match_scratch:SI 2 ""))]
540 "TARGET_POWERPC && reload_completed"
542 (sign_extend:SI (match_dup 1)))
544 (compare:CC (match_dup 2)
549 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
550 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
552 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
553 (sign_extend:SI (match_dup 1)))]
558 [(set_attr "type" "compare")
559 (set_attr "length" "4,8")])
562 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
563 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
565 (set (match_operand:SI 0 "gpc_reg_operand" "")
566 (sign_extend:SI (match_dup 1)))]
567 "TARGET_POWERPC && reload_completed"
569 (sign_extend:SI (match_dup 1)))
571 (compare:CC (match_dup 0)
575 (define_expand "extendqisi2_power"
576 [(parallel [(set (match_dup 2)
577 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
579 (clobber (scratch:SI))])
580 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
581 (ashiftrt:SI (match_dup 2)
583 (clobber (scratch:SI))])]
586 { operands[1] = gen_lowpart (SImode, operands[1]);
587 operands[2] = gen_reg_rtx (SImode); }")
589 (define_expand "extendqisi2_no_power"
591 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
593 (set (match_operand:SI 0 "gpc_reg_operand" "")
594 (ashiftrt:SI (match_dup 2)
596 "! TARGET_POWER && ! TARGET_POWERPC"
598 { operands[1] = gen_lowpart (SImode, operands[1]);
599 operands[2] = gen_reg_rtx (SImode); }")
601 (define_expand "zero_extendqihi2"
602 [(set (match_operand:HI 0 "gpc_reg_operand" "")
603 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
608 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
609 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
613 {rlinm|rlwinm} %0,%1,0,0xff"
614 [(set_attr "type" "load,*")])
617 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
618 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
620 (clobber (match_scratch:HI 2 "=r,r"))]
623 {andil.|andi.} %2,%1,0xff
625 [(set_attr "type" "compare")
626 (set_attr "length" "4,8")])
629 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
630 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
632 (clobber (match_scratch:HI 2 ""))]
635 (zero_extend:HI (match_dup 1)))
637 (compare:CC (match_dup 2)
642 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
643 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
645 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
646 (zero_extend:HI (match_dup 1)))]
649 {andil.|andi.} %0,%1,0xff
651 [(set_attr "type" "compare")
652 (set_attr "length" "4,8")])
655 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
656 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
658 (set (match_operand:HI 0 "gpc_reg_operand" "")
659 (zero_extend:HI (match_dup 1)))]
662 (zero_extend:HI (match_dup 1)))
664 (compare:CC (match_dup 0)
668 (define_expand "extendqihi2"
669 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
670 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
675 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
676 else if (TARGET_POWER)
677 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
679 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
683 (define_insn "extendqihi2_ppc"
684 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
685 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
688 [(set_attr "type" "exts")])
691 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
692 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
694 (clobber (match_scratch:HI 2 "=r,r"))]
699 [(set_attr "type" "compare")
700 (set_attr "length" "4,8")])
703 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
704 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
706 (clobber (match_scratch:HI 2 ""))]
707 "TARGET_POWERPC && reload_completed"
709 (sign_extend:HI (match_dup 1)))
711 (compare:CC (match_dup 2)
716 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
717 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
719 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
720 (sign_extend:HI (match_dup 1)))]
725 [(set_attr "type" "compare")
726 (set_attr "length" "4,8")])
729 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
730 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
732 (set (match_operand:HI 0 "gpc_reg_operand" "")
733 (sign_extend:HI (match_dup 1)))]
734 "TARGET_POWERPC && reload_completed"
736 (sign_extend:HI (match_dup 1)))
738 (compare:CC (match_dup 0)
742 (define_expand "extendqihi2_power"
743 [(parallel [(set (match_dup 2)
744 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
746 (clobber (scratch:SI))])
747 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
748 (ashiftrt:SI (match_dup 2)
750 (clobber (scratch:SI))])]
753 { operands[0] = gen_lowpart (SImode, operands[0]);
754 operands[1] = gen_lowpart (SImode, operands[1]);
755 operands[2] = gen_reg_rtx (SImode); }")
757 (define_expand "extendqihi2_no_power"
759 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
761 (set (match_operand:HI 0 "gpc_reg_operand" "")
762 (ashiftrt:SI (match_dup 2)
764 "! TARGET_POWER && ! TARGET_POWERPC"
766 { operands[0] = gen_lowpart (SImode, operands[0]);
767 operands[1] = gen_lowpart (SImode, operands[1]);
768 operands[2] = gen_reg_rtx (SImode); }")
770 (define_expand "zero_extendhisi2"
771 [(set (match_operand:SI 0 "gpc_reg_operand" "")
772 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
777 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
778 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
782 {rlinm|rlwinm} %0,%1,0,0xffff"
783 [(set_attr "type" "load,*")])
786 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
787 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
789 (clobber (match_scratch:SI 2 "=r,r"))]
792 {andil.|andi.} %2,%1,0xffff
794 [(set_attr "type" "compare")
795 (set_attr "length" "4,8")])
798 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
799 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
801 (clobber (match_scratch:SI 2 ""))]
804 (zero_extend:SI (match_dup 1)))
806 (compare:CC (match_dup 2)
811 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
812 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
814 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
815 (zero_extend:SI (match_dup 1)))]
818 {andil.|andi.} %0,%1,0xffff
820 [(set_attr "type" "compare")
821 (set_attr "length" "4,8")])
824 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
825 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
827 (set (match_operand:SI 0 "gpc_reg_operand" "")
828 (zero_extend:SI (match_dup 1)))]
831 (zero_extend:SI (match_dup 1)))
833 (compare:CC (match_dup 0)
837 (define_expand "extendhisi2"
838 [(set (match_operand:SI 0 "gpc_reg_operand" "")
839 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
844 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
845 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
850 [(set_attr "type" "load_ext,exts")])
853 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
854 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
856 (clobber (match_scratch:SI 2 "=r,r"))]
861 [(set_attr "type" "compare")
862 (set_attr "length" "4,8")])
865 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
866 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
868 (clobber (match_scratch:SI 2 ""))]
871 (sign_extend:SI (match_dup 1)))
873 (compare:CC (match_dup 2)
878 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
879 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
881 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
882 (sign_extend:SI (match_dup 1)))]
887 [(set_attr "type" "compare")
888 (set_attr "length" "4,8")])
890 ;; IBM 405 and 440 half-word multiplication operations.
892 (define_insn "*macchwc"
893 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
894 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
895 (match_operand:SI 2 "gpc_reg_operand" "r")
898 (match_operand:HI 1 "gpc_reg_operand" "r")))
899 (match_operand:SI 4 "gpc_reg_operand" "0"))
901 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
902 (plus:SI (mult:SI (ashiftrt:SI
910 [(set_attr "type" "imul3")])
912 (define_insn "*macchw"
913 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
914 (plus:SI (mult:SI (ashiftrt:SI
915 (match_operand:SI 2 "gpc_reg_operand" "r")
918 (match_operand:HI 1 "gpc_reg_operand" "r")))
919 (match_operand:SI 3 "gpc_reg_operand" "0")))]
922 [(set_attr "type" "imul3")])
924 (define_insn "*macchwuc"
925 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
926 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
927 (match_operand:SI 2 "gpc_reg_operand" "r")
930 (match_operand:HI 1 "gpc_reg_operand" "r")))
931 (match_operand:SI 4 "gpc_reg_operand" "0"))
933 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
934 (plus:SI (mult:SI (lshiftrt:SI
941 "macchwu. %0, %1, %2"
942 [(set_attr "type" "imul3")])
944 (define_insn "*macchwu"
945 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
946 (plus:SI (mult:SI (lshiftrt:SI
947 (match_operand:SI 2 "gpc_reg_operand" "r")
950 (match_operand:HI 1 "gpc_reg_operand" "r")))
951 (match_operand:SI 3 "gpc_reg_operand" "0")))]
954 [(set_attr "type" "imul3")])
956 (define_insn "*machhwc"
957 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
958 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
959 (match_operand:SI 1 "gpc_reg_operand" "%r")
962 (match_operand:SI 2 "gpc_reg_operand" "r")
964 (match_operand:SI 4 "gpc_reg_operand" "0"))
966 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
967 (plus:SI (mult:SI (ashiftrt:SI
976 [(set_attr "type" "imul3")])
978 (define_insn "*machhw"
979 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
980 (plus:SI (mult:SI (ashiftrt:SI
981 (match_operand:SI 1 "gpc_reg_operand" "%r")
984 (match_operand:SI 2 "gpc_reg_operand" "r")
986 (match_operand:SI 3 "gpc_reg_operand" "0")))]
989 [(set_attr "type" "imul3")])
991 (define_insn "*machhwuc"
992 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
993 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
994 (match_operand:SI 1 "gpc_reg_operand" "%r")
997 (match_operand:SI 2 "gpc_reg_operand" "r")
999 (match_operand:SI 4 "gpc_reg_operand" "0"))
1001 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1002 (plus:SI (mult:SI (lshiftrt:SI
1010 "machhwu. %0, %1, %2"
1011 [(set_attr "type" "imul3")])
1013 (define_insn "*machhwu"
1014 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1015 (plus:SI (mult:SI (lshiftrt:SI
1016 (match_operand:SI 1 "gpc_reg_operand" "%r")
1019 (match_operand:SI 2 "gpc_reg_operand" "r")
1021 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1023 "machhwu %0, %1, %2"
1024 [(set_attr "type" "imul3")])
1026 (define_insn "*maclhwc"
1027 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1028 (compare:CC (plus:SI (mult:SI (sign_extend:SI
1029 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1031 (match_operand:HI 2 "gpc_reg_operand" "r")))
1032 (match_operand:SI 4 "gpc_reg_operand" "0"))
1034 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1035 (plus:SI (mult:SI (sign_extend:SI
1041 "maclhw. %0, %1, %2"
1042 [(set_attr "type" "imul3")])
1044 (define_insn "*maclhw"
1045 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1046 (plus:SI (mult:SI (sign_extend:SI
1047 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1049 (match_operand:HI 2 "gpc_reg_operand" "r")))
1050 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1053 [(set_attr "type" "imul3")])
1055 (define_insn "*maclhwuc"
1056 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1057 (compare:CC (plus:SI (mult:SI (zero_extend:SI
1058 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1060 (match_operand:HI 2 "gpc_reg_operand" "r")))
1061 (match_operand:SI 4 "gpc_reg_operand" "0"))
1063 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1064 (plus:SI (mult:SI (zero_extend:SI
1070 "maclhwu. %0, %1, %2"
1071 [(set_attr "type" "imul3")])
1073 (define_insn "*maclhwu"
1074 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1075 (plus:SI (mult:SI (zero_extend:SI
1076 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1078 (match_operand:HI 2 "gpc_reg_operand" "r")))
1079 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1081 "maclhwu %0, %1, %2"
1082 [(set_attr "type" "imul3")])
1084 (define_insn "*nmacchwc"
1085 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1086 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1087 (mult:SI (ashiftrt:SI
1088 (match_operand:SI 2 "gpc_reg_operand" "r")
1091 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1093 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1094 (minus:SI (match_dup 4)
1095 (mult:SI (ashiftrt:SI
1101 "nmacchw. %0, %1, %2"
1102 [(set_attr "type" "imul3")])
1104 (define_insn "*nmacchw"
1105 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1106 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1107 (mult:SI (ashiftrt:SI
1108 (match_operand:SI 2 "gpc_reg_operand" "r")
1111 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1113 "nmacchw %0, %1, %2"
1114 [(set_attr "type" "imul3")])
1116 (define_insn "*nmachhwc"
1117 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1118 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1119 (mult:SI (ashiftrt:SI
1120 (match_operand:SI 1 "gpc_reg_operand" "%r")
1123 (match_operand:SI 2 "gpc_reg_operand" "r")
1126 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1127 (minus:SI (match_dup 4)
1128 (mult:SI (ashiftrt:SI
1135 "nmachhw. %0, %1, %2"
1136 [(set_attr "type" "imul3")])
1138 (define_insn "*nmachhw"
1139 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1140 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1141 (mult:SI (ashiftrt:SI
1142 (match_operand:SI 1 "gpc_reg_operand" "%r")
1145 (match_operand:SI 2 "gpc_reg_operand" "r")
1148 "nmachhw %0, %1, %2"
1149 [(set_attr "type" "imul3")])
1151 (define_insn "*nmaclhwc"
1152 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1153 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1154 (mult:SI (sign_extend:SI
1155 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1157 (match_operand:HI 2 "gpc_reg_operand" "r"))))
1159 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1160 (minus:SI (match_dup 4)
1161 (mult:SI (sign_extend:SI
1166 "nmaclhw. %0, %1, %2"
1167 [(set_attr "type" "imul3")])
1169 (define_insn "*nmaclhw"
1170 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1171 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1172 (mult:SI (sign_extend:SI
1173 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1175 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1177 "nmaclhw %0, %1, %2"
1178 [(set_attr "type" "imul3")])
1180 (define_insn "*mulchwc"
1181 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1182 (compare:CC (mult:SI (ashiftrt:SI
1183 (match_operand:SI 2 "gpc_reg_operand" "r")
1186 (match_operand:HI 1 "gpc_reg_operand" "r")))
1188 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1189 (mult:SI (ashiftrt:SI
1195 "mulchw. %0, %1, %2"
1196 [(set_attr "type" "imul3")])
1198 (define_insn "*mulchw"
1199 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1200 (mult:SI (ashiftrt:SI
1201 (match_operand:SI 2 "gpc_reg_operand" "r")
1204 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1207 [(set_attr "type" "imul3")])
1209 (define_insn "*mulchwuc"
1210 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1211 (compare:CC (mult:SI (lshiftrt:SI
1212 (match_operand:SI 2 "gpc_reg_operand" "r")
1215 (match_operand:HI 1 "gpc_reg_operand" "r")))
1217 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1218 (mult:SI (lshiftrt:SI
1224 "mulchwu. %0, %1, %2"
1225 [(set_attr "type" "imul3")])
1227 (define_insn "*mulchwu"
1228 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1229 (mult:SI (lshiftrt:SI
1230 (match_operand:SI 2 "gpc_reg_operand" "r")
1233 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1235 "mulchwu %0, %1, %2"
1236 [(set_attr "type" "imul3")])
1238 (define_insn "*mulhhwc"
1239 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1240 (compare:CC (mult:SI (ashiftrt:SI
1241 (match_operand:SI 1 "gpc_reg_operand" "%r")
1244 (match_operand:SI 2 "gpc_reg_operand" "r")
1247 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1248 (mult:SI (ashiftrt:SI
1255 "mulhhw. %0, %1, %2"
1256 [(set_attr "type" "imul3")])
1258 (define_insn "*mulhhw"
1259 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1260 (mult:SI (ashiftrt:SI
1261 (match_operand:SI 1 "gpc_reg_operand" "%r")
1264 (match_operand:SI 2 "gpc_reg_operand" "r")
1268 [(set_attr "type" "imul3")])
1270 (define_insn "*mulhhwuc"
1271 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1272 (compare:CC (mult:SI (lshiftrt:SI
1273 (match_operand:SI 1 "gpc_reg_operand" "%r")
1276 (match_operand:SI 2 "gpc_reg_operand" "r")
1279 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1280 (mult:SI (lshiftrt:SI
1287 "mulhhwu. %0, %1, %2"
1288 [(set_attr "type" "imul3")])
1290 (define_insn "*mulhhwu"
1291 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1292 (mult:SI (lshiftrt:SI
1293 (match_operand:SI 1 "gpc_reg_operand" "%r")
1296 (match_operand:SI 2 "gpc_reg_operand" "r")
1299 "mulhhwu %0, %1, %2"
1300 [(set_attr "type" "imul3")])
1302 (define_insn "*mullhwc"
1303 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1304 (compare:CC (mult:SI (sign_extend:SI
1305 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1307 (match_operand:HI 2 "gpc_reg_operand" "r")))
1309 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1310 (mult:SI (sign_extend:SI
1315 "mullhw. %0, %1, %2"
1316 [(set_attr "type" "imul3")])
1318 (define_insn "*mullhw"
1319 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1320 (mult:SI (sign_extend:SI
1321 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1323 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1326 [(set_attr "type" "imul3")])
1328 (define_insn "*mullhwuc"
1329 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1330 (compare:CC (mult:SI (zero_extend:SI
1331 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1333 (match_operand:HI 2 "gpc_reg_operand" "r")))
1335 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1336 (mult:SI (zero_extend:SI
1341 "mullhwu. %0, %1, %2"
1342 [(set_attr "type" "imul3")])
1344 (define_insn "*mullhwu"
1345 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1346 (mult:SI (zero_extend:SI
1347 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1349 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1351 "mullhwu %0, %1, %2"
1352 [(set_attr "type" "imul3")])
1354 ;; IBM 405 and 440 string-search dlmzb instruction support.
1355 (define_insn "dlmzb"
1356 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1357 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1358 (match_operand:SI 2 "gpc_reg_operand" "r")]
1360 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1361 (unspec:SI [(match_dup 1)
1365 "dlmzb. %0, %1, %2")
1367 (define_expand "strlensi"
1368 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1369 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1370 (match_operand:QI 2 "const_int_operand" "")
1371 (match_operand 3 "const_int_operand" "")]
1372 UNSPEC_DLMZB_STRLEN))
1373 (clobber (match_scratch:CC 4 "=x"))]
1374 "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1376 rtx result = operands[0];
1377 rtx src = operands[1];
1378 rtx search_char = operands[2];
1379 rtx align = operands[3];
1380 rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1381 rtx loop_label, end_label, mem, cr0, cond;
1382 if (search_char != const0_rtx
1383 || GET_CODE (align) != CONST_INT
1384 || INTVAL (align) < 8)
1386 word1 = gen_reg_rtx (SImode);
1387 word2 = gen_reg_rtx (SImode);
1388 scratch_dlmzb = gen_reg_rtx (SImode);
1389 scratch_string = gen_reg_rtx (Pmode);
1390 loop_label = gen_label_rtx ();
1391 end_label = gen_label_rtx ();
1392 addr = force_reg (Pmode, XEXP (src, 0));
1393 emit_move_insn (scratch_string, addr);
1394 emit_label (loop_label);
1395 mem = change_address (src, SImode, scratch_string);
1396 emit_move_insn (word1, mem);
1397 emit_move_insn (word2, adjust_address (mem, SImode, 4));
1398 cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1399 emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1400 cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1401 emit_jump_insn (gen_rtx_SET (VOIDmode,
1403 gen_rtx_IF_THEN_ELSE (VOIDmode,
1409 emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1410 emit_jump_insn (gen_rtx_SET (VOIDmode,
1412 gen_rtx_LABEL_REF (VOIDmode, loop_label)));
1414 emit_label (end_label);
1415 emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1416 emit_insn (gen_subsi3 (result, scratch_string, addr));
1417 emit_insn (gen_subsi3 (result, result, const1_rtx));
1422 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1423 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1425 (set (match_operand:SI 0 "gpc_reg_operand" "")
1426 (sign_extend:SI (match_dup 1)))]
1429 (sign_extend:SI (match_dup 1)))
1431 (compare:CC (match_dup 0)
1435 ;; Fixed-point arithmetic insns.
1437 (define_expand "add<mode>3"
1438 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1439 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1440 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1443 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1445 if (non_short_cint_operand (operands[2], DImode))
1448 else if (GET_CODE (operands[2]) == CONST_INT
1449 && ! add_operand (operands[2], <MODE>mode))
1451 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
1452 ? operands[0] : gen_reg_rtx (<MODE>mode));
1454 HOST_WIDE_INT val = INTVAL (operands[2]);
1455 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1456 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1458 if (<MODE>mode == DImode && !satisfies_constraint_L (GEN_INT (rest)))
1461 /* The ordering here is important for the prolog expander.
1462 When space is allocated from the stack, adding 'low' first may
1463 produce a temporary deallocation (which would be bad). */
1464 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1465 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1470 ;; Discourage ai/addic because of carry but provide it in an alternative
1471 ;; allowing register zero as source.
1472 (define_insn "*add<mode>3_internal1"
1473 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1474 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1475 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
1479 {cal %0,%2(%1)|addi %0,%1,%2}
1481 {cau|addis} %0,%1,%v2"
1482 [(set_attr "length" "4,4,4,4")])
1484 (define_insn "addsi3_high"
1485 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1486 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1487 (high:SI (match_operand 2 "" ""))))]
1488 "TARGET_MACHO && !TARGET_64BIT"
1489 "{cau|addis} %0,%1,ha16(%2)"
1490 [(set_attr "length" "4")])
1492 (define_insn "*add<mode>3_internal2"
1493 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1494 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1495 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1497 (clobber (match_scratch:P 3 "=r,r,r,r"))]
1500 {cax.|add.} %3,%1,%2
1501 {ai.|addic.} %3,%1,%2
1504 [(set_attr "type" "fast_compare,compare,compare,compare")
1505 (set_attr "length" "4,4,8,8")])
1508 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1509 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1510 (match_operand:GPR 2 "reg_or_short_operand" ""))
1512 (clobber (match_scratch:GPR 3 ""))]
1515 (plus:GPR (match_dup 1)
1518 (compare:CC (match_dup 3)
1522 (define_insn "*add<mode>3_internal3"
1523 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1524 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1525 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1527 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1528 (plus:P (match_dup 1)
1532 {cax.|add.} %0,%1,%2
1533 {ai.|addic.} %0,%1,%2
1536 [(set_attr "type" "fast_compare,compare,compare,compare")
1537 (set_attr "length" "4,4,8,8")])
1540 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1541 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1542 (match_operand:P 2 "reg_or_short_operand" ""))
1544 (set (match_operand:P 0 "gpc_reg_operand" "")
1545 (plus:P (match_dup 1) (match_dup 2)))]
1548 (plus:P (match_dup 1)
1551 (compare:CC (match_dup 0)
1555 ;; Split an add that we can't do in one insn into two insns, each of which
1556 ;; does one 16-bit part. This is used by combine. Note that the low-order
1557 ;; add should be last in case the result gets used in an address.
1560 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1561 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1562 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1564 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1565 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1567 HOST_WIDE_INT val = INTVAL (operands[2]);
1568 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1569 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1571 operands[4] = GEN_INT (low);
1572 if (<MODE>mode == SImode || satisfies_constraint_L (GEN_INT (rest)))
1573 operands[3] = GEN_INT (rest);
1574 else if (! no_new_pseudos)
1576 operands[3] = gen_reg_rtx (DImode);
1577 emit_move_insn (operands[3], operands[2]);
1578 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1585 (define_insn "one_cmpl<mode>2"
1586 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1587 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1592 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1593 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1595 (clobber (match_scratch:P 2 "=r,r"))]
1600 [(set_attr "type" "compare")
1601 (set_attr "length" "4,8")])
1604 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1605 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1607 (clobber (match_scratch:P 2 ""))]
1610 (not:P (match_dup 1)))
1612 (compare:CC (match_dup 2)
1617 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1618 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1620 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1621 (not:P (match_dup 1)))]
1626 [(set_attr "type" "compare")
1627 (set_attr "length" "4,8")])
1630 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1631 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1633 (set (match_operand:P 0 "gpc_reg_operand" "")
1634 (not:P (match_dup 1)))]
1637 (not:P (match_dup 1)))
1639 (compare:CC (match_dup 0)
1644 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1645 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1646 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1648 "{sf%I1|subf%I1c} %0,%2,%1")
1651 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1652 (minus:GPR (match_operand:GPR 1 "reg_or_short_operand" "r,I")
1653 (match_operand:GPR 2 "gpc_reg_operand" "r,r")))]
1660 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1661 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1662 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1664 (clobber (match_scratch:SI 3 "=r,r"))]
1667 {sf.|subfc.} %3,%2,%1
1669 [(set_attr "type" "compare")
1670 (set_attr "length" "4,8")])
1673 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1674 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1675 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1677 (clobber (match_scratch:P 3 "=r,r"))]
1682 [(set_attr "type" "fast_compare")
1683 (set_attr "length" "4,8")])
1686 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1687 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1688 (match_operand:P 2 "gpc_reg_operand" ""))
1690 (clobber (match_scratch:P 3 ""))]
1693 (minus:P (match_dup 1)
1696 (compare:CC (match_dup 3)
1701 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1702 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1703 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1705 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1706 (minus:SI (match_dup 1) (match_dup 2)))]
1709 {sf.|subfc.} %0,%2,%1
1711 [(set_attr "type" "compare")
1712 (set_attr "length" "4,8")])
1715 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1716 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1717 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1719 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1720 (minus:P (match_dup 1)
1726 [(set_attr "type" "fast_compare")
1727 (set_attr "length" "4,8")])
1730 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1731 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1732 (match_operand:P 2 "gpc_reg_operand" ""))
1734 (set (match_operand:P 0 "gpc_reg_operand" "")
1735 (minus:P (match_dup 1)
1739 (minus:P (match_dup 1)
1742 (compare:CC (match_dup 0)
1746 (define_expand "sub<mode>3"
1747 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1748 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1749 (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
1753 if (GET_CODE (operands[2]) == CONST_INT)
1755 emit_insn (gen_add<mode>3 (operands[0], operands[1],
1756 negate_rtx (<MODE>mode, operands[2])));
1761 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1762 ;; instruction and some auxiliary computations. Then we just have a single
1763 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1766 (define_expand "sminsi3"
1768 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1769 (match_operand:SI 2 "reg_or_short_operand" ""))
1771 (minus:SI (match_dup 2) (match_dup 1))))
1772 (set (match_operand:SI 0 "gpc_reg_operand" "")
1773 (minus:SI (match_dup 2) (match_dup 3)))]
1774 "TARGET_POWER || TARGET_ISEL"
1779 operands[2] = force_reg (SImode, operands[2]);
1780 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1784 operands[3] = gen_reg_rtx (SImode);
1788 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1789 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1790 (match_operand:SI 2 "reg_or_short_operand" "")))
1791 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1794 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1796 (minus:SI (match_dup 2) (match_dup 1))))
1797 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1800 (define_expand "smaxsi3"
1802 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1803 (match_operand:SI 2 "reg_or_short_operand" ""))
1805 (minus:SI (match_dup 2) (match_dup 1))))
1806 (set (match_operand:SI 0 "gpc_reg_operand" "")
1807 (plus:SI (match_dup 3) (match_dup 1)))]
1808 "TARGET_POWER || TARGET_ISEL"
1813 operands[2] = force_reg (SImode, operands[2]);
1814 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1817 operands[3] = gen_reg_rtx (SImode);
1821 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1822 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1823 (match_operand:SI 2 "reg_or_short_operand" "")))
1824 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1827 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1829 (minus:SI (match_dup 2) (match_dup 1))))
1830 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1833 (define_expand "uminsi3"
1834 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1836 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1838 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1840 (minus:SI (match_dup 4) (match_dup 3))))
1841 (set (match_operand:SI 0 "gpc_reg_operand" "")
1842 (minus:SI (match_dup 2) (match_dup 3)))]
1843 "TARGET_POWER || TARGET_ISEL"
1848 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1851 operands[3] = gen_reg_rtx (SImode);
1852 operands[4] = gen_reg_rtx (SImode);
1853 operands[5] = GEN_INT (-2147483647 - 1);
1856 (define_expand "umaxsi3"
1857 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1859 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1861 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1863 (minus:SI (match_dup 4) (match_dup 3))))
1864 (set (match_operand:SI 0 "gpc_reg_operand" "")
1865 (plus:SI (match_dup 3) (match_dup 1)))]
1866 "TARGET_POWER || TARGET_ISEL"
1871 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1874 operands[3] = gen_reg_rtx (SImode);
1875 operands[4] = gen_reg_rtx (SImode);
1876 operands[5] = GEN_INT (-2147483647 - 1);
1880 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1881 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1882 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1884 (minus:SI (match_dup 2) (match_dup 1))))]
1889 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1891 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1892 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1894 (minus:SI (match_dup 2) (match_dup 1)))
1896 (clobber (match_scratch:SI 3 "=r,r"))]
1901 [(set_attr "type" "delayed_compare")
1902 (set_attr "length" "4,8")])
1905 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1907 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1908 (match_operand:SI 2 "reg_or_short_operand" ""))
1910 (minus:SI (match_dup 2) (match_dup 1)))
1912 (clobber (match_scratch:SI 3 ""))]
1913 "TARGET_POWER && reload_completed"
1915 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1917 (minus:SI (match_dup 2) (match_dup 1))))
1919 (compare:CC (match_dup 3)
1924 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1926 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1927 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1929 (minus:SI (match_dup 2) (match_dup 1)))
1931 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1932 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1934 (minus:SI (match_dup 2) (match_dup 1))))]
1939 [(set_attr "type" "delayed_compare")
1940 (set_attr "length" "4,8")])
1943 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1945 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1946 (match_operand:SI 2 "reg_or_short_operand" ""))
1948 (minus:SI (match_dup 2) (match_dup 1)))
1950 (set (match_operand:SI 0 "gpc_reg_operand" "")
1951 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1953 (minus:SI (match_dup 2) (match_dup 1))))]
1954 "TARGET_POWER && reload_completed"
1956 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1958 (minus:SI (match_dup 2) (match_dup 1))))
1960 (compare:CC (match_dup 0)
1964 ;; We don't need abs with condition code because such comparisons should
1966 (define_expand "abssi2"
1967 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1968 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1974 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
1977 else if (! TARGET_POWER)
1979 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
1984 (define_insn "*abssi2_power"
1985 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1986 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1990 (define_insn_and_split "abssi2_isel"
1991 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1992 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
1993 (clobber (match_scratch:SI 2 "=&b"))
1994 (clobber (match_scratch:CC 3 "=y"))]
1997 "&& reload_completed"
1998 [(set (match_dup 2) (neg:SI (match_dup 1)))
2000 (compare:CC (match_dup 1)
2003 (if_then_else:SI (ge (match_dup 3)
2009 (define_insn_and_split "abssi2_nopower"
2010 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2011 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
2012 (clobber (match_scratch:SI 2 "=&r,&r"))]
2013 "! TARGET_POWER && ! TARGET_ISEL"
2015 "&& reload_completed"
2016 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2017 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2018 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
2021 (define_insn "*nabs_power"
2022 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2023 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
2027 (define_insn_and_split "*nabs_nopower"
2028 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2029 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
2030 (clobber (match_scratch:SI 2 "=&r,&r"))]
2033 "&& reload_completed"
2034 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2035 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2036 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
2039 (define_expand "neg<mode>2"
2040 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2041 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
2045 (define_insn "*neg<mode>2_internal"
2046 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2047 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2052 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2053 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2055 (clobber (match_scratch:P 2 "=r,r"))]
2060 [(set_attr "type" "fast_compare")
2061 (set_attr "length" "4,8")])
2064 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2065 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2067 (clobber (match_scratch:P 2 ""))]
2070 (neg:P (match_dup 1)))
2072 (compare:CC (match_dup 2)
2077 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2078 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2080 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2081 (neg:P (match_dup 1)))]
2086 [(set_attr "type" "fast_compare")
2087 (set_attr "length" "4,8")])
2090 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2091 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2093 (set (match_operand:P 0 "gpc_reg_operand" "")
2094 (neg:P (match_dup 1)))]
2097 (neg:P (match_dup 1)))
2099 (compare:CC (match_dup 0)
2103 (define_insn "clz<mode>2"
2104 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2105 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2107 "{cntlz|cntlz<wd>} %0,%1"
2108 [(set_attr "type" "cntlz")])
2110 (define_expand "ctz<mode>2"
2112 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))
2113 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2115 (clobber (scratch:CC))])
2116 (set (match_dup 4) (clz:GPR (match_dup 3)))
2117 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2118 (minus:GPR (match_dup 5) (match_dup 4)))]
2121 operands[2] = gen_reg_rtx (<MODE>mode);
2122 operands[3] = gen_reg_rtx (<MODE>mode);
2123 operands[4] = gen_reg_rtx (<MODE>mode);
2124 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
2127 (define_expand "ffs<mode>2"
2129 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))
2130 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2132 (clobber (scratch:CC))])
2133 (set (match_dup 4) (clz:GPR (match_dup 3)))
2134 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2135 (minus:GPR (match_dup 5) (match_dup 4)))]
2138 operands[2] = gen_reg_rtx (<MODE>mode);
2139 operands[3] = gen_reg_rtx (<MODE>mode);
2140 operands[4] = gen_reg_rtx (<MODE>mode);
2141 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
2144 (define_expand "popcount<mode>2"
2146 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2149 (mult:GPR (match_dup 2) (match_dup 4)))
2150 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2151 (lshiftrt:GPR (match_dup 3) (match_dup 5)))]
2154 operands[2] = gen_reg_rtx (<MODE>mode);
2155 operands[3] = gen_reg_rtx (<MODE>mode);
2156 operands[4] = force_reg (<MODE>mode,
2157 <MODE>mode == SImode
2158 ? GEN_INT (0x01010101)
2159 : GEN_INT ((HOST_WIDE_INT)
2160 0x01010101 << 32 | 0x01010101));
2161 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 8);
2164 (define_insn "popcntb<mode>2"
2165 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2166 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2171 (define_expand "mulsi3"
2172 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2173 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2174 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2179 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2181 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2185 (define_insn "mulsi3_mq"
2186 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2187 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2188 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2189 (clobber (match_scratch:SI 3 "=q,q"))]
2192 {muls|mullw} %0,%1,%2
2193 {muli|mulli} %0,%1,%2"
2195 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2196 (const_string "imul3")
2197 (match_operand:SI 2 "short_cint_operand" "")
2198 (const_string "imul2")]
2199 (const_string "imul")))])
2201 (define_insn "mulsi3_no_mq"
2202 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2203 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2204 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2207 {muls|mullw} %0,%1,%2
2208 {muli|mulli} %0,%1,%2"
2210 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2211 (const_string "imul3")
2212 (match_operand:SI 2 "short_cint_operand" "")
2213 (const_string "imul2")]
2214 (const_string "imul")))])
2216 (define_insn "*mulsi3_mq_internal1"
2217 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2218 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2219 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2221 (clobber (match_scratch:SI 3 "=r,r"))
2222 (clobber (match_scratch:SI 4 "=q,q"))]
2225 {muls.|mullw.} %3,%1,%2
2227 [(set_attr "type" "imul_compare")
2228 (set_attr "length" "4,8")])
2231 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2232 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2233 (match_operand:SI 2 "gpc_reg_operand" ""))
2235 (clobber (match_scratch:SI 3 ""))
2236 (clobber (match_scratch:SI 4 ""))]
2237 "TARGET_POWER && reload_completed"
2238 [(parallel [(set (match_dup 3)
2239 (mult:SI (match_dup 1) (match_dup 2)))
2240 (clobber (match_dup 4))])
2242 (compare:CC (match_dup 3)
2246 (define_insn "*mulsi3_no_mq_internal1"
2247 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2248 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2249 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2251 (clobber (match_scratch:SI 3 "=r,r"))]
2254 {muls.|mullw.} %3,%1,%2
2256 [(set_attr "type" "imul_compare")
2257 (set_attr "length" "4,8")])
2260 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2261 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2262 (match_operand:SI 2 "gpc_reg_operand" ""))
2264 (clobber (match_scratch:SI 3 ""))]
2265 "! TARGET_POWER && reload_completed"
2267 (mult:SI (match_dup 1) (match_dup 2)))
2269 (compare:CC (match_dup 3)
2273 (define_insn "*mulsi3_mq_internal2"
2274 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2275 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2276 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2278 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2279 (mult:SI (match_dup 1) (match_dup 2)))
2280 (clobber (match_scratch:SI 4 "=q,q"))]
2283 {muls.|mullw.} %0,%1,%2
2285 [(set_attr "type" "imul_compare")
2286 (set_attr "length" "4,8")])
2289 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2290 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2291 (match_operand:SI 2 "gpc_reg_operand" ""))
2293 (set (match_operand:SI 0 "gpc_reg_operand" "")
2294 (mult:SI (match_dup 1) (match_dup 2)))
2295 (clobber (match_scratch:SI 4 ""))]
2296 "TARGET_POWER && reload_completed"
2297 [(parallel [(set (match_dup 0)
2298 (mult:SI (match_dup 1) (match_dup 2)))
2299 (clobber (match_dup 4))])
2301 (compare:CC (match_dup 0)
2305 (define_insn "*mulsi3_no_mq_internal2"
2306 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2307 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2308 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2310 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2311 (mult:SI (match_dup 1) (match_dup 2)))]
2314 {muls.|mullw.} %0,%1,%2
2316 [(set_attr "type" "imul_compare")
2317 (set_attr "length" "4,8")])
2320 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2321 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2322 (match_operand:SI 2 "gpc_reg_operand" ""))
2324 (set (match_operand:SI 0 "gpc_reg_operand" "")
2325 (mult:SI (match_dup 1) (match_dup 2)))]
2326 "! TARGET_POWER && reload_completed"
2328 (mult:SI (match_dup 1) (match_dup 2)))
2330 (compare:CC (match_dup 0)
2334 ;; Operand 1 is divided by operand 2; quotient goes to operand
2335 ;; 0 and remainder to operand 3.
2336 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2338 (define_expand "divmodsi4"
2339 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2340 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2341 (match_operand:SI 2 "gpc_reg_operand" "")))
2342 (set (match_operand:SI 3 "register_operand" "")
2343 (mod:SI (match_dup 1) (match_dup 2)))])]
2344 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2347 if (! TARGET_POWER && ! TARGET_POWERPC)
2349 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2350 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2351 emit_insn (gen_divss_call ());
2352 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2353 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2358 (define_insn "*divmodsi4_internal"
2359 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2360 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2361 (match_operand:SI 2 "gpc_reg_operand" "r")))
2362 (set (match_operand:SI 3 "register_operand" "=q")
2363 (mod:SI (match_dup 1) (match_dup 2)))]
2366 [(set_attr "type" "idiv")])
2368 (define_expand "udiv<mode>3"
2369 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2370 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2371 (match_operand:GPR 2 "gpc_reg_operand" "")))]
2372 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2375 if (! TARGET_POWER && ! TARGET_POWERPC)
2377 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2378 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2379 emit_insn (gen_quous_call ());
2380 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2383 else if (TARGET_POWER)
2385 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2390 (define_insn "udivsi3_mq"
2391 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2392 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2393 (match_operand:SI 2 "gpc_reg_operand" "r")))
2394 (clobber (match_scratch:SI 3 "=q"))]
2395 "TARGET_POWERPC && TARGET_POWER"
2397 [(set_attr "type" "idiv")])
2399 (define_insn "*udivsi3_no_mq"
2400 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2401 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2402 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2403 "TARGET_POWERPC && ! TARGET_POWER"
2406 (cond [(match_operand:SI 0 "" "")
2407 (const_string "idiv")]
2408 (const_string "ldiv")))])
2411 ;; For powers of two we can do srai/aze for divide and then adjust for
2412 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2413 ;; used; for PowerPC, force operands into register and do a normal divide;
2414 ;; for AIX common-mode, use quoss call on register operands.
2415 (define_expand "div<mode>3"
2416 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2417 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2418 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2422 if (GET_CODE (operands[2]) == CONST_INT
2423 && INTVAL (operands[2]) > 0
2424 && exact_log2 (INTVAL (operands[2])) >= 0)
2426 else if (TARGET_POWERPC)
2428 operands[2] = force_reg (SImode, operands[2]);
2431 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2435 else if (TARGET_POWER)
2439 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2440 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2441 emit_insn (gen_quoss_call ());
2442 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2447 (define_insn "divsi3_mq"
2448 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2449 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2450 (match_operand:SI 2 "gpc_reg_operand" "r")))
2451 (clobber (match_scratch:SI 3 "=q"))]
2452 "TARGET_POWERPC && TARGET_POWER"
2454 [(set_attr "type" "idiv")])
2456 (define_insn "*div<mode>3_no_mq"
2457 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2458 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2459 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2460 "TARGET_POWERPC && ! TARGET_POWER"
2463 (cond [(match_operand:SI 0 "" "")
2464 (const_string "idiv")]
2465 (const_string "ldiv")))])
2467 (define_expand "mod<mode>3"
2468 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2469 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2470 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
2478 if (GET_CODE (operands[2]) != CONST_INT
2479 || INTVAL (operands[2]) <= 0
2480 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2483 temp1 = gen_reg_rtx (<MODE>mode);
2484 temp2 = gen_reg_rtx (<MODE>mode);
2486 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2487 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2488 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
2493 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2494 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2495 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
2497 "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
2498 [(set_attr "type" "two")
2499 (set_attr "length" "8")])
2502 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2503 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2504 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2506 (clobber (match_scratch:P 3 "=r,r"))]
2509 {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
2511 [(set_attr "type" "compare")
2512 (set_attr "length" "8,12")])
2515 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2516 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2517 (match_operand:GPR 2 "exact_log2_cint_operand"
2520 (clobber (match_scratch:GPR 3 ""))]
2523 (div:<MODE> (match_dup 1) (match_dup 2)))
2525 (compare:CC (match_dup 3)
2530 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2531 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2532 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2534 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2535 (div:P (match_dup 1) (match_dup 2)))]
2538 {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
2540 [(set_attr "type" "compare")
2541 (set_attr "length" "8,12")])
2544 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2545 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2546 (match_operand:GPR 2 "exact_log2_cint_operand"
2549 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2550 (div:GPR (match_dup 1) (match_dup 2)))]
2553 (div:<MODE> (match_dup 1) (match_dup 2)))
2555 (compare:CC (match_dup 0)
2560 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2563 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2565 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2566 (match_operand:SI 3 "gpc_reg_operand" "r")))
2567 (set (match_operand:SI 2 "register_operand" "=*q")
2570 (zero_extend:DI (match_dup 1)) (const_int 32))
2571 (zero_extend:DI (match_dup 4)))
2575 [(set_attr "type" "idiv")])
2577 ;; To do unsigned divide we handle the cases of the divisor looking like a
2578 ;; negative number. If it is a constant that is less than 2**31, we don't
2579 ;; have to worry about the branches. So make a few subroutines here.
2581 ;; First comes the normal case.
2582 (define_expand "udivmodsi4_normal"
2583 [(set (match_dup 4) (const_int 0))
2584 (parallel [(set (match_operand:SI 0 "" "")
2585 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2587 (zero_extend:DI (match_operand:SI 1 "" "")))
2588 (match_operand:SI 2 "" "")))
2589 (set (match_operand:SI 3 "" "")
2590 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2592 (zero_extend:DI (match_dup 1)))
2596 { operands[4] = gen_reg_rtx (SImode); }")
2598 ;; This handles the branches.
2599 (define_expand "udivmodsi4_tests"
2600 [(set (match_operand:SI 0 "" "") (const_int 0))
2601 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2602 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2603 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2604 (label_ref (match_operand:SI 4 "" "")) (pc)))
2605 (set (match_dup 0) (const_int 1))
2606 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2607 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2608 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2609 (label_ref (match_dup 4)) (pc)))]
2612 { operands[5] = gen_reg_rtx (CCUNSmode);
2613 operands[6] = gen_reg_rtx (CCmode);
2616 (define_expand "udivmodsi4"
2617 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2618 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2619 (match_operand:SI 2 "reg_or_cint_operand" "")))
2620 (set (match_operand:SI 3 "gpc_reg_operand" "")
2621 (umod:SI (match_dup 1) (match_dup 2)))])]
2629 if (! TARGET_POWERPC)
2631 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2632 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2633 emit_insn (gen_divus_call ());
2634 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2635 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2642 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2644 operands[2] = force_reg (SImode, operands[2]);
2645 label = gen_label_rtx ();
2646 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2647 operands[3], label));
2650 operands[2] = force_reg (SImode, operands[2]);
2652 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2660 ;; AIX architecture-independent common-mode multiply (DImode),
2661 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2662 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2663 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2664 ;; assumed unused if generating common-mode, so ignore.
2665 (define_insn "mulh_call"
2668 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2669 (sign_extend:DI (reg:SI 4)))
2671 (clobber (match_scratch:SI 0 "=l"))]
2672 "! TARGET_POWER && ! TARGET_POWERPC"
2674 [(set_attr "type" "imul")])
2676 (define_insn "mull_call"
2678 (mult:DI (sign_extend:DI (reg:SI 3))
2679 (sign_extend:DI (reg:SI 4))))
2680 (clobber (match_scratch:SI 0 "=l"))
2681 (clobber (reg:SI 0))]
2682 "! TARGET_POWER && ! TARGET_POWERPC"
2684 [(set_attr "type" "imul")])
2686 (define_insn "divss_call"
2688 (div:SI (reg:SI 3) (reg:SI 4)))
2690 (mod:SI (reg:SI 3) (reg:SI 4)))
2691 (clobber (match_scratch:SI 0 "=l"))
2692 (clobber (reg:SI 0))]
2693 "! TARGET_POWER && ! TARGET_POWERPC"
2695 [(set_attr "type" "idiv")])
2697 (define_insn "divus_call"
2699 (udiv:SI (reg:SI 3) (reg:SI 4)))
2701 (umod:SI (reg:SI 3) (reg:SI 4)))
2702 (clobber (match_scratch:SI 0 "=l"))
2703 (clobber (reg:SI 0))
2704 (clobber (match_scratch:CC 1 "=x"))
2705 (clobber (reg:CC 69))]
2706 "! TARGET_POWER && ! TARGET_POWERPC"
2708 [(set_attr "type" "idiv")])
2710 (define_insn "quoss_call"
2712 (div:SI (reg:SI 3) (reg:SI 4)))
2713 (clobber (match_scratch:SI 0 "=l"))]
2714 "! TARGET_POWER && ! TARGET_POWERPC"
2716 [(set_attr "type" "idiv")])
2718 (define_insn "quous_call"
2720 (udiv:SI (reg:SI 3) (reg:SI 4)))
2721 (clobber (match_scratch:SI 0 "=l"))
2722 (clobber (reg:SI 0))
2723 (clobber (match_scratch:CC 1 "=x"))
2724 (clobber (reg:CC 69))]
2725 "! TARGET_POWER && ! TARGET_POWERPC"
2727 [(set_attr "type" "idiv")])
2729 ;; Logical instructions
2730 ;; The logical instructions are mostly combined by using match_operator,
2731 ;; but the plain AND insns are somewhat different because there is no
2732 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2733 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2735 (define_insn "andsi3"
2736 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2737 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2738 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2739 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2743 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2744 {andil.|andi.} %0,%1,%b2
2745 {andiu.|andis.} %0,%1,%u2"
2746 [(set_attr "type" "*,*,compare,compare")])
2748 ;; Note to set cr's other than cr0 we do the and immediate and then
2749 ;; the test again -- this avoids a mfcr which on the higher end
2750 ;; machines causes an execution serialization
2752 (define_insn "*andsi3_internal2"
2753 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2754 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2755 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2757 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2758 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2762 {andil.|andi.} %3,%1,%b2
2763 {andiu.|andis.} %3,%1,%u2
2764 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2769 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2770 (set_attr "length" "4,4,4,4,8,8,8,8")])
2772 (define_insn "*andsi3_internal3"
2773 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2774 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2775 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2777 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2778 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2782 {andil.|andi.} %3,%1,%b2
2783 {andiu.|andis.} %3,%1,%u2
2784 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2789 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2790 (set_attr "length" "8,4,4,4,8,8,8,8")])
2793 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2794 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2795 (match_operand:GPR 2 "and_operand" ""))
2797 (clobber (match_scratch:GPR 3 ""))
2798 (clobber (match_scratch:CC 4 ""))]
2800 [(parallel [(set (match_dup 3)
2801 (and:<MODE> (match_dup 1)
2803 (clobber (match_dup 4))])
2805 (compare:CC (match_dup 3)
2809 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2810 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2813 [(set (match_operand:CC 0 "cc_reg_operand" "")
2814 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2815 (match_operand:SI 2 "gpc_reg_operand" ""))
2817 (clobber (match_scratch:SI 3 ""))
2818 (clobber (match_scratch:CC 4 ""))]
2819 "TARGET_POWERPC64 && reload_completed"
2820 [(parallel [(set (match_dup 3)
2821 (and:SI (match_dup 1)
2823 (clobber (match_dup 4))])
2825 (compare:CC (match_dup 3)
2829 (define_insn "*andsi3_internal4"
2830 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2831 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2832 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2834 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2835 (and:SI (match_dup 1)
2837 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2841 {andil.|andi.} %0,%1,%b2
2842 {andiu.|andis.} %0,%1,%u2
2843 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2848 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2849 (set_attr "length" "4,4,4,4,8,8,8,8")])
2851 (define_insn "*andsi3_internal5"
2852 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2853 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2854 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2856 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2857 (and:SI (match_dup 1)
2859 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2863 {andil.|andi.} %0,%1,%b2
2864 {andiu.|andis.} %0,%1,%u2
2865 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2870 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2871 (set_attr "length" "8,4,4,4,8,8,8,8")])
2874 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2875 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2876 (match_operand:SI 2 "and_operand" ""))
2878 (set (match_operand:SI 0 "gpc_reg_operand" "")
2879 (and:SI (match_dup 1)
2881 (clobber (match_scratch:CC 4 ""))]
2883 [(parallel [(set (match_dup 0)
2884 (and:SI (match_dup 1)
2886 (clobber (match_dup 4))])
2888 (compare:CC (match_dup 0)
2893 [(set (match_operand:CC 3 "cc_reg_operand" "")
2894 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2895 (match_operand:SI 2 "gpc_reg_operand" ""))
2897 (set (match_operand:SI 0 "gpc_reg_operand" "")
2898 (and:SI (match_dup 1)
2900 (clobber (match_scratch:CC 4 ""))]
2901 "TARGET_POWERPC64 && reload_completed"
2902 [(parallel [(set (match_dup 0)
2903 (and:SI (match_dup 1)
2905 (clobber (match_dup 4))])
2907 (compare:CC (match_dup 0)
2911 ;; Handle the PowerPC64 rlwinm corner case
2913 (define_insn_and_split "*andsi3_internal6"
2914 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2915 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2916 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2921 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2924 (rotate:SI (match_dup 0) (match_dup 5)))]
2927 int mb = extract_MB (operands[2]);
2928 int me = extract_ME (operands[2]);
2929 operands[3] = GEN_INT (me + 1);
2930 operands[5] = GEN_INT (32 - (me + 1));
2931 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2933 [(set_attr "length" "8")])
2935 (define_expand "iorsi3"
2936 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2937 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
2938 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2942 if (GET_CODE (operands[2]) == CONST_INT
2943 && ! logical_operand (operands[2], SImode))
2945 HOST_WIDE_INT value = INTVAL (operands[2]);
2946 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2947 ? operands[0] : gen_reg_rtx (SImode));
2949 emit_insn (gen_iorsi3 (tmp, operands[1],
2950 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2951 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2956 (define_expand "xorsi3"
2957 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2958 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2959 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2963 if (GET_CODE (operands[2]) == CONST_INT
2964 && ! logical_operand (operands[2], SImode))
2966 HOST_WIDE_INT value = INTVAL (operands[2]);
2967 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2968 ? operands[0] : gen_reg_rtx (SImode));
2970 emit_insn (gen_xorsi3 (tmp, operands[1],
2971 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2972 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2977 (define_insn "*boolsi3_internal1"
2978 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2979 (match_operator:SI 3 "boolean_or_operator"
2980 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
2981 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
2985 {%q3il|%q3i} %0,%1,%b2
2986 {%q3iu|%q3is} %0,%1,%u2")
2988 (define_insn "*boolsi3_internal2"
2989 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2990 (compare:CC (match_operator:SI 4 "boolean_or_operator"
2991 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2992 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2994 (clobber (match_scratch:SI 3 "=r,r"))]
2999 [(set_attr "type" "compare")
3000 (set_attr "length" "4,8")])
3003 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3004 (compare:CC (match_operator:SI 4 "boolean_operator"
3005 [(match_operand:SI 1 "gpc_reg_operand" "")
3006 (match_operand:SI 2 "gpc_reg_operand" "")])
3008 (clobber (match_scratch:SI 3 ""))]
3009 "TARGET_32BIT && reload_completed"
3010 [(set (match_dup 3) (match_dup 4))
3012 (compare:CC (match_dup 3)
3016 (define_insn "*boolsi3_internal3"
3017 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3018 (compare:CC (match_operator:SI 4 "boolean_operator"
3019 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3020 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3022 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3028 [(set_attr "type" "compare")
3029 (set_attr "length" "4,8")])
3032 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3033 (compare:CC (match_operator:SI 4 "boolean_operator"
3034 [(match_operand:SI 1 "gpc_reg_operand" "")
3035 (match_operand:SI 2 "gpc_reg_operand" "")])
3037 (set (match_operand:SI 0 "gpc_reg_operand" "")
3039 "TARGET_32BIT && reload_completed"
3040 [(set (match_dup 0) (match_dup 4))
3042 (compare:CC (match_dup 0)
3046 ;; Split a logical operation that we can't do in one insn into two insns,
3047 ;; each of which does one 16-bit part. This is used by combine.
3050 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3051 (match_operator:SI 3 "boolean_or_operator"
3052 [(match_operand:SI 1 "gpc_reg_operand" "")
3053 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
3055 [(set (match_dup 0) (match_dup 4))
3056 (set (match_dup 0) (match_dup 5))]
3060 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
3061 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3063 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
3064 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3068 (define_insn "*boolcsi3_internal1"
3069 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3070 (match_operator:SI 3 "boolean_operator"
3071 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3072 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
3076 (define_insn "*boolcsi3_internal2"
3077 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3078 (compare:CC (match_operator:SI 4 "boolean_operator"
3079 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3080 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3082 (clobber (match_scratch:SI 3 "=r,r"))]
3087 [(set_attr "type" "compare")
3088 (set_attr "length" "4,8")])
3091 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3092 (compare:CC (match_operator:SI 4 "boolean_operator"
3093 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3094 (match_operand:SI 2 "gpc_reg_operand" "")])
3096 (clobber (match_scratch:SI 3 ""))]
3097 "TARGET_32BIT && reload_completed"
3098 [(set (match_dup 3) (match_dup 4))
3100 (compare:CC (match_dup 3)
3104 (define_insn "*boolcsi3_internal3"
3105 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3106 (compare:CC (match_operator:SI 4 "boolean_operator"
3107 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3108 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3110 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3116 [(set_attr "type" "compare")
3117 (set_attr "length" "4,8")])
3120 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3121 (compare:CC (match_operator:SI 4 "boolean_operator"
3122 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3123 (match_operand:SI 2 "gpc_reg_operand" "")])
3125 (set (match_operand:SI 0 "gpc_reg_operand" "")
3127 "TARGET_32BIT && reload_completed"
3128 [(set (match_dup 0) (match_dup 4))
3130 (compare:CC (match_dup 0)
3134 (define_insn "*boolccsi3_internal1"
3135 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3136 (match_operator:SI 3 "boolean_operator"
3137 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3138 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3142 (define_insn "*boolccsi3_internal2"
3143 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3144 (compare:CC (match_operator:SI 4 "boolean_operator"
3145 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3146 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3148 (clobber (match_scratch:SI 3 "=r,r"))]
3153 [(set_attr "type" "compare")
3154 (set_attr "length" "4,8")])
3157 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3158 (compare:CC (match_operator:SI 4 "boolean_operator"
3159 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3160 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3162 (clobber (match_scratch:SI 3 ""))]
3163 "TARGET_32BIT && reload_completed"
3164 [(set (match_dup 3) (match_dup 4))
3166 (compare:CC (match_dup 3)
3170 (define_insn "*boolccsi3_internal3"
3171 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3172 (compare:CC (match_operator:SI 4 "boolean_operator"
3173 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3174 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3176 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3182 [(set_attr "type" "compare")
3183 (set_attr "length" "4,8")])
3186 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3187 (compare:CC (match_operator:SI 4 "boolean_operator"
3188 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3189 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3191 (set (match_operand:SI 0 "gpc_reg_operand" "")
3193 "TARGET_32BIT && reload_completed"
3194 [(set (match_dup 0) (match_dup 4))
3196 (compare:CC (match_dup 0)
3200 ;; maskir insn. We need four forms because things might be in arbitrary
3201 ;; orders. Don't define forms that only set CR fields because these
3202 ;; would modify an input register.
3204 (define_insn "*maskir_internal1"
3205 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3206 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3207 (match_operand:SI 1 "gpc_reg_operand" "0"))
3208 (and:SI (match_dup 2)
3209 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
3213 (define_insn "*maskir_internal2"
3214 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3215 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3216 (match_operand:SI 1 "gpc_reg_operand" "0"))
3217 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3222 (define_insn "*maskir_internal3"
3223 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3224 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
3225 (match_operand:SI 3 "gpc_reg_operand" "r"))
3226 (and:SI (not:SI (match_dup 2))
3227 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3231 (define_insn "*maskir_internal4"
3232 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3233 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3234 (match_operand:SI 2 "gpc_reg_operand" "r"))
3235 (and:SI (not:SI (match_dup 2))
3236 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3240 (define_insn "*maskir_internal5"
3241 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3243 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3244 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3245 (and:SI (match_dup 2)
3246 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
3248 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3249 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3250 (and:SI (match_dup 2) (match_dup 3))))]
3255 [(set_attr "type" "compare")
3256 (set_attr "length" "4,8")])
3259 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3261 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3262 (match_operand:SI 1 "gpc_reg_operand" ""))
3263 (and:SI (match_dup 2)
3264 (match_operand:SI 3 "gpc_reg_operand" "")))
3266 (set (match_operand:SI 0 "gpc_reg_operand" "")
3267 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3268 (and:SI (match_dup 2) (match_dup 3))))]
3269 "TARGET_POWER && reload_completed"
3271 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3272 (and:SI (match_dup 2) (match_dup 3))))
3274 (compare:CC (match_dup 0)
3278 (define_insn "*maskir_internal6"
3279 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3281 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3282 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3283 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3286 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3287 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3288 (and:SI (match_dup 3) (match_dup 2))))]
3293 [(set_attr "type" "compare")
3294 (set_attr "length" "4,8")])
3297 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3299 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3300 (match_operand:SI 1 "gpc_reg_operand" ""))
3301 (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3304 (set (match_operand:SI 0 "gpc_reg_operand" "")
3305 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3306 (and:SI (match_dup 3) (match_dup 2))))]
3307 "TARGET_POWER && reload_completed"
3309 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3310 (and:SI (match_dup 3) (match_dup 2))))
3312 (compare:CC (match_dup 0)
3316 (define_insn "*maskir_internal7"
3317 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3319 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
3320 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
3321 (and:SI (not:SI (match_dup 2))
3322 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3324 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3325 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3326 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3331 [(set_attr "type" "compare")
3332 (set_attr "length" "4,8")])
3335 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3337 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
3338 (match_operand:SI 3 "gpc_reg_operand" ""))
3339 (and:SI (not:SI (match_dup 2))
3340 (match_operand:SI 1 "gpc_reg_operand" "")))
3342 (set (match_operand:SI 0 "gpc_reg_operand" "")
3343 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3344 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3345 "TARGET_POWER && reload_completed"
3347 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3348 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3350 (compare:CC (match_dup 0)
3354 (define_insn "*maskir_internal8"
3355 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3357 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3358 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3359 (and:SI (not:SI (match_dup 2))
3360 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3362 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3363 (ior:SI (and:SI (match_dup 3) (match_dup 2))
3364 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3369 [(set_attr "type" "compare")
3370 (set_attr "length" "4,8")])
3373 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3375 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3376 (match_operand:SI 2 "gpc_reg_operand" ""))
3377 (and:SI (not:SI (match_dup 2))
3378 (match_operand:SI 1 "gpc_reg_operand" "")))
3380 (set (match_operand:SI 0 "gpc_reg_operand" "")
3381 (ior:SI (and:SI (match_dup 3) (match_dup 2))
3382 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3383 "TARGET_POWER && reload_completed"
3385 (ior:SI (and:SI (match_dup 3) (match_dup 2))
3386 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3388 (compare:CC (match_dup 0)
3392 ;; Rotate and shift insns, in all their variants. These support shifts,
3393 ;; field inserts and extracts, and various combinations thereof.
3394 (define_expand "insv"
3395 [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
3396 (match_operand:SI 1 "const_int_operand" "")
3397 (match_operand:SI 2 "const_int_operand" ""))
3398 (match_operand 3 "gpc_reg_operand" ""))]
3402 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3403 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3404 compiler if the address of the structure is taken later. */
3405 if (GET_CODE (operands[0]) == SUBREG
3406 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3409 if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
3410 emit_insn (gen_insvdi (operands[0], operands[1], operands[2], operands[3]));
3412 emit_insn (gen_insvsi (operands[0], operands[1], operands[2], operands[3]));
3416 (define_insn "insvsi"
3417 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3418 (match_operand:SI 1 "const_int_operand" "i")
3419 (match_operand:SI 2 "const_int_operand" "i"))
3420 (match_operand:SI 3 "gpc_reg_operand" "r"))]
3424 int start = INTVAL (operands[2]) & 31;
3425 int size = INTVAL (operands[1]) & 31;
3427 operands[4] = GEN_INT (32 - start - size);
3428 operands[1] = GEN_INT (start + size - 1);
3429 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3431 [(set_attr "type" "insert_word")])
3433 (define_insn "*insvsi_internal1"
3434 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3435 (match_operand:SI 1 "const_int_operand" "i")
3436 (match_operand:SI 2 "const_int_operand" "i"))
3437 (rotate:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3438 (match_operand:SI 4 "const_int_operand" "i")))]
3439 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3442 int shift = INTVAL (operands[4]) & 31;
3443 int start = INTVAL (operands[2]) & 31;
3444 int size = INTVAL (operands[1]) & 31;
3446 operands[4] = GEN_INT (shift - start - size);
3447 operands[1] = GEN_INT (start + size - 1);
3448 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3450 [(set_attr "type" "insert_word")])
3452 (define_insn "*insvsi_internal2"
3453 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3454 (match_operand:SI 1 "const_int_operand" "i")
3455 (match_operand:SI 2 "const_int_operand" "i"))
3456 (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3457 (match_operand:SI 4 "const_int_operand" "i")))]
3458 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3461 int shift = INTVAL (operands[4]) & 31;
3462 int start = INTVAL (operands[2]) & 31;
3463 int size = INTVAL (operands[1]) & 31;
3465 operands[4] = GEN_INT (32 - shift - start - size);
3466 operands[1] = GEN_INT (start + size - 1);
3467 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3469 [(set_attr "type" "insert_word")])
3471 (define_insn "*insvsi_internal3"
3472 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3473 (match_operand:SI 1 "const_int_operand" "i")
3474 (match_operand:SI 2 "const_int_operand" "i"))
3475 (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3476 (match_operand:SI 4 "const_int_operand" "i")))]
3477 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3480 int shift = INTVAL (operands[4]) & 31;
3481 int start = INTVAL (operands[2]) & 31;
3482 int size = INTVAL (operands[1]) & 31;
3484 operands[4] = GEN_INT (32 - shift - start - size);
3485 operands[1] = GEN_INT (start + size - 1);
3486 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3488 [(set_attr "type" "insert_word")])
3490 (define_insn "*insvsi_internal4"
3491 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3492 (match_operand:SI 1 "const_int_operand" "i")
3493 (match_operand:SI 2 "const_int_operand" "i"))
3494 (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3495 (match_operand:SI 4 "const_int_operand" "i")
3496 (match_operand:SI 5 "const_int_operand" "i")))]
3497 "INTVAL (operands[4]) >= INTVAL (operands[1])"
3500 int extract_start = INTVAL (operands[5]) & 31;
3501 int extract_size = INTVAL (operands[4]) & 31;
3502 int insert_start = INTVAL (operands[2]) & 31;
3503 int insert_size = INTVAL (operands[1]) & 31;
3505 /* Align extract field with insert field */
3506 operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
3507 operands[1] = GEN_INT (insert_start + insert_size - 1);
3508 return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
3510 [(set_attr "type" "insert_word")])
3512 ;; combine patterns for rlwimi
3513 (define_insn "*insvsi_internal5"
3514 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3515 (ior:SI (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3516 (match_operand:SI 1 "mask_operand" "i"))
3517 (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3518 (match_operand:SI 2 "const_int_operand" "i"))
3519 (match_operand:SI 5 "mask_operand" "i"))))]
3520 "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
3523 int me = extract_ME(operands[5]);
3524 int mb = extract_MB(operands[5]);
3525 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3526 operands[2] = GEN_INT(mb);
3527 operands[1] = GEN_INT(me);
3528 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3530 [(set_attr "type" "insert_word")])
3532 (define_insn "*insvsi_internal6"
3533 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3534 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3535 (match_operand:SI 2 "const_int_operand" "i"))
3536 (match_operand:SI 5 "mask_operand" "i"))
3537 (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3538 (match_operand:SI 1 "mask_operand" "i"))))]
3539 "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
3542 int me = extract_ME(operands[5]);
3543 int mb = extract_MB(operands[5]);
3544 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3545 operands[2] = GEN_INT(mb);
3546 operands[1] = GEN_INT(me);
3547 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3549 [(set_attr "type" "insert_word")])
3551 (define_insn "insvdi"
3552 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3553 (match_operand:SI 1 "const_int_operand" "i")
3554 (match_operand:SI 2 "const_int_operand" "i"))
3555 (match_operand:DI 3 "gpc_reg_operand" "r"))]
3559 int start = INTVAL (operands[2]) & 63;
3560 int size = INTVAL (operands[1]) & 63;
3562 operands[1] = GEN_INT (64 - start - size);
3563 return \"rldimi %0,%3,%H1,%H2\";
3565 [(set_attr "type" "insert_dword")])
3567 (define_insn "*insvdi_internal2"
3568 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3569 (match_operand:SI 1 "const_int_operand" "i")
3570 (match_operand:SI 2 "const_int_operand" "i"))
3571 (ashiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3572 (match_operand:SI 4 "const_int_operand" "i")))]
3574 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3577 int shift = INTVAL (operands[4]) & 63;
3578 int start = (INTVAL (operands[2]) & 63) - 32;
3579 int size = INTVAL (operands[1]) & 63;
3581 operands[4] = GEN_INT (64 - shift - start - size);
3582 operands[2] = GEN_INT (start);
3583 operands[1] = GEN_INT (start + size - 1);
3584 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3587 (define_insn "*insvdi_internal3"
3588 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3589 (match_operand:SI 1 "const_int_operand" "i")
3590 (match_operand:SI 2 "const_int_operand" "i"))
3591 (lshiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3592 (match_operand:SI 4 "const_int_operand" "i")))]
3594 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3597 int shift = INTVAL (operands[4]) & 63;
3598 int start = (INTVAL (operands[2]) & 63) - 32;
3599 int size = INTVAL (operands[1]) & 63;
3601 operands[4] = GEN_INT (64 - shift - start - size);
3602 operands[2] = GEN_INT (start);
3603 operands[1] = GEN_INT (start + size - 1);
3604 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3607 (define_expand "extzv"
3608 [(set (match_operand 0 "gpc_reg_operand" "")
3609 (zero_extract (match_operand 1 "gpc_reg_operand" "")
3610 (match_operand:SI 2 "const_int_operand" "")
3611 (match_operand:SI 3 "const_int_operand" "")))]
3615 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3616 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3617 compiler if the address of the structure is taken later. */
3618 if (GET_CODE (operands[0]) == SUBREG
3619 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3622 if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3623 emit_insn (gen_extzvdi (operands[0], operands[1], operands[2], operands[3]));
3625 emit_insn (gen_extzvsi (operands[0], operands[1], operands[2], operands[3]));
3629 (define_insn "extzvsi"
3630 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3631 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3632 (match_operand:SI 2 "const_int_operand" "i")
3633 (match_operand:SI 3 "const_int_operand" "i")))]
3637 int start = INTVAL (operands[3]) & 31;
3638 int size = INTVAL (operands[2]) & 31;
3640 if (start + size >= 32)
3641 operands[3] = const0_rtx;
3643 operands[3] = GEN_INT (start + size);
3644 return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
3647 (define_insn "*extzvsi_internal1"
3648 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3649 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3650 (match_operand:SI 2 "const_int_operand" "i,i")
3651 (match_operand:SI 3 "const_int_operand" "i,i"))
3653 (clobber (match_scratch:SI 4 "=r,r"))]
3657 int start = INTVAL (operands[3]) & 31;
3658 int size = INTVAL (operands[2]) & 31;
3660 /* Force split for non-cc0 compare. */
3661 if (which_alternative == 1)
3664 /* If the bit-field being tested fits in the upper or lower half of a
3665 word, it is possible to use andiu. or andil. to test it. This is
3666 useful because the condition register set-use delay is smaller for
3667 andi[ul]. than for rlinm. This doesn't work when the starting bit
3668 position is 0 because the LT and GT bits may be set wrong. */
3670 if ((start > 0 && start + size <= 16) || start >= 16)
3672 operands[3] = GEN_INT (((1 << (16 - (start & 15)))
3673 - (1 << (16 - (start & 15) - size))));
3675 return \"{andiu.|andis.} %4,%1,%3\";
3677 return \"{andil.|andi.} %4,%1,%3\";
3680 if (start + size >= 32)
3681 operands[3] = const0_rtx;
3683 operands[3] = GEN_INT (start + size);
3684 return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
3686 [(set_attr "type" "delayed_compare")
3687 (set_attr "length" "4,8")])
3690 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3691 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3692 (match_operand:SI 2 "const_int_operand" "")
3693 (match_operand:SI 3 "const_int_operand" ""))
3695 (clobber (match_scratch:SI 4 ""))]
3698 (zero_extract:SI (match_dup 1) (match_dup 2)
3701 (compare:CC (match_dup 4)
3705 (define_insn "*extzvsi_internal2"
3706 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3707 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3708 (match_operand:SI 2 "const_int_operand" "i,i")
3709 (match_operand:SI 3 "const_int_operand" "i,i"))
3711 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3712 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3716 int start = INTVAL (operands[3]) & 31;
3717 int size = INTVAL (operands[2]) & 31;
3719 /* Force split for non-cc0 compare. */
3720 if (which_alternative == 1)
3723 /* Since we are using the output value, we can't ignore any need for
3724 a shift. The bit-field must end at the LSB. */
3725 if (start >= 16 && start + size == 32)
3727 operands[3] = GEN_INT ((1 << size) - 1);
3728 return \"{andil.|andi.} %0,%1,%3\";
3731 if (start + size >= 32)
3732 operands[3] = const0_rtx;
3734 operands[3] = GEN_INT (start + size);
3735 return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
3737 [(set_attr "type" "delayed_compare")
3738 (set_attr "length" "4,8")])
3741 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3742 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3743 (match_operand:SI 2 "const_int_operand" "")
3744 (match_operand:SI 3 "const_int_operand" ""))
3746 (set (match_operand:SI 0 "gpc_reg_operand" "")
3747 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3750 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3752 (compare:CC (match_dup 0)
3756 (define_insn "extzvdi"
3757 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3758 (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3759 (match_operand:SI 2 "const_int_operand" "i")
3760 (match_operand:SI 3 "const_int_operand" "i")))]
3764 int start = INTVAL (operands[3]) & 63;
3765 int size = INTVAL (operands[2]) & 63;
3767 if (start + size >= 64)
3768 operands[3] = const0_rtx;
3770 operands[3] = GEN_INT (start + size);
3771 operands[2] = GEN_INT (64 - size);
3772 return \"rldicl %0,%1,%3,%2\";
3775 (define_insn "*extzvdi_internal1"
3776 [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3777 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3778 (match_operand:SI 2 "const_int_operand" "i")
3779 (match_operand:SI 3 "const_int_operand" "i"))
3781 (clobber (match_scratch:DI 4 "=r"))]
3785 int start = INTVAL (operands[3]) & 63;
3786 int size = INTVAL (operands[2]) & 63;
3788 if (start + size >= 64)
3789 operands[3] = const0_rtx;
3791 operands[3] = GEN_INT (start + size);
3792 operands[2] = GEN_INT (64 - size);
3793 return \"rldicl. %4,%1,%3,%2\";
3795 [(set_attr "type" "compare")])