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 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.
44 (FIRST_ALTIVEC_REGNO 77)
45 (LAST_ALTIVEC_REGNO 108)
58 [(UNSPEC_FRSP 0) ; frsp for POWER machines
59 (UNSPEC_TIE 5) ; tie stack contents and stack pointer
60 (UNSPEC_TOCPTR 6) ; address of a word pointing to the TOC
61 (UNSPEC_TOC 7) ; address of the TOC (more-or-less)
63 (UNSPEC_MV_CR_OV 9) ; move_from_CR_ov_bit
69 (UNSPEC_LD_MPIC 15) ; load_macho_picbase
70 (UNSPEC_MPIC_CORRECT 16) ; macho_correct_pic
73 (UNSPEC_MOVESI_FROM_CR 19)
74 (UNSPEC_MOVESI_TO_CR 20)
76 (UNSPEC_TLSDTPRELHA 22)
77 (UNSPEC_TLSDTPRELLO 23)
78 (UNSPEC_TLSGOTDTPREL 24)
80 (UNSPEC_TLSTPRELHA 26)
81 (UNSPEC_TLSTPRELLO 27)
82 (UNSPEC_TLSGOTTPREL 28)
84 (UNSPEC_FIX_TRUNC_TF 30) ; fadd, rounding towards zero
85 (UNSPEC_MV_CR_GT 31) ; move_from_CR_gt_bit
101 (UNSPEC_DLMZB_STRLEN 47)
105 ;; UNSPEC_VOLATILE usage
110 (UNSPECV_LL 1) ; load-locked
111 (UNSPECV_SC 2) ; store-conditional
112 (UNSPECV_EH_RR 9) ; eh_reg_restore
115 ;; Define an insn type attribute. This is used in function unit delay
117 (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"
118 (const_string "integer"))
120 ;; Length (in bytes).
121 ; '(pc)' in the following doesn't include the instruction itself; it is
122 ; calculated as if the instruction had zero size.
123 (define_attr "length" ""
124 (if_then_else (eq_attr "type" "branch")
125 (if_then_else (and (ge (minus (match_dup 0) (pc))
127 (lt (minus (match_dup 0) (pc))
133 ;; Processor type -- this attribute must exactly match the processor_type
134 ;; enumeration in rs6000.h.
136 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4,power5,power6,cell"
137 (const (symbol_ref "rs6000_cpu_attr")))
140 ;; If this instruction is microcoded on the CELL processor
141 ; The default for load and stores is conditional
142 ; The default for load extended and the recorded instructions is always microcoded
143 (define_attr "cell_micro" "not,conditional,always"
144 (if_then_else (ior (ior (eq_attr "type" "load")
145 (eq_attr "type" "store"))
146 (ior (eq_attr "type" "fpload")
147 (eq_attr "type" "fpstore")))
148 (const_string "conditional")
149 (if_then_else (ior (eq_attr "type" "load_ext")
150 (ior (eq_attr "type" "compare")
151 (eq_attr "type" "delayed_compare")))
152 (const_string "always")
153 (const_string "not"))))
156 (automata_option "ndfa")
169 (include "power4.md")
170 (include "power5.md")
171 (include "power6.md")
174 (include "predicates.md")
175 (include "constraints.md")
177 (include "darwin.md")
182 ; This mode macro allows :GPR to be used to indicate the allowable size
183 ; of whole values in GPRs.
184 (define_mode_macro GPR [SI (DI "TARGET_POWERPC64")])
186 ; Any supported integer mode.
187 (define_mode_macro INT [QI HI SI DI TI])
189 ; Any supported integer mode that fits in one register.
190 (define_mode_macro INT1 [QI HI SI (DI "TARGET_POWERPC64")])
192 ; extend modes for DImode
193 (define_mode_macro QHSI [QI HI SI])
195 ; SImode or DImode, even if DImode doesn't fit in GPRs.
196 (define_mode_macro SDI [SI DI])
198 ; The size of a pointer. Also, the size of the value that a record-condition
199 ; (one with a '.') will compare.
200 (define_mode_macro P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
202 ; Any hardware-supported floating-point mode
203 (define_mode_macro FP [(SF "TARGET_HARD_FLOAT")
204 (DF "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)")
205 (TF "!TARGET_IEEEQUAD
207 && (TARGET_FPRS || TARGET_E500_DOUBLE)
208 && TARGET_LONG_DOUBLE_128")])
210 ; Various instructions that come in SI and DI forms.
211 ; A generic w/d attribute, for things like cmpw/cmpd.
212 (define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
215 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
218 ;; Start with fixed-point load and store insns. Here we put only the more
219 ;; complex forms. Basic data transfer is done later.
221 (define_expand "zero_extend<mode>di2"
222 [(set (match_operand:DI 0 "gpc_reg_operand" "")
223 (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "")))]
227 (define_insn "*zero_extend<mode>di2_internal1"
228 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
229 (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
233 rldicl %0,%1,0,<dbits>"
234 [(set_attr "type" "load,*")])
236 (define_insn "*zero_extend<mode>di2_internal2"
237 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
238 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
240 (clobber (match_scratch:DI 2 "=r,r"))]
243 rldicl. %2,%1,0,<dbits>
245 [(set_attr "type" "compare")
246 (set_attr "length" "4,8")])
249 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
250 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
252 (clobber (match_scratch:DI 2 ""))]
253 "TARGET_POWERPC64 && reload_completed"
255 (zero_extend:DI (match_dup 1)))
257 (compare:CC (match_dup 2)
261 (define_insn "*zero_extend<mode>di2_internal3"
262 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
263 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
265 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
266 (zero_extend:DI (match_dup 1)))]
269 rldicl. %0,%1,0,<dbits>
271 [(set_attr "type" "compare")
272 (set_attr "length" "4,8")])
275 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
276 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
278 (set (match_operand:DI 0 "gpc_reg_operand" "")
279 (zero_extend:DI (match_dup 1)))]
280 "TARGET_POWERPC64 && reload_completed"
282 (zero_extend:DI (match_dup 1)))
284 (compare:CC (match_dup 0)
288 (define_insn "extendqidi2"
289 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
290 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
293 [(set_attr "type" "exts")])
296 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
297 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
299 (clobber (match_scratch:DI 2 "=r,r"))]
304 [(set_attr "type" "compare")
305 (set_attr "length" "4,8")])
308 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
309 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
311 (clobber (match_scratch:DI 2 ""))]
312 "TARGET_POWERPC64 && reload_completed"
314 (sign_extend:DI (match_dup 1)))
316 (compare:CC (match_dup 2)
321 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
322 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
324 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
325 (sign_extend:DI (match_dup 1)))]
330 [(set_attr "type" "compare")
331 (set_attr "length" "4,8")])
334 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
335 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
337 (set (match_operand:DI 0 "gpc_reg_operand" "")
338 (sign_extend:DI (match_dup 1)))]
339 "TARGET_POWERPC64 && reload_completed"
341 (sign_extend:DI (match_dup 1)))
343 (compare:CC (match_dup 0)
347 (define_expand "extendhidi2"
348 [(set (match_operand:DI 0 "gpc_reg_operand" "")
349 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
354 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
355 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
360 [(set_attr "type" "load_ext,exts")])
363 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
364 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
366 (clobber (match_scratch:DI 2 "=r,r"))]
371 [(set_attr "type" "compare")
372 (set_attr "length" "4,8")])
375 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
376 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
378 (clobber (match_scratch:DI 2 ""))]
379 "TARGET_POWERPC64 && reload_completed"
381 (sign_extend:DI (match_dup 1)))
383 (compare:CC (match_dup 2)
388 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
389 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
391 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
392 (sign_extend:DI (match_dup 1)))]
397 [(set_attr "type" "compare")
398 (set_attr "length" "4,8")])
401 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
402 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
404 (set (match_operand:DI 0 "gpc_reg_operand" "")
405 (sign_extend:DI (match_dup 1)))]
406 "TARGET_POWERPC64 && reload_completed"
408 (sign_extend:DI (match_dup 1)))
410 (compare:CC (match_dup 0)
414 (define_expand "extendsidi2"
415 [(set (match_operand:DI 0 "gpc_reg_operand" "")
416 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
421 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
422 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
427 [(set_attr "type" "load_ext,exts")])
430 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
431 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
433 (clobber (match_scratch:DI 2 "=r,r"))]
438 [(set_attr "type" "compare")
439 (set_attr "length" "4,8")])
442 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
443 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
445 (clobber (match_scratch:DI 2 ""))]
446 "TARGET_POWERPC64 && reload_completed"
448 (sign_extend:DI (match_dup 1)))
450 (compare:CC (match_dup 2)
455 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
456 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
458 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
459 (sign_extend:DI (match_dup 1)))]
464 [(set_attr "type" "compare")
465 (set_attr "length" "4,8")])
468 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
469 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
471 (set (match_operand:DI 0 "gpc_reg_operand" "")
472 (sign_extend:DI (match_dup 1)))]
473 "TARGET_POWERPC64 && reload_completed"
475 (sign_extend:DI (match_dup 1)))
477 (compare:CC (match_dup 0)
481 (define_expand "zero_extendqisi2"
482 [(set (match_operand:SI 0 "gpc_reg_operand" "")
483 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
488 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
489 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
493 {rlinm|rlwinm} %0,%1,0,0xff"
494 [(set_attr "type" "load,*")])
497 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
498 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
500 (clobber (match_scratch:SI 2 "=r,r"))]
503 {andil.|andi.} %2,%1,0xff
505 [(set_attr "type" "compare")
506 (set_attr "length" "4,8")])
509 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
510 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
512 (clobber (match_scratch:SI 2 ""))]
515 (zero_extend:SI (match_dup 1)))
517 (compare:CC (match_dup 2)
522 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
523 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
525 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
526 (zero_extend:SI (match_dup 1)))]
529 {andil.|andi.} %0,%1,0xff
531 [(set_attr "type" "compare")
532 (set_attr "length" "4,8")])
535 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
536 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
538 (set (match_operand:SI 0 "gpc_reg_operand" "")
539 (zero_extend:SI (match_dup 1)))]
542 (zero_extend:SI (match_dup 1)))
544 (compare:CC (match_dup 0)
548 (define_expand "extendqisi2"
549 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
550 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
555 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
556 else if (TARGET_POWER)
557 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
559 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
563 (define_insn "extendqisi2_ppc"
564 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
565 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
568 [(set_attr "type" "exts")])
571 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
572 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
574 (clobber (match_scratch:SI 2 "=r,r"))]
579 [(set_attr "type" "compare")
580 (set_attr "length" "4,8")])
583 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
584 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
586 (clobber (match_scratch:SI 2 ""))]
587 "TARGET_POWERPC && reload_completed"
589 (sign_extend:SI (match_dup 1)))
591 (compare:CC (match_dup 2)
596 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
597 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
599 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
600 (sign_extend:SI (match_dup 1)))]
605 [(set_attr "type" "compare")
606 (set_attr "length" "4,8")])
609 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
610 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
612 (set (match_operand:SI 0 "gpc_reg_operand" "")
613 (sign_extend:SI (match_dup 1)))]
614 "TARGET_POWERPC && reload_completed"
616 (sign_extend:SI (match_dup 1)))
618 (compare:CC (match_dup 0)
622 (define_expand "extendqisi2_power"
623 [(parallel [(set (match_dup 2)
624 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
626 (clobber (scratch:SI))])
627 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
628 (ashiftrt:SI (match_dup 2)
630 (clobber (scratch:SI))])]
633 { operands[1] = gen_lowpart (SImode, operands[1]);
634 operands[2] = gen_reg_rtx (SImode); }")
636 (define_expand "extendqisi2_no_power"
638 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
640 (set (match_operand:SI 0 "gpc_reg_operand" "")
641 (ashiftrt:SI (match_dup 2)
643 "! TARGET_POWER && ! TARGET_POWERPC"
645 { operands[1] = gen_lowpart (SImode, operands[1]);
646 operands[2] = gen_reg_rtx (SImode); }")
648 (define_expand "zero_extendqihi2"
649 [(set (match_operand:HI 0 "gpc_reg_operand" "")
650 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
655 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
656 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
660 {rlinm|rlwinm} %0,%1,0,0xff"
661 [(set_attr "type" "load,*")])
664 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
665 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
667 (clobber (match_scratch:HI 2 "=r,r"))]
670 {andil.|andi.} %2,%1,0xff
672 [(set_attr "type" "compare")
673 (set_attr "length" "4,8")])
676 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
677 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
679 (clobber (match_scratch:HI 2 ""))]
682 (zero_extend:HI (match_dup 1)))
684 (compare:CC (match_dup 2)
689 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
690 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
692 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
693 (zero_extend:HI (match_dup 1)))]
696 {andil.|andi.} %0,%1,0xff
698 [(set_attr "type" "compare")
699 (set_attr "length" "4,8")])
702 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
703 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
705 (set (match_operand:HI 0 "gpc_reg_operand" "")
706 (zero_extend:HI (match_dup 1)))]
709 (zero_extend:HI (match_dup 1)))
711 (compare:CC (match_dup 0)
715 (define_expand "extendqihi2"
716 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
717 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
722 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
723 else if (TARGET_POWER)
724 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
726 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
730 (define_insn "extendqihi2_ppc"
731 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
732 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
735 [(set_attr "type" "exts")])
738 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
739 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
741 (clobber (match_scratch:HI 2 "=r,r"))]
746 [(set_attr "type" "compare")
747 (set_attr "length" "4,8")])
750 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
751 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
753 (clobber (match_scratch:HI 2 ""))]
754 "TARGET_POWERPC && reload_completed"
756 (sign_extend:HI (match_dup 1)))
758 (compare:CC (match_dup 2)
763 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
764 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
766 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
767 (sign_extend:HI (match_dup 1)))]
772 [(set_attr "type" "compare")
773 (set_attr "length" "4,8")])
776 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
777 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
779 (set (match_operand:HI 0 "gpc_reg_operand" "")
780 (sign_extend:HI (match_dup 1)))]
781 "TARGET_POWERPC && reload_completed"
783 (sign_extend:HI (match_dup 1)))
785 (compare:CC (match_dup 0)
789 (define_expand "extendqihi2_power"
790 [(parallel [(set (match_dup 2)
791 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
793 (clobber (scratch:SI))])
794 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
795 (ashiftrt:SI (match_dup 2)
797 (clobber (scratch:SI))])]
800 { operands[0] = gen_lowpart (SImode, operands[0]);
801 operands[1] = gen_lowpart (SImode, operands[1]);
802 operands[2] = gen_reg_rtx (SImode); }")
804 (define_expand "extendqihi2_no_power"
806 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
808 (set (match_operand:HI 0 "gpc_reg_operand" "")
809 (ashiftrt:SI (match_dup 2)
811 "! TARGET_POWER && ! TARGET_POWERPC"
813 { operands[0] = gen_lowpart (SImode, operands[0]);
814 operands[1] = gen_lowpart (SImode, operands[1]);
815 operands[2] = gen_reg_rtx (SImode); }")
817 (define_expand "zero_extendhisi2"
818 [(set (match_operand:SI 0 "gpc_reg_operand" "")
819 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
824 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
825 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
829 {rlinm|rlwinm} %0,%1,0,0xffff"
830 [(set_attr "type" "load,*")])
833 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
834 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
836 (clobber (match_scratch:SI 2 "=r,r"))]
839 {andil.|andi.} %2,%1,0xffff
841 [(set_attr "type" "compare")
842 (set_attr "length" "4,8")])
845 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
846 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
848 (clobber (match_scratch:SI 2 ""))]
851 (zero_extend:SI (match_dup 1)))
853 (compare:CC (match_dup 2)
858 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
859 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
861 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
862 (zero_extend:SI (match_dup 1)))]
865 {andil.|andi.} %0,%1,0xffff
867 [(set_attr "type" "compare")
868 (set_attr "length" "4,8")])
871 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
872 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
874 (set (match_operand:SI 0 "gpc_reg_operand" "")
875 (zero_extend:SI (match_dup 1)))]
878 (zero_extend:SI (match_dup 1)))
880 (compare:CC (match_dup 0)
884 (define_expand "extendhisi2"
885 [(set (match_operand:SI 0 "gpc_reg_operand" "")
886 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
891 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
892 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
897 [(set_attr "type" "load_ext,exts")])
900 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
901 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
903 (clobber (match_scratch:SI 2 "=r,r"))]
908 [(set_attr "type" "compare")
909 (set_attr "length" "4,8")])
912 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
913 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
915 (clobber (match_scratch:SI 2 ""))]
918 (sign_extend:SI (match_dup 1)))
920 (compare:CC (match_dup 2)
925 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
926 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
928 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
929 (sign_extend:SI (match_dup 1)))]
934 [(set_attr "type" "compare")
935 (set_attr "length" "4,8")])
937 ;; IBM 405 and 440 half-word multiplication operations.
939 (define_insn "*macchwc"
940 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
941 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
942 (match_operand:SI 2 "gpc_reg_operand" "r")
945 (match_operand:HI 1 "gpc_reg_operand" "r")))
946 (match_operand:SI 4 "gpc_reg_operand" "0"))
948 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
949 (plus:SI (mult:SI (ashiftrt:SI
957 [(set_attr "type" "imul3")])
959 (define_insn "*macchw"
960 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
961 (plus:SI (mult:SI (ashiftrt:SI
962 (match_operand:SI 2 "gpc_reg_operand" "r")
965 (match_operand:HI 1 "gpc_reg_operand" "r")))
966 (match_operand:SI 3 "gpc_reg_operand" "0")))]
969 [(set_attr "type" "imul3")])
971 (define_insn "*macchwuc"
972 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
973 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
974 (match_operand:SI 2 "gpc_reg_operand" "r")
977 (match_operand:HI 1 "gpc_reg_operand" "r")))
978 (match_operand:SI 4 "gpc_reg_operand" "0"))
980 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
981 (plus:SI (mult:SI (lshiftrt:SI
988 "macchwu. %0, %1, %2"
989 [(set_attr "type" "imul3")])
991 (define_insn "*macchwu"
992 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
993 (plus:SI (mult:SI (lshiftrt:SI
994 (match_operand:SI 2 "gpc_reg_operand" "r")
997 (match_operand:HI 1 "gpc_reg_operand" "r")))
998 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1000 "macchwu %0, %1, %2"
1001 [(set_attr "type" "imul3")])
1003 (define_insn "*machhwc"
1004 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1005 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
1006 (match_operand:SI 1 "gpc_reg_operand" "%r")
1009 (match_operand:SI 2 "gpc_reg_operand" "r")
1011 (match_operand:SI 4 "gpc_reg_operand" "0"))
1013 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1014 (plus:SI (mult:SI (ashiftrt:SI
1022 "machhw. %0, %1, %2"
1023 [(set_attr "type" "imul3")])
1025 (define_insn "*machhw"
1026 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1027 (plus:SI (mult:SI (ashiftrt:SI
1028 (match_operand:SI 1 "gpc_reg_operand" "%r")
1031 (match_operand:SI 2 "gpc_reg_operand" "r")
1033 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1036 [(set_attr "type" "imul3")])
1038 (define_insn "*machhwuc"
1039 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1040 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
1041 (match_operand:SI 1 "gpc_reg_operand" "%r")
1044 (match_operand:SI 2 "gpc_reg_operand" "r")
1046 (match_operand:SI 4 "gpc_reg_operand" "0"))
1048 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1049 (plus:SI (mult:SI (lshiftrt:SI
1057 "machhwu. %0, %1, %2"
1058 [(set_attr "type" "imul3")])
1060 (define_insn "*machhwu"
1061 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1062 (plus:SI (mult:SI (lshiftrt:SI
1063 (match_operand:SI 1 "gpc_reg_operand" "%r")
1066 (match_operand:SI 2 "gpc_reg_operand" "r")
1068 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1070 "machhwu %0, %1, %2"
1071 [(set_attr "type" "imul3")])
1073 (define_insn "*maclhwc"
1074 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1075 (compare:CC (plus:SI (mult:SI (sign_extend:SI
1076 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1078 (match_operand:HI 2 "gpc_reg_operand" "r")))
1079 (match_operand:SI 4 "gpc_reg_operand" "0"))
1081 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1082 (plus:SI (mult:SI (sign_extend:SI
1088 "maclhw. %0, %1, %2"
1089 [(set_attr "type" "imul3")])
1091 (define_insn "*maclhw"
1092 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1093 (plus:SI (mult:SI (sign_extend:SI
1094 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1096 (match_operand:HI 2 "gpc_reg_operand" "r")))
1097 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1100 [(set_attr "type" "imul3")])
1102 (define_insn "*maclhwuc"
1103 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1104 (compare:CC (plus:SI (mult:SI (zero_extend:SI
1105 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1107 (match_operand:HI 2 "gpc_reg_operand" "r")))
1108 (match_operand:SI 4 "gpc_reg_operand" "0"))
1110 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1111 (plus:SI (mult:SI (zero_extend:SI
1117 "maclhwu. %0, %1, %2"
1118 [(set_attr "type" "imul3")])
1120 (define_insn "*maclhwu"
1121 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1122 (plus:SI (mult:SI (zero_extend:SI
1123 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1125 (match_operand:HI 2 "gpc_reg_operand" "r")))
1126 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1128 "maclhwu %0, %1, %2"
1129 [(set_attr "type" "imul3")])
1131 (define_insn "*nmacchwc"
1132 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1133 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1134 (mult:SI (ashiftrt:SI
1135 (match_operand:SI 2 "gpc_reg_operand" "r")
1138 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1140 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1141 (minus:SI (match_dup 4)
1142 (mult:SI (ashiftrt:SI
1148 "nmacchw. %0, %1, %2"
1149 [(set_attr "type" "imul3")])
1151 (define_insn "*nmacchw"
1152 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1153 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1154 (mult:SI (ashiftrt:SI
1155 (match_operand:SI 2 "gpc_reg_operand" "r")
1158 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1160 "nmacchw %0, %1, %2"
1161 [(set_attr "type" "imul3")])
1163 (define_insn "*nmachhwc"
1164 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1165 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1166 (mult:SI (ashiftrt:SI
1167 (match_operand:SI 1 "gpc_reg_operand" "%r")
1170 (match_operand:SI 2 "gpc_reg_operand" "r")
1173 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1174 (minus:SI (match_dup 4)
1175 (mult:SI (ashiftrt:SI
1182 "nmachhw. %0, %1, %2"
1183 [(set_attr "type" "imul3")])
1185 (define_insn "*nmachhw"
1186 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1187 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1188 (mult:SI (ashiftrt:SI
1189 (match_operand:SI 1 "gpc_reg_operand" "%r")
1192 (match_operand:SI 2 "gpc_reg_operand" "r")
1195 "nmachhw %0, %1, %2"
1196 [(set_attr "type" "imul3")])
1198 (define_insn "*nmaclhwc"
1199 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1200 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1201 (mult:SI (sign_extend:SI
1202 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1204 (match_operand:HI 2 "gpc_reg_operand" "r"))))
1206 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1207 (minus:SI (match_dup 4)
1208 (mult:SI (sign_extend:SI
1213 "nmaclhw. %0, %1, %2"
1214 [(set_attr "type" "imul3")])
1216 (define_insn "*nmaclhw"
1217 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1218 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1219 (mult:SI (sign_extend:SI
1220 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1222 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1224 "nmaclhw %0, %1, %2"
1225 [(set_attr "type" "imul3")])
1227 (define_insn "*mulchwc"
1228 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1229 (compare:CC (mult:SI (ashiftrt:SI
1230 (match_operand:SI 2 "gpc_reg_operand" "r")
1233 (match_operand:HI 1 "gpc_reg_operand" "r")))
1235 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1236 (mult:SI (ashiftrt:SI
1242 "mulchw. %0, %1, %2"
1243 [(set_attr "type" "imul3")])
1245 (define_insn "*mulchw"
1246 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1247 (mult:SI (ashiftrt:SI
1248 (match_operand:SI 2 "gpc_reg_operand" "r")
1251 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1254 [(set_attr "type" "imul3")])
1256 (define_insn "*mulchwuc"
1257 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1258 (compare:CC (mult:SI (lshiftrt:SI
1259 (match_operand:SI 2 "gpc_reg_operand" "r")
1262 (match_operand:HI 1 "gpc_reg_operand" "r")))
1264 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1265 (mult:SI (lshiftrt:SI
1271 "mulchwu. %0, %1, %2"
1272 [(set_attr "type" "imul3")])
1274 (define_insn "*mulchwu"
1275 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1276 (mult:SI (lshiftrt:SI
1277 (match_operand:SI 2 "gpc_reg_operand" "r")
1280 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1282 "mulchwu %0, %1, %2"
1283 [(set_attr "type" "imul3")])
1285 (define_insn "*mulhhwc"
1286 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1287 (compare:CC (mult:SI (ashiftrt:SI
1288 (match_operand:SI 1 "gpc_reg_operand" "%r")
1291 (match_operand:SI 2 "gpc_reg_operand" "r")
1294 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1295 (mult:SI (ashiftrt:SI
1302 "mulhhw. %0, %1, %2"
1303 [(set_attr "type" "imul3")])
1305 (define_insn "*mulhhw"
1306 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1307 (mult:SI (ashiftrt:SI
1308 (match_operand:SI 1 "gpc_reg_operand" "%r")
1311 (match_operand:SI 2 "gpc_reg_operand" "r")
1315 [(set_attr "type" "imul3")])
1317 (define_insn "*mulhhwuc"
1318 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1319 (compare:CC (mult:SI (lshiftrt:SI
1320 (match_operand:SI 1 "gpc_reg_operand" "%r")
1323 (match_operand:SI 2 "gpc_reg_operand" "r")
1326 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1327 (mult:SI (lshiftrt:SI
1334 "mulhhwu. %0, %1, %2"
1335 [(set_attr "type" "imul3")])
1337 (define_insn "*mulhhwu"
1338 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1339 (mult:SI (lshiftrt:SI
1340 (match_operand:SI 1 "gpc_reg_operand" "%r")
1343 (match_operand:SI 2 "gpc_reg_operand" "r")
1346 "mulhhwu %0, %1, %2"
1347 [(set_attr "type" "imul3")])
1349 (define_insn "*mullhwc"
1350 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1351 (compare:CC (mult:SI (sign_extend:SI
1352 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1354 (match_operand:HI 2 "gpc_reg_operand" "r")))
1356 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1357 (mult:SI (sign_extend:SI
1362 "mullhw. %0, %1, %2"
1363 [(set_attr "type" "imul3")])
1365 (define_insn "*mullhw"
1366 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1367 (mult:SI (sign_extend:SI
1368 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1370 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1373 [(set_attr "type" "imul3")])
1375 (define_insn "*mullhwuc"
1376 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1377 (compare:CC (mult:SI (zero_extend:SI
1378 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1380 (match_operand:HI 2 "gpc_reg_operand" "r")))
1382 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1383 (mult:SI (zero_extend:SI
1388 "mullhwu. %0, %1, %2"
1389 [(set_attr "type" "imul3")])
1391 (define_insn "*mullhwu"
1392 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1393 (mult:SI (zero_extend:SI
1394 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1396 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1398 "mullhwu %0, %1, %2"
1399 [(set_attr "type" "imul3")])
1401 ;; IBM 405 and 440 string-search dlmzb instruction support.
1402 (define_insn "dlmzb"
1403 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1404 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1405 (match_operand:SI 2 "gpc_reg_operand" "r")]
1407 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1408 (unspec:SI [(match_dup 1)
1412 "dlmzb. %0, %1, %2")
1414 (define_expand "strlensi"
1415 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1416 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1417 (match_operand:QI 2 "const_int_operand" "")
1418 (match_operand 3 "const_int_operand" "")]
1419 UNSPEC_DLMZB_STRLEN))
1420 (clobber (match_scratch:CC 4 "=x"))]
1421 "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1423 rtx result = operands[0];
1424 rtx src = operands[1];
1425 rtx search_char = operands[2];
1426 rtx align = operands[3];
1427 rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1428 rtx loop_label, end_label, mem, cr0, cond;
1429 if (search_char != const0_rtx
1430 || GET_CODE (align) != CONST_INT
1431 || INTVAL (align) < 8)
1433 word1 = gen_reg_rtx (SImode);
1434 word2 = gen_reg_rtx (SImode);
1435 scratch_dlmzb = gen_reg_rtx (SImode);
1436 scratch_string = gen_reg_rtx (Pmode);
1437 loop_label = gen_label_rtx ();
1438 end_label = gen_label_rtx ();
1439 addr = force_reg (Pmode, XEXP (src, 0));
1440 emit_move_insn (scratch_string, addr);
1441 emit_label (loop_label);
1442 mem = change_address (src, SImode, scratch_string);
1443 emit_move_insn (word1, mem);
1444 emit_move_insn (word2, adjust_address (mem, SImode, 4));
1445 cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1446 emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1447 cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1448 emit_jump_insn (gen_rtx_SET (VOIDmode,
1450 gen_rtx_IF_THEN_ELSE (VOIDmode,
1456 emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1457 emit_jump_insn (gen_rtx_SET (VOIDmode,
1459 gen_rtx_LABEL_REF (VOIDmode, loop_label)));
1461 emit_label (end_label);
1462 emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1463 emit_insn (gen_subsi3 (result, scratch_string, addr));
1464 emit_insn (gen_subsi3 (result, result, const1_rtx));
1469 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1470 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1472 (set (match_operand:SI 0 "gpc_reg_operand" "")
1473 (sign_extend:SI (match_dup 1)))]
1476 (sign_extend:SI (match_dup 1)))
1478 (compare:CC (match_dup 0)
1482 ;; Fixed-point arithmetic insns.
1484 (define_expand "add<mode>3"
1485 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1486 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1487 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1490 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1492 if (non_short_cint_operand (operands[2], DImode))
1495 else if (GET_CODE (operands[2]) == CONST_INT
1496 && ! add_operand (operands[2], <MODE>mode))
1498 rtx tmp = ((!can_create_pseudo_p ()
1499 || rtx_equal_p (operands[0], operands[1]))
1500 ? operands[0] : gen_reg_rtx (<MODE>mode));
1502 HOST_WIDE_INT val = INTVAL (operands[2]);
1503 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1504 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1506 if (<MODE>mode == DImode && !satisfies_constraint_L (GEN_INT (rest)))
1509 /* The ordering here is important for the prolog expander.
1510 When space is allocated from the stack, adding 'low' first may
1511 produce a temporary deallocation (which would be bad). */
1512 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1513 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1518 ;; Discourage ai/addic because of carry but provide it in an alternative
1519 ;; allowing register zero as source.
1520 (define_insn "*add<mode>3_internal1"
1521 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1522 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1523 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
1524 "!DECIMAL_FLOAT_MODE_P (GET_MODE (operands[0])) && !DECIMAL_FLOAT_MODE_P (GET_MODE (operands[1]))"
1527 {cal %0,%2(%1)|addi %0,%1,%2}
1529 {cau|addis} %0,%1,%v2"
1530 [(set_attr "length" "4,4,4,4")])
1532 (define_insn "addsi3_high"
1533 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1534 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1535 (high:SI (match_operand 2 "" ""))))]
1536 "TARGET_MACHO && !TARGET_64BIT"
1537 "{cau|addis} %0,%1,ha16(%2)"
1538 [(set_attr "length" "4")])
1540 (define_insn "*add<mode>3_internal2"
1541 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1542 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1543 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1545 (clobber (match_scratch:P 3 "=r,r,r,r"))]
1548 {cax.|add.} %3,%1,%2
1549 {ai.|addic.} %3,%1,%2
1552 [(set_attr "type" "fast_compare,compare,compare,compare")
1553 (set_attr "length" "4,4,8,8")])
1556 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1557 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1558 (match_operand:GPR 2 "reg_or_short_operand" ""))
1560 (clobber (match_scratch:GPR 3 ""))]
1563 (plus:GPR (match_dup 1)
1566 (compare:CC (match_dup 3)
1570 (define_insn "*add<mode>3_internal3"
1571 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1572 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1573 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1575 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1576 (plus:P (match_dup 1)
1580 {cax.|add.} %0,%1,%2
1581 {ai.|addic.} %0,%1,%2
1584 [(set_attr "type" "fast_compare,compare,compare,compare")
1585 (set_attr "length" "4,4,8,8")])
1588 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1589 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1590 (match_operand:P 2 "reg_or_short_operand" ""))
1592 (set (match_operand:P 0 "gpc_reg_operand" "")
1593 (plus:P (match_dup 1) (match_dup 2)))]
1596 (plus:P (match_dup 1)
1599 (compare:CC (match_dup 0)
1603 ;; Split an add that we can't do in one insn into two insns, each of which
1604 ;; does one 16-bit part. This is used by combine. Note that the low-order
1605 ;; add should be last in case the result gets used in an address.
1608 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1609 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1610 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1612 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1613 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1615 HOST_WIDE_INT val = INTVAL (operands[2]);
1616 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1617 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1619 operands[4] = GEN_INT (low);
1620 if (<MODE>mode == SImode || satisfies_constraint_L (GEN_INT (rest)))
1621 operands[3] = GEN_INT (rest);
1622 else if (can_create_pseudo_p ())
1624 operands[3] = gen_reg_rtx (DImode);
1625 emit_move_insn (operands[3], operands[2]);
1626 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1633 (define_insn "one_cmpl<mode>2"
1634 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1635 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1640 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1641 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1643 (clobber (match_scratch:P 2 "=r,r"))]
1648 [(set_attr "type" "compare")
1649 (set_attr "length" "4,8")])
1652 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1653 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1655 (clobber (match_scratch:P 2 ""))]
1658 (not:P (match_dup 1)))
1660 (compare:CC (match_dup 2)
1665 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1666 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1668 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1669 (not:P (match_dup 1)))]
1674 [(set_attr "type" "compare")
1675 (set_attr "length" "4,8")])
1678 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1679 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1681 (set (match_operand:P 0 "gpc_reg_operand" "")
1682 (not:P (match_dup 1)))]
1685 (not:P (match_dup 1)))
1687 (compare:CC (match_dup 0)
1692 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1693 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1694 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1696 "{sf%I1|subf%I1c} %0,%2,%1")
1699 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1700 (minus:GPR (match_operand:GPR 1 "reg_or_short_operand" "r,I")
1701 (match_operand:GPR 2 "gpc_reg_operand" "r,r")))]
1708 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1709 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1710 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1712 (clobber (match_scratch:SI 3 "=r,r"))]
1715 {sf.|subfc.} %3,%2,%1
1717 [(set_attr "type" "compare")
1718 (set_attr "length" "4,8")])
1721 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1722 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1723 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1725 (clobber (match_scratch:P 3 "=r,r"))]
1730 [(set_attr "type" "fast_compare")
1731 (set_attr "length" "4,8")])
1734 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1735 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1736 (match_operand:P 2 "gpc_reg_operand" ""))
1738 (clobber (match_scratch:P 3 ""))]
1741 (minus:P (match_dup 1)
1744 (compare:CC (match_dup 3)
1749 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1750 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1751 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1753 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1754 (minus:SI (match_dup 1) (match_dup 2)))]
1757 {sf.|subfc.} %0,%2,%1
1759 [(set_attr "type" "compare")
1760 (set_attr "length" "4,8")])
1763 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1764 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1765 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1767 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1768 (minus:P (match_dup 1)
1774 [(set_attr "type" "fast_compare")
1775 (set_attr "length" "4,8")])
1778 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1779 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1780 (match_operand:P 2 "gpc_reg_operand" ""))
1782 (set (match_operand:P 0 "gpc_reg_operand" "")
1783 (minus:P (match_dup 1)
1787 (minus:P (match_dup 1)
1790 (compare:CC (match_dup 0)
1794 (define_expand "sub<mode>3"
1795 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1796 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1797 (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
1801 if (GET_CODE (operands[2]) == CONST_INT)
1803 emit_insn (gen_add<mode>3 (operands[0], operands[1],
1804 negate_rtx (<MODE>mode, operands[2])));
1809 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1810 ;; instruction and some auxiliary computations. Then we just have a single
1811 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1814 (define_expand "sminsi3"
1816 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1817 (match_operand:SI 2 "reg_or_short_operand" ""))
1819 (minus:SI (match_dup 2) (match_dup 1))))
1820 (set (match_operand:SI 0 "gpc_reg_operand" "")
1821 (minus:SI (match_dup 2) (match_dup 3)))]
1822 "TARGET_POWER || TARGET_ISEL"
1827 operands[2] = force_reg (SImode, operands[2]);
1828 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1832 operands[3] = gen_reg_rtx (SImode);
1836 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1837 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1838 (match_operand:SI 2 "reg_or_short_operand" "")))
1839 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1842 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1844 (minus:SI (match_dup 2) (match_dup 1))))
1845 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1848 (define_expand "smaxsi3"
1850 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1851 (match_operand:SI 2 "reg_or_short_operand" ""))
1853 (minus:SI (match_dup 2) (match_dup 1))))
1854 (set (match_operand:SI 0 "gpc_reg_operand" "")
1855 (plus:SI (match_dup 3) (match_dup 1)))]
1856 "TARGET_POWER || TARGET_ISEL"
1861 operands[2] = force_reg (SImode, operands[2]);
1862 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1865 operands[3] = gen_reg_rtx (SImode);
1869 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1870 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1871 (match_operand:SI 2 "reg_or_short_operand" "")))
1872 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1875 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1877 (minus:SI (match_dup 2) (match_dup 1))))
1878 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1881 (define_expand "uminsi3"
1882 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1884 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1886 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1888 (minus:SI (match_dup 4) (match_dup 3))))
1889 (set (match_operand:SI 0 "gpc_reg_operand" "")
1890 (minus:SI (match_dup 2) (match_dup 3)))]
1891 "TARGET_POWER || TARGET_ISEL"
1896 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1899 operands[3] = gen_reg_rtx (SImode);
1900 operands[4] = gen_reg_rtx (SImode);
1901 operands[5] = GEN_INT (-2147483647 - 1);
1904 (define_expand "umaxsi3"
1905 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1907 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1909 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1911 (minus:SI (match_dup 4) (match_dup 3))))
1912 (set (match_operand:SI 0 "gpc_reg_operand" "")
1913 (plus:SI (match_dup 3) (match_dup 1)))]
1914 "TARGET_POWER || TARGET_ISEL"
1919 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1922 operands[3] = gen_reg_rtx (SImode);
1923 operands[4] = gen_reg_rtx (SImode);
1924 operands[5] = GEN_INT (-2147483647 - 1);
1928 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1929 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1930 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1932 (minus:SI (match_dup 2) (match_dup 1))))]
1937 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1939 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1940 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1942 (minus:SI (match_dup 2) (match_dup 1)))
1944 (clobber (match_scratch:SI 3 "=r,r"))]
1949 [(set_attr "type" "delayed_compare")
1950 (set_attr "length" "4,8")])
1953 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1955 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1956 (match_operand:SI 2 "reg_or_short_operand" ""))
1958 (minus:SI (match_dup 2) (match_dup 1)))
1960 (clobber (match_scratch:SI 3 ""))]
1961 "TARGET_POWER && reload_completed"
1963 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1965 (minus:SI (match_dup 2) (match_dup 1))))
1967 (compare:CC (match_dup 3)
1972 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1974 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1975 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1977 (minus:SI (match_dup 2) (match_dup 1)))
1979 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1980 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1982 (minus:SI (match_dup 2) (match_dup 1))))]
1987 [(set_attr "type" "delayed_compare")
1988 (set_attr "length" "4,8")])
1991 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1993 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1994 (match_operand:SI 2 "reg_or_short_operand" ""))
1996 (minus:SI (match_dup 2) (match_dup 1)))
1998 (set (match_operand:SI 0 "gpc_reg_operand" "")
1999 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2001 (minus:SI (match_dup 2) (match_dup 1))))]
2002 "TARGET_POWER && reload_completed"
2004 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2006 (minus:SI (match_dup 2) (match_dup 1))))
2008 (compare:CC (match_dup 0)
2012 ;; We don't need abs with condition code because such comparisons should
2014 (define_expand "abssi2"
2015 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2016 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2022 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
2025 else if (! TARGET_POWER)
2027 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
2032 (define_insn "*abssi2_power"
2033 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2034 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2038 (define_insn_and_split "abssi2_isel"
2039 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2040 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
2041 (clobber (match_scratch:SI 2 "=&b"))
2042 (clobber (match_scratch:CC 3 "=y"))]
2045 "&& reload_completed"
2046 [(set (match_dup 2) (neg:SI (match_dup 1)))
2048 (compare:CC (match_dup 1)
2051 (if_then_else:SI (ge (match_dup 3)
2057 (define_insn_and_split "abssi2_nopower"
2058 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2059 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
2060 (clobber (match_scratch:SI 2 "=&r,&r"))]
2061 "! TARGET_POWER && ! TARGET_ISEL"
2063 "&& reload_completed"
2064 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2065 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2066 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
2069 (define_insn "*nabs_power"
2070 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2071 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
2075 (define_insn_and_split "*nabs_nopower"
2076 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2077 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
2078 (clobber (match_scratch:SI 2 "=&r,&r"))]
2081 "&& reload_completed"
2082 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2083 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2084 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
2087 (define_expand "neg<mode>2"
2088 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2089 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
2093 (define_insn "*neg<mode>2_internal"
2094 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2095 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2100 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2101 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2103 (clobber (match_scratch:P 2 "=r,r"))]
2108 [(set_attr "type" "fast_compare")
2109 (set_attr "length" "4,8")])
2112 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2113 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2115 (clobber (match_scratch:P 2 ""))]
2118 (neg:P (match_dup 1)))
2120 (compare:CC (match_dup 2)
2125 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2126 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2128 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2129 (neg:P (match_dup 1)))]
2134 [(set_attr "type" "fast_compare")
2135 (set_attr "length" "4,8")])
2138 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2139 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2141 (set (match_operand:P 0 "gpc_reg_operand" "")
2142 (neg:P (match_dup 1)))]
2145 (neg:P (match_dup 1)))
2147 (compare:CC (match_dup 0)
2151 (define_insn "clz<mode>2"
2152 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2153 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2155 "{cntlz|cntlz<wd>} %0,%1"
2156 [(set_attr "type" "cntlz")])
2158 (define_expand "ctz<mode>2"
2160 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
2161 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2163 (clobber (scratch:CC))])
2164 (set (match_dup 4) (clz:GPR (match_dup 3)))
2165 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2166 (minus:GPR (match_dup 5) (match_dup 4)))]
2169 operands[2] = gen_reg_rtx (<MODE>mode);
2170 operands[3] = gen_reg_rtx (<MODE>mode);
2171 operands[4] = gen_reg_rtx (<MODE>mode);
2172 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
2175 (define_expand "ffs<mode>2"
2177 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
2178 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2180 (clobber (scratch:CC))])
2181 (set (match_dup 4) (clz:GPR (match_dup 3)))
2182 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2183 (minus:GPR (match_dup 5) (match_dup 4)))]
2186 operands[2] = gen_reg_rtx (<MODE>mode);
2187 operands[3] = gen_reg_rtx (<MODE>mode);
2188 operands[4] = gen_reg_rtx (<MODE>mode);
2189 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
2192 (define_insn "popcntb<mode>2"
2193 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2194 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2199 (define_expand "popcount<mode>2"
2200 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2201 (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
2204 rs6000_emit_popcount (operands[0], operands[1]);
2208 (define_expand "parity<mode>2"
2209 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2210 (parity:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
2213 rs6000_emit_parity (operands[0], operands[1]);
2217 (define_insn "bswapsi2"
2218 [(set (match_operand:SI 0 "reg_or_mem_operand" "=r,Z,&r")
2219 (bswap:SI (match_operand:SI 1 "reg_or_mem_operand" "Z,r,r")))]
2223 {stbrx|stwbrx} %1,%y0
2225 [(set_attr "length" "4,4,12")])
2228 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2229 (bswap:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2232 (rotate:SI (match_dup 1) (const_int 8)))
2233 (set (zero_extract:SI (match_dup 0)
2237 (set (zero_extract:SI (match_dup 0)
2240 (rotate:SI (match_dup 1)
2244 (define_expand "mulsi3"
2245 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2246 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2247 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2252 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2254 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2258 (define_insn "mulsi3_mq"
2259 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2260 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2261 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2262 (clobber (match_scratch:SI 3 "=q,q"))]
2265 {muls|mullw} %0,%1,%2
2266 {muli|mulli} %0,%1,%2"
2268 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2269 (const_string "imul3")
2270 (match_operand:SI 2 "short_cint_operand" "")
2271 (const_string "imul2")]
2272 (const_string "imul")))])
2274 (define_insn "mulsi3_no_mq"
2275 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2276 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2277 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2280 {muls|mullw} %0,%1,%2
2281 {muli|mulli} %0,%1,%2"
2283 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2284 (const_string "imul3")
2285 (match_operand:SI 2 "short_cint_operand" "")
2286 (const_string "imul2")]
2287 (const_string "imul")))])
2289 (define_insn "*mulsi3_mq_internal1"
2290 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2291 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2292 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2294 (clobber (match_scratch:SI 3 "=r,r"))
2295 (clobber (match_scratch:SI 4 "=q,q"))]
2298 {muls.|mullw.} %3,%1,%2
2300 [(set_attr "type" "imul_compare")
2301 (set_attr "length" "4,8")])
2304 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2305 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2306 (match_operand:SI 2 "gpc_reg_operand" ""))
2308 (clobber (match_scratch:SI 3 ""))
2309 (clobber (match_scratch:SI 4 ""))]
2310 "TARGET_POWER && reload_completed"
2311 [(parallel [(set (match_dup 3)
2312 (mult:SI (match_dup 1) (match_dup 2)))
2313 (clobber (match_dup 4))])
2315 (compare:CC (match_dup 3)
2319 (define_insn "*mulsi3_no_mq_internal1"
2320 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2321 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2322 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2324 (clobber (match_scratch:SI 3 "=r,r"))]
2327 {muls.|mullw.} %3,%1,%2
2329 [(set_attr "type" "imul_compare")
2330 (set_attr "length" "4,8")])
2333 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2334 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2335 (match_operand:SI 2 "gpc_reg_operand" ""))
2337 (clobber (match_scratch:SI 3 ""))]
2338 "! TARGET_POWER && reload_completed"
2340 (mult:SI (match_dup 1) (match_dup 2)))
2342 (compare:CC (match_dup 3)
2346 (define_insn "*mulsi3_mq_internal2"
2347 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2348 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2349 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2351 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2352 (mult:SI (match_dup 1) (match_dup 2)))
2353 (clobber (match_scratch:SI 4 "=q,q"))]
2356 {muls.|mullw.} %0,%1,%2
2358 [(set_attr "type" "imul_compare")
2359 (set_attr "length" "4,8")])
2362 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2363 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2364 (match_operand:SI 2 "gpc_reg_operand" ""))
2366 (set (match_operand:SI 0 "gpc_reg_operand" "")
2367 (mult:SI (match_dup 1) (match_dup 2)))
2368 (clobber (match_scratch:SI 4 ""))]
2369 "TARGET_POWER && reload_completed"
2370 [(parallel [(set (match_dup 0)
2371 (mult:SI (match_dup 1) (match_dup 2)))
2372 (clobber (match_dup 4))])
2374 (compare:CC (match_dup 0)
2378 (define_insn "*mulsi3_no_mq_internal2"
2379 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2380 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2381 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2383 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2384 (mult:SI (match_dup 1) (match_dup 2)))]
2387 {muls.|mullw.} %0,%1,%2
2389 [(set_attr "type" "imul_compare")
2390 (set_attr "length" "4,8")])
2393 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2394 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2395 (match_operand:SI 2 "gpc_reg_operand" ""))
2397 (set (match_operand:SI 0 "gpc_reg_operand" "")
2398 (mult:SI (match_dup 1) (match_dup 2)))]
2399 "! TARGET_POWER && reload_completed"
2401 (mult:SI (match_dup 1) (match_dup 2)))
2403 (compare:CC (match_dup 0)
2407 ;; Operand 1 is divided by operand 2; quotient goes to operand
2408 ;; 0 and remainder to operand 3.
2409 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2411 (define_expand "divmodsi4"
2412 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2413 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2414 (match_operand:SI 2 "gpc_reg_operand" "")))
2415 (set (match_operand:SI 3 "register_operand" "")
2416 (mod:SI (match_dup 1) (match_dup 2)))])]
2417 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2420 if (! TARGET_POWER && ! TARGET_POWERPC)
2422 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2423 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2424 emit_insn (gen_divss_call ());
2425 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2426 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2431 (define_insn "*divmodsi4_internal"
2432 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2433 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2434 (match_operand:SI 2 "gpc_reg_operand" "r")))
2435 (set (match_operand:SI 3 "register_operand" "=q")
2436 (mod:SI (match_dup 1) (match_dup 2)))]
2439 [(set_attr "type" "idiv")])
2441 (define_expand "udiv<mode>3"
2442 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2443 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2444 (match_operand:GPR 2 "gpc_reg_operand" "")))]
2445 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2448 if (! TARGET_POWER && ! TARGET_POWERPC)
2450 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2451 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2452 emit_insn (gen_quous_call ());
2453 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2456 else if (TARGET_POWER)
2458 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2463 (define_insn "udivsi3_mq"
2464 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2465 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2466 (match_operand:SI 2 "gpc_reg_operand" "r")))
2467 (clobber (match_scratch:SI 3 "=q"))]
2468 "TARGET_POWERPC && TARGET_POWER"
2470 [(set_attr "type" "idiv")])
2472 (define_insn "*udivsi3_no_mq"
2473 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2474 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2475 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2476 "TARGET_POWERPC && ! TARGET_POWER"
2479 (cond [(match_operand:SI 0 "" "")
2480 (const_string "idiv")]
2481 (const_string "ldiv")))])
2484 ;; For powers of two we can do srai/aze for divide and then adjust for
2485 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2486 ;; used; for PowerPC, force operands into register and do a normal divide;
2487 ;; for AIX common-mode, use quoss call on register operands.
2488 (define_expand "div<mode>3"
2489 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2490 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2491 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2495 if (GET_CODE (operands[2]) == CONST_INT
2496 && INTVAL (operands[2]) > 0
2497 && exact_log2 (INTVAL (operands[2])) >= 0)
2499 else if (TARGET_POWERPC)
2501 operands[2] = force_reg (<MODE>mode, operands[2]);
2504 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2508 else if (TARGET_POWER)
2512 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2513 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2514 emit_insn (gen_quoss_call ());
2515 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2520 (define_insn "divsi3_mq"
2521 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2522 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2523 (match_operand:SI 2 "gpc_reg_operand" "r")))
2524 (clobber (match_scratch:SI 3 "=q"))]
2525 "TARGET_POWERPC && TARGET_POWER"
2527 [(set_attr "type" "idiv")])
2529 (define_insn "*div<mode>3_no_mq"
2530 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2531 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2532 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2533 "TARGET_POWERPC && ! TARGET_POWER"
2536 (cond [(match_operand:SI 0 "" "")
2537 (const_string "idiv")]
2538 (const_string "ldiv")))])
2540 (define_expand "mod<mode>3"
2541 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2542 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2543 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
2551 if (GET_CODE (operands[2]) != CONST_INT
2552 || INTVAL (operands[2]) <= 0
2553 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2556 temp1 = gen_reg_rtx (<MODE>mode);
2557 temp2 = gen_reg_rtx (<MODE>mode);
2559 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2560 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2561 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
2566 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2567 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2568 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
2570 "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
2571 [(set_attr "type" "two")
2572 (set_attr "length" "8")])
2575 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2576 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2577 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2579 (clobber (match_scratch:P 3 "=r,r"))]
2582 {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
2584 [(set_attr "type" "compare")
2585 (set_attr "length" "8,12")])
2588 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2589 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2590 (match_operand:GPR 2 "exact_log2_cint_operand"
2593 (clobber (match_scratch:GPR 3 ""))]
2596 (div:<MODE> (match_dup 1) (match_dup 2)))
2598 (compare:CC (match_dup 3)
2603 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2604 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2605 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2607 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2608 (div:P (match_dup 1) (match_dup 2)))]
2611 {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
2613 [(set_attr "type" "compare")
2614 (set_attr "length" "8,12")])
2617 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2618 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2619 (match_operand:GPR 2 "exact_log2_cint_operand"
2622 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2623 (div:GPR (match_dup 1) (match_dup 2)))]
2626 (div:<MODE> (match_dup 1) (match_dup 2)))
2628 (compare:CC (match_dup 0)
2633 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2636 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2638 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2639 (match_operand:SI 3 "gpc_reg_operand" "r")))
2640 (set (match_operand:SI 2 "register_operand" "=*q")
2643 (zero_extend:DI (match_dup 1)) (const_int 32))
2644 (zero_extend:DI (match_dup 4)))
2648 [(set_attr "type" "idiv")])
2650 ;; To do unsigned divide we handle the cases of the divisor looking like a
2651 ;; negative number. If it is a constant that is less than 2**31, we don't
2652 ;; have to worry about the branches. So make a few subroutines here.
2654 ;; First comes the normal case.
2655 (define_expand "udivmodsi4_normal"
2656 [(set (match_dup 4) (const_int 0))
2657 (parallel [(set (match_operand:SI 0 "" "")
2658 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2660 (zero_extend:DI (match_operand:SI 1 "" "")))
2661 (match_operand:SI 2 "" "")))
2662 (set (match_operand:SI 3 "" "")
2663 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2665 (zero_extend:DI (match_dup 1)))
2669 { operands[4] = gen_reg_rtx (SImode); }")
2671 ;; This handles the branches.
2672 (define_expand "udivmodsi4_tests"
2673 [(set (match_operand:SI 0 "" "") (const_int 0))
2674 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2675 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2676 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2677 (label_ref (match_operand:SI 4 "" "")) (pc)))
2678 (set (match_dup 0) (const_int 1))
2679 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2680 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2681 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2682 (label_ref (match_dup 4)) (pc)))]
2685 { operands[5] = gen_reg_rtx (CCUNSmode);
2686 operands[6] = gen_reg_rtx (CCmode);
2689 (define_expand "udivmodsi4"
2690 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2691 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2692 (match_operand:SI 2 "reg_or_cint_operand" "")))
2693 (set (match_operand:SI 3 "gpc_reg_operand" "")
2694 (umod:SI (match_dup 1) (match_dup 2)))])]
2702 if (! TARGET_POWERPC)
2704 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2705 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2706 emit_insn (gen_divus_call ());
2707 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2708 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2715 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2717 operands[2] = force_reg (SImode, operands[2]);
2718 label = gen_label_rtx ();
2719 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2720 operands[3], label));
2723 operands[2] = force_reg (SImode, operands[2]);
2725 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2733 ;; AIX architecture-independent common-mode multiply (DImode),
2734 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2735 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2736 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2737 ;; assumed unused if generating common-mode, so ignore.
2738 (define_insn "mulh_call"
2741 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2742 (sign_extend:DI (reg:SI 4)))
2744 (clobber (reg:SI LR_REGNO))]
2745 "! TARGET_POWER && ! TARGET_POWERPC"
2747 [(set_attr "type" "imul")])
2749 (define_insn "mull_call"
2751 (mult:DI (sign_extend:DI (reg:SI 3))
2752 (sign_extend:DI (reg:SI 4))))
2753 (clobber (reg:SI LR_REGNO))
2754 (clobber (reg:SI 0))]
2755 "! TARGET_POWER && ! TARGET_POWERPC"
2757 [(set_attr "type" "imul")])
2759 (define_insn "divss_call"
2761 (div:SI (reg:SI 3) (reg:SI 4)))
2763 (mod:SI (reg:SI 3) (reg:SI 4)))
2764 (clobber (reg:SI LR_REGNO))
2765 (clobber (reg:SI 0))]
2766 "! TARGET_POWER && ! TARGET_POWERPC"
2768 [(set_attr "type" "idiv")])
2770 (define_insn "divus_call"
2772 (udiv:SI (reg:SI 3) (reg:SI 4)))
2774 (umod:SI (reg:SI 3) (reg:SI 4)))
2775 (clobber (reg:SI LR_REGNO))
2776 (clobber (reg:SI 0))
2777 (clobber (match_scratch:CC 0 "=x"))
2778 (clobber (reg:CC CR1_REGNO))]
2779 "! TARGET_POWER && ! TARGET_POWERPC"
2781 [(set_attr "type" "idiv")])
2783 (define_insn "quoss_call"
2785 (div:SI (reg:SI 3) (reg:SI 4)))
2786 (clobber (reg:SI LR_REGNO))]
2787 "! TARGET_POWER && ! TARGET_POWERPC"
2789 [(set_attr "type" "idiv")])
2791 (define_insn "quous_call"
2793 (udiv:SI (reg:SI 3) (reg:SI 4)))
2794 (clobber (reg:SI LR_REGNO))
2795 (clobber (reg:SI 0))
2796 (clobber (match_scratch:CC 0 "=x"))
2797 (clobber (reg:CC CR1_REGNO))]
2798 "! TARGET_POWER && ! TARGET_POWERPC"
2800 [(set_attr "type" "idiv")])
2802 ;; Logical instructions
2803 ;; The logical instructions are mostly combined by using match_operator,
2804 ;; but the plain AND insns are somewhat different because there is no
2805 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2806 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2808 (define_insn "andsi3"
2809 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2810 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2811 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2812 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2816 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2817 {andil.|andi.} %0,%1,%b2
2818 {andiu.|andis.} %0,%1,%u2"
2819 [(set_attr "type" "*,*,compare,compare")])
2821 ;; Note to set cr's other than cr0 we do the and immediate and then
2822 ;; the test again -- this avoids a mfcr which on the higher end
2823 ;; machines causes an execution serialization
2825 (define_insn "*andsi3_internal2"
2826 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2827 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2828 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2830 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2831 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2835 {andil.|andi.} %3,%1,%b2
2836 {andiu.|andis.} %3,%1,%u2
2837 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2842 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2843 (set_attr "length" "4,4,4,4,8,8,8,8")])
2845 (define_insn "*andsi3_internal3"
2846 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2847 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2848 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2850 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2851 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2855 {andil.|andi.} %3,%1,%b2
2856 {andiu.|andis.} %3,%1,%u2
2857 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2862 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2863 (set_attr "length" "8,4,4,4,8,8,8,8")])
2866 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2867 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2868 (match_operand:GPR 2 "and_operand" ""))
2870 (clobber (match_scratch:GPR 3 ""))
2871 (clobber (match_scratch:CC 4 ""))]
2873 [(parallel [(set (match_dup 3)
2874 (and:<MODE> (match_dup 1)
2876 (clobber (match_dup 4))])
2878 (compare:CC (match_dup 3)
2882 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2883 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2886 [(set (match_operand:CC 0 "cc_reg_operand" "")
2887 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2888 (match_operand:SI 2 "gpc_reg_operand" ""))
2890 (clobber (match_scratch:SI 3 ""))
2891 (clobber (match_scratch:CC 4 ""))]
2892 "TARGET_POWERPC64 && reload_completed"
2893 [(parallel [(set (match_dup 3)
2894 (and:SI (match_dup 1)
2896 (clobber (match_dup 4))])
2898 (compare:CC (match_dup 3)
2902 (define_insn "*andsi3_internal4"
2903 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2904 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2905 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2907 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2908 (and:SI (match_dup 1)
2910 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2914 {andil.|andi.} %0,%1,%b2
2915 {andiu.|andis.} %0,%1,%u2
2916 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2921 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2922 (set_attr "length" "4,4,4,4,8,8,8,8")])
2924 (define_insn "*andsi3_internal5"
2925 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2926 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2927 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2929 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2930 (and:SI (match_dup 1)
2932 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2936 {andil.|andi.} %0,%1,%b2
2937 {andiu.|andis.} %0,%1,%u2
2938 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2943 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2944 (set_attr "length" "8,4,4,4,8,8,8,8")])
2947 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2948 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2949 (match_operand:SI 2 "and_operand" ""))
2951 (set (match_operand:SI 0 "gpc_reg_operand" "")
2952 (and:SI (match_dup 1)
2954 (clobber (match_scratch:CC 4 ""))]
2956 [(parallel [(set (match_dup 0)
2957 (and:SI (match_dup 1)
2959 (clobber (match_dup 4))])
2961 (compare:CC (match_dup 0)
2966 [(set (match_operand:CC 3 "cc_reg_operand" "")
2967 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2968 (match_operand:SI 2 "gpc_reg_operand" ""))
2970 (set (match_operand:SI 0 "gpc_reg_operand" "")
2971 (and:SI (match_dup 1)
2973 (clobber (match_scratch:CC 4 ""))]
2974 "TARGET_POWERPC64 && reload_completed"
2975 [(parallel [(set (match_dup 0)
2976 (and:SI (match_dup 1)
2978 (clobber (match_dup 4))])
2980 (compare:CC (match_dup 0)
2984 ;; Handle the PowerPC64 rlwinm corner case
2986 (define_insn_and_split "*andsi3_internal6"
2987 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2988 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2989 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2994 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2997 (rotate:SI (match_dup 0) (match_dup 5)))]
3000 int mb = extract_MB (operands[2]);
3001 int me = extract_ME (operands[2]);
3002 operands[3] = GEN_INT (me + 1);
3003 operands[5] = GEN_INT (32 - (me + 1));
3004 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
3006 [(set_attr "length" "8")])
3008 (define_expand "iorsi3"
3009 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3010 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
3011 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
3015 if (GET_CODE (operands[2]) == CONST_INT
3016 && ! logical_operand (operands[2], SImode))
3018 HOST_WIDE_INT value = INTVAL (operands[2]);
3019 rtx tmp = ((!can_create_pseudo_p ()
3020 || rtx_equal_p (operands[0], operands[1]))
3021 ? operands[0] : gen_reg_rtx (SImode));
3023 emit_insn (gen_iorsi3 (tmp, operands[1],
3024 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3025 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3030 (define_expand "xorsi3"
3031 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3032 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
3033 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
3037 if (GET_CODE (operands[2]) == CONST_INT
3038 && ! logical_operand (operands[2], SImode))
3040 HOST_WIDE_INT value = INTVAL (operands[2]);
3041 rtx tmp = ((!can_create_pseudo_p ()
3042 || rtx_equal_p (operands[0], operands[1]))
3043 ? operands[0] : gen_reg_rtx (SImode));
3045 emit_insn (gen_xorsi3 (tmp, operands[1],
3046 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3047 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3052 (define_insn "*boolsi3_internal1"
3053 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
3054 (match_operator:SI 3 "boolean_or_operator"
3055 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
3056 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
3060 {%q3il|%q3i} %0,%1,%b2
3061 {%q3iu|%q3is} %0,%1,%u2")
3063 (define_insn "*boolsi3_internal2"
3064 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3065 (compare:CC (match_operator:SI 4 "boolean_or_operator"
3066 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3067 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3069 (clobber (match_scratch:SI 3 "=r,r"))]
3074 [(set_attr "type" "compare")
3075 (set_attr "length" "4,8")])
3078 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3079 (compare:CC (match_operator:SI 4 "boolean_operator"
3080 [(match_operand:SI 1 "gpc_reg_operand" "")
3081 (match_operand:SI 2 "gpc_reg_operand" "")])
3083 (clobber (match_scratch:SI 3 ""))]
3084 "TARGET_32BIT && reload_completed"
3085 [(set (match_dup 3) (match_dup 4))
3087 (compare:CC (match_dup 3)
3091 (define_insn "*boolsi3_internal3"
3092 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3093 (compare:CC (match_operator:SI 4 "boolean_operator"
3094 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3095 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3097 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3103 [(set_attr "type" "compare")
3104 (set_attr "length" "4,8")])
3107 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3108 (compare:CC (match_operator:SI 4 "boolean_operator"
3109 [(match_operand:SI 1 "gpc_reg_operand" "")
3110 (match_operand:SI 2 "gpc_reg_operand" "")])
3112 (set (match_operand:SI 0 "gpc_reg_operand" "")
3114 "TARGET_32BIT && reload_completed"
3115 [(set (match_dup 0) (match_dup 4))
3117 (compare:CC (match_dup 0)
3121 ;; Split a logical operation that we can't do in one insn into two insns,
3122 ;; each of which does one 16-bit part. This is used by combine.
3125 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3126 (match_operator:SI 3 "boolean_or_operator"
3127 [(match_operand:SI 1 "gpc_reg_operand" "")
3128 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
3130 [(set (match_dup 0) (match_dup 4))
3131 (set (match_dup 0) (match_dup 5))]
3135 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
3136 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3138 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
3139 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3143 (define_insn "*boolcsi3_internal1"
3144 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3145 (match_operator:SI 3 "boolean_operator"
3146 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3147 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
3151 (define_insn "*boolcsi3_internal2"
3152 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3153 (compare:CC (match_operator:SI 4 "boolean_operator"
3154 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3155 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3157 (clobber (match_scratch:SI 3 "=r,r"))]
3162 [(set_attr "type" "compare")
3163 (set_attr "length" "4,8")])
3166 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3167 (compare:CC (match_operator:SI 4 "boolean_operator"
3168 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3169 (match_operand:SI 2 "gpc_reg_operand" "")])
3171 (clobber (match_scratch:SI 3 ""))]
3172 "TARGET_32BIT && reload_completed"
3173 [(set (match_dup 3) (match_dup 4))
3175 (compare:CC (match_dup 3)
3179 (define_insn "*boolcsi3_internal3"
3180 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3181 (compare:CC (match_operator:SI 4 "boolean_operator"
3182 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3183 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3185 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3191 [(set_attr "type" "compare")
3192 (set_attr "length" "4,8")])
3195 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3196 (compare:CC (match_operator:SI 4 "boolean_operator"
3197 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3198 (match_operand:SI 2 "gpc_reg_operand" "")])
3200 (set (match_operand:SI 0 "gpc_reg_operand" "")
3202 "TARGET_32BIT && reload_completed"
3203 [(set (match_dup 0) (match_dup 4))
3205 (compare:CC (match_dup 0)
3209 (define_insn "*boolccsi3_internal1"
3210 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3211 (match_operator:SI 3 "boolean_operator"
3212 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3213 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3217 (define_insn "*boolccsi3_internal2"
3218 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3219 (compare:CC (match_operator:SI 4 "boolean_operator"
3220 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3221 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3223 (clobber (match_scratch:SI 3 "=r,r"))]
3228 [(set_attr "type" "compare")
3229 (set_attr "length" "4,8")])
3232 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3233 (compare:CC (match_operator:SI 4 "boolean_operator"
3234 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3235 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3237 (clobber (match_scratch:SI 3 ""))]
3238 "TARGET_32BIT && reload_completed"
3239 [(set (match_dup 3) (match_dup 4))
3241 (compare:CC (match_dup 3)
3245 (define_insn "*boolccsi3_internal3"
3246 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3247 (compare:CC (match_operator:SI 4 "boolean_operator"
3248 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3249 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3251 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3257 [(set_attr "type" "compare")
3258 (set_attr "length" "4,8")])
3261 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3262 (compare:CC (match_operator:SI 4 "boolean_operator"
3263 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3264 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3266 (set (match_operand:SI 0 "gpc_reg_operand" "")
3268 "TARGET_32BIT && reload_completed"
3269 [(set (match_dup 0) (match_dup 4))
3271 (compare:CC (match_dup 0)
3275 ;; maskir insn. We need four forms because things might be in arbitrary
3276 ;; orders. Don't define forms that only set CR fields because these