1 ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
2 ;; Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
4 ;; Free Software Foundation, Inc.
5 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
7 ;; This file is part of GCC.
9 ;; GCC is free software; you can redistribute it and/or modify it
10 ;; under the terms of the GNU General Public License as published
11 ;; by the Free Software Foundation; either version 2, or (at your
12 ;; option) any later version.
14 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
15 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 ;; License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
22 ;; MA 02110-1301, USA.
24 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
31 [(UNSPEC_FRSP 0) ; frsp for POWER machines
32 (UNSPEC_TIE 5) ; tie stack contents and stack pointer
33 (UNSPEC_TOCPTR 6) ; address of a word pointing to the TOC
34 (UNSPEC_TOC 7) ; address of the TOC (more-or-less)
36 (UNSPEC_MV_CR_OV 9) ; move_from_CR_ov_bit
42 (UNSPEC_LD_MPIC 15) ; load_macho_picbase
43 (UNSPEC_MPIC_CORRECT 16) ; macho_correct_pic
46 (UNSPEC_MOVESI_FROM_CR 19)
47 (UNSPEC_MOVESI_TO_CR 20)
49 (UNSPEC_TLSDTPRELHA 22)
50 (UNSPEC_TLSDTPRELLO 23)
51 (UNSPEC_TLSGOTDTPREL 24)
53 (UNSPEC_TLSTPRELHA 26)
54 (UNSPEC_TLSTPRELLO 27)
55 (UNSPEC_TLSGOTTPREL 28)
57 (UNSPEC_FIX_TRUNC_TF 30) ; fadd, rounding towards zero
58 (UNSPEC_MV_CR_GT 31) ; move_from_CR_eq_bit
74 (UNSPEC_DLMZB_STRLEN 47)
78 ;; UNSPEC_VOLATILE usage
83 (UNSPECV_LL 1) ; load-locked
84 (UNSPECV_SC 2) ; store-conditional
85 (UNSPECV_EH_RR 9) ; eh_reg_restore
88 ;; Define an insn type attribute. This is used in function unit delay
90 (define_attr "type" "integer,two,three,load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,store,store_ux,store_u,fpload,fpload_ux,fpload_u,fpstore,fpstore_ux,fpstore_u,vecload,vecstore,imul,imul2,imul3,lmul,idiv,ldiv,insert_word,branch,cmp,fast_compare,compare,delayed_compare,imul_compare,lmul_compare,fpcompare,cr_logical,delayed_cr,mfcr,mfcrf,mtcr,mfjmpr,mtjmpr,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg,brinc,vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,vecfloat,vecfdiv,isync,sync,load_l,store_c"
91 (const_string "integer"))
94 ; '(pc)' in the following doesn't include the instruction itself; it is
95 ; calculated as if the instruction had zero size.
96 (define_attr "length" ""
97 (if_then_else (eq_attr "type" "branch")
98 (if_then_else (and (ge (minus (match_dup 0) (pc))
100 (lt (minus (match_dup 0) (pc))
106 ;; Processor type -- this attribute must exactly match the processor_type
107 ;; enumeration in rs6000.h.
109 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4,power5"
110 (const (symbol_ref "rs6000_cpu_attr")))
112 (automata_option "ndfa")
125 (include "power4.md")
126 (include "power5.md")
128 (include "predicates.md")
129 (include "constraints.md")
131 (include "darwin.md")
136 ; This mode macro allows :GPR to be used to indicate the allowable size
137 ; of whole values in GPRs.
138 (define_mode_macro GPR [SI (DI "TARGET_POWERPC64")])
140 ; Any supported integer mode.
141 (define_mode_macro INT [QI HI SI DI TI])
143 ; Any supported integer mode that fits in one register.
144 (define_mode_macro INT1 [QI HI SI (DI "TARGET_POWERPC64")])
146 ; extend modes for DImode
147 (define_mode_macro QHSI [QI HI SI])
149 ; SImode or DImode, even if DImode doesn't fit in GPRs.
150 (define_mode_macro SDI [SI DI])
152 ; The size of a pointer. Also, the size of the value that a record-condition
153 ; (one with a '.') will compare.
154 (define_mode_macro P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
156 ; Any hardware-supported floating-point mode
157 (define_mode_macro FP [(SF "TARGET_HARD_FLOAT")
158 (DF "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)")
159 (TF "!TARGET_IEEEQUAD
160 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128")])
162 ; Various instructions that come in SI and DI forms.
163 ; A generic w/d attribute, for things like cmpw/cmpd.
164 (define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
167 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
170 ;; Start with fixed-point load and store insns. Here we put only the more
171 ;; complex forms. Basic data transfer is done later.
173 (define_expand "zero_extend<mode>di2"
174 [(set (match_operand:DI 0 "gpc_reg_operand" "")
175 (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "")))]
179 (define_insn "*zero_extend<mode>di2_internal1"
180 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
181 (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
185 rldicl %0,%1,0,<dbits>"
186 [(set_attr "type" "load,*")])
188 (define_insn "*zero_extend<mode>di2_internal2"
189 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
190 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
192 (clobber (match_scratch:DI 2 "=r,r"))]
195 rldicl. %2,%1,0,<dbits>
197 [(set_attr "type" "compare")
198 (set_attr "length" "4,8")])
201 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
202 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
204 (clobber (match_scratch:DI 2 ""))]
205 "TARGET_POWERPC64 && reload_completed"
207 (zero_extend:DI (match_dup 1)))
209 (compare:CC (match_dup 2)
213 (define_insn "*zero_extend<mode>di2_internal3"
214 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
215 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
217 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
218 (zero_extend:DI (match_dup 1)))]
221 rldicl. %0,%1,0,<dbits>
223 [(set_attr "type" "compare")
224 (set_attr "length" "4,8")])
227 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
228 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
230 (set (match_operand:DI 0 "gpc_reg_operand" "")
231 (zero_extend:DI (match_dup 1)))]
232 "TARGET_POWERPC64 && reload_completed"
234 (zero_extend:DI (match_dup 1)))
236 (compare:CC (match_dup 0)
240 (define_insn "extendqidi2"
241 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
242 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
247 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
248 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
250 (clobber (match_scratch:DI 2 "=r,r"))]
255 [(set_attr "type" "compare")
256 (set_attr "length" "4,8")])
259 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
260 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
262 (clobber (match_scratch:DI 2 ""))]
263 "TARGET_POWERPC64 && reload_completed"
265 (sign_extend:DI (match_dup 1)))
267 (compare:CC (match_dup 2)
272 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
273 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
275 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
276 (sign_extend:DI (match_dup 1)))]
281 [(set_attr "type" "compare")
282 (set_attr "length" "4,8")])
285 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
286 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
288 (set (match_operand:DI 0 "gpc_reg_operand" "")
289 (sign_extend:DI (match_dup 1)))]
290 "TARGET_POWERPC64 && reload_completed"
292 (sign_extend:DI (match_dup 1)))
294 (compare:CC (match_dup 0)
298 (define_expand "extendhidi2"
299 [(set (match_operand:DI 0 "gpc_reg_operand" "")
300 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
305 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
306 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
311 [(set_attr "type" "load_ext,*")])
314 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
315 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
317 (clobber (match_scratch:DI 2 "=r,r"))]
322 [(set_attr "type" "compare")
323 (set_attr "length" "4,8")])
326 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
327 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
329 (clobber (match_scratch:DI 2 ""))]
330 "TARGET_POWERPC64 && reload_completed"
332 (sign_extend:DI (match_dup 1)))
334 (compare:CC (match_dup 2)
339 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
340 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
342 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
343 (sign_extend:DI (match_dup 1)))]
348 [(set_attr "type" "compare")
349 (set_attr "length" "4,8")])
352 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
353 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
355 (set (match_operand:DI 0 "gpc_reg_operand" "")
356 (sign_extend:DI (match_dup 1)))]
357 "TARGET_POWERPC64 && reload_completed"
359 (sign_extend:DI (match_dup 1)))
361 (compare:CC (match_dup 0)
365 (define_expand "extendsidi2"
366 [(set (match_operand:DI 0 "gpc_reg_operand" "")
367 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
372 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
373 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
378 [(set_attr "type" "load_ext,*")])
381 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
382 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
384 (clobber (match_scratch:DI 2 "=r,r"))]
389 [(set_attr "type" "compare")
390 (set_attr "length" "4,8")])
393 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
394 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
396 (clobber (match_scratch:DI 2 ""))]
397 "TARGET_POWERPC64 && reload_completed"
399 (sign_extend:DI (match_dup 1)))
401 (compare:CC (match_dup 2)
406 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
407 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
409 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
410 (sign_extend:DI (match_dup 1)))]
415 [(set_attr "type" "compare")
416 (set_attr "length" "4,8")])
419 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
420 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
422 (set (match_operand:DI 0 "gpc_reg_operand" "")
423 (sign_extend:DI (match_dup 1)))]
424 "TARGET_POWERPC64 && reload_completed"
426 (sign_extend:DI (match_dup 1)))
428 (compare:CC (match_dup 0)
432 (define_expand "zero_extendqisi2"
433 [(set (match_operand:SI 0 "gpc_reg_operand" "")
434 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
439 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
440 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
444 {rlinm|rlwinm} %0,%1,0,0xff"
445 [(set_attr "type" "load,*")])
448 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
449 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
451 (clobber (match_scratch:SI 2 "=r,r"))]
454 {andil.|andi.} %2,%1,0xff
456 [(set_attr "type" "compare")
457 (set_attr "length" "4,8")])
460 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
461 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
463 (clobber (match_scratch:SI 2 ""))]
466 (zero_extend:SI (match_dup 1)))
468 (compare:CC (match_dup 2)
473 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
474 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
476 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
477 (zero_extend:SI (match_dup 1)))]
480 {andil.|andi.} %0,%1,0xff
482 [(set_attr "type" "compare")
483 (set_attr "length" "4,8")])
486 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
487 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
489 (set (match_operand:SI 0 "gpc_reg_operand" "")
490 (zero_extend:SI (match_dup 1)))]
493 (zero_extend:SI (match_dup 1)))
495 (compare:CC (match_dup 0)
499 (define_expand "extendqisi2"
500 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
501 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
506 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
507 else if (TARGET_POWER)
508 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
510 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
514 (define_insn "extendqisi2_ppc"
515 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
516 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
521 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
522 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
524 (clobber (match_scratch:SI 2 "=r,r"))]
529 [(set_attr "type" "compare")
530 (set_attr "length" "4,8")])
533 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
534 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
536 (clobber (match_scratch:SI 2 ""))]
537 "TARGET_POWERPC && reload_completed"
539 (sign_extend:SI (match_dup 1)))
541 (compare:CC (match_dup 2)
546 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
547 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
549 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
550 (sign_extend:SI (match_dup 1)))]
555 [(set_attr "type" "compare")
556 (set_attr "length" "4,8")])
559 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
560 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
562 (set (match_operand:SI 0 "gpc_reg_operand" "")
563 (sign_extend:SI (match_dup 1)))]
564 "TARGET_POWERPC && reload_completed"
566 (sign_extend:SI (match_dup 1)))
568 (compare:CC (match_dup 0)
572 (define_expand "extendqisi2_power"
573 [(parallel [(set (match_dup 2)
574 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
576 (clobber (scratch:SI))])
577 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
578 (ashiftrt:SI (match_dup 2)
580 (clobber (scratch:SI))])]
583 { operands[1] = gen_lowpart (SImode, operands[1]);
584 operands[2] = gen_reg_rtx (SImode); }")
586 (define_expand "extendqisi2_no_power"
588 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
590 (set (match_operand:SI 0 "gpc_reg_operand" "")
591 (ashiftrt:SI (match_dup 2)
593 "! TARGET_POWER && ! TARGET_POWERPC"
595 { operands[1] = gen_lowpart (SImode, operands[1]);
596 operands[2] = gen_reg_rtx (SImode); }")
598 (define_expand "zero_extendqihi2"
599 [(set (match_operand:HI 0 "gpc_reg_operand" "")
600 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
605 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
606 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
610 {rlinm|rlwinm} %0,%1,0,0xff"
611 [(set_attr "type" "load,*")])
614 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
615 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
617 (clobber (match_scratch:HI 2 "=r,r"))]
620 {andil.|andi.} %2,%1,0xff
622 [(set_attr "type" "compare")
623 (set_attr "length" "4,8")])
626 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
627 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
629 (clobber (match_scratch:HI 2 ""))]
632 (zero_extend:HI (match_dup 1)))
634 (compare:CC (match_dup 2)
639 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
640 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
642 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
643 (zero_extend:HI (match_dup 1)))]
646 {andil.|andi.} %0,%1,0xff
648 [(set_attr "type" "compare")
649 (set_attr "length" "4,8")])
652 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
653 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
655 (set (match_operand:HI 0 "gpc_reg_operand" "")
656 (zero_extend:HI (match_dup 1)))]
659 (zero_extend:HI (match_dup 1)))
661 (compare:CC (match_dup 0)
665 (define_expand "extendqihi2"
666 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
667 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
672 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
673 else if (TARGET_POWER)
674 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
676 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
680 (define_insn "extendqihi2_ppc"
681 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
682 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
687 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
688 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
690 (clobber (match_scratch:HI 2 "=r,r"))]
695 [(set_attr "type" "compare")
696 (set_attr "length" "4,8")])
699 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
700 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
702 (clobber (match_scratch:HI 2 ""))]
703 "TARGET_POWERPC && reload_completed"
705 (sign_extend:HI (match_dup 1)))
707 (compare:CC (match_dup 2)
712 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
713 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
715 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
716 (sign_extend:HI (match_dup 1)))]
721 [(set_attr "type" "compare")
722 (set_attr "length" "4,8")])
725 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
726 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
728 (set (match_operand:HI 0 "gpc_reg_operand" "")
729 (sign_extend:HI (match_dup 1)))]
730 "TARGET_POWERPC && reload_completed"
732 (sign_extend:HI (match_dup 1)))
734 (compare:CC (match_dup 0)
738 (define_expand "extendqihi2_power"
739 [(parallel [(set (match_dup 2)
740 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
742 (clobber (scratch:SI))])
743 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
744 (ashiftrt:SI (match_dup 2)
746 (clobber (scratch:SI))])]
749 { operands[0] = gen_lowpart (SImode, operands[0]);
750 operands[1] = gen_lowpart (SImode, operands[1]);
751 operands[2] = gen_reg_rtx (SImode); }")
753 (define_expand "extendqihi2_no_power"
755 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
757 (set (match_operand:HI 0 "gpc_reg_operand" "")
758 (ashiftrt:SI (match_dup 2)
760 "! TARGET_POWER && ! TARGET_POWERPC"
762 { operands[0] = gen_lowpart (SImode, operands[0]);
763 operands[1] = gen_lowpart (SImode, operands[1]);
764 operands[2] = gen_reg_rtx (SImode); }")
766 (define_expand "zero_extendhisi2"
767 [(set (match_operand:SI 0 "gpc_reg_operand" "")
768 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
773 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
774 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
778 {rlinm|rlwinm} %0,%1,0,0xffff"
779 [(set_attr "type" "load,*")])
782 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
783 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
785 (clobber (match_scratch:SI 2 "=r,r"))]
788 {andil.|andi.} %2,%1,0xffff
790 [(set_attr "type" "compare")
791 (set_attr "length" "4,8")])
794 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
795 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
797 (clobber (match_scratch:SI 2 ""))]
800 (zero_extend:SI (match_dup 1)))
802 (compare:CC (match_dup 2)
807 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
808 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
810 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
811 (zero_extend:SI (match_dup 1)))]
814 {andil.|andi.} %0,%1,0xffff
816 [(set_attr "type" "compare")
817 (set_attr "length" "4,8")])
820 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
821 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
823 (set (match_operand:SI 0 "gpc_reg_operand" "")
824 (zero_extend:SI (match_dup 1)))]
827 (zero_extend:SI (match_dup 1)))
829 (compare:CC (match_dup 0)
833 (define_expand "extendhisi2"
834 [(set (match_operand:SI 0 "gpc_reg_operand" "")
835 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
840 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
841 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
846 [(set_attr "type" "load_ext,*")])
849 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
850 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
852 (clobber (match_scratch:SI 2 "=r,r"))]
857 [(set_attr "type" "compare")
858 (set_attr "length" "4,8")])
861 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
862 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
864 (clobber (match_scratch:SI 2 ""))]
867 (sign_extend:SI (match_dup 1)))
869 (compare:CC (match_dup 2)
874 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
875 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
877 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
878 (sign_extend:SI (match_dup 1)))]
883 [(set_attr "type" "compare")
884 (set_attr "length" "4,8")])
886 ;; IBM 405 and 440 half-word multiplication operations.
888 (define_insn "*macchwc"
889 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
890 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
891 (match_operand:SI 2 "gpc_reg_operand" "r")
894 (match_operand:HI 1 "gpc_reg_operand" "r")))
895 (match_operand:SI 4 "gpc_reg_operand" "0"))
897 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
898 (plus:SI (mult:SI (ashiftrt:SI
906 [(set_attr "type" "imul3")])
908 (define_insn "*macchw"
909 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
910 (plus:SI (mult:SI (ashiftrt:SI
911 (match_operand:SI 2 "gpc_reg_operand" "r")
914 (match_operand:HI 1 "gpc_reg_operand" "r")))
915 (match_operand:SI 3 "gpc_reg_operand" "0")))]
918 [(set_attr "type" "imul3")])
920 (define_insn "*macchwuc"
921 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
922 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
923 (match_operand:SI 2 "gpc_reg_operand" "r")
926 (match_operand:HI 1 "gpc_reg_operand" "r")))
927 (match_operand:SI 4 "gpc_reg_operand" "0"))
929 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
930 (plus:SI (mult:SI (lshiftrt:SI
937 "macchwu. %0, %1, %2"
938 [(set_attr "type" "imul3")])
940 (define_insn "*macchwu"
941 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
942 (plus:SI (mult:SI (lshiftrt:SI
943 (match_operand:SI 2 "gpc_reg_operand" "r")
946 (match_operand:HI 1 "gpc_reg_operand" "r")))
947 (match_operand:SI 3 "gpc_reg_operand" "0")))]
950 [(set_attr "type" "imul3")])
952 (define_insn "*machhwc"
953 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
954 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
955 (match_operand:SI 1 "gpc_reg_operand" "%r")
958 (match_operand:SI 2 "gpc_reg_operand" "r")
960 (match_operand:SI 4 "gpc_reg_operand" "0"))
962 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
963 (plus:SI (mult:SI (ashiftrt:SI
972 [(set_attr "type" "imul3")])
974 (define_insn "*machhw"
975 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
976 (plus:SI (mult:SI (ashiftrt:SI
977 (match_operand:SI 1 "gpc_reg_operand" "%r")
980 (match_operand:SI 2 "gpc_reg_operand" "r")
982 (match_operand:SI 3 "gpc_reg_operand" "0")))]
985 [(set_attr "type" "imul3")])
987 (define_insn "*machhwuc"
988 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
989 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
990 (match_operand:SI 1 "gpc_reg_operand" "%r")
993 (match_operand:SI 2 "gpc_reg_operand" "r")
995 (match_operand:SI 4 "gpc_reg_operand" "0"))
997 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
998 (plus:SI (mult:SI (lshiftrt:SI
1006 "machhwu. %0, %1, %2"
1007 [(set_attr "type" "imul3")])
1009 (define_insn "*machhwu"
1010 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1011 (plus:SI (mult:SI (lshiftrt:SI
1012 (match_operand:SI 1 "gpc_reg_operand" "%r")
1015 (match_operand:SI 2 "gpc_reg_operand" "r")
1017 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1019 "machhwu %0, %1, %2"
1020 [(set_attr "type" "imul3")])
1022 (define_insn "*maclhwc"
1023 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1024 (compare:CC (plus:SI (mult:SI (sign_extend:SI
1025 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1027 (match_operand:HI 2 "gpc_reg_operand" "r")))
1028 (match_operand:SI 4 "gpc_reg_operand" "0"))
1030 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1031 (plus:SI (mult:SI (sign_extend:SI
1037 "maclhw. %0, %1, %2"
1038 [(set_attr "type" "imul3")])
1040 (define_insn "*maclhw"
1041 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1042 (plus:SI (mult:SI (sign_extend:SI
1043 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1045 (match_operand:HI 2 "gpc_reg_operand" "r")))
1046 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1049 [(set_attr "type" "imul3")])
1051 (define_insn "*maclhwuc"
1052 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1053 (compare:CC (plus:SI (mult:SI (zero_extend:SI
1054 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1056 (match_operand:HI 2 "gpc_reg_operand" "r")))
1057 (match_operand:SI 4 "gpc_reg_operand" "0"))
1059 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1060 (plus:SI (mult:SI (zero_extend:SI
1066 "maclhwu. %0, %1, %2"
1067 [(set_attr "type" "imul3")])
1069 (define_insn "*maclhwu"
1070 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1071 (plus:SI (mult:SI (zero_extend:SI
1072 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1074 (match_operand:HI 2 "gpc_reg_operand" "r")))
1075 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1077 "maclhwu %0, %1, %2"
1078 [(set_attr "type" "imul3")])
1080 (define_insn "*nmacchwc"
1081 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1082 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1083 (mult:SI (ashiftrt:SI
1084 (match_operand:SI 2 "gpc_reg_operand" "r")
1087 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1089 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1090 (minus:SI (match_dup 4)
1091 (mult:SI (ashiftrt:SI
1097 "nmacchw. %0, %1, %2"
1098 [(set_attr "type" "imul3")])
1100 (define_insn "*nmacchw"
1101 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1102 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1103 (mult:SI (ashiftrt:SI
1104 (match_operand:SI 2 "gpc_reg_operand" "r")
1107 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1109 "nmacchw %0, %1, %2"
1110 [(set_attr "type" "imul3")])
1112 (define_insn "*nmachhwc"
1113 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1114 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1115 (mult:SI (ashiftrt:SI
1116 (match_operand:SI 1 "gpc_reg_operand" "%r")
1119 (match_operand:SI 2 "gpc_reg_operand" "r")
1122 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1123 (minus:SI (match_dup 4)
1124 (mult:SI (ashiftrt:SI
1131 "nmachhw. %0, %1, %2"
1132 [(set_attr "type" "imul3")])
1134 (define_insn "*nmachhw"
1135 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1136 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1137 (mult:SI (ashiftrt:SI
1138 (match_operand:SI 1 "gpc_reg_operand" "%r")
1141 (match_operand:SI 2 "gpc_reg_operand" "r")
1144 "nmachhw %0, %1, %2"
1145 [(set_attr "type" "imul3")])
1147 (define_insn "*nmaclhwc"
1148 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1149 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1150 (mult:SI (sign_extend:SI
1151 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1153 (match_operand:HI 2 "gpc_reg_operand" "r"))))
1155 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1156 (minus:SI (match_dup 4)
1157 (mult:SI (sign_extend:SI
1162 "nmaclhw. %0, %1, %2"
1163 [(set_attr "type" "imul3")])
1165 (define_insn "*nmaclhw"
1166 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1167 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1168 (mult:SI (sign_extend:SI
1169 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1171 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1173 "nmaclhw %0, %1, %2"
1174 [(set_attr "type" "imul3")])
1176 (define_insn "*mulchwc"
1177 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1178 (compare:CC (mult:SI (ashiftrt:SI
1179 (match_operand:SI 2 "gpc_reg_operand" "r")
1182 (match_operand:HI 1 "gpc_reg_operand" "r")))
1184 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1185 (mult:SI (ashiftrt:SI
1191 "mulchw. %0, %1, %2"
1192 [(set_attr "type" "imul3")])
1194 (define_insn "*mulchw"
1195 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1196 (mult:SI (ashiftrt:SI
1197 (match_operand:SI 2 "gpc_reg_operand" "r")
1200 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1203 [(set_attr "type" "imul3")])
1205 (define_insn "*mulchwuc"
1206 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1207 (compare:CC (mult:SI (lshiftrt:SI
1208 (match_operand:SI 2 "gpc_reg_operand" "r")
1211 (match_operand:HI 1 "gpc_reg_operand" "r")))
1213 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1214 (mult:SI (lshiftrt:SI
1220 "mulchwu. %0, %1, %2"
1221 [(set_attr "type" "imul3")])
1223 (define_insn "*mulchwu"
1224 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1225 (mult:SI (lshiftrt:SI
1226 (match_operand:SI 2 "gpc_reg_operand" "r")
1229 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1231 "mulchwu %0, %1, %2"
1232 [(set_attr "type" "imul3")])
1234 (define_insn "*mulhhwc"
1235 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1236 (compare:CC (mult:SI (ashiftrt:SI
1237 (match_operand:SI 1 "gpc_reg_operand" "%r")
1240 (match_operand:SI 2 "gpc_reg_operand" "r")
1243 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1244 (mult:SI (ashiftrt:SI
1251 "mulhhw. %0, %1, %2"
1252 [(set_attr "type" "imul3")])
1254 (define_insn "*mulhhw"
1255 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1256 (mult:SI (ashiftrt:SI
1257 (match_operand:SI 1 "gpc_reg_operand" "%r")
1260 (match_operand:SI 2 "gpc_reg_operand" "r")
1264 [(set_attr "type" "imul3")])
1266 (define_insn "*mulhhwuc"
1267 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1268 (compare:CC (mult:SI (lshiftrt:SI
1269 (match_operand:SI 1 "gpc_reg_operand" "%r")
1272 (match_operand:SI 2 "gpc_reg_operand" "r")
1275 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1276 (mult:SI (lshiftrt:SI
1283 "mulhhwu. %0, %1, %2"
1284 [(set_attr "type" "imul3")])
1286 (define_insn "*mulhhwu"
1287 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1288 (mult:SI (lshiftrt:SI
1289 (match_operand:SI 1 "gpc_reg_operand" "%r")
1292 (match_operand:SI 2 "gpc_reg_operand" "r")
1295 "mulhhwu %0, %1, %2"
1296 [(set_attr "type" "imul3")])
1298 (define_insn "*mullhwc"
1299 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1300 (compare:CC (mult:SI (sign_extend:SI
1301 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1303 (match_operand:HI 2 "gpc_reg_operand" "r")))
1305 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1306 (mult:SI (sign_extend:SI
1311 "mullhw. %0, %1, %2"
1312 [(set_attr "type" "imul3")])
1314 (define_insn "*mullhw"
1315 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1316 (mult:SI (sign_extend:SI
1317 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1319 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1322 [(set_attr "type" "imul3")])
1324 (define_insn "*mullhwuc"
1325 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1326 (compare:CC (mult:SI (zero_extend:SI
1327 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1329 (match_operand:HI 2 "gpc_reg_operand" "r")))
1331 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1332 (mult:SI (zero_extend:SI
1337 "mullhwu. %0, %1, %2"
1338 [(set_attr "type" "imul3")])
1340 (define_insn "*mullhwu"
1341 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1342 (mult:SI (zero_extend:SI
1343 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1345 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1347 "mullhwu %0, %1, %2"
1348 [(set_attr "type" "imul3")])
1350 ;; IBM 405 and 440 string-search dlmzb instruction support.
1351 (define_insn "dlmzb"
1352 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1353 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1354 (match_operand:SI 2 "gpc_reg_operand" "r")]
1356 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1357 (unspec:SI [(match_dup 1)
1361 "dlmzb. %0, %1, %2")
1363 (define_expand "strlensi"
1364 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1365 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1366 (match_operand:QI 2 "const_int_operand" "")
1367 (match_operand 3 "const_int_operand" "")]
1368 UNSPEC_DLMZB_STRLEN))
1369 (clobber (match_scratch:CC 4 "=x"))]
1370 "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1372 rtx result = operands[0];
1373 rtx src = operands[1];
1374 rtx search_char = operands[2];
1375 rtx align = operands[3];
1376 rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1377 rtx loop_label, end_label, mem, cr0, cond;
1378 if (search_char != const0_rtx
1379 || GET_CODE (align) != CONST_INT
1380 || INTVAL (align) < 8)
1382 word1 = gen_reg_rtx (SImode);
1383 word2 = gen_reg_rtx (SImode);
1384 scratch_dlmzb = gen_reg_rtx (SImode);
1385 scratch_string = gen_reg_rtx (Pmode);
1386 loop_label = gen_label_rtx ();
1387 end_label = gen_label_rtx ();
1388 addr = force_reg (Pmode, XEXP (src, 0));
1389 emit_move_insn (scratch_string, addr);
1390 emit_label (loop_label);
1391 mem = change_address (src, SImode, scratch_string);
1392 emit_move_insn (word1, mem);
1393 emit_move_insn (word2, adjust_address (mem, SImode, 4));
1394 cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1395 emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1396 cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1397 emit_jump_insn (gen_rtx_SET (VOIDmode,
1399 gen_rtx_IF_THEN_ELSE (VOIDmode,
1405 emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1406 emit_jump_insn (gen_rtx_SET (VOIDmode,
1408 gen_rtx_LABEL_REF (VOIDmode, loop_label)));
1410 emit_label (end_label);
1411 emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1412 emit_insn (gen_subsi3 (result, scratch_string, addr));
1413 emit_insn (gen_subsi3 (result, result, const1_rtx));
1418 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1419 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1421 (set (match_operand:SI 0 "gpc_reg_operand" "")
1422 (sign_extend:SI (match_dup 1)))]
1425 (sign_extend:SI (match_dup 1)))
1427 (compare:CC (match_dup 0)
1431 ;; Fixed-point arithmetic insns.
1433 (define_expand "add<mode>3"
1434 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1435 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1436 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1439 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1441 if (non_short_cint_operand (operands[2], DImode))
1444 else if (GET_CODE (operands[2]) == CONST_INT
1445 && ! add_operand (operands[2], <MODE>mode))
1447 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
1448 ? operands[0] : gen_reg_rtx (<MODE>mode));
1450 HOST_WIDE_INT val = INTVAL (operands[2]);
1451 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1452 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1454 if (<MODE>mode == DImode && !satisfies_constraint_L (GEN_INT (rest)))
1457 /* The ordering here is important for the prolog expander.
1458 When space is allocated from the stack, adding 'low' first may
1459 produce a temporary deallocation (which would be bad). */
1460 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1461 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1466 ;; Discourage ai/addic because of carry but provide it in an alternative
1467 ;; allowing register zero as source.
1468 (define_insn "*add<mode>3_internal1"
1469 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1470 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1471 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
1475 {cal %0,%2(%1)|addi %0,%1,%2}
1477 {cau|addis} %0,%1,%v2"
1478 [(set_attr "length" "4,4,4,4")])
1480 (define_insn "addsi3_high"
1481 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1482 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1483 (high:SI (match_operand 2 "" ""))))]
1484 "TARGET_MACHO && !TARGET_64BIT"
1485 "{cau|addis} %0,%1,ha16(%2)"
1486 [(set_attr "length" "4")])
1488 (define_insn "*add<mode>3_internal2"
1489 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1490 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1491 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1493 (clobber (match_scratch:P 3 "=r,r,r,r"))]
1496 {cax.|add.} %3,%1,%2
1497 {ai.|addic.} %3,%1,%2
1500 [(set_attr "type" "fast_compare,compare,compare,compare")
1501 (set_attr "length" "4,4,8,8")])
1504 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1505 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1506 (match_operand:GPR 2 "reg_or_short_operand" ""))
1508 (clobber (match_scratch:GPR 3 ""))]
1511 (plus:GPR (match_dup 1)
1514 (compare:CC (match_dup 3)
1518 (define_insn "*add<mode>3_internal3"
1519 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1520 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1521 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1523 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1524 (plus:P (match_dup 1)
1528 {cax.|add.} %0,%1,%2
1529 {ai.|addic.} %0,%1,%2
1532 [(set_attr "type" "fast_compare,compare,compare,compare")
1533 (set_attr "length" "4,4,8,8")])
1536 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1537 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1538 (match_operand:P 2 "reg_or_short_operand" ""))
1540 (set (match_operand:P 0 "gpc_reg_operand" "")
1541 (plus:P (match_dup 1) (match_dup 2)))]
1544 (plus:P (match_dup 1)
1547 (compare:CC (match_dup 0)
1551 ;; Split an add that we can't do in one insn into two insns, each of which
1552 ;; does one 16-bit part. This is used by combine. Note that the low-order
1553 ;; add should be last in case the result gets used in an address.
1556 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1557 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1558 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1560 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1561 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1563 HOST_WIDE_INT val = INTVAL (operands[2]);
1564 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1565 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1567 operands[4] = GEN_INT (low);
1568 if (<MODE>mode == SImode || satisfies_constraint_L (GEN_INT (rest)))
1569 operands[3] = GEN_INT (rest);
1570 else if (! no_new_pseudos)
1572 operands[3] = gen_reg_rtx (DImode);
1573 emit_move_insn (operands[3], operands[2]);
1574 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1581 (define_insn "one_cmpl<mode>2"
1582 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1583 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1588 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1589 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1591 (clobber (match_scratch:P 2 "=r,r"))]
1596 [(set_attr "type" "compare")
1597 (set_attr "length" "4,8")])
1600 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1601 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1603 (clobber (match_scratch:P 2 ""))]
1606 (not:P (match_dup 1)))
1608 (compare:CC (match_dup 2)
1613 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1614 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1616 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1617 (not:P (match_dup 1)))]
1622 [(set_attr "type" "compare")
1623 (set_attr "length" "4,8")])
1626 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1627 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1629 (set (match_operand:P 0 "gpc_reg_operand" "")
1630 (not:P (match_dup 1)))]
1633 (not:P (match_dup 1)))
1635 (compare:CC (match_dup 0)
1640 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1641 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1642 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1644 "{sf%I1|subf%I1c} %0,%2,%1")
1647 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1648 (minus:GPR (match_operand:GPR 1 "reg_or_short_operand" "r,I")
1649 (match_operand:GPR 2 "gpc_reg_operand" "r,r")))]
1656 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1657 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1658 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1660 (clobber (match_scratch:SI 3 "=r,r"))]
1663 {sf.|subfc.} %3,%2,%1
1665 [(set_attr "type" "compare")
1666 (set_attr "length" "4,8")])
1669 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1670 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1671 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1673 (clobber (match_scratch:P 3 "=r,r"))]
1678 [(set_attr "type" "fast_compare")
1679 (set_attr "length" "4,8")])
1682 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1683 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1684 (match_operand:P 2 "gpc_reg_operand" ""))
1686 (clobber (match_scratch:P 3 ""))]
1689 (minus:P (match_dup 1)
1692 (compare:CC (match_dup 3)
1697 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1698 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1699 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1701 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1702 (minus:SI (match_dup 1) (match_dup 2)))]
1705 {sf.|subfc.} %0,%2,%1
1707 [(set_attr "type" "compare")
1708 (set_attr "length" "4,8")])
1711 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1712 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1713 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1715 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1716 (minus:P (match_dup 1)
1722 [(set_attr "type" "fast_compare")
1723 (set_attr "length" "4,8")])
1726 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1727 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1728 (match_operand:P 2 "gpc_reg_operand" ""))
1730 (set (match_operand:P 0 "gpc_reg_operand" "")
1731 (minus:P (match_dup 1)
1735 (minus:P (match_dup 1)
1738 (compare:CC (match_dup 0)
1742 (define_expand "sub<mode>3"
1743 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1744 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1745 (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
1749 if (GET_CODE (operands[2]) == CONST_INT)
1751 emit_insn (gen_add<mode>3 (operands[0], operands[1],
1752 negate_rtx (<MODE>mode, operands[2])));
1757 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1758 ;; instruction and some auxiliary computations. Then we just have a single
1759 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1762 (define_expand "sminsi3"
1764 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1765 (match_operand:SI 2 "reg_or_short_operand" ""))
1767 (minus:SI (match_dup 2) (match_dup 1))))
1768 (set (match_operand:SI 0 "gpc_reg_operand" "")
1769 (minus:SI (match_dup 2) (match_dup 3)))]
1770 "TARGET_POWER || TARGET_ISEL"
1775 operands[2] = force_reg (SImode, operands[2]);
1776 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1780 operands[3] = gen_reg_rtx (SImode);
1784 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1785 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1786 (match_operand:SI 2 "reg_or_short_operand" "")))
1787 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1790 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1792 (minus:SI (match_dup 2) (match_dup 1))))
1793 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1796 (define_expand "smaxsi3"
1798 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1799 (match_operand:SI 2 "reg_or_short_operand" ""))
1801 (minus:SI (match_dup 2) (match_dup 1))))
1802 (set (match_operand:SI 0 "gpc_reg_operand" "")
1803 (plus:SI (match_dup 3) (match_dup 1)))]
1804 "TARGET_POWER || TARGET_ISEL"
1809 operands[2] = force_reg (SImode, operands[2]);
1810 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1813 operands[3] = gen_reg_rtx (SImode);
1817 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1818 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1819 (match_operand:SI 2 "reg_or_short_operand" "")))
1820 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1823 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1825 (minus:SI (match_dup 2) (match_dup 1))))
1826 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1829 (define_expand "uminsi3"
1830 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1832 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1834 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1836 (minus:SI (match_dup 4) (match_dup 3))))
1837 (set (match_operand:SI 0 "gpc_reg_operand" "")
1838 (minus:SI (match_dup 2) (match_dup 3)))]
1839 "TARGET_POWER || TARGET_ISEL"
1844 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1847 operands[3] = gen_reg_rtx (SImode);
1848 operands[4] = gen_reg_rtx (SImode);
1849 operands[5] = GEN_INT (-2147483647 - 1);
1852 (define_expand "umaxsi3"
1853 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1855 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1857 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1859 (minus:SI (match_dup 4) (match_dup 3))))
1860 (set (match_operand:SI 0 "gpc_reg_operand" "")
1861 (plus:SI (match_dup 3) (match_dup 1)))]
1862 "TARGET_POWER || TARGET_ISEL"
1867 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1870 operands[3] = gen_reg_rtx (SImode);
1871 operands[4] = gen_reg_rtx (SImode);
1872 operands[5] = GEN_INT (-2147483647 - 1);
1876 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1877 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1878 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1880 (minus:SI (match_dup 2) (match_dup 1))))]
1885 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1887 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1888 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1890 (minus:SI (match_dup 2) (match_dup 1)))
1892 (clobber (match_scratch:SI 3 "=r,r"))]
1897 [(set_attr "type" "delayed_compare")
1898 (set_attr "length" "4,8")])
1901 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1903 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1904 (match_operand:SI 2 "reg_or_short_operand" ""))
1906 (minus:SI (match_dup 2) (match_dup 1)))
1908 (clobber (match_scratch:SI 3 ""))]
1909 "TARGET_POWER && reload_completed"
1911 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1913 (minus:SI (match_dup 2) (match_dup 1))))
1915 (compare:CC (match_dup 3)
1920 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1922 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1923 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1925 (minus:SI (match_dup 2) (match_dup 1)))
1927 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1928 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1930 (minus:SI (match_dup 2) (match_dup 1))))]
1935 [(set_attr "type" "delayed_compare")
1936 (set_attr "length" "4,8")])
1939 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1941 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1942 (match_operand:SI 2 "reg_or_short_operand" ""))
1944 (minus:SI (match_dup 2) (match_dup 1)))
1946 (set (match_operand:SI 0 "gpc_reg_operand" "")
1947 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1949 (minus:SI (match_dup 2) (match_dup 1))))]
1950 "TARGET_POWER && reload_completed"
1952 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1954 (minus:SI (match_dup 2) (match_dup 1))))
1956 (compare:CC (match_dup 0)
1960 ;; We don't need abs with condition code because such comparisons should
1962 (define_expand "abssi2"
1963 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1964 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1970 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
1973 else if (! TARGET_POWER)
1975 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
1980 (define_insn "*abssi2_power"
1981 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1982 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1986 (define_insn_and_split "abssi2_isel"
1987 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1988 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
1989 (clobber (match_scratch:SI 2 "=&b"))
1990 (clobber (match_scratch:CC 3 "=y"))]
1993 "&& reload_completed"
1994 [(set (match_dup 2) (neg:SI (match_dup 1)))
1996 (compare:CC (match_dup 1)
1999 (if_then_else:SI (ge (match_dup 3)
2005 (define_insn_and_split "abssi2_nopower"
2006 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2007 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
2008 (clobber (match_scratch:SI 2 "=&r,&r"))]
2009 "! TARGET_POWER && ! TARGET_ISEL"
2011 "&& reload_completed"
2012 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2013 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2014 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
2017 (define_insn "*nabs_power"
2018 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2019 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
2023 (define_insn_and_split "*nabs_nopower"
2024 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2025 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
2026 (clobber (match_scratch:SI 2 "=&r,&r"))]
2029 "&& reload_completed"
2030 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2031 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2032 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
2035 (define_expand "neg<mode>2"
2036 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2037 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
2041 (define_insn "*neg<mode>2_internal"
2042 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2043 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2048 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2049 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2051 (clobber (match_scratch:P 2 "=r,r"))]
2056 [(set_attr "type" "fast_compare")
2057 (set_attr "length" "4,8")])
2060 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2061 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2063 (clobber (match_scratch:P 2 ""))]
2066 (neg:P (match_dup 1)))
2068 (compare:CC (match_dup 2)
2073 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2074 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2076 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2077 (neg:P (match_dup 1)))]
2082 [(set_attr "type" "fast_compare")
2083 (set_attr "length" "4,8")])
2086 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2087 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2089 (set (match_operand:P 0 "gpc_reg_operand" "")
2090 (neg:P (match_dup 1)))]
2093 (neg:P (match_dup 1)))
2095 (compare:CC (match_dup 0)
2099 (define_insn "clz<mode>2"
2100 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2101 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2103 "{cntlz|cntlz<wd>} %0,%1")
2105 (define_expand "ctz<mode>2"
2107 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))
2108 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2110 (clobber (scratch:CC))])
2111 (set (match_dup 4) (clz:GPR (match_dup 3)))
2112 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2113 (minus:GPR (match_dup 5) (match_dup 4)))]
2116 operands[2] = gen_reg_rtx (<MODE>mode);
2117 operands[3] = gen_reg_rtx (<MODE>mode);
2118 operands[4] = gen_reg_rtx (<MODE>mode);
2119 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
2122 (define_expand "ffs<mode>2"
2124 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))
2125 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2127 (clobber (scratch:CC))])
2128 (set (match_dup 4) (clz:GPR (match_dup 3)))
2129 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2130 (minus:GPR (match_dup 5) (match_dup 4)))]
2133 operands[2] = gen_reg_rtx (<MODE>mode);
2134 operands[3] = gen_reg_rtx (<MODE>mode);
2135 operands[4] = gen_reg_rtx (<MODE>mode);
2136 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
2139 (define_expand "popcount<mode>2"
2141 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2144 (mult:GPR (match_dup 2) (match_dup 4)))
2145 (set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2146 (lshiftrt:GPR (match_dup 3) (match_dup 5)))]
2149 operands[2] = gen_reg_rtx (<MODE>mode);
2150 operands[3] = gen_reg_rtx (<MODE>mode);
2151 operands[4] = force_reg (<MODE>mode,
2152 <MODE>mode == SImode
2153 ? GEN_INT (0x01010101)
2154 : GEN_INT ((HOST_WIDE_INT)
2155 0x01010101 << 32 | 0x01010101));
2156 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 8);
2159 (define_insn "popcntb<mode>2"
2160 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2161 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2166 (define_expand "mulsi3"
2167 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2168 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2169 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2174 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2176 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2180 (define_insn "mulsi3_mq"
2181 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2182 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2183 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2184 (clobber (match_scratch:SI 3 "=q,q"))]
2187 {muls|mullw} %0,%1,%2
2188 {muli|mulli} %0,%1,%2"
2190 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2191 (const_string "imul3")
2192 (match_operand:SI 2 "short_cint_operand" "")
2193 (const_string "imul2")]
2194 (const_string "imul")))])
2196 (define_insn "mulsi3_no_mq"
2197 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2198 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2199 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2202 {muls|mullw} %0,%1,%2
2203 {muli|mulli} %0,%1,%2"
2205 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2206 (const_string "imul3")
2207 (match_operand:SI 2 "short_cint_operand" "")
2208 (const_string "imul2")]
2209 (const_string "imul")))])
2211 (define_insn "*mulsi3_mq_internal1"
2212 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2213 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2214 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2216 (clobber (match_scratch:SI 3 "=r,r"))
2217 (clobber (match_scratch:SI 4 "=q,q"))]
2220 {muls.|mullw.} %3,%1,%2
2222 [(set_attr "type" "imul_compare")
2223 (set_attr "length" "4,8")])
2226 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2227 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2228 (match_operand:SI 2 "gpc_reg_operand" ""))
2230 (clobber (match_scratch:SI 3 ""))
2231 (clobber (match_scratch:SI 4 ""))]
2232 "TARGET_POWER && reload_completed"
2233 [(parallel [(set (match_dup 3)
2234 (mult:SI (match_dup 1) (match_dup 2)))
2235 (clobber (match_dup 4))])
2237 (compare:CC (match_dup 3)
2241 (define_insn "*mulsi3_no_mq_internal1"
2242 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2243 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2244 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2246 (clobber (match_scratch:SI 3 "=r,r"))]
2249 {muls.|mullw.} %3,%1,%2
2251 [(set_attr "type" "imul_compare")
2252 (set_attr "length" "4,8")])
2255 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2256 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2257 (match_operand:SI 2 "gpc_reg_operand" ""))
2259 (clobber (match_scratch:SI 3 ""))]
2260 "! TARGET_POWER && reload_completed"
2262 (mult:SI (match_dup 1) (match_dup 2)))
2264 (compare:CC (match_dup 3)
2268 (define_insn "*mulsi3_mq_internal2"
2269 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2270 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2271 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2273 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2274 (mult:SI (match_dup 1) (match_dup 2)))
2275 (clobber (match_scratch:SI 4 "=q,q"))]
2278 {muls.|mullw.} %0,%1,%2
2280 [(set_attr "type" "imul_compare")
2281 (set_attr "length" "4,8")])
2284 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2285 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2286 (match_operand:SI 2 "gpc_reg_operand" ""))
2288 (set (match_operand:SI 0 "gpc_reg_operand" "")
2289 (mult:SI (match_dup 1) (match_dup 2)))
2290 (clobber (match_scratch:SI 4 ""))]
2291 "TARGET_POWER && reload_completed"
2292 [(parallel [(set (match_dup 0)
2293 (mult:SI (match_dup 1) (match_dup 2)))
2294 (clobber (match_dup 4))])
2296 (compare:CC (match_dup 0)
2300 (define_insn "*mulsi3_no_mq_internal2"
2301 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2302 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2303 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2305 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2306 (mult:SI (match_dup 1) (match_dup 2)))]
2309 {muls.|mullw.} %0,%1,%2
2311 [(set_attr "type" "imul_compare")
2312 (set_attr "length" "4,8")])
2315 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2316 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2317 (match_operand:SI 2 "gpc_reg_operand" ""))
2319 (set (match_operand:SI 0 "gpc_reg_operand" "")
2320 (mult:SI (match_dup 1) (match_dup 2)))]
2321 "! TARGET_POWER && reload_completed"
2323 (mult:SI (match_dup 1) (match_dup 2)))
2325 (compare:CC (match_dup 0)
2329 ;; Operand 1 is divided by operand 2; quotient goes to operand
2330 ;; 0 and remainder to operand 3.
2331 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2333 (define_expand "divmodsi4"
2334 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2335 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2336 (match_operand:SI 2 "gpc_reg_operand" "")))
2337 (set (match_operand:SI 3 "register_operand" "")
2338 (mod:SI (match_dup 1) (match_dup 2)))])]
2339 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2342 if (! TARGET_POWER && ! TARGET_POWERPC)
2344 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2345 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2346 emit_insn (gen_divss_call ());
2347 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2348 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2353 (define_insn "*divmodsi4_internal"
2354 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2355 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2356 (match_operand:SI 2 "gpc_reg_operand" "r")))
2357 (set (match_operand:SI 3 "register_operand" "=q")
2358 (mod:SI (match_dup 1) (match_dup 2)))]
2361 [(set_attr "type" "idiv")])
2363 (define_expand "udiv<mode>3"
2364 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2365 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2366 (match_operand:GPR 2 "gpc_reg_operand" "")))]
2367 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2370 if (! TARGET_POWER && ! TARGET_POWERPC)
2372 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2373 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2374 emit_insn (gen_quous_call ());
2375 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2378 else if (TARGET_POWER)
2380 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2385 (define_insn "udivsi3_mq"
2386 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2387 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2388 (match_operand:SI 2 "gpc_reg_operand" "r")))
2389 (clobber (match_scratch:SI 3 "=q"))]
2390 "TARGET_POWERPC && TARGET_POWER"
2392 [(set_attr "type" "idiv")])
2394 (define_insn "*udivsi3_no_mq"
2395 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2396 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2397 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2398 "TARGET_POWERPC && ! TARGET_POWER"
2400 [(set_attr "type" "idiv")])
2402 ;; For powers of two we can do srai/aze for divide and then adjust for
2403 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2404 ;; used; for PowerPC, force operands into register and do a normal divide;
2405 ;; for AIX common-mode, use quoss call on register operands.
2406 (define_expand "div<mode>3"
2407 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2408 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2409 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2413 if (GET_CODE (operands[2]) == CONST_INT
2414 && INTVAL (operands[2]) > 0
2415 && exact_log2 (INTVAL (operands[2])) >= 0)
2417 else if (TARGET_POWERPC)
2419 operands[2] = force_reg (SImode, operands[2]);
2422 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2426 else if (TARGET_POWER)
2430 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2431 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2432 emit_insn (gen_quoss_call ());
2433 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2438 (define_insn "divsi3_mq"
2439 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2440 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2441 (match_operand:SI 2 "gpc_reg_operand" "r")))
2442 (clobber (match_scratch:SI 3 "=q"))]
2443 "TARGET_POWERPC && TARGET_POWER"
2445 [(set_attr "type" "idiv")])
2447 (define_insn "*div<mode>3_no_mq"
2448 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2449 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2450 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2451 "TARGET_POWERPC && ! TARGET_POWER"
2453 [(set_attr "type" "idiv")])
2455 (define_expand "mod<mode>3"
2456 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2457 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2458 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
2466 if (GET_CODE (operands[2]) != CONST_INT
2467 || INTVAL (operands[2]) <= 0
2468 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2471 temp1 = gen_reg_rtx (<MODE>mode);
2472 temp2 = gen_reg_rtx (<MODE>mode);
2474 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2475 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2476 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
2481 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2482 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2483 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
2485 "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
2486 [(set_attr "type" "two")
2487 (set_attr "length" "8")])
2490 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2491 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2492 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2494 (clobber (match_scratch:P 3 "=r,r"))]
2497 {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
2499 [(set_attr "type" "compare")
2500 (set_attr "length" "8,12")])
2503 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2504 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2505 (match_operand:GPR 2 "exact_log2_cint_operand"
2508 (clobber (match_scratch:GPR 3 ""))]
2511 (div:<MODE> (match_dup 1) (match_dup 2)))
2513 (compare:CC (match_dup 3)
2518 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2519 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2520 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2522 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2523 (div:P (match_dup 1) (match_dup 2)))]
2526 {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
2528 [(set_attr "type" "compare")
2529 (set_attr "length" "8,12")])
2532 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2533 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2534 (match_operand:GPR 2 "exact_log2_cint_operand"
2537 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2538 (div:GPR (match_dup 1) (match_dup 2)))]
2541 (div:<MODE> (match_dup 1) (match_dup 2)))
2543 (compare:CC (match_dup 0)
2548 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2551 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2553 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2554 (match_operand:SI 3 "gpc_reg_operand" "r")))
2555 (set (match_operand:SI 2 "register_operand" "=*q")
2558 (zero_extend:DI (match_dup 1)) (const_int 32))
2559 (zero_extend:DI (match_dup 4)))
2563 [(set_attr "type" "idiv")])
2565 ;; To do unsigned divide we handle the cases of the divisor looking like a
2566 ;; negative number. If it is a constant that is less than 2**31, we don't
2567 ;; have to worry about the branches. So make a few subroutines here.
2569 ;; First comes the normal case.
2570 (define_expand "udivmodsi4_normal"
2571 [(set (match_dup 4) (const_int 0))
2572 (parallel [(set (match_operand:SI 0 "" "")
2573 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2575 (zero_extend:DI (match_operand:SI 1 "" "")))
2576 (match_operand:SI 2 "" "")))
2577 (set (match_operand:SI 3 "" "")
2578 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2580 (zero_extend:DI (match_dup 1)))
2584 { operands[4] = gen_reg_rtx (SImode); }")
2586 ;; This handles the branches.
2587 (define_expand "udivmodsi4_tests"
2588 [(set (match_operand:SI 0 "" "") (const_int 0))
2589 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2590 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2591 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2592 (label_ref (match_operand:SI 4 "" "")) (pc)))
2593 (set (match_dup 0) (const_int 1))
2594 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2595 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2596 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2597 (label_ref (match_dup 4)) (pc)))]
2600 { operands[5] = gen_reg_rtx (CCUNSmode);
2601 operands[6] = gen_reg_rtx (CCmode);
2604 (define_expand "udivmodsi4"
2605 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2606 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2607 (match_operand:SI 2 "reg_or_cint_operand" "")))
2608 (set (match_operand:SI 3 "gpc_reg_operand" "")
2609 (umod:SI (match_dup 1) (match_dup 2)))])]
2617 if (! TARGET_POWERPC)
2619 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2620 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2621 emit_insn (gen_divus_call ());
2622 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2623 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2630 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2632 operands[2] = force_reg (SImode, operands[2]);
2633 label = gen_label_rtx ();
2634 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2635 operands[3], label));
2638 operands[2] = force_reg (SImode, operands[2]);
2640 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2648 ;; AIX architecture-independent common-mode multiply (DImode),
2649 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2650 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2651 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2652 ;; assumed unused if generating common-mode, so ignore.
2653 (define_insn "mulh_call"
2656 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2657 (sign_extend:DI (reg:SI 4)))
2659 (clobber (match_scratch:SI 0 "=l"))]
2660 "! TARGET_POWER && ! TARGET_POWERPC"
2662 [(set_attr "type" "imul")])
2664 (define_insn "mull_call"
2666 (mult:DI (sign_extend:DI (reg:SI 3))
2667 (sign_extend:DI (reg:SI 4))))
2668 (clobber (match_scratch:SI 0 "=l"))
2669 (clobber (reg:SI 0))]
2670 "! TARGET_POWER && ! TARGET_POWERPC"
2672 [(set_attr "type" "imul")])
2674 (define_insn "divss_call"
2676 (div:SI (reg:SI 3) (reg:SI 4)))
2678 (mod:SI (reg:SI 3) (reg:SI 4)))
2679 (clobber (match_scratch:SI 0 "=l"))
2680 (clobber (reg:SI 0))]
2681 "! TARGET_POWER && ! TARGET_POWERPC"
2683 [(set_attr "type" "idiv")])
2685 (define_insn "divus_call"
2687 (udiv:SI (reg:SI 3) (reg:SI 4)))
2689 (umod:SI (reg:SI 3) (reg:SI 4)))
2690 (clobber (match_scratch:SI 0 "=l"))
2691 (clobber (reg:SI 0))
2692 (clobber (match_scratch:CC 1 "=x"))
2693 (clobber (reg:CC 69))]
2694 "! TARGET_POWER && ! TARGET_POWERPC"
2696 [(set_attr "type" "idiv")])
2698 (define_insn "quoss_call"
2700 (div:SI (reg:SI 3) (reg:SI 4)))
2701 (clobber (match_scratch:SI 0 "=l"))]
2702 "! TARGET_POWER && ! TARGET_POWERPC"
2704 [(set_attr "type" "idiv")])
2706 (define_insn "quous_call"
2708 (udiv:SI (reg:SI 3) (reg:SI 4)))
2709 (clobber (match_scratch:SI 0 "=l"))
2710 (clobber (reg:SI 0))
2711 (clobber (match_scratch:CC 1 "=x"))
2712 (clobber (reg:CC 69))]
2713 "! TARGET_POWER && ! TARGET_POWERPC"
2715 [(set_attr "type" "idiv")])
2717 ;; Logical instructions
2718 ;; The logical instructions are mostly combined by using match_operator,
2719 ;; but the plain AND insns are somewhat different because there is no
2720 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2721 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2723 (define_insn "andsi3"
2724 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2725 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2726 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2727 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2731 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2732 {andil.|andi.} %0,%1,%b2
2733 {andiu.|andis.} %0,%1,%u2"
2734 [(set_attr "type" "*,*,compare,compare")])
2736 ;; Note to set cr's other than cr0 we do the and immediate and then
2737 ;; the test again -- this avoids a mfcr which on the higher end
2738 ;; machines causes an execution serialization
2740 (define_insn "*andsi3_internal2"
2741 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2742 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2743 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2745 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2746 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2750 {andil.|andi.} %3,%1,%b2
2751 {andiu.|andis.} %3,%1,%u2
2752 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2757 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2758 (set_attr "length" "4,4,4,4,8,8,8,8")])
2760 (define_insn "*andsi3_internal3"
2761 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2762 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2763 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2765 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2766 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2770 {andil.|andi.} %3,%1,%b2
2771 {andiu.|andis.} %3,%1,%u2
2772 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2777 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2778 (set_attr "length" "8,4,4,4,8,8,8,8")])
2781 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2782 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2783 (match_operand:GPR 2 "and_operand" ""))
2785 (clobber (match_scratch:GPR 3 ""))
2786 (clobber (match_scratch:CC 4 ""))]
2788 [(parallel [(set (match_dup 3)
2789 (and:<MODE> (match_dup 1)
2791 (clobber (match_dup 4))])
2793 (compare:CC (match_dup 3)
2797 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2798 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2801 [(set (match_operand:CC 0 "cc_reg_operand" "")
2802 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2803 (match_operand:SI 2 "gpc_reg_operand" ""))
2805 (clobber (match_scratch:SI 3 ""))
2806 (clobber (match_scratch:CC 4 ""))]
2807 "TARGET_POWERPC64 && reload_completed"
2808 [(parallel [(set (match_dup 3)
2809 (and:SI (match_dup 1)
2811 (clobber (match_dup 4))])
2813 (compare:CC (match_dup 3)
2817 (define_insn "*andsi3_internal4"
2818 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2819 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2820 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2822 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2823 (and:SI (match_dup 1)
2825 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2829 {andil.|andi.} %0,%1,%b2
2830 {andiu.|andis.} %0,%1,%u2
2831 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2836 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2837 (set_attr "length" "4,4,4,4,8,8,8,8")])
2839 (define_insn "*andsi3_internal5"
2840 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2841 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2842 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2844 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2845 (and:SI (match_dup 1)
2847 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2851 {andil.|andi.} %0,%1,%b2
2852 {andiu.|andis.} %0,%1,%u2
2853 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2858 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2859 (set_attr "length" "8,4,4,4,8,8,8,8")])
2862 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2863 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2864 (match_operand:SI 2 "and_operand" ""))
2866 (set (match_operand:SI 0 "gpc_reg_operand" "")
2867 (and:SI (match_dup 1)
2869 (clobber (match_scratch:CC 4 ""))]
2871 [(parallel [(set (match_dup 0)
2872 (and:SI (match_dup 1)
2874 (clobber (match_dup 4))])
2876 (compare:CC (match_dup 0)
2881 [(set (match_operand:CC 3 "cc_reg_operand" "")
2882 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2883 (match_operand:SI 2 "gpc_reg_operand" ""))
2885 (set (match_operand:SI 0 "gpc_reg_operand" "")
2886 (and:SI (match_dup 1)
2888 (clobber (match_scratch:CC 4 ""))]
2889 "TARGET_POWERPC64 && reload_completed"
2890 [(parallel [(set (match_dup 0)
2891 (and:SI (match_dup 1)
2893 (clobber (match_dup 4))])
2895 (compare:CC (match_dup 0)
2899 ;; Handle the PowerPC64 rlwinm corner case
2901 (define_insn_and_split "*andsi3_internal6"
2902 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2903 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2904 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2909 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2912 (rotate:SI (match_dup 0) (match_dup 5)))]
2915 int mb = extract_MB (operands[2]);
2916 int me = extract_ME (operands[2]);
2917 operands[3] = GEN_INT (me + 1);
2918 operands[5] = GEN_INT (32 - (me + 1));
2919 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2921 [(set_attr "length" "8")])
2923 (define_expand "iorsi3"
2924 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2925 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
2926 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2930 if (GET_CODE (operands[2]) == CONST_INT
2931 && ! logical_operand (operands[2], SImode))
2933 HOST_WIDE_INT value = INTVAL (operands[2]);
2934 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2935 ? operands[0] : gen_reg_rtx (SImode));
2937 emit_insn (gen_iorsi3 (tmp, operands[1],
2938 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2939 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2944 (define_expand "xorsi3"
2945 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2946 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2947 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2951 if (GET_CODE (operands[2]) == CONST_INT
2952 && ! logical_operand (operands[2], SImode))
2954 HOST_WIDE_INT value = INTVAL (operands[2]);
2955 rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2956 ? operands[0] : gen_reg_rtx (SImode));
2958 emit_insn (gen_xorsi3 (tmp, operands[1],
2959 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2960 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2965 (define_insn "*boolsi3_internal1"
2966 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2967 (match_operator:SI 3 "boolean_or_operator"
2968 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
2969 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
2973 {%q3il|%q3i} %0,%1,%b2
2974 {%q3iu|%q3is} %0,%1,%u2")
2976 (define_insn "*boolsi3_internal2"
2977 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2978 (compare:CC (match_operator:SI 4 "boolean_or_operator"
2979 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2980 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2982 (clobber (match_scratch:SI 3 "=r,r"))]
2987 [(set_attr "type" "compare")
2988 (set_attr "length" "4,8")])
2991 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2992 (compare:CC (match_operator:SI 4 "boolean_operator"
2993 [(match_operand:SI 1 "gpc_reg_operand" "")
2994 (match_operand:SI 2 "gpc_reg_operand" "")])
2996 (clobber (match_scratch:SI 3 ""))]
2997 "TARGET_32BIT && reload_completed"
2998 [(set (match_dup 3) (match_dup 4))
3000 (compare:CC (match_dup 3)
3004 (define_insn "*boolsi3_internal3"
3005 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3006 (compare:CC (match_operator:SI 4 "boolean_operator"
3007 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3008 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3010 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3016 [(set_attr "type" "compare")
3017 (set_attr "length" "4,8")])
3020 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3021 (compare:CC (match_operator:SI 4 "boolean_operator"
3022 [(match_operand:SI 1 "gpc_reg_operand" "")
3023 (match_operand:SI 2 "gpc_reg_operand" "")])
3025 (set (match_operand:SI 0 "gpc_reg_operand" "")
3027 "TARGET_32BIT && reload_completed"
3028 [(set (match_dup 0) (match_dup 4))
3030 (compare:CC (match_dup 0)
3034 ;; Split a logical operation that we can't do in one insn into two insns,
3035 ;; each of which does one 16-bit part. This is used by combine.
3038 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3039 (match_operator:SI 3 "boolean_or_operator"
3040 [(match_operand:SI 1 "gpc_reg_operand" "")
3041 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
3043 [(set (match_dup 0) (match_dup 4))
3044 (set (match_dup 0) (match_dup 5))]
3048 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
3049 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3051 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
3052 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3056 (define_insn "*boolcsi3_internal1"
3057 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3058 (match_operator:SI 3 "boolean_operator"
3059 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3060 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
3064 (define_insn "*boolcsi3_internal2"
3065 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3066 (compare:CC (match_operator:SI 4 "boolean_operator"
3067 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3068 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3070 (clobber (match_scratch:SI 3 "=r,r"))]
3075 [(set_attr "type" "compare")
3076 (set_attr "length" "4,8")])
3079 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3080 (compare:CC (match_operator:SI 4 "boolean_operator"
3081 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3082 (match_operand:SI 2 "gpc_reg_operand" "")])
3084 (clobber (match_scratch:SI 3 ""))]
3085 "TARGET_32BIT && reload_completed"
3086 [(set (match_dup 3) (match_dup 4))
3088 (compare:CC (match_dup 3)
3092 (define_insn "*boolcsi3_internal3"
3093 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3094 (compare:CC (match_operator:SI 4 "boolean_operator"
3095 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3096 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3098 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3104 [(set_attr "type" "compare")
3105 (set_attr "length" "4,8")])
3108 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3109 (compare:CC (match_operator:SI 4 "boolean_operator"
3110 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3111 (match_operand:SI 2 "gpc_reg_operand" "")])
3113 (set (match_operand:SI 0 "gpc_reg_operand" "")
3115 "TARGET_32BIT && reload_completed"
3116 [(set (match_dup 0) (match_dup 4))
3118 (compare:CC (match_dup 0)
3122 (define_insn "*boolccsi3_internal1"
3123 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3124 (match_operator:SI 3 "boolean_operator"
3125 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3126 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3130 (define_insn "*boolccsi3_internal2"
3131 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3132 (compare:CC (match_operator:SI 4 "boolean_operator"
3133 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3134 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3136 (clobber (match_scratch:SI 3 "=r,r"))]
3141 [(set_attr "type" "compare")
3142 (set_attr "length" "4,8")])
3145 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3146 (compare:CC (match_operator:SI 4 "boolean_operator"
3147 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3148 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3150 (clobber (match_scratch:SI 3 ""))]
3151 "TARGET_32BIT && reload_completed"
3152 [(set (match_dup 3) (match_dup 4))
3154 (compare:CC (match_dup 3)
3158 (define_insn "*boolccsi3_internal3"
3159 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3160 (compare:CC (match_operator:SI 4 "boolean_operator"
3161 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3162 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3164 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3170 [(set_attr "type" "compare")
3171 (set_attr "length" "4,8")])
3174 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3175 (compare:CC (match_operator:SI 4 "boolean_operator"
3176 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3177 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3179 (set (match_operand:SI 0 "gpc_reg_operand" "")
3181 "TARGET_32BIT && reload_completed"
3182 [(set (match_dup 0) (match_dup 4))
3184 (compare:CC (match_dup 0)
3188 ;; maskir insn. We need four forms because things might be in arbitrary
3189 ;; orders. Don't define forms that only set CR fields because these
3190 ;; would modify an input register.
3192 (define_insn "*maskir_internal1"
3193 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3194 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3195 (match_operand:SI 1 "gpc_reg_operand" "0"))
3196 (and:SI (match_dup 2)
3197 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
3201 (define_insn "*maskir_internal2"
3202 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3203 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3204 (match_operand:SI 1 "gpc_reg_operand" "0"))
3205 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3210 (define_insn "*maskir_internal3"
3211 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3212 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
3213 (match_operand:SI 3 "gpc_reg_operand" "r"))
3214 (and:SI (not:SI (match_dup 2))
3215 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3219 (define_insn "*maskir_internal4"
3220 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3221 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3222 (match_operand:SI 2 "gpc_reg_operand" "r"))
3223 (and:SI (not:SI (match_dup 2))
3224 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3228 (define_insn "*maskir_internal5"
3229 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3231 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3232 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3233 (and:SI (match_dup 2)
3234 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
3236 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3237 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3238 (and:SI (match_dup 2) (match_dup 3))))]
3243 [(set_attr "type" "compare")
3244 (set_attr "length" "4,8")])
3247 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3249 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3250 (match_operand:SI 1 "gpc_reg_operand" ""))
3251 (and:SI (match_dup 2)
3252 (match_operand:SI 3 "gpc_reg_operand" "")))
3254 (set (match_operand:SI 0 "gpc_reg_operand" "")
3255 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3256 (and:SI (match_dup 2) (match_dup 3))))]
3257 "TARGET_POWER && reload_completed"
3259 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3260 (and:SI (match_dup 2) (match_dup 3))))
3262 (compare:CC (match_dup 0)
3266 (define_insn "*maskir_internal6"
3267 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3269 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3270 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3271 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")