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.
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_gt_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,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"
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,power6,cell"
110 (const (symbol_ref "rs6000_cpu_attr")))
113 ;; If this instruction is microcoded on the CELL processor
114 ; The default for load and stores is conditional
115 ; The default for load extended and the recorded instructions is always microcoded
116 (define_attr "cell_micro" "not,conditional,always"
117 (if_then_else (ior (ior (eq_attr "type" "load")
118 (eq_attr "type" "store"))
119 (ior (eq_attr "type" "fpload")
120 (eq_attr "type" "fpstore")))
121 (const_string "conditional")
122 (if_then_else (ior (eq_attr "type" "load_ext")
123 (ior (eq_attr "type" "compare")
124 (eq_attr "type" "delayed_compare")))
125 (const_string "always")
126 (const_string "not"))))
129 (automata_option "ndfa")
142 (include "power4.md")
143 (include "power5.md")
144 (include "power6.md")
147 (include "predicates.md")
148 (include "constraints.md")
150 (include "darwin.md")
155 ; This mode macro allows :GPR to be used to indicate the allowable size
156 ; of whole values in GPRs.
157 (define_mode_macro GPR [SI (DI "TARGET_POWERPC64")])
159 ; Any supported integer mode.
160 (define_mode_macro INT [QI HI SI DI TI])
162 ; Any supported integer mode that fits in one register.
163 (define_mode_macro INT1 [QI HI SI (DI "TARGET_POWERPC64")])
165 ; extend modes for DImode
166 (define_mode_macro QHSI [QI HI SI])
168 ; SImode or DImode, even if DImode doesn't fit in GPRs.
169 (define_mode_macro SDI [SI DI])
171 ; The size of a pointer. Also, the size of the value that a record-condition
172 ; (one with a '.') will compare.
173 (define_mode_macro P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
175 ; Any hardware-supported floating-point mode
176 (define_mode_macro FP [(SF "TARGET_HARD_FLOAT")
177 (DF "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)")
178 (TF "!TARGET_IEEEQUAD
180 && (TARGET_FPRS || TARGET_E500_DOUBLE)
181 && TARGET_LONG_DOUBLE_128")])
183 ; Various instructions that come in SI and DI forms.
184 ; A generic w/d attribute, for things like cmpw/cmpd.
185 (define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
188 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
191 ;; Start with fixed-point load and store insns. Here we put only the more
192 ;; complex forms. Basic data transfer is done later.
194 (define_expand "zero_extend<mode>di2"
195 [(set (match_operand:DI 0 "gpc_reg_operand" "")
196 (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "")))]
200 (define_insn "*zero_extend<mode>di2_internal1"
201 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
202 (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
206 rldicl %0,%1,0,<dbits>"
207 [(set_attr "type" "load,*")])
209 (define_insn "*zero_extend<mode>di2_internal2"
210 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
211 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
213 (clobber (match_scratch:DI 2 "=r,r"))]
216 rldicl. %2,%1,0,<dbits>
218 [(set_attr "type" "compare")
219 (set_attr "length" "4,8")])
222 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
223 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
225 (clobber (match_scratch:DI 2 ""))]
226 "TARGET_POWERPC64 && reload_completed"
228 (zero_extend:DI (match_dup 1)))
230 (compare:CC (match_dup 2)
234 (define_insn "*zero_extend<mode>di2_internal3"
235 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
236 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
238 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
239 (zero_extend:DI (match_dup 1)))]
242 rldicl. %0,%1,0,<dbits>
244 [(set_attr "type" "compare")
245 (set_attr "length" "4,8")])
248 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
249 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
251 (set (match_operand:DI 0 "gpc_reg_operand" "")
252 (zero_extend:DI (match_dup 1)))]
253 "TARGET_POWERPC64 && reload_completed"
255 (zero_extend:DI (match_dup 1)))
257 (compare:CC (match_dup 0)
261 (define_insn "extendqidi2"
262 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
263 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
266 [(set_attr "type" "exts")])
269 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
270 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
272 (clobber (match_scratch:DI 2 "=r,r"))]
277 [(set_attr "type" "compare")
278 (set_attr "length" "4,8")])
281 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
282 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
284 (clobber (match_scratch:DI 2 ""))]
285 "TARGET_POWERPC64 && reload_completed"
287 (sign_extend:DI (match_dup 1)))
289 (compare:CC (match_dup 2)
294 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
295 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
297 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
298 (sign_extend:DI (match_dup 1)))]
303 [(set_attr "type" "compare")
304 (set_attr "length" "4,8")])
307 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
308 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
310 (set (match_operand:DI 0 "gpc_reg_operand" "")
311 (sign_extend:DI (match_dup 1)))]
312 "TARGET_POWERPC64 && reload_completed"
314 (sign_extend:DI (match_dup 1)))
316 (compare:CC (match_dup 0)
320 (define_expand "extendhidi2"
321 [(set (match_operand:DI 0 "gpc_reg_operand" "")
322 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
327 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
328 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
333 [(set_attr "type" "load_ext,exts")])
336 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
337 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
339 (clobber (match_scratch:DI 2 "=r,r"))]
344 [(set_attr "type" "compare")
345 (set_attr "length" "4,8")])
348 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
349 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
351 (clobber (match_scratch:DI 2 ""))]
352 "TARGET_POWERPC64 && reload_completed"
354 (sign_extend:DI (match_dup 1)))
356 (compare:CC (match_dup 2)
361 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
362 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
364 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
365 (sign_extend:DI (match_dup 1)))]
370 [(set_attr "type" "compare")
371 (set_attr "length" "4,8")])
374 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
375 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
377 (set (match_operand:DI 0 "gpc_reg_operand" "")
378 (sign_extend:DI (match_dup 1)))]
379 "TARGET_POWERPC64 && reload_completed"
381 (sign_extend:DI (match_dup 1)))
383 (compare:CC (match_dup 0)
387 (define_expand "extendsidi2"
388 [(set (match_operand:DI 0 "gpc_reg_operand" "")
389 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
394 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
395 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
400 [(set_attr "type" "load_ext,exts")])
403 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
404 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
406 (clobber (match_scratch:DI 2 "=r,r"))]
411 [(set_attr "type" "compare")
412 (set_attr "length" "4,8")])
415 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
416 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
418 (clobber (match_scratch:DI 2 ""))]
419 "TARGET_POWERPC64 && reload_completed"
421 (sign_extend:DI (match_dup 1)))
423 (compare:CC (match_dup 2)
428 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
429 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
431 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
432 (sign_extend:DI (match_dup 1)))]
437 [(set_attr "type" "compare")
438 (set_attr "length" "4,8")])
441 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
442 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
444 (set (match_operand:DI 0 "gpc_reg_operand" "")
445 (sign_extend:DI (match_dup 1)))]
446 "TARGET_POWERPC64 && reload_completed"
448 (sign_extend:DI (match_dup 1)))
450 (compare:CC (match_dup 0)
454 (define_expand "zero_extendqisi2"
455 [(set (match_operand:SI 0 "gpc_reg_operand" "")
456 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
461 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
462 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
466 {rlinm|rlwinm} %0,%1,0,0xff"
467 [(set_attr "type" "load,*")])
470 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
471 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
473 (clobber (match_scratch:SI 2 "=r,r"))]
476 {andil.|andi.} %2,%1,0xff
478 [(set_attr "type" "compare")
479 (set_attr "length" "4,8")])
482 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
483 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
485 (clobber (match_scratch:SI 2 ""))]
488 (zero_extend:SI (match_dup 1)))
490 (compare:CC (match_dup 2)
495 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
496 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
498 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
499 (zero_extend:SI (match_dup 1)))]
502 {andil.|andi.} %0,%1,0xff
504 [(set_attr "type" "compare")
505 (set_attr "length" "4,8")])
508 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
509 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
511 (set (match_operand:SI 0 "gpc_reg_operand" "")
512 (zero_extend:SI (match_dup 1)))]
515 (zero_extend:SI (match_dup 1)))
517 (compare:CC (match_dup 0)
521 (define_expand "extendqisi2"
522 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
523 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
528 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
529 else if (TARGET_POWER)
530 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
532 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
536 (define_insn "extendqisi2_ppc"
537 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
538 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
541 [(set_attr "type" "exts")])
544 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
545 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
547 (clobber (match_scratch:SI 2 "=r,r"))]
552 [(set_attr "type" "compare")
553 (set_attr "length" "4,8")])
556 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
557 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
559 (clobber (match_scratch:SI 2 ""))]
560 "TARGET_POWERPC && reload_completed"
562 (sign_extend:SI (match_dup 1)))
564 (compare:CC (match_dup 2)
569 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
570 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
572 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
573 (sign_extend:SI (match_dup 1)))]
578 [(set_attr "type" "compare")
579 (set_attr "length" "4,8")])
582 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
583 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
585 (set (match_operand:SI 0 "gpc_reg_operand" "")
586 (sign_extend:SI (match_dup 1)))]
587 "TARGET_POWERPC && reload_completed"
589 (sign_extend:SI (match_dup 1)))
591 (compare:CC (match_dup 0)
595 (define_expand "extendqisi2_power"
596 [(parallel [(set (match_dup 2)
597 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
599 (clobber (scratch:SI))])
600 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
601 (ashiftrt:SI (match_dup 2)
603 (clobber (scratch:SI))])]
606 { operands[1] = gen_lowpart (SImode, operands[1]);
607 operands[2] = gen_reg_rtx (SImode); }")
609 (define_expand "extendqisi2_no_power"
611 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
613 (set (match_operand:SI 0 "gpc_reg_operand" "")
614 (ashiftrt:SI (match_dup 2)
616 "! TARGET_POWER && ! TARGET_POWERPC"
618 { operands[1] = gen_lowpart (SImode, operands[1]);
619 operands[2] = gen_reg_rtx (SImode); }")
621 (define_expand "zero_extendqihi2"
622 [(set (match_operand:HI 0 "gpc_reg_operand" "")
623 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
628 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
629 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
633 {rlinm|rlwinm} %0,%1,0,0xff"
634 [(set_attr "type" "load,*")])
637 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
638 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
640 (clobber (match_scratch:HI 2 "=r,r"))]
643 {andil.|andi.} %2,%1,0xff
645 [(set_attr "type" "compare")
646 (set_attr "length" "4,8")])
649 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
650 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
652 (clobber (match_scratch:HI 2 ""))]
655 (zero_extend:HI (match_dup 1)))
657 (compare:CC (match_dup 2)
662 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
663 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
665 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
666 (zero_extend:HI (match_dup 1)))]
669 {andil.|andi.} %0,%1,0xff
671 [(set_attr "type" "compare")
672 (set_attr "length" "4,8")])
675 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
676 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
678 (set (match_operand:HI 0 "gpc_reg_operand" "")
679 (zero_extend:HI (match_dup 1)))]
682 (zero_extend:HI (match_dup 1)))
684 (compare:CC (match_dup 0)
688 (define_expand "extendqihi2"
689 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
690 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
695 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
696 else if (TARGET_POWER)
697 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
699 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
703 (define_insn "extendqihi2_ppc"
704 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
705 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
708 [(set_attr "type" "exts")])
711 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
712 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
714 (clobber (match_scratch:HI 2 "=r,r"))]
719 [(set_attr "type" "compare")
720 (set_attr "length" "4,8")])
723 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
724 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
726 (clobber (match_scratch:HI 2 ""))]
727 "TARGET_POWERPC && reload_completed"
729 (sign_extend:HI (match_dup 1)))
731 (compare:CC (match_dup 2)
736 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
737 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
739 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
740 (sign_extend:HI (match_dup 1)))]
745 [(set_attr "type" "compare")
746 (set_attr "length" "4,8")])
749 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
750 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
752 (set (match_operand:HI 0 "gpc_reg_operand" "")
753 (sign_extend:HI (match_dup 1)))]
754 "TARGET_POWERPC && reload_completed"
756 (sign_extend:HI (match_dup 1)))
758 (compare:CC (match_dup 0)
762 (define_expand "extendqihi2_power"
763 [(parallel [(set (match_dup 2)
764 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
766 (clobber (scratch:SI))])
767 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
768 (ashiftrt:SI (match_dup 2)
770 (clobber (scratch:SI))])]
773 { operands[0] = gen_lowpart (SImode, operands[0]);
774 operands[1] = gen_lowpart (SImode, operands[1]);
775 operands[2] = gen_reg_rtx (SImode); }")
777 (define_expand "extendqihi2_no_power"
779 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
781 (set (match_operand:HI 0 "gpc_reg_operand" "")
782 (ashiftrt:SI (match_dup 2)
784 "! TARGET_POWER && ! TARGET_POWERPC"
786 { operands[0] = gen_lowpart (SImode, operands[0]);
787 operands[1] = gen_lowpart (SImode, operands[1]);
788 operands[2] = gen_reg_rtx (SImode); }")
790 (define_expand "zero_extendhisi2"
791 [(set (match_operand:SI 0 "gpc_reg_operand" "")
792 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
797 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
798 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
802 {rlinm|rlwinm} %0,%1,0,0xffff"
803 [(set_attr "type" "load,*")])
806 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
807 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
809 (clobber (match_scratch:SI 2 "=r,r"))]
812 {andil.|andi.} %2,%1,0xffff
814 [(set_attr "type" "compare")
815 (set_attr "length" "4,8")])
818 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
819 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
821 (clobber (match_scratch:SI 2 ""))]
824 (zero_extend:SI (match_dup 1)))
826 (compare:CC (match_dup 2)
831 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
832 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
834 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
835 (zero_extend:SI (match_dup 1)))]
838 {andil.|andi.} %0,%1,0xffff
840 [(set_attr "type" "compare")
841 (set_attr "length" "4,8")])
844 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
845 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
847 (set (match_operand:SI 0 "gpc_reg_operand" "")
848 (zero_extend:SI (match_dup 1)))]
851 (zero_extend:SI (match_dup 1)))
853 (compare:CC (match_dup 0)
857 (define_expand "extendhisi2"
858 [(set (match_operand:SI 0 "gpc_reg_operand" "")
859 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
864 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
865 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
870 [(set_attr "type" "load_ext,exts")])
873 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
874 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
876 (clobber (match_scratch:SI 2 "=r,r"))]
881 [(set_attr "type" "compare")
882 (set_attr "length" "4,8")])
885 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
886 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
888 (clobber (match_scratch:SI 2 ""))]
891 (sign_extend:SI (match_dup 1)))
893 (compare:CC (match_dup 2)
898 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
899 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
901 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
902 (sign_extend:SI (match_dup 1)))]
907 [(set_attr "type" "compare")
908 (set_attr "length" "4,8")])
910 ;; IBM 405 and 440 half-word multiplication operations.
912 (define_insn "*macchwc"
913 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
914 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
915 (match_operand:SI 2 "gpc_reg_operand" "r")
918 (match_operand:HI 1 "gpc_reg_operand" "r")))
919 (match_operand:SI 4 "gpc_reg_operand" "0"))
921 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
922 (plus:SI (mult:SI (ashiftrt:SI
930 [(set_attr "type" "imul3")])
932 (define_insn "*macchw"
933 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
934 (plus:SI (mult:SI (ashiftrt:SI
935 (match_operand:SI 2 "gpc_reg_operand" "r")
938 (match_operand:HI 1 "gpc_reg_operand" "r")))
939 (match_operand:SI 3 "gpc_reg_operand" "0")))]
942 [(set_attr "type" "imul3")])
944 (define_insn "*macchwuc"
945 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
946 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
947 (match_operand:SI 2 "gpc_reg_operand" "r")
950 (match_operand:HI 1 "gpc_reg_operand" "r")))
951 (match_operand:SI 4 "gpc_reg_operand" "0"))
953 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
954 (plus:SI (mult:SI (lshiftrt:SI
961 "macchwu. %0, %1, %2"
962 [(set_attr "type" "imul3")])
964 (define_insn "*macchwu"
965 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
966 (plus:SI (mult:SI (lshiftrt:SI
967 (match_operand:SI 2 "gpc_reg_operand" "r")
970 (match_operand:HI 1 "gpc_reg_operand" "r")))
971 (match_operand:SI 3 "gpc_reg_operand" "0")))]
974 [(set_attr "type" "imul3")])
976 (define_insn "*machhwc"
977 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
978 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
979 (match_operand:SI 1 "gpc_reg_operand" "%r")
982 (match_operand:SI 2 "gpc_reg_operand" "r")
984 (match_operand:SI 4 "gpc_reg_operand" "0"))
986 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
987 (plus:SI (mult:SI (ashiftrt:SI
996 [(set_attr "type" "imul3")])
998 (define_insn "*machhw"
999 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1000 (plus:SI (mult:SI (ashiftrt:SI
1001 (match_operand:SI 1 "gpc_reg_operand" "%r")
1004 (match_operand:SI 2 "gpc_reg_operand" "r")
1006 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1009 [(set_attr "type" "imul3")])
1011 (define_insn "*machhwuc"
1012 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1013 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
1014 (match_operand:SI 1 "gpc_reg_operand" "%r")
1017 (match_operand:SI 2 "gpc_reg_operand" "r")
1019 (match_operand:SI 4 "gpc_reg_operand" "0"))
1021 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1022 (plus:SI (mult:SI (lshiftrt:SI
1030 "machhwu. %0, %1, %2"
1031 [(set_attr "type" "imul3")])
1033 (define_insn "*machhwu"
1034 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1035 (plus:SI (mult:SI (lshiftrt:SI
1036 (match_operand:SI 1 "gpc_reg_operand" "%r")
1039 (match_operand:SI 2 "gpc_reg_operand" "r")
1041 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1043 "machhwu %0, %1, %2"
1044 [(set_attr "type" "imul3")])
1046 (define_insn "*maclhwc"
1047 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1048 (compare:CC (plus:SI (mult:SI (sign_extend:SI
1049 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1051 (match_operand:HI 2 "gpc_reg_operand" "r")))
1052 (match_operand:SI 4 "gpc_reg_operand" "0"))
1054 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1055 (plus:SI (mult:SI (sign_extend:SI
1061 "maclhw. %0, %1, %2"
1062 [(set_attr "type" "imul3")])
1064 (define_insn "*maclhw"
1065 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1066 (plus:SI (mult:SI (sign_extend:SI
1067 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1069 (match_operand:HI 2 "gpc_reg_operand" "r")))
1070 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1073 [(set_attr "type" "imul3")])
1075 (define_insn "*maclhwuc"
1076 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1077 (compare:CC (plus:SI (mult:SI (zero_extend:SI
1078 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1080 (match_operand:HI 2 "gpc_reg_operand" "r")))
1081 (match_operand:SI 4 "gpc_reg_operand" "0"))
1083 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1084 (plus:SI (mult:SI (zero_extend:SI
1090 "maclhwu. %0, %1, %2"
1091 [(set_attr "type" "imul3")])
1093 (define_insn "*maclhwu"
1094 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1095 (plus:SI (mult:SI (zero_extend:SI
1096 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1098 (match_operand:HI 2 "gpc_reg_operand" "r")))
1099 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1101 "maclhwu %0, %1, %2"
1102 [(set_attr "type" "imul3")])
1104 (define_insn "*nmacchwc"
1105 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1106 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1107 (mult:SI (ashiftrt:SI
1108 (match_operand:SI 2 "gpc_reg_operand" "r")
1111 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1113 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1114 (minus:SI (match_dup 4)
1115 (mult:SI (ashiftrt:SI
1121 "nmacchw. %0, %1, %2"
1122 [(set_attr "type" "imul3")])
1124 (define_insn "*nmacchw"
1125 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1126 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1127 (mult:SI (ashiftrt:SI
1128 (match_operand:SI 2 "gpc_reg_operand" "r")
1131 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1133 "nmacchw %0, %1, %2"
1134 [(set_attr "type" "imul3")])
1136 (define_insn "*nmachhwc"
1137 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1138 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1139 (mult:SI (ashiftrt:SI
1140 (match_operand:SI 1 "gpc_reg_operand" "%r")
1143 (match_operand:SI 2 "gpc_reg_operand" "r")
1146 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1147 (minus:SI (match_dup 4)
1148 (mult:SI (ashiftrt:SI
1155 "nmachhw. %0, %1, %2"
1156 [(set_attr "type" "imul3")])
1158 (define_insn "*nmachhw"
1159 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1160 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1161 (mult:SI (ashiftrt:SI
1162 (match_operand:SI 1 "gpc_reg_operand" "%r")
1165 (match_operand:SI 2 "gpc_reg_operand" "r")
1168 "nmachhw %0, %1, %2"
1169 [(set_attr "type" "imul3")])
1171 (define_insn "*nmaclhwc"
1172 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1173 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1174 (mult:SI (sign_extend:SI
1175 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1177 (match_operand:HI 2 "gpc_reg_operand" "r"))))
1179 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1180 (minus:SI (match_dup 4)
1181 (mult:SI (sign_extend:SI
1186 "nmaclhw. %0, %1, %2"
1187 [(set_attr "type" "imul3")])
1189 (define_insn "*nmaclhw"
1190 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1191 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1192 (mult:SI (sign_extend:SI
1193 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1195 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1197 "nmaclhw %0, %1, %2"
1198 [(set_attr "type" "imul3")])
1200 (define_insn "*mulchwc"
1201 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1202 (compare:CC (mult:SI (ashiftrt:SI
1203 (match_operand:SI 2 "gpc_reg_operand" "r")
1206 (match_operand:HI 1 "gpc_reg_operand" "r")))
1208 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1209 (mult:SI (ashiftrt:SI
1215 "mulchw. %0, %1, %2"
1216 [(set_attr "type" "imul3")])
1218 (define_insn "*mulchw"
1219 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1220 (mult:SI (ashiftrt:SI
1221 (match_operand:SI 2 "gpc_reg_operand" "r")
1224 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1227 [(set_attr "type" "imul3")])
1229 (define_insn "*mulchwuc"
1230 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1231 (compare:CC (mult:SI (lshiftrt:SI
1232 (match_operand:SI 2 "gpc_reg_operand" "r")
1235 (match_operand:HI 1 "gpc_reg_operand" "r")))
1237 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1238 (mult:SI (lshiftrt:SI
1244 "mulchwu. %0, %1, %2"
1245 [(set_attr "type" "imul3")])
1247 (define_insn "*mulchwu"
1248 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1249 (mult:SI (lshiftrt:SI
1250 (match_operand:SI 2 "gpc_reg_operand" "r")
1253 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1255 "mulchwu %0, %1, %2"
1256 [(set_attr "type" "imul3")])
1258 (define_insn "*mulhhwc"
1259 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1260 (compare:CC (mult:SI (ashiftrt:SI
1261 (match_operand:SI 1 "gpc_reg_operand" "%r")
1264 (match_operand:SI 2 "gpc_reg_operand" "r")
1267 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1268 (mult:SI (ashiftrt:SI
1275 "mulhhw. %0, %1, %2"
1276 [(set_attr "type" "imul3")])
1278 (define_insn "*mulhhw"
1279 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1280 (mult:SI (ashiftrt:SI
1281 (match_operand:SI 1 "gpc_reg_operand" "%r")
1284 (match_operand:SI 2 "gpc_reg_operand" "r")
1288 [(set_attr "type" "imul3")])
1290 (define_insn "*mulhhwuc"
1291 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1292 (compare:CC (mult:SI (lshiftrt:SI
1293 (match_operand:SI 1 "gpc_reg_operand" "%r")
1296 (match_operand:SI 2 "gpc_reg_operand" "r")
1299 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1300 (mult:SI (lshiftrt:SI
1307 "mulhhwu. %0, %1, %2"
1308 [(set_attr "type" "imul3")])
1310 (define_insn "*mulhhwu"
1311 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1312 (mult:SI (lshiftrt:SI
1313 (match_operand:SI 1 "gpc_reg_operand" "%r")
1316 (match_operand:SI 2 "gpc_reg_operand" "r")
1319 "mulhhwu %0, %1, %2"
1320 [(set_attr "type" "imul3")])
1322 (define_insn "*mullhwc"
1323 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1324 (compare:CC (mult:SI (sign_extend:SI
1325 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1327 (match_operand:HI 2 "gpc_reg_operand" "r")))
1329 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1330 (mult:SI (sign_extend:SI
1335 "mullhw. %0, %1, %2"
1336 [(set_attr "type" "imul3")])
1338 (define_insn "*mullhw"
1339 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1340 (mult:SI (sign_extend:SI
1341 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1343 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1346 [(set_attr "type" "imul3")])
1348 (define_insn "*mullhwuc"
1349 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1350 (compare:CC (mult:SI (zero_extend:SI
1351 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1353 (match_operand:HI 2 "gpc_reg_operand" "r")))
1355 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1356 (mult:SI (zero_extend:SI
1361 "mullhwu. %0, %1, %2"
1362 [(set_attr "type" "imul3")])
1364 (define_insn "*mullhwu"
1365 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1366 (mult:SI (zero_extend:SI
1367 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1369 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1371 "mullhwu %0, %1, %2"
1372 [(set_attr "type" "imul3")])
1374 ;; IBM 405 and 440 string-search dlmzb instruction support.
1375 (define_insn "dlmzb"
1376 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1377 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1378 (match_operand:SI 2 "gpc_reg_operand" "r")]
1380 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1381 (unspec:SI [(match_dup 1)
1385 "dlmzb. %0, %1, %2")
1387 (define_expand "strlensi"
1388 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1389 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1390 (match_operand:QI 2 "const_int_operand" "")
1391 (match_operand 3 "const_int_operand" "")]
1392 UNSPEC_DLMZB_STRLEN))
1393 (clobber (match_scratch:CC 4 "=x"))]
1394 "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1396 rtx result = operands[0];
1397 rtx src = operands[1];
1398 rtx search_char = operands[2];
1399 rtx align = operands[3];
1400 rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1401 rtx loop_label, end_label, mem, cr0, cond;
1402 if (search_char != const0_rtx
1403 || GET_CODE (align) != CONST_INT
1404 || INTVAL (align) < 8)
1406 word1 = gen_reg_rtx (SImode);
1407 word2 = gen_reg_rtx (SImode);
1408 scratch_dlmzb = gen_reg_rtx (SImode);
1409 scratch_string = gen_reg_rtx (Pmode);
1410 loop_label = gen_label_rtx ();
1411 end_label = gen_label_rtx ();
1412 addr = force_reg (Pmode, XEXP (src, 0));
1413 emit_move_insn (scratch_string, addr);
1414 emit_label (loop_label);
1415 mem = change_address (src, SImode, scratch_string);
1416 emit_move_insn (word1, mem);
1417 emit_move_insn (word2, adjust_address (mem, SImode, 4));
1418 cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1419 emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1420 cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1421 emit_jump_insn (gen_rtx_SET (VOIDmode,
1423 gen_rtx_IF_THEN_ELSE (VOIDmode,
1429 emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1430 emit_jump_insn (gen_rtx_SET (VOIDmode,
1432 gen_rtx_LABEL_REF (VOIDmode, loop_label)));
1434 emit_label (end_label);
1435 emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1436 emit_insn (gen_subsi3 (result, scratch_string, addr));
1437 emit_insn (gen_subsi3 (result, result, const1_rtx));
1442 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1443 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1445 (set (match_operand:SI 0 "gpc_reg_operand" "")
1446 (sign_extend:SI (match_dup 1)))]
1449 (sign_extend:SI (match_dup 1)))
1451 (compare:CC (match_dup 0)
1455 ;; Fixed-point arithmetic insns.
1457 (define_expand "add<mode>3"
1458 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1459 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1460 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1463 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1465 if (non_short_cint_operand (operands[2], DImode))
1468 else if (GET_CODE (operands[2]) == CONST_INT
1469 && ! add_operand (operands[2], <MODE>mode))
1471 rtx tmp = ((!can_create_pseudo_p ()
1472 || rtx_equal_p (operands[0], operands[1]))
1473 ? operands[0] : gen_reg_rtx (<MODE>mode));
1475 HOST_WIDE_INT val = INTVAL (operands[2]);
1476 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1477 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1479 if (<MODE>mode == DImode && !satisfies_constraint_L (GEN_INT (rest)))
1482 /* The ordering here is important for the prolog expander.
1483 When space is allocated from the stack, adding 'low' first may
1484 produce a temporary deallocation (which would be bad). */
1485 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1486 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1491 ;; Discourage ai/addic because of carry but provide it in an alternative
1492 ;; allowing register zero as source.
1493 (define_insn "*add<mode>3_internal1"
1494 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1495 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1496 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
1497 "!DECIMAL_FLOAT_MODE_P (GET_MODE (operands[0])) && !DECIMAL_FLOAT_MODE_P (GET_MODE (operands[1]))"
1500 {cal %0,%2(%1)|addi %0,%1,%2}
1502 {cau|addis} %0,%1,%v2"
1503 [(set_attr "length" "4,4,4,4")])
1505 (define_insn "addsi3_high"
1506 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1507 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1508 (high:SI (match_operand 2 "" ""))))]
1509 "TARGET_MACHO && !TARGET_64BIT"
1510 "{cau|addis} %0,%1,ha16(%2)"
1511 [(set_attr "length" "4")])
1513 (define_insn "*add<mode>3_internal2"
1514 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1515 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1516 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1518 (clobber (match_scratch:P 3 "=r,r,r,r"))]
1521 {cax.|add.} %3,%1,%2
1522 {ai.|addic.} %3,%1,%2
1525 [(set_attr "type" "fast_compare,compare,compare,compare")
1526 (set_attr "length" "4,4,8,8")])
1529 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1530 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1531 (match_operand:GPR 2 "reg_or_short_operand" ""))
1533 (clobber (match_scratch:GPR 3 ""))]
1536 (plus:GPR (match_dup 1)
1539 (compare:CC (match_dup 3)
1543 (define_insn "*add<mode>3_internal3"
1544 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1545 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1546 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1548 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1549 (plus:P (match_dup 1)
1553 {cax.|add.} %0,%1,%2
1554 {ai.|addic.} %0,%1,%2
1557 [(set_attr "type" "fast_compare,compare,compare,compare")
1558 (set_attr "length" "4,4,8,8")])
1561 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1562 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1563 (match_operand:P 2 "reg_or_short_operand" ""))
1565 (set (match_operand:P 0 "gpc_reg_operand" "")
1566 (plus:P (match_dup 1) (match_dup 2)))]
1569 (plus:P (match_dup 1)
1572 (compare:CC (match_dup 0)
1576 ;; Split an add that we can't do in one insn into two insns, each of which
1577 ;; does one 16-bit part. This is used by combine. Note that the low-order
1578 ;; add should be last in case the result gets used in an address.
1581 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1582 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1583 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1585 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1586 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1588 HOST_WIDE_INT val = INTVAL (operands[2]);
1589 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1590 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1592 operands[4] = GEN_INT (low);
1593 if (<MODE>mode == SImode || satisfies_constraint_L (GEN_INT (rest)))
1594 operands[3] = GEN_INT (rest);
1595 else if (can_create_pseudo_p ())
1597 operands[3] = gen_reg_rtx (DImode);
1598 emit_move_insn (operands[3], operands[2]);
1599 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1606 (define_insn "one_cmpl<mode>2"
1607 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1608 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1613 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1614 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1616 (clobber (match_scratch:P 2 "=r,r"))]
1621 [(set_attr "type" "compare")
1622 (set_attr "length" "4,8")])
1625 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1626 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1628 (clobber (match_scratch:P 2 ""))]
1631 (not:P (match_dup 1)))
1633 (compare:CC (match_dup 2)
1638 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1639 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1641 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1642 (not:P (match_dup 1)))]
1647 [(set_attr "type" "compare")
1648 (set_attr "length" "4,8")])
1651 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1652 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1654 (set (match_operand:P 0 "gpc_reg_operand" "")
1655 (not:P (match_dup 1)))]
1658 (not:P (match_dup 1)))
1660 (compare:CC (match_dup 0)
1665 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1666 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1667 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1669 "{sf%I1|subf%I1c} %0,%2,%1")
1672 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1673 (minus:GPR (match_operand:GPR 1 "reg_or_short_operand" "r,I")
1674 (match_operand:GPR 2 "gpc_reg_operand" "r,r")))]
1681 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1682 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1683 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1685 (clobber (match_scratch:SI 3 "=r,r"))]
1688 {sf.|subfc.} %3,%2,%1
1690 [(set_attr "type" "compare")
1691 (set_attr "length" "4,8")])
1694 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1695 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1696 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1698 (clobber (match_scratch:P 3 "=r,r"))]
1703 [(set_attr "type" "fast_compare")
1704 (set_attr "length" "4,8")])
1707 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1708 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1709 (match_operand:P 2 "gpc_reg_operand" ""))
1711 (clobber (match_scratch:P 3 ""))]
1714 (minus:P (match_dup 1)
1717 (compare:CC (match_dup 3)
1722 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1723 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1724 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1726 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1727 (minus:SI (match_dup 1) (match_dup 2)))]
1730 {sf.|subfc.} %0,%2,%1
1732 [(set_attr "type" "compare")
1733 (set_attr "length" "4,8")])
1736 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1737 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1738 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1740 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1741 (minus:P (match_dup 1)
1747 [(set_attr "type" "fast_compare")
1748 (set_attr "length" "4,8")])
1751 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1752 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1753 (match_operand:P 2 "gpc_reg_operand" ""))
1755 (set (match_operand:P 0 "gpc_reg_operand" "")
1756 (minus:P (match_dup 1)
1760 (minus:P (match_dup 1)
1763 (compare:CC (match_dup 0)
1767 (define_expand "sub<mode>3"
1768 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1769 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1770 (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
1774 if (GET_CODE (operands[2]) == CONST_INT)
1776 emit_insn (gen_add<mode>3 (operands[0], operands[1],
1777 negate_rtx (<MODE>mode, operands[2])));
1782 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1783 ;; instruction and some auxiliary computations. Then we just have a single
1784 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1787 (define_expand "sminsi3"
1789 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1790 (match_operand:SI 2 "reg_or_short_operand" ""))
1792 (minus:SI (match_dup 2) (match_dup 1))))
1793 (set (match_operand:SI 0 "gpc_reg_operand" "")
1794 (minus:SI (match_dup 2) (match_dup 3)))]
1795 "TARGET_POWER || TARGET_ISEL"
1800 operands[2] = force_reg (SImode, operands[2]);
1801 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1805 operands[3] = gen_reg_rtx (SImode);
1809 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1810 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1811 (match_operand:SI 2 "reg_or_short_operand" "")))
1812 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1815 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1817 (minus:SI (match_dup 2) (match_dup 1))))
1818 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1821 (define_expand "smaxsi3"
1823 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1824 (match_operand:SI 2 "reg_or_short_operand" ""))
1826 (minus:SI (match_dup 2) (match_dup 1))))
1827 (set (match_operand:SI 0 "gpc_reg_operand" "")
1828 (plus:SI (match_dup 3) (match_dup 1)))]
1829 "TARGET_POWER || TARGET_ISEL"
1834 operands[2] = force_reg (SImode, operands[2]);
1835 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1838 operands[3] = gen_reg_rtx (SImode);
1842 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1843 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1844 (match_operand:SI 2 "reg_or_short_operand" "")))
1845 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1848 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1850 (minus:SI (match_dup 2) (match_dup 1))))
1851 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1854 (define_expand "uminsi3"
1855 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1857 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1859 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1861 (minus:SI (match_dup 4) (match_dup 3))))
1862 (set (match_operand:SI 0 "gpc_reg_operand" "")
1863 (minus:SI (match_dup 2) (match_dup 3)))]
1864 "TARGET_POWER || TARGET_ISEL"
1869 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1872 operands[3] = gen_reg_rtx (SImode);
1873 operands[4] = gen_reg_rtx (SImode);
1874 operands[5] = GEN_INT (-2147483647 - 1);
1877 (define_expand "umaxsi3"
1878 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1880 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1882 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1884 (minus:SI (match_dup 4) (match_dup 3))))
1885 (set (match_operand:SI 0 "gpc_reg_operand" "")
1886 (plus:SI (match_dup 3) (match_dup 1)))]
1887 "TARGET_POWER || TARGET_ISEL"
1892 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1895 operands[3] = gen_reg_rtx (SImode);
1896 operands[4] = gen_reg_rtx (SImode);
1897 operands[5] = GEN_INT (-2147483647 - 1);
1901 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1902 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1903 (match_operand:SI 2 "reg_or_short_operand" "rI"))
1905 (minus:SI (match_dup 2) (match_dup 1))))]
1910 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1912 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1913 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1915 (minus:SI (match_dup 2) (match_dup 1)))
1917 (clobber (match_scratch:SI 3 "=r,r"))]
1922 [(set_attr "type" "delayed_compare")
1923 (set_attr "length" "4,8")])
1926 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1928 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1929 (match_operand:SI 2 "reg_or_short_operand" ""))
1931 (minus:SI (match_dup 2) (match_dup 1)))
1933 (clobber (match_scratch:SI 3 ""))]
1934 "TARGET_POWER && reload_completed"
1936 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1938 (minus:SI (match_dup 2) (match_dup 1))))
1940 (compare:CC (match_dup 3)
1945 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1947 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1948 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1950 (minus:SI (match_dup 2) (match_dup 1)))
1952 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1953 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1955 (minus:SI (match_dup 2) (match_dup 1))))]
1960 [(set_attr "type" "delayed_compare")
1961 (set_attr "length" "4,8")])
1964 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1966 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1967 (match_operand:SI 2 "reg_or_short_operand" ""))
1969 (minus:SI (match_dup 2) (match_dup 1)))
1971 (set (match_operand:SI 0 "gpc_reg_operand" "")
1972 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1974 (minus:SI (match_dup 2) (match_dup 1))))]
1975 "TARGET_POWER && reload_completed"
1977 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1979 (minus:SI (match_dup 2) (match_dup 1))))
1981 (compare:CC (match_dup 0)
1985 ;; We don't need abs with condition code because such comparisons should
1987 (define_expand "abssi2"
1988 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1989 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1995 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
1998 else if (! TARGET_POWER)
2000 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
2005 (define_insn "*abssi2_power"
2006 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2007 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2011 (define_insn_and_split "abssi2_isel"
2012 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2013 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
2014 (clobber (match_scratch:SI 2 "=&b"))
2015 (clobber (match_scratch:CC 3 "=y"))]
2018 "&& reload_completed"
2019 [(set (match_dup 2) (neg:SI (match_dup 1)))
2021 (compare:CC (match_dup 1)
2024 (if_then_else:SI (ge (match_dup 3)
2030 (define_insn_and_split "abssi2_nopower"
2031 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2032 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
2033 (clobber (match_scratch:SI 2 "=&r,&r"))]
2034 "! TARGET_POWER && ! TARGET_ISEL"
2036 "&& reload_completed"
2037 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2038 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2039 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
2042 (define_insn "*nabs_power"
2043 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2044 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
2048 (define_insn_and_split "*nabs_nopower"
2049 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2050 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
2051 (clobber (match_scratch:SI 2 "=&r,&r"))]
2054 "&& reload_completed"
2055 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2056 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2057 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
2060 (define_expand "neg<mode>2"
2061 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2062 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
2066 (define_insn "*neg<mode>2_internal"
2067 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2068 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2073 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2074 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2076 (clobber (match_scratch:P 2 "=r,r"))]
2081 [(set_attr "type" "fast_compare")
2082 (set_attr "length" "4,8")])
2085 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2086 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2088 (clobber (match_scratch:P 2 ""))]
2091 (neg:P (match_dup 1)))
2093 (compare:CC (match_dup 2)
2098 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2099 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2101 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2102 (neg:P (match_dup 1)))]
2107 [(set_attr "type" "fast_compare")
2108 (set_attr "length" "4,8")])
2111 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2112 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2114 (set (match_operand:P 0 "gpc_reg_operand" "")
2115 (neg:P (match_dup 1)))]
2118 (neg:P (match_dup 1)))
2120 (compare:CC (match_dup 0)
2124 (define_insn "clz<mode>2"
2125 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2126 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2128 "{cntlz|cntlz<wd>} %0,%1"
2129 [(set_attr "type" "cntlz")])
2131 (define_expand "ctz<mode>2"
2133 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
2134 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2136 (clobber (scratch:CC))])
2137 (set (match_dup 4) (clz:GPR (match_dup 3)))
2138 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2139 (minus:GPR (match_dup 5) (match_dup 4)))]
2142 operands[2] = gen_reg_rtx (<MODE>mode);
2143 operands[3] = gen_reg_rtx (<MODE>mode);
2144 operands[4] = gen_reg_rtx (<MODE>mode);
2145 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
2148 (define_expand "ffs<mode>2"
2150 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
2151 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2153 (clobber (scratch:CC))])
2154 (set (match_dup 4) (clz:GPR (match_dup 3)))
2155 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2156 (minus:GPR (match_dup 5) (match_dup 4)))]
2159 operands[2] = gen_reg_rtx (<MODE>mode);
2160 operands[3] = gen_reg_rtx (<MODE>mode);
2161 operands[4] = gen_reg_rtx (<MODE>mode);
2162 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
2165 (define_insn "popcntb<mode>2"
2166 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2167 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2172 (define_expand "popcount<mode>2"
2173 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2174 (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
2177 rs6000_emit_popcount (operands[0], operands[1]);
2181 (define_expand "parity<mode>2"
2182 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2183 (parity:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
2186 rs6000_emit_parity (operands[0], operands[1]);
2190 (define_insn "bswapsi2"
2191 [(set (match_operand:SI 0 "reg_or_mem_operand" "=r,Z,&r")
2192 (bswap:SI (match_operand:SI 1 "reg_or_mem_operand" "Z,r,r")))]
2196 {stbrx|stwbrx} %1,%y0
2198 [(set_attr "length" "4,4,12")])
2201 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2202 (bswap:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2205 (rotate:SI (match_dup 1) (const_int 8)))
2206 (set (zero_extract:SI (match_dup 0)
2210 (set (zero_extract:SI (match_dup 0)
2213 (rotate:SI (match_dup 1)
2217 (define_expand "mulsi3"
2218 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2219 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2220 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2225 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2227 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2231 (define_insn "mulsi3_mq"
2232 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2233 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2234 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2235 (clobber (match_scratch:SI 3 "=q,q"))]
2238 {muls|mullw} %0,%1,%2
2239 {muli|mulli} %0,%1,%2"
2241 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2242 (const_string "imul3")
2243 (match_operand:SI 2 "short_cint_operand" "")
2244 (const_string "imul2")]
2245 (const_string "imul")))])
2247 (define_insn "mulsi3_no_mq"
2248 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2249 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2250 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2253 {muls|mullw} %0,%1,%2
2254 {muli|mulli} %0,%1,%2"
2256 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2257 (const_string "imul3")
2258 (match_operand:SI 2 "short_cint_operand" "")
2259 (const_string "imul2")]
2260 (const_string "imul")))])
2262 (define_insn "*mulsi3_mq_internal1"
2263 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2264 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2265 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2267 (clobber (match_scratch:SI 3 "=r,r"))
2268 (clobber (match_scratch:SI 4 "=q,q"))]
2271 {muls.|mullw.} %3,%1,%2
2273 [(set_attr "type" "imul_compare")
2274 (set_attr "length" "4,8")])
2277 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2278 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2279 (match_operand:SI 2 "gpc_reg_operand" ""))
2281 (clobber (match_scratch:SI 3 ""))
2282 (clobber (match_scratch:SI 4 ""))]
2283 "TARGET_POWER && reload_completed"
2284 [(parallel [(set (match_dup 3)
2285 (mult:SI (match_dup 1) (match_dup 2)))
2286 (clobber (match_dup 4))])
2288 (compare:CC (match_dup 3)
2292 (define_insn "*mulsi3_no_mq_internal1"
2293 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2294 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2295 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2297 (clobber (match_scratch:SI 3 "=r,r"))]
2300 {muls.|mullw.} %3,%1,%2
2302 [(set_attr "type" "imul_compare")
2303 (set_attr "length" "4,8")])
2306 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2307 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2308 (match_operand:SI 2 "gpc_reg_operand" ""))
2310 (clobber (match_scratch:SI 3 ""))]
2311 "! TARGET_POWER && reload_completed"
2313 (mult:SI (match_dup 1) (match_dup 2)))
2315 (compare:CC (match_dup 3)
2319 (define_insn "*mulsi3_mq_internal2"
2320 [(set (match_operand:CC 3 "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 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2325 (mult:SI (match_dup 1) (match_dup 2)))
2326 (clobber (match_scratch:SI 4 "=q,q"))]
2329 {muls.|mullw.} %0,%1,%2
2331 [(set_attr "type" "imul_compare")
2332 (set_attr "length" "4,8")])
2335 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2336 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2337 (match_operand:SI 2 "gpc_reg_operand" ""))
2339 (set (match_operand:SI 0 "gpc_reg_operand" "")
2340 (mult:SI (match_dup 1) (match_dup 2)))
2341 (clobber (match_scratch:SI 4 ""))]
2342 "TARGET_POWER && reload_completed"
2343 [(parallel [(set (match_dup 0)
2344 (mult:SI (match_dup 1) (match_dup 2)))
2345 (clobber (match_dup 4))])
2347 (compare:CC (match_dup 0)
2351 (define_insn "*mulsi3_no_mq_internal2"
2352 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2353 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2354 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2356 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2357 (mult:SI (match_dup 1) (match_dup 2)))]
2360 {muls.|mullw.} %0,%1,%2
2362 [(set_attr "type" "imul_compare")
2363 (set_attr "length" "4,8")])
2366 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2367 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2368 (match_operand:SI 2 "gpc_reg_operand" ""))
2370 (set (match_operand:SI 0 "gpc_reg_operand" "")
2371 (mult:SI (match_dup 1) (match_dup 2)))]
2372 "! TARGET_POWER && reload_completed"
2374 (mult:SI (match_dup 1) (match_dup 2)))
2376 (compare:CC (match_dup 0)
2380 ;; Operand 1 is divided by operand 2; quotient goes to operand
2381 ;; 0 and remainder to operand 3.
2382 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2384 (define_expand "divmodsi4"
2385 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2386 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2387 (match_operand:SI 2 "gpc_reg_operand" "")))
2388 (set (match_operand:SI 3 "register_operand" "")
2389 (mod:SI (match_dup 1) (match_dup 2)))])]
2390 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2393 if (! TARGET_POWER && ! TARGET_POWERPC)
2395 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2396 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2397 emit_insn (gen_divss_call ());
2398 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2399 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2404 (define_insn "*divmodsi4_internal"
2405 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2406 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2407 (match_operand:SI 2 "gpc_reg_operand" "r")))
2408 (set (match_operand:SI 3 "register_operand" "=q")
2409 (mod:SI (match_dup 1) (match_dup 2)))]
2412 [(set_attr "type" "idiv")])
2414 (define_expand "udiv<mode>3"
2415 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2416 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2417 (match_operand:GPR 2 "gpc_reg_operand" "")))]
2418 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2421 if (! TARGET_POWER && ! TARGET_POWERPC)
2423 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2424 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2425 emit_insn (gen_quous_call ());
2426 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2429 else if (TARGET_POWER)
2431 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2436 (define_insn "udivsi3_mq"
2437 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2438 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2439 (match_operand:SI 2 "gpc_reg_operand" "r")))
2440 (clobber (match_scratch:SI 3 "=q"))]
2441 "TARGET_POWERPC && TARGET_POWER"
2443 [(set_attr "type" "idiv")])
2445 (define_insn "*udivsi3_no_mq"
2446 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2447 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2448 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2449 "TARGET_POWERPC && ! TARGET_POWER"
2452 (cond [(match_operand:SI 0 "" "")
2453 (const_string "idiv")]
2454 (const_string "ldiv")))])
2457 ;; For powers of two we can do srai/aze for divide and then adjust for
2458 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2459 ;; used; for PowerPC, force operands into register and do a normal divide;
2460 ;; for AIX common-mode, use quoss call on register operands.
2461 (define_expand "div<mode>3"
2462 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2463 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2464 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2468 if (GET_CODE (operands[2]) == CONST_INT
2469 && INTVAL (operands[2]) > 0
2470 && exact_log2 (INTVAL (operands[2])) >= 0)
2472 else if (TARGET_POWERPC)
2474 operands[2] = force_reg (<MODE>mode, operands[2]);
2477 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2481 else if (TARGET_POWER)
2485 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2486 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2487 emit_insn (gen_quoss_call ());
2488 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2493 (define_insn "divsi3_mq"
2494 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2495 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2496 (match_operand:SI 2 "gpc_reg_operand" "r")))
2497 (clobber (match_scratch:SI 3 "=q"))]
2498 "TARGET_POWERPC && TARGET_POWER"
2500 [(set_attr "type" "idiv")])
2502 (define_insn "*div<mode>3_no_mq"
2503 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2504 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2505 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2506 "TARGET_POWERPC && ! TARGET_POWER"
2509 (cond [(match_operand:SI 0 "" "")
2510 (const_string "idiv")]
2511 (const_string "ldiv")))])
2513 (define_expand "mod<mode>3"
2514 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2515 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2516 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
2524 if (GET_CODE (operands[2]) != CONST_INT
2525 || INTVAL (operands[2]) <= 0
2526 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2529 temp1 = gen_reg_rtx (<MODE>mode);
2530 temp2 = gen_reg_rtx (<MODE>mode);
2532 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2533 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2534 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
2539 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2540 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2541 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
2543 "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
2544 [(set_attr "type" "two")
2545 (set_attr "length" "8")])
2548 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2549 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2550 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2552 (clobber (match_scratch:P 3 "=r,r"))]
2555 {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
2557 [(set_attr "type" "compare")
2558 (set_attr "length" "8,12")])
2561 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2562 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2563 (match_operand:GPR 2 "exact_log2_cint_operand"
2566 (clobber (match_scratch:GPR 3 ""))]
2569 (div:<MODE> (match_dup 1) (match_dup 2)))
2571 (compare:CC (match_dup 3)
2576 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2577 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
2578 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
2580 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2581 (div:P (match_dup 1) (match_dup 2)))]
2584 {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
2586 [(set_attr "type" "compare")
2587 (set_attr "length" "8,12")])
2590 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2591 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2592 (match_operand:GPR 2 "exact_log2_cint_operand"
2595 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2596 (div:GPR (match_dup 1) (match_dup 2)))]
2599 (div:<MODE> (match_dup 1) (match_dup 2)))
2601 (compare:CC (match_dup 0)
2606 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2609 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2611 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2612 (match_operand:SI 3 "gpc_reg_operand" "r")))
2613 (set (match_operand:SI 2 "register_operand" "=*q")
2616 (zero_extend:DI (match_dup 1)) (const_int 32))
2617 (zero_extend:DI (match_dup 4)))
2621 [(set_attr "type" "idiv")])
2623 ;; To do unsigned divide we handle the cases of the divisor looking like a
2624 ;; negative number. If it is a constant that is less than 2**31, we don't
2625 ;; have to worry about the branches. So make a few subroutines here.
2627 ;; First comes the normal case.
2628 (define_expand "udivmodsi4_normal"
2629 [(set (match_dup 4) (const_int 0))
2630 (parallel [(set (match_operand:SI 0 "" "")
2631 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2633 (zero_extend:DI (match_operand:SI 1 "" "")))
2634 (match_operand:SI 2 "" "")))
2635 (set (match_operand:SI 3 "" "")
2636 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2638 (zero_extend:DI (match_dup 1)))
2642 { operands[4] = gen_reg_rtx (SImode); }")
2644 ;; This handles the branches.
2645 (define_expand "udivmodsi4_tests"
2646 [(set (match_operand:SI 0 "" "") (const_int 0))
2647 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2648 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2649 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2650 (label_ref (match_operand:SI 4 "" "")) (pc)))
2651 (set (match_dup 0) (const_int 1))
2652 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2653 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2654 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2655 (label_ref (match_dup 4)) (pc)))]
2658 { operands[5] = gen_reg_rtx (CCUNSmode);
2659 operands[6] = gen_reg_rtx (CCmode);
2662 (define_expand "udivmodsi4"
2663 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2664 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2665 (match_operand:SI 2 "reg_or_cint_operand" "")))
2666 (set (match_operand:SI 3 "gpc_reg_operand" "")
2667 (umod:SI (match_dup 1) (match_dup 2)))])]
2675 if (! TARGET_POWERPC)
2677 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2678 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2679 emit_insn (gen_divus_call ());
2680 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2681 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2688 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2690 operands[2] = force_reg (SImode, operands[2]);
2691 label = gen_label_rtx ();
2692 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2693 operands[3], label));
2696 operands[2] = force_reg (SImode, operands[2]);
2698 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2706 ;; AIX architecture-independent common-mode multiply (DImode),
2707 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
2708 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2709 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2710 ;; assumed unused if generating common-mode, so ignore.
2711 (define_insn "mulh_call"
2714 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2715 (sign_extend:DI (reg:SI 4)))
2717 (clobber (reg:SI 65))]
2718 "! TARGET_POWER && ! TARGET_POWERPC"
2720 [(set_attr "type" "imul")])
2722 (define_insn "mull_call"
2724 (mult:DI (sign_extend:DI (reg:SI 3))
2725 (sign_extend:DI (reg:SI 4))))
2726 (clobber (reg:SI 65))
2727 (clobber (reg:SI 0))]
2728 "! TARGET_POWER && ! TARGET_POWERPC"
2730 [(set_attr "type" "imul")])
2732 (define_insn "divss_call"
2734 (div:SI (reg:SI 3) (reg:SI 4)))
2736 (mod:SI (reg:SI 3) (reg:SI 4)))
2737 (clobber (reg:SI 65))
2738 (clobber (reg:SI 0))]
2739 "! TARGET_POWER && ! TARGET_POWERPC"
2741 [(set_attr "type" "idiv")])
2743 (define_insn "divus_call"
2745 (udiv:SI (reg:SI 3) (reg:SI 4)))
2747 (umod:SI (reg:SI 3) (reg:SI 4)))
2748 (clobber (reg:SI 65))
2749 (clobber (reg:SI 0))
2750 (clobber (match_scratch:CC 0 "=x"))
2751 (clobber (reg:CC 69))]
2752 "! TARGET_POWER && ! TARGET_POWERPC"
2754 [(set_attr "type" "idiv")])
2756 (define_insn "quoss_call"
2758 (div:SI (reg:SI 3) (reg:SI 4)))
2759 (clobber (reg:SI 65))]
2760 "! TARGET_POWER && ! TARGET_POWERPC"
2762 [(set_attr "type" "idiv")])
2764 (define_insn "quous_call"
2766 (udiv:SI (reg:SI 3) (reg:SI 4)))
2767 (clobber (reg:SI 65))
2768 (clobber (reg:SI 0))
2769 (clobber (match_scratch:CC 0 "=x"))
2770 (clobber (reg:CC 69))]
2771 "! TARGET_POWER && ! TARGET_POWERPC"
2773 [(set_attr "type" "idiv")])
2775 ;; Logical instructions
2776 ;; The logical instructions are mostly combined by using match_operator,
2777 ;; but the plain AND insns are somewhat different because there is no
2778 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2779 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2781 (define_insn "andsi3"
2782 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2783 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2784 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2785 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2789 {rlinm|rlwinm} %0,%1,0,%m2,%M2
2790 {andil.|andi.} %0,%1,%b2
2791 {andiu.|andis.} %0,%1,%u2"
2792 [(set_attr "type" "*,*,compare,compare")])
2794 ;; Note to set cr's other than cr0 we do the and immediate and then
2795 ;; the test again -- this avoids a mfcr which on the higher end
2796 ;; machines causes an execution serialization
2798 (define_insn "*andsi3_internal2"
2799 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2800 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2801 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2803 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2804 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2808 {andil.|andi.} %3,%1,%b2
2809 {andiu.|andis.} %3,%1,%u2
2810 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2815 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2816 (set_attr "length" "4,4,4,4,8,8,8,8")])
2818 (define_insn "*andsi3_internal3"
2819 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2820 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2821 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2823 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2824 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2828 {andil.|andi.} %3,%1,%b2
2829 {andiu.|andis.} %3,%1,%u2
2830 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2835 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2836 (set_attr "length" "8,4,4,4,8,8,8,8")])
2839 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2840 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2841 (match_operand:GPR 2 "and_operand" ""))
2843 (clobber (match_scratch:GPR 3 ""))
2844 (clobber (match_scratch:CC 4 ""))]
2846 [(parallel [(set (match_dup 3)
2847 (and:<MODE> (match_dup 1)
2849 (clobber (match_dup 4))])
2851 (compare:CC (match_dup 3)
2855 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
2856 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2859 [(set (match_operand:CC 0 "cc_reg_operand" "")
2860 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2861 (match_operand:SI 2 "gpc_reg_operand" ""))
2863 (clobber (match_scratch:SI 3 ""))
2864 (clobber (match_scratch:CC 4 ""))]
2865 "TARGET_POWERPC64 && reload_completed"
2866 [(parallel [(set (match_dup 3)
2867 (and:SI (match_dup 1)
2869 (clobber (match_dup 4))])
2871 (compare:CC (match_dup 3)
2875 (define_insn "*andsi3_internal4"
2876 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2877 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2878 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2880 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2881 (and:SI (match_dup 1)
2883 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2887 {andil.|andi.} %0,%1,%b2
2888 {andiu.|andis.} %0,%1,%u2
2889 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2894 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2895 (set_attr "length" "4,4,4,4,8,8,8,8")])
2897 (define_insn "*andsi3_internal5"
2898 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2899 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2900 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2902 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2903 (and:SI (match_dup 1)
2905 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2909 {andil.|andi.} %0,%1,%b2
2910 {andiu.|andis.} %0,%1,%u2
2911 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2916 [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2917 (set_attr "length" "8,4,4,4,8,8,8,8")])
2920 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2921 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2922 (match_operand:SI 2 "and_operand" ""))
2924 (set (match_operand:SI 0 "gpc_reg_operand" "")
2925 (and:SI (match_dup 1)
2927 (clobber (match_scratch:CC 4 ""))]
2929 [(parallel [(set (match_dup 0)
2930 (and:SI (match_dup 1)
2932 (clobber (match_dup 4))])
2934 (compare:CC (match_dup 0)
2939 [(set (match_operand:CC 3 "cc_reg_operand" "")
2940 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2941 (match_operand:SI 2 "gpc_reg_operand" ""))
2943 (set (match_operand:SI 0 "gpc_reg_operand" "")
2944 (and:SI (match_dup 1)
2946 (clobber (match_scratch:CC 4 ""))]
2947 "TARGET_POWERPC64 && reload_completed"
2948 [(parallel [(set (match_dup 0)
2949 (and:SI (match_dup 1)
2951 (clobber (match_dup 4))])
2953 (compare:CC (match_dup 0)
2957 ;; Handle the PowerPC64 rlwinm corner case
2959 (define_insn_and_split "*andsi3_internal6"
2960 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2961 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2962 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2967 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2970 (rotate:SI (match_dup 0) (match_dup 5)))]
2973 int mb = extract_MB (operands[2]);
2974 int me = extract_ME (operands[2]);
2975 operands[3] = GEN_INT (me + 1);
2976 operands[5] = GEN_INT (32 - (me + 1));
2977 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2979 [(set_attr "length" "8")])
2981 (define_expand "iorsi3"
2982 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2983 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
2984 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2988 if (GET_CODE (operands[2]) == CONST_INT
2989 && ! logical_operand (operands[2], SImode))
2991 HOST_WIDE_INT value = INTVAL (operands[2]);
2992 rtx tmp = ((!can_create_pseudo_p ()
2993 || rtx_equal_p (operands[0], operands[1]))
2994 ? operands[0] : gen_reg_rtx (SImode));
2996 emit_insn (gen_iorsi3 (tmp, operands[1],
2997 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2998 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3003 (define_expand "xorsi3"
3004 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3005 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
3006 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
3010 if (GET_CODE (operands[2]) == CONST_INT
3011 && ! logical_operand (operands[2], SImode))
3013 HOST_WIDE_INT value = INTVAL (operands[2]);
3014 rtx tmp = ((!can_create_pseudo_p ()
3015 || rtx_equal_p (operands[0], operands[1]))
3016 ? operands[0] : gen_reg_rtx (SImode));
3018 emit_insn (gen_xorsi3 (tmp, operands[1],
3019 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3020 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3025 (define_insn "*boolsi3_internal1"
3026 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
3027 (match_operator:SI 3 "boolean_or_operator"
3028 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
3029 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
3033 {%q3il|%q3i} %0,%1,%b2
3034 {%q3iu|%q3is} %0,%1,%u2")
3036 (define_insn "*boolsi3_internal2"
3037 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3038 (compare:CC (match_operator:SI 4 "boolean_or_operator"
3039 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3040 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3042 (clobber (match_scratch:SI 3 "=r,r"))]
3047 [(set_attr "type" "compare")
3048 (set_attr "length" "4,8")])
3051 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3052 (compare:CC (match_operator:SI 4 "boolean_operator"
3053 [(match_operand:SI 1 "gpc_reg_operand" "")
3054 (match_operand:SI 2 "gpc_reg_operand" "")])
3056 (clobber (match_scratch:SI 3 ""))]
3057 "TARGET_32BIT && reload_completed"
3058 [(set (match_dup 3) (match_dup 4))
3060 (compare:CC (match_dup 3)
3064 (define_insn "*boolsi3_internal3"
3065 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3066 (compare:CC (match_operator:SI 4 "boolean_operator"
3067 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3068 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3070 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3076 [(set_attr "type" "compare")
3077 (set_attr "length" "4,8")])
3080 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3081 (compare:CC (match_operator:SI 4 "boolean_operator"
3082 [(match_operand:SI 1 "gpc_reg_operand" "")
3083 (match_operand:SI 2 "gpc_reg_operand" "")])
3085 (set (match_operand:SI 0 "gpc_reg_operand" "")
3087 "TARGET_32BIT && reload_completed"
3088 [(set (match_dup 0) (match_dup 4))
3090 (compare:CC (match_dup 0)
3094 ;; Split a logical operation that we can't do in one insn into two insns,
3095 ;; each of which does one 16-bit part. This is used by combine.
3098 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3099 (match_operator:SI 3 "boolean_or_operator"
3100 [(match_operand:SI 1 "gpc_reg_operand" "")
3101 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
3103 [(set (match_dup 0) (match_dup 4))
3104 (set (match_dup 0) (match_dup 5))]
3108 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
3109 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3111 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
3112 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3116 (define_insn "*boolcsi3_internal1"
3117 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3118 (match_operator:SI 3 "boolean_operator"
3119 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3120 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
3124 (define_insn "*boolcsi3_internal2"
3125 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3126 (compare:CC (match_operator:SI 4 "boolean_operator"
3127 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3128 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3130 (clobber (match_scratch:SI 3 "=r,r"))]
3135 [(set_attr "type" "compare")
3136 (set_attr "length" "4,8")])
3139 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3140 (compare:CC (match_operator:SI 4 "boolean_operator"
3141 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3142 (match_operand:SI 2 "gpc_reg_operand" "")])
3144 (clobber (match_scratch:SI 3 ""))]
3145 "TARGET_32BIT && reload_completed"
3146 [(set (match_dup 3) (match_dup 4))
3148 (compare:CC (match_dup 3)
3152 (define_insn "*boolcsi3_internal3"
3153 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3154 (compare:CC (match_operator:SI 4 "boolean_operator"
3155 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3156 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3158 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3164 [(set_attr "type" "compare")
3165 (set_attr "length" "4,8")])
3168 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3169 (compare:CC (match_operator:SI 4 "boolean_operator"
3170 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3171 (match_operand:SI 2 "gpc_reg_operand" "")])
3173 (set (match_operand:SI 0 "gpc_reg_operand" "")
3175 "TARGET_32BIT && reload_completed"
3176 [(set (match_dup 0) (match_dup 4))
3178 (compare:CC (match_dup 0)
3182 (define_insn "*boolccsi3_internal1"
3183 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3184 (match_operator:SI 3 "boolean_operator"
3185 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3186 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3190 (define_insn "*boolccsi3_internal2"
3191 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3192 (compare:CC (match_operator:SI 4 "boolean_operator"
3193 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3194 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3196 (clobber (match_scratch:SI 3 "=r,r"))]
3201 [(set_attr "type" "compare")
3202 (set_attr "length" "4,8")])
3205 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3206 (compare:CC (match_operator:SI 4 "boolean_operator"
3207 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3208 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3210 (clobber (match_scratch:SI 3 ""))]
3211 "TARGET_32BIT && reload_completed"
3212 [(set (match_dup 3) (match_dup 4))
3214 (compare:CC (match_dup 3)
3218 (define_insn "*boolccsi3_internal3"
3219 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3220 (compare:CC (match_operator:SI 4 "boolean_operator"
3221 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3222 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3224 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3230 [(set_attr "type" "compare")
3231 (set_attr "length" "4,8")])
3234 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3235 (compare:CC (match_operator:SI 4 "boolean_operator"
3236 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3237 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3239 (set (match_operand:SI 0 "gpc_reg_operand" "")
3241 "TARGET_32BIT && reload_completed"
3242 [(set (match_dup 0) (match_dup 4))
3244 (compare:CC (match_dup 0)
3248 ;; maskir insn. We need four forms because things might be in arbitrary
3249 ;; orders. Don't define forms that only set CR fields because these
3250 ;; would modify an input register.
3252 (define_insn "*maskir_internal1"
3253 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3254 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3255 (match_operand:SI 1 "gpc_reg_operand" "0"))
3256 (and:SI (match_dup 2)
3257 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
3261 (define_insn "*maskir_internal2"
3262 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3263 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3264 (match_operand:SI 1 "gpc_reg_operand" "0"))
3265 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3270 (define_insn "*maskir_internal3"
3271 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3272 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
3273 (match_operand:SI 3 "gpc_reg_operand" "r"))
3274 (and:SI (not:SI (match_dup 2))
3275 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3279 (define_insn "*maskir_internal4"
3280 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3281 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3282 (match_operand:SI 2 "gpc_reg_operand" "r"))
3283 (and:SI (not:SI (match_dup 2))
3284 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3288 (define_insn "*maskir_internal5"
3289 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3291 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3292 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3293 (and:SI (match_dup 2)
3294 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
3296 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3297 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3298 (and:SI (match_dup 2) (match_dup 3))))]
3303 [(set_attr "type" "compare")
3304 (set_attr "length" "4,8")])
3307 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3309 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3310 (match_operand:SI 1 "gpc_reg_operand" ""))
3311 (and:SI (match_dup 2)
3312 (match_operand:SI 3 "gpc_reg_operand" "")))
3314 (set (match_operand:SI 0 "gpc_reg_operand" "")
3315 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3316 (and:SI (match_dup 2) (match_dup 3))))]
3317 "TARGET_POWER && reload_completed"
3319 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3320 (and:SI (match_dup 2) (match_dup 3))))
3322 (compare:CC (match_dup 0)
3326 (define_insn "*maskir_internal6"
3327 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3329 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3330 (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3331 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3334 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3335 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3336 (and:SI (match_dup 3) (match_dup 2))))]
3341 [(set_attr "type" "compare")
3342 (set_attr "length" "4,8")])
3345 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3347 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3348 (match_operand:SI 1 "gpc_reg_operand" ""))
3349 (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3352 (set (match_operand:SI 0 "gpc_reg_operand" "")
3353 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3354 (and:SI (match_dup 3) (match_dup 2))))]
3355 "TARGET_POWER && reload_completed"
3357 (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3358 (and:SI (match_dup 3) (match_dup 2))))
3360 (compare:CC (match_dup 0)
3364 (define_insn "*maskir_internal7"
3365 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3367 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
3368 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
3369 (and:SI (not:SI (match_dup 2))
3370 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3372 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3373 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3374 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3379 [(set_attr "type" "compare")
3380 (set_attr "length" "4,8")])
3383 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3385 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
3386 (match_operand:SI 3 "gpc_reg_operand" ""))
3387 (and:SI (not:SI (match_dup 2))
3388 (match_operand:SI 1 "gpc_reg_operand" "")))
3390 (set (match_operand:SI 0 "gpc_reg_operand" "")
3391 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3392 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3393 "TARGET_POWER && reload_completed"
3395 (ior:SI (and:SI (match_dup 2) (match_dup 3))
3396 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3398 (compare:CC (match_dup 0)
3402 (define_insn "*maskir_internal8"
3403 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3405 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3406 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3407 (and:SI (not:SI (match_dup 2))
3408 (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3410 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3411 (ior:SI (and:SI (match_dup 3) (match_dup 2))
3412 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3417 [(set_attr "type" "compare")
3418 (set_attr "length" "4,8")])
3421 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3423 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3424 (match_operand:SI 2 "gpc_reg_operand" ""))
3425 (and:SI (not:SI (match_dup 2))
3426 (match_operand:SI 1 "gpc_reg_operand" "")))
3428 (set (match_operand:SI 0 "gpc_reg_operand" "")
3429 (ior:SI (and:SI (match_dup 3) (match_dup 2))
3430 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3431 "TARGET_POWER && reload_completed"
3433 (ior:SI (and:SI (match_dup 3) (match_dup 2))
3434 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3436 (compare:CC (match_dup 0)
3440 ;; Rotate and shift insns, in all their variants. These support shifts,
3441 ;; field inserts and extracts, and various combinations thereof.
3442 (define_expand "insv"
3443 [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
3444 (match_operand:SI 1 "const_int_operand" "")
3445 (match_operand:SI 2 "const_int_operand" ""))
3446 (match_operand 3 "gpc_reg_operand" ""))]
3450 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3451 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3452 compiler if the address of the structure is taken later. Likewise, do
3453 not handle invalid E500 subregs. */
3454 if (GET_CODE (operands[0]) == SUBREG
3455 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD
3456 || ((TARGET_E500_DOUBLE || TARGET_SPE)
3457 && invalid_e500_subreg (operands[0], GET_MODE (operands[0])))))
3460 if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
3461 emit_insn (gen_insvdi (operands[0], operands[1], operands[2], operands[3]));
3463 emit_insn (gen_insvsi (operands[0], operands[1], operands[2], operands[3]));
3467 (define_insn "insvsi"
3468 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3469 (match_operand:SI 1 "const_int_operand" "i")
3470 (match_operand:SI 2 "const_int_operand" "i"))
3471 (match_operand:SI 3 "gpc_reg_operand" "r"))]
3475 int start = INTVAL (operands[2]) & 31;
3476 int size = INTVAL (operands[1]) & 31;
3478 operands[4] = GEN_INT (32 - start - size);
3479 operands[1] = GEN_INT (start + size - 1);
3480 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3482 [(set_attr "type" "insert_word")])
3484 (define_insn "*insvsi_internal1"
3485 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3486 (match_operand:SI 1 "const_int_operand" "i")
3487 (match_operand:SI 2 "const_int_operand" "i"))
3488 (rotate:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3489 (match_operand:SI 4 "const_int_operand" "i")))]
3490 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3493 int shift = INTVAL (operands[4]) & 31;
3494 int start = INTVAL (operands[2]) & 31;
3495 int size = INTVAL (operands[1]) & 31;
3497 operands[4] = GEN_INT (shift - start - size);
3498 operands[1] = GEN_INT (start + size - 1);
3499 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3501 [(set_attr "type" "insert_word")])
3503 (define_insn "*insvsi_internal2"
3504 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3505 (match_operand:SI 1 "const_int_operand" "i")
3506 (match_operand:SI 2 "const_int_operand" "i"))
3507 (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3508 (match_operand:SI 4 "const_int_operand" "i")))]
3509 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3512 int shift = INTVAL (operands[4]) & 31;
3513 int start = INTVAL (operands[2]) & 31;
3514 int size = INTVAL (operands[1]) & 31;
3516 operands[4] = GEN_INT (32 - shift - start - size);
3517 operands[1] = GEN_INT (start + size - 1);
3518 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3520 [(set_attr "type" "insert_word")])
3522 (define_insn "*insvsi_internal3"
3523 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3524 (match_operand:SI 1 "const_int_operand" "i")
3525 (match_operand:SI 2 "const_int_operand" "i"))
3526 (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3527 (match_operand:SI 4 "const_int_operand" "i")))]
3528 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3531 int shift = INTVAL (operands[4]) & 31;
3532 int start = INTVAL (operands[2]) & 31;
3533 int size = INTVAL (operands[1]) & 31;
3535 operands[4] = GEN_INT (32 - shift - start - size);
3536 operands[1] = GEN_INT (start + size - 1);
3537 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3539 [(set_attr "type" "insert_word")])
3541 (define_insn "*insvsi_internal4"
3542 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3543 (match_operand:SI 1 "const_int_operand" "i")
3544 (match_operand:SI 2 "const_int_operand" "i"))
3545 (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3546 (match_operand:SI 4 "const_int_operand" "i")
3547 (match_operand:SI 5 "const_int_operand" "i")))]
3548 "INTVAL (operands[4]) >= INTVAL (operands[1])"
3551 int extract_start = INTVAL (operands[5]) & 31;
3552 int extract_size = INTVAL (operands[4]) & 31;
3553 int insert_start = INTVAL (operands[2]) & 31;
3554 int insert_size = INTVAL (operands[1]) & 31;
3556 /* Align extract field with insert field */
3557 operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
3558 operands[1] = GEN_INT (insert_start + insert_size - 1);
3559 return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
3561 [(set_attr "type" "insert_word")])
3563 ;; combine patterns for rlwimi
3564 (define_insn "*insvsi_internal5"
3565 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3566 (ior:SI (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3567 (match_operand:SI 1 "mask_operand" "i"))
3568 (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3569 (match_operand:SI 2 "const_int_operand" "i"))
3570 (match_operand:SI 5 "mask_operand" "i"))))]
3571 "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
3574 int me = extract_ME(operands[5]);
3575 int mb = extract_MB(operands[5]);
3576 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3577 operands[2] = GEN_INT(mb);
3578 operands[1] = GEN_INT(me);
3579 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3581 [(set_attr "type" "insert_word")])
3583 (define_insn "*insvsi_internal6"
3584 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3585 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3586 (match_operand:SI 2 "const_int_operand" "i"))
3587 (match_operand:SI 5 "mask_operand" "i"))
3588 (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3589 (match_operand:SI 1 "mask_operand" "i"))))]
3590 "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
3593 int me = extract_ME(operands[5]);
3594 int mb = extract_MB(operands[5]);
3595 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3596 operands[2] = GEN_INT(mb);
3597 operands[1] = GEN_INT(me);
3598 return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3600 [(set_attr "type" "insert_word")])
3602 (define_insn "insvdi"
3603 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3604 (match_operand:SI 1 "const_int_operand" "i")
3605 (match_operand:SI 2 "const_int_operand" "i"))
3606 (match_operand:DI 3 "gpc_reg_operand" "r"))]
3610 int start = INTVAL (operands[2]) & 63;
3611 int size = INTVAL (operands[1]) & 63;
3613 operands[1] = GEN_INT (64 - start - size);
3614 return \"rldimi %0,%3,%H1,%H2\";
3616 [(set_attr "type" "insert_dword")])
3618 (define_insn "*insvdi_internal2"
3619 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3620 (match_operand:SI 1 "const_int_operand" "i")
3621 (match_operand:SI 2 "const_int_operand" "i"))
3622 (ashiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3623 (match_operand:SI 4 "const_int_operand" "i")))]
3625 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3628 int shift = INTVAL (operands[4]) & 63;
3629 int start = (INTVAL (operands[2]) & 63) - 32;
3630 int size = INTVAL (operands[1]) & 63;
3632 operands[4] = GEN_INT (64 - shift - start - size);
3633 operands[2] = GEN_INT (start);
3634 operands[1] = GEN_INT (start + size - 1);
3635 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3638 (define_insn "*insvdi_internal3"
3639 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3640 (match_operand:SI 1 "const_int_operand" "i")
3641 (match_operand:SI 2 "const_int_operand" "i"))
3642 (lshiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3643 (match_operand:SI 4 "const_int_operand" "i")))]
3645 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3648 int shift = INTVAL (operands[4]) & 63;
3649 int start = (INTVAL (operands[2]) & 63) - 32;
3650 int size = INTVAL (operands[1]) & 63;
3652 operands[4] = GEN_INT (64 - shift - start - size);
3653 operands[2] = GEN_INT (start);
3654 operands[1] = GEN_INT (start + size - 1);
3655 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3658 (define_expand "extzv"
3659 [(set (match_operand 0 "gpc_reg_operand" "")
3660 (zero_extract (match_operand 1 "gpc_reg_operand" "")
3661 (match_operand:SI 2 "const_int_operand" "")
3662 (match_operand:SI 3 "const_int_operand" "")))]
3666 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3667 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3668 compiler if the address of the structure is taken later. */
3669 if (GET_CODE (operands[0]) == SUBREG
3670 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3673 if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3674 emit_insn (gen_extzvdi (operands[0], operands[1], operands[2], operands[3]));
3676 emit_insn (gen_extzvsi (operands[0], operands[1], operands[2], operands[3]));
3680 (define_insn "extzvsi"
3681 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3682 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3683 (match_operand:SI 2 "const_int_operand" "i")
3684 (match_operand:SI 3 "const_int_operand" "i")))]
3688 int start = INTVAL (operands[3]) & 31;
3689 int size = INTVAL (operands[2]) & 31;
3691 if (start + size >= 32)
3692 operands[3] = const0_rtx;
3694 operands[3] = GEN_INT (start + size);
3695 return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
3698 (define_insn "*extzvsi_internal1"
3699 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3700 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3701 (match_operand:SI 2 "const_int_operand" "i,i")
3702 (match_operand:SI 3 "const_int_operand" "i,i"))
3704 (clobber (match_scratch:SI 4 "=r,r"))]
3708 int start = INTVAL (operands[3]) & 31;
3709 int size = INTVAL (operands[2]) & 31;
3711 /* Force split for non-cc0 compare. */
3712 if (which_alternative == 1)
3715 /* If the bit-field being tested fits in the upper or lower half of a
3716 word, it is possible to use andiu. or andil. to test it. This is
3717 useful because the condition register set-use delay is smaller for
3718 andi[ul]. than for rlinm. This doesn't work when the starting bit
3719 position is 0 because the LT and GT bits may be set wrong. */
3721 if ((start > 0 && start + size <= 16) || start >= 16)
3723 operands[3] = GEN_INT (((1 << (16 - (start & 15)))
3724 - (1 << (16 - (start & 15) - size))));
3726 return \"{andiu.|andis.} %4,%1,%3\";
3728 return \"{andil.|andi.} %4,%1,%3\";
3731 if (start + size >= 32)
3732 operands[3] = const0_rtx;
3734 operands[3] = GEN_INT (start + size);
3735 return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
3737 [(set_attr "type" "delayed_compare")
3738 (set_attr "length" "4,8")])
3741 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3742 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3743 (match_operand:SI 2 "const_int_operand" "")
3744 (match_operand:SI 3 "const_int_operand" ""))
3746 (clobber (match_scratch:SI 4 ""))]
3749 (zero_extract:SI (match_dup 1) (match_dup 2)
3752 (compare:CC (match_dup 4)
3756 (define_insn "*extzvsi_internal2"
3757 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3758 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3759 (match_operand:SI 2 "const_int_operand" "i,i")
3760 (match_operand:SI 3 "const_int_operand" "i,i"))
3762 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3763 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3767 int start = INTVAL (operands[3]) & 31;
3768 int size = INTVAL (operands[2]) & 31;
3770 /* Force split for non-cc0 compare. */
3771 if (which_alternative == 1)
3774 /* Since we are using the output value, we can't ignore any need for
3775 a shift. The bit-field must end at the LSB. */
3776 if (start >= 16 && start + size == 32)
3778 operands[3] = GEN_INT ((1 << size) - 1);
3779 return \"{andil.|andi.} %0,%1,%3\";
3782 if (start + size >= 32)
3783 operands[3] = const0_rtx;
3785 operands[3] = GEN_INT (start + size);
3786 return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
3788 [(set_attr "type" "delayed_compare")
3789 (set_attr "length" "4,8")])
3792 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3793 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3794 (match_operand:SI 2 "const_int_operand" "")
3795 (match_operand:SI 3 "const_int