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_eq_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,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"
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"
110 (const (symbol_ref "rs6000_cpu_attr")))
112 (automata_option "ndfa")
125 (include "power4.md")
126 (include "power5.md")
128 (include "predicates.md")
130 (include "darwin.md")
135 ; This mode macro allows :GPR to be used to indicate the allowable size
136 ; of whole values in GPRs.
137 (define_mode_macro GPR [SI (DI "TARGET_POWERPC64")])
139 ; Any supported integer mode.
140 (define_mode_macro INT [QI HI SI DI TI])
142 ; Any supported integer mode that fits in one register.
143 (define_mode_macro INT1 [QI HI SI (DI "TARGET_POWERPC64")])
145 ; extend modes for DImode
146 (define_mode_macro QHSI [QI HI SI])
148 ; SImode or DImode, even if DImode doesn't fit in GPRs.
149 (define_mode_macro SDI [SI DI])
151 ; The size of a pointer. Also, the size of the value that a record-condition
152 ; (one with a '.') will compare.
153 (define_mode_macro P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
155 ; Any hardware-supported floating-point mode
156 (define_mode_macro FP [(SF "TARGET_HARD_FLOAT")
157 (DF "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)")
158 (TF "!TARGET_IEEEQUAD
159 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128")])
161 ; Various instructions that come in SI and DI forms.
162 ; A generic w/d attribute, for things like cmpw/cmpd.
163 (define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
166 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
169 ;; Start with fixed-point load and store insns. Here we put only the more
170 ;; complex forms. Basic data transfer is done later.
172 (define_expand "zero_extend<mode>di2"
173 [(set (match_operand:DI 0 "gpc_reg_operand" "")
174 (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "")))]
178 (define_insn "*zero_extend<mode>di2_internal1"
179 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
180 (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
184 rldicl %0,%1,0,<dbits>"
185 [(set_attr "type" "load,*")])
187 (define_insn "*zero_extend<mode>di2_internal2"
188 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
189 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
191 (clobber (match_scratch:DI 2 "=r,r"))]
194 rldicl. %2,%1,0,<dbits>
196 [(set_attr "type" "compare")
197 (set_attr "length" "4,8")])
200 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
201 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
203 (clobber (match_scratch:DI 2 ""))]
204 "TARGET_POWERPC64 && reload_completed"
206 (zero_extend:DI (match_dup 1)))
208 (compare:CC (match_dup 2)
212 (define_insn "*zero_extend<mode>di2_internal3"
213 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
214 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
216 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
217 (zero_extend:DI (match_dup 1)))]
220 rldicl. %0,%1,0,<dbits>
222 [(set_attr "type" "compare")
223 (set_attr "length" "4,8")])
226 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
227 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
229 (set (match_operand:DI 0 "gpc_reg_operand" "")
230 (zero_extend:DI (match_dup 1)))]
231 "TARGET_POWERPC64 && reload_completed"
233 (zero_extend:DI (match_dup 1)))
235 (compare:CC (match_dup 0)
239 (define_insn "extendqidi2"
240 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
241 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
246 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
247 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
249 (clobber (match_scratch:DI 2 "=r,r"))]
254 [(set_attr "type" "compare")
255 (set_attr "length" "4,8")])
258 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
259 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
261 (clobber (match_scratch:DI 2 ""))]
262 "TARGET_POWERPC64 && reload_completed"
264 (sign_extend:DI (match_dup 1)))
266 (compare:CC (match_dup 2)
271 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
272 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
274 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
275 (sign_extend:DI (match_dup 1)))]
280 [(set_attr "type" "compare")
281 (set_attr "length" "4,8")])
284 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
285 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
287 (set (match_operand:DI 0 "gpc_reg_operand" "")
288 (sign_extend:DI (match_dup 1)))]
289 "TARGET_POWERPC64 && reload_completed"
291 (sign_extend:DI (match_dup 1)))
293 (compare:CC (match_dup 0)
297 (define_expand "extendhidi2"
298 [(set (match_operand:DI 0 "gpc_reg_operand" "")
299 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
304 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
305 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
310 [(set_attr "type" "load_ext,*")])
313 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
314 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
316 (clobber (match_scratch:DI 2 "=r,r"))]
321 [(set_attr "type" "compare")
322 (set_attr "length" "4,8")])
325 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
326 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
328 (clobber (match_scratch:DI 2 ""))]
329 "TARGET_POWERPC64 && reload_completed"
331 (sign_extend:DI (match_dup 1)))
333 (compare:CC (match_dup 2)
338 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
339 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
341 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
342 (sign_extend:DI (match_dup 1)))]
347 [(set_attr "type" "compare")
348 (set_attr "length" "4,8")])
351 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
352 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
354 (set (match_operand:DI 0 "gpc_reg_operand" "")
355 (sign_extend:DI (match_dup 1)))]
356 "TARGET_POWERPC64 && reload_completed"
358 (sign_extend:DI (match_dup 1)))
360 (compare:CC (match_dup 0)
364 (define_expand "extendsidi2"
365 [(set (match_operand:DI 0 "gpc_reg_operand" "")
366 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
371 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
372 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
377 [(set_attr "type" "load_ext,*")])
380 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
381 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
383 (clobber (match_scratch:DI 2 "=r,r"))]
388 [(set_attr "type" "compare")
389 (set_attr "length" "4,8")])
392 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
393 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
395 (clobber (match_scratch:DI 2 ""))]
396 "TARGET_POWERPC64 && reload_completed"
398 (sign_extend:DI (match_dup 1)))
400 (compare:CC (match_dup 2)
405 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
406 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
408 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
409 (sign_extend:DI (match_dup 1)))]
414 [(set_attr "type" "compare")
415 (set_attr "length" "4,8")])
418 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
419 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
421 (set (match_operand:DI 0 "gpc_reg_operand" "")
422 (sign_extend:DI (match_dup 1)))]
423 "TARGET_POWERPC64 && reload_completed"
425 (sign_extend:DI (match_dup 1)))
427 (compare:CC (match_dup 0)
431 (define_expand "zero_extendqisi2"
432 [(set (match_operand:SI 0 "gpc_reg_operand" "")
433 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
438 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
439 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
443 {rlinm|rlwinm} %0,%1,0,0xff"
444 [(set_attr "type" "load,*")])
447 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
448 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
450 (clobber (match_scratch:SI 2 "=r,r"))]
453 {andil.|andi.} %2,%1,0xff
455 [(set_attr "type" "compare")
456 (set_attr "length" "4,8")])
459 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
460 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
462 (clobber (match_scratch:SI 2 ""))]
465 (zero_extend:SI (match_dup 1)))
467 (compare:CC (match_dup 2)
472 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
473 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
475 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
476 (zero_extend:SI (match_dup 1)))]
479 {andil.|andi.} %0,%1,0xff
481 [(set_attr "type" "compare")
482 (set_attr "length" "4,8")])
485 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
486 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
488 (set (match_operand:SI 0 "gpc_reg_operand" "")
489 (zero_extend:SI (match_dup 1)))]
492 (zero_extend:SI (match_dup 1)))
494 (compare:CC (match_dup 0)
498 (define_expand "extendqisi2"
499 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
500 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
505 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
506 else if (TARGET_POWER)
507 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
509 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
513 (define_insn "extendqisi2_ppc"
514 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
515 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
520 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
521 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
523 (clobber (match_scratch:SI 2 "=r,r"))]
528 [(set_attr "type" "compare")
529 (set_attr "length" "4,8")])
532 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
533 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
535 (clobber (match_scratch:SI 2 ""))]
536 "TARGET_POWERPC && reload_completed"
538 (sign_extend:SI (match_dup 1)))
540 (compare:CC (match_dup 2)
545 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
546 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
548 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
549 (sign_extend:SI (match_dup 1)))]
554 [(set_attr "type" "compare")
555 (set_attr "length" "4,8")])
558 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
559 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
561 (set (match_operand:SI 0 "gpc_reg_operand" "")
562 (sign_extend:SI (match_dup 1)))]
563 "TARGET_POWERPC && reload_completed"
565 (sign_extend:SI (match_dup 1)))
567 (compare:CC (match_dup 0)
571 (define_expand "extendqisi2_power"
572 [(parallel [(set (match_dup 2)
573 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
575 (clobber (scratch:SI))])
576 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
577 (ashiftrt:SI (match_dup 2)
579 (clobber (scratch:SI))])]
582 { operands[1] = gen_lowpart (SImode, operands[1]);
583 operands[2] = gen_reg_rtx (SImode); }")
585 (define_expand "extendqisi2_no_power"
587 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
589 (set (match_operand:SI 0 "gpc_reg_operand" "")
590 (ashiftrt:SI (match_dup 2)
592 "! TARGET_POWER && ! TARGET_POWERPC"
594 { operands[1] = gen_lowpart (SImode, operands[1]);
595 operands[2] = gen_reg_rtx (SImode); }")
597 (define_expand "zero_extendqihi2"
598 [(set (match_operand:HI 0 "gpc_reg_operand" "")
599 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
604 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
605 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
609 {rlinm|rlwinm} %0,%1,0,0xff"
610 [(set_attr "type" "load,*")])
613 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
614 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
616 (clobber (match_scratch:HI 2 "=r,r"))]
619 {andil.|andi.} %2,%1,0xff
621 [(set_attr "type" "compare")
622 (set_attr "length" "4,8")])
625 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
626 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
628 (clobber (match_scratch:HI 2 ""))]
631 (zero_extend:HI (match_dup 1)))
633 (compare:CC (match_dup 2)
638 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
639 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
641 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
642 (zero_extend:HI (match_dup 1)))]
645 {andil.|andi.} %0,%1,0xff
647 [(set_attr "type" "compare")
648 (set_attr "length" "4,8")])
651 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
652 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
654 (set (match_operand:HI 0 "gpc_reg_operand" "")
655 (zero_extend:HI (match_dup 1)))]
658 (zero_extend:HI (match_dup 1)))
660 (compare:CC (match_dup 0)
664 (define_expand "extendqihi2"
665 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
666 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
671 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
672 else if (TARGET_POWER)
673 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
675 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
679 (define_insn "extendqihi2_ppc"
680 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
681 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
686 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
687 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
689 (clobber (match_scratch:HI 2 "=r,r"))]
694 [(set_attr "type" "compare")
695 (set_attr "length" "4,8")])
698 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
699 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
701 (clobber (match_scratch:HI 2 ""))]
702 "TARGET_POWERPC && reload_completed"
704 (sign_extend:HI (match_dup 1)))
706 (compare:CC (match_dup 2)
711 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
712 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
714 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
715 (sign_extend:HI (match_dup 1)))]
720 [(set_attr "type" "compare")
721 (set_attr "length" "4,8")])
724 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
725 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
727 (set (match_operand:HI 0 "gpc_reg_operand" "")
728 (sign_extend:HI (match_dup 1)))]
729 "TARGET_POWERPC && reload_completed"
731 (sign_extend:HI (match_dup 1)))
733 (compare:CC (match_dup 0)
737 (define_expand "extendqihi2_power"
738 [(parallel [(set (match_dup 2)
739 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
741 (clobber (scratch:SI))])
742 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
743 (ashiftrt:SI (match_dup 2)
745 (clobber (scratch:SI))])]
748 { operands[0] = gen_lowpart (SImode, operands[0]);
749 operands[1] = gen_lowpart (SImode, operands[1]);
750 operands[2] = gen_reg_rtx (SImode); }")
752 (define_expand "extendqihi2_no_power"
754 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
756 (set (match_operand:HI 0 "gpc_reg_operand" "")
757 (ashiftrt:SI (match_dup 2)
759 "! TARGET_POWER && ! TARGET_POWERPC"
761 { operands[0] = gen_lowpart (SImode, operands[0]);
762 operands[1] = gen_lowpart (SImode, operands[1]);
763 operands[2] = gen_reg_rtx (SImode); }")
765 (define_expand "zero_extendhisi2"
766 [(set (match_operand:SI 0 "gpc_reg_operand" "")
767 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
772 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
773 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
777 {rlinm|rlwinm} %0,%1,0,0xffff"
778 [(set_attr "type" "load,*")])
781 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
782 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
784 (clobber (match_scratch:SI 2 "=r,r"))]
787 {andil.|andi.} %2,%1,0xffff
789 [(set_attr "type" "compare")
790 (set_attr "length" "4,8")])
793 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
794 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
796 (clobber (match_scratch:SI 2 ""))]
799 (zero_extend:SI (match_dup 1)))
801 (compare:CC (match_dup 2)
806 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
807 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
809 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
810 (zero_extend:SI (match_dup 1)))]
813 {andil.|andi.} %0,%1,0xffff
815 [(set_attr "type" "compare")
816 (set_attr "length" "4,8")])
819 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
820 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
822 (set (match_operand:SI 0 "gpc_reg_operand" "")
823 (zero_extend:SI (match_dup 1)))]
826 (zero_extend:SI (match_dup 1)))
828 (compare:CC (match_dup 0)
832 (define_expand "extendhisi2"
833 [(set (match_operand:SI 0 "gpc_reg_operand" "")
834 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
839 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
840 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
845 [(set_attr "type" "load_ext,*")])
848 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
849 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
851 (clobber (match_scratch:SI 2 "=r,r"))]
856 [(set_attr "type" "compare")
857 (set_attr "length" "4,8")])
860 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
861 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
863 (clobber (match_scratch:SI 2 ""))]
866 (sign_extend:SI (match_dup 1)))
868 (compare:CC (match_dup 2)
873 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
874 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
876 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
877 (sign_extend:SI (match_dup 1)))]
882 [(set_attr "type" "compare")
883 (set_attr "length" "4,8")])
885 ;; IBM 405 and 440 half-word multiplication operations.
887 (define_insn "*macchwc"
888 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
889 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
890 (match_operand:SI 2 "gpc_reg_operand" "r")
893 (match_operand:HI 1 "gpc_reg_operand" "r")))
894 (match_operand:SI 4 "gpc_reg_operand" "0"))
896 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
897 (plus:SI (mult:SI (ashiftrt:SI
905 [(set_attr "type" "imul3")])
907 (define_insn "*macchw"
908 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
909 (plus:SI (mult:SI (ashiftrt:SI
910 (match_operand:SI 2 "gpc_reg_operand" "r")
913 (match_operand:HI 1 "gpc_reg_operand" "r")))
914 (match_operand:SI 3 "gpc_reg_operand" "0")))]
917 [(set_attr "type" "imul3")])
919 (define_insn "*macchwuc"
920 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
921 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
922 (match_operand:SI 2 "gpc_reg_operand" "r")
925 (match_operand:HI 1 "gpc_reg_operand" "r")))
926 (match_operand:SI 4 "gpc_reg_operand" "0"))
928 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
929 (plus:SI (mult:SI (lshiftrt:SI
936 "macchwu. %0, %1, %2"
937 [(set_attr "type" "imul3")])
939 (define_insn "*macchwu"
940 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
941 (plus:SI (mult:SI (lshiftrt:SI
942 (match_operand:SI 2 "gpc_reg_operand" "r")
945 (match_operand:HI 1 "gpc_reg_operand" "r")))
946 (match_operand:SI 3 "gpc_reg_operand" "0")))]
949 [(set_attr "type" "imul3")])
951 (define_insn "*machhwc"
952 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
953 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
954 (match_operand:SI 1 "gpc_reg_operand" "%r")
957 (match_operand:SI 2 "gpc_reg_operand" "r")
959 (match_operand:SI 4 "gpc_reg_operand" "0"))
961 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
962 (plus:SI (mult:SI (ashiftrt:SI
971 [(set_attr "type" "imul3")])
973 (define_insn "*machhw"
974 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
975 (plus:SI (mult:SI (ashiftrt:SI
976 (match_operand:SI 1 "gpc_reg_operand" "%r")
979 (match_operand:SI 2 "gpc_reg_operand" "r")
981 (match_operand:SI 3 "gpc_reg_operand" "0")))]
984 [(set_attr "type" "imul3")])
986 (define_insn "*machhwuc"
987 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
988 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
989 (match_operand:SI 1 "gpc_reg_operand" "%r")
992 (match_operand:SI 2 "gpc_reg_operand" "r")
994 (match_operand:SI 4 "gpc_reg_operand" "0"))
996 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
997 (plus:SI (mult:SI (lshiftrt:SI
1005 "machhwu. %0, %1, %2"
1006 [(set_attr "type" "imul3")])
1008 (define_insn "*machhwu"
1009 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1010 (plus:SI (mult:SI (lshiftrt:SI
1011 (match_operand:SI 1 "gpc_reg_operand" "%r")
1014 (match_operand:SI 2 "gpc_reg_operand" "r")
1016 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1018 "machhwu %0, %1, %2"
1019 [(set_attr "type" "imul3")])
1021 (define_insn "*maclhwc"
1022 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1023 (compare:CC (plus:SI (mult:SI (sign_extend:SI
1024 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1026 (match_operand:HI 2 "gpc_reg_operand" "r")))
1027 (match_operand:SI 4 "gpc_reg_operand" "0"))
1029 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1030 (plus:SI (mult:SI (sign_extend:SI
1036 "maclhw. %0, %1, %2"
1037 [(set_attr "type" "imul3")])
1039 (define_insn "*maclhw"
1040 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1041 (plus:SI (mult:SI (sign_extend:SI
1042 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1044 (match_operand:HI 2 "gpc_reg_operand" "r")))
1045 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1048 [(set_attr "type" "imul3")])
1050 (define_insn "*maclhwuc"
1051 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1052 (compare:CC (plus:SI (mult:SI (zero_extend:SI
1053 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1055 (match_operand:HI 2 "gpc_reg_operand" "r")))
1056 (match_operand:SI 4 "gpc_reg_operand" "0"))
1058 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1059 (plus:SI (mult:SI (zero_extend:SI
1065 "maclhwu. %0, %1, %2"
1066 [(set_attr "type" "imul3")])
1068 (define_insn "*maclhwu"
1069 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1070 (plus:SI (mult:SI (zero_extend:SI
1071 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1073 (match_operand:HI 2 "gpc_reg_operand" "r")))
1074 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1076 "maclhwu %0, %1, %2"
1077 [(set_attr "type" "imul3")])
1079 (define_insn "*nmacchwc"
1080 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1081 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1082 (mult:SI (ashiftrt:SI
1083 (match_operand:SI 2 "gpc_reg_operand" "r")
1086 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1088 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1089 (minus:SI (match_dup 4)
1090 (mult:SI (ashiftrt:SI
1096 "nmacchw. %0, %1, %2"
1097 [(set_attr "type" "imul3")])
1099 (define_insn "*nmacchw"
1100 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1101 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1102 (mult:SI (ashiftrt:SI
1103 (match_operand:SI 2 "gpc_reg_operand" "r")
1106 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1108 "nmacchw %0, %1, %2"
1109 [(set_attr "type" "imul3")])
1111 (define_insn "*nmachhwc"
1112 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1113 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1114 (mult:SI (ashiftrt:SI
1115 (match_operand:SI 1 "gpc_reg_operand" "%r")
1118 (match_operand:SI 2 "gpc_reg_operand" "r")
1121 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1122 (minus:SI (match_dup 4)
1123 (mult:SI (ashiftrt:SI
1130 "nmachhw. %0, %1, %2"
1131 [(set_attr "type" "imul3")])
1133 (define_insn "*nmachhw"
1134 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1135 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1136 (mult:SI (ashiftrt:SI
1137 (match_operand:SI 1 "gpc_reg_operand" "%r")
1140 (match_operand:SI 2 "gpc_reg_operand" "r")
1143 "nmachhw %0, %1, %2"
1144 [(set_attr "type" "imul3")])
1146 (define_insn "*nmaclhwc"
1147 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1148 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1149 (mult:SI (sign_extend:SI
1150 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1152 (match_operand:HI 2 "gpc_reg_operand" "r"))))
1154 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1155 (minus:SI (match_dup 4)
1156 (mult:SI (sign_extend:SI
1161 "nmaclhw. %0, %1, %2"
1162 [(set_attr "type" "imul3")])
1164 (define_insn "*nmaclhw"
1165 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1166 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1167 (mult:SI (sign_extend:SI
1168 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1170 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1172 "nmaclhw %0, %1, %2"
1173 [(set_attr "type" "imul3")])
1175 (define_insn "*mulchwc"
1176 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1177 (compare:CC (mult:SI (ashiftrt:SI
1178 (match_operand:SI 2 "gpc_reg_operand" "r")
1181 (match_operand:HI 1 "gpc_reg_operand" "r")))
1183 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1184 (mult:SI (ashiftrt:SI
1190 "mulchw. %0, %1, %2"
1191 [(set_attr "type" "imul3")])
1193 (define_insn "*mulchw"
1194 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1195 (mult:SI (ashiftrt:SI
1196 (match_operand:SI 2 "gpc_reg_operand" "r")
1199 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1202 [(set_attr "type" "imul3")])
1204 (define_insn "*mulchwuc"
1205 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1206 (compare:CC (mult:SI (lshiftrt:SI
1207 (match_operand:SI 2 "gpc_reg_operand" "r")
1210 (match_operand:HI 1 "gpc_reg_operand" "r")))
1212 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1213 (mult:SI (lshiftrt:SI
1219 "mulchwu. %0, %1, %2"
1220 [(set_attr "type" "imul3")])
1222 (define_insn "*mulchwu"
1223 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1224 (mult:SI (lshiftrt:SI
1225 (match_operand:SI 2 "gpc_reg_operand" "r")
1228 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1230 "mulchwu %0, %1, %2"
1231 [(set_attr "type" "imul3")])
1233 (define_insn "*mulhhwc"
1234 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1235 (compare:CC (mult:SI (ashiftrt:SI
1236 (match_operand:SI 1 "gpc_reg_operand" "%r")
1239 (match_operand:SI 2 "gpc_reg_operand" "r")
1242 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1243 (mult:SI (ashiftrt:SI
1250 "mulhhw. %0, %1, %2"
1251 [(set_attr "type" "imul3")])
1253 (define_insn "*mulhhw"
1254 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1255 (mult:SI (ashiftrt:SI
1256 (match_operand:SI 1 "gpc_reg_operand" "%r")
1259 (match_operand:SI 2 "gpc_reg_operand" "r")
1263 [(set_attr "type" "imul3")])
1265 (define_insn "*mulhhwuc"
1266 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1267 (compare:CC (mult:SI (lshiftrt:SI
1268 (match_operand:SI 1 "gpc_reg_operand" "%r")
1271 (match_operand:SI 2 "gpc_reg_operand" "r")
1274 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1275 (mult:SI (lshiftrt:SI
1282 "mulhhwu. %0, %1, %2"
1283 [(set_attr "type" "imul3")])
1285 (define_insn "*mulhhwu"
1286 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1287 (mult:SI (lshiftrt:SI
1288 (match_operand:SI 1 "gpc_reg_operand" "%r")
1291 (match_operand:SI 2 "gpc_reg_operand" "r")
1294 "mulhhwu %0, %1, %2"
1295 [(set_attr "type" "imul3")])
1297 (define_insn "*mullhwc"
1298 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1299 (compare:CC (mult:SI (sign_extend:SI
1300 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1302 (match_operand:HI 2 "gpc_reg_operand" "r")))
1304 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1305 (mult:SI (sign_extend:SI
1310 "mullhw. %0, %1, %2"
1311 [(set_attr "type" "imul3")])
1313 (define_insn "*mullhw"
1314 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1315 (mult:SI (sign_extend:SI
1316 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1318 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1321 [(set_attr "type" "imul3")])
1323 (define_insn "*mullhwuc"
1324 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1325 (compare:CC (mult:SI (zero_extend:SI
1326 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1328 (match_operand:HI 2 "gpc_reg_operand" "r")))
1330 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1331 (mult:SI (zero_extend:SI
1336 "mullhwu. %0, %1, %2"
1337 [(set_attr "type" "imul3")])
1339 (define_insn "*mullhwu"
1340 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1341 (mult:SI (zero_extend:SI
1342 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1344 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1346 "mullhwu %0, %1, %2"
1347 [(set_attr "type" "imul3")])
1349 ;; IBM 405 and 440 string-search dlmzb instruction support.
1350 (define_insn "dlmzb"
1351 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1352 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1353 (match_operand:SI 2 "gpc_reg_operand" "r")]
1355 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1356 (unspec:SI [(match_dup 1)
1360 "dlmzb. %0, %1, %2")
1362 (define_expand "strlensi"
1363 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1364 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1365 (match_operand:QI 2 "const_int_operand" "")
1366 (match_operand 3 "const_int_operand" "")]
1367 UNSPEC_DLMZB_STRLEN))
1368 (clobber (match_scratch:CC 4 "=x"))]
1369 "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1371 rtx result = operands[0];
1372 rtx src = operands[1];
1373 rtx search_char = operands[2];
1374 rtx align = operands[3];
1375 rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1376 rtx loop_label, end_label, mem, cr0, cond;
1377 if (search_char != const0_rtx
1378 || GET_CODE (align) != CONST_INT
1379 || INTVAL (align) < 8)
1381 word1 = gen_reg_rtx (SImode);
1382 word2 = gen_reg_rtx (SImode);
1383 scratch_dlmzb = gen_reg_rtx (SImode);
1384 scratch_string = gen_reg_rtx (Pmode);
1385 loop_label = gen_label_rtx ();
1386 end_label = gen_label_rtx ();
1387 addr = force_reg (Pmode, XEXP (src, 0));
1388 emit_move_insn (scratch_string, addr);
1389 emit_label (loop_label);
1390 mem = change_address (src, SImode, scratch_string);
1391 emit_move_insn (word1, mem);
1392 emit_move_insn (word2, adjust_address (mem, SImode, 4));
1393 cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1394 emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1395 cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1396 emit_jump_insn (gen_rtx_SET (VOIDmode,
1398 gen_rtx_IF_THEN_ELSE (VOIDmode,
1404 emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1405 emit_jump_insn (gen_rtx_SET (VOIDmode,
1407 gen_rtx_LABEL_REF (VOIDmode, loop_label)));
1408 emit_label (end_label);
1409 emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1410 emit_insn (gen_subsi3 (result, scratch_string, addr));
1411 emit_insn (gen_subsi3 (result, result, const1_rtx));
1416 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1417 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1419 (set (match_operand:SI 0 "gpc_reg_operand" "")
1420 (sign_extend:SI (match_dup 1)))]
1423 (sign_extend:SI (match_dup 1)))
1425 (compare:CC (match_dup 0)
1429 ;; Fixed-point arithmetic insns.
1431 (define_expand "add<mode>3"
1432 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1433 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1434 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1438 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1440 if (non_short_cint_operand (operands[2], DImode))
1443 else if (GET_CODE (operands[2]) == CONST_INT
1444 && ! add_operand (operands[2], <MODE>mode))
1446 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
1447 ? operands[0] : gen_reg_rtx (<MODE>mode));
1449 HOST_WIDE_INT val = INTVAL (operands[2]);
1450 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1451 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1453 if (<MODE>mode == DImode && !CONST_OK_FOR_LETTER_P (rest, 'L'))
1456 /* The ordering here is important for the prolog expander.
1457 When space is allocated from the stack, adding 'low' first may
1458 produce a temporary deallocation (which would be bad). */
1459 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1460 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1465 ;; Discourage ai/addic because of carry but provide it in an alternative
1466 ;; allowing register zero as source.
1467 (define_insn "*add<mode>3_internal1"
1468 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1469 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1470 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
1474 {cal %0,%2(%1)|addi %0,%1,%2}
1476 {cau|addis} %0,%1,%v2"
1477 [(set_attr "length" "4,4,4,4")])
1479 (define_insn "addsi3_high"
1480 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1481 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1482 (high:SI (match_operand 2 "" ""))))]
1483 "TARGET_MACHO && !TARGET_64BIT"
1484 "{cau|addis} %0,%1,ha16(%2)"
1485 [(set_attr "length" "4")])
1487 (define_insn "*add<mode>3_internal2"
1488 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1489 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1490 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1492 (clobber (match_scratch:P 3 "=r,r,r,r"))]
1495 {cax.|add.} %3,%1,%2
1496 {ai.|addic.} %3,%1,%2
1499 [(set_attr "type" "fast_compare,compare,compare,compare")
1500 (set_attr "length" "4,4,8,8")])
1503 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1504 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1505 (match_operand:GPR 2 "reg_or_short_operand" ""))
1507 (clobber (match_scratch:GPR 3 ""))]
1510 (plus:GPR (match_dup 1)
1513 (compare:CC (match_dup 3)
1517 (define_insn "*add<mode>3_internal3"
1518 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1519 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1520 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1522 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1523 (plus:P (match_dup 1)
1527 {cax.|add.} %0,%1,%2
1528 {ai.|addic.} %0,%1,%2
1531 [(set_attr "type" "fast_compare,compare,compare,compare")
1532 (set_attr "length" "4,4,8,8")])
1535 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1536 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1537 (match_operand:P 2 "reg_or_short_operand" ""))
1539 (set (match_operand:P 0 "gpc_reg_operand" "")
1540 (plus:P (match_dup 1) (match_dup 2)))]
1543 (plus:P (match_dup 1)
1546 (compare:CC (match_dup 0)
1550 ;; Split an add that we can't do in one insn into two insns, each of which
1551 ;; does one 16-bit part. This is used by combine. Note that the low-order
1552 ;; add should be last in case the result gets used in an address.
1555 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1556 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1557 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1559 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1560 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1563 HOST_WIDE_INT val = INTVAL (operands[2]);
1564 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1565 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1567 operands[4] = GEN_INT (low);
1568 if (<MODE>mode == SImode || CONST_OK_FOR_LETTER_P (rest, 'L'))
1569 operands[3] = GEN_INT (rest);
1570 else if (! no_new_pseudos)
1572 operands[3] = gen_reg_rtx (DImode);
1573 emit_move_insn (operands[3], operands[2]);
1574 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1581 (define_insn "one_cmpl<mode>2"
1582 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1583 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1588 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1589 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1591 (clobber (match_scratch:P 2 "=r,r"))]
1596 [(set_attr "type" "compare")
1597 (set_attr "length" "4,8")])
1600 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1601 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1603 (clobber (match_scratch:P 2 ""))]
1606 (not:P (match_dup 1)))
1608 (compare:CC (match_dup 2)
1613 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1614 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1616 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1617 (not:P (match_dup 1)))]
1622 [(set_attr "type" "compare")
1623 (set_attr "length" "4,8")])
1626 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1627 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1629 (set (match_operand:P 0 "gpc_reg_operand" "")
1630 (not:P (match_dup 1)))]
1633 (not:P (match_dup 1)))
1635 (compare:CC (match_dup 0)
1640 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1641 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1642 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1644 "{sf%I1|subf%I1c} %0,%2,%1")
1647 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1648 (minus:GPR (match_operand:GPR 1 "reg_or_short_operand" "r,I")
1649 (match_operand:GPR 2 "gpc_reg_operand" "r,r")))]
1656 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1657 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1658 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1660 (clobber (match_scratch:SI 3 "=r,r"))]
1663 {sf.|subfc.} %3,%2,%1
1665 [(set_attr "type" "compare")
1666 (set_attr "length" "4,8")])
1669 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1670 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1671 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1673 (clobber (match_scratch:P 3 "=r,r"))]
1678 [(set_attr "type" "fast_compare")
1679 (set_attr "length" "4,8")])
1682 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1683 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1684 (match_operand:P 2 "gpc_reg_operand" ""))
1686 (clobber (match_scratch:P 3 ""))]
1689 (minus:P (match_dup 1)
1692 (compare:CC (match_dup 3)
1697 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1698 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1699 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1701 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1702 (minus:SI (match_dup 1) (match_dup 2)))]
1705 {sf.|subfc.} %0,%2,%1
1707 [(set_attr "type" "compare")
1708 (set_attr "length" "4,8")])
1711 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1712 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1713 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1715 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1716 (minus:P (match_dup 1)
1722 [(set_attr "type" "fast_compare")
1723 (set_attr "length" "4,8")])
1726 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1727 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1728 (match_operand:P 2 "gpc_reg_operand" ""))
1730 (set (match_operand:P 0 "gpc_reg_operand" "")
1731 (minus:P (match_dup 1)
1735 (minus:P (match_dup 1)
1738 (compare:CC (match_dup 0)
1742 (define_expand "sub<mode>3"
1743 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1744 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1745 (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
1749 if (GET_CODE (operands[2]) == CONST_INT)
1751 emit_insn (gen_add<mode>3 (operands[0], operands[1],
1752 negate_rtx (<MODE>mode, operands[2])));
1757 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1758 ;; instruction and some auxiliary computations. Then we just have a single
1759 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1762 (define_expand "sminsi3"
1764 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1765 (match_operand:SI 2 "reg_or_short_operand" ""))
1767 (minus:SI (match_dup 2) (match_dup 1))))
1768 (set (match_operand:SI 0 "gpc_reg_operand" "")
1769 (minus:SI (match_dup 2) (match_dup 3)))]
1770 "TARGET_POWER || TARGET_ISEL"
1775 operands[2] = force_reg (SImode, operands[2]);
1776 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1780 operands[3] = gen_reg_rtx (SImode);
1784 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1785 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1786 (match_operand:SI 2 "reg_or_short_operand" "")))
1787 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1790 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1792 (minus:SI (match_dup 2) (match_dup 1))))
1793 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1796 (define_expand "smaxsi3"
1798 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1799 (match_operand:SI 2 "reg_or_short_operand" ""))
1801 (minus:SI (match_dup 2) (match_dup 1))))
1802 (set (match_operand:SI 0 "gpc_reg_operand" "")
1803 (plus:SI (match_dup 3) (match_dup 1)))]
1804 "TARGET_POWER || TARGET_ISEL"
1809 operands[2] = force_reg (SImode, operands[2]);
1810 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1813 operands[3] = gen_reg_rtx (SImode);
1817 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1818 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1819 (match_operand:SI 2 "reg_or_short_operand" "")))
1820 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1823 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1825 (minus:SI (match_dup 2) (match_dup 1))))
1826 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1829 (define_expand "uminsi3"
1830 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1832 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1834 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1836 (minus:SI (match_dup 4) (match_dup 3))))
1837 (set (match_operand:SI 0 "gpc_reg_operand" "")
1838 (minus:SI (match_dup 2) (match_dup 3)))]
1839 "TARGET_POWER || TARGET_ISEL"
1844 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1847 operands[3] = gen_reg_rtx (SImode);
1848 operands[4] = gen_reg_rtx (SImode);
1849 operands[5] = GEN_INT (-2147483647 - 1);
1852 (define_expand "umaxsi3"
1853 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1855 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1857 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1859 (minus:SI (match_dup 4) (match_dup 3))))
1860 (set (match_operand:SI 0 "gpc_reg_operand" "")
1861 (plus:SI (match_dup 3) (match_dup 1)))]
1862 "TARGET_POWER || TARGET_ISEL"
1867 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1870 operands[3] = gen_reg_rtx (SImode);
1871 operands[4] = gen_reg_rtx (SImode);
1872 operands[5] = GEN_INT (-2147483647 - 1);
1876 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1877 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1878 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1880 (minus:SI (match_dup 2) (match_dup 1))))]
1885 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1887 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1888 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1890 (minus:SI (match_dup 2) (match_dup 1)))
1892 (clobber (match_scratch:SI 3 "=r,r"))]
1897 [(set_attr "type" "delayed_compare")
1898 (set_attr "length" "4,8")])
1901 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1903 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1904 (match_operand:SI 2 "reg_or_short_operand" ""))
1906 (minus:SI (match_dup 2) (match_dup 1)))
1908 (clobber (match_scratch:SI 3 ""))]
1909 "TARGET_POWER && reload_completed"
1911 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1913 (minus:SI (match_dup 2) (match_dup 1))))
1915 (compare:CC (match_dup 3)
1920 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1922 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1923 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1925 (minus:SI (match_dup 2) (match_dup 1)))
1927 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1928 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1930 (minus:SI (match_dup 2) (match_dup 1))))]
1935 [(set_attr "type" "delayed_compare")
1936 (set_attr "length" "4,8")])
1939 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1941 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1942 (match_operand:SI 2 "reg_or_short_operand" ""))
1944 (minus:SI (match_dup 2) (match_dup 1)))
1946 (set (match_operand:SI 0 "gpc_reg_operand" "")
1947 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1949 (minus:SI (match_dup 2) (match_dup 1))))]
1950 "TARGET_POWER && reload_completed"
1952 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1954 (minus:SI (match_dup 2) (match_dup 1))))
1956 (compare:CC (match_dup 0)
1960 ;; We don't need abs with condition code because such comparisons should
1962 (define_expand "abssi2"
1963 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1964 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1970 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
1973 else if (! TARGET_POWER)
1975 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
1980 (define_insn "*abssi2_power"
1981 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1982 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1986 (define_insn_and_split "abssi2_isel"
1987 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1988 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
1989 (clobber (match_scratch:SI 2 "=&b"))
1990 (clobber (match_scratch:CC 3 "=y"))]
1993 "&& reload_completed"
1994 [(set (match_dup 2) (neg:SI (match_dup 1)))
1996 (compare:CC (match_dup 1)
1999 (if_then_else:SI (ge (match_dup 3)
2005 (define_insn_and_split "abssi2_nopower"
2006 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2007 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
2008 (clobber (match_scratch:SI 2 "=&r,&r"))]
2009 "! TARGET_POWER && ! TARGET_ISEL"
2011 "&& reload_completed"
2012 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2013 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2014 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
2017 (define_insn "*nabs_power"
2018 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2019 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
2023 (define_insn_and_split "*nabs_nopower"
2024 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2025 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
2026 (clobber (match_scratch:SI 2 "=&r,&r"))]
2029 "&& reload_completed"
2030 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2031 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2032 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
2035 (define_expand "neg<mode>2"
2036 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2037 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
2041 (define_insn "*neg<mode>2_internal"
2042 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2043 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2048 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2049 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2051 (clobber (match_scratch:P 2 "=r,r"))]
2056 [(set_attr "type" "fast_compare")
2057 (set_attr "length" "4,8")])
2060 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2061 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2063 (clobber (match_scratch:P 2 ""))]
2066 (neg:P (match_dup 1)))
2068 (compare:CC (match_dup 2)
2073 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2074 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2076 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2077 (neg:P (match_dup 1)))]
2082 [(set_attr "type" "fast_compare")
2083 (set_attr "length" "4,8")])
2086 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2087 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2089 (set (match_operand:P 0 "gpc_reg_operand" "")
2090 (neg:P (match_dup 1)))]
2093 (neg:P (match_dup 1)))
2095 (compare:CC (match_dup 0)
2099 (define_insn "clz<mode>2"
2100 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2101 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2103 "{cntlz|cntlz<wd>} %0,%1")
2105 (define_expand "ctz<mode>2"
2107 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))
2108 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2110 (clobber (scratch:CC))])
2111 (set (match_dup 4) (clz:GPR (match_dup 3)))
2112 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2113 (minus:GPR (match_dup 5) (match_dup 4)))]
2116 operands[2] = gen_reg_rtx (<MODE>mode);
2117 operands[3] = gen_reg_rtx (<MODE>mode);
2118 operands[4] = gen_reg_rtx (<MODE>mode);
2119 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
2122 (define_expand "ffs<mode>2"
2124 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))
2125 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2127 (clobber (scratch:CC))])
2128 (set (match_dup 4) (clz:GPR (match_dup 3)))
2129 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2130 (minus:GPR (match_dup 5) (match_dup 4)))]
2133 operands[2] = gen_reg_rtx (<MODE>mode);
2134 operands[3] = gen_reg_rtx (<MODE>mode);
2135 operands[4] = gen_reg_rtx (<MODE>mode);
2136 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
2139 (define_expand "popcount<mode>2"
2141 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2144 (mult:GPR (match_dup 2) (match_dup 4)))
2145 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2146 (lshiftrt:GPR (match_dup 3) (match_dup 5)))]
2149 operands[2] = gen_reg_rtx (<MODE>mode);
2150 operands[3] = gen_reg_rtx (<MODE>mode);
2151 operands[4] = force_reg (<MODE>mode,
2152 <MODE>mode == SImode
2153 ? GEN_INT (0x01010101)
2154 : GEN_INT ((HOST_WIDE_INT)
2155 0x01010101 << 32 | 0x01010101));
2156 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 8);
2159 (define_insn "popcntb<mode>2"
2160 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2161 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2166 (define_expand "mulsi3"
2167 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2168 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2169 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2174 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2176 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2180 (define_insn "mulsi3_mq"
2181 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2182 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2183 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2184 (clobber (match_scratch:SI 3 "=q,q"))]
2187 {muls|mullw} %0,%1,%2
2188 {muli|mulli} %0,%1,%2"
2190 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2191 (const_string "imul3")
2192 (match_operand:SI 2 "short_cint_operand" "")
2193 (const_string "imul2")]
2194 (const_string "imul")))])
2196 (define_insn "mulsi3_no_mq"
2197 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2198 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2199 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2202 {muls|mullw} %0,%1,%2
2203 {muli|mulli} %0,%1,%2"
2205 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2206 (const_string "imul3")
2207 (match_operand:SI 2 "short_cint_operand" "")
2208 (const_string "imul2")]
2209 (const_string "imul")))])
2211 (define_insn "*mulsi3_mq_internal1"
2212 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2213 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2214 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2216 (clobber (match_scratch:SI 3 "=r,r"))
2217 (clobber (match_scratch:SI 4 "=q,q"))]
2220 {muls.|mullw.} %3,%1,%2
2222 [(set_attr "type" "imul_compare")
2223 (set_attr "length" "4,8")])
2226 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2227 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2228 (match_operand:SI 2 "gpc_reg_operand" ""))
2230 (clobber (match_scratch:SI 3 ""))
2231 (clobber (match_scratch:SI 4 ""))]
2232 "TARGET_POWER && reload_completed"
2233 [(parallel [(set (match_dup 3)
2234 (mult:SI (match_dup 1) (match_dup 2)))
2235 (clobber (match_dup 4))])
2237 (compare:CC (match_dup 3)
2241 (define_insn "*mulsi3_no_mq_internal1"
2242 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2243 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2244 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2246 (clobber (match_scratch:SI 3 "=r,r"))]
2249 {muls.|mullw.} %3,%1,%2
2251 [(set_attr "type" "imul_compare")
2252 (set_attr "length" "4,8")])
2255 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2256 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2257 (match_operand:SI 2 "gpc_reg_operand" ""))
2259 (clobber (match_scratch:SI 3 ""))]
2260 "! TARGET_POWER && reload_completed"
2262 (mult:SI (match_dup 1) (match_dup 2)))
2264 (compare:CC (match_dup 3)
2268 (define_insn "*mulsi3_mq_internal2"
2269 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2270 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2271 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2273 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2274 (mult:SI (match_dup 1) (match_dup 2)))
2275 (clobber (match_scratch:SI 4 "=q,q"))]
2278 {muls.|mullw.} %0,%1,%2
2280 [(set_attr "type" "imul_compare")
2281 (set_attr "length" "4,8")])
2284 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2285 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2286 (match_operand:SI 2 "gpc_reg_operand" ""))
2288 (set (match_operand:SI 0 "gpc_reg_operand" "")
2289 (mult:SI (match_dup 1) (match_dup 2)))
2290 (clobber (match_scratch:SI 4 ""))]
2291 "TARGET_POWER && reload_completed"
2292 [(parallel [(set (match_dup 0)
2293 (mult:SI (match_dup 1) (match_dup 2)))
2294 (clobber (match_dup 4))])
2296 (compare:CC (match_dup 0)
2300 (define_insn "*mulsi3_no_mq_internal2"
2301 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2302 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2303 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2305 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2306 (mult:SI (match_dup 1) (match_dup 2)))]
2309 {muls.|mullw.} %0,%1,%2
2311 [(set_attr "type" "imul_compare")
2312 (set_attr "length" "4,8")])
2315 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2316 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2317 (match_operand:SI 2 "gpc_reg_operand" ""))
2319 (set (match_operand:SI 0 "gpc_reg_operand" "")
2320 (mult:SI (match_dup 1) (match_dup 2)))]
2321 "! TARGET_POWER && reload_completed"
2323 (mult:SI (match_dup 1) (match_dup 2)))
2325 (compare:CC (match_dup 0)
2329 ;; Operand 1 is divided by operand 2; quotient goes to operand
2330 ;; 0 and remainder to operand 3.
2331 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2333 (define_expand "divmodsi4"
2334 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2335 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2336 (match_operand:SI 2 "gpc_reg_operand" "")))
2337 (set (match_operand:SI 3 "register_operand" "")
2338 (mod:SI (match_dup 1) (match_dup 2)))])]
2339 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2342 if (! TARGET_POWER && ! TARGET_POWERPC)
2344 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2345 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2346 emit_insn (gen_divss_call ());
2347 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2348 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2353 (define_insn "*divmodsi4_internal"
2354 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2355 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2356 (match_operand:SI 2 "gpc_reg_operand" "r")))
2357 (set (match_operand:SI 3 "register_operand" "=q")
2358 (mod:SI (match_dup 1) (match_dup 2)))]
2361 [(set_attr "type" "idiv")])
2363 (define_expand "udiv<mode>3"
2364 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2365 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2366 (match_operand:GPR 2 "gpc_reg_operand" "")))]
2367 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2370 if (! TARGET_POWER && ! TARGET_POWERPC)
2372 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2373 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2374 emit_insn (gen_quous_call ());
2375 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2378 else if (TARGET_POWER)
2380 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2385 (define_insn "udivsi3_mq"
2386 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2387 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2388 (match_operand:SI 2 "gpc_reg_operand" "r")))
2389 (clobber (match_scratch:SI 3 "=q"))]
2390 "TARGET_POWERPC && TARGET_POWER"
2392 [(set_attr "type" "idiv")])
2394 (define_insn "*udivsi3_no_mq"
2395 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2396 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2397 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2398 "TARGET_POWERPC && ! TARGET_POWER"
2400 [(set_attr "type" "idiv")])
2402 ;; For powers of two we can do srai/aze for divide and then adjust for
2403 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2404 ;; used; for PowerPC, force operands into register and do a normal divide;
2405 ;; for AIX common-mode, use quoss call on register operands.
2406 (define_expand "div<mode>3"
2407 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2408 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2409 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2413 if (GET_CODE (operands[2]) == CONST_INT
2414 && INTVAL (operands[2]) > 0
2415 && exact_log2 (INTVAL (operands[2])) >= 0)
2417 else if (TARGET_POWERPC)
2419 operands[2] = force_reg (SImode, operands[2]);
2422 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2426 else if (TARGET_POWER)
2430 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2431 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2432 emit_insn (gen_quoss_call ());
2433 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2438 (define_insn "divsi3_mq"
2439 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2440 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2441 (match_operand:SI 2 "gpc_reg_operand" "r")))
2442 (clobber (match_scratch:SI 3 "=q"))]
2443 "TARGET_POWERPC && TARGET_POWER"
2445 [(set_attr "type" "idiv")])
2447 (define_insn "*div<mode>3_no_mq"
2448 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2449 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2450 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2451 "TARGET_POWERPC && ! TARGET_POWER"
2453 [(set_attr "type" "idiv")])
2455 (define_expand "mod<mode>3"
2456 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2457 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2458 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
2466 if (GET_CODE (operands[2]) != CONST_INT
2467 || INTVAL (operands[2]) <= 0
2468 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2471 temp1 = gen_reg_rtx (<MODE>mode);
2472 temp2 = gen_reg_rtx (<MODE>mode);
2474 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2475 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2476 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
2481 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2482 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2483 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
2485 "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
2486 [(set_attr "type" "two")
2487 (set_attr "length" "8")])
2490 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2491 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2492 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2494 (clobber (match_scratch:P 3 "=r,r"))]
2497 {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
2499 [(set_attr "type" "compare")
2500 (set_attr "length" "8,12")])
2503 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2504 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2505 (match_operand:GPR 2 "exact_log2_cint_operand"
2508 (clobber (match_scratch:GPR 3 ""))]
2511 (div:<MODE> (match_dup 1) (match_dup 2)))
2513 (compare:CC (match_dup 3)
2518 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2519 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2520 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2522 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2523 (div:P (match_dup 1) (match_dup 2)))]
2526 {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
2528 [(set_attr "type" "compare")
2529 (set_attr "length" "8,12")])
2532 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2533 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2534 (match_operand:GPR 2 "exact_log2_cint_operand"
2537 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2538 (div:GPR (match_dup 1) (match_dup 2)))]
2541 (div:<MODE> (match_dup 1) (match_dup 2)))
2543 (compare:CC (match_dup 0)
2548 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2551 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2553 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2554 (match_operand:SI 3 "gpc_reg_operand" "r")))
2555 (set (match_operand:SI 2 "register_operand" "=*q")
2558 (zero_extend:DI (match_dup 1)) (const_int 32))
2559 (zero_extend:DI (match_dup 4)))
2563 [(set_attr "type" "idiv")])
2565 ;; To do unsigned divide we handle the cases of the divisor looking like a
2566 ;; negative number. If it is a constant that is less than 2**31, we don't
2567 ;; have to worry about the branches. So make a few subroutines here.
2569 ;; First comes the normal case.
2570 (define_expand "udivmodsi4_normal"
2571 [(set (match_dup 4) (const_int 0))
2572 (parallel [(set (match_operand:SI 0 "" "")
2573 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2575 (zero_extend:DI (match_operand:SI 1 "" "")))
2576 (match_operand:SI 2 "" "")))
2577 (set (match_operand:SI 3 "" "")
2578 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2580 (zero_extend:DI (match_dup 1)))
2584 { operands[4] = gen_reg_rtx (SImode); }")
2586 ;; This handles the branches.
2587 (define_expand "udivmodsi4_tests"
2588 [(set (match_operand:SI 0 "" "") (const_int 0))
2589 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2590 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2591 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2592 (label_ref (match_operand:SI 4 "" "")) (pc)))
2593 (set (match_dup 0) (const_int 1))
2594 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2595 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2596 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2597 (label_ref (match_dup 4)) (pc)))]
2600 { operands[5] = gen_reg_rtx (CCUNSmode);
2601 operands[6] = gen_reg_rtx (CCmode);
2604 (define_expand "udivmodsi4"
2605 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2606 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2607 (match_operand:SI 2 "reg_or_cint_operand" "")))
2608 (set (match_operand:SI 3 "gpc_reg_operand" "")
2609 (umod:SI (match_dup 1) (match_dup 2)))])]
2617 if (! TARGET_POWERPC)
2619 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2620 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2621 emit_insn (gen_divus_call ());
2622 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2623 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2630 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2632 operands[2] = force_reg (SImode, operands[2]);
2633 label = gen_label_rtx ();
2634 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2635 operands[3], label));
2638 operands[2] = force_reg (SImode, operands[2]);
2640 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2648 ;; AIX architecture-independent common-mode multiply (DImode),
2649 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2650 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2651 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2652 ;; assumed unused if generating common-mode, so ignore.
2653 (define_insn "mulh_call"
2656 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2657 (sign_extend:DI (reg:SI 4)))
2659 (clobber (match_scratch:SI 0 "=l"))]
2660 "! TARGET_POWER && ! TARGET_POWERPC"
2662 [(set_attr "type" "imul")])
2664 (define_insn "mull_call"
2666 (mult:DI (sign_extend:DI (reg:SI 3))
2667 (sign_extend:DI (reg:SI 4))))
2668 (clobber (match_scratch:SI 0 "=l"))
2669 (clobber (reg:SI 0))]
2670 "! TARGET_POWER && ! TARGET_POWERPC"
2672 [(set_attr "type" "imul")])
2674 (define_insn "divss_call"
2676 (div:SI (reg:SI 3) (reg:SI 4)))
2678 (mod:SI (reg:SI 3) (reg:SI 4)))
2679 (clobber (match_scratch:SI 0 "=l"))
2680 (clobber (reg:SI 0))]
2681 "! TARGET_POWER && ! TARGET_POWERPC"
2683 [(set_attr "type" "idiv")])
2685 (define_insn "divus_call"
2687 (udiv:SI (reg:SI 3) (reg:SI 4)))
2689 (umod:SI (reg:SI 3) (reg:SI 4)))
2690 (clobber (match_scratch:SI 0 "=l"))
2691 (clobber (reg:SI 0))
2692 (clobber (match_scratch:CC 1 "=x"))
2693 (clobber (reg:CC 69))]
2694 "! TARGET_POWER && ! TARGET_POWERPC"
2696 [(set_attr "type" "idiv")])
2698 (define_insn "quoss_call"
2700 (div:SI (reg:SI 3) (reg:SI 4)))
2701 (clobber (match_scratch:SI 0 "=l"))]
2702 "! TARGET_POWER && ! TARGET_POWERPC"
2704 [(set_attr "type" "idiv")])
2706 (define_insn "quous_call"
2708 (udiv:SI (reg:SI 3) (reg:SI 4)))
2709 (clobber (match_scratch:SI 0 "=l"))
2710 (clobber (reg:SI 0))
2711 (clobber (match_scratch:CC 1 "=x"))
2712 (clobber (reg:CC 69))]
2713 "! TARGET_POWER && ! TARGET_POWERPC"
2715 [(set_attr "type" "idiv")])
2717 ;; Logical instructions
2718 ;; The logical instructions are mostly combined by using match_operator,
2719 ;; but the plain AND insns are somewhat different because there is no
2720 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2721 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2723 (define_insn "andsi3"
2724 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2725 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2726 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2727 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2731 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2732 {andil.|andi.} %0,%1,%b2
2733 {andiu.|andis.} %0,%1,%u2"
2734 [(set_attr "type" "*,*,compare,compare")])
2736 ;; Note to set cr's other than cr0 we do the and immediate and then
2737 ;; the test again -- this avoids a mfcr which on the higher end
2738 ;; machines causes an execution serialization
2740 (define_insn "*andsi3_internal2"
2741 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2742 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2743 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2745 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2746 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2750 {andil.|andi.} %3,%1,%b2
2751 {andiu.|andis.} %3,%1,%u2
2752 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2757 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2758 (set_attr "length" "4,4,4,4,8,8,8,8")])
2760 (define_insn "*andsi3_internal3"
2761 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2762 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2763 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2765 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2766 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2770 {andil.|andi.} %3,%1,%b2
2771 {andiu.|andis.} %3,%1,%u2
2772 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2777 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2778 (set_attr "length" "8,4,4,4,8,8,8,8")])
2781 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2782 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2783 (match_operand:GPR 2 "and_operand" ""))
2785 (clobber (match_scratch:GPR 3 ""))
2786 (clobber (match_scratch:CC 4 ""))]
2788 [(parallel [(set (match_dup 3)
2789 (and:<MODE> (match_dup 1)
2791 (clobber (match_dup 4))])
2793 (compare:CC (match_dup 3)
2797 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2798 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2801 [(set (match_operand:CC 0 "cc_reg_operand" "")
2802 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2803 (match_operand:SI 2 "gpc_reg_operand" ""))
2805 (clobber (match_scratch:SI 3 ""))
2806 (clobber (match_scratch:CC 4 ""))]
2807 "TARGET_POWERPC64 && reload_completed"
2808 [(parallel [(set (match_dup 3)
2809 (and:SI (match_dup 1)
2811 (clobber (match_dup 4))])
2813 (compare:CC (match_dup 3)
2817 (define_insn "*andsi3_internal4"
2818 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2819 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2820 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2822 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2823 (and:SI (match_dup 1)
2825 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2829 {andil.|andi.} %0,%1,%b2
2830 {andiu.|andis.} %0,%1,%u2
2831 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2836 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2837 (set_attr "length" "4,4,4,4,8,8,8,8")])
2839 (define_insn "*andsi3_internal5"
2840 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2841 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2842 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2844 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2845 (and:SI (match_dup 1)
2847 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2851 {andil.|andi.} %0,%1,%b2
2852 {andiu.|andis.} %0,%1,%u2
2853 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2858 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2859 (set_attr "length" "8,4,4,4,8,8,8,8")])
2862 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2863 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2864 (match_operand:SI 2 "and_operand" ""))
2866 (set (match_operand:SI 0 "gpc_reg_operand" "")
2867 (and:SI (match_dup 1)
2869 (clobber (match_scratch:CC 4 ""))]
2871 [(parallel [(set (match_dup 0)
2872 (and:SI (match_dup 1)
2874 (clobber (match_dup 4))])
2876 (compare:CC (match_dup 0)
2881 [(set (match_operand:CC 3 "cc_reg_operand" "")
2882 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2883 (match_operand:SI 2 "gpc_reg_operand" ""))
2885 (set (match_operand:SI 0 "gpc_reg_operand" "")
2886 (and:SI (match_dup 1)
2888 (clobber (match_scratch:CC 4 ""))]
2889 "TARGET_POWERPC64 && reload_completed"
2890 [(parallel [(set (match_dup 0)
2891 (and:SI (match_dup 1)
2893 (clobber (match_dup 4))])
2895 (compare:CC (match_dup 0)
2899 ;; Handle the PowerPC64 rlwinm corner case
2901 (define_insn_and_split "*andsi3_internal6"
2902 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2903 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2904 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2909 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2912 (rotate:SI (match_dup 0) (match_dup 5)))]
2915 int mb = extract_MB (operands[2]);
2916 int me = extract_ME (operands[2]);
2917 operands[3] = GEN_INT (me + 1);
2918 operands[5] = GEN_INT (32 - (me + 1));
2919 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2921 [(set_attr "length" "8")])
2923 (define_expand "iorsi3"
2924 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2925 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
2926 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2930 if (GET_CODE (operands[2]) == CONST_INT
2931 && ! logical_operand (operands[2], SImode))
2933 HOST_WIDE_INT value = INTVAL (operands[2]);
2934 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2935 ? operands[0] : gen_reg_rtx (SImode));
2937 emit_insn (gen_iorsi3 (tmp, operands[1],
2938 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2939 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2944 (define_expand "xorsi3"
2945 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2946 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2947 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2951 if (GET_CODE (operands[2]) == CONST_INT
2952 && ! logical_operand (operands[2], SImode))
2954 HOST_WIDE_INT value = INTVAL (operands[2]);
2955 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2956 ? operands[0] : gen_reg_rtx (SImode));
2958 emit_insn (gen_xorsi3 (tmp, operands[1],
2959 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2960 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2965 (define_insn "*boolsi3_internal1"
2966 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2967 (match_operator:SI 3 "boolean_or_operator"
2968 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
2969 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
2973 {%q3il|%q3i} %0,%1,%b2
2974 {%q3iu|%q3is} %0,%1,%u2")
2976 (define_insn "*boolsi3_internal2"
2977 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2978 (compare:CC (match_operator:SI 4 "boolean_or_operator"
2979 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2980 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2982 (clobber (match_scratch:SI 3 "=r,r"))]
2987 [(set_attr "type" "compare")
2988 (set_attr "length" "4,8")])
2991 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2992 (compare:CC (match_operator:SI 4 "boolean_operator"
2993 [(match_operand:SI 1 "gpc_reg_operand" "")
2994 (match_operand:SI 2 "gpc_reg_operand" "")])
2996 (clobber (match_scratch:SI 3 ""))]
2997 "TARGET_32BIT && reload_completed"
2998 [(set (match_dup 3) (match_dup 4))
3000 (compare:CC (match_dup 3)
3004 (define_insn "*boolsi3_internal3"
3005 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3006 (compare:CC (match_operator:SI 4 "boolean_operator"
3007 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3008 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3010 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3016 [(set_attr "type" "compare")
3017 (set_attr "length" "4,8")])
3020 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3021 (compare:CC (match_operator:SI 4 "boolean_operator"
3022 [(match_operand:SI 1 "gpc_reg_operand" "")
3023 (match_operand:SI 2 "gpc_reg_operand" "")])
3025 (set (match_operand:SI 0 "gpc_reg_operand" "")
3027 "TARGET_32BIT && reload_completed"
3028 [(set (match_dup 0) (match_dup 4))
3030 (compare:CC (match_dup 0)
3034 ;; Split a logical operation that we can't do in one insn into two insns,
3035 ;; each of which does one 16-bit part. This is used by combine.
3038 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3039 (match_operator:SI 3 "boolean_or_operator"
3040 [(match_operand:SI 1 "gpc_reg_operand" "")
3041 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
3043 [(set (match_dup 0) (match_dup 4))
3044 (set (match_dup 0) (match_dup 5))]
3048 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
3049 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3051 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
3052 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3056 (define_insn "*boolcsi3_internal1"
3057 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3058 (match_operator:SI 3 "boolean_operator"
3059 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3060 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
3064 (define_insn "*boolcsi3_internal2"
3065 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3066 (compare:CC (match_operator:SI 4 "boolean_operator"
3067 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3068 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3070 (clobber (match_scratch:SI 3 "=r,r"))]
3075 [(set_attr "type" "compare")
3076 (set_attr "length" "4,8")])
3079 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3080 (compare:CC (match_operator:SI 4 "boolean_operator"
3081 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3082 (match_operand:SI 2 "gpc_reg_operand" "")])
3084 (clobber (match_scratch:SI 3 ""))]
3085 "TARGET_32BIT && reload_completed"
3086 [(set (match_dup 3) (match_dup 4))
3088 (compare:CC (match_dup 3)
3092 (define_insn "*boolcsi3_internal3"
3093 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3094 (compare:CC (match_operator:SI 4 "boolean_operator"
3095 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3096 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3098 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3104 [(set_attr "type" "compare")
3105 (set_attr "length" "4,8")])
3108 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3109 (compare:CC (match_operator:SI 4 "boolean_operator"
3110 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3111 (match_operand:SI 2 "gpc_reg_operand" "")])
3113 (set (match_operand:SI 0 "gpc_reg_operand" "")
3115 "TARGET_32BIT && reload_completed"
3116 [(set (match_dup 0) (match_dup 4))
3118 (compare:CC (match_dup 0)
3122 (define_insn "*boolccsi3_internal1"
3123 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3124 (match_operator:SI 3 "boolean_operator"
3125 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3126 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3130 (define_insn "*boolccsi3_internal2"
3131 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3132 (compare:CC (match_operator:SI 4 "boolean_operator"
3133 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3134 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3136 (clobber (match_scratch:SI 3 "=r,r"))]
3141 [(set_attr "type" "compare")
3142 (set_attr "length" "4,8")])
3145 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3146 (compare:CC (match_operator:SI 4 "boolean_operator"
3147 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3148 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3150 (clobber (match_scratch:SI 3 ""))]
3151 "TARGET_32BIT && reload_completed"
3152 [(set (match_dup 3) (match_dup 4))
3154 (compare:CC (match_dup 3)
3158 (define_insn "*boolccsi3_internal3"
3159 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3160 (compare:CC (match_operator:SI 4 "boolean_operator"
3161 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3162 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3164 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3170 [(set_attr "type" "compare")
3171 (set_attr "length" "4,8")])
3174 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3175 (compare:CC (match_operator:SI 4 "boolean_operator"
3176 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3177 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3179 (set (match_operand:SI 0 "gpc_reg_operand" "")
3181 "TARGET_32BIT && reload_completed"
3182 [(set (match_dup 0) (match_dup 4))
3184 (compare:CC (match_dup 0)
3188 ;; maskir insn. We need four forms because things might be in arbitrary
3189 ;; orders. Don't define forms that only set CR fields because these
3190 ;; would modify an input register.
3192 (define_insn "*maskir_internal1"
3193 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3194 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3195 (match_operand:SI 1 "gpc_reg_operand" "0"))
3196 (and:SI (match_dup 2)
3197 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
3201 (define_insn "*maskir_internal2"
3202 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3203 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3204 (match_operand:SI 1 "gpc_reg_operand" "0"))
3205 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3210 (define_insn "*maskir_internal3"
3211 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3212 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
3213 (match_operand:SI 3 "gpc_reg_operand" "r"))
3214 (and:SI (not:SI (match_dup 2))
3215 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3219 (define_insn "*maskir_internal4"
3220 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3221 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3222 (match_operand:SI 2 "gpc_reg_operand" "r"))
3223 (and:SI (not:SI (match_dup 2))
3224 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3228 (define_insn "*maskir_internal5"
3229 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3231 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3232 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3233 (and:SI (match_dup 2)
3234 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
3236 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3237 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3238 (and:SI (match_dup 2) (match_dup 3))))]
3243 [(set_attr "type" "compare")
3244 (set_attr "length" "4,8")])
3247 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3249 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3250 (match_operand:SI 1 "gpc_reg_operand" ""))
3251 (and:SI (match_dup 2)
3252 (match_operand:SI 3 "gpc_reg_operand" "")))
3254 (set (match_operand:SI 0 "gpc_reg_operand" "")
3255 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3256 (and:SI (match_dup 2) (match_dup 3))))]
3257 "TARGET_POWER && reload_completed"
3259 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3260 (and:SI (match_dup 2) (match_dup 3))))
3262 (compare:CC (match_dup 0)
3266 (define_insn "*maskir_internal6"
3267 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3269 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3270 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3271 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")