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
75 ;; UNSPEC_VOLATILE usage
80 (UNSPECV_LL 1) ; load-locked
81 (UNSPECV_SC 2) ; store-conditional
82 (UNSPECV_EH_RR 9) ; eh_reg_restore
85 ;; Define an insn type attribute. This is used in function unit delay
87 (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"
88 (const_string "integer"))
91 ; '(pc)' in the following doesn't include the instruction itself; it is
92 ; calculated as if the instruction had zero size.
93 (define_attr "length" ""
94 (if_then_else (eq_attr "type" "branch")
95 (if_then_else (and (ge (minus (match_dup 0) (pc))
97 (lt (minus (match_dup 0) (pc))
103 ;; Processor type -- this attribute must exactly match the processor_type
104 ;; enumeration in rs6000.h.
106 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4,power5"
107 (const (symbol_ref "rs6000_cpu_attr")))
109 (automata_option "ndfa")
122 (include "power4.md")
123 (include "power5.md")
125 (include "predicates.md")
127 (include "darwin.md")
132 ; This mode macro allows :GPR to be used to indicate the allowable size
133 ; of whole values in GPRs.
134 (define_mode_macro GPR [SI (DI "TARGET_POWERPC64")])
136 ; Any supported integer mode.
137 (define_mode_macro INT [QI HI SI DI TI])
139 ; Any supported integer mode that fits in one register.
140 (define_mode_macro INT1 [QI HI SI (DI "TARGET_POWERPC64")])
142 ; extend modes for DImode
143 (define_mode_macro QHSI [QI HI SI])
145 ; SImode or DImode, even if DImode doesn't fit in GPRs.
146 (define_mode_macro SDI [SI DI])
148 ; The size of a pointer. Also, the size of the value that a record-condition
149 ; (one with a '.') will compare.
150 (define_mode_macro P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
152 ; Any hardware-supported floating-point mode
153 (define_mode_macro FP [(SF "TARGET_HARD_FLOAT")
154 (DF "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)")
155 (TF "!TARGET_IEEEQUAD
156 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128")])
158 ; Various instructions that come in SI and DI forms.
159 ; A generic w/d attribute, for things like cmpw/cmpd.
160 (define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
163 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
166 ;; Start with fixed-point load and store insns. Here we put only the more
167 ;; complex forms. Basic data transfer is done later.
169 (define_expand "zero_extend<mode>di2"
170 [(set (match_operand:DI 0 "gpc_reg_operand" "")
171 (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "")))]
175 (define_insn "*zero_extend<mode>di2_internal1"
176 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
177 (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
181 rldicl %0,%1,0,<dbits>"
182 [(set_attr "type" "load,*")])
184 (define_insn "*zero_extend<mode>di2_internal2"
185 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
186 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
188 (clobber (match_scratch:DI 2 "=r,r"))]
191 rldicl. %2,%1,0,<dbits>
193 [(set_attr "type" "compare")
194 (set_attr "length" "4,8")])
197 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
198 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
200 (clobber (match_scratch:DI 2 ""))]
201 "TARGET_POWERPC64 && reload_completed"
203 (zero_extend:DI (match_dup 1)))
205 (compare:CC (match_dup 2)
209 (define_insn "*zero_extend<mode>di2_internal3"
210 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
211 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
213 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
214 (zero_extend:DI (match_dup 1)))]
217 rldicl. %0,%1,0,<dbits>
219 [(set_attr "type" "compare")
220 (set_attr "length" "4,8")])
223 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
224 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
226 (set (match_operand:DI 0 "gpc_reg_operand" "")
227 (zero_extend:DI (match_dup 1)))]
228 "TARGET_POWERPC64 && reload_completed"
230 (zero_extend:DI (match_dup 1)))
232 (compare:CC (match_dup 0)
236 (define_insn "extendqidi2"
237 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
238 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
243 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
244 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
246 (clobber (match_scratch:DI 2 "=r,r"))]
251 [(set_attr "type" "compare")
252 (set_attr "length" "4,8")])
255 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
256 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
258 (clobber (match_scratch:DI 2 ""))]
259 "TARGET_POWERPC64 && reload_completed"
261 (sign_extend:DI (match_dup 1)))
263 (compare:CC (match_dup 2)
268 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
269 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
271 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
272 (sign_extend:DI (match_dup 1)))]
277 [(set_attr "type" "compare")
278 (set_attr "length" "4,8")])
281 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
282 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
284 (set (match_operand:DI 0 "gpc_reg_operand" "")
285 (sign_extend:DI (match_dup 1)))]
286 "TARGET_POWERPC64 && reload_completed"
288 (sign_extend:DI (match_dup 1)))
290 (compare:CC (match_dup 0)
294 (define_expand "extendhidi2"
295 [(set (match_operand:DI 0 "gpc_reg_operand" "")
296 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
301 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
302 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
307 [(set_attr "type" "load_ext,*")])
310 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
311 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
313 (clobber (match_scratch:DI 2 "=r,r"))]
318 [(set_attr "type" "compare")
319 (set_attr "length" "4,8")])
322 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
323 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
325 (clobber (match_scratch:DI 2 ""))]
326 "TARGET_POWERPC64 && reload_completed"
328 (sign_extend:DI (match_dup 1)))
330 (compare:CC (match_dup 2)
335 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
336 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
338 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
339 (sign_extend:DI (match_dup 1)))]
344 [(set_attr "type" "compare")
345 (set_attr "length" "4,8")])
348 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
349 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
351 (set (match_operand:DI 0 "gpc_reg_operand" "")
352 (sign_extend:DI (match_dup 1)))]
353 "TARGET_POWERPC64 && reload_completed"
355 (sign_extend:DI (match_dup 1)))
357 (compare:CC (match_dup 0)
361 (define_expand "extendsidi2"
362 [(set (match_operand:DI 0 "gpc_reg_operand" "")
363 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
368 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
369 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
374 [(set_attr "type" "load_ext,*")])
377 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
378 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
380 (clobber (match_scratch:DI 2 "=r,r"))]
385 [(set_attr "type" "compare")
386 (set_attr "length" "4,8")])
389 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
390 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
392 (clobber (match_scratch:DI 2 ""))]
393 "TARGET_POWERPC64 && reload_completed"
395 (sign_extend:DI (match_dup 1)))
397 (compare:CC (match_dup 2)
402 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
403 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
405 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
406 (sign_extend:DI (match_dup 1)))]
411 [(set_attr "type" "compare")
412 (set_attr "length" "4,8")])
415 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
416 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
418 (set (match_operand:DI 0 "gpc_reg_operand" "")
419 (sign_extend:DI (match_dup 1)))]
420 "TARGET_POWERPC64 && reload_completed"
422 (sign_extend:DI (match_dup 1)))
424 (compare:CC (match_dup 0)
428 (define_expand "zero_extendqisi2"
429 [(set (match_operand:SI 0 "gpc_reg_operand" "")
430 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
435 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
436 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
440 {rlinm|rlwinm} %0,%1,0,0xff"
441 [(set_attr "type" "load,*")])
444 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
445 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
447 (clobber (match_scratch:SI 2 "=r,r"))]
450 {andil.|andi.} %2,%1,0xff
452 [(set_attr "type" "compare")
453 (set_attr "length" "4,8")])
456 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
457 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
459 (clobber (match_scratch:SI 2 ""))]
462 (zero_extend:SI (match_dup 1)))
464 (compare:CC (match_dup 2)
469 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
470 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
472 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
473 (zero_extend:SI (match_dup 1)))]
476 {andil.|andi.} %0,%1,0xff
478 [(set_attr "type" "compare")
479 (set_attr "length" "4,8")])
482 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
483 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
485 (set (match_operand:SI 0 "gpc_reg_operand" "")
486 (zero_extend:SI (match_dup 1)))]
489 (zero_extend:SI (match_dup 1)))
491 (compare:CC (match_dup 0)
495 (define_expand "extendqisi2"
496 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
497 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
502 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
503 else if (TARGET_POWER)
504 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
506 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
510 (define_insn "extendqisi2_ppc"
511 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
512 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
517 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
518 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
520 (clobber (match_scratch:SI 2 "=r,r"))]
525 [(set_attr "type" "compare")
526 (set_attr "length" "4,8")])
529 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
530 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
532 (clobber (match_scratch:SI 2 ""))]
533 "TARGET_POWERPC && reload_completed"
535 (sign_extend:SI (match_dup 1)))
537 (compare:CC (match_dup 2)
542 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
543 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
545 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
546 (sign_extend:SI (match_dup 1)))]
551 [(set_attr "type" "compare")
552 (set_attr "length" "4,8")])
555 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
556 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
558 (set (match_operand:SI 0 "gpc_reg_operand" "")
559 (sign_extend:SI (match_dup 1)))]
560 "TARGET_POWERPC && reload_completed"
562 (sign_extend:SI (match_dup 1)))
564 (compare:CC (match_dup 0)
568 (define_expand "extendqisi2_power"
569 [(parallel [(set (match_dup 2)
570 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
572 (clobber (scratch:SI))])
573 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
574 (ashiftrt:SI (match_dup 2)
576 (clobber (scratch:SI))])]
579 { operands[1] = gen_lowpart (SImode, operands[1]);
580 operands[2] = gen_reg_rtx (SImode); }")
582 (define_expand "extendqisi2_no_power"
584 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
586 (set (match_operand:SI 0 "gpc_reg_operand" "")
587 (ashiftrt:SI (match_dup 2)
589 "! TARGET_POWER && ! TARGET_POWERPC"
591 { operands[1] = gen_lowpart (SImode, operands[1]);
592 operands[2] = gen_reg_rtx (SImode); }")
594 (define_expand "zero_extendqihi2"
595 [(set (match_operand:HI 0 "gpc_reg_operand" "")
596 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
601 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
602 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
606 {rlinm|rlwinm} %0,%1,0,0xff"
607 [(set_attr "type" "load,*")])
610 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
611 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
613 (clobber (match_scratch:HI 2 "=r,r"))]
616 {andil.|andi.} %2,%1,0xff
618 [(set_attr "type" "compare")
619 (set_attr "length" "4,8")])
622 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
623 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
625 (clobber (match_scratch:HI 2 ""))]
628 (zero_extend:HI (match_dup 1)))
630 (compare:CC (match_dup 2)
635 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
636 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
638 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
639 (zero_extend:HI (match_dup 1)))]
642 {andil.|andi.} %0,%1,0xff
644 [(set_attr "type" "compare")
645 (set_attr "length" "4,8")])
648 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
649 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
651 (set (match_operand:HI 0 "gpc_reg_operand" "")
652 (zero_extend:HI (match_dup 1)))]
655 (zero_extend:HI (match_dup 1)))
657 (compare:CC (match_dup 0)
661 (define_expand "extendqihi2"
662 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
663 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
668 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
669 else if (TARGET_POWER)
670 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
672 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
676 (define_insn "extendqihi2_ppc"
677 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
678 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
683 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
684 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
686 (clobber (match_scratch:HI 2 "=r,r"))]
691 [(set_attr "type" "compare")
692 (set_attr "length" "4,8")])
695 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
696 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
698 (clobber (match_scratch:HI 2 ""))]
699 "TARGET_POWERPC && reload_completed"
701 (sign_extend:HI (match_dup 1)))
703 (compare:CC (match_dup 2)
708 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
709 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
711 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
712 (sign_extend:HI (match_dup 1)))]
717 [(set_attr "type" "compare")
718 (set_attr "length" "4,8")])
721 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
722 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
724 (set (match_operand:HI 0 "gpc_reg_operand" "")
725 (sign_extend:HI (match_dup 1)))]
726 "TARGET_POWERPC && reload_completed"
728 (sign_extend:HI (match_dup 1)))
730 (compare:CC (match_dup 0)
734 (define_expand "extendqihi2_power"
735 [(parallel [(set (match_dup 2)
736 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
738 (clobber (scratch:SI))])
739 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
740 (ashiftrt:SI (match_dup 2)
742 (clobber (scratch:SI))])]
745 { operands[0] = gen_lowpart (SImode, operands[0]);
746 operands[1] = gen_lowpart (SImode, operands[1]);
747 operands[2] = gen_reg_rtx (SImode); }")
749 (define_expand "extendqihi2_no_power"
751 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
753 (set (match_operand:HI 0 "gpc_reg_operand" "")
754 (ashiftrt:SI (match_dup 2)
756 "! TARGET_POWER && ! TARGET_POWERPC"
758 { operands[0] = gen_lowpart (SImode, operands[0]);
759 operands[1] = gen_lowpart (SImode, operands[1]);
760 operands[2] = gen_reg_rtx (SImode); }")
762 (define_expand "zero_extendhisi2"
763 [(set (match_operand:SI 0 "gpc_reg_operand" "")
764 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
769 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
770 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
774 {rlinm|rlwinm} %0,%1,0,0xffff"
775 [(set_attr "type" "load,*")])
778 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
779 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
781 (clobber (match_scratch:SI 2 "=r,r"))]
784 {andil.|andi.} %2,%1,0xffff
786 [(set_attr "type" "compare")
787 (set_attr "length" "4,8")])
790 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
791 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
793 (clobber (match_scratch:SI 2 ""))]
796 (zero_extend:SI (match_dup 1)))
798 (compare:CC (match_dup 2)
803 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
804 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
806 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
807 (zero_extend:SI (match_dup 1)))]
810 {andil.|andi.} %0,%1,0xffff
812 [(set_attr "type" "compare")
813 (set_attr "length" "4,8")])
816 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
817 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
819 (set (match_operand:SI 0 "gpc_reg_operand" "")
820 (zero_extend:SI (match_dup 1)))]
823 (zero_extend:SI (match_dup 1)))
825 (compare:CC (match_dup 0)
829 (define_expand "extendhisi2"
830 [(set (match_operand:SI 0 "gpc_reg_operand" "")
831 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
836 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
837 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
842 [(set_attr "type" "load_ext,*")])
845 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
846 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
848 (clobber (match_scratch:SI 2 "=r,r"))]
853 [(set_attr "type" "compare")
854 (set_attr "length" "4,8")])
857 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
858 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
860 (clobber (match_scratch:SI 2 ""))]
863 (sign_extend:SI (match_dup 1)))
865 (compare:CC (match_dup 2)
870 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
871 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
873 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
874 (sign_extend:SI (match_dup 1)))]
879 [(set_attr "type" "compare")
880 (set_attr "length" "4,8")])
882 ;; IBM 405 and 440 half-word multiplication operations.
884 (define_insn "*macchwc"
885 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
886 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
887 (match_operand:SI 2 "gpc_reg_operand" "r")
890 (match_operand:HI 1 "gpc_reg_operand" "r")))
891 (match_operand:SI 4 "gpc_reg_operand" "0"))
893 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
894 (plus:SI (mult:SI (ashiftrt:SI
902 [(set_attr "type" "imul3")])
904 (define_insn "*macchw"
905 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
906 (plus:SI (mult:SI (ashiftrt:SI
907 (match_operand:SI 2 "gpc_reg_operand" "r")
910 (match_operand:HI 1 "gpc_reg_operand" "r")))
911 (match_operand:SI 3 "gpc_reg_operand" "0")))]
914 [(set_attr "type" "imul3")])
916 (define_insn "*macchwuc"
917 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
918 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
919 (match_operand:SI 2 "gpc_reg_operand" "r")
922 (match_operand:HI 1 "gpc_reg_operand" "r")))
923 (match_operand:SI 4 "gpc_reg_operand" "0"))
925 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
926 (plus:SI (mult:SI (lshiftrt:SI
933 "macchwu. %0, %1, %2"
934 [(set_attr "type" "imul3")])
936 (define_insn "*macchwu"
937 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
938 (plus:SI (mult:SI (lshiftrt:SI
939 (match_operand:SI 2 "gpc_reg_operand" "r")
942 (match_operand:HI 1 "gpc_reg_operand" "r")))
943 (match_operand:SI 3 "gpc_reg_operand" "0")))]
946 [(set_attr "type" "imul3")])
948 (define_insn "*machhwc"
949 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
950 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
951 (match_operand:SI 1 "gpc_reg_operand" "%r")
954 (match_operand:SI 2 "gpc_reg_operand" "r")
956 (match_operand:SI 4 "gpc_reg_operand" "0"))
958 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
959 (plus:SI (mult:SI (ashiftrt:SI
968 [(set_attr "type" "imul3")])
970 (define_insn "*machhw"
971 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
972 (plus:SI (mult:SI (ashiftrt:SI
973 (match_operand:SI 1 "gpc_reg_operand" "%r")
976 (match_operand:SI 2 "gpc_reg_operand" "r")
978 (match_operand:SI 3 "gpc_reg_operand" "0")))]
981 [(set_attr "type" "imul3")])
983 (define_insn "*machhwuc"
984 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
985 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
986 (match_operand:SI 1 "gpc_reg_operand" "%r")
989 (match_operand:SI 2 "gpc_reg_operand" "r")
991 (match_operand:SI 4 "gpc_reg_operand" "0"))
993 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
994 (plus:SI (mult:SI (lshiftrt:SI
1002 "machhwu. %0, %1, %2"
1003 [(set_attr "type" "imul3")])
1005 (define_insn "*machhwu"
1006 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1007 (plus:SI (mult:SI (lshiftrt:SI
1008 (match_operand:SI 1 "gpc_reg_operand" "%r")
1011 (match_operand:SI 2 "gpc_reg_operand" "r")
1013 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1015 "machhwu %0, %1, %2"
1016 [(set_attr "type" "imul3")])
1018 (define_insn "*maclhwc"
1019 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1020 (compare:CC (plus:SI (mult:SI (sign_extend:SI
1021 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1023 (match_operand:HI 2 "gpc_reg_operand" "r")))
1024 (match_operand:SI 4 "gpc_reg_operand" "0"))
1026 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1027 (plus:SI (mult:SI (sign_extend:SI
1033 "maclhw. %0, %1, %2"
1034 [(set_attr "type" "imul3")])
1036 (define_insn "*maclhw"
1037 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1038 (plus:SI (mult:SI (sign_extend:SI
1039 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1041 (match_operand:HI 2 "gpc_reg_operand" "r")))
1042 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1045 [(set_attr "type" "imul3")])
1047 (define_insn "*maclhwuc"
1048 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1049 (compare:CC (plus:SI (mult:SI (zero_extend:SI
1050 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1052 (match_operand:HI 2 "gpc_reg_operand" "r")))
1053 (match_operand:SI 4 "gpc_reg_operand" "0"))
1055 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1056 (plus:SI (mult:SI (zero_extend:SI
1062 "maclhwu. %0, %1, %2"
1063 [(set_attr "type" "imul3")])
1065 (define_insn "*maclhwu"
1066 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1067 (plus:SI (mult:SI (zero_extend:SI
1068 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1070 (match_operand:HI 2 "gpc_reg_operand" "r")))
1071 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1073 "maclhwu %0, %1, %2"
1074 [(set_attr "type" "imul3")])
1076 (define_insn "*nmacchwc"
1077 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1078 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1079 (mult:SI (ashiftrt:SI
1080 (match_operand:SI 2 "gpc_reg_operand" "r")
1083 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1085 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1086 (minus:SI (match_dup 4)
1087 (mult:SI (ashiftrt:SI
1093 "nmacchw. %0, %1, %2"
1094 [(set_attr "type" "imul3")])
1096 (define_insn "*nmacchw"
1097 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1098 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1099 (mult:SI (ashiftrt:SI
1100 (match_operand:SI 2 "gpc_reg_operand" "r")
1103 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1105 "nmacchw %0, %1, %2"
1106 [(set_attr "type" "imul3")])
1108 (define_insn "*nmachhwc"
1109 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1110 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1111 (mult:SI (ashiftrt:SI
1112 (match_operand:SI 1 "gpc_reg_operand" "%r")
1115 (match_operand:SI 2 "gpc_reg_operand" "r")
1118 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1119 (minus:SI (match_dup 4)
1120 (mult:SI (ashiftrt:SI
1127 "nmachhw. %0, %1, %2"
1128 [(set_attr "type" "imul3")])
1130 (define_insn "*nmachhw"
1131 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1132 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1133 (mult:SI (ashiftrt:SI
1134 (match_operand:SI 1 "gpc_reg_operand" "%r")
1137 (match_operand:SI 2 "gpc_reg_operand" "r")
1140 "nmachhw %0, %1, %2"
1141 [(set_attr "type" "imul3")])
1143 (define_insn "*nmaclhwc"
1144 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1145 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1146 (mult:SI (sign_extend:SI
1147 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1149 (match_operand:HI 2 "gpc_reg_operand" "r"))))
1151 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1152 (minus:SI (match_dup 4)
1153 (mult:SI (sign_extend:SI
1158 "nmaclhw. %0, %1, %2"
1159 [(set_attr "type" "imul3")])
1161 (define_insn "*nmaclhw"
1162 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1163 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1164 (mult:SI (sign_extend:SI
1165 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1167 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1169 "nmaclhw %0, %1, %2"
1170 [(set_attr "type" "imul3")])
1172 (define_insn "*mulchwc"
1173 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1174 (compare:CC (mult:SI (ashiftrt:SI
1175 (match_operand:SI 2 "gpc_reg_operand" "r")
1178 (match_operand:HI 1 "gpc_reg_operand" "r")))
1180 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1181 (mult:SI (ashiftrt:SI
1187 "mulchw. %0, %1, %2"
1188 [(set_attr "type" "imul3")])
1190 (define_insn "*mulchw"
1191 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1192 (mult:SI (ashiftrt:SI
1193 (match_operand:SI 2 "gpc_reg_operand" "r")
1196 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1199 [(set_attr "type" "imul3")])
1201 (define_insn "*mulchwuc"
1202 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1203 (compare:CC (mult:SI (lshiftrt:SI
1204 (match_operand:SI 2 "gpc_reg_operand" "r")
1207 (match_operand:HI 1 "gpc_reg_operand" "r")))
1209 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1210 (mult:SI (lshiftrt:SI
1216 "mulchwu. %0, %1, %2"
1217 [(set_attr "type" "imul3")])
1219 (define_insn "*mulchwu"
1220 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1221 (mult:SI (lshiftrt:SI
1222 (match_operand:SI 2 "gpc_reg_operand" "r")
1225 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1227 "mulchwu %0, %1, %2"
1228 [(set_attr "type" "imul3")])
1230 (define_insn "*mulhhwc"
1231 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1232 (compare:CC (mult:SI (ashiftrt:SI
1233 (match_operand:SI 1 "gpc_reg_operand" "%r")
1236 (match_operand:SI 2 "gpc_reg_operand" "r")
1239 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1240 (mult:SI (ashiftrt:SI
1247 "mulhhw. %0, %1, %2"
1248 [(set_attr "type" "imul3")])
1250 (define_insn "*mulhhw"
1251 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1252 (mult:SI (ashiftrt:SI
1253 (match_operand:SI 1 "gpc_reg_operand" "%r")
1256 (match_operand:SI 2 "gpc_reg_operand" "r")
1260 [(set_attr "type" "imul3")])
1262 (define_insn "*mulhhwuc"
1263 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1264 (compare:CC (mult:SI (lshiftrt:SI
1265 (match_operand:SI 1 "gpc_reg_operand" "%r")
1268 (match_operand:SI 2 "gpc_reg_operand" "r")
1271 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1272 (mult:SI (lshiftrt:SI
1279 "mulhhwu. %0, %1, %2"
1280 [(set_attr "type" "imul3")])
1282 (define_insn "*mulhhwu"
1283 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1284 (mult:SI (lshiftrt:SI
1285 (match_operand:SI 1 "gpc_reg_operand" "%r")
1288 (match_operand:SI 2 "gpc_reg_operand" "r")
1291 "mulhhwu %0, %1, %2"
1292 [(set_attr "type" "imul3")])
1294 (define_insn "*mullhwc"
1295 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1296 (compare:CC (mult:SI (sign_extend:SI
1297 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1299 (match_operand:HI 2 "gpc_reg_operand" "r")))
1301 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1302 (mult:SI (sign_extend:SI
1307 "mullhw. %0, %1, %2"
1308 [(set_attr "type" "imul3")])
1310 (define_insn "*mullhw"
1311 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1312 (mult:SI (sign_extend:SI
1313 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1315 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1318 [(set_attr "type" "imul3")])
1320 (define_insn "*mullhwuc"
1321 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1322 (compare:CC (mult:SI (zero_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 (zero_extend:SI
1333 "mullhwu. %0, %1, %2"
1334 [(set_attr "type" "imul3")])
1336 (define_insn "*mullhwu"
1337 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1338 (mult:SI (zero_extend:SI
1339 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1341 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1343 "mullhwu %0, %1, %2"
1344 [(set_attr "type" "imul3")])
1347 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1348 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1350 (set (match_operand:SI 0 "gpc_reg_operand" "")
1351 (sign_extend:SI (match_dup 1)))]
1354 (sign_extend:SI (match_dup 1)))
1356 (compare:CC (match_dup 0)
1360 ;; Fixed-point arithmetic insns.
1362 (define_expand "add<mode>3"
1363 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1364 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1365 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1369 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1371 if (non_short_cint_operand (operands[2], DImode))
1374 else if (GET_CODE (operands[2]) == CONST_INT
1375 && ! add_operand (operands[2], <MODE>mode))
1377 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
1378 ? operands[0] : gen_reg_rtx (<MODE>mode));
1380 HOST_WIDE_INT val = INTVAL (operands[2]);
1381 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1382 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1384 if (<MODE>mode == DImode && !CONST_OK_FOR_LETTER_P (rest, 'L'))
1387 /* The ordering here is important for the prolog expander.
1388 When space is allocated from the stack, adding 'low' first may
1389 produce a temporary deallocation (which would be bad). */
1390 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1391 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1396 ;; Discourage ai/addic because of carry but provide it in an alternative
1397 ;; allowing register zero as source.
1398 (define_insn "*add<mode>3_internal1"
1399 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1400 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1401 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
1405 {cal %0,%2(%1)|addi %0,%1,%2}
1407 {cau|addis} %0,%1,%v2"
1408 [(set_attr "length" "4,4,4,4")])
1410 (define_insn "addsi3_high"
1411 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1412 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1413 (high:SI (match_operand 2 "" ""))))]
1414 "TARGET_MACHO && !TARGET_64BIT"
1415 "{cau|addis} %0,%1,ha16(%2)"
1416 [(set_attr "length" "4")])
1418 (define_insn "*add<mode>3_internal2"
1419 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1420 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1421 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1423 (clobber (match_scratch:P 3 "=r,r,r,r"))]
1426 {cax.|add.} %3,%1,%2
1427 {ai.|addic.} %3,%1,%2
1430 [(set_attr "type" "fast_compare,compare,compare,compare")
1431 (set_attr "length" "4,4,8,8")])
1434 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1435 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1436 (match_operand:GPR 2 "reg_or_short_operand" ""))
1438 (clobber (match_scratch:GPR 3 ""))]
1441 (plus:GPR (match_dup 1)
1444 (compare:CC (match_dup 3)
1448 (define_insn "*add<mode>3_internal3"
1449 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1450 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1451 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1453 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1454 (plus:P (match_dup 1)
1458 {cax.|add.} %0,%1,%2
1459 {ai.|addic.} %0,%1,%2
1462 [(set_attr "type" "fast_compare,compare,compare,compare")
1463 (set_attr "length" "4,4,8,8")])
1466 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1467 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1468 (match_operand:P 2 "reg_or_short_operand" ""))
1470 (set (match_operand:P 0 "gpc_reg_operand" "")
1471 (plus:P (match_dup 1) (match_dup 2)))]
1474 (plus:P (match_dup 1)
1477 (compare:CC (match_dup 0)
1481 ;; Split an add that we can't do in one insn into two insns, each of which
1482 ;; does one 16-bit part. This is used by combine. Note that the low-order
1483 ;; add should be last in case the result gets used in an address.
1486 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1487 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1488 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1490 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1491 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1494 HOST_WIDE_INT val = INTVAL (operands[2]);
1495 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1496 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1498 operands[4] = GEN_INT (low);
1499 if (<MODE>mode == SImode || CONST_OK_FOR_LETTER_P (rest, 'L'))
1500 operands[3] = GEN_INT (rest);
1501 else if (! no_new_pseudos)
1503 operands[3] = gen_reg_rtx (DImode);
1504 emit_move_insn (operands[3], operands[2]);
1505 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1512 (define_insn "one_cmpl<mode>2"
1513 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1514 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1519 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1520 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1522 (clobber (match_scratch:P 2 "=r,r"))]
1527 [(set_attr "type" "compare")
1528 (set_attr "length" "4,8")])
1531 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1532 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1534 (clobber (match_scratch:P 2 ""))]
1537 (not:P (match_dup 1)))
1539 (compare:CC (match_dup 2)
1544 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1545 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1547 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1548 (not:P (match_dup 1)))]
1553 [(set_attr "type" "compare")
1554 (set_attr "length" "4,8")])
1557 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1558 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1560 (set (match_operand:P 0 "gpc_reg_operand" "")
1561 (not:P (match_dup 1)))]
1564 (not:P (match_dup 1)))
1566 (compare:CC (match_dup 0)
1571 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1572 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1573 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1575 "{sf%I1|subf%I1c} %0,%2,%1")
1578 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1579 (minus:GPR (match_operand:GPR 1 "reg_or_short_operand" "r,I")
1580 (match_operand:GPR 2 "gpc_reg_operand" "r,r")))]
1587 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1588 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1589 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1591 (clobber (match_scratch:SI 3 "=r,r"))]
1594 {sf.|subfc.} %3,%2,%1
1596 [(set_attr "type" "compare")
1597 (set_attr "length" "4,8")])
1600 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1601 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1602 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1604 (clobber (match_scratch:P 3 "=r,r"))]
1609 [(set_attr "type" "fast_compare")
1610 (set_attr "length" "4,8")])
1613 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1614 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1615 (match_operand:P 2 "gpc_reg_operand" ""))
1617 (clobber (match_scratch:P 3 ""))]
1620 (minus:P (match_dup 1)
1623 (compare:CC (match_dup 3)
1628 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1629 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1630 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1632 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1633 (minus:SI (match_dup 1) (match_dup 2)))]
1636 {sf.|subfc.} %0,%2,%1
1638 [(set_attr "type" "compare")
1639 (set_attr "length" "4,8")])
1642 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1643 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1644 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1646 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1647 (minus:P (match_dup 1)
1653 [(set_attr "type" "fast_compare")
1654 (set_attr "length" "4,8")])
1657 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1658 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1659 (match_operand:P 2 "gpc_reg_operand" ""))
1661 (set (match_operand:P 0 "gpc_reg_operand" "")
1662 (minus:P (match_dup 1)
1666 (minus:P (match_dup 1)
1669 (compare:CC (match_dup 0)
1673 (define_expand "sub<mode>3"
1674 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1675 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1676 (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
1680 if (GET_CODE (operands[2]) == CONST_INT)
1682 emit_insn (gen_add<mode>3 (operands[0], operands[1],
1683 negate_rtx (<MODE>mode, operands[2])));
1688 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1689 ;; instruction and some auxiliary computations. Then we just have a single
1690 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1693 (define_expand "sminsi3"
1695 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1696 (match_operand:SI 2 "reg_or_short_operand" ""))
1698 (minus:SI (match_dup 2) (match_dup 1))))
1699 (set (match_operand:SI 0 "gpc_reg_operand" "")
1700 (minus:SI (match_dup 2) (match_dup 3)))]
1701 "TARGET_POWER || TARGET_ISEL"
1706 operands[2] = force_reg (SImode, operands[2]);
1707 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1711 operands[3] = gen_reg_rtx (SImode);
1715 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1716 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1717 (match_operand:SI 2 "reg_or_short_operand" "")))
1718 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1721 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1723 (minus:SI (match_dup 2) (match_dup 1))))
1724 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1727 (define_expand "smaxsi3"
1729 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1730 (match_operand:SI 2 "reg_or_short_operand" ""))
1732 (minus:SI (match_dup 2) (match_dup 1))))
1733 (set (match_operand:SI 0 "gpc_reg_operand" "")
1734 (plus:SI (match_dup 3) (match_dup 1)))]
1735 "TARGET_POWER || TARGET_ISEL"
1740 operands[2] = force_reg (SImode, operands[2]);
1741 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1744 operands[3] = gen_reg_rtx (SImode);
1748 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1749 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1750 (match_operand:SI 2 "reg_or_short_operand" "")))
1751 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1754 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1756 (minus:SI (match_dup 2) (match_dup 1))))
1757 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1760 (define_expand "uminsi3"
1761 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1763 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1765 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1767 (minus:SI (match_dup 4) (match_dup 3))))
1768 (set (match_operand:SI 0 "gpc_reg_operand" "")
1769 (minus:SI (match_dup 2) (match_dup 3)))]
1770 "TARGET_POWER || TARGET_ISEL"
1775 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1778 operands[3] = gen_reg_rtx (SImode);
1779 operands[4] = gen_reg_rtx (SImode);
1780 operands[5] = GEN_INT (-2147483647 - 1);
1783 (define_expand "umaxsi3"
1784 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1786 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1788 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1790 (minus:SI (match_dup 4) (match_dup 3))))
1791 (set (match_operand:SI 0 "gpc_reg_operand" "")
1792 (plus:SI (match_dup 3) (match_dup 1)))]
1793 "TARGET_POWER || TARGET_ISEL"
1798 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1801 operands[3] = gen_reg_rtx (SImode);
1802 operands[4] = gen_reg_rtx (SImode);
1803 operands[5] = GEN_INT (-2147483647 - 1);
1807 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1808 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1809 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1811 (minus:SI (match_dup 2) (match_dup 1))))]
1816 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1818 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1819 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1821 (minus:SI (match_dup 2) (match_dup 1)))
1823 (clobber (match_scratch:SI 3 "=r,r"))]
1828 [(set_attr "type" "delayed_compare")
1829 (set_attr "length" "4,8")])
1832 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1834 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1835 (match_operand:SI 2 "reg_or_short_operand" ""))
1837 (minus:SI (match_dup 2) (match_dup 1)))
1839 (clobber (match_scratch:SI 3 ""))]
1840 "TARGET_POWER && reload_completed"
1842 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1844 (minus:SI (match_dup 2) (match_dup 1))))
1846 (compare:CC (match_dup 3)
1851 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1853 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1854 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1856 (minus:SI (match_dup 2) (match_dup 1)))
1858 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1859 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1861 (minus:SI (match_dup 2) (match_dup 1))))]
1866 [(set_attr "type" "delayed_compare")
1867 (set_attr "length" "4,8")])
1870 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1872 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1873 (match_operand:SI 2 "reg_or_short_operand" ""))
1875 (minus:SI (match_dup 2) (match_dup 1)))
1877 (set (match_operand:SI 0 "gpc_reg_operand" "")
1878 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1880 (minus:SI (match_dup 2) (match_dup 1))))]
1881 "TARGET_POWER && reload_completed"
1883 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1885 (minus:SI (match_dup 2) (match_dup 1))))
1887 (compare:CC (match_dup 0)
1891 ;; We don't need abs with condition code because such comparisons should
1893 (define_expand "abssi2"
1894 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1895 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1901 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
1904 else if (! TARGET_POWER)
1906 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
1911 (define_insn "*abssi2_power"
1912 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1913 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1917 (define_insn_and_split "abssi2_isel"
1918 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1919 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
1920 (clobber (match_scratch:SI 2 "=&b"))
1921 (clobber (match_scratch:CC 3 "=y"))]
1924 "&& reload_completed"
1925 [(set (match_dup 2) (neg:SI (match_dup 1)))
1927 (compare:CC (match_dup 1)
1930 (if_then_else:SI (ge (match_dup 3)
1936 (define_insn_and_split "abssi2_nopower"
1937 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1938 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
1939 (clobber (match_scratch:SI 2 "=&r,&r"))]
1940 "! TARGET_POWER && ! TARGET_ISEL"
1942 "&& reload_completed"
1943 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1944 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1945 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
1948 (define_insn "*nabs_power"
1949 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1950 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
1954 (define_insn_and_split "*nabs_nopower"
1955 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1956 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
1957 (clobber (match_scratch:SI 2 "=&r,&r"))]
1960 "&& reload_completed"
1961 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1962 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1963 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
1966 (define_expand "neg<mode>2"
1967 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1968 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
1972 (define_insn "*neg<mode>2_internal"
1973 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1974 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1979 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1980 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1982 (clobber (match_scratch:P 2 "=r,r"))]
1987 [(set_attr "type" "fast_compare")
1988 (set_attr "length" "4,8")])
1991 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1992 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
1994 (clobber (match_scratch:P 2 ""))]
1997 (neg:P (match_dup 1)))
1999 (compare:CC (match_dup 2)
2004 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2005 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2007 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2008 (neg:P (match_dup 1)))]
2013 [(set_attr "type" "fast_compare")
2014 (set_attr "length" "4,8")])
2017 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2018 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2020 (set (match_operand:P 0 "gpc_reg_operand" "")
2021 (neg:P (match_dup 1)))]
2024 (neg:P (match_dup 1)))
2026 (compare:CC (match_dup 0)
2030 (define_insn "clz<mode>2"
2031 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2032 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2034 "{cntlz|cntlz<wd>} %0,%1")
2036 (define_expand "ctz<mode>2"
2038 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))
2039 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2041 (clobber (scratch:CC))])
2042 (set (match_dup 4) (clz:GPR (match_dup 3)))
2043 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2044 (minus:GPR (match_dup 5) (match_dup 4)))]
2047 operands[2] = gen_reg_rtx (<MODE>mode);
2048 operands[3] = gen_reg_rtx (<MODE>mode);
2049 operands[4] = gen_reg_rtx (<MODE>mode);
2050 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
2053 (define_expand "ffs<mode>2"
2055 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))
2056 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2058 (clobber (scratch:CC))])
2059 (set (match_dup 4) (clz:GPR (match_dup 3)))
2060 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2061 (minus:GPR (match_dup 5) (match_dup 4)))]
2064 operands[2] = gen_reg_rtx (<MODE>mode);
2065 operands[3] = gen_reg_rtx (<MODE>mode);
2066 operands[4] = gen_reg_rtx (<MODE>mode);
2067 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
2070 (define_expand "popcount<mode>2"
2072 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2075 (mult:GPR (match_dup 2) (match_dup 4)))
2076 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2077 (lshiftrt:GPR (match_dup 3) (match_dup 5)))]
2080 operands[2] = gen_reg_rtx (<MODE>mode);
2081 operands[3] = gen_reg_rtx (<MODE>mode);
2082 operands[4] = force_reg (<MODE>mode,
2083 <MODE>mode == SImode
2084 ? GEN_INT (0x01010101)
2085 : GEN_INT ((HOST_WIDE_INT)
2086 0x01010101 << 32 | 0x01010101));
2087 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 8);
2090 (define_insn "popcntb<mode>2"
2091 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2092 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2097 (define_expand "mulsi3"
2098 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2099 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2100 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2105 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2107 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2111 (define_insn "mulsi3_mq"
2112 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2113 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2114 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2115 (clobber (match_scratch:SI 3 "=q,q"))]
2118 {muls|mullw} %0,%1,%2
2119 {muli|mulli} %0,%1,%2"
2121 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2122 (const_string "imul3")
2123 (match_operand:SI 2 "short_cint_operand" "")
2124 (const_string "imul2")]
2125 (const_string "imul")))])
2127 (define_insn "mulsi3_no_mq"
2128 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2129 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2130 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2133 {muls|mullw} %0,%1,%2
2134 {muli|mulli} %0,%1,%2"
2136 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2137 (const_string "imul3")
2138 (match_operand:SI 2 "short_cint_operand" "")
2139 (const_string "imul2")]
2140 (const_string "imul")))])
2142 (define_insn "*mulsi3_mq_internal1"
2143 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2144 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2145 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2147 (clobber (match_scratch:SI 3 "=r,r"))
2148 (clobber (match_scratch:SI 4 "=q,q"))]
2151 {muls.|mullw.} %3,%1,%2
2153 [(set_attr "type" "imul_compare")
2154 (set_attr "length" "4,8")])
2157 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2158 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2159 (match_operand:SI 2 "gpc_reg_operand" ""))
2161 (clobber (match_scratch:SI 3 ""))
2162 (clobber (match_scratch:SI 4 ""))]
2163 "TARGET_POWER && reload_completed"
2164 [(parallel [(set (match_dup 3)
2165 (mult:SI (match_dup 1) (match_dup 2)))
2166 (clobber (match_dup 4))])
2168 (compare:CC (match_dup 3)
2172 (define_insn "*mulsi3_no_mq_internal1"
2173 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2174 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2175 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2177 (clobber (match_scratch:SI 3 "=r,r"))]
2180 {muls.|mullw.} %3,%1,%2
2182 [(set_attr "type" "imul_compare")
2183 (set_attr "length" "4,8")])
2186 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2187 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2188 (match_operand:SI 2 "gpc_reg_operand" ""))
2190 (clobber (match_scratch:SI 3 ""))]
2191 "! TARGET_POWER && reload_completed"
2193 (mult:SI (match_dup 1) (match_dup 2)))
2195 (compare:CC (match_dup 3)
2199 (define_insn "*mulsi3_mq_internal2"
2200 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2201 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2202 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2204 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2205 (mult:SI (match_dup 1) (match_dup 2)))
2206 (clobber (match_scratch:SI 4 "=q,q"))]
2209 {muls.|mullw.} %0,%1,%2
2211 [(set_attr "type" "imul_compare")
2212 (set_attr "length" "4,8")])
2215 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2216 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2217 (match_operand:SI 2 "gpc_reg_operand" ""))
2219 (set (match_operand:SI 0 "gpc_reg_operand" "")
2220 (mult:SI (match_dup 1) (match_dup 2)))
2221 (clobber (match_scratch:SI 4 ""))]
2222 "TARGET_POWER && reload_completed"
2223 [(parallel [(set (match_dup 0)
2224 (mult:SI (match_dup 1) (match_dup 2)))
2225 (clobber (match_dup 4))])
2227 (compare:CC (match_dup 0)
2231 (define_insn "*mulsi3_no_mq_internal2"
2232 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2233 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2234 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2236 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2237 (mult:SI (match_dup 1) (match_dup 2)))]
2240 {muls.|mullw.} %0,%1,%2
2242 [(set_attr "type" "imul_compare")
2243 (set_attr "length" "4,8")])
2246 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2247 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2248 (match_operand:SI 2 "gpc_reg_operand" ""))
2250 (set (match_operand:SI 0 "gpc_reg_operand" "")
2251 (mult:SI (match_dup 1) (match_dup 2)))]
2252 "! TARGET_POWER && reload_completed"
2254 (mult:SI (match_dup 1) (match_dup 2)))
2256 (compare:CC (match_dup 0)
2260 ;; Operand 1 is divided by operand 2; quotient goes to operand
2261 ;; 0 and remainder to operand 3.
2262 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2264 (define_expand "divmodsi4"
2265 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2266 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2267 (match_operand:SI 2 "gpc_reg_operand" "")))
2268 (set (match_operand:SI 3 "register_operand" "")
2269 (mod:SI (match_dup 1) (match_dup 2)))])]
2270 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2273 if (! TARGET_POWER && ! TARGET_POWERPC)
2275 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2276 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2277 emit_insn (gen_divss_call ());
2278 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2279 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2284 (define_insn "*divmodsi4_internal"
2285 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2286 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2287 (match_operand:SI 2 "gpc_reg_operand" "r")))
2288 (set (match_operand:SI 3 "register_operand" "=q")
2289 (mod:SI (match_dup 1) (match_dup 2)))]
2292 [(set_attr "type" "idiv")])
2294 (define_expand "udiv<mode>3"
2295 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2296 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2297 (match_operand:GPR 2 "gpc_reg_operand" "")))]
2298 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2301 if (! TARGET_POWER && ! TARGET_POWERPC)
2303 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2304 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2305 emit_insn (gen_quous_call ());
2306 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2309 else if (TARGET_POWER)
2311 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2316 (define_insn "udivsi3_mq"
2317 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2318 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2319 (match_operand:SI 2 "gpc_reg_operand" "r")))
2320 (clobber (match_scratch:SI 3 "=q"))]
2321 "TARGET_POWERPC && TARGET_POWER"
2323 [(set_attr "type" "idiv")])
2325 (define_insn "*udivsi3_no_mq"
2326 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2327 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2328 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2329 "TARGET_POWERPC && ! TARGET_POWER"
2331 [(set_attr "type" "idiv")])
2333 ;; For powers of two we can do srai/aze for divide and then adjust for
2334 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2335 ;; used; for PowerPC, force operands into register and do a normal divide;
2336 ;; for AIX common-mode, use quoss call on register operands.
2337 (define_expand "div<mode>3"
2338 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2339 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2340 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2344 if (GET_CODE (operands[2]) == CONST_INT
2345 && INTVAL (operands[2]) > 0
2346 && exact_log2 (INTVAL (operands[2])) >= 0)
2348 else if (TARGET_POWERPC)
2350 operands[2] = force_reg (SImode, operands[2]);
2353 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2357 else if (TARGET_POWER)
2361 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2362 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2363 emit_insn (gen_quoss_call ());
2364 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2369 (define_insn "divsi3_mq"
2370 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2371 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2372 (match_operand:SI 2 "gpc_reg_operand" "r")))
2373 (clobber (match_scratch:SI 3 "=q"))]
2374 "TARGET_POWERPC && TARGET_POWER"
2376 [(set_attr "type" "idiv")])
2378 (define_insn "*div<mode>3_no_mq"
2379 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2380 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2381 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2382 "TARGET_POWERPC && ! TARGET_POWER"
2384 [(set_attr "type" "idiv")])
2386 (define_expand "mod<mode>3"
2387 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2388 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2389 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
2397 if (GET_CODE (operands[2]) != CONST_INT
2398 || INTVAL (operands[2]) <= 0
2399 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2402 temp1 = gen_reg_rtx (<MODE>mode);
2403 temp2 = gen_reg_rtx (<MODE>mode);
2405 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2406 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2407 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
2412 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2413 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2414 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
2416 "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
2417 [(set_attr "type" "two")
2418 (set_attr "length" "8")])
2421 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2422 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2423 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2425 (clobber (match_scratch:P 3 "=r,r"))]
2428 {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
2430 [(set_attr "type" "compare")
2431 (set_attr "length" "8,12")])
2434 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2435 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2436 (match_operand:GPR 2 "exact_log2_cint_operand"
2439 (clobber (match_scratch:GPR 3 ""))]
2442 (div:<MODE> (match_dup 1) (match_dup 2)))
2444 (compare:CC (match_dup 3)
2449 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2450 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2451 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2453 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2454 (div:P (match_dup 1) (match_dup 2)))]
2457 {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
2459 [(set_attr "type" "compare")
2460 (set_attr "length" "8,12")])
2463 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2464 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2465 (match_operand:GPR 2 "exact_log2_cint_operand"
2468 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2469 (div:GPR (match_dup 1) (match_dup 2)))]
2472 (div:<MODE> (match_dup 1) (match_dup 2)))
2474 (compare:CC (match_dup 0)
2479 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2482 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2484 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2485 (match_operand:SI 3 "gpc_reg_operand" "r")))
2486 (set (match_operand:SI 2 "register_operand" "=*q")
2489 (zero_extend:DI (match_dup 1)) (const_int 32))
2490 (zero_extend:DI (match_dup 4)))
2494 [(set_attr "type" "idiv")])
2496 ;; To do unsigned divide we handle the cases of the divisor looking like a
2497 ;; negative number. If it is a constant that is less than 2**31, we don't
2498 ;; have to worry about the branches. So make a few subroutines here.
2500 ;; First comes the normal case.
2501 (define_expand "udivmodsi4_normal"
2502 [(set (match_dup 4) (const_int 0))
2503 (parallel [(set (match_operand:SI 0 "" "")
2504 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2506 (zero_extend:DI (match_operand:SI 1 "" "")))
2507 (match_operand:SI 2 "" "")))
2508 (set (match_operand:SI 3 "" "")
2509 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2511 (zero_extend:DI (match_dup 1)))
2515 { operands[4] = gen_reg_rtx (SImode); }")
2517 ;; This handles the branches.
2518 (define_expand "udivmodsi4_tests"
2519 [(set (match_operand:SI 0 "" "") (const_int 0))
2520 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2521 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2522 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2523 (label_ref (match_operand:SI 4 "" "")) (pc)))
2524 (set (match_dup 0) (const_int 1))
2525 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2526 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2527 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2528 (label_ref (match_dup 4)) (pc)))]
2531 { operands[5] = gen_reg_rtx (CCUNSmode);
2532 operands[6] = gen_reg_rtx (CCmode);
2535 (define_expand "udivmodsi4"
2536 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2537 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2538 (match_operand:SI 2 "reg_or_cint_operand" "")))
2539 (set (match_operand:SI 3 "gpc_reg_operand" "")
2540 (umod:SI (match_dup 1) (match_dup 2)))])]
2548 if (! TARGET_POWERPC)
2550 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2551 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2552 emit_insn (gen_divus_call ());
2553 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2554 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2561 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2563 operands[2] = force_reg (SImode, operands[2]);
2564 label = gen_label_rtx ();
2565 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2566 operands[3], label));
2569 operands[2] = force_reg (SImode, operands[2]);
2571 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2579 ;; AIX architecture-independent common-mode multiply (DImode),
2580 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2581 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2582 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2583 ;; assumed unused if generating common-mode, so ignore.
2584 (define_insn "mulh_call"
2587 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2588 (sign_extend:DI (reg:SI 4)))
2590 (clobber (match_scratch:SI 0 "=l"))]
2591 "! TARGET_POWER && ! TARGET_POWERPC"
2593 [(set_attr "type" "imul")])
2595 (define_insn "mull_call"
2597 (mult:DI (sign_extend:DI (reg:SI 3))
2598 (sign_extend:DI (reg:SI 4))))
2599 (clobber (match_scratch:SI 0 "=l"))
2600 (clobber (reg:SI 0))]
2601 "! TARGET_POWER && ! TARGET_POWERPC"
2603 [(set_attr "type" "imul")])
2605 (define_insn "divss_call"
2607 (div:SI (reg:SI 3) (reg:SI 4)))
2609 (mod:SI (reg:SI 3) (reg:SI 4)))
2610 (clobber (match_scratch:SI 0 "=l"))
2611 (clobber (reg:SI 0))]
2612 "! TARGET_POWER && ! TARGET_POWERPC"
2614 [(set_attr "type" "idiv")])
2616 (define_insn "divus_call"
2618 (udiv:SI (reg:SI 3) (reg:SI 4)))
2620 (umod:SI (reg:SI 3) (reg:SI 4)))
2621 (clobber (match_scratch:SI 0 "=l"))
2622 (clobber (reg:SI 0))
2623 (clobber (match_scratch:CC 1 "=x"))
2624 (clobber (reg:CC 69))]
2625 "! TARGET_POWER && ! TARGET_POWERPC"
2627 [(set_attr "type" "idiv")])
2629 (define_insn "quoss_call"
2631 (div:SI (reg:SI 3) (reg:SI 4)))
2632 (clobber (match_scratch:SI 0 "=l"))]
2633 "! TARGET_POWER && ! TARGET_POWERPC"
2635 [(set_attr "type" "idiv")])
2637 (define_insn "quous_call"
2639 (udiv:SI (reg:SI 3) (reg:SI 4)))
2640 (clobber (match_scratch:SI 0 "=l"))
2641 (clobber (reg:SI 0))
2642 (clobber (match_scratch:CC 1 "=x"))
2643 (clobber (reg:CC 69))]
2644 "! TARGET_POWER && ! TARGET_POWERPC"
2646 [(set_attr "type" "idiv")])
2648 ;; Logical instructions
2649 ;; The logical instructions are mostly combined by using match_operator,
2650 ;; but the plain AND insns are somewhat different because there is no
2651 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2652 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2654 (define_insn "andsi3"
2655 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2656 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2657 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2658 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2662 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2663 {andil.|andi.} %0,%1,%b2
2664 {andiu.|andis.} %0,%1,%u2"
2665 [(set_attr "type" "*,*,compare,compare")])
2667 ;; Note to set cr's other than cr0 we do the and immediate and then
2668 ;; the test again -- this avoids a mfcr which on the higher end
2669 ;; machines causes an execution serialization
2671 (define_insn "*andsi3_internal2"
2672 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2673 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2674 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2676 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2677 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2681 {andil.|andi.} %3,%1,%b2
2682 {andiu.|andis.} %3,%1,%u2
2683 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2688 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2689 (set_attr "length" "4,4,4,4,8,8,8,8")])
2691 (define_insn "*andsi3_internal3"
2692 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2693 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2694 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2696 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2697 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2701 {andil.|andi.} %3,%1,%b2
2702 {andiu.|andis.} %3,%1,%u2
2703 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2708 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2709 (set_attr "length" "8,4,4,4,8,8,8,8")])
2712 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2713 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2714 (match_operand:GPR 2 "and_operand" ""))
2716 (clobber (match_scratch:GPR 3 ""))
2717 (clobber (match_scratch:CC 4 ""))]
2719 [(parallel [(set (match_dup 3)
2720 (and:<MODE> (match_dup 1)
2722 (clobber (match_dup 4))])
2724 (compare:CC (match_dup 3)
2728 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2729 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2732 [(set (match_operand:CC 0 "cc_reg_operand" "")
2733 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2734 (match_operand:SI 2 "gpc_reg_operand" ""))
2736 (clobber (match_scratch:SI 3 ""))
2737 (clobber (match_scratch:CC 4 ""))]
2738 "TARGET_POWERPC64 && reload_completed"
2739 [(parallel [(set (match_dup 3)
2740 (and:SI (match_dup 1)
2742 (clobber (match_dup 4))])
2744 (compare:CC (match_dup 3)
2748 (define_insn "*andsi3_internal4"
2749 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2750 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2751 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2753 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2754 (and:SI (match_dup 1)
2756 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2760 {andil.|andi.} %0,%1,%b2
2761 {andiu.|andis.} %0,%1,%u2
2762 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2767 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2768 (set_attr "length" "4,4,4,4,8,8,8,8")])
2770 (define_insn "*andsi3_internal5"
2771 [(set (match_operand:CC 3 "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 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2776 (and:SI (match_dup 1)
2778 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2782 {andil.|andi.} %0,%1,%b2
2783 {andiu.|andis.} %0,%1,%u2
2784 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2789 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2790 (set_attr "length" "8,4,4,4,8,8,8,8")])
2793 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2794 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2795 (match_operand:SI 2 "and_operand" ""))
2797 (set (match_operand:SI 0 "gpc_reg_operand" "")
2798 (and:SI (match_dup 1)
2800 (clobber (match_scratch:CC 4 ""))]
2802 [(parallel [(set (match_dup 0)
2803 (and:SI (match_dup 1)
2805 (clobber (match_dup 4))])
2807 (compare:CC (match_dup 0)
2812 [(set (match_operand:CC 3 "cc_reg_operand" "")
2813 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2814 (match_operand:SI 2 "gpc_reg_operand" ""))
2816 (set (match_operand:SI 0 "gpc_reg_operand" "")
2817 (and:SI (match_dup 1)
2819 (clobber (match_scratch:CC 4 ""))]
2820 "TARGET_POWERPC64 && reload_completed"
2821 [(parallel [(set (match_dup 0)
2822 (and:SI (match_dup 1)
2824 (clobber (match_dup 4))])
2826 (compare:CC (match_dup 0)
2830 ;; Handle the PowerPC64 rlwinm corner case
2832 (define_insn_and_split "*andsi3_internal6"
2833 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2834 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2835 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2840 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2843 (rotate:SI (match_dup 0) (match_dup 5)))]
2846 int mb = extract_MB (operands[2]);
2847 int me = extract_ME (operands[2]);
2848 operands[3] = GEN_INT (me + 1);
2849 operands[5] = GEN_INT (32 - (me + 1));
2850 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2852 [(set_attr "length" "8")])
2854 (define_expand "iorsi3"
2855 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2856 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
2857 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2861 if (GET_CODE (operands[2]) == CONST_INT
2862 && ! logical_operand (operands[2], SImode))
2864 HOST_WIDE_INT value = INTVAL (operands[2]);
2865 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2866 ? operands[0] : gen_reg_rtx (SImode));
2868 emit_insn (gen_iorsi3 (tmp, operands[1],
2869 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2870 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2875 (define_expand "xorsi3"
2876 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2877 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2878 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2882 if (GET_CODE (operands[2]) == CONST_INT
2883 && ! logical_operand (operands[2], SImode))
2885 HOST_WIDE_INT value = INTVAL (operands[2]);
2886 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2887 ? operands[0] : gen_reg_rtx (SImode));
2889 emit_insn (gen_xorsi3 (tmp, operands[1],
2890 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2891 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2896 (define_insn "*boolsi3_internal1"
2897 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2898 (match_operator:SI 3 "boolean_or_operator"
2899 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
2900 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
2904 {%q3il|%q3i} %0,%1,%b2
2905 {%q3iu|%q3is} %0,%1,%u2")
2907 (define_insn "*boolsi3_internal2"
2908 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2909 (compare:CC (match_operator:SI 4 "boolean_or_operator"
2910 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2911 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2913 (clobber (match_scratch:SI 3 "=r,r"))]
2918 [(set_attr "type" "compare")
2919 (set_attr "length" "4,8")])
2922 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2923 (compare:CC (match_operator:SI 4 "boolean_operator"
2924 [(match_operand:SI 1 "gpc_reg_operand" "")
2925 (match_operand:SI 2 "gpc_reg_operand" "")])
2927 (clobber (match_scratch:SI 3 ""))]
2928 "TARGET_32BIT && reload_completed"
2929 [(set (match_dup 3) (match_dup 4))
2931 (compare:CC (match_dup 3)
2935 (define_insn "*boolsi3_internal3"
2936 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2937 (compare:CC (match_operator:SI 4 "boolean_operator"
2938 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2939 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2941 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2947 [(set_attr "type" "compare")
2948 (set_attr "length" "4,8")])
2951 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2952 (compare:CC (match_operator:SI 4 "boolean_operator"
2953 [(match_operand:SI 1 "gpc_reg_operand" "")
2954 (match_operand:SI 2 "gpc_reg_operand" "")])
2956 (set (match_operand:SI 0 "gpc_reg_operand" "")
2958 "TARGET_32BIT && reload_completed"
2959 [(set (match_dup 0) (match_dup 4))
2961 (compare:CC (match_dup 0)
2965 ;; Split a logical operation that we can't do in one insn into two insns,
2966 ;; each of which does one 16-bit part. This is used by combine.
2969 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2970 (match_operator:SI 3 "boolean_or_operator"
2971 [(match_operand:SI 1 "gpc_reg_operand" "")
2972 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
2974 [(set (match_dup 0) (match_dup 4))
2975 (set (match_dup 0) (match_dup 5))]
2979 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
2980 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
2982 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
2983 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
2987 (define_insn "*boolcsi3_internal1"
2988 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2989 (match_operator:SI 3 "boolean_operator"
2990 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
2991 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
2995 (define_insn "*boolcsi3_internal2"
2996 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2997 (compare:CC (match_operator:SI 4 "boolean_operator"
2998 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2999 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3001 (clobber (match_scratch:SI 3 "=r,r"))]
3006 [(set_attr "type" "compare")
3007 (set_attr "length" "4,8")])
3010 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3011 (compare:CC (match_operator:SI 4 "boolean_operator"
3012 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3013 (match_operand:SI 2 "gpc_reg_operand" "")])
3015 (clobber (match_scratch:SI 3 ""))]
3016 "TARGET_32BIT && reload_completed"
3017 [(set (match_dup 3) (match_dup 4))
3019 (compare:CC (match_dup 3)
3023 (define_insn "*boolcsi3_internal3"
3024 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3025 (compare:CC (match_operator:SI 4 "boolean_operator"
3026 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3027 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3029 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3035 [(set_attr "type" "compare")
3036 (set_attr "length" "4,8")])
3039 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3040 (compare:CC (match_operator:SI 4 "boolean_operator"
3041 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3042 (match_operand:SI 2 "gpc_reg_operand" "")])
3044 (set (match_operand:SI 0 "gpc_reg_operand" "")
3046 "TARGET_32BIT && reload_completed"
3047 [(set (match_dup 0) (match_dup 4))
3049 (compare:CC (match_dup 0)
3053 (define_insn "*boolccsi3_internal1"
3054 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3055 (match_operator:SI 3 "boolean_operator"
3056 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3057 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3061 (define_insn "*boolccsi3_internal2"
3062 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3063 (compare:CC (match_operator:SI 4 "boolean_operator"
3064 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3065 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3067 (clobber (match_scratch:SI 3 "=r,r"))]
3072 [(set_attr "type" "compare")
3073 (set_attr "length" "4,8")])
3076 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3077 (compare:CC (match_operator:SI 4 "boolean_operator"
3078 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3079 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3081 (clobber (match_scratch:SI 3 ""))]
3082 "TARGET_32BIT && reload_completed"
3083 [(set (match_dup 3) (match_dup 4))
3085 (compare:CC (match_dup 3)
3089 (define_insn "*boolccsi3_internal3"
3090 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3091 (compare:CC (match_operator:SI 4 "boolean_operator"
3092 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3093 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3095 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3101 [(set_attr "type" "compare")
3102 (set_attr "length" "4,8")])
3105 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3106 (compare:CC (match_operator:SI 4 "boolean_operator"
3107 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3108 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3110 (set (match_operand:SI 0 "gpc_reg_operand" "")
3112 "TARGET_32BIT && reload_completed"
3113 [(set (match_dup 0) (match_dup 4))
3115 (compare:CC (match_dup 0)
3119 ;; maskir insn. We need four forms because things might be in arbitrary
3120 ;; orders. Don't define forms that only set CR fields because these
3121 ;; would modify an input register.
3123 (define_insn "*maskir_internal1"
3124 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3125 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3126 (match_operand:SI 1 "gpc_reg_operand" "0"))
3127 (and:SI (match_dup 2)
3128 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
3132 (define_insn "*maskir_internal2"
3133 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3134 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3135 (match_operand:SI 1 "gpc_reg_operand" "0"))
3136 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3141 (define_insn "*maskir_internal3"
3142 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3143 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
3144 (match_operand:SI 3 "gpc_reg_operand" "r"))
3145 (and:SI (not:SI (match_dup 2))
3146 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3150 (define_insn "*maskir_internal4"
3151 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3152 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3153 (match_operand:SI 2 "gpc_reg_operand" "r"))
3154 (and:SI (not:SI (match_dup 2))
3155 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3159 (define_insn "*maskir_internal5"
3160 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3162 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3163 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3164 (and:SI (match_dup 2)
3165 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
3167 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3168 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3169 (and:SI (match_dup 2) (match_dup 3))))]
3174 [(set_attr "type" "compare")
3175 (set_attr "length" "4,8")])
3178 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3180 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3181 (match_operand:SI 1 "gpc_reg_operand" ""))
3182 (and:SI (match_dup 2)
3183 (match_operand:SI 3 "gpc_reg_operand" "")))
3185 (set (match_operand:SI 0 "gpc_reg_operand" "")
3186 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3187 (and:SI (match_dup 2) (match_dup 3))))]
3188 "TARGET_POWER && reload_completed"
3190 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3191 (and:SI (match_dup 2) (match_dup 3))))
3193 (compare:CC (match_dup 0)
3197 (define_insn "*maskir_internal6"
3198 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3200 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3201 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3202 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3205 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3206 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3207 (and:SI (match_dup 3) (match_dup 2))))]
3212 [(set_attr "type" "compare")
3213 (set_attr "length" "4,8")])
3216 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3218 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3219 (match_operand:SI 1 "gpc_reg_operand" ""))
3220 (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3223 (set (match_operand:SI 0 "gpc_reg_operand" "")
3224 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3225 (and:SI (match_dup 3) (match_dup 2))))]
3226 "TARGET_POWER && reload_completed"
3228 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3229 (and:SI (match_dup 3) (match_dup 2))))
3231 (compare:CC (match_dup 0)
3235 (define_insn "*maskir_internal7"
3236 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3238 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
3239 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
3240 (and:SI (not:SI (match_dup 2))
3241 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3243 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3244 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3245 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3250 [(set_attr "type" "compare")
3251 (set_attr "length" "4,8")])
3254 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3256 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
3257 (match_operand:SI 3 "gpc_reg_operand" ""))
3258 (and:SI (not:SI (match_dup 2))
3259 (match_operand:SI 1 "gpc_reg_operand" "")))
3261 (set (match_operand:SI 0 "gpc_reg_operand" "")
3262 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3263 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3264 "TARGET_POWER && reload_completed"
3266 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3267 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3269 (compare:CC (match_dup 0)
3273 (define_insn "*maskir_internal8"
3274 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")