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,cell"
110 (const (symbol_ref "rs6000_cpu_attr")))
113 ;; If this instruction is microcoded on the CELL processor
114 ; The default for load and stores is conditional
115 ; The default for load extended and the recorded instructions is always microcoded
116 (define_attr "cell_micro" "not,conditional,always"
117 (if_then_else (ior (ior (eq_attr "type" "load")
118 (eq_attr "type" "store"))
119 (ior (eq_attr "type" "fpload")
120 (eq_attr "type" "fpstore")))
121 (const_string "conditional")
122 (if_then_else (ior (eq_attr "type" "load_ext")
123 (ior (eq_attr "type" "compare")
124 (eq_attr "type" "delayed_compare")))
125 (const_string "always")
126 (const_string "not"))))
129 (automata_option "ndfa")
142 (include "power4.md")
143 (include "power5.md")
144 (include "power6.md")
147 (include "predicates.md")
148 (include "constraints.md")
150 (include "darwin.md")
155 ; This mode macro allows :GPR to be used to indicate the allowable size
156 ; of whole values in GPRs.
157 (define_mode_macro GPR [SI (DI "TARGET_POWERPC64")])
159 ; Any supported integer mode.
160 (define_mode_macro INT [QI HI SI DI TI])
162 ; Any supported integer mode that fits in one register.
163 (define_mode_macro INT1 [QI HI SI (DI "TARGET_POWERPC64")])
165 ; extend modes for DImode
166 (define_mode_macro QHSI [QI HI SI])
168 ; SImode or DImode, even if DImode doesn't fit in GPRs.
169 (define_mode_macro SDI [SI DI])
171 ; The size of a pointer. Also, the size of the value that a record-condition
172 ; (one with a '.') will compare.
173 (define_mode_macro P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
175 ; Any hardware-supported floating-point mode
176 (define_mode_macro FP [(SF "TARGET_HARD_FLOAT")
177 (DF "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)")
178 (TF "!TARGET_IEEEQUAD
179 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128")])
181 ; Various instructions that come in SI and DI forms.
182 ; A generic w/d attribute, for things like cmpw/cmpd.
183 (define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
186 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
189 ;; Start with fixed-point load and store insns. Here we put only the more
190 ;; complex forms. Basic data transfer is done later.
192 (define_expand "zero_extend<mode>di2"
193 [(set (match_operand:DI 0 "gpc_reg_operand" "")
194 (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "")))]
198 (define_insn "*zero_extend<mode>di2_internal1"
199 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
200 (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
204 rldicl %0,%1,0,<dbits>"
205 [(set_attr "type" "load,*")])
207 (define_insn "*zero_extend<mode>di2_internal2"
208 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
209 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
211 (clobber (match_scratch:DI 2 "=r,r"))]
214 rldicl. %2,%1,0,<dbits>
216 [(set_attr "type" "compare")
217 (set_attr "length" "4,8")])
220 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
221 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
223 (clobber (match_scratch:DI 2 ""))]
224 "TARGET_POWERPC64 && reload_completed"
226 (zero_extend:DI (match_dup 1)))
228 (compare:CC (match_dup 2)
232 (define_insn "*zero_extend<mode>di2_internal3"
233 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
234 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
236 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
237 (zero_extend:DI (match_dup 1)))]
240 rldicl. %0,%1,0,<dbits>
242 [(set_attr "type" "compare")
243 (set_attr "length" "4,8")])
246 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
247 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
249 (set (match_operand:DI 0 "gpc_reg_operand" "")
250 (zero_extend:DI (match_dup 1)))]
251 "TARGET_POWERPC64 && reload_completed"
253 (zero_extend:DI (match_dup 1)))
255 (compare:CC (match_dup 0)
259 (define_insn "extendqidi2"
260 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
261 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
264 [(set_attr "type" "exts")])
267 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
268 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
270 (clobber (match_scratch:DI 2 "=r,r"))]
275 [(set_attr "type" "compare")
276 (set_attr "length" "4,8")])
279 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
280 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
282 (clobber (match_scratch:DI 2 ""))]
283 "TARGET_POWERPC64 && reload_completed"
285 (sign_extend:DI (match_dup 1)))
287 (compare:CC (match_dup 2)
292 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
293 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
295 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
296 (sign_extend:DI (match_dup 1)))]
301 [(set_attr "type" "compare")
302 (set_attr "length" "4,8")])
305 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
306 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
308 (set (match_operand:DI 0 "gpc_reg_operand" "")
309 (sign_extend:DI (match_dup 1)))]
310 "TARGET_POWERPC64 && reload_completed"
312 (sign_extend:DI (match_dup 1)))
314 (compare:CC (match_dup 0)
318 (define_expand "extendhidi2"
319 [(set (match_operand:DI 0 "gpc_reg_operand" "")
320 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
325 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
326 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
331 [(set_attr "type" "load_ext,exts")])
334 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
335 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
337 (clobber (match_scratch:DI 2 "=r,r"))]
342 [(set_attr "type" "compare")
343 (set_attr "length" "4,8")])
346 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
347 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
349 (clobber (match_scratch:DI 2 ""))]
350 "TARGET_POWERPC64 && reload_completed"
352 (sign_extend:DI (match_dup 1)))
354 (compare:CC (match_dup 2)
359 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
360 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
362 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
363 (sign_extend:DI (match_dup 1)))]
368 [(set_attr "type" "compare")
369 (set_attr "length" "4,8")])
372 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
373 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
375 (set (match_operand:DI 0 "gpc_reg_operand" "")
376 (sign_extend:DI (match_dup 1)))]
377 "TARGET_POWERPC64 && reload_completed"
379 (sign_extend:DI (match_dup 1)))
381 (compare:CC (match_dup 0)
385 (define_expand "extendsidi2"
386 [(set (match_operand:DI 0 "gpc_reg_operand" "")
387 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
392 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
393 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
398 [(set_attr "type" "load_ext,exts")])
401 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
402 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
404 (clobber (match_scratch:DI 2 "=r,r"))]
409 [(set_attr "type" "compare")
410 (set_attr "length" "4,8")])
413 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
414 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
416 (clobber (match_scratch:DI 2 ""))]
417 "TARGET_POWERPC64 && reload_completed"
419 (sign_extend:DI (match_dup 1)))
421 (compare:CC (match_dup 2)
426 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
427 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
429 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
430 (sign_extend:DI (match_dup 1)))]
435 [(set_attr "type" "compare")
436 (set_attr "length" "4,8")])
439 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
440 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
442 (set (match_operand:DI 0 "gpc_reg_operand" "")
443 (sign_extend:DI (match_dup 1)))]
444 "TARGET_POWERPC64 && reload_completed"
446 (sign_extend:DI (match_dup 1)))
448 (compare:CC (match_dup 0)
452 (define_expand "zero_extendqisi2"
453 [(set (match_operand:SI 0 "gpc_reg_operand" "")
454 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
459 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
460 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
464 {rlinm|rlwinm} %0,%1,0,0xff"
465 [(set_attr "type" "load,*")])
468 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
469 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
471 (clobber (match_scratch:SI 2 "=r,r"))]
474 {andil.|andi.} %2,%1,0xff
476 [(set_attr "type" "compare")
477 (set_attr "length" "4,8")])
480 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
481 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
483 (clobber (match_scratch:SI 2 ""))]
486 (zero_extend:SI (match_dup 1)))
488 (compare:CC (match_dup 2)
493 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
494 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
496 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
497 (zero_extend:SI (match_dup 1)))]
500 {andil.|andi.} %0,%1,0xff
502 [(set_attr "type" "compare")
503 (set_attr "length" "4,8")])
506 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
507 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
509 (set (match_operand:SI 0 "gpc_reg_operand" "")
510 (zero_extend:SI (match_dup 1)))]
513 (zero_extend:SI (match_dup 1)))
515 (compare:CC (match_dup 0)
519 (define_expand "extendqisi2"
520 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
521 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
526 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
527 else if (TARGET_POWER)
528 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
530 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
534 (define_insn "extendqisi2_ppc"
535 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
536 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
539 [(set_attr "type" "exts")])
542 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
543 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
545 (clobber (match_scratch:SI 2 "=r,r"))]
550 [(set_attr "type" "compare")
551 (set_attr "length" "4,8")])
554 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
555 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
557 (clobber (match_scratch:SI 2 ""))]
558 "TARGET_POWERPC && reload_completed"
560 (sign_extend:SI (match_dup 1)))
562 (compare:CC (match_dup 2)
567 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
568 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
570 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
571 (sign_extend:SI (match_dup 1)))]
576 [(set_attr "type" "compare")
577 (set_attr "length" "4,8")])
580 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
581 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
583 (set (match_operand:SI 0 "gpc_reg_operand" "")
584 (sign_extend:SI (match_dup 1)))]
585 "TARGET_POWERPC && reload_completed"
587 (sign_extend:SI (match_dup 1)))
589 (compare:CC (match_dup 0)
593 (define_expand "extendqisi2_power"
594 [(parallel [(set (match_dup 2)
595 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
597 (clobber (scratch:SI))])
598 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
599 (ashiftrt:SI (match_dup 2)
601 (clobber (scratch:SI))])]
604 { operands[1] = gen_lowpart (SImode, operands[1]);
605 operands[2] = gen_reg_rtx (SImode); }")
607 (define_expand "extendqisi2_no_power"
609 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
611 (set (match_operand:SI 0 "gpc_reg_operand" "")
612 (ashiftrt:SI (match_dup 2)
614 "! TARGET_POWER && ! TARGET_POWERPC"
616 { operands[1] = gen_lowpart (SImode, operands[1]);
617 operands[2] = gen_reg_rtx (SImode); }")
619 (define_expand "zero_extendqihi2"
620 [(set (match_operand:HI 0 "gpc_reg_operand" "")
621 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
626 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
627 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
631 {rlinm|rlwinm} %0,%1,0,0xff"
632 [(set_attr "type" "load,*")])
635 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
636 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
638 (clobber (match_scratch:HI 2 "=r,r"))]
641 {andil.|andi.} %2,%1,0xff
643 [(set_attr "type" "compare")
644 (set_attr "length" "4,8")])
647 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
648 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
650 (clobber (match_scratch:HI 2 ""))]
653 (zero_extend:HI (match_dup 1)))
655 (compare:CC (match_dup 2)
660 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
661 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
663 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
664 (zero_extend:HI (match_dup 1)))]
667 {andil.|andi.} %0,%1,0xff
669 [(set_attr "type" "compare")
670 (set_attr "length" "4,8")])
673 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
674 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
676 (set (match_operand:HI 0 "gpc_reg_operand" "")
677 (zero_extend:HI (match_dup 1)))]
680 (zero_extend:HI (match_dup 1)))
682 (compare:CC (match_dup 0)
686 (define_expand "extendqihi2"
687 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
688 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
693 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
694 else if (TARGET_POWER)
695 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
697 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
701 (define_insn "extendqihi2_ppc"
702 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
703 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
706 [(set_attr "type" "exts")])
709 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
710 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
712 (clobber (match_scratch:HI 2 "=r,r"))]
717 [(set_attr "type" "compare")
718 (set_attr "length" "4,8")])
721 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
722 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
724 (clobber (match_scratch:HI 2 ""))]
725 "TARGET_POWERPC && reload_completed"
727 (sign_extend:HI (match_dup 1)))
729 (compare:CC (match_dup 2)
734 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
735 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
737 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
738 (sign_extend:HI (match_dup 1)))]
743 [(set_attr "type" "compare")
744 (set_attr "length" "4,8")])
747 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
748 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
750 (set (match_operand:HI 0 "gpc_reg_operand" "")
751 (sign_extend:HI (match_dup 1)))]
752 "TARGET_POWERPC && reload_completed"
754 (sign_extend:HI (match_dup 1)))
756 (compare:CC (match_dup 0)
760 (define_expand "extendqihi2_power"
761 [(parallel [(set (match_dup 2)
762 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
764 (clobber (scratch:SI))])
765 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
766 (ashiftrt:SI (match_dup 2)
768 (clobber (scratch:SI))])]
771 { operands[0] = gen_lowpart (SImode, operands[0]);
772 operands[1] = gen_lowpart (SImode, operands[1]);
773 operands[2] = gen_reg_rtx (SImode); }")
775 (define_expand "extendqihi2_no_power"
777 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
779 (set (match_operand:HI 0 "gpc_reg_operand" "")
780 (ashiftrt:SI (match_dup 2)
782 "! TARGET_POWER && ! TARGET_POWERPC"
784 { operands[0] = gen_lowpart (SImode, operands[0]);
785 operands[1] = gen_lowpart (SImode, operands[1]);
786 operands[2] = gen_reg_rtx (SImode); }")
788 (define_expand "zero_extendhisi2"
789 [(set (match_operand:SI 0 "gpc_reg_operand" "")
790 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
795 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
796 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
800 {rlinm|rlwinm} %0,%1,0,0xffff"
801 [(set_attr "type" "load,*")])
804 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
805 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
807 (clobber (match_scratch:SI 2 "=r,r"))]
810 {andil.|andi.} %2,%1,0xffff
812 [(set_attr "type" "compare")
813 (set_attr "length" "4,8")])
816 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
817 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
819 (clobber (match_scratch:SI 2 ""))]
822 (zero_extend:SI (match_dup 1)))
824 (compare:CC (match_dup 2)
829 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
830 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
832 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
833 (zero_extend:SI (match_dup 1)))]
836 {andil.|andi.} %0,%1,0xffff
838 [(set_attr "type" "compare")
839 (set_attr "length" "4,8")])
842 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
843 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
845 (set (match_operand:SI 0 "gpc_reg_operand" "")
846 (zero_extend:SI (match_dup 1)))]
849 (zero_extend:SI (match_dup 1)))
851 (compare:CC (match_dup 0)
855 (define_expand "extendhisi2"
856 [(set (match_operand:SI 0 "gpc_reg_operand" "")
857 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
862 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
863 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
868 [(set_attr "type" "load_ext,exts")])
871 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
872 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
874 (clobber (match_scratch:SI 2 "=r,r"))]
879 [(set_attr "type" "compare")
880 (set_attr "length" "4,8")])
883 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
884 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
886 (clobber (match_scratch:SI 2 ""))]
889 (sign_extend:SI (match_dup 1)))
891 (compare:CC (match_dup 2)
896 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
897 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
899 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
900 (sign_extend:SI (match_dup 1)))]
905 [(set_attr "type" "compare")
906 (set_attr "length" "4,8")])
908 ;; IBM 405 and 440 half-word multiplication operations.
910 (define_insn "*macchwc"
911 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
912 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
913 (match_operand:SI 2 "gpc_reg_operand" "r")
916 (match_operand:HI 1 "gpc_reg_operand" "r")))
917 (match_operand:SI 4 "gpc_reg_operand" "0"))
919 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
920 (plus:SI (mult:SI (ashiftrt:SI
928 [(set_attr "type" "imul3")])
930 (define_insn "*macchw"
931 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
932 (plus:SI (mult:SI (ashiftrt:SI
933 (match_operand:SI 2 "gpc_reg_operand" "r")
936 (match_operand:HI 1 "gpc_reg_operand" "r")))
937 (match_operand:SI 3 "gpc_reg_operand" "0")))]
940 [(set_attr "type" "imul3")])
942 (define_insn "*macchwuc"
943 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
944 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
945 (match_operand:SI 2 "gpc_reg_operand" "r")
948 (match_operand:HI 1 "gpc_reg_operand" "r")))
949 (match_operand:SI 4 "gpc_reg_operand" "0"))
951 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
952 (plus:SI (mult:SI (lshiftrt:SI
959 "macchwu. %0, %1, %2"
960 [(set_attr "type" "imul3")])
962 (define_insn "*macchwu"
963 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
964 (plus:SI (mult:SI (lshiftrt:SI
965 (match_operand:SI 2 "gpc_reg_operand" "r")
968 (match_operand:HI 1 "gpc_reg_operand" "r")))
969 (match_operand:SI 3 "gpc_reg_operand" "0")))]
972 [(set_attr "type" "imul3")])
974 (define_insn "*machhwc"
975 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
976 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
977 (match_operand:SI 1 "gpc_reg_operand" "%r")
980 (match_operand:SI 2 "gpc_reg_operand" "r")
982 (match_operand:SI 4 "gpc_reg_operand" "0"))
984 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
985 (plus:SI (mult:SI (ashiftrt:SI
994 [(set_attr "type" "imul3")])
996 (define_insn "*machhw"
997 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
998 (plus:SI (mult:SI (ashiftrt:SI
999 (match_operand:SI 1 "gpc_reg_operand" "%r")
1002 (match_operand:SI 2 "gpc_reg_operand" "r")
1004 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1007 [(set_attr "type" "imul3")])
1009 (define_insn "*machhwuc"
1010 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1011 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
1012 (match_operand:SI 1 "gpc_reg_operand" "%r")
1015 (match_operand:SI 2 "gpc_reg_operand" "r")
1017 (match_operand:SI 4 "gpc_reg_operand" "0"))
1019 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1020 (plus:SI (mult:SI (lshiftrt:SI
1028 "machhwu. %0, %1, %2"
1029 [(set_attr "type" "imul3")])
1031 (define_insn "*machhwu"
1032 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1033 (plus:SI (mult:SI (lshiftrt:SI
1034 (match_operand:SI 1 "gpc_reg_operand" "%r")
1037 (match_operand:SI 2 "gpc_reg_operand" "r")
1039 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1041 "machhwu %0, %1, %2"
1042 [(set_attr "type" "imul3")])
1044 (define_insn "*maclhwc"
1045 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1046 (compare:CC (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 4 "gpc_reg_operand" "0"))
1052 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1053 (plus:SI (mult:SI (sign_extend:SI
1059 "maclhw. %0, %1, %2"
1060 [(set_attr "type" "imul3")])
1062 (define_insn "*maclhw"
1063 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1064 (plus:SI (mult:SI (sign_extend:SI
1065 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1067 (match_operand:HI 2 "gpc_reg_operand" "r")))
1068 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1071 [(set_attr "type" "imul3")])
1073 (define_insn "*maclhwuc"
1074 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1075 (compare:CC (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 4 "gpc_reg_operand" "0"))
1081 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1082 (plus:SI (mult:SI (zero_extend:SI
1088 "maclhwu. %0, %1, %2"
1089 [(set_attr "type" "imul3")])
1091 (define_insn "*maclhwu"
1092 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1093 (plus:SI (mult:SI (zero_extend:SI
1094 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1096 (match_operand:HI 2 "gpc_reg_operand" "r")))
1097 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1099 "maclhwu %0, %1, %2"
1100 [(set_attr "type" "imul3")])
1102 (define_insn "*nmacchwc"
1103 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1104 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1105 (mult:SI (ashiftrt:SI
1106 (match_operand:SI 2 "gpc_reg_operand" "r")
1109 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1111 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1112 (minus:SI (match_dup 4)
1113 (mult:SI (ashiftrt:SI
1119 "nmacchw. %0, %1, %2"
1120 [(set_attr "type" "imul3")])
1122 (define_insn "*nmacchw"
1123 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1124 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1125 (mult:SI (ashiftrt:SI
1126 (match_operand:SI 2 "gpc_reg_operand" "r")
1129 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1131 "nmacchw %0, %1, %2"
1132 [(set_attr "type" "imul3")])
1134 (define_insn "*nmachhwc"
1135 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1136 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1137 (mult:SI (ashiftrt:SI
1138 (match_operand:SI 1 "gpc_reg_operand" "%r")
1141 (match_operand:SI 2 "gpc_reg_operand" "r")
1144 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1145 (minus:SI (match_dup 4)
1146 (mult:SI (ashiftrt:SI
1153 "nmachhw. %0, %1, %2"
1154 [(set_attr "type" "imul3")])
1156 (define_insn "*nmachhw"
1157 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1158 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1159 (mult:SI (ashiftrt:SI
1160 (match_operand:SI 1 "gpc_reg_operand" "%r")
1163 (match_operand:SI 2 "gpc_reg_operand" "r")
1166 "nmachhw %0, %1, %2"
1167 [(set_attr "type" "imul3")])
1169 (define_insn "*nmaclhwc"
1170 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1171 (compare:CC (minus:SI (match_operand:SI 4 "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 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1178 (minus:SI (match_dup 4)
1179 (mult:SI (sign_extend:SI
1184 "nmaclhw. %0, %1, %2"
1185 [(set_attr "type" "imul3")])
1187 (define_insn "*nmaclhw"
1188 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1189 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1190 (mult:SI (sign_extend:SI
1191 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1193 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1195 "nmaclhw %0, %1, %2"
1196 [(set_attr "type" "imul3")])
1198 (define_insn "*mulchwc"
1199 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1200 (compare:CC (mult:SI (ashiftrt:SI
1201 (match_operand:SI 2 "gpc_reg_operand" "r")
1204 (match_operand:HI 1 "gpc_reg_operand" "r")))
1206 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1207 (mult:SI (ashiftrt:SI
1213 "mulchw. %0, %1, %2"
1214 [(set_attr "type" "imul3")])
1216 (define_insn "*mulchw"
1217 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1218 (mult:SI (ashiftrt:SI
1219 (match_operand:SI 2 "gpc_reg_operand" "r")
1222 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1225 [(set_attr "type" "imul3")])
1227 (define_insn "*mulchwuc"
1228 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1229 (compare:CC (mult:SI (lshiftrt:SI
1230 (match_operand:SI 2 "gpc_reg_operand" "r")
1233 (match_operand:HI 1 "gpc_reg_operand" "r")))
1235 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1236 (mult:SI (lshiftrt:SI
1242 "mulchwu. %0, %1, %2"
1243 [(set_attr "type" "imul3")])
1245 (define_insn "*mulchwu"
1246 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1247 (mult:SI (lshiftrt:SI
1248 (match_operand:SI 2 "gpc_reg_operand" "r")
1251 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1253 "mulchwu %0, %1, %2"
1254 [(set_attr "type" "imul3")])
1256 (define_insn "*mulhhwc"
1257 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1258 (compare:CC (mult:SI (ashiftrt:SI
1259 (match_operand:SI 1 "gpc_reg_operand" "%r")
1262 (match_operand:SI 2 "gpc_reg_operand" "r")
1265 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1266 (mult:SI (ashiftrt:SI
1273 "mulhhw. %0, %1, %2"
1274 [(set_attr "type" "imul3")])
1276 (define_insn "*mulhhw"
1277 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1278 (mult:SI (ashiftrt:SI
1279 (match_operand:SI 1 "gpc_reg_operand" "%r")
1282 (match_operand:SI 2 "gpc_reg_operand" "r")
1286 [(set_attr "type" "imul3")])
1288 (define_insn "*mulhhwuc"
1289 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1290 (compare:CC (mult:SI (lshiftrt:SI
1291 (match_operand:SI 1 "gpc_reg_operand" "%r")
1294 (match_operand:SI 2 "gpc_reg_operand" "r")
1297 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1298 (mult:SI (lshiftrt:SI
1305 "mulhhwu. %0, %1, %2"
1306 [(set_attr "type" "imul3")])
1308 (define_insn "*mulhhwu"
1309 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1310 (mult:SI (lshiftrt:SI
1311 (match_operand:SI 1 "gpc_reg_operand" "%r")
1314 (match_operand:SI 2 "gpc_reg_operand" "r")
1317 "mulhhwu %0, %1, %2"
1318 [(set_attr "type" "imul3")])
1320 (define_insn "*mullhwc"
1321 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1322 (compare:CC (mult:SI (sign_extend:SI
1323 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1325 (match_operand:HI 2 "gpc_reg_operand" "r")))
1327 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1328 (mult:SI (sign_extend:SI
1333 "mullhw. %0, %1, %2"
1334 [(set_attr "type" "imul3")])
1336 (define_insn "*mullhw"
1337 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1338 (mult:SI (sign_extend:SI
1339 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1341 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1344 [(set_attr "type" "imul3")])
1346 (define_insn "*mullhwuc"
1347 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1348 (compare:CC (mult:SI (zero_extend:SI
1349 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1351 (match_operand:HI 2 "gpc_reg_operand" "r")))
1353 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1354 (mult:SI (zero_extend:SI
1359 "mullhwu. %0, %1, %2"
1360 [(set_attr "type" "imul3")])
1362 (define_insn "*mullhwu"
1363 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1364 (mult:SI (zero_extend:SI
1365 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1367 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1369 "mullhwu %0, %1, %2"
1370 [(set_attr "type" "imul3")])
1372 ;; IBM 405 and 440 string-search dlmzb instruction support.
1373 (define_insn "dlmzb"
1374 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1375 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1376 (match_operand:SI 2 "gpc_reg_operand" "r")]
1378 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1379 (unspec:SI [(match_dup 1)
1383 "dlmzb. %0, %1, %2")
1385 (define_expand "strlensi"
1386 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1387 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1388 (match_operand:QI 2 "const_int_operand" "")
1389 (match_operand 3 "const_int_operand" "")]
1390 UNSPEC_DLMZB_STRLEN))
1391 (clobber (match_scratch:CC 4 "=x"))]
1392 "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1394 rtx result = operands[0];
1395 rtx src = operands[1];
1396 rtx search_char = operands[2];
1397 rtx align = operands[3];
1398 rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1399 rtx loop_label, end_label, mem, cr0, cond;
1400 if (search_char != const0_rtx
1401 || GET_CODE (align) != CONST_INT
1402 || INTVAL (align) < 8)
1404 word1 = gen_reg_rtx (SImode);
1405 word2 = gen_reg_rtx (SImode);
1406 scratch_dlmzb = gen_reg_rtx (SImode);
1407 scratch_string = gen_reg_rtx (Pmode);
1408 loop_label = gen_label_rtx ();
1409 end_label = gen_label_rtx ();
1410 addr = force_reg (Pmode, XEXP (src, 0));
1411 emit_move_insn (scratch_string, addr);
1412 emit_label (loop_label);
1413 mem = change_address (src, SImode, scratch_string);
1414 emit_move_insn (word1, mem);
1415 emit_move_insn (word2, adjust_address (mem, SImode, 4));
1416 cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1417 emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1418 cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1419 emit_jump_insn (gen_rtx_SET (VOIDmode,
1421 gen_rtx_IF_THEN_ELSE (VOIDmode,
1427 emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1428 emit_jump_insn (gen_rtx_SET (VOIDmode,
1430 gen_rtx_LABEL_REF (VOIDmode, loop_label)));
1432 emit_label (end_label);
1433 emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1434 emit_insn (gen_subsi3 (result, scratch_string, addr));
1435 emit_insn (gen_subsi3 (result, result, const1_rtx));
1440 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1441 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1443 (set (match_operand:SI 0 "gpc_reg_operand" "")
1444 (sign_extend:SI (match_dup 1)))]
1447 (sign_extend:SI (match_dup 1)))
1449 (compare:CC (match_dup 0)
1453 ;; Fixed-point arithmetic insns.
1455 (define_expand "add<mode>3"
1456 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1457 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1458 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1461 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1463 if (non_short_cint_operand (operands[2], DImode))
1466 else if (GET_CODE (operands[2]) == CONST_INT
1467 && ! add_operand (operands[2], <MODE>mode))
1469 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
1470 ? operands[0] : gen_reg_rtx (<MODE>mode));
1472 HOST_WIDE_INT val = INTVAL (operands[2]);
1473 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1474 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1476 if (<MODE>mode == DImode && !satisfies_constraint_L (GEN_INT (rest)))
1479 /* The ordering here is important for the prolog expander.
1480 When space is allocated from the stack, adding 'low' first may
1481 produce a temporary deallocation (which would be bad). */
1482 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1483 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1488 ;; Discourage ai/addic because of carry but provide it in an alternative
1489 ;; allowing register zero as source.
1490 (define_insn "*add<mode>3_internal1"
1491 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1492 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1493 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
1497 {cal %0,%2(%1)|addi %0,%1,%2}
1499 {cau|addis} %0,%1,%v2"
1500 [(set_attr "length" "4,4,4,4")])
1502 (define_insn "addsi3_high"
1503 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1504 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1505 (high:SI (match_operand 2 "" ""))))]
1506 "TARGET_MACHO && !TARGET_64BIT"
1507 "{cau|addis} %0,%1,ha16(%2)"
1508 [(set_attr "length" "4")])
1510 (define_insn "*add<mode>3_internal2"
1511 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1512 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1513 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1515 (clobber (match_scratch:P 3 "=r,r,r,r"))]
1518 {cax.|add.} %3,%1,%2
1519 {ai.|addic.} %3,%1,%2
1522 [(set_attr "type" "fast_compare,compare,compare,compare")
1523 (set_attr "length" "4,4,8,8")])
1526 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1527 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1528 (match_operand:GPR 2 "reg_or_short_operand" ""))
1530 (clobber (match_scratch:GPR 3 ""))]
1533 (plus:GPR (match_dup 1)
1536 (compare:CC (match_dup 3)
1540 (define_insn "*add<mode>3_internal3"
1541 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1542 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1543 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1545 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1546 (plus:P (match_dup 1)
1550 {cax.|add.} %0,%1,%2
1551 {ai.|addic.} %0,%1,%2
1554 [(set_attr "type" "fast_compare,compare,compare,compare")
1555 (set_attr "length" "4,4,8,8")])
1558 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1559 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1560 (match_operand:P 2 "reg_or_short_operand" ""))
1562 (set (match_operand:P 0 "gpc_reg_operand" "")
1563 (plus:P (match_dup 1) (match_dup 2)))]
1566 (plus:P (match_dup 1)
1569 (compare:CC (match_dup 0)
1573 ;; Split an add that we can't do in one insn into two insns, each of which
1574 ;; does one 16-bit part. This is used by combine. Note that the low-order
1575 ;; add should be last in case the result gets used in an address.
1578 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1579 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1580 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1582 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1583 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1585 HOST_WIDE_INT val = INTVAL (operands[2]);
1586 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1587 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1589 operands[4] = GEN_INT (low);
1590 if (<MODE>mode == SImode || satisfies_constraint_L (GEN_INT (rest)))
1591 operands[3] = GEN_INT (rest);
1592 else if (! no_new_pseudos)
1594 operands[3] = gen_reg_rtx (DImode);
1595 emit_move_insn (operands[3], operands[2]);
1596 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1603 (define_insn "one_cmpl<mode>2"
1604 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1605 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1610 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1611 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1613 (clobber (match_scratch:P 2 "=r,r"))]
1618 [(set_attr "type" "compare")
1619 (set_attr "length" "4,8")])
1622 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1623 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1625 (clobber (match_scratch:P 2 ""))]
1628 (not:P (match_dup 1)))
1630 (compare:CC (match_dup 2)
1635 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1636 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1638 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1639 (not:P (match_dup 1)))]
1644 [(set_attr "type" "compare")
1645 (set_attr "length" "4,8")])
1648 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1649 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1651 (set (match_operand:P 0 "gpc_reg_operand" "")
1652 (not:P (match_dup 1)))]
1655 (not:P (match_dup 1)))
1657 (compare:CC (match_dup 0)
1662 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1663 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1664 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1666 "{sf%I1|subf%I1c} %0,%2,%1")
1669 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1670 (minus:GPR (match_operand:GPR 1 "reg_or_short_operand" "r,I")
1671 (match_operand:GPR 2 "gpc_reg_operand" "r,r")))]
1678 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1679 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1680 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1682 (clobber (match_scratch:SI 3 "=r,r"))]
1685 {sf.|subfc.} %3,%2,%1
1687 [(set_attr "type" "compare")
1688 (set_attr "length" "4,8")])
1691 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1692 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1693 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1695 (clobber (match_scratch:P 3 "=r,r"))]
1700 [(set_attr "type" "fast_compare")
1701 (set_attr "length" "4,8")])
1704 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1705 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1706 (match_operand:P 2 "gpc_reg_operand" ""))
1708 (clobber (match_scratch:P 3 ""))]
1711 (minus:P (match_dup 1)
1714 (compare:CC (match_dup 3)
1719 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1720 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1721 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1723 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1724 (minus:SI (match_dup 1) (match_dup 2)))]
1727 {sf.|subfc.} %0,%2,%1
1729 [(set_attr "type" "compare")
1730 (set_attr "length" "4,8")])
1733 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1734 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1735 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1737 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1738 (minus:P (match_dup 1)
1744 [(set_attr "type" "fast_compare")
1745 (set_attr "length" "4,8")])
1748 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1749 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1750 (match_operand:P 2 "gpc_reg_operand" ""))
1752 (set (match_operand:P 0 "gpc_reg_operand" "")
1753 (minus:P (match_dup 1)
1757 (minus:P (match_dup 1)
1760 (compare:CC (match_dup 0)
1764 (define_expand "sub<mode>3"
1765 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1766 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1767 (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
1771 if (GET_CODE (operands[2]) == CONST_INT)
1773 emit_insn (gen_add<mode>3 (operands[0], operands[1],
1774 negate_rtx (<MODE>mode, operands[2])));
1779 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1780 ;; instruction and some auxiliary computations. Then we just have a single
1781 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1784 (define_expand "sminsi3"
1786 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1787 (match_operand:SI 2 "reg_or_short_operand" ""))
1789 (minus:SI (match_dup 2) (match_dup 1))))
1790 (set (match_operand:SI 0 "gpc_reg_operand" "")
1791 (minus:SI (match_dup 2) (match_dup 3)))]
1792 "TARGET_POWER || TARGET_ISEL"
1797 operands[2] = force_reg (SImode, operands[2]);
1798 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1802 operands[3] = gen_reg_rtx (SImode);
1806 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1807 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1808 (match_operand:SI 2 "reg_or_short_operand" "")))
1809 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1812 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1814 (minus:SI (match_dup 2) (match_dup 1))))
1815 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1818 (define_expand "smaxsi3"
1820 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1821 (match_operand:SI 2 "reg_or_short_operand" ""))
1823 (minus:SI (match_dup 2) (match_dup 1))))
1824 (set (match_operand:SI 0 "gpc_reg_operand" "")
1825 (plus:SI (match_dup 3) (match_dup 1)))]
1826 "TARGET_POWER || TARGET_ISEL"
1831 operands[2] = force_reg (SImode, operands[2]);
1832 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1835 operands[3] = gen_reg_rtx (SImode);
1839 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1840 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1841 (match_operand:SI 2 "reg_or_short_operand" "")))
1842 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1845 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1847 (minus:SI (match_dup 2) (match_dup 1))))
1848 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1851 (define_expand "uminsi3"
1852 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1854 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1856 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1858 (minus:SI (match_dup 4) (match_dup 3))))
1859 (set (match_operand:SI 0 "gpc_reg_operand" "")
1860 (minus:SI (match_dup 2) (match_dup 3)))]
1861 "TARGET_POWER || TARGET_ISEL"
1866 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1869 operands[3] = gen_reg_rtx (SImode);
1870 operands[4] = gen_reg_rtx (SImode);
1871 operands[5] = GEN_INT (-2147483647 - 1);
1874 (define_expand "umaxsi3"
1875 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1877 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1879 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1881 (minus:SI (match_dup 4) (match_dup 3))))
1882 (set (match_operand:SI 0 "gpc_reg_operand" "")
1883 (plus:SI (match_dup 3) (match_dup 1)))]
1884 "TARGET_POWER || TARGET_ISEL"
1889 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1892 operands[3] = gen_reg_rtx (SImode);
1893 operands[4] = gen_reg_rtx (SImode);
1894 operands[5] = GEN_INT (-2147483647 - 1);
1898 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1899 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1900 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1902 (minus:SI (match_dup 2) (match_dup 1))))]
1907 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1909 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1910 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1912 (minus:SI (match_dup 2) (match_dup 1)))
1914 (clobber (match_scratch:SI 3 "=r,r"))]
1919 [(set_attr "type" "delayed_compare")
1920 (set_attr "length" "4,8")])
1923 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1925 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1926 (match_operand:SI 2 "reg_or_short_operand" ""))
1928 (minus:SI (match_dup 2) (match_dup 1)))
1930 (clobber (match_scratch:SI 3 ""))]
1931 "TARGET_POWER && reload_completed"
1933 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1935 (minus:SI (match_dup 2) (match_dup 1))))
1937 (compare:CC (match_dup 3)
1942 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1944 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1945 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1947 (minus:SI (match_dup 2) (match_dup 1)))
1949 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1950 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1952 (minus:SI (match_dup 2) (match_dup 1))))]
1957 [(set_attr "type" "delayed_compare")
1958 (set_attr "length" "4,8")])
1961 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1963 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1964 (match_operand:SI 2 "reg_or_short_operand" ""))
1966 (minus:SI (match_dup 2) (match_dup 1)))
1968 (set (match_operand:SI 0 "gpc_reg_operand" "")
1969 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1971 (minus:SI (match_dup 2) (match_dup 1))))]
1972 "TARGET_POWER && reload_completed"
1974 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1976 (minus:SI (match_dup 2) (match_dup 1))))
1978 (compare:CC (match_dup 0)
1982 ;; We don't need abs with condition code because such comparisons should
1984 (define_expand "abssi2"
1985 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1986 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1992 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
1995 else if (! TARGET_POWER)
1997 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
2002 (define_insn "*abssi2_power"
2003 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2004 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2008 (define_insn_and_split "abssi2_isel"
2009 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2010 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
2011 (clobber (match_scratch:SI 2 "=&b"))
2012 (clobber (match_scratch:CC 3 "=y"))]
2015 "&& reload_completed"
2016 [(set (match_dup 2) (neg:SI (match_dup 1)))
2018 (compare:CC (match_dup 1)
2021 (if_then_else:SI (ge (match_dup 3)
2027 (define_insn_and_split "abssi2_nopower"
2028 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2029 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
2030 (clobber (match_scratch:SI 2 "=&r,&r"))]
2031 "! TARGET_POWER && ! TARGET_ISEL"
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 0) (match_dup 2)))]
2039 (define_insn "*nabs_power"
2040 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2041 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
2045 (define_insn_and_split "*nabs_nopower"
2046 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2047 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
2048 (clobber (match_scratch:SI 2 "=&r,&r"))]
2051 "&& reload_completed"
2052 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2053 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2054 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
2057 (define_expand "neg<mode>2"
2058 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2059 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
2063 (define_insn "*neg<mode>2_internal"
2064 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2065 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2070 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2071 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2073 (clobber (match_scratch:P 2 "=r,r"))]
2078 [(set_attr "type" "fast_compare")
2079 (set_attr "length" "4,8")])
2082 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2083 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2085 (clobber (match_scratch:P 2 ""))]
2088 (neg:P (match_dup 1)))
2090 (compare:CC (match_dup 2)
2095 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2096 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2098 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2099 (neg:P (match_dup 1)))]
2104 [(set_attr "type" "fast_compare")
2105 (set_attr "length" "4,8")])
2108 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2109 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2111 (set (match_operand:P 0 "gpc_reg_operand" "")
2112 (neg:P (match_dup 1)))]
2115 (neg:P (match_dup 1)))
2117 (compare:CC (match_dup 0)
2121 (define_insn "clz<mode>2"
2122 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2123 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2125 "{cntlz|cntlz<wd>} %0,%1"
2126 [(set_attr "type" "cntlz")])
2128 (define_expand "ctz<mode>2"
2130 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))
2131 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2133 (clobber (scratch:CC))])
2134 (set (match_dup 4) (clz:GPR (match_dup 3)))
2135 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2136 (minus:GPR (match_dup 5) (match_dup 4)))]
2139 operands[2] = gen_reg_rtx (<MODE>mode);
2140 operands[3] = gen_reg_rtx (<MODE>mode);
2141 operands[4] = gen_reg_rtx (<MODE>mode);
2142 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
2145 (define_expand "ffs<mode>2"
2147 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))
2148 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2150 (clobber (scratch:CC))])
2151 (set (match_dup 4) (clz:GPR (match_dup 3)))
2152 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2153 (minus:GPR (match_dup 5) (match_dup 4)))]
2156 operands[2] = gen_reg_rtx (<MODE>mode);
2157 operands[3] = gen_reg_rtx (<MODE>mode);
2158 operands[4] = gen_reg_rtx (<MODE>mode);
2159 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
2162 (define_expand "popcount<mode>2"
2164 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2167 (mult:GPR (match_dup 2) (match_dup 4)))
2168 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2169 (lshiftrt:GPR (match_dup 3) (match_dup 5)))]
2172 operands[2] = gen_reg_rtx (<MODE>mode);
2173 operands[3] = gen_reg_rtx (<MODE>mode);
2174 operands[4] = force_reg (<MODE>mode,
2175 <MODE>mode == SImode
2176 ? GEN_INT (0x01010101)
2177 : GEN_INT ((HOST_WIDE_INT)
2178 0x01010101 << 32 | 0x01010101));
2179 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 8);
2182 (define_insn "popcntb<mode>2"
2183 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2184 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2189 (define_expand "mulsi3"
2190 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2191 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2192 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2197 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2199 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2203 (define_insn "mulsi3_mq"
2204 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2205 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2206 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2207 (clobber (match_scratch:SI 3 "=q,q"))]
2210 {muls|mullw} %0,%1,%2
2211 {muli|mulli} %0,%1,%2"
2213 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2214 (const_string "imul3")
2215 (match_operand:SI 2 "short_cint_operand" "")
2216 (const_string "imul2")]
2217 (const_string "imul")))])
2219 (define_insn "mulsi3_no_mq"
2220 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2221 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2222 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2225 {muls|mullw} %0,%1,%2
2226 {muli|mulli} %0,%1,%2"
2228 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2229 (const_string "imul3")
2230 (match_operand:SI 2 "short_cint_operand" "")
2231 (const_string "imul2")]
2232 (const_string "imul")))])
2234 (define_insn "*mulsi3_mq_internal1"
2235 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2236 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2237 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2239 (clobber (match_scratch:SI 3 "=r,r"))
2240 (clobber (match_scratch:SI 4 "=q,q"))]
2243 {muls.|mullw.} %3,%1,%2
2245 [(set_attr "type" "imul_compare")
2246 (set_attr "length" "4,8")])
2249 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2250 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2251 (match_operand:SI 2 "gpc_reg_operand" ""))
2253 (clobber (match_scratch:SI 3 ""))
2254 (clobber (match_scratch:SI 4 ""))]
2255 "TARGET_POWER && reload_completed"
2256 [(parallel [(set (match_dup 3)
2257 (mult:SI (match_dup 1) (match_dup 2)))
2258 (clobber (match_dup 4))])
2260 (compare:CC (match_dup 3)
2264 (define_insn "*mulsi3_no_mq_internal1"
2265 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2266 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2267 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2269 (clobber (match_scratch:SI 3 "=r,r"))]
2272 {muls.|mullw.} %3,%1,%2
2274 [(set_attr "type" "imul_compare")
2275 (set_attr "length" "4,8")])
2278 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2279 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2280 (match_operand:SI 2 "gpc_reg_operand" ""))
2282 (clobber (match_scratch:SI 3 ""))]
2283 "! TARGET_POWER && reload_completed"
2285 (mult:SI (match_dup 1) (match_dup 2)))
2287 (compare:CC (match_dup 3)
2291 (define_insn "*mulsi3_mq_internal2"
2292 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2293 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2294 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2296 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2297 (mult:SI (match_dup 1) (match_dup 2)))
2298 (clobber (match_scratch:SI 4 "=q,q"))]
2301 {muls.|mullw.} %0,%1,%2
2303 [(set_attr "type" "imul_compare")
2304 (set_attr "length" "4,8")])
2307 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2308 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2309 (match_operand:SI 2 "gpc_reg_operand" ""))
2311 (set (match_operand:SI 0 "gpc_reg_operand" "")
2312 (mult:SI (match_dup 1) (match_dup 2)))
2313 (clobber (match_scratch:SI 4 ""))]
2314 "TARGET_POWER && reload_completed"
2315 [(parallel [(set (match_dup 0)
2316 (mult:SI (match_dup 1) (match_dup 2)))
2317 (clobber (match_dup 4))])
2319 (compare:CC (match_dup 0)
2323 (define_insn "*mulsi3_no_mq_internal2"
2324 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2325 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2326 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2328 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2329 (mult:SI (match_dup 1) (match_dup 2)))]
2332 {muls.|mullw.} %0,%1,%2
2334 [(set_attr "type" "imul_compare")
2335 (set_attr "length" "4,8")])
2338 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2339 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2340 (match_operand:SI 2 "gpc_reg_operand" ""))
2342 (set (match_operand:SI 0 "gpc_reg_operand" "")
2343 (mult:SI (match_dup 1) (match_dup 2)))]
2344 "! TARGET_POWER && reload_completed"
2346 (mult:SI (match_dup 1) (match_dup 2)))
2348 (compare:CC (match_dup 0)
2352 ;; Operand 1 is divided by operand 2; quotient goes to operand
2353 ;; 0 and remainder to operand 3.
2354 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2356 (define_expand "divmodsi4"
2357 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2358 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2359 (match_operand:SI 2 "gpc_reg_operand" "")))
2360 (set (match_operand:SI 3 "register_operand" "")
2361 (mod:SI (match_dup 1) (match_dup 2)))])]
2362 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2365 if (! TARGET_POWER && ! TARGET_POWERPC)
2367 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2368 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2369 emit_insn (gen_divss_call ());
2370 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2371 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2376 (define_insn "*divmodsi4_internal"
2377 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2378 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2379 (match_operand:SI 2 "gpc_reg_operand" "r")))
2380 (set (match_operand:SI 3 "register_operand" "=q")
2381 (mod:SI (match_dup 1) (match_dup 2)))]
2384 [(set_attr "type" "idiv")])
2386 (define_expand "udiv<mode>3"
2387 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2388 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2389 (match_operand:GPR 2 "gpc_reg_operand" "")))]
2390 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2393 if (! TARGET_POWER && ! TARGET_POWERPC)
2395 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2396 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2397 emit_insn (gen_quous_call ());
2398 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2401 else if (TARGET_POWER)
2403 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2408 (define_insn "udivsi3_mq"
2409 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2410 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2411 (match_operand:SI 2 "gpc_reg_operand" "r")))
2412 (clobber (match_scratch:SI 3 "=q"))]
2413 "TARGET_POWERPC && TARGET_POWER"
2415 [(set_attr "type" "idiv")])
2417 (define_insn "*udivsi3_no_mq"
2418 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2419 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2420 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2421 "TARGET_POWERPC && ! TARGET_POWER"
2424 (cond [(match_operand:SI 0 "" "")
2425 (const_string "idiv")]
2426 (const_string "ldiv")))])
2429 ;; For powers of two we can do srai/aze for divide and then adjust for
2430 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2431 ;; used; for PowerPC, force operands into register and do a normal divide;
2432 ;; for AIX common-mode, use quoss call on register operands.
2433 (define_expand "div<mode>3"
2434 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2435 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2436 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2440 if (GET_CODE (operands[2]) == CONST_INT
2441 && INTVAL (operands[2]) > 0
2442 && exact_log2 (INTVAL (operands[2])) >= 0)
2444 else if (TARGET_POWERPC)
2446 operands[2] = force_reg (SImode, operands[2]);
2449 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2453 else if (TARGET_POWER)
2457 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2458 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2459 emit_insn (gen_quoss_call ());
2460 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2465 (define_insn "divsi3_mq"
2466 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2467 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2468 (match_operand:SI 2 "gpc_reg_operand" "r")))
2469 (clobber (match_scratch:SI 3 "=q"))]
2470 "TARGET_POWERPC && TARGET_POWER"
2472 [(set_attr "type" "idiv")])
2474 (define_insn "*div<mode>3_no_mq"
2475 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2476 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2477 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2478 "TARGET_POWERPC && ! TARGET_POWER"
2481 (cond [(match_operand:SI 0 "" "")
2482 (const_string "idiv")]
2483 (const_string "ldiv")))])
2485 (define_expand "mod<mode>3"
2486 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2487 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2488 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
2496 if (GET_CODE (operands[2]) != CONST_INT
2497 || INTVAL (operands[2]) <= 0
2498 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2501 temp1 = gen_reg_rtx (<MODE>mode);
2502 temp2 = gen_reg_rtx (<MODE>mode);
2504 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2505 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2506 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
2511 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2512 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2513 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
2515 "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
2516 [(set_attr "type" "two")
2517 (set_attr "length" "8")])
2520 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2521 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2522 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2524 (clobber (match_scratch:P 3 "=r,r"))]
2527 {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
2529 [(set_attr "type" "compare")
2530 (set_attr "length" "8,12")])
2533 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2534 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2535 (match_operand:GPR 2 "exact_log2_cint_operand"
2538 (clobber (match_scratch:GPR 3 ""))]
2541 (div:<MODE> (match_dup 1) (match_dup 2)))
2543 (compare:CC (match_dup 3)
2548 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2549 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2550 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2552 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2553 (div:P (match_dup 1) (match_dup 2)))]
2556 {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
2558 [(set_attr "type" "compare")
2559 (set_attr "length" "8,12")])
2562 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2563 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2564 (match_operand:GPR 2 "exact_log2_cint_operand"
2567 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2568 (div:GPR (match_dup 1) (match_dup 2)))]
2571 (div:<MODE> (match_dup 1) (match_dup 2)))
2573 (compare:CC (match_dup 0)
2578 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2581 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2583 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2584 (match_operand:SI 3 "gpc_reg_operand" "r")))
2585 (set (match_operand:SI 2 "register_operand" "=*q")
2588 (zero_extend:DI (match_dup 1)) (const_int 32))
2589 (zero_extend:DI (match_dup 4)))
2593 [(set_attr "type" "idiv")])
2595 ;; To do unsigned divide we handle the cases of the divisor looking like a
2596 ;; negative number. If it is a constant that is less than 2**31, we don't
2597 ;; have to worry about the branches. So make a few subroutines here.
2599 ;; First comes the normal case.
2600 (define_expand "udivmodsi4_normal"
2601 [(set (match_dup 4) (const_int 0))
2602 (parallel [(set (match_operand:SI 0 "" "")
2603 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2605 (zero_extend:DI (match_operand:SI 1 "" "")))
2606 (match_operand:SI 2 "" "")))
2607 (set (match_operand:SI 3 "" "")
2608 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2610 (zero_extend:DI (match_dup 1)))
2614 { operands[4] = gen_reg_rtx (SImode); }")
2616 ;; This handles the branches.
2617 (define_expand "udivmodsi4_tests"
2618 [(set (match_operand:SI 0 "" "") (const_int 0))
2619 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2620 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2621 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2622 (label_ref (match_operand:SI 4 "" "")) (pc)))
2623 (set (match_dup 0) (const_int 1))
2624 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2625 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2626 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2627 (label_ref (match_dup 4)) (pc)))]
2630 { operands[5] = gen_reg_rtx (CCUNSmode);
2631 operands[6] = gen_reg_rtx (CCmode);
2634 (define_expand "udivmodsi4"
2635 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2636 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2637 (match_operand:SI 2 "reg_or_cint_operand" "")))
2638 (set (match_operand:SI 3 "gpc_reg_operand" "")
2639 (umod:SI (match_dup 1) (match_dup 2)))])]
2647 if (! TARGET_POWERPC)
2649 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2650 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2651 emit_insn (gen_divus_call ());
2652 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2653 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2660 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2662 operands[2] = force_reg (SImode, operands[2]);
2663 label = gen_label_rtx ();
2664 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2665 operands[3], label));
2668 operands[2] = force_reg (SImode, operands[2]);
2670 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2678 ;; AIX architecture-independent common-mode multiply (DImode),
2679 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2680 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2681 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2682 ;; assumed unused if generating common-mode, so ignore.
2683 (define_insn "mulh_call"
2686 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2687 (sign_extend:DI (reg:SI 4)))
2689 (clobber (match_scratch:SI 0 "=l"))]
2690 "! TARGET_POWER && ! TARGET_POWERPC"
2692 [(set_attr "type" "imul")])
2694 (define_insn "mull_call"
2696 (mult:DI (sign_extend:DI (reg:SI 3))
2697 (sign_extend:DI (reg:SI 4))))
2698 (clobber (match_scratch:SI 0 "=l"))
2699 (clobber (reg:SI 0))]
2700 "! TARGET_POWER && ! TARGET_POWERPC"
2702 [(set_attr "type" "imul")])
2704 (define_insn "divss_call"
2706 (div:SI (reg:SI 3) (reg:SI 4)))
2708 (mod:SI (reg:SI 3) (reg:SI 4)))
2709 (clobber (match_scratch:SI 0 "=l"))
2710 (clobber (reg:SI 0))]
2711 "! TARGET_POWER && ! TARGET_POWERPC"
2713 [(set_attr "type" "idiv")])
2715 (define_insn "divus_call"
2717 (udiv:SI (reg:SI 3) (reg:SI 4)))
2719 (umod:SI (reg:SI 3) (reg:SI 4)))
2720 (clobber (match_scratch:SI 0 "=l"))
2721 (clobber (reg:SI 0))
2722 (clobber (match_scratch:CC 1 "=x"))
2723 (clobber (reg:CC 69))]
2724 "! TARGET_POWER && ! TARGET_POWERPC"
2726 [(set_attr "type" "idiv")])
2728 (define_insn "quoss_call"
2730 (div:SI (reg:SI 3) (reg:SI 4)))
2731 (clobber (match_scratch:SI 0 "=l"))]
2732 "! TARGET_POWER && ! TARGET_POWERPC"
2734 [(set_attr "type" "idiv")])
2736 (define_insn "quous_call"
2738 (udiv:SI (reg:SI 3) (reg:SI 4)))
2739 (clobber (match_scratch:SI 0 "=l"))
2740 (clobber (reg:SI 0))
2741 (clobber (match_scratch:CC 1 "=x"))
2742 (clobber (reg:CC 69))]
2743 "! TARGET_POWER && ! TARGET_POWERPC"
2745 [(set_attr "type" "idiv")])
2747 ;; Logical instructions
2748 ;; The logical instructions are mostly combined by using match_operator,
2749 ;; but the plain AND insns are somewhat different because there is no
2750 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2751 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2753 (define_insn "andsi3"
2754 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2755 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2756 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2757 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2761 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2762 {andil.|andi.} %0,%1,%b2
2763 {andiu.|andis.} %0,%1,%u2"
2764 [(set_attr "type" "*,*,compare,compare")])
2766 ;; Note to set cr's other than cr0 we do the and immediate and then
2767 ;; the test again -- this avoids a mfcr which on the higher end
2768 ;; machines causes an execution serialization
2770 (define_insn "*andsi3_internal2"
2771 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2772 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2773 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2775 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2776 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2780 {andil.|andi.} %3,%1,%b2
2781 {andiu.|andis.} %3,%1,%u2
2782 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2787 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2788 (set_attr "length" "4,4,4,4,8,8,8,8")])
2790 (define_insn "*andsi3_internal3"
2791 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2792 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2793 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2795 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2796 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2800 {andil.|andi.} %3,%1,%b2
2801 {andiu.|andis.} %3,%1,%u2
2802 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2807 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2808 (set_attr "length" "8,4,4,4,8,8,8,8")])
2811 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2812 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2813 (match_operand:GPR 2 "and_operand" ""))
2815 (clobber (match_scratch:GPR 3 ""))
2816 (clobber (match_scratch:CC 4 ""))]
2818 [(parallel [(set (match_dup 3)
2819 (and:<MODE> (match_dup 1)
2821 (clobber (match_dup 4))])
2823 (compare:CC (match_dup 3)
2827 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2828 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2831 [(set (match_operand:CC 0 "cc_reg_operand" "")
2832 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2833 (match_operand:SI 2 "gpc_reg_operand" ""))
2835 (clobber (match_scratch:SI 3 ""))
2836 (clobber (match_scratch:CC 4 ""))]
2837 "TARGET_POWERPC64 && reload_completed"
2838 [(parallel [(set (match_dup 3)
2839 (and:SI (match_dup 1)
2841 (clobber (match_dup 4))])
2843 (compare:CC (match_dup 3)
2847 (define_insn "*andsi3_internal4"
2848 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2849 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2850 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2852 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2853 (and:SI (match_dup 1)
2855 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2859 {andil.|andi.} %0,%1,%b2
2860 {andiu.|andis.} %0,%1,%u2
2861 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2866 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2867 (set_attr "length" "4,4,4,4,8,8,8,8")])
2869 (define_insn "*andsi3_internal5"
2870 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2871 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2872 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2874 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2875 (and:SI (match_dup 1)
2877 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2881 {andil.|andi.} %0,%1,%b2
2882 {andiu.|andis.} %0,%1,%u2
2883 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2888 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2889 (set_attr "length" "8,4,4,4,8,8,8,8")])
2892 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2893 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2894 (match_operand:SI 2 "and_operand" ""))
2896 (set (match_operand:SI 0 "gpc_reg_operand" "")
2897 (and:SI (match_dup 1)
2899 (clobber (match_scratch:CC 4 ""))]
2901 [(parallel [(set (match_dup 0)
2902 (and:SI (match_dup 1)
2904 (clobber (match_dup 4))])
2906 (compare:CC (match_dup 0)
2911 [(set (match_operand:CC 3 "cc_reg_operand" "")
2912 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2913 (match_operand:SI 2 "gpc_reg_operand" ""))
2915 (set (match_operand:SI 0 "gpc_reg_operand" "")
2916 (and:SI (match_dup 1)
2918 (clobber (match_scratch:CC 4 ""))]
2919 "TARGET_POWERPC64 && reload_completed"
2920 [(parallel [(set (match_dup 0)
2921 (and:SI (match_dup 1)
2923 (clobber (match_dup 4))])
2925 (compare:CC (match_dup 0)
2929 ;; Handle the PowerPC64 rlwinm corner case
2931 (define_insn_and_split "*andsi3_internal6"
2932 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2933 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2934 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2939 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2942 (rotate:SI (match_dup 0) (match_dup 5)))]
2945 int mb = extract_MB (operands[2]);
2946 int me = extract_ME (operands[2]);
2947 operands[3] = GEN_INT (me + 1);
2948 operands[5] = GEN_INT (32 - (me + 1));
2949 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2951 [(set_attr "length" "8")])
2953 (define_expand "iorsi3"
2954 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2955 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
2956 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2960 if (GET_CODE (operands[2]) == CONST_INT
2961 && ! logical_operand (operands[2], SImode))
2963 HOST_WIDE_INT value = INTVAL (operands[2]);
2964 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2965 ? operands[0] : gen_reg_rtx (SImode));
2967 emit_insn (gen_iorsi3 (tmp, operands[1],
2968 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2969 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2974 (define_expand "xorsi3"
2975 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2976 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2977 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2981 if (GET_CODE (operands[2]) == CONST_INT
2982 && ! logical_operand (operands[2], SImode))
2984 HOST_WIDE_INT value = INTVAL (operands[2]);
2985 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2986 ? operands[0] : gen_reg_rtx (SImode));
2988 emit_insn (gen_xorsi3 (tmp, operands[1],
2989 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2990 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2995 (define_insn "*boolsi3_internal1"
2996 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2997 (match_operator:SI 3 "boolean_or_operator"
2998 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
2999 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
3003 {%q3il|%q3i} %0,%1,%b2
3004 {%q3iu|%q3is} %0,%1,%u2")
3006 (define_insn "*boolsi3_internal2"
3007 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3008 (compare:CC (match_operator:SI 4 "boolean_or_operator"
3009 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3010 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3012 (clobber (match_scratch:SI 3 "=r,r"))]
3017 [(set_attr "type" "compare")
3018 (set_attr "length" "4,8")])
3021 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3022 (compare:CC (match_operator:SI 4 "boolean_operator"
3023 [(match_operand:SI 1 "gpc_reg_operand" "")
3024 (match_operand:SI 2 "gpc_reg_operand" "")])
3026 (clobber (match_scratch:SI 3 ""))]
3027 "TARGET_32BIT && reload_completed"
3028 [(set (match_dup 3) (match_dup 4))
3030 (compare:CC (match_dup 3)
3034 (define_insn "*boolsi3_internal3"
3035 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3036 (compare:CC (match_operator:SI 4 "boolean_operator"
3037 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3038 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3040 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3046 [(set_attr "type" "compare")
3047 (set_attr "length" "4,8")])
3050 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3051 (compare:CC (match_operator:SI 4 "boolean_operator"
3052 [(match_operand:SI 1 "gpc_reg_operand" "")
3053 (match_operand:SI 2 "gpc_reg_operand" "")])
3055 (set (match_operand:SI 0 "gpc_reg_operand" "")
3057 "TARGET_32BIT && reload_completed"
3058 [(set (match_dup 0) (match_dup 4))
3060 (compare:CC (match_dup 0)
3064 ;; Split a logical operation that we can't do in one insn into two insns,
3065 ;; each of which does one 16-bit part. This is used by combine.
3068 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3069 (match_operator:SI 3 "boolean_or_operator"
3070 [(match_operand:SI 1 "gpc_reg_operand" "")
3071 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
3073 [(set (match_dup 0) (match_dup 4))
3074 (set (match_dup 0) (match_dup 5))]
3078 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
3079 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3081 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
3082 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3086 (define_insn "*boolcsi3_internal1"
3087 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3088 (match_operator:SI 3 "boolean_operator"
3089 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3090 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
3094 (define_insn "*boolcsi3_internal2"
3095 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3096 (compare:CC (match_operator:SI 4 "boolean_operator"
3097 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3098 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3100 (clobber (match_scratch:SI 3 "=r,r"))]
3105 [(set_attr "type" "compare")
3106 (set_attr "length" "4,8")])
3109 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3110 (compare:CC (match_operator:SI 4 "boolean_operator"
3111 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3112 (match_operand:SI 2 "gpc_reg_operand" "")])
3114 (clobber (match_scratch:SI 3 ""))]
3115 "TARGET_32BIT && reload_completed"
3116 [(set (match_dup 3) (match_dup 4))
3118 (compare:CC (match_dup 3)
3122 (define_insn "*boolcsi3_internal3"
3123 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3124 (compare:CC (match_operator:SI 4 "boolean_operator"
3125 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3126 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3128 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3134 [(set_attr "type" "compare")
3135 (set_attr "length" "4,8")])
3138 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3139 (compare:CC (match_operator:SI 4 "boolean_operator"
3140 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3141 (match_operand:SI 2 "gpc_reg_operand" "")])
3143 (set (match_operand:SI 0 "gpc_reg_operand" "")
3145 "TARGET_32BIT && reload_completed"
3146 [(set (match_dup 0) (match_dup 4))
3148 (compare:CC (match_dup 0)
3152 (define_insn "*boolccsi3_internal1"
3153 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3154 (match_operator:SI 3 "boolean_operator"
3155 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3156 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3160 (define_insn "*boolccsi3_internal2"
3161 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3162 (compare:CC (match_operator:SI 4 "boolean_operator"
3163 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3164 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3166 (clobber (match_scratch:SI 3 "=r,r"))]
3171 [(set_attr "type" "compare")
3172 (set_attr "length" "4,8")])
3175 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3176 (compare:CC (match_operator:SI 4 "boolean_operator"
3177 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3178 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3180 (clobber (match_scratch:SI 3 ""))]
3181 "TARGET_32BIT && reload_completed"
3182 [(set (match_dup 3) (match_dup 4))
3184 (compare:CC (match_dup 3)
3188 (define_insn "*boolccsi3_internal3"
3189 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3190 (compare:CC (match_operator:SI 4 "boolean_operator"
3191 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3192 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3194 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3200 [(set_attr "type" "compare")
3201 (set_attr "length" "4,8")])
3204 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3205 (compare:CC (match_operator:SI 4 "boolean_operator"
3206 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3207 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3209 (set (match_operand:SI 0 "gpc_reg_operand" "")
3211 "TARGET_32BIT && reload_completed"
3212 [(set (match_dup 0) (match_dup 4))
3214 (compare:CC (match_dup 0)
3218 ;; maskir insn. We need four forms because things might be in arbitrary
3219 ;; orders. Don't define forms that only set CR fields because these
3220 ;; would modify an input register.
3222 (define_insn "*maskir_internal1"
3223 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3224 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3225 (match_operand:SI 1 "gpc_reg_operand" "0"))
3226 (and:SI (match_dup 2)
3227 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
3231 (define_insn "*maskir_internal2"
3232 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3233 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3234 (match_operand:SI 1 "gpc_reg_operand" "0"))
3235 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3240 (define_insn "*maskir_internal3"
3241 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3242 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
3243 (match_operand:SI 3 "gpc_reg_operand" "r"))
3244 (and:SI (not:SI (match_dup 2))
3245 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3249 (define_insn "*maskir_internal4"
3250 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3251 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3252 (match_operand:SI 2 "gpc_reg_operand" "r"))
3253 (and:SI (not:SI (match_dup 2))
3254 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3258 (define_insn "*maskir_internal5"
3259 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3261 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3262 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3263 (and:SI (match_dup 2)
3264 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
3266 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3267 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3268 (and:SI (match_dup 2) (match_dup 3))))]