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, 2007
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 3, 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 COPYING3. If not see
21 ;; <http://www.gnu.org/licenses/>.
23 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
43 (FIRST_ALTIVEC_REGNO 77)
44 (LAST_ALTIVEC_REGNO 108)
57 [(UNSPEC_FRSP 0) ; frsp for POWER machines
58 (UNSPEC_TIE 5) ; tie stack contents and stack pointer
59 (UNSPEC_TOCPTR 6) ; address of a word pointing to the TOC
60 (UNSPEC_TOC 7) ; address of the TOC (more-or-less)
62 (UNSPEC_MV_CR_OV 9) ; move_from_CR_ov_bit
68 (UNSPEC_LD_MPIC 15) ; load_macho_picbase
69 (UNSPEC_MPIC_CORRECT 16) ; macho_correct_pic
72 (UNSPEC_MOVESI_FROM_CR 19)
73 (UNSPEC_MOVESI_TO_CR 20)
75 (UNSPEC_TLSDTPRELHA 22)
76 (UNSPEC_TLSDTPRELLO 23)
77 (UNSPEC_TLSGOTDTPREL 24)
79 (UNSPEC_TLSTPRELHA 26)
80 (UNSPEC_TLSTPRELLO 27)
81 (UNSPEC_TLSGOTTPREL 28)
83 (UNSPEC_FIX_TRUNC_TF 30) ; fadd, rounding towards zero
84 (UNSPEC_MV_CR_GT 31) ; move_from_CR_gt_bit
100 (UNSPEC_DLMZB_STRLEN 47)
104 ;; UNSPEC_VOLATILE usage
109 (UNSPECV_LL 1) ; load-locked
110 (UNSPECV_SC 2) ; store-conditional
111 (UNSPECV_EH_RR 9) ; eh_reg_restore
114 ;; Define an insn type attribute. This is used in function unit delay
116 (define_attr "type" "integer,two,three,load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,store,store_ux,store_u,fpload,fpload_ux,fpload_u,fpstore,fpstore_ux,fpstore_u,vecload,vecstore,imul,imul2,imul3,lmul,idiv,ldiv,insert_word,branch,cmp,fast_compare,compare,var_delayed_compare,delayed_compare,imul_compare,lmul_compare,fpcompare,cr_logical,delayed_cr,mfcr,mfcrf,mtcr,mfjmpr,mtjmpr,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg,brinc,vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,vecfloat,vecfdiv,isync,sync,load_l,store_c,shift,trap,insert_dword,var_shift_rotate,cntlz,exts,mffgpr,mftgpr"
117 (const_string "integer"))
119 ;; Length (in bytes).
120 ; '(pc)' in the following doesn't include the instruction itself; it is
121 ; calculated as if the instruction had zero size.
122 (define_attr "length" ""
123 (if_then_else (eq_attr "type" "branch")
124 (if_then_else (and (ge (minus (match_dup 0) (pc))
126 (lt (minus (match_dup 0) (pc))
132 ;; Processor type -- this attribute must exactly match the processor_type
133 ;; enumeration in rs6000.h.
135 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4,power5,power6,cell"
136 (const (symbol_ref "rs6000_cpu_attr")))
139 ;; If this instruction is microcoded on the CELL processor
140 ; The default for load and stores is conditional
141 ; The default for load extended and the recorded instructions is always microcoded
142 (define_attr "cell_micro" "not,conditional,always"
143 (if_then_else (ior (ior (eq_attr "type" "load")
144 (eq_attr "type" "store"))
145 (ior (eq_attr "type" "fpload")
146 (eq_attr "type" "fpstore")))
147 (const_string "conditional")
148 (if_then_else (ior (eq_attr "type" "load_ext")
149 (ior (eq_attr "type" "compare")
150 (eq_attr "type" "delayed_compare")))
151 (const_string "always")
152 (const_string "not"))))
155 (automata_option "ndfa")
168 (include "power4.md")
169 (include "power5.md")
170 (include "power6.md")
173 (include "predicates.md")
174 (include "constraints.md")
176 (include "darwin.md")
181 ; This mode iterator allows :GPR to be used to indicate the allowable size
182 ; of whole values in GPRs.
183 (define_mode_iterator GPR [SI (DI "TARGET_POWERPC64")])
185 ; Any supported integer mode.
186 (define_mode_iterator INT [QI HI SI DI TI])
188 ; Any supported integer mode that fits in one register.
189 (define_mode_iterator INT1 [QI HI SI (DI "TARGET_POWERPC64")])
191 ; extend modes for DImode
192 (define_mode_iterator QHSI [QI HI SI])
194 ; SImode or DImode, even if DImode doesn't fit in GPRs.
195 (define_mode_iterator SDI [SI DI])
197 ; The size of a pointer. Also, the size of the value that a record-condition
198 ; (one with a '.') will compare.
199 (define_mode_iterator P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
201 ; Any hardware-supported floating-point mode
202 (define_mode_iterator FP [(SF "TARGET_HARD_FLOAT")
203 (DF "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)")
204 (TF "!TARGET_IEEEQUAD
206 && (TARGET_FPRS || TARGET_E500_DOUBLE)
207 && TARGET_LONG_DOUBLE_128")
211 ; Various instructions that come in SI and DI forms.
212 ; A generic w/d attribute, for things like cmpw/cmpd.
213 (define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
216 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
219 ;; Start with fixed-point load and store insns. Here we put only the more
220 ;; complex forms. Basic data transfer is done later.
222 (define_expand "zero_extend<mode>di2"
223 [(set (match_operand:DI 0 "gpc_reg_operand" "")
224 (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "")))]
228 (define_insn "*zero_extend<mode>di2_internal1"
229 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
230 (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
234 rldicl %0,%1,0,<dbits>"
235 [(set_attr "type" "load,*")])
237 (define_insn "*zero_extend<mode>di2_internal2"
238 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
239 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
241 (clobber (match_scratch:DI 2 "=r,r"))]
244 rldicl. %2,%1,0,<dbits>
246 [(set_attr "type" "compare")
247 (set_attr "length" "4,8")])
250 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
251 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
253 (clobber (match_scratch:DI 2 ""))]
254 "TARGET_POWERPC64 && reload_completed"
256 (zero_extend:DI (match_dup 1)))
258 (compare:CC (match_dup 2)
262 (define_insn "*zero_extend<mode>di2_internal3"
263 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
264 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
266 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
267 (zero_extend:DI (match_dup 1)))]
270 rldicl. %0,%1,0,<dbits>
272 [(set_attr "type" "compare")
273 (set_attr "length" "4,8")])
276 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
277 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
279 (set (match_operand:DI 0 "gpc_reg_operand" "")
280 (zero_extend:DI (match_dup 1)))]
281 "TARGET_POWERPC64 && reload_completed"
283 (zero_extend:DI (match_dup 1)))
285 (compare:CC (match_dup 0)
289 (define_insn "extendqidi2"
290 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
291 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
294 [(set_attr "type" "exts")])
297 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
298 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
300 (clobber (match_scratch:DI 2 "=r,r"))]
305 [(set_attr "type" "compare")
306 (set_attr "length" "4,8")])
309 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
310 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
312 (clobber (match_scratch:DI 2 ""))]
313 "TARGET_POWERPC64 && reload_completed"
315 (sign_extend:DI (match_dup 1)))
317 (compare:CC (match_dup 2)
322 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
323 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
325 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
326 (sign_extend:DI (match_dup 1)))]
331 [(set_attr "type" "compare")
332 (set_attr "length" "4,8")])
335 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
336 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
338 (set (match_operand:DI 0 "gpc_reg_operand" "")
339 (sign_extend:DI (match_dup 1)))]
340 "TARGET_POWERPC64 && reload_completed"
342 (sign_extend:DI (match_dup 1)))
344 (compare:CC (match_dup 0)
348 (define_expand "extendhidi2"
349 [(set (match_operand:DI 0 "gpc_reg_operand" "")
350 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
355 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
356 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
361 [(set_attr "type" "load_ext,exts")])
364 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
365 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
367 (clobber (match_scratch:DI 2 "=r,r"))]
372 [(set_attr "type" "compare")
373 (set_attr "length" "4,8")])
376 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
377 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
379 (clobber (match_scratch:DI 2 ""))]
380 "TARGET_POWERPC64 && reload_completed"
382 (sign_extend:DI (match_dup 1)))
384 (compare:CC (match_dup 2)
389 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
390 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
392 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
393 (sign_extend:DI (match_dup 1)))]
398 [(set_attr "type" "compare")
399 (set_attr "length" "4,8")])
402 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
403 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
405 (set (match_operand:DI 0 "gpc_reg_operand" "")
406 (sign_extend:DI (match_dup 1)))]
407 "TARGET_POWERPC64 && reload_completed"
409 (sign_extend:DI (match_dup 1)))
411 (compare:CC (match_dup 0)
415 (define_expand "extendsidi2"
416 [(set (match_operand:DI 0 "gpc_reg_operand" "")
417 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
422 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
423 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
428 [(set_attr "type" "load_ext,exts")])
431 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
432 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
434 (clobber (match_scratch:DI 2 "=r,r"))]
439 [(set_attr "type" "compare")
440 (set_attr "length" "4,8")])
443 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
444 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
446 (clobber (match_scratch:DI 2 ""))]
447 "TARGET_POWERPC64 && reload_completed"
449 (sign_extend:DI (match_dup 1)))
451 (compare:CC (match_dup 2)
456 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
457 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
459 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
460 (sign_extend:DI (match_dup 1)))]
465 [(set_attr "type" "compare")
466 (set_attr "length" "4,8")])
469 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
470 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
472 (set (match_operand:DI 0 "gpc_reg_operand" "")
473 (sign_extend:DI (match_dup 1)))]
474 "TARGET_POWERPC64 && reload_completed"
476 (sign_extend:DI (match_dup 1)))
478 (compare:CC (match_dup 0)
482 (define_expand "zero_extendqisi2"
483 [(set (match_operand:SI 0 "gpc_reg_operand" "")
484 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
489 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
490 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
494 {rlinm|rlwinm} %0,%1,0,0xff"
495 [(set_attr "type" "load,*")])
498 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
499 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
501 (clobber (match_scratch:SI 2 "=r,r"))]
504 {andil.|andi.} %2,%1,0xff
506 [(set_attr "type" "compare")
507 (set_attr "length" "4,8")])
510 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
511 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
513 (clobber (match_scratch:SI 2 ""))]
516 (zero_extend:SI (match_dup 1)))
518 (compare:CC (match_dup 2)
523 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
524 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
526 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
527 (zero_extend:SI (match_dup 1)))]
530 {andil.|andi.} %0,%1,0xff
532 [(set_attr "type" "compare")
533 (set_attr "length" "4,8")])
536 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
537 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
539 (set (match_operand:SI 0 "gpc_reg_operand" "")
540 (zero_extend:SI (match_dup 1)))]
543 (zero_extend:SI (match_dup 1)))
545 (compare:CC (match_dup 0)
549 (define_expand "extendqisi2"
550 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
551 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
556 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
557 else if (TARGET_POWER)
558 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
560 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
564 (define_insn "extendqisi2_ppc"
565 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
566 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
569 [(set_attr "type" "exts")])
572 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
573 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
575 (clobber (match_scratch:SI 2 "=r,r"))]
580 [(set_attr "type" "compare")
581 (set_attr "length" "4,8")])
584 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
585 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
587 (clobber (match_scratch:SI 2 ""))]
588 "TARGET_POWERPC && reload_completed"
590 (sign_extend:SI (match_dup 1)))
592 (compare:CC (match_dup 2)
597 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
598 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
600 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
601 (sign_extend:SI (match_dup 1)))]
606 [(set_attr "type" "compare")
607 (set_attr "length" "4,8")])
610 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
611 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
613 (set (match_operand:SI 0 "gpc_reg_operand" "")
614 (sign_extend:SI (match_dup 1)))]
615 "TARGET_POWERPC && reload_completed"
617 (sign_extend:SI (match_dup 1)))
619 (compare:CC (match_dup 0)
623 (define_expand "extendqisi2_power"
624 [(parallel [(set (match_dup 2)
625 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
627 (clobber (scratch:SI))])
628 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
629 (ashiftrt:SI (match_dup 2)
631 (clobber (scratch:SI))])]
634 { operands[1] = gen_lowpart (SImode, operands[1]);
635 operands[2] = gen_reg_rtx (SImode); }")
637 (define_expand "extendqisi2_no_power"
639 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
641 (set (match_operand:SI 0 "gpc_reg_operand" "")
642 (ashiftrt:SI (match_dup 2)
644 "! TARGET_POWER && ! TARGET_POWERPC"
646 { operands[1] = gen_lowpart (SImode, operands[1]);
647 operands[2] = gen_reg_rtx (SImode); }")
649 (define_expand "zero_extendqihi2"
650 [(set (match_operand:HI 0 "gpc_reg_operand" "")
651 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
656 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
657 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
661 {rlinm|rlwinm} %0,%1,0,0xff"
662 [(set_attr "type" "load,*")])
665 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
666 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
668 (clobber (match_scratch:HI 2 "=r,r"))]
671 {andil.|andi.} %2,%1,0xff
673 [(set_attr "type" "compare")
674 (set_attr "length" "4,8")])
677 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
678 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
680 (clobber (match_scratch:HI 2 ""))]
683 (zero_extend:HI (match_dup 1)))
685 (compare:CC (match_dup 2)
690 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
691 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
693 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
694 (zero_extend:HI (match_dup 1)))]
697 {andil.|andi.} %0,%1,0xff
699 [(set_attr "type" "compare")
700 (set_attr "length" "4,8")])
703 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
704 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
706 (set (match_operand:HI 0 "gpc_reg_operand" "")
707 (zero_extend:HI (match_dup 1)))]
710 (zero_extend:HI (match_dup 1)))
712 (compare:CC (match_dup 0)
716 (define_expand "extendqihi2"
717 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
718 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
723 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
724 else if (TARGET_POWER)
725 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
727 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
731 (define_insn "extendqihi2_ppc"
732 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
733 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
736 [(set_attr "type" "exts")])
739 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
740 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
742 (clobber (match_scratch:HI 2 "=r,r"))]
747 [(set_attr "type" "compare")
748 (set_attr "length" "4,8")])
751 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
752 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
754 (clobber (match_scratch:HI 2 ""))]
755 "TARGET_POWERPC && reload_completed"
757 (sign_extend:HI (match_dup 1)))
759 (compare:CC (match_dup 2)
764 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
765 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
767 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
768 (sign_extend:HI (match_dup 1)))]
773 [(set_attr "type" "compare")
774 (set_attr "length" "4,8")])
777 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
778 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
780 (set (match_operand:HI 0 "gpc_reg_operand" "")
781 (sign_extend:HI (match_dup 1)))]
782 "TARGET_POWERPC && reload_completed"
784 (sign_extend:HI (match_dup 1)))
786 (compare:CC (match_dup 0)
790 (define_expand "extendqihi2_power"
791 [(parallel [(set (match_dup 2)
792 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
794 (clobber (scratch:SI))])
795 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
796 (ashiftrt:SI (match_dup 2)
798 (clobber (scratch:SI))])]
801 { operands[0] = gen_lowpart (SImode, operands[0]);
802 operands[1] = gen_lowpart (SImode, operands[1]);
803 operands[2] = gen_reg_rtx (SImode); }")
805 (define_expand "extendqihi2_no_power"
807 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
809 (set (match_operand:HI 0 "gpc_reg_operand" "")
810 (ashiftrt:SI (match_dup 2)
812 "! TARGET_POWER && ! TARGET_POWERPC"
814 { operands[0] = gen_lowpart (SImode, operands[0]);
815 operands[1] = gen_lowpart (SImode, operands[1]);
816 operands[2] = gen_reg_rtx (SImode); }")
818 (define_expand "zero_extendhisi2"
819 [(set (match_operand:SI 0 "gpc_reg_operand" "")
820 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
825 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
826 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
830 {rlinm|rlwinm} %0,%1,0,0xffff"
831 [(set_attr "type" "load,*")])
834 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
835 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
837 (clobber (match_scratch:SI 2 "=r,r"))]
840 {andil.|andi.} %2,%1,0xffff
842 [(set_attr "type" "compare")
843 (set_attr "length" "4,8")])
846 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
847 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
849 (clobber (match_scratch:SI 2 ""))]
852 (zero_extend:SI (match_dup 1)))
854 (compare:CC (match_dup 2)
859 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
860 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
862 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
863 (zero_extend:SI (match_dup 1)))]
866 {andil.|andi.} %0,%1,0xffff
868 [(set_attr "type" "compare")
869 (set_attr "length" "4,8")])
872 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
873 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
875 (set (match_operand:SI 0 "gpc_reg_operand" "")
876 (zero_extend:SI (match_dup 1)))]
879 (zero_extend:SI (match_dup 1)))
881 (compare:CC (match_dup 0)
885 (define_expand "extendhisi2"
886 [(set (match_operand:SI 0 "gpc_reg_operand" "")
887 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
892 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
893 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
898 [(set_attr "type" "load_ext,exts")])
901 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
902 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
904 (clobber (match_scratch:SI 2 "=r,r"))]
909 [(set_attr "type" "compare")
910 (set_attr "length" "4,8")])
913 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
914 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
916 (clobber (match_scratch:SI 2 ""))]
919 (sign_extend:SI (match_dup 1)))
921 (compare:CC (match_dup 2)
926 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
927 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
929 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
930 (sign_extend:SI (match_dup 1)))]
935 [(set_attr "type" "compare")
936 (set_attr "length" "4,8")])
938 ;; IBM 405 and 440 half-word multiplication operations.
940 (define_insn "*macchwc"
941 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
942 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
943 (match_operand:SI 2 "gpc_reg_operand" "r")
946 (match_operand:HI 1 "gpc_reg_operand" "r")))
947 (match_operand:SI 4 "gpc_reg_operand" "0"))
949 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
950 (plus:SI (mult:SI (ashiftrt:SI
958 [(set_attr "type" "imul3")])
960 (define_insn "*macchw"
961 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
962 (plus:SI (mult:SI (ashiftrt:SI
963 (match_operand:SI 2 "gpc_reg_operand" "r")
966 (match_operand:HI 1 "gpc_reg_operand" "r")))
967 (match_operand:SI 3 "gpc_reg_operand" "0")))]
970 [(set_attr "type" "imul3")])
972 (define_insn "*macchwuc"
973 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
974 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
975 (match_operand:SI 2 "gpc_reg_operand" "r")
978 (match_operand:HI 1 "gpc_reg_operand" "r")))
979 (match_operand:SI 4 "gpc_reg_operand" "0"))
981 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
982 (plus:SI (mult:SI (lshiftrt:SI
989 "macchwu. %0, %1, %2"
990 [(set_attr "type" "imul3")])
992 (define_insn "*macchwu"
993 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
994 (plus:SI (mult:SI (lshiftrt:SI
995 (match_operand:SI 2 "gpc_reg_operand" "r")
998 (match_operand:HI 1 "gpc_reg_operand" "r")))
999 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1001 "macchwu %0, %1, %2"
1002 [(set_attr "type" "imul3")])
1004 (define_insn "*machhwc"
1005 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1006 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
1007 (match_operand:SI 1 "gpc_reg_operand" "%r")
1010 (match_operand:SI 2 "gpc_reg_operand" "r")
1012 (match_operand:SI 4 "gpc_reg_operand" "0"))
1014 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1015 (plus:SI (mult:SI (ashiftrt:SI
1023 "machhw. %0, %1, %2"
1024 [(set_attr "type" "imul3")])
1026 (define_insn "*machhw"
1027 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1028 (plus:SI (mult:SI (ashiftrt:SI
1029 (match_operand:SI 1 "gpc_reg_operand" "%r")
1032 (match_operand:SI 2 "gpc_reg_operand" "r")
1034 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1037 [(set_attr "type" "imul3")])
1039 (define_insn "*machhwuc"
1040 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1041 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
1042 (match_operand:SI 1 "gpc_reg_operand" "%r")
1045 (match_operand:SI 2 "gpc_reg_operand" "r")
1047 (match_operand:SI 4 "gpc_reg_operand" "0"))
1049 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1050 (plus:SI (mult:SI (lshiftrt:SI
1058 "machhwu. %0, %1, %2"
1059 [(set_attr "type" "imul3")])
1061 (define_insn "*machhwu"
1062 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1063 (plus:SI (mult:SI (lshiftrt:SI
1064 (match_operand:SI 1 "gpc_reg_operand" "%r")
1067 (match_operand:SI 2 "gpc_reg_operand" "r")
1069 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1071 "machhwu %0, %1, %2"
1072 [(set_attr "type" "imul3")])
1074 (define_insn "*maclhwc"
1075 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1076 (compare:CC (plus:SI (mult:SI (sign_extend:SI
1077 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1079 (match_operand:HI 2 "gpc_reg_operand" "r")))
1080 (match_operand:SI 4 "gpc_reg_operand" "0"))
1082 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1083 (plus:SI (mult:SI (sign_extend:SI
1089 "maclhw. %0, %1, %2"
1090 [(set_attr "type" "imul3")])
1092 (define_insn "*maclhw"
1093 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1094 (plus:SI (mult:SI (sign_extend:SI
1095 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1097 (match_operand:HI 2 "gpc_reg_operand" "r")))
1098 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1101 [(set_attr "type" "imul3")])
1103 (define_insn "*maclhwuc"
1104 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1105 (compare:CC (plus:SI (mult:SI (zero_extend:SI
1106 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1108 (match_operand:HI 2 "gpc_reg_operand" "r")))
1109 (match_operand:SI 4 "gpc_reg_operand" "0"))
1111 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1112 (plus:SI (mult:SI (zero_extend:SI
1118 "maclhwu. %0, %1, %2"
1119 [(set_attr "type" "imul3")])
1121 (define_insn "*maclhwu"
1122 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1123 (plus:SI (mult:SI (zero_extend:SI
1124 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1126 (match_operand:HI 2 "gpc_reg_operand" "r")))
1127 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1129 "maclhwu %0, %1, %2"
1130 [(set_attr "type" "imul3")])
1132 (define_insn "*nmacchwc"
1133 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1134 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1135 (mult:SI (ashiftrt:SI
1136 (match_operand:SI 2 "gpc_reg_operand" "r")
1139 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1141 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1142 (minus:SI (match_dup 4)
1143 (mult:SI (ashiftrt:SI
1149 "nmacchw. %0, %1, %2"
1150 [(set_attr "type" "imul3")])
1152 (define_insn "*nmacchw"
1153 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1154 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1155 (mult:SI (ashiftrt:SI
1156 (match_operand:SI 2 "gpc_reg_operand" "r")
1159 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1161 "nmacchw %0, %1, %2"
1162 [(set_attr "type" "imul3")])
1164 (define_insn "*nmachhwc"
1165 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1166 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1167 (mult:SI (ashiftrt:SI
1168 (match_operand:SI 1 "gpc_reg_operand" "%r")
1171 (match_operand:SI 2 "gpc_reg_operand" "r")
1174 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1175 (minus:SI (match_dup 4)
1176 (mult:SI (ashiftrt:SI
1183 "nmachhw. %0, %1, %2"
1184 [(set_attr "type" "imul3")])
1186 (define_insn "*nmachhw"
1187 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1188 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1189 (mult:SI (ashiftrt:SI
1190 (match_operand:SI 1 "gpc_reg_operand" "%r")
1193 (match_operand:SI 2 "gpc_reg_operand" "r")
1196 "nmachhw %0, %1, %2"
1197 [(set_attr "type" "imul3")])
1199 (define_insn "*nmaclhwc"
1200 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1201 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1202 (mult:SI (sign_extend:SI
1203 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1205 (match_operand:HI 2 "gpc_reg_operand" "r"))))
1207 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1208 (minus:SI (match_dup 4)
1209 (mult:SI (sign_extend:SI
1214 "nmaclhw. %0, %1, %2"
1215 [(set_attr "type" "imul3")])
1217 (define_insn "*nmaclhw"
1218 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1219 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1220 (mult:SI (sign_extend:SI
1221 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1223 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1225 "nmaclhw %0, %1, %2"
1226 [(set_attr "type" "imul3")])
1228 (define_insn "*mulchwc"
1229 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1230 (compare:CC (mult:SI (ashiftrt:SI
1231 (match_operand:SI 2 "gpc_reg_operand" "r")
1234 (match_operand:HI 1 "gpc_reg_operand" "r")))
1236 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1237 (mult:SI (ashiftrt:SI
1243 "mulchw. %0, %1, %2"
1244 [(set_attr "type" "imul3")])
1246 (define_insn "*mulchw"
1247 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1248 (mult:SI (ashiftrt:SI
1249 (match_operand:SI 2 "gpc_reg_operand" "r")
1252 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1255 [(set_attr "type" "imul3")])
1257 (define_insn "*mulchwuc"
1258 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1259 (compare:CC (mult:SI (lshiftrt:SI
1260 (match_operand:SI 2 "gpc_reg_operand" "r")
1263 (match_operand:HI 1 "gpc_reg_operand" "r")))
1265 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1266 (mult:SI (lshiftrt:SI
1272 "mulchwu. %0, %1, %2"
1273 [(set_attr "type" "imul3")])
1275 (define_insn "*mulchwu"
1276 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1277 (mult:SI (lshiftrt:SI
1278 (match_operand:SI 2 "gpc_reg_operand" "r")
1281 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1283 "mulchwu %0, %1, %2"
1284 [(set_attr "type" "imul3")])
1286 (define_insn "*mulhhwc"
1287 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1288 (compare:CC (mult:SI (ashiftrt:SI
1289 (match_operand:SI 1 "gpc_reg_operand" "%r")
1292 (match_operand:SI 2 "gpc_reg_operand" "r")
1295 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1296 (mult:SI (ashiftrt:SI
1303 "mulhhw. %0, %1, %2"
1304 [(set_attr "type" "imul3")])
1306 (define_insn "*mulhhw"
1307 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1308 (mult:SI (ashiftrt:SI
1309 (match_operand:SI 1 "gpc_reg_operand" "%r")
1312 (match_operand:SI 2 "gpc_reg_operand" "r")
1316 [(set_attr "type" "imul3")])
1318 (define_insn "*mulhhwuc"
1319 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1320 (compare:CC (mult:SI (lshiftrt:SI
1321 (match_operand:SI 1 "gpc_reg_operand" "%r")
1324 (match_operand:SI 2 "gpc_reg_operand" "r")
1327 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1328 (mult:SI (lshiftrt:SI
1335 "mulhhwu. %0, %1, %2"
1336 [(set_attr "type" "imul3")])
1338 (define_insn "*mulhhwu"
1339 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1340 (mult:SI (lshiftrt:SI
1341 (match_operand:SI 1 "gpc_reg_operand" "%r")
1344 (match_operand:SI 2 "gpc_reg_operand" "r")
1347 "mulhhwu %0, %1, %2"
1348 [(set_attr "type" "imul3")])
1350 (define_insn "*mullhwc"
1351 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1352 (compare:CC (mult:SI (sign_extend:SI
1353 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1355 (match_operand:HI 2 "gpc_reg_operand" "r")))
1357 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1358 (mult:SI (sign_extend:SI
1363 "mullhw. %0, %1, %2"
1364 [(set_attr "type" "imul3")])
1366 (define_insn "*mullhw"
1367 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1368 (mult:SI (sign_extend:SI
1369 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1371 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1374 [(set_attr "type" "imul3")])
1376 (define_insn "*mullhwuc"
1377 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1378 (compare:CC (mult:SI (zero_extend:SI
1379 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1381 (match_operand:HI 2 "gpc_reg_operand" "r")))
1383 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1384 (mult:SI (zero_extend:SI
1389 "mullhwu. %0, %1, %2"
1390 [(set_attr "type" "imul3")])
1392 (define_insn "*mullhwu"
1393 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1394 (mult:SI (zero_extend:SI
1395 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1397 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1399 "mullhwu %0, %1, %2"
1400 [(set_attr "type" "imul3")])
1402 ;; IBM 405 and 440 string-search dlmzb instruction support.
1403 (define_insn "dlmzb"
1404 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1405 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1406 (match_operand:SI 2 "gpc_reg_operand" "r")]
1408 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1409 (unspec:SI [(match_dup 1)
1413 "dlmzb. %0, %1, %2")
1415 (define_expand "strlensi"
1416 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1417 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1418 (match_operand:QI 2 "const_int_operand" "")
1419 (match_operand 3 "const_int_operand" "")]
1420 UNSPEC_DLMZB_STRLEN))
1421 (clobber (match_scratch:CC 4 "=x"))]
1422 "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1424 rtx result = operands[0];
1425 rtx src = operands[1];
1426 rtx search_char = operands[2];
1427 rtx align = operands[3];
1428 rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1429 rtx loop_label, end_label, mem, cr0, cond;
1430 if (search_char != const0_rtx
1431 || GET_CODE (align) != CONST_INT
1432 || INTVAL (align) < 8)
1434 word1 = gen_reg_rtx (SImode);
1435 word2 = gen_reg_rtx (SImode);
1436 scratch_dlmzb = gen_reg_rtx (SImode);
1437 scratch_string = gen_reg_rtx (Pmode);
1438 loop_label = gen_label_rtx ();
1439 end_label = gen_label_rtx ();
1440 addr = force_reg (Pmode, XEXP (src, 0));
1441 emit_move_insn (scratch_string, addr);
1442 emit_label (loop_label);
1443 mem = change_address (src, SImode, scratch_string);
1444 emit_move_insn (word1, mem);
1445 emit_move_insn (word2, adjust_address (mem, SImode, 4));
1446 cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1447 emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1448 cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1449 emit_jump_insn (gen_rtx_SET (VOIDmode,
1451 gen_rtx_IF_THEN_ELSE (VOIDmode,
1457 emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1458 emit_jump_insn (gen_rtx_SET (VOIDmode,
1460 gen_rtx_LABEL_REF (VOIDmode, loop_label)));
1462 emit_label (end_label);
1463 emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1464 emit_insn (gen_subsi3 (result, scratch_string, addr));
1465 emit_insn (gen_subsi3 (result, result, const1_rtx));
1470 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1471 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1473 (set (match_operand:SI 0 "gpc_reg_operand" "")
1474 (sign_extend:SI (match_dup 1)))]
1477 (sign_extend:SI (match_dup 1)))
1479 (compare:CC (match_dup 0)
1483 ;; Fixed-point arithmetic insns.
1485 (define_expand "add<mode>3"
1486 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1487 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1488 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1491 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1493 if (non_short_cint_operand (operands[2], DImode))
1496 else if (GET_CODE (operands[2]) == CONST_INT
1497 && ! add_operand (operands[2], <MODE>mode))
1499 rtx tmp = ((!can_create_pseudo_p ()
1500 || rtx_equal_p (operands[0], operands[1]))
1501 ? operands[0] : gen_reg_rtx (<MODE>mode));
1503 HOST_WIDE_INT val = INTVAL (operands[2]);
1504 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1505 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1507 if (<MODE>mode == DImode && !satisfies_constraint_L (GEN_INT (rest)))
1510 /* The ordering here is important for the prolog expander.
1511 When space is allocated from the stack, adding 'low' first may
1512 produce a temporary deallocation (which would be bad). */
1513 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1514 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1519 ;; Discourage ai/addic because of carry but provide it in an alternative
1520 ;; allowing register zero as source.
1521 (define_insn "*add<mode>3_internal1"
1522 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1523 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1524 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
1525 "!DECIMAL_FLOAT_MODE_P (GET_MODE (operands[0])) && !DECIMAL_FLOAT_MODE_P (GET_MODE (operands[1]))"
1528 {cal %0,%2(%1)|addi %0,%1,%2}
1530 {cau|addis} %0,%1,%v2"
1531 [(set_attr "length" "4,4,4,4")])
1533 (define_insn "addsi3_high"
1534 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1535 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1536 (high:SI (match_operand 2 "" ""))))]
1537 "TARGET_MACHO && !TARGET_64BIT"
1538 "{cau|addis} %0,%1,ha16(%2)"
1539 [(set_attr "length" "4")])
1541 (define_insn "*add<mode>3_internal2"
1542 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1543 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1544 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1546 (clobber (match_scratch:P 3 "=r,r,r,r"))]
1549 {cax.|add.} %3,%1,%2
1550 {ai.|addic.} %3,%1,%2
1553 [(set_attr "type" "fast_compare,compare,compare,compare")
1554 (set_attr "length" "4,4,8,8")])
1557 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1558 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1559 (match_operand:GPR 2 "reg_or_short_operand" ""))
1561 (clobber (match_scratch:GPR 3 ""))]
1564 (plus:GPR (match_dup 1)
1567 (compare:CC (match_dup 3)
1571 (define_insn "*add<mode>3_internal3"
1572 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1573 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1574 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1576 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1577 (plus:P (match_dup 1)
1581 {cax.|add.} %0,%1,%2
1582 {ai.|addic.} %0,%1,%2
1585 [(set_attr "type" "fast_compare,compare,compare,compare")
1586 (set_attr "length" "4,4,8,8")])
1589 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1590 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1591 (match_operand:P 2 "reg_or_short_operand" ""))
1593 (set (match_operand:P 0 "gpc_reg_operand" "")
1594 (plus:P (match_dup 1) (match_dup 2)))]
1597 (plus:P (match_dup 1)
1600 (compare:CC (match_dup 0)
1604 ;; Split an add that we can't do in one insn into two insns, each of which
1605 ;; does one 16-bit part. This is used by combine. Note that the low-order
1606 ;; add should be last in case the result gets used in an address.
1609 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1610 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1611 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1613 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1614 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1616 HOST_WIDE_INT val = INTVAL (operands[2]);
1617 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1618 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1620 operands[4] = GEN_INT (low);
1621 if (<MODE>mode == SImode || satisfies_constraint_L (GEN_INT (rest)))
1622 operands[3] = GEN_INT (rest);
1623 else if (can_create_pseudo_p ())
1625 operands[3] = gen_reg_rtx (DImode);
1626 emit_move_insn (operands[3], operands[2]);
1627 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1634 (define_insn "one_cmpl<mode>2"
1635 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1636 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1641 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1642 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1644 (clobber (match_scratch:P 2 "=r,r"))]
1649 [(set_attr "type" "compare")
1650 (set_attr "length" "4,8")])
1653 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1654 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1656 (clobber (match_scratch:P 2 ""))]
1659 (not:P (match_dup 1)))
1661 (compare:CC (match_dup 2)
1666 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1667 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1669 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1670 (not:P (match_dup 1)))]
1675 [(set_attr "type" "compare")
1676 (set_attr "length" "4,8")])
1679 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1680 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1682 (set (match_operand:P 0 "gpc_reg_operand" "")
1683 (not:P (match_dup 1)))]
1686 (not:P (match_dup 1)))
1688 (compare:CC (match_dup 0)
1693 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1694 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1695 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1697 "{sf%I1|subf%I1c} %0,%2,%1")
1700 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1701 (minus:GPR (match_operand:GPR 1 "reg_or_short_operand" "r,I")
1702 (match_operand:GPR 2 "gpc_reg_operand" "r,r")))]
1709 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1710 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1711 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1713 (clobber (match_scratch:SI 3 "=r,r"))]
1716 {sf.|subfc.} %3,%2,%1
1718 [(set_attr "type" "compare")
1719 (set_attr "length" "4,8")])
1722 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1723 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1724 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1726 (clobber (match_scratch:P 3 "=r,r"))]
1731 [(set_attr "type" "fast_compare")
1732 (set_attr "length" "4,8")])
1735 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1736 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1737 (match_operand:P 2 "gpc_reg_operand" ""))
1739 (clobber (match_scratch:P 3 ""))]
1742 (minus:P (match_dup 1)
1745 (compare:CC (match_dup 3)
1750 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1751 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1752 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1754 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1755 (minus:SI (match_dup 1) (match_dup 2)))]
1758 {sf.|subfc.} %0,%2,%1
1760 [(set_attr "type" "compare")
1761 (set_attr "length" "4,8")])
1764 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1765 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1766 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1768 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1769 (minus:P (match_dup 1)
1775 [(set_attr "type" "fast_compare")
1776 (set_attr "length" "4,8")])
1779 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1780 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1781 (match_operand:P 2 "gpc_reg_operand" ""))
1783 (set (match_operand:P 0 "gpc_reg_operand" "")
1784 (minus:P (match_dup 1)
1788 (minus:P (match_dup 1)
1791 (compare:CC (match_dup 0)
1795 (define_expand "sub<mode>3"
1796 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1797 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1798 (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
1802 if (GET_CODE (operands[2]) == CONST_INT)
1804 emit_insn (gen_add<mode>3 (operands[0], operands[1],
1805 negate_rtx (<MODE>mode, operands[2])));
1810 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1811 ;; instruction and some auxiliary computations. Then we just have a single
1812 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1815 (define_expand "sminsi3"
1817 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1818 (match_operand:SI 2 "reg_or_short_operand" ""))
1820 (minus:SI (match_dup 2) (match_dup 1))))
1821 (set (match_operand:SI 0 "gpc_reg_operand" "")
1822 (minus:SI (match_dup 2) (match_dup 3)))]
1823 "TARGET_POWER || TARGET_ISEL"
1828 operands[2] = force_reg (SImode, operands[2]);
1829 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1833 operands[3] = gen_reg_rtx (SImode);
1837 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1838 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1839 (match_operand:SI 2 "reg_or_short_operand" "")))
1840 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1843 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1845 (minus:SI (match_dup 2) (match_dup 1))))
1846 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1849 (define_expand "smaxsi3"
1851 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1852 (match_operand:SI 2 "reg_or_short_operand" ""))
1854 (minus:SI (match_dup 2) (match_dup 1))))
1855 (set (match_operand:SI 0 "gpc_reg_operand" "")
1856 (plus:SI (match_dup 3) (match_dup 1)))]
1857 "TARGET_POWER || TARGET_ISEL"
1862 operands[2] = force_reg (SImode, operands[2]);
1863 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1866 operands[3] = gen_reg_rtx (SImode);
1870 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1871 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1872 (match_operand:SI 2 "reg_or_short_operand" "")))
1873 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1876 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1878 (minus:SI (match_dup 2) (match_dup 1))))
1879 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1882 (define_expand "uminsi3"
1883 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1885 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1887 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1889 (minus:SI (match_dup 4) (match_dup 3))))
1890 (set (match_operand:SI 0 "gpc_reg_operand" "")
1891 (minus:SI (match_dup 2) (match_dup 3)))]
1892 "TARGET_POWER || TARGET_ISEL"
1897 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1900 operands[3] = gen_reg_rtx (SImode);
1901 operands[4] = gen_reg_rtx (SImode);
1902 operands[5] = GEN_INT (-2147483647 - 1);
1905 (define_expand "umaxsi3"
1906 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1908 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1910 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1912 (minus:SI (match_dup 4) (match_dup 3))))
1913 (set (match_operand:SI 0 "gpc_reg_operand" "")
1914 (plus:SI (match_dup 3) (match_dup 1)))]
1915 "TARGET_POWER || TARGET_ISEL"
1920 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1923 operands[3] = gen_reg_rtx (SImode);
1924 operands[4] = gen_reg_rtx (SImode);
1925 operands[5] = GEN_INT (-2147483647 - 1);
1929 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1930 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1931 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1933 (minus:SI (match_dup 2) (match_dup 1))))]
1938 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1940 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1941 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1943 (minus:SI (match_dup 2) (match_dup 1)))
1945 (clobber (match_scratch:SI 3 "=r,r"))]
1950 [(set_attr "type" "delayed_compare")
1951 (set_attr "length" "4,8")])
1954 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1956 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1957 (match_operand:SI 2 "reg_or_short_operand" ""))
1959 (minus:SI (match_dup 2) (match_dup 1)))
1961 (clobber (match_scratch:SI 3 ""))]
1962 "TARGET_POWER && reload_completed"
1964 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1966 (minus:SI (match_dup 2) (match_dup 1))))
1968 (compare:CC (match_dup 3)
1973 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1975 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1976 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1978 (minus:SI (match_dup 2) (match_dup 1)))
1980 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1981 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1983 (minus:SI (match_dup 2) (match_dup 1))))]
1988 [(set_attr "type" "delayed_compare")
1989 (set_attr "length" "4,8")])
1992 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1994 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1995 (match_operand:SI 2 "reg_or_short_operand" ""))
1997 (minus:SI (match_dup 2) (match_dup 1)))
1999 (set (match_operand:SI 0 "gpc_reg_operand" "")
2000 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2002 (minus:SI (match_dup 2) (match_dup 1))))]
2003 "TARGET_POWER && reload_completed"
2005 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2007 (minus:SI (match_dup 2) (match_dup 1))))
2009 (compare:CC (match_dup 0)
2013 ;; We don't need abs with condition code because such comparisons should
2015 (define_expand "abssi2"
2016 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2017 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2023 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
2026 else if (! TARGET_POWER)
2028 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
2033 (define_insn "*abssi2_power"
2034 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2035 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2039 (define_insn_and_split "abssi2_isel"
2040 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2041 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
2042 (clobber (match_scratch:SI 2 "=&b"))
2043 (clobber (match_scratch:CC 3 "=y"))]
2046 "&& reload_completed"
2047 [(set (match_dup 2) (neg:SI (match_dup 1)))
2049 (compare:CC (match_dup 1)
2052 (if_then_else:SI (ge (match_dup 3)
2058 (define_insn_and_split "abssi2_nopower"
2059 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2060 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
2061 (clobber (match_scratch:SI 2 "=&r,&r"))]
2062 "! TARGET_POWER && ! TARGET_ISEL"
2064 "&& reload_completed"
2065 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2066 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2067 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
2070 (define_insn "*nabs_power"
2071 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2072 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
2076 (define_insn_and_split "*nabs_nopower"
2077 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2078 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
2079 (clobber (match_scratch:SI 2 "=&r,&r"))]
2082 "&& reload_completed"
2083 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2084 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2085 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
2088 (define_expand "neg<mode>2"
2089 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2090 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
2094 (define_insn "*neg<mode>2_internal"
2095 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2096 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2101 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2102 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2104 (clobber (match_scratch:P 2 "=r,r"))]
2109 [(set_attr "type" "fast_compare")
2110 (set_attr "length" "4,8")])
2113 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2114 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2116 (clobber (match_scratch:P 2 ""))]
2119 (neg:P (match_dup 1)))
2121 (compare:CC (match_dup 2)
2126 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2127 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2129 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2130 (neg:P (match_dup 1)))]
2135 [(set_attr "type" "fast_compare")
2136 (set_attr "length" "4,8")])
2139 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2140 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2142 (set (match_operand:P 0 "gpc_reg_operand" "")
2143 (neg:P (match_dup 1)))]
2146 (neg:P (match_dup 1)))
2148 (compare:CC (match_dup 0)
2152 (define_insn "clz<mode>2"
2153 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2154 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2156 "{cntlz|cntlz<wd>} %0,%1"
2157 [(set_attr "type" "cntlz")])
2159 (define_expand "ctz<mode>2"
2161 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
2162 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2164 (clobber (scratch:CC))])
2165 (set (match_dup 4) (clz:GPR (match_dup 3)))
2166 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2167 (minus:GPR (match_dup 5) (match_dup 4)))]
2170 operands[2] = gen_reg_rtx (<MODE>mode);
2171 operands[3] = gen_reg_rtx (<MODE>mode);
2172 operands[4] = gen_reg_rtx (<MODE>mode);
2173 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
2176 (define_expand "ffs<mode>2"
2178 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
2179 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2181 (clobber (scratch:CC))])
2182 (set (match_dup 4) (clz:GPR (match_dup 3)))
2183 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2184 (minus:GPR (match_dup 5) (match_dup 4)))]
2187 operands[2] = gen_reg_rtx (<MODE>mode);
2188 operands[3] = gen_reg_rtx (<MODE>mode);
2189 operands[4] = gen_reg_rtx (<MODE>mode);
2190 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
2193 (define_insn "popcntb<mode>2"
2194 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2195 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2200 (define_expand "popcount<mode>2"
2201 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2202 (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
2205 rs6000_emit_popcount (operands[0], operands[1]);
2209 (define_expand "parity<mode>2"
2210 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2211 (parity:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
2214 rs6000_emit_parity (operands[0], operands[1]);
2218 (define_insn "bswapsi2"
2219 [(set (match_operand:SI 0 "reg_or_mem_operand" "=r,Z,&r")
2220 (bswap:SI (match_operand:SI 1 "reg_or_mem_operand" "Z,r,r")))]
2224 {stbrx|stwbrx} %1,%y0
2226 [(set_attr "length" "4,4,12")])
2229 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2230 (bswap:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2233 (rotate:SI (match_dup 1) (const_int 8)))
2234 (set (zero_extract:SI (match_dup 0)
2238 (set (zero_extract:SI (match_dup 0)
2241 (rotate:SI (match_dup 1)
2245 (define_expand "mulsi3"
2246 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2247 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2248 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2253 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2255 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2259 (define_insn "mulsi3_mq"
2260 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2261 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2262 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2263 (clobber (match_scratch:SI 3 "=q,q"))]
2266 {muls|mullw} %0,%1,%2
2267 {muli|mulli} %0,%1,%2"
2269 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2270 (const_string "imul3")
2271 (match_operand:SI 2 "short_cint_operand" "")
2272 (const_string "imul2")]
2273 (const_string "imul")))])
2275 (define_insn "mulsi3_no_mq"
2276 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2277 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2278 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2281 {muls|mullw} %0,%1,%2
2282 {muli|mulli} %0,%1,%2"
2284 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2285 (const_string "imul3")
2286 (match_operand:SI 2 "short_cint_operand" "")
2287 (const_string "imul2")]
2288 (const_string "imul")))])
2290 (define_insn "*mulsi3_mq_internal1"
2291 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2292 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2293 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2295 (clobber (match_scratch:SI 3 "=r,r"))
2296 (clobber (match_scratch:SI 4 "=q,q"))]
2299 {muls.|mullw.} %3,%1,%2
2301 [(set_attr "type" "imul_compare")
2302 (set_attr "length" "4,8")])
2305 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2306 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2307 (match_operand:SI 2 "gpc_reg_operand" ""))
2309 (clobber (match_scratch:SI 3 ""))
2310 (clobber (match_scratch:SI 4 ""))]
2311 "TARGET_POWER && reload_completed"
2312 [(parallel [(set (match_dup 3)
2313 (mult:SI (match_dup 1) (match_dup 2)))
2314 (clobber (match_dup 4))])
2316 (compare:CC (match_dup 3)
2320 (define_insn "*mulsi3_no_mq_internal1"
2321 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2322 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2323 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2325 (clobber (match_scratch:SI 3 "=r,r"))]
2328 {muls.|mullw.} %3,%1,%2
2330 [(set_attr "type" "imul_compare")
2331 (set_attr "length" "4,8")])
2334 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2335 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2336 (match_operand:SI 2 "gpc_reg_operand" ""))
2338 (clobber (match_scratch:SI 3 ""))]
2339 "! TARGET_POWER && reload_completed"
2341 (mult:SI (match_dup 1) (match_dup 2)))
2343 (compare:CC (match_dup 3)
2347 (define_insn "*mulsi3_mq_internal2"
2348 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2349 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2350 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2352 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2353 (mult:SI (match_dup 1) (match_dup 2)))
2354 (clobber (match_scratch:SI 4 "=q,q"))]
2357 {muls.|mullw.} %0,%1,%2
2359 [(set_attr "type" "imul_compare")
2360 (set_attr "length" "4,8")])
2363 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2364 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2365 (match_operand:SI 2 "gpc_reg_operand" ""))
2367 (set (match_operand:SI 0 "gpc_reg_operand" "")
2368 (mult:SI (match_dup 1) (match_dup 2)))
2369 (clobber (match_scratch:SI 4 ""))]
2370 "TARGET_POWER && reload_completed"
2371 [(parallel [(set (match_dup 0)
2372 (mult:SI (match_dup 1) (match_dup 2)))
2373 (clobber (match_dup 4))])
2375 (compare:CC (match_dup 0)
2379 (define_insn "*mulsi3_no_mq_internal2"
2380 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2381 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2382 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2384 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2385 (mult:SI (match_dup 1) (match_dup 2)))]
2388 {muls.|mullw.} %0,%1,%2
2390 [(set_attr "type" "imul_compare")
2391 (set_attr "length" "4,8")])
2394 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2395 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2396 (match_operand:SI 2 "gpc_reg_operand" ""))
2398 (set (match_operand:SI 0 "gpc_reg_operand" "")
2399 (mult:SI (match_dup 1) (match_dup 2)))]
2400 "! TARGET_POWER && reload_completed"
2402 (mult:SI (match_dup 1) (match_dup 2)))
2404 (compare:CC (match_dup 0)
2408 ;; Operand 1 is divided by operand 2; quotient goes to operand
2409 ;; 0 and remainder to operand 3.
2410 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2412 (define_expand "divmodsi4"
2413 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2414 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2415 (match_operand:SI 2 "gpc_reg_operand" "")))
2416 (set (match_operand:SI 3 "register_operand" "")
2417 (mod:SI (match_dup 1) (match_dup 2)))])]
2418 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2421 if (! TARGET_POWER && ! TARGET_POWERPC)
2423 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2424 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2425 emit_insn (gen_divss_call ());
2426 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2427 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2432 (define_insn "*divmodsi4_internal"
2433 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2434 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2435 (match_operand:SI 2 "gpc_reg_operand" "r")))
2436 (set (match_operand:SI 3 "register_operand" "=q")
2437 (mod:SI (match_dup 1) (match_dup 2)))]
2440 [(set_attr "type" "idiv")])
2442 (define_expand "udiv<mode>3"
2443 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2444 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2445 (match_operand:GPR 2 "gpc_reg_operand" "")))]
2446 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2449 if (! TARGET_POWER && ! TARGET_POWERPC)
2451 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2452 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2453 emit_insn (gen_quous_call ());
2454 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2457 else if (TARGET_POWER)
2459 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2464 (define_insn "udivsi3_mq"
2465 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2466 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2467 (match_operand:SI 2 "gpc_reg_operand" "r")))
2468 (clobber (match_scratch:SI 3 "=q"))]
2469 "TARGET_POWERPC && TARGET_POWER"
2471 [(set_attr "type" "idiv")])
2473 (define_insn "*udivsi3_no_mq"
2474 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2475 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2476 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2477 "TARGET_POWERPC && ! TARGET_POWER"
2480 (cond [(match_operand:SI 0 "" "")
2481 (const_string "idiv")]
2482 (const_string "ldiv")))])
2485 ;; For powers of two we can do srai/aze for divide and then adjust for
2486 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2487 ;; used; for PowerPC, force operands into register and do a normal divide;
2488 ;; for AIX common-mode, use quoss call on register operands.
2489 (define_expand "div<mode>3"
2490 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2491 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2492 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2496 if (GET_CODE (operands[2]) == CONST_INT
2497 && INTVAL (operands[2]) > 0
2498 && exact_log2 (INTVAL (operands[2])) >= 0)
2500 else if (TARGET_POWERPC)
2502 operands[2] = force_reg (<MODE>mode, operands[2]);
2505 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2509 else if (TARGET_POWER)
2513 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2514 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2515 emit_insn (gen_quoss_call ());
2516 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2521 (define_insn "divsi3_mq"
2522 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2523 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2524 (match_operand:SI 2 "gpc_reg_operand" "r")))
2525 (clobber (match_scratch:SI 3 "=q"))]
2526 "TARGET_POWERPC && TARGET_POWER"
2528 [(set_attr "type" "idiv")])
2530 (define_insn "*div<mode>3_no_mq"
2531 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2532 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2533 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2534 "TARGET_POWERPC && ! TARGET_POWER"
2537 (cond [(match_operand:SI 0 "" "")
2538 (const_string "idiv")]
2539 (const_string "ldiv")))])
2541 (define_expand "mod<mode>3"
2542 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2543 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2544 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
2552 if (GET_CODE (operands[2]) != CONST_INT
2553 || INTVAL (operands[2]) <= 0
2554 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2557 temp1 = gen_reg_rtx (<MODE>mode);
2558 temp2 = gen_reg_rtx (<MODE>mode);
2560 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2561 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2562 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
2567 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2568 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2569 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
2571 "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
2572 [(set_attr "type" "two")
2573 (set_attr "length" "8")])
2576 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2577 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2578 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2580 (clobber (match_scratch:P 3 "=r,r"))]
2583 {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
2585 [(set_attr "type" "compare")
2586 (set_attr "length" "8,12")])
2589 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2590 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2591 (match_operand:GPR 2 "exact_log2_cint_operand"
2594 (clobber (match_scratch:GPR 3 ""))]
2597 (div:<MODE> (match_dup 1) (match_dup 2)))
2599 (compare:CC (match_dup 3)
2604 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2605 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2606 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2608 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2609 (div:P (match_dup 1) (match_dup 2)))]
2612 {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
2614 [(set_attr "type" "compare")
2615 (set_attr "length" "8,12")])
2618 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2619 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2620 (match_operand:GPR 2 "exact_log2_cint_operand"
2623 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2624 (div:GPR (match_dup 1) (match_dup 2)))]
2627 (div:<MODE> (match_dup 1) (match_dup 2)))
2629 (compare:CC (match_dup 0)
2634 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2637 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2639 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2640 (match_operand:SI 3 "gpc_reg_operand" "r")))
2641 (set (match_operand:SI 2 "register_operand" "=*q")
2644 (zero_extend:DI (match_dup 1)) (const_int 32))
2645 (zero_extend:DI (match_dup 4)))
2649 [(set_attr "type" "idiv")])
2651 ;; To do unsigned divide we handle the cases of the divisor looking like a
2652 ;; negative number. If it is a constant that is less than 2**31, we don't
2653 ;; have to worry about the branches. So make a few subroutines here.
2655 ;; First comes the normal case.
2656 (define_expand "udivmodsi4_normal"
2657 [(set (match_dup 4) (const_int 0))
2658 (parallel [(set (match_operand:SI 0 "" "")
2659 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2661 (zero_extend:DI (match_operand:SI 1 "" "")))
2662 (match_operand:SI 2 "" "")))
2663 (set (match_operand:SI 3 "" "")
2664 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2666 (zero_extend:DI (match_dup 1)))
2670 { operands[4] = gen_reg_rtx (SImode); }")
2672 ;; This handles the branches.
2673 (define_expand "udivmodsi4_tests"
2674 [(set (match_operand:SI 0 "" "") (const_int 0))
2675 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2676 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2677 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2678 (label_ref (match_operand:SI 4 "" "")) (pc)))
2679 (set (match_dup 0) (const_int 1))
2680 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2681 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2682 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2683 (label_ref (match_dup 4)) (pc)))]
2686 { operands[5] = gen_reg_rtx (CCUNSmode);
2687 operands[6] = gen_reg_rtx (CCmode);
2690 (define_expand "udivmodsi4"
2691 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2692 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2693 (match_operand:SI 2 "reg_or_cint_operand" "")))
2694 (set (match_operand:SI 3 "gpc_reg_operand" "")
2695 (umod:SI (match_dup 1) (match_dup 2)))])]
2703 if (! TARGET_POWERPC)
2705 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2706 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2707 emit_insn (gen_divus_call ());
2708 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2709 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2716 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2718 operands[2] = force_reg (SImode, operands[2]);
2719 label = gen_label_rtx ();
2720 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2721 operands[3], label));
2724 operands[2] = force_reg (SImode, operands[2]);
2726 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2734 ;; AIX architecture-independent common-mode multiply (DImode),
2735 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2736 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2737 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2738 ;; assumed unused if generating common-mode, so ignore.
2739 (define_insn "mulh_call"
2742 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2743 (sign_extend:DI (reg:SI 4)))
2745 (clobber (reg:SI LR_REGNO))]
2746 "! TARGET_POWER && ! TARGET_POWERPC"
2748 [(set_attr "type" "imul")])
2750 (define_insn "mull_call"
2752 (mult:DI (sign_extend:DI (reg:SI 3))
2753 (sign_extend:DI (reg:SI 4))))
2754 (clobber (reg:SI LR_REGNO))
2755 (clobber (reg:SI 0))]
2756 "! TARGET_POWER && ! TARGET_POWERPC"
2758 [(set_attr "type" "imul")])
2760 (define_insn "divss_call"
2762 (div:SI (reg:SI 3) (reg:SI 4)))
2764 (mod:SI (reg:SI 3) (reg:SI 4)))
2765 (clobber (reg:SI LR_REGNO))
2766 (clobber (reg:SI 0))]
2767 "! TARGET_POWER && ! TARGET_POWERPC"
2769 [(set_attr "type" "idiv")])
2771 (define_insn "divus_call"
2773 (udiv:SI (reg:SI 3) (reg:SI 4)))
2775 (umod:SI (reg:SI 3) (reg:SI 4)))
2776 (clobber (reg:SI LR_REGNO))
2777 (clobber (reg:SI 0))
2778 (clobber (match_scratch:CC 0 "=x"))
2779 (clobber (reg:CC CR1_REGNO))]
2780 "! TARGET_POWER && ! TARGET_POWERPC"
2782 [(set_attr "type" "idiv")])
2784 (define_insn "quoss_call"
2786 (div:SI (reg:SI 3) (reg:SI 4)))
2787 (clobber (reg:SI LR_REGNO))]
2788 "! TARGET_POWER && ! TARGET_POWERPC"
2790 [(set_attr "type" "idiv")])
2792 (define_insn "quous_call"
2794 (udiv:SI (reg:SI 3) (reg:SI 4)))
2795 (clobber (reg:SI LR_REGNO))
2796 (clobber (reg:SI 0))
2797 (clobber (match_scratch:CC 0 "=x"))
2798 (clobber (reg:CC CR1_REGNO))]
2799 "! TARGET_POWER && ! TARGET_POWERPC"
2801 [(set_attr "type" "idiv")])
2803 ;; Logical instructions
2804 ;; The logical instructions are mostly combined by using match_operator,
2805 ;; but the plain AND insns are somewhat different because there is no
2806 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2807 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2809 (define_insn "andsi3"
2810 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2811 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2812 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2813 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2817 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2818 {andil.|andi.} %0,%1,%b2
2819 {andiu.|andis.} %0,%1,%u2"
2820 [(set_attr "type" "*,*,compare,compare")])
2822 ;; Note to set cr's other than cr0 we do the and immediate and then
2823 ;; the test again -- this avoids a mfcr which on the higher end
2824 ;; machines causes an execution serialization
2826 (define_insn "*andsi3_internal2"
2827 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2828 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2829 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2831 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2832 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2836 {andil.|andi.} %3,%1,%b2
2837 {andiu.|andis.} %3,%1,%u2
2838 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2843 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2844 (set_attr "length" "4,4,4,4,8,8,8,8")])
2846 (define_insn "*andsi3_internal3"
2847 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2848 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2849 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2851 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2852 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2856 {andil.|andi.} %3,%1,%b2
2857 {andiu.|andis.} %3,%1,%u2
2858 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2863 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2864 (set_attr "length" "8,4,4,4,8,8,8,8")])
2867 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2868 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2869 (match_operand:GPR 2 "and_operand" ""))
2871 (clobber (match_scratch:GPR 3 ""))
2872 (clobber (match_scratch:CC 4 ""))]
2874 [(parallel [(set (match_dup 3)
2875 (and:<MODE> (match_dup 1)
2877 (clobber (match_dup 4))])
2879 (compare:CC (match_dup 3)
2883 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2884 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2887 [(set (match_operand:CC 0 "cc_reg_operand" "")
2888 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2889 (match_operand:SI 2 "gpc_reg_operand" ""))
2891 (clobber (match_scratch:SI 3 ""))
2892 (clobber (match_scratch:CC 4 ""))]
2893 "TARGET_POWERPC64 && reload_completed"
2894 [(parallel [(set (match_dup 3)
2895 (and:SI (match_dup 1)
2897 (clobber (match_dup 4))])
2899 (compare:CC (match_dup 3)
2903 (define_insn "*andsi3_internal4"
2904 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2905 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2906 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2908 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2909 (and:SI (match_dup 1)
2911 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2915 {andil.|andi.} %0,%1,%b2
2916 {andiu.|andis.} %0,%1,%u2
2917 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2922 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2923 (set_attr "length" "4,4,4,4,8,8,8,8")])
2925 (define_insn "*andsi3_internal5"
2926 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2927 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2928 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2930 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2931 (and:SI (match_dup 1)
2933 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2937 {andil.|andi.} %0,%1,%b2
2938 {andiu.|andis.} %0,%1,%u2
2939 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2944 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2945 (set_attr "length" "8,4,4,4,8,8,8,8")])
2948 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2949 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2950 (match_operand:SI 2 "and_operand" ""))
2952 (set (match_operand:SI 0 "gpc_reg_operand" "")
2953 (and:SI (match_dup 1)
2955 (clobber (match_scratch:CC 4 ""))]
2957 [(parallel [(set (match_dup 0)
2958 (and:SI (match_dup 1)
2960 (clobber (match_dup 4))])
2962 (compare:CC (match_dup 0)
2967 [(set (match_operand:CC 3 "cc_reg_operand" "")
2968 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2969 (match_operand:SI 2 "gpc_reg_operand" ""))
2971 (set (match_operand:SI 0 "gpc_reg_operand" "")
2972 (and:SI (match_dup 1)
2974 (clobber (match_scratch:CC 4 ""))]
2975 "TARGET_POWERPC64 && reload_completed"
2976 [(parallel [(set (match_dup 0)
2977 (and:SI (match_dup 1)
2979 (clobber (match_dup 4))])
2981 (compare:CC (match_dup 0)
2985 ;; Handle the PowerPC64 rlwinm corner case
2987 (define_insn_and_split "*andsi3_internal6"
2988 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2989 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2990 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2995 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2998 (rotate:SI (match_dup 0) (match_dup 5)))]
3001 int mb = extract_MB (operands[2]);
3002 int me = extract_ME (operands[2]);
3003 operands[3] = GEN_INT (me + 1);
3004 operands[5] = GEN_INT (32 - (me + 1));
3005 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
3007 [(set_attr "length" "8")])
3009 (define_expand "iorsi3"
3010 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3011 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
3012 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
3016 if (GET_CODE (operands[2]) == CONST_INT
3017 && ! logical_operand (operands[2], SImode))
3019 HOST_WIDE_INT value = INTVAL (operands[2]);
3020 rtx tmp = ((!can_create_pseudo_p ()
3021 || rtx_equal_p (operands[0], operands[1]))
3022 ? operands[0] : gen_reg_rtx (SImode));
3024 emit_insn (gen_iorsi3 (tmp, operands[1],
3025 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3026 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3031 (define_expand "xorsi3"
3032 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3033 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
3034 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
3038 if (GET_CODE (operands[2]) == CONST_INT
3039 && ! logical_operand (operands[2], SImode))
3041 HOST_WIDE_INT value = INTVAL (operands[2]);
3042 rtx tmp = ((!can_create_pseudo_p ()
3043 || rtx_equal_p (operands[0], operands[1]))
3044 ? operands[0] : gen_reg_rtx (SImode));
3046 emit_insn (gen_xorsi3 (tmp, operands[1],
3047 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3048 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3053 (define_insn "*boolsi3_internal1"
3054 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
3055 (match_operator:SI 3 "boolean_or_operator"
3056 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
3057 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
3061 {%q3il|%q3i} %0,%1,%b2
3062 {%q3iu|%q3is} %0,%1,%u2")
3064 (define_insn "*boolsi3_internal2"
3065 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3066 (compare:CC (match_operator:SI 4 "boolean_or_operator"
3067 [(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 [(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 "*boolsi3_internal3"
3093 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3094 (compare:CC (match_operator:SI 4 "boolean_operator"
3095 [(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 [(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 ;; Split a logical operation that we can't do in one insn into two insns,
3123 ;; each of which does one 16-bit part. This is used by combine.
3126 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3127 (match_operator:SI 3 "boolean_or_operator"
3128 [(match_operand:SI 1 "gpc_reg_operand" "")
3129 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
3131 [(set (match_dup 0) (match_dup 4))
3132 (set (match_dup 0) (match_dup 5))]
3136 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
3137 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3139 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
3140 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3144 (define_insn "*boolcsi3_internal1"
3145 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3146 (match_operator:SI 3 "boolean_operator"
3147 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3148 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
3152 (define_insn "*boolcsi3_internal2"
3153 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3154 (compare:CC (match_operator:SI 4 "boolean_operator"
3155 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3156 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3158 (clobber (match_scratch:SI 3 "=r,r"))]
3163 [(set_attr "type" "compare")
3164 (set_attr "length" "4,8")])
3167 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3168 (compare:CC (match_operator:SI 4 "boolean_operator"
3169 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3170 (match_operand:SI 2 "gpc_reg_operand" "")])
3172 (clobber (match_scratch:SI 3 ""))]
3173 "TARGET_32BIT && reload_completed"
3174 [(set (match_dup 3) (match_dup 4))
3176 (compare:CC (match_dup 3)
3180 (define_insn "*boolcsi3_internal3"
3181 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3182 (compare:CC (match_operator:SI 4 "boolean_operator"
3183 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3184 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3186 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3192 [(set_attr "type" "compare")
3193 (set_attr "length" "4,8")])
3196 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3197 (compare:CC (match_operator:SI 4 "boolean_operator"
3198 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3199 (match_operand:SI 2 "gpc_reg_operand" "")])
3201 (set (match_operand:SI 0 "gpc_reg_operand" "")
3203 "TARGET_32BIT && reload_completed"
3204 [(set (match_dup 0) (match_dup 4))
3206 (compare:CC (match_dup 0)
3210 (define_insn "*boolccsi3_internal1"
3211 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3212 (match_operator:SI 3 "boolean_operator"
3213 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3214 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3218 (define_insn "*boolccsi3_internal2"
3219 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3220 (compare:CC (match_operator:SI 4 "boolean_operator"
3221 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3222 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3224 (clobber (match_scratch:SI 3 "=r,r"))]
3229 [(set_attr "type" "compare")
3230 (set_attr "length" "4,8")])
3233 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3234 (compare:CC (match_operator:SI 4 "boolean_operator"
3235 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3236 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3238 (clobber (match_scratch:SI 3 ""))]
3239 "TARGET_32BIT && reload_completed"
3240 [(set (match_dup 3) (match_dup 4))
3242 (compare:CC (match_dup 3)
3246 (define_insn "*boolccsi3_internal3"
3247 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3248 (compare:CC (match_operator:SI 4 "boolean_operator"
3249 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3250 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3252 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3258 [(set_attr "type" "compare")
3259 (set_attr "length" "4,8")])
3262 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3263 (compare:CC (match_operator:SI 4 "boolean_operator"
3264 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3265 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3267 (set (match_operand:SI 0 "gpc_reg_operand" "")
3269 "TARGET_32BIT && reload_completed"
3270 [(set (match_dup 0) (match_dup 4))
3272 (compare:CC (match_dup 0)
3276 ;; maskir insn. We need four forms because things might be in arbitrary