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, 2008, 2009, 2010, 2011
4 ;; Free Software Foundation, Inc.
5 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
7 ;; This file is part of GCC.
9 ;; GCC is free software; you can redistribute it and/or modify it
10 ;; under the terms of the GNU General Public License as published
11 ;; by the Free Software Foundation; either version 3, or (at your
12 ;; option) any later version.
14 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
15 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 ;; License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING3. If not see
21 ;; <http://www.gnu.org/licenses/>.
23 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
43 (FIRST_ALTIVEC_REGNO 77)
44 (LAST_ALTIVEC_REGNO 108)
56 (define_c_enum "unspec"
57 [UNSPEC_FRSP ; frsp for POWER machines
58 UNSPEC_PROBE_STACK ; probe stack memory reference
59 UNSPEC_TIE ; tie stack contents and stack pointer
60 UNSPEC_TOCPTR ; address of a word pointing to the TOC
61 UNSPEC_TOC ; address of the TOC (more-or-less)
63 UNSPEC_MV_CR_OV ; move_from_CR_ov_bit
69 UNSPEC_LD_MPIC ; load_macho_picbase
70 UNSPEC_MPIC_CORRECT ; macho_correct_pic
84 UNSPEC_FIX_TRUNC_TF ; fadd, rounding towards zero
85 UNSPEC_MV_CR_GT ; move_from_CR_gt_bit
102 UNSPEC_MACHOPIC_OFFSET
114 ;; UNSPEC_VOLATILE usage
117 (define_c_enum "unspecv"
119 UNSPECV_LL ; load-locked
120 UNSPECV_SC ; store-conditional
121 UNSPECV_PROBE_STACK_RANGE ; probe range of stack addresses
122 UNSPECV_EH_RR ; eh_reg_restore
123 UNSPECV_ISYNC ; isync instruction
124 UNSPECV_LWSYNC ; lwsync
128 ;; Define an insn type attribute. This is used in function unit delay
130 (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,isel"
131 (const_string "integer"))
133 ;; Define floating point instruction sub-types for use with Xfpu.md
134 (define_attr "fp_type" "fp_default,fp_addsub_s,fp_addsub_d,fp_mul_s,fp_mul_d,fp_div_s,fp_div_d,fp_maddsub_s,fp_maddsub_d,fp_sqrt_s,fp_sqrt_d" (const_string "fp_default"))
136 ;; Length (in bytes).
137 ; '(pc)' in the following doesn't include the instruction itself; it is
138 ; calculated as if the instruction had zero size.
139 (define_attr "length" ""
140 (if_then_else (eq_attr "type" "branch")
141 (if_then_else (and (ge (minus (match_dup 0) (pc))
143 (lt (minus (match_dup 0) (pc))
149 ;; Processor type -- this attribute must exactly match the processor_type
150 ;; enumeration in rs6000.h.
152 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc476,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,ppce300c2,ppce300c3,ppce500mc,ppce500mc64,power4,power5,power6,power7,cell,ppca2,titan"
153 (const (symbol_ref "rs6000_cpu_attr")))
156 ;; If this instruction is microcoded on the CELL processor
157 ; The default for load extended, the recorded instructions and rotate/shifts by a variable is always microcoded
158 (define_attr "cell_micro" "not,conditional,always"
159 (if_then_else (eq_attr "type" "compare,delayed_compare,imul_compare,lmul_compare,load_ext,load_ext_ux,var_shift_rotate,var_delayed_compare")
160 (const_string "always")
161 (const_string "not")))
163 (automata_option "ndfa")
177 (include "e300c2c3.md")
178 (include "e500mc.md")
179 (include "e500mc64.md")
180 (include "power4.md")
181 (include "power5.md")
182 (include "power6.md")
183 (include "power7.md")
189 (include "predicates.md")
190 (include "constraints.md")
192 (include "darwin.md")
197 ; This mode iterator allows :GPR to be used to indicate the allowable size
198 ; of whole values in GPRs.
199 (define_mode_iterator GPR [SI (DI "TARGET_POWERPC64")])
201 ; Any supported integer mode.
202 (define_mode_iterator INT [QI HI SI DI TI])
204 ; Any supported integer mode that fits in one register.
205 (define_mode_iterator INT1 [QI HI SI (DI "TARGET_POWERPC64")])
207 ; extend modes for DImode
208 (define_mode_iterator QHSI [QI HI SI])
210 ; SImode or DImode, even if DImode doesn't fit in GPRs.
211 (define_mode_iterator SDI [SI DI])
213 ; The size of a pointer. Also, the size of the value that a record-condition
214 ; (one with a '.') will compare; and the size used for arithmetic carries.
215 (define_mode_iterator P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
217 ; Any hardware-supported floating-point mode
218 (define_mode_iterator FP [
219 (SF "TARGET_HARD_FLOAT
220 && ((TARGET_FPRS && TARGET_SINGLE_FLOAT) || TARGET_E500_SINGLE)")
221 (DF "TARGET_HARD_FLOAT
222 && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)")
223 (TF "!TARGET_IEEEQUAD
225 && (TARGET_FPRS || TARGET_E500_DOUBLE)
226 && TARGET_LONG_DOUBLE_128")
230 ; Any fma capable floating-point mode.
231 (define_mode_iterator FMA_F [
232 (SF "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT")
233 (DF "(TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
234 || VECTOR_UNIT_VSX_P (DFmode)")
235 (V2SF "TARGET_PAIRED_FLOAT")
236 (V4SF "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)")
237 (V2DF "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V2DFmode)")
240 ; These modes do not fit in integer registers in 32-bit mode.
241 ; but on e500v2, the gpr are 64 bit registers
242 (define_mode_iterator DIFD [DI (DF "!TARGET_E500_DOUBLE") DD])
244 ; Iterator for reciprocal estimate instructions
245 (define_mode_iterator RECIPF [SF DF V4SF V2DF])
247 ; Iterator for just SF/DF
248 (define_mode_iterator SFDF [SF DF])
250 ; Various instructions that come in SI and DI forms.
251 ; A generic w/d attribute, for things like cmpw/cmpd.
252 (define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
255 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
257 ;; ISEL/ISEL64 target selection
258 (define_mode_attr sel [(SI "") (DI "64")])
260 ;; Suffix for reload patterns
261 (define_mode_attr ptrsize [(SI "32bit")
264 (define_mode_attr tptrsize [(SI "TARGET_32BIT")
265 (DI "TARGET_64BIT")])
267 (define_mode_attr mptrsize [(SI "si")
270 (define_mode_attr rreg [(SF "f")
275 (define_mode_attr rreg2 [(SF "f")
278 (define_mode_attr SI_CONVERT_FP [(SF "TARGET_FCFIDS")
279 (DF "TARGET_FCFID")])
281 (define_mode_attr E500_CONVERT [(SF "!TARGET_FPRS")
282 (DF "TARGET_E500_DOUBLE")])
284 (define_mode_attr TARGET_FLOAT [(SF "TARGET_SINGLE_FLOAT")
285 (DF "TARGET_DOUBLE_FLOAT")])
287 ;; Start with fixed-point load and store insns. Here we put only the more
288 ;; complex forms. Basic data transfer is done later.
290 (define_expand "zero_extend<mode>di2"
291 [(set (match_operand:DI 0 "gpc_reg_operand" "")
292 (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "")))]
296 (define_insn "*zero_extend<mode>di2_internal1"
297 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
298 (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
302 rldicl %0,%1,0,<dbits>"
303 [(set_attr "type" "load,*")])
305 (define_insn "*zero_extend<mode>di2_internal2"
306 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
307 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
309 (clobber (match_scratch:DI 2 "=r,r"))]
312 rldicl. %2,%1,0,<dbits>
314 [(set_attr "type" "compare")
315 (set_attr "length" "4,8")])
318 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
319 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
321 (clobber (match_scratch:DI 2 ""))]
322 "TARGET_POWERPC64 && reload_completed"
324 (zero_extend:DI (match_dup 1)))
326 (compare:CC (match_dup 2)
330 (define_insn "*zero_extend<mode>di2_internal3"
331 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
332 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" "r,r"))
334 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
335 (zero_extend:DI (match_dup 1)))]
338 rldicl. %0,%1,0,<dbits>
340 [(set_attr "type" "compare")
341 (set_attr "length" "4,8")])
344 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
345 (compare:CC (zero_extend:DI (match_operand:QHSI 1 "gpc_reg_operand" ""))
347 (set (match_operand:DI 0 "gpc_reg_operand" "")
348 (zero_extend:DI (match_dup 1)))]
349 "TARGET_POWERPC64 && reload_completed"
351 (zero_extend:DI (match_dup 1)))
353 (compare:CC (match_dup 0)
357 (define_insn "extendqidi2"
358 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
359 (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
362 [(set_attr "type" "exts")])
365 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
366 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
368 (clobber (match_scratch:DI 2 "=r,r"))]
373 [(set_attr "type" "compare")
374 (set_attr "length" "4,8")])
377 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
378 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
380 (clobber (match_scratch:DI 2 ""))]
381 "TARGET_POWERPC64 && reload_completed"
383 (sign_extend:DI (match_dup 1)))
385 (compare:CC (match_dup 2)
390 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
391 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
393 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
394 (sign_extend:DI (match_dup 1)))]
399 [(set_attr "type" "compare")
400 (set_attr "length" "4,8")])
403 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
404 (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
406 (set (match_operand:DI 0 "gpc_reg_operand" "")
407 (sign_extend:DI (match_dup 1)))]
408 "TARGET_POWERPC64 && reload_completed"
410 (sign_extend:DI (match_dup 1)))
412 (compare:CC (match_dup 0)
416 (define_expand "extendhidi2"
417 [(set (match_operand:DI 0 "gpc_reg_operand" "")
418 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
423 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
424 (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
425 "TARGET_POWERPC64 && rs6000_gen_cell_microcode"
429 [(set_attr "type" "load_ext,exts")])
432 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
433 (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r")))]
434 "TARGET_POWERPC64 && !rs6000_gen_cell_microcode"
436 [(set_attr "type" "exts")])
439 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
440 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
442 (clobber (match_scratch:DI 2 "=r,r"))]
447 [(set_attr "type" "compare")
448 (set_attr "length" "4,8")])
451 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
452 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
454 (clobber (match_scratch:DI 2 ""))]
455 "TARGET_POWERPC64 && reload_completed"
457 (sign_extend:DI (match_dup 1)))
459 (compare:CC (match_dup 2)
464 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
465 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
467 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
468 (sign_extend:DI (match_dup 1)))]
473 [(set_attr "type" "compare")
474 (set_attr "length" "4,8")])
477 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
478 (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
480 (set (match_operand:DI 0 "gpc_reg_operand" "")
481 (sign_extend:DI (match_dup 1)))]
482 "TARGET_POWERPC64 && reload_completed"
484 (sign_extend:DI (match_dup 1)))
486 (compare:CC (match_dup 0)
490 (define_expand "extendsidi2"
491 [(set (match_operand:DI 0 "gpc_reg_operand" "")
492 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
497 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
498 (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
499 "TARGET_POWERPC64 && rs6000_gen_cell_microcode"
503 [(set_attr "type" "load_ext,exts")])
506 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
507 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r")))]
508 "TARGET_POWERPC64 && !rs6000_gen_cell_microcode"
510 [(set_attr "type" "exts")])
513 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
514 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
516 (clobber (match_scratch:DI 2 "=r,r"))]
521 [(set_attr "type" "compare")
522 (set_attr "length" "4,8")])
525 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
526 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
528 (clobber (match_scratch:DI 2 ""))]
529 "TARGET_POWERPC64 && reload_completed"
531 (sign_extend:DI (match_dup 1)))
533 (compare:CC (match_dup 2)
538 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
539 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
541 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
542 (sign_extend:DI (match_dup 1)))]
547 [(set_attr "type" "compare")
548 (set_attr "length" "4,8")])
551 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
552 (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
554 (set (match_operand:DI 0 "gpc_reg_operand" "")
555 (sign_extend:DI (match_dup 1)))]
556 "TARGET_POWERPC64 && reload_completed"
558 (sign_extend:DI (match_dup 1)))
560 (compare:CC (match_dup 0)
564 (define_expand "zero_extendqisi2"
565 [(set (match_operand:SI 0 "gpc_reg_operand" "")
566 (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
571 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
572 (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
576 {rlinm|rlwinm} %0,%1,0,0xff"
577 [(set_attr "type" "load,*")])
580 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
581 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
583 (clobber (match_scratch:SI 2 "=r,r"))]
586 {andil.|andi.} %2,%1,0xff
588 [(set_attr "type" "fast_compare,compare")
589 (set_attr "length" "4,8")])
592 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
593 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
595 (clobber (match_scratch:SI 2 ""))]
598 (zero_extend:SI (match_dup 1)))
600 (compare:CC (match_dup 2)
605 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
606 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
608 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
609 (zero_extend:SI (match_dup 1)))]
612 {andil.|andi.} %0,%1,0xff
614 [(set_attr "type" "fast_compare,compare")
615 (set_attr "length" "4,8")])
618 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
619 (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
621 (set (match_operand:SI 0 "gpc_reg_operand" "")
622 (zero_extend:SI (match_dup 1)))]
625 (zero_extend:SI (match_dup 1)))
627 (compare:CC (match_dup 0)
631 (define_expand "extendqisi2"
632 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
633 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
638 emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
639 else if (TARGET_POWER)
640 emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
642 emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
646 (define_insn "extendqisi2_ppc"
647 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
648 (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
651 [(set_attr "type" "exts")])
654 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
655 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
657 (clobber (match_scratch:SI 2 "=r,r"))]
662 [(set_attr "type" "compare")
663 (set_attr "length" "4,8")])
666 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
667 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
669 (clobber (match_scratch:SI 2 ""))]
670 "TARGET_POWERPC && reload_completed"
672 (sign_extend:SI (match_dup 1)))
674 (compare:CC (match_dup 2)
679 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
680 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
682 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
683 (sign_extend:SI (match_dup 1)))]
688 [(set_attr "type" "compare")
689 (set_attr "length" "4,8")])
692 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
693 (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
695 (set (match_operand:SI 0 "gpc_reg_operand" "")
696 (sign_extend:SI (match_dup 1)))]
697 "TARGET_POWERPC && reload_completed"
699 (sign_extend:SI (match_dup 1)))
701 (compare:CC (match_dup 0)
705 (define_expand "extendqisi2_power"
706 [(parallel [(set (match_dup 2)
707 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
709 (clobber (scratch:SI))])
710 (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
711 (ashiftrt:SI (match_dup 2)
713 (clobber (scratch:SI))])]
716 { operands[1] = gen_lowpart (SImode, operands[1]);
717 operands[2] = gen_reg_rtx (SImode); }")
719 (define_expand "extendqisi2_no_power"
721 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
723 (set (match_operand:SI 0 "gpc_reg_operand" "")
724 (ashiftrt:SI (match_dup 2)
726 "! TARGET_POWER && ! TARGET_POWERPC"
728 { operands[1] = gen_lowpart (SImode, operands[1]);
729 operands[2] = gen_reg_rtx (SImode); }")
731 (define_expand "zero_extendqihi2"
732 [(set (match_operand:HI 0 "gpc_reg_operand" "")
733 (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
738 [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
739 (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
743 {rlinm|rlwinm} %0,%1,0,0xff"
744 [(set_attr "type" "load,*")])
747 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
748 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
750 (clobber (match_scratch:HI 2 "=r,r"))]
753 {andil.|andi.} %2,%1,0xff
755 [(set_attr "type" "fast_compare,compare")
756 (set_attr "length" "4,8")])
759 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
760 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
762 (clobber (match_scratch:HI 2 ""))]
765 (zero_extend:HI (match_dup 1)))
767 (compare:CC (match_dup 2)
772 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
773 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
775 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
776 (zero_extend:HI (match_dup 1)))]
779 {andil.|andi.} %0,%1,0xff
781 [(set_attr "type" "fast_compare,compare")
782 (set_attr "length" "4,8")])
785 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
786 (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
788 (set (match_operand:HI 0 "gpc_reg_operand" "")
789 (zero_extend:HI (match_dup 1)))]
792 (zero_extend:HI (match_dup 1)))
794 (compare:CC (match_dup 0)
798 (define_expand "extendqihi2"
799 [(use (match_operand:HI 0 "gpc_reg_operand" ""))
800 (use (match_operand:QI 1 "gpc_reg_operand" ""))]
805 emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
806 else if (TARGET_POWER)
807 emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
809 emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
813 (define_insn "extendqihi2_ppc"
814 [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
815 (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
818 [(set_attr "type" "exts")])
821 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
822 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
824 (clobber (match_scratch:HI 2 "=r,r"))]
829 [(set_attr "type" "compare")
830 (set_attr "length" "4,8")])
833 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
834 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
836 (clobber (match_scratch:HI 2 ""))]
837 "TARGET_POWERPC && reload_completed"
839 (sign_extend:HI (match_dup 1)))
841 (compare:CC (match_dup 2)
846 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
847 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
849 (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
850 (sign_extend:HI (match_dup 1)))]
855 [(set_attr "type" "compare")
856 (set_attr "length" "4,8")])
859 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
860 (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
862 (set (match_operand:HI 0 "gpc_reg_operand" "")
863 (sign_extend:HI (match_dup 1)))]
864 "TARGET_POWERPC && reload_completed"
866 (sign_extend:HI (match_dup 1)))
868 (compare:CC (match_dup 0)
872 (define_expand "extendqihi2_power"
873 [(parallel [(set (match_dup 2)
874 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
876 (clobber (scratch:SI))])
877 (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
878 (ashiftrt:SI (match_dup 2)
880 (clobber (scratch:SI))])]
883 { operands[0] = gen_lowpart (SImode, operands[0]);
884 operands[1] = gen_lowpart (SImode, operands[1]);
885 operands[2] = gen_reg_rtx (SImode); }")
887 (define_expand "extendqihi2_no_power"
889 (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
891 (set (match_operand:HI 0 "gpc_reg_operand" "")
892 (ashiftrt:SI (match_dup 2)
894 "! TARGET_POWER && ! TARGET_POWERPC"
896 { operands[0] = gen_lowpart (SImode, operands[0]);
897 operands[1] = gen_lowpart (SImode, operands[1]);
898 operands[2] = gen_reg_rtx (SImode); }")
900 (define_expand "zero_extendhisi2"
901 [(set (match_operand:SI 0 "gpc_reg_operand" "")
902 (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
907 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
908 (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
912 {rlinm|rlwinm} %0,%1,0,0xffff"
913 [(set_attr "type" "load,*")])
916 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
917 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
919 (clobber (match_scratch:SI 2 "=r,r"))]
922 {andil.|andi.} %2,%1,0xffff
924 [(set_attr "type" "fast_compare,compare")
925 (set_attr "length" "4,8")])
928 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
929 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
931 (clobber (match_scratch:SI 2 ""))]
934 (zero_extend:SI (match_dup 1)))
936 (compare:CC (match_dup 2)
941 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
942 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
944 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
945 (zero_extend:SI (match_dup 1)))]
948 {andil.|andi.} %0,%1,0xffff
950 [(set_attr "type" "fast_compare,compare")
951 (set_attr "length" "4,8")])
954 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
955 (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
957 (set (match_operand:SI 0 "gpc_reg_operand" "")
958 (zero_extend:SI (match_dup 1)))]
961 (zero_extend:SI (match_dup 1)))
963 (compare:CC (match_dup 0)
967 (define_expand "extendhisi2"
968 [(set (match_operand:SI 0 "gpc_reg_operand" "")
969 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
974 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
975 (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
976 "rs6000_gen_cell_microcode"
980 [(set_attr "type" "load_ext,exts")])
983 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
984 (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r")))]
985 "!rs6000_gen_cell_microcode"
987 [(set_attr "type" "exts")])
990 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
991 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
993 (clobber (match_scratch:SI 2 "=r,r"))]
998 [(set_attr "type" "compare")
999 (set_attr "length" "4,8")])
1002 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
1003 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1005 (clobber (match_scratch:SI 2 ""))]
1008 (sign_extend:SI (match_dup 1)))
1010 (compare:CC (match_dup 2)
1015 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1016 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1018 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1019 (sign_extend:SI (match_dup 1)))]
1022 {exts.|extsh.} %0,%1
1024 [(set_attr "type" "compare")
1025 (set_attr "length" "4,8")])
1027 ;; IBM 405, 440, 464 and 476 half-word multiplication operations.
1029 (define_insn "*macchwc"
1030 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1031 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
1032 (match_operand:SI 2 "gpc_reg_operand" "r")
1035 (match_operand:HI 1 "gpc_reg_operand" "r")))
1036 (match_operand:SI 4 "gpc_reg_operand" "0"))
1038 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1039 (plus:SI (mult:SI (ashiftrt:SI
1046 "macchw. %0, %1, %2"
1047 [(set_attr "type" "imul3")])
1049 (define_insn "*macchw"
1050 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1051 (plus:SI (mult:SI (ashiftrt:SI
1052 (match_operand:SI 2 "gpc_reg_operand" "r")
1055 (match_operand:HI 1 "gpc_reg_operand" "r")))
1056 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1059 [(set_attr "type" "imul3")])
1061 (define_insn "*macchwuc"
1062 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1063 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
1064 (match_operand:SI 2 "gpc_reg_operand" "r")
1067 (match_operand:HI 1 "gpc_reg_operand" "r")))
1068 (match_operand:SI 4 "gpc_reg_operand" "0"))
1070 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1071 (plus:SI (mult:SI (lshiftrt:SI
1078 "macchwu. %0, %1, %2"
1079 [(set_attr "type" "imul3")])
1081 (define_insn "*macchwu"
1082 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1083 (plus:SI (mult:SI (lshiftrt:SI
1084 (match_operand:SI 2 "gpc_reg_operand" "r")
1087 (match_operand:HI 1 "gpc_reg_operand" "r")))
1088 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1090 "macchwu %0, %1, %2"
1091 [(set_attr "type" "imul3")])
1093 (define_insn "*machhwc"
1094 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1095 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
1096 (match_operand:SI 1 "gpc_reg_operand" "%r")
1099 (match_operand:SI 2 "gpc_reg_operand" "r")
1101 (match_operand:SI 4 "gpc_reg_operand" "0"))
1103 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1104 (plus:SI (mult:SI (ashiftrt:SI
1112 "machhw. %0, %1, %2"
1113 [(set_attr "type" "imul3")])
1115 (define_insn "*machhw"
1116 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1117 (plus:SI (mult:SI (ashiftrt:SI
1118 (match_operand:SI 1 "gpc_reg_operand" "%r")
1121 (match_operand:SI 2 "gpc_reg_operand" "r")
1123 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1126 [(set_attr "type" "imul3")])
1128 (define_insn "*machhwuc"
1129 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1130 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
1131 (match_operand:SI 1 "gpc_reg_operand" "%r")
1134 (match_operand:SI 2 "gpc_reg_operand" "r")
1136 (match_operand:SI 4 "gpc_reg_operand" "0"))
1138 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1139 (plus:SI (mult:SI (lshiftrt:SI
1147 "machhwu. %0, %1, %2"
1148 [(set_attr "type" "imul3")])
1150 (define_insn "*machhwu"
1151 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1152 (plus:SI (mult:SI (lshiftrt:SI
1153 (match_operand:SI 1 "gpc_reg_operand" "%r")
1156 (match_operand:SI 2 "gpc_reg_operand" "r")
1158 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1160 "machhwu %0, %1, %2"
1161 [(set_attr "type" "imul3")])
1163 (define_insn "*maclhwc"
1164 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1165 (compare:CC (plus:SI (mult:SI (sign_extend:SI
1166 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1168 (match_operand:HI 2 "gpc_reg_operand" "r")))
1169 (match_operand:SI 4 "gpc_reg_operand" "0"))
1171 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1172 (plus:SI (mult:SI (sign_extend:SI
1178 "maclhw. %0, %1, %2"
1179 [(set_attr "type" "imul3")])
1181 (define_insn "*maclhw"
1182 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1183 (plus:SI (mult:SI (sign_extend:SI
1184 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1186 (match_operand:HI 2 "gpc_reg_operand" "r")))
1187 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1190 [(set_attr "type" "imul3")])
1192 (define_insn "*maclhwuc"
1193 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1194 (compare:CC (plus:SI (mult:SI (zero_extend:SI
1195 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1197 (match_operand:HI 2 "gpc_reg_operand" "r")))
1198 (match_operand:SI 4 "gpc_reg_operand" "0"))
1200 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1201 (plus:SI (mult:SI (zero_extend:SI
1207 "maclhwu. %0, %1, %2"
1208 [(set_attr "type" "imul3")])
1210 (define_insn "*maclhwu"
1211 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1212 (plus:SI (mult:SI (zero_extend:SI
1213 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1215 (match_operand:HI 2 "gpc_reg_operand" "r")))
1216 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1218 "maclhwu %0, %1, %2"
1219 [(set_attr "type" "imul3")])
1221 (define_insn "*nmacchwc"
1222 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1223 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1224 (mult:SI (ashiftrt:SI
1225 (match_operand:SI 2 "gpc_reg_operand" "r")
1228 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1230 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1231 (minus:SI (match_dup 4)
1232 (mult:SI (ashiftrt:SI
1238 "nmacchw. %0, %1, %2"
1239 [(set_attr "type" "imul3")])
1241 (define_insn "*nmacchw"
1242 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1243 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1244 (mult:SI (ashiftrt:SI
1245 (match_operand:SI 2 "gpc_reg_operand" "r")
1248 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1250 "nmacchw %0, %1, %2"
1251 [(set_attr "type" "imul3")])
1253 (define_insn "*nmachhwc"
1254 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1255 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1256 (mult:SI (ashiftrt:SI
1257 (match_operand:SI 1 "gpc_reg_operand" "%r")
1260 (match_operand:SI 2 "gpc_reg_operand" "r")
1263 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1264 (minus:SI (match_dup 4)
1265 (mult:SI (ashiftrt:SI
1272 "nmachhw. %0, %1, %2"
1273 [(set_attr "type" "imul3")])
1275 (define_insn "*nmachhw"
1276 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1277 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1278 (mult:SI (ashiftrt:SI
1279 (match_operand:SI 1 "gpc_reg_operand" "%r")
1282 (match_operand:SI 2 "gpc_reg_operand" "r")
1285 "nmachhw %0, %1, %2"
1286 [(set_attr "type" "imul3")])
1288 (define_insn "*nmaclhwc"
1289 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1290 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1291 (mult:SI (sign_extend:SI
1292 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1294 (match_operand:HI 2 "gpc_reg_operand" "r"))))
1296 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1297 (minus:SI (match_dup 4)
1298 (mult:SI (sign_extend:SI
1303 "nmaclhw. %0, %1, %2"
1304 [(set_attr "type" "imul3")])
1306 (define_insn "*nmaclhw"
1307 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1308 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1309 (mult:SI (sign_extend:SI
1310 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1312 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1314 "nmaclhw %0, %1, %2"
1315 [(set_attr "type" "imul3")])
1317 (define_insn "*mulchwc"
1318 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1319 (compare:CC (mult:SI (ashiftrt:SI
1320 (match_operand:SI 2 "gpc_reg_operand" "r")
1323 (match_operand:HI 1 "gpc_reg_operand" "r")))
1325 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1326 (mult:SI (ashiftrt:SI
1332 "mulchw. %0, %1, %2"
1333 [(set_attr "type" "imul3")])
1335 (define_insn "*mulchw"
1336 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1337 (mult:SI (ashiftrt:SI
1338 (match_operand:SI 2 "gpc_reg_operand" "r")
1341 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1344 [(set_attr "type" "imul3")])
1346 (define_insn "*mulchwuc"
1347 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1348 (compare:CC (mult:SI (lshiftrt:SI
1349 (match_operand:SI 2 "gpc_reg_operand" "r")
1352 (match_operand:HI 1 "gpc_reg_operand" "r")))
1354 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1355 (mult:SI (lshiftrt:SI
1361 "mulchwu. %0, %1, %2"
1362 [(set_attr "type" "imul3")])
1364 (define_insn "*mulchwu"
1365 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1366 (mult:SI (lshiftrt:SI
1367 (match_operand:SI 2 "gpc_reg_operand" "r")
1370 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1372 "mulchwu %0, %1, %2"
1373 [(set_attr "type" "imul3")])
1375 (define_insn "*mulhhwc"
1376 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1377 (compare:CC (mult:SI (ashiftrt:SI
1378 (match_operand:SI 1 "gpc_reg_operand" "%r")
1381 (match_operand:SI 2 "gpc_reg_operand" "r")
1384 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1385 (mult:SI (ashiftrt:SI
1392 "mulhhw. %0, %1, %2"
1393 [(set_attr "type" "imul3")])
1395 (define_insn "*mulhhw"
1396 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1397 (mult:SI (ashiftrt:SI
1398 (match_operand:SI 1 "gpc_reg_operand" "%r")
1401 (match_operand:SI 2 "gpc_reg_operand" "r")
1405 [(set_attr "type" "imul3")])
1407 (define_insn "*mulhhwuc"
1408 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1409 (compare:CC (mult:SI (lshiftrt:SI
1410 (match_operand:SI 1 "gpc_reg_operand" "%r")
1413 (match_operand:SI 2 "gpc_reg_operand" "r")
1416 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1417 (mult:SI (lshiftrt:SI
1424 "mulhhwu. %0, %1, %2"
1425 [(set_attr "type" "imul3")])
1427 (define_insn "*mulhhwu"
1428 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1429 (mult:SI (lshiftrt:SI
1430 (match_operand:SI 1 "gpc_reg_operand" "%r")
1433 (match_operand:SI 2 "gpc_reg_operand" "r")
1436 "mulhhwu %0, %1, %2"
1437 [(set_attr "type" "imul3")])
1439 (define_insn "*mullhwc"
1440 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1441 (compare:CC (mult:SI (sign_extend:SI
1442 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1444 (match_operand:HI 2 "gpc_reg_operand" "r")))
1446 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1447 (mult:SI (sign_extend:SI
1452 "mullhw. %0, %1, %2"
1453 [(set_attr "type" "imul3")])
1455 (define_insn "*mullhw"
1456 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1457 (mult:SI (sign_extend:SI
1458 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1460 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1463 [(set_attr "type" "imul3")])
1465 (define_insn "*mullhwuc"
1466 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1467 (compare:CC (mult:SI (zero_extend:SI
1468 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1470 (match_operand:HI 2 "gpc_reg_operand" "r")))
1472 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1473 (mult:SI (zero_extend:SI
1478 "mullhwu. %0, %1, %2"
1479 [(set_attr "type" "imul3")])
1481 (define_insn "*mullhwu"
1482 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1483 (mult:SI (zero_extend:SI
1484 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1486 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1488 "mullhwu %0, %1, %2"
1489 [(set_attr "type" "imul3")])
1491 ;; IBM 405, 440, 464 and 476 string-search dlmzb instruction support.
1492 (define_insn "dlmzb"
1493 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1494 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1495 (match_operand:SI 2 "gpc_reg_operand" "r")]
1497 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1498 (unspec:SI [(match_dup 1)
1502 "dlmzb. %0, %1, %2")
1504 (define_expand "strlensi"
1505 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1506 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1507 (match_operand:QI 2 "const_int_operand" "")
1508 (match_operand 3 "const_int_operand" "")]
1509 UNSPEC_DLMZB_STRLEN))
1510 (clobber (match_scratch:CC 4 "=x"))]
1511 "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1513 rtx result = operands[0];
1514 rtx src = operands[1];
1515 rtx search_char = operands[2];
1516 rtx align = operands[3];
1517 rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1518 rtx loop_label, end_label, mem, cr0, cond;
1519 if (search_char != const0_rtx
1520 || GET_CODE (align) != CONST_INT
1521 || INTVAL (align) < 8)
1523 word1 = gen_reg_rtx (SImode);
1524 word2 = gen_reg_rtx (SImode);
1525 scratch_dlmzb = gen_reg_rtx (SImode);
1526 scratch_string = gen_reg_rtx (Pmode);
1527 loop_label = gen_label_rtx ();
1528 end_label = gen_label_rtx ();
1529 addr = force_reg (Pmode, XEXP (src, 0));
1530 emit_move_insn (scratch_string, addr);
1531 emit_label (loop_label);
1532 mem = change_address (src, SImode, scratch_string);
1533 emit_move_insn (word1, mem);
1534 emit_move_insn (word2, adjust_address (mem, SImode, 4));
1535 cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1536 emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1537 cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1538 emit_jump_insn (gen_rtx_SET (VOIDmode,
1540 gen_rtx_IF_THEN_ELSE (VOIDmode,
1546 emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1547 emit_jump_insn (gen_rtx_SET (VOIDmode,
1549 gen_rtx_LABEL_REF (VOIDmode, loop_label)));
1551 emit_label (end_label);
1552 emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1553 emit_insn (gen_subsi3 (result, scratch_string, addr));
1554 emit_insn (gen_subsi3 (result, result, const1_rtx));
1559 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
1560 (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1562 (set (match_operand:SI 0 "gpc_reg_operand" "")
1563 (sign_extend:SI (match_dup 1)))]
1566 (sign_extend:SI (match_dup 1)))
1568 (compare:CC (match_dup 0)
1572 ;; Fixed-point arithmetic insns.
1574 (define_expand "add<mode>3"
1575 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1576 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1577 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1580 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1582 if (non_short_cint_operand (operands[2], DImode))
1585 else if (GET_CODE (operands[2]) == CONST_INT
1586 && ! add_operand (operands[2], <MODE>mode))
1588 rtx tmp = ((!can_create_pseudo_p ()
1589 || rtx_equal_p (operands[0], operands[1]))
1590 ? operands[0] : gen_reg_rtx (<MODE>mode));
1592 HOST_WIDE_INT val = INTVAL (operands[2]);
1593 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1594 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1596 if (<MODE>mode == DImode && !satisfies_constraint_L (GEN_INT (rest)))
1599 /* The ordering here is important for the prolog expander.
1600 When space is allocated from the stack, adding 'low' first may
1601 produce a temporary deallocation (which would be bad). */
1602 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1603 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1608 ;; Discourage ai/addic because of carry but provide it in an alternative
1609 ;; allowing register zero as source.
1610 (define_insn "*add<mode>3_internal1"
1611 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1612 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1613 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
1614 "!DECIMAL_FLOAT_MODE_P (GET_MODE (operands[0])) && !DECIMAL_FLOAT_MODE_P (GET_MODE (operands[1]))"
1617 {cal %0,%2(%1)|addi %0,%1,%2}
1619 {cau|addis} %0,%1,%v2"
1620 [(set_attr "length" "4,4,4,4")])
1622 (define_insn "addsi3_high"
1623 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1624 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1625 (high:SI (match_operand 2 "" ""))))]
1626 "TARGET_MACHO && !TARGET_64BIT"
1627 "{cau|addis} %0,%1,ha16(%2)"
1628 [(set_attr "length" "4")])
1630 (define_insn "*add<mode>3_internal2"
1631 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1632 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1633 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1635 (clobber (match_scratch:P 3 "=r,r,r,r"))]
1638 {cax.|add.} %3,%1,%2
1639 {ai.|addic.} %3,%1,%2
1642 [(set_attr "type" "fast_compare,compare,compare,compare")
1643 (set_attr "length" "4,4,8,8")])
1646 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1647 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1648 (match_operand:GPR 2 "reg_or_short_operand" ""))
1650 (clobber (match_scratch:GPR 3 ""))]
1653 (plus:GPR (match_dup 1)
1656 (compare:CC (match_dup 3)
1660 (define_insn "*add<mode>3_internal3"
1661 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1662 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1663 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1665 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1666 (plus:P (match_dup 1)
1670 {cax.|add.} %0,%1,%2
1671 {ai.|addic.} %0,%1,%2
1674 [(set_attr "type" "fast_compare,compare,compare,compare")
1675 (set_attr "length" "4,4,8,8")])
1678 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1679 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1680 (match_operand:P 2 "reg_or_short_operand" ""))
1682 (set (match_operand:P 0 "gpc_reg_operand" "")
1683 (plus:P (match_dup 1) (match_dup 2)))]
1686 (plus:P (match_dup 1)
1689 (compare:CC (match_dup 0)
1693 ;; Split an add that we can't do in one insn into two insns, each of which
1694 ;; does one 16-bit part. This is used by combine. Note that the low-order
1695 ;; add should be last in case the result gets used in an address.
1698 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1699 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1700 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1702 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1703 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1705 HOST_WIDE_INT val = INTVAL (operands[2]);
1706 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1707 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1709 operands[4] = GEN_INT (low);
1710 if (<MODE>mode == SImode || satisfies_constraint_L (GEN_INT (rest)))
1711 operands[3] = GEN_INT (rest);
1712 else if (can_create_pseudo_p ())
1714 operands[3] = gen_reg_rtx (DImode);
1715 emit_move_insn (operands[3], operands[2]);
1716 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1723 (define_insn "one_cmpl<mode>2"
1724 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1725 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1730 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1731 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1733 (clobber (match_scratch:P 2 "=r,r"))]
1738 [(set_attr "type" "fast_compare,compare")
1739 (set_attr "length" "4,8")])
1742 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
1743 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1745 (clobber (match_scratch:P 2 ""))]
1748 (not:P (match_dup 1)))
1750 (compare:CC (match_dup 2)
1755 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1756 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
1758 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1759 (not:P (match_dup 1)))]
1764 [(set_attr "type" "fast_compare,compare")
1765 (set_attr "length" "4,8")])
1768 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
1769 (compare:CC (not:P (match_operand:P 1 "gpc_reg_operand" ""))
1771 (set (match_operand:P 0 "gpc_reg_operand" "")
1772 (not:P (match_dup 1)))]
1775 (not:P (match_dup 1)))
1777 (compare:CC (match_dup 0)
1782 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1783 (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1784 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1786 "{sf%I1|subf%I1c} %0,%2,%1")
1789 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1790 (minus:GPR (match_operand:GPR 1 "reg_or_short_operand" "r,I")
1791 (match_operand:GPR 2 "gpc_reg_operand" "r,r")))]
1798 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1799 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1800 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1802 (clobber (match_scratch:SI 3 "=r,r"))]
1805 {sf.|subfc.} %3,%2,%1
1807 [(set_attr "type" "compare")
1808 (set_attr "length" "4,8")])
1811 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1812 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1813 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1815 (clobber (match_scratch:P 3 "=r,r"))]
1820 [(set_attr "type" "fast_compare")
1821 (set_attr "length" "4,8")])
1824 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1825 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1826 (match_operand:P 2 "gpc_reg_operand" ""))
1828 (clobber (match_scratch:P 3 ""))]
1831 (minus:P (match_dup 1)
1834 (compare:CC (match_dup 3)
1839 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1840 (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1841 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1843 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1844 (minus:SI (match_dup 1) (match_dup 2)))]
1847 {sf.|subfc.} %0,%2,%1
1849 [(set_attr "type" "compare")
1850 (set_attr "length" "4,8")])
1853 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1854 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "r,r")
1855 (match_operand:P 2 "gpc_reg_operand" "r,r"))
1857 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
1858 (minus:P (match_dup 1)
1864 [(set_attr "type" "fast_compare")
1865 (set_attr "length" "4,8")])
1868 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1869 (compare:CC (minus:P (match_operand:P 1 "gpc_reg_operand" "")
1870 (match_operand:P 2 "gpc_reg_operand" ""))
1872 (set (match_operand:P 0 "gpc_reg_operand" "")
1873 (minus:P (match_dup 1)
1877 (minus:P (match_dup 1)
1880 (compare:CC (match_dup 0)
1884 (define_expand "sub<mode>3"
1885 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1886 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1887 (match_operand:SDI 2 "reg_or_sub_cint_operand" "")))]
1891 if (GET_CODE (operands[2]) == CONST_INT)
1893 emit_insn (gen_add<mode>3 (operands[0], operands[1],
1894 negate_rtx (<MODE>mode, operands[2])));
1899 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1900 ;; instruction and some auxiliary computations. Then we just have a single
1901 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1904 (define_expand "sminsi3"
1906 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1907 (match_operand:SI 2 "reg_or_short_operand" ""))
1909 (minus:SI (match_dup 2) (match_dup 1))))
1910 (set (match_operand:SI 0 "gpc_reg_operand" "")
1911 (minus:SI (match_dup 2) (match_dup 3)))]
1912 "TARGET_POWER || TARGET_ISEL"
1917 operands[2] = force_reg (SImode, operands[2]);
1918 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1922 operands[3] = gen_reg_rtx (SImode);
1926 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1927 (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1928 (match_operand:SI 2 "reg_or_short_operand" "")))
1929 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1932 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1934 (minus:SI (match_dup 2) (match_dup 1))))
1935 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1938 (define_expand "smaxsi3"
1940 (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1941 (match_operand:SI 2 "reg_or_short_operand" ""))
1943 (minus:SI (match_dup 2) (match_dup 1))))
1944 (set (match_operand:SI 0 "gpc_reg_operand" "")
1945 (plus:SI (match_dup 3) (match_dup 1)))]
1946 "TARGET_POWER || TARGET_ISEL"
1951 operands[2] = force_reg (SImode, operands[2]);
1952 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1955 operands[3] = gen_reg_rtx (SImode);
1959 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1960 (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1961 (match_operand:SI 2 "reg_or_short_operand" "")))
1962 (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1965 (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1967 (minus:SI (match_dup 2) (match_dup 1))))
1968 (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1971 (define_expand "uminsi3"
1972 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1974 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1976 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1978 (minus:SI (match_dup 4) (match_dup 3))))
1979 (set (match_operand:SI 0 "gpc_reg_operand" "")
1980 (minus:SI (match_dup 2) (match_dup 3)))]
1981 "TARGET_POWER || TARGET_ISEL"
1986 rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1989 operands[3] = gen_reg_rtx (SImode);
1990 operands[4] = gen_reg_rtx (SImode);
1991 operands[5] = GEN_INT (-2147483647 - 1);
1994 (define_expand "umaxsi3"
1995 [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1997 (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1999 (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
2001 (minus:SI (match_dup 4) (match_dup 3))))
2002 (set (match_operand:SI 0 "gpc_reg_operand" "")
2003 (plus:SI (match_dup 3) (match_dup 1)))]
2004 "TARGET_POWER || TARGET_ISEL"
2009 rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
2012 operands[3] = gen_reg_rtx (SImode);
2013 operands[4] = gen_reg_rtx (SImode);
2014 operands[5] = GEN_INT (-2147483647 - 1);
2018 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2019 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
2020 (match_operand:SI 2 "reg_or_short_operand" "rI"))
2022 (minus:SI (match_dup 2) (match_dup 1))))]
2027 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2029 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
2030 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
2032 (minus:SI (match_dup 2) (match_dup 1)))
2034 (clobber (match_scratch:SI 3 "=r,r"))]
2039 [(set_attr "type" "delayed_compare")
2040 (set_attr "length" "4,8")])
2043 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2045 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
2046 (match_operand:SI 2 "reg_or_short_operand" ""))
2048 (minus:SI (match_dup 2) (match_dup 1)))
2050 (clobber (match_scratch:SI 3 ""))]
2051 "TARGET_POWER && reload_completed"
2053 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2055 (minus:SI (match_dup 2) (match_dup 1))))
2057 (compare:CC (match_dup 3)
2062 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2064 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
2065 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
2067 (minus:SI (match_dup 2) (match_dup 1)))
2069 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2070 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2072 (minus:SI (match_dup 2) (match_dup 1))))]
2077 [(set_attr "type" "delayed_compare")
2078 (set_attr "length" "4,8")])
2081 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2083 (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
2084 (match_operand:SI 2 "reg_or_short_operand" ""))
2086 (minus:SI (match_dup 2) (match_dup 1)))
2088 (set (match_operand:SI 0 "gpc_reg_operand" "")
2089 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2091 (minus:SI (match_dup 2) (match_dup 1))))]
2092 "TARGET_POWER && reload_completed"
2094 (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2096 (minus:SI (match_dup 2) (match_dup 1))))
2098 (compare:CC (match_dup 0)
2102 ;; We don't need abs with condition code because such comparisons should
2104 (define_expand "abssi2"
2105 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2106 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2112 emit_insn (gen_abssi2_isel (operands[0], operands[1]));
2115 else if (! TARGET_POWER)
2117 emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
2122 (define_insn "*abssi2_power"
2123 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2124 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2128 (define_insn_and_split "abs<mode>2_isel"
2129 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2130 (abs:GPR (match_operand:GPR 1 "gpc_reg_operand" "b")))
2131 (clobber (match_scratch:GPR 2 "=&b"))
2132 (clobber (match_scratch:CC 3 "=y"))]
2135 "&& reload_completed"
2136 [(set (match_dup 2) (neg:GPR (match_dup 1)))
2138 (compare:CC (match_dup 1)
2141 (if_then_else:GPR (lt (match_dup 3)
2147 (define_insn_and_split "nabs<mode>2_isel"
2148 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2149 (neg:GPR (abs:GPR (match_operand:GPR 1 "gpc_reg_operand" "b"))))
2150 (clobber (match_scratch:GPR 2 "=&b"))
2151 (clobber (match_scratch:CC 3 "=y"))]
2154 "&& reload_completed"
2155 [(set (match_dup 2) (neg:GPR (match_dup 1)))
2157 (compare:CC (match_dup 1)
2160 (if_then_else:GPR (lt (match_dup 3)
2166 (define_insn_and_split "abssi2_nopower"
2167 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2168 (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
2169 (clobber (match_scratch:SI 2 "=&r,&r"))]
2170 "! TARGET_POWER && ! TARGET_ISEL"
2172 "&& reload_completed"
2173 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2174 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2175 (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
2178 (define_insn "*nabs_power"
2179 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2180 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
2184 (define_insn_and_split "*nabs_nopower"
2185 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2186 (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
2187 (clobber (match_scratch:SI 2 "=&r,&r"))]
2190 "&& reload_completed"
2191 [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2192 (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2193 (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
2196 (define_expand "neg<mode>2"
2197 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2198 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
2202 (define_insn "*neg<mode>2_internal"
2203 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2204 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2209 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2210 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2212 (clobber (match_scratch:P 2 "=r,r"))]
2217 [(set_attr "type" "fast_compare")
2218 (set_attr "length" "4,8")])
2221 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2222 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2224 (clobber (match_scratch:P 2 ""))]
2227 (neg:P (match_dup 1)))
2229 (compare:CC (match_dup 2)
2234 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2235 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" "r,r"))
2237 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
2238 (neg:P (match_dup 1)))]
2243 [(set_attr "type" "fast_compare")
2244 (set_attr "length" "4,8")])
2247 [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2248 (compare:CC (neg:P (match_operand:P 1 "gpc_reg_operand" ""))
2250 (set (match_operand:P 0 "gpc_reg_operand" "")
2251 (neg:P (match_dup 1)))]
2254 (neg:P (match_dup 1)))
2256 (compare:CC (match_dup 0)
2260 (define_insn "clz<mode>2"
2261 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2262 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2264 "{cntlz|cntlz<wd>} %0,%1"
2265 [(set_attr "type" "cntlz")])
2267 (define_expand "ctz<mode>2"
2269 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
2270 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2272 (clobber (scratch:CC))])
2273 (set (match_dup 4) (clz:GPR (match_dup 3)))
2274 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2275 (minus:GPR (match_dup 5) (match_dup 4)))]
2278 operands[2] = gen_reg_rtx (<MODE>mode);
2279 operands[3] = gen_reg_rtx (<MODE>mode);
2280 operands[4] = gen_reg_rtx (<MODE>mode);
2281 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
2284 (define_expand "ffs<mode>2"
2286 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
2287 (parallel [(set (match_dup 3) (and:GPR (match_dup 1)
2289 (clobber (scratch:CC))])
2290 (set (match_dup 4) (clz:GPR (match_dup 3)))
2291 (set (match_operand:GPR 0 "gpc_reg_operand" "")
2292 (minus:GPR (match_dup 5) (match_dup 4)))]
2295 operands[2] = gen_reg_rtx (<MODE>mode);
2296 operands[3] = gen_reg_rtx (<MODE>mode);
2297 operands[4] = gen_reg_rtx (<MODE>mode);
2298 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
2301 (define_insn "popcntb<mode>2"
2302 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2303 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2308 (define_insn "popcntd<mode>2"
2309 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2310 (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2314 (define_expand "popcount<mode>2"
2315 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2316 (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
2317 "TARGET_POPCNTB || TARGET_POPCNTD"
2319 rs6000_emit_popcount (operands[0], operands[1]);
2323 (define_insn "parity<mode>2_cmpb"
2324 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2325 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")] UNSPEC_PARITY))]
2326 "TARGET_CMPB && TARGET_POPCNTB"
2329 (define_expand "parity<mode>2"
2330 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2331 (parity:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
2334 rs6000_emit_parity (operands[0], operands[1]);
2338 ;; Since the hardware zeros the upper part of the register, save generating the
2339 ;; AND immediate if we are converting to unsigned
2340 (define_insn "*bswaphi2_extenddi"
2341 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
2343 (bswap:HI (match_operand:HI 1 "memory_operand" "Z"))))]
2346 [(set_attr "length" "4")
2347 (set_attr "type" "load")])
2349 (define_insn "*bswaphi2_extendsi"
2350 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2352 (bswap:HI (match_operand:HI 1 "memory_operand" "Z"))))]
2355 [(set_attr "length" "4")
2356 (set_attr "type" "load")])
2358 (define_expand "bswaphi2"
2359 [(parallel [(set (match_operand:HI 0 "reg_or_mem_operand" "")
2361 (match_operand:HI 1 "reg_or_mem_operand" "")))
2362 (clobber (match_scratch:SI 2 ""))])]
2365 if (!REG_P (operands[0]) && !REG_P (operands[1]))
2366 operands[1] = force_reg (HImode, operands[1]);
2369 (define_insn "bswaphi2_internal"
2370 [(set (match_operand:HI 0 "reg_or_mem_operand" "=r,Z,&r")
2372 (match_operand:HI 1 "reg_or_mem_operand" "Z,r,r")))
2373 (clobber (match_scratch:SI 2 "=X,X,&r"))]
2379 [(set_attr "length" "4,4,12")
2380 (set_attr "type" "load,store,*")])
2383 [(set (match_operand:HI 0 "gpc_reg_operand" "")
2384 (bswap:HI (match_operand:HI 1 "gpc_reg_operand" "")))
2385 (clobber (match_operand:SI 2 "gpc_reg_operand" ""))]
2386 "TARGET_POWERPC && reload_completed"
2388 (zero_extract:SI (match_dup 4)
2392 (and:SI (ashift:SI (match_dup 4)
2394 (const_int 65280))) ;; 0xff00
2396 (ior:SI (match_dup 3)
2400 operands[3] = simplify_gen_subreg (SImode, operands[0], HImode, 0);
2401 operands[4] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
2404 (define_insn "*bswapsi2_extenddi"
2405 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
2407 (bswap:SI (match_operand:SI 1 "memory_operand" "Z"))))]
2410 [(set_attr "length" "4")
2411 (set_attr "type" "load")])
2413 (define_expand "bswapsi2"
2414 [(set (match_operand:SI 0 "reg_or_mem_operand" "")
2416 (match_operand:SI 1 "reg_or_mem_operand" "")))]
2419 if (!REG_P (operands[0]) && !REG_P (operands[1]))
2420 operands[1] = force_reg (SImode, operands[1]);
2423 (define_insn "*bswapsi2_internal"
2424 [(set (match_operand:SI 0 "reg_or_mem_operand" "=r,Z,&r")
2426 (match_operand:SI 1 "reg_or_mem_operand" "Z,r,r")))]
2430 {stbrx|stwbrx} %1,%y0
2432 [(set_attr "length" "4,4,12")
2433 (set_attr "type" "load,store,*")])
2436 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2437 (bswap:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2440 (rotate:SI (match_dup 1) (const_int 8)))
2441 (set (zero_extract:SI (match_dup 0)
2445 (set (zero_extract:SI (match_dup 0)
2448 (rotate:SI (match_dup 1)
2452 (define_expand "bswapdi2"
2453 [(parallel [(set (match_operand:DI 0 "reg_or_mem_operand" "")
2455 (match_operand:DI 1 "reg_or_mem_operand" "")))
2456 (clobber (match_scratch:DI 2 ""))
2457 (clobber (match_scratch:DI 3 ""))
2458 (clobber (match_scratch:DI 4 ""))])]
2461 if (!REG_P (operands[0]) && !REG_P (operands[1]))
2462 operands[1] = force_reg (DImode, operands[1]);
2464 if (!TARGET_POWERPC64)
2466 /* 32-bit mode needs fewer scratch registers, but 32-bit addressing mode
2467 that uses 64-bit registers needs the same scratch registers as 64-bit
2469 emit_insn (gen_bswapdi2_32bit (operands[0], operands[1]));
2474 ;; Power7/cell has ldbrx/stdbrx, so use it directly
2475 (define_insn "*bswapdi2_ldbrx"
2476 [(set (match_operand:DI 0 "reg_or_mem_operand" "=&r,Z,??&r")
2477 (bswap:DI (match_operand:DI 1 "reg_or_mem_operand" "Z,r,r")))
2478 (clobber (match_scratch:DI 2 "=X,X,&r"))
2479 (clobber (match_scratch:DI 3 "=X,X,&r"))
2480 (clobber (match_scratch:DI 4 "=X,X,&r"))]
2481 "TARGET_POWERPC64 && TARGET_LDBRX
2482 && (REG_P (operands[0]) || REG_P (operands[1]))"
2487 [(set_attr "length" "4,4,36")
2488 (set_attr "type" "load,store,*")])
2490 ;; Non-power7/cell, fall back to use lwbrx/stwbrx
2491 (define_insn "*bswapdi2_64bit"
2492 [(set (match_operand:DI 0 "reg_or_mem_operand" "=&r,Z,??&r")
2493 (bswap:DI (match_operand:DI 1 "reg_or_mem_operand" "Z,r,r")))
2494 (clobber (match_scratch:DI 2 "=&b,&b,&r"))
2495 (clobber (match_scratch:DI 3 "=&r,&r,&r"))
2496 (clobber (match_scratch:DI 4 "=&r,X,&r"))]
2497 "TARGET_POWERPC64 && !TARGET_LDBRX
2498 && (REG_P (operands[0]) || REG_P (operands[1]))"
2500 [(set_attr "length" "16,12,36")])
2503 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2504 (bswap:DI (match_operand:DI 1 "indexed_or_indirect_operand" "")))
2505 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
2506 (clobber (match_operand:DI 3 "gpc_reg_operand" ""))
2507 (clobber (match_operand:DI 4 "gpc_reg_operand" ""))]
2508 "TARGET_POWERPC64 && !TARGET_LDBRX && reload_completed"
2512 rtx dest = operands[0];
2513 rtx src = operands[1];
2514 rtx op2 = operands[2];
2515 rtx op3 = operands[3];
2516 rtx op4 = operands[4];
2517 rtx op3_32 = simplify_gen_subreg (SImode, op3, DImode, 4);
2518 rtx op4_32 = simplify_gen_subreg (SImode, op4, DImode, 4);
2524 addr1 = XEXP (src, 0);
2525 if (GET_CODE (addr1) == PLUS)
2527 emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2528 addr2 = gen_rtx_PLUS (Pmode, op2, XEXP (addr1, 1));
2532 emit_move_insn (op2, GEN_INT (4));
2533 addr2 = gen_rtx_PLUS (Pmode, op2, addr1);
2536 if (BYTES_BIG_ENDIAN)
2538 word_high = change_address (src, SImode, addr1);
2539 word_low = change_address (src, SImode, addr2);
2543 word_high = change_address (src, SImode, addr2);
2544 word_low = change_address (src, SImode, addr1);
2547 emit_insn (gen_bswapsi2 (op3_32, word_low));
2548 emit_insn (gen_bswapsi2 (op4_32, word_high));
2549 emit_insn (gen_ashldi3 (dest, op3, GEN_INT (32)));
2550 emit_insn (gen_iordi3 (dest, dest, op4));
2554 [(set (match_operand:DI 0 "indexed_or_indirect_operand" "")
2555 (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2556 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
2557 (clobber (match_operand:DI 3 "gpc_reg_operand" ""))
2558 (clobber (match_operand:DI 4 "" ""))]
2559 "TARGET_POWERPC64 && !TARGET_LDBRX && reload_completed"
2563 rtx dest = operands[0];
2564 rtx src = operands[1];
2565 rtx op2 = operands[2];
2566 rtx op3 = operands[3];
2567 rtx src_si = simplify_gen_subreg (SImode, src, DImode, 4);
2568 rtx op3_si = simplify_gen_subreg (SImode, op3, DImode, 4);
2574 addr1 = XEXP (dest, 0);
2575 if (GET_CODE (addr1) == PLUS)
2577 emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2578 addr2 = gen_rtx_PLUS (Pmode, op2, XEXP (addr1, 1));
2582 emit_move_insn (op2, GEN_INT (4));
2583 addr2 = gen_rtx_PLUS (Pmode, op2, addr1);
2586 emit_insn (gen_lshrdi3 (op3, src, GEN_INT (32)));
2587 if (BYTES_BIG_ENDIAN)
2589 word_high = change_address (dest, SImode, addr1);
2590 word_low = change_address (dest, SImode, addr2);
2591 emit_insn (gen_bswapsi2 (word_high, src_si));
2592 emit_insn (gen_bswapsi2 (word_low, op3_si));
2596 word_high = change_address (dest, SImode, addr2);
2597 word_low = change_address (dest, SImode, addr1);
2598 emit_insn (gen_bswapsi2 (word_low, src_si));
2599 emit_insn (gen_bswapsi2 (word_high, op3_si));
2604 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2605 (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2606 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
2607 (clobber (match_operand:DI 3 "gpc_reg_operand" ""))
2608 (clobber (match_operand:DI 4 "" ""))]
2609 "TARGET_POWERPC64 && reload_completed"
2613 rtx dest = operands[0];
2614 rtx src = operands[1];
2615 rtx op2 = operands[2];
2616 rtx op3 = operands[3];
2617 rtx dest_si = simplify_gen_subreg (SImode, dest, DImode, 4);
2618 rtx src_si = simplify_gen_subreg (SImode, src, DImode, 4);
2619 rtx op2_si = simplify_gen_subreg (SImode, op2, DImode, 4);
2620 rtx op3_si = simplify_gen_subreg (SImode, op3, DImode, 4);
2622 emit_insn (gen_lshrdi3 (op2, src, GEN_INT (32)));
2623 emit_insn (gen_bswapsi2 (dest_si, src_si));
2624 emit_insn (gen_bswapsi2 (op3_si, op2_si));
2625 emit_insn (gen_ashldi3 (dest, dest, GEN_INT (32)));
2626 emit_insn (gen_iordi3 (dest, dest, op3));
2629 (define_insn "bswapdi2_32bit"
2630 [(set (match_operand:DI 0 "reg_or_mem_operand" "=&r,Z,??&r")
2631 (bswap:DI (match_operand:DI 1 "reg_or_mem_operand" "Z,r,r")))
2632 (clobber (match_scratch:SI 2 "=&b,&b,X"))]
2633 "!TARGET_POWERPC64 && (REG_P (operands[0]) || REG_P (operands[1]))"
2635 [(set_attr "length" "16,12,36")])
2638 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2639 (bswap:DI (match_operand:DI 1 "indexed_or_indirect_operand" "")))
2640 (clobber (match_operand:SI 2 "gpc_reg_operand" ""))]
2641 "!TARGET_POWERPC64 && reload_completed"
2645 rtx dest = operands[0];
2646 rtx src = operands[1];
2647 rtx op2 = operands[2];
2648 rtx dest_hi = simplify_gen_subreg (SImode, dest, DImode, 0);
2649 rtx dest_lo = simplify_gen_subreg (SImode, dest, DImode, 4);
2655 addr1 = XEXP (src, 0);
2656 if (GET_CODE (addr1) == PLUS)
2658 emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2659 addr2 = gen_rtx_PLUS (SImode, op2, XEXP (addr1, 1));
2663 emit_move_insn (op2, GEN_INT (4));
2664 addr2 = gen_rtx_PLUS (SImode, op2, addr1);
2667 if (BYTES_BIG_ENDIAN)
2669 word_high = change_address (src, SImode, addr1);
2670 word_low = change_address (src, SImode, addr2);
2674 word_high = change_address (src, SImode, addr2);
2675 word_low = change_address (src, SImode, addr1);
2678 emit_insn (gen_bswapsi2 (dest_hi, word_low));
2679 emit_insn (gen_bswapsi2 (dest_lo, word_high));
2683 [(set (match_operand:DI 0 "indexed_or_indirect_operand" "")
2684 (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2685 (clobber (match_operand:SI 2 "gpc_reg_operand" ""))]
2686 "!TARGET_POWERPC64 && reload_completed"
2690 rtx dest = operands[0];
2691 rtx src = operands[1];
2692 rtx op2 = operands[2];
2693 rtx src_high = simplify_gen_subreg (SImode, src, DImode, 0);
2694 rtx src_low = simplify_gen_subreg (SImode, src, DImode, 4);
2700 addr1 = XEXP (dest, 0);
2701 if (GET_CODE (addr1) == PLUS)
2703 emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2704 addr2 = gen_rtx_PLUS (SImode, op2, XEXP (addr1, 1));
2708 emit_move_insn (op2, GEN_INT (4));
2709 addr2 = gen_rtx_PLUS (SImode, op2, addr1);
2712 if (BYTES_BIG_ENDIAN)
2714 word_high = change_address (dest, SImode, addr1);
2715 word_low = change_address (dest, SImode, addr2);
2719 word_high = change_address (dest, SImode, addr2);
2720 word_low = change_address (dest, SImode, addr1);
2723 emit_insn (gen_bswapsi2 (word_high, src_low));
2724 emit_insn (gen_bswapsi2 (word_low, src_high));
2728 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2729 (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2730 (clobber (match_operand:SI 2 "" ""))]
2731 "!TARGET_POWERPC64 && reload_completed"
2735 rtx dest = operands[0];
2736 rtx src = operands[1];
2737 rtx src_high = simplify_gen_subreg (SImode, src, DImode, 0);
2738 rtx src_low = simplify_gen_subreg (SImode, src, DImode, 4);
2739 rtx dest_high = simplify_gen_subreg (SImode, dest, DImode, 0);
2740 rtx dest_low = simplify_gen_subreg (SImode, dest, DImode, 4);
2742 emit_insn (gen_bswapsi2 (dest_high, src_low));
2743 emit_insn (gen_bswapsi2 (dest_low, src_high));
2746 (define_expand "mulsi3"
2747 [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2748 (use (match_operand:SI 1 "gpc_reg_operand" ""))
2749 (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2754 emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2756 emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2760 (define_insn "mulsi3_mq"
2761 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2762 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2763 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2764 (clobber (match_scratch:SI 3 "=q,q"))]
2767 {muls|mullw} %0,%1,%2
2768 {muli|mulli} %0,%1,%2"
2770 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2771 (const_string "imul3")
2772 (match_operand:SI 2 "short_cint_operand" "")
2773 (const_string "imul2")]
2774 (const_string "imul")))])
2776 (define_insn "mulsi3_no_mq"
2777 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2778 (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2779 (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2782 {muls|mullw} %0,%1,%2
2783 {muli|mulli} %0,%1,%2"
2785 (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2786 (const_string "imul3")
2787 (match_operand:SI 2 "short_cint_operand" "")
2788 (const_string "imul2")]
2789 (const_string "imul")))])
2791 (define_insn "*mulsi3_mq_internal1"
2792 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2793 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2794 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2796 (clobber (match_scratch:SI 3 "=r,r"))
2797 (clobber (match_scratch:SI 4 "=q,q"))]
2800 {muls.|mullw.} %3,%1,%2
2802 [(set_attr "type" "imul_compare")
2803 (set_attr "length" "4,8")])
2806 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2807 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2808 (match_operand:SI 2 "gpc_reg_operand" ""))
2810 (clobber (match_scratch:SI 3 ""))
2811 (clobber (match_scratch:SI 4 ""))]
2812 "TARGET_POWER && reload_completed"
2813 [(parallel [(set (match_dup 3)
2814 (mult:SI (match_dup 1) (match_dup 2)))
2815 (clobber (match_dup 4))])
2817 (compare:CC (match_dup 3)
2821 (define_insn "*mulsi3_no_mq_internal1"
2822 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2823 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2824 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2826 (clobber (match_scratch:SI 3 "=r,r"))]
2829 {muls.|mullw.} %3,%1,%2
2831 [(set_attr "type" "imul_compare")
2832 (set_attr "length" "4,8")])
2835 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
2836 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2837 (match_operand:SI 2 "gpc_reg_operand" ""))
2839 (clobber (match_scratch:SI 3 ""))]
2840 "! TARGET_POWER && reload_completed"
2842 (mult:SI (match_dup 1) (match_dup 2)))
2844 (compare:CC (match_dup 3)
2848 (define_insn "*mulsi3_mq_internal2"
2849 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2850 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2851 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2853 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2854 (mult:SI (match_dup 1) (match_dup 2)))
2855 (clobber (match_scratch:SI 4 "=q,q"))]
2858 {muls.|mullw.} %0,%1,%2
2860 [(set_attr "type" "imul_compare")
2861 (set_attr "length" "4,8")])
2864 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2865 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2866 (match_operand:SI 2 "gpc_reg_operand" ""))
2868 (set (match_operand:SI 0 "gpc_reg_operand" "")
2869 (mult:SI (match_dup 1) (match_dup 2)))
2870 (clobber (match_scratch:SI 4 ""))]
2871 "TARGET_POWER && reload_completed"
2872 [(parallel [(set (match_dup 0)
2873 (mult:SI (match_dup 1) (match_dup 2)))
2874 (clobber (match_dup 4))])
2876 (compare:CC (match_dup 0)
2880 (define_insn "*mulsi3_no_mq_internal2"
2881 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2882 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2883 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2885 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2886 (mult:SI (match_dup 1) (match_dup 2)))]
2889 {muls.|mullw.} %0,%1,%2
2891 [(set_attr "type" "imul_compare")
2892 (set_attr "length" "4,8")])
2895 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
2896 (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2897 (match_operand:SI 2 "gpc_reg_operand" ""))
2899 (set (match_operand:SI 0 "gpc_reg_operand" "")
2900 (mult:SI (match_dup 1) (match_dup 2)))]
2901 "! TARGET_POWER && reload_completed"
2903 (mult:SI (match_dup 1) (match_dup 2)))
2905 (compare:CC (match_dup 0)
2909 ;; Operand 1 is divided by operand 2; quotient goes to operand
2910 ;; 0 and remainder to operand 3.
2911 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2913 (define_expand "divmodsi4"
2914 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2915 (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2916 (match_operand:SI 2 "gpc_reg_operand" "")))
2917 (set (match_operand:SI 3 "register_operand" "")
2918 (mod:SI (match_dup 1) (match_dup 2)))])]
2919 "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2922 if (! TARGET_POWER && ! TARGET_POWERPC)
2924 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2925 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2926 emit_insn (gen_divss_call ());
2927 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2928 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2933 (define_insn "*divmodsi4_internal"
2934 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2935 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2936 (match_operand:SI 2 "gpc_reg_operand" "r")))
2937 (set (match_operand:SI 3 "register_operand" "=q")
2938 (mod:SI (match_dup 1) (match_dup 2)))]
2941 [(set_attr "type" "idiv")])
2943 (define_expand "udiv<mode>3"
2944 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2945 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2946 (match_operand:GPR 2 "gpc_reg_operand" "")))]
2947 "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2950 if (! TARGET_POWER && ! TARGET_POWERPC)
2952 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2953 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2954 emit_insn (gen_quous_call ());
2955 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2958 else if (TARGET_POWER)
2960 emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2965 (define_insn "udivsi3_mq"
2966 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2967 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2968 (match_operand:SI 2 "gpc_reg_operand" "r")))
2969 (clobber (match_scratch:SI 3 "=q"))]
2970 "TARGET_POWERPC && TARGET_POWER"
2972 [(set_attr "type" "idiv")])
2974 (define_insn "*udivsi3_no_mq"
2975 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2976 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2977 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2978 "TARGET_POWERPC && ! TARGET_POWER"
2981 (cond [(match_operand:SI 0 "" "")
2982 (const_string "idiv")]
2983 (const_string "ldiv")))])
2986 ;; For powers of two we can do srai/aze for divide and then adjust for
2987 ;; modulus. If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2988 ;; used; for PowerPC, force operands into register and do a normal divide;
2989 ;; for AIX common-mode, use quoss call on register operands.
2990 (define_expand "div<mode>3"
2991 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2992 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2993 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2997 if (GET_CODE (operands[2]) == CONST_INT
2998 && INTVAL (operands[2]) > 0
2999 && exact_log2 (INTVAL (operands[2])) >= 0)
3001 else if (TARGET_POWERPC)
3003 operands[2] = force_reg (<MODE>mode, operands[2]);
3006 emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
3010 else if (TARGET_POWER)
3014 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
3015 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
3016 emit_insn (gen_quoss_call ());
3017 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
3022 (define_insn "divsi3_mq"
3023 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3024 (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3025 (match_operand:SI 2 "gpc_reg_operand" "r")))
3026 (clobber (match_scratch:SI 3 "=q"))]
3027 "TARGET_POWERPC && TARGET_POWER"
3029 [(set_attr "type" "idiv")])
3031 (define_insn "*div<mode>3_no_mq"
3032 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3033 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
3034 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
3035 "TARGET_POWERPC && ! TARGET_POWER"
3038 (cond [(match_operand:SI 0 "" "")
3039 (const_string "idiv")]
3040 (const_string "ldiv")))])
3042 (define_expand "mod<mode>3"
3043 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
3044 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
3045 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
3053 if (GET_CODE (operands[2]) != CONST_INT
3054 || INTVAL (operands[2]) <= 0
3055 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
3058 temp1 = gen_reg_rtx (<MODE>mode);
3059 temp2 = gen_reg_rtx (<MODE>mode);
3061 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
3062 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
3063 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
3068 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3069 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
3070 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))]
3072 "{srai|sra<wd>i} %0,%1,%p2\;{aze|addze} %0,%0"
3073 [(set_attr "type" "two")
3074 (set_attr "length" "8")])
3077 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3078 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
3079 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
3081 (clobber (match_scratch:P 3 "=r,r"))]
3084 {srai|sra<wd>i} %3,%1,%p2\;{aze.|addze.} %3,%3
3086 [(set_attr "type" "compare")
3087 (set_attr "length" "8,12")
3088 (set_attr "cell_micro" "not")])
3091 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3092 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
3093 (match_operand:GPR 2 "exact_log2_cint_operand"
3096 (clobber (match_scratch:GPR 3 ""))]
3099 (div:<MODE> (match_dup 1) (match_dup 2)))
3101 (compare:CC (match_dup 3)
3106 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3107 (compare:CC (div:P (match_operand:P 1 "gpc_reg_operand" "r,r")
3108 (match_operand:P 2 "exact_log2_cint_operand" "N,N"))
3110 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
3111 (div:P (match_dup 1) (match_dup 2)))]
3114 {srai|sra<wd>i} %0,%1,%p2\;{aze.|addze.} %0,%0
3116 [(set_attr "type" "compare")
3117 (set_attr "length" "8,12")
3118 (set_attr "cell_micro" "not")])
3121 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3122 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
3123 (match_operand:GPR 2 "exact_log2_cint_operand"
3126 (set (match_operand:GPR 0 "gpc_reg_operand" "")
3127 (div:GPR (match_dup 1) (match_dup 2)))]
3130 (div:<MODE> (match_dup 1) (match_dup 2)))
3132 (compare:CC (match_dup 0)
3137 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3140 (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
3142 (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
3143 (match_operand:SI 3 "gpc_reg_operand" "r")))
3144 (set (match_operand:SI 2 "register_operand" "=*q")
3147 (zero_extend:DI (match_dup 1)) (const_int 32))
3148 (zero_extend:DI (match_dup 4)))
3152 [(set_attr "type" "idiv")])
3154 ;; To do unsigned divide we handle the cases of the divisor looking like a
3155 ;; negative number. If it is a constant that is less than 2**31, we don't
3156 ;; have to worry about the branches. So make a few subroutines here.
3158 ;; First comes the normal case.
3159 (define_expand "udivmodsi4_normal"
3160 [(set (match_dup 4) (const_int 0))
3161 (parallel [(set (match_operand:SI 0 "" "")
3162 (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
3164 (zero_extend:DI (match_operand:SI 1 "" "")))
3165 (match_operand:SI 2 "" "")))
3166 (set (match_operand:SI 3 "" "")
3167 (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
3169 (zero_extend:DI (match_dup 1)))
3173 { operands[4] = gen_reg_rtx (SImode); }")
3175 ;; This handles the branches.
3176 (define_expand "udivmodsi4_tests"
3177 [(set (match_operand:SI 0 "" "") (const_int 0))
3178 (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
3179 (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
3180 (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
3181 (label_ref (match_operand:SI 4 "" "")) (pc)))
3182 (set (match_dup 0) (const_int 1))
3183 (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
3184 (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
3185 (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
3186 (label_ref (match_dup 4)) (pc)))]
3189 { operands[5] = gen_reg_rtx (CCUNSmode);
3190 operands[6] = gen_reg_rtx (CCmode);
3193 (define_expand "udivmodsi4"
3194 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
3195 (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
3196 (match_operand:SI 2 "reg_or_cint_operand" "")))
3197 (set (match_operand:SI 3 "gpc_reg_operand" "")
3198 (umod:SI (match_dup 1) (match_dup 2)))])]
3206 if (! TARGET_POWERPC)
3208 emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
3209 emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
3210 emit_insn (gen_divus_call ());
3211 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
3212 emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
3219 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
3221 operands[2] = force_reg (SImode, operands[2]);
3222 label = gen_label_rtx ();
3223 emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
3224 operands[3], label));
3227 operands[2] = force_reg (SImode, operands[2]);
3229 emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
3237 ;; AIX architecture-independent common-mode multiply (DImode),
3238 ;; divide/modulus, and quotient subroutine calls. Input operands in R3 and
3239 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
3240 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
3241 ;; assumed unused if generating common-mode, so ignore.
3242 (define_insn "mulh_call"
3245 (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
3246 (sign_extend:DI (reg:SI 4)))
3248 (clobber (reg:SI LR_REGNO))]
3249 "! TARGET_POWER && ! TARGET_POWERPC"
3251 [(set_attr "type" "imul")])
3253 (define_insn "mull_call"
3255 (mult:DI (sign_extend:DI (reg:SI 3))
3256 (sign_extend:DI (reg:SI 4))))
3257 (clobber (reg:SI LR_REGNO))
3258 (clobber (reg:SI 0))]
3259 "! TARGET_POWER && ! TARGET_POWERPC"
3261 [(set_attr "type" "imul")])
3263 (define_insn "divss_call"
3265 (div:SI (reg:SI 3) (reg:SI 4)))
3267 (mod:SI (reg:SI 3) (reg:SI 4)))
3268 (clobber (reg:SI LR_REGNO))
3269 (clobber (reg:SI 0))]
3270 "! TARGET_POWER && ! TARGET_POWERPC"
3272 [(set_attr "type" "idiv")])
3274 (define_insn "divus_call"
3276 (udiv:SI (reg:SI 3) (reg:SI 4)))
3278 (umod:SI (reg:SI 3) (reg:SI 4)))
3279 (clobber (reg:SI LR_REGNO))
3280 (clobber (reg:SI 0))
3281 (clobber (match_scratch:CC 0 "=x"))
3282 (clobber (reg:CC CR1_REGNO))]
3283 "! TARGET_POWER && ! TARGET_POWERPC"
3285 [(set_attr "type" "idiv")])
3287 (define_insn "quoss_call"
3289 (div:SI (reg:SI 3) (reg:SI 4)))
3290 (clobber (reg:SI LR_REGNO))]
3291 "! TARGET_POWER && ! TARGET_POWERPC"
3293 [(set_attr "type" "idiv")])
3295 (define_insn "quous_call"
3297 (udiv:SI (reg:SI 3) (reg:SI 4)))
3298 (clobber (reg:SI LR_REGNO))
3299 (clobber (reg:SI 0))
3300 (clobber (match_scratch:CC 0 "=x"))
3301 (clobber (reg:CC CR1_REGNO))]
3302 "! TARGET_POWER && ! TARGET_POWERPC"
3304 [(set_attr "type" "idiv")])
3306 ;; Logical instructions
3307 ;; The logical instructions are mostly combined by using match_operator,
3308 ;; but the plain AND insns are somewhat different because there is no
3309 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
3310 ;; those rotate-and-mask operations. Thus, the AND insns come first.
3312 (define_expand "andsi3"
3314 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3315 (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
3316 (match_operand:SI 2 "and_operand" "")))
3317 (clobber (match_scratch:CC 3 ""))])]
3321 (define_insn "andsi3_mc"
3322 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
3323 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
3324 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
3325 (clobber (match_scratch:CC 3 "=X,X,x,x"))]
3326 "rs6000_gen_cell_microcode"
3329 {rlinm|rlwinm} %0,%1,0,%m2,%M2
3330 {andil.|andi.} %0,%1,%b2
3331 {andiu.|andis.} %0,%1,%u2"
3332 [(set_attr "type" "*,*,fast_compare,fast_compare")])
3334 (define_insn "andsi3_nomc"
3335 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3336 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
3337 (match_operand:SI 2 "and_operand" "?r,T")))
3338 (clobber (match_scratch:CC 3 "=X,X"))]
3339 "!rs6000_gen_cell_microcode"
3342 {rlinm|rlwinm} %0,%1,0,%m2,%M2")
3344 (define_insn "andsi3_internal0_nomc"
3345 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3346 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
3347 (match_operand:SI 2 "and_operand" "?r,T")))]
3348 "!rs6000_gen_cell_microcode"
3351 {rlinm|rlwinm} %0,%1,0,%m2,%M2")
3354 ;; Note to set cr's other than cr0 we do the and immediate and then
3355 ;; the test again -- this avoids a mfcr which on the higher end
3356 ;; machines causes an execution serialization
3358 (define_insn "*andsi3_internal2_mc"
3359 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
3360 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
3361 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
3363 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
3364 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
3365 "TARGET_32BIT && rs6000_gen_cell_microcode"
3368 {andil.|andi.} %3,%1,%b2
3369 {andiu.|andis.} %3,%1,%u2
3370 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
3375 [(set_attr "type" "fast_compare,fast_compare,fast_compare,delayed_compare,\
3376 compare,compare,compare,compare")
3377 (set_attr "length" "4,4,4,4,8,8,8,8")])
3379 (define_insn "*andsi3_internal3_mc"
3380 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
3381 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
3382 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
3384 (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
3385 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
3386 "TARGET_64BIT && rs6000_gen_cell_microcode"
3389 {andil.|andi.} %3,%1,%b2
3390 {andiu.|andis.} %3,%1,%u2
3391 {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
3396 [(set_attr "type" "compare,fast_compare,fast_compare,delayed_compare,compare,\
3397 compare,compare,compare")
3398 (set_attr "length" "8,4,4,4,8,8,8,8")])
3401 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3402 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
3403 (match_operand:GPR 2 "and_operand" ""))
3405 (clobber (match_scratch:GPR 3 ""))
3406 (clobber (match_scratch:CC 4 ""))]
3408 [(parallel [(set (match_dup 3)
3409 (and:<MODE> (match_dup 1)
3411 (clobber (match_dup 4))])
3413 (compare:CC (match_dup 3)
3417 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64. cr is set from the
3418 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
3421 [(set (match_operand:CC 0 "cc_reg_operand" "")
3422 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
3423 (match_operand:SI 2 "gpc_reg_operand" ""))
3425 (clobber (match_scratch:SI 3 ""))
3426 (clobber (match_scratch:CC 4 ""))]
3427 "TARGET_POWERPC64 && reload_completed"
3428 [(parallel [(set (match_dup 3)
3429 (and:SI (match_dup 1)
3431 (clobber (match_dup 4))])
3433 (compare:CC (match_dup 3)
3437 (define_insn "*andsi3_internal4"
3438 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
3439 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
3440 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
3442 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
3443 (and:SI (match_dup 1)
3445 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
3446 "TARGET_32BIT && rs6000_gen_cell_microcode"
3449 {andil.|andi.} %0,%1,%b2
3450 {andiu.|andis.} %0,%1,%u2
3451 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
3456 [(set_attr "type" "fast_compare,fast_compare,fast_compare,delayed_compare,\
3457 compare,compare,compare,compare")
3458 (set_attr "length" "4,4,4,4,8,8,8,8")])
3460 (define_insn "*andsi3_internal5_mc"
3461 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
3462 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
3463 (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
3465 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
3466 (and:SI (match_dup 1)
3468 (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
3469 "TARGET_64BIT && rs6000_gen_cell_microcode"
3472 {andil.|andi.} %0,%1,%b2
3473 {andiu.|andis.} %0,%1,%u2
3474 {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
3479 [(set_attr "type" "compare,fast_compare,fast_compare,delayed_compare,compare,\
3480 compare,compare,compare")
3481 (set_attr "length" "8,4,4,4,8,8,8,8")])
3484 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
3485 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
3486 (match_operand:SI 2 "and_operand" ""))
3488 (set (match_operand:SI 0 "gpc_reg_operand" "")
3489 (and:SI (match_dup 1)
3491 (clobber (match_scratch:CC 4 ""))]
3493 [(parallel [(set (match_dup 0)
3494 (and:SI (match_dup 1)
3496 (clobber (match_dup 4))])
3498 (compare:CC (match_dup 0)
3503 [(set (match_operand:CC 3 "cc_reg_operand" "")
3504 (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
3505 (match_operand:SI 2 "gpc_reg_operand" ""))
3507 (set (match_operand:SI 0 "gpc_reg_operand" "")
3508 (and:SI (match_dup 1)
3510 (clobber (match_scratch:CC 4 ""))]
3511 "TARGET_POWERPC64 && reload_completed"
3512 [(parallel [(set (match_dup 0)
3513 (and:SI (match_dup 1)
3515 (clobber (match_dup 4))])
3517 (compare:CC (match_dup 0)
3521 ;; Handle the PowerPC64 rlwinm corner case
3523 (define_insn_and_split "*andsi3_internal6"
3524 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3525 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3526 (match_operand:SI 2 "mask_operand_wrap" "i")))]
3531 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
3534 (rotate:SI (match_dup 0) (match_dup 5)))]
3537 int mb = extract_MB (operands[2]);
3538 int me = extract_ME (operands[2]);
3539 operands[3] = GEN_INT (me + 1);
3540 operands[5] = GEN_INT (32 - (me + 1));
3541 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
3543 [(set_attr "length" "8")])
3545 (define_expand "iorsi3"
3546 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3547 (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
3548 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
3552 if (GET_CODE (operands[2]) == CONST_INT
3553 && ! logical_operand (operands[2], SImode))
3555 HOST_WIDE_INT value = INTVAL (operands[2]);
3556 rtx tmp = ((!can_create_pseudo_p ()
3557 || rtx_equal_p (operands[0], operands[1]))
3558 ? operands[0] : gen_reg_rtx (SImode));
3560 emit_insn (gen_iorsi3 (tmp, operands[1],
3561 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3562 emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3567 (define_expand "xorsi3"
3568 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3569 (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
3570 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
3574 if (GET_CODE (operands[2]) == CONST_INT
3575 && ! logical_operand (operands[2], SImode))
3577 HOST_WIDE_INT value = INTVAL (operands[2]);
3578 rtx tmp = ((!can_create_pseudo_p ()
3579 || rtx_equal_p (operands[0], operands[1]))
3580 ? operands[0] : gen_reg_rtx (SImode));
3582 emit_insn (gen_xorsi3 (tmp, operands[1],
3583 GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3584 emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3589 (define_insn "*boolsi3_internal1"
3590 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
3591 (match_operator:SI 3 "boolean_or_operator"
3592 [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
3593 (match_operand:SI 2 "logical_operand" "r,K,L")]))]
3597 {%q3il|%q3i} %0,%1,%b2
3598 {%q3iu|%q3is} %0,%1,%u2")
3600 (define_insn "*boolsi3_internal2"
3601 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3602 (compare:CC (match_operator:SI 4 "boolean_or_operator"
3603 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3604 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3606 (clobber (match_scratch:SI 3 "=r,r"))]
3611 [(set_attr "type" "fast_compare,compare")
3612 (set_attr "length" "4,8")])
3615 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3616 (compare:CC (match_operator:SI 4 "boolean_operator"
3617 [(match_operand:SI 1 "gpc_reg_operand" "")
3618 (match_operand:SI 2 "gpc_reg_operand" "")])
3620 (clobber (match_scratch:SI 3 ""))]
3621 "TARGET_32BIT && reload_completed"
3622 [(set (match_dup 3) (match_dup 4))
3624 (compare:CC (match_dup 3)
3628 (define_insn "*boolsi3_internal3"
3629 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3630 (compare:CC (match_operator:SI 4 "boolean_operator"
3631 [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3632 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3634 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3640 [(set_attr "type" "fast_compare,compare")
3641 (set_attr "length" "4,8")])
3644 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
3645 (compare:CC (match_operator:SI 4 "boolean_operator"
3646 [(match_operand:SI 1 "gpc_reg_operand" "")
3647 (match_operand:SI 2 "gpc_reg_operand" "")])
3649 (set (match_operand:SI 0 "gpc_reg_operand" "")
3651 "TARGET_32BIT && reload_completed"
3652 [(set (match_dup 0) (match_dup 4))
3654 (compare:CC (match_dup 0)
3658 ;; Split a logical operation that we can't do in one insn into two insns,
3659 ;; each of which does one 16-bit part. This is used by combine.
3662 [(set (match_operand:SI 0 "gpc_reg_operand" "")
3663 (match_operator:SI 3 "boolean_or_operator"
3664 [(match_operand:SI 1 "gpc_reg_operand" "")
3665 (match_operand:SI 2 "non_logical_cint_operand" "")]))]
3667 [(set (match_dup 0) (match_dup 4))
3668 (set (match_dup 0) (match_dup 5))]
3672 i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
3673 operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3675 i = GEN_INT (INTVAL (operands[2]) & 0xffff);
3676 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
3680 (define_insn "*boolcsi3_internal1"
3681 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3682 (match_operator:SI 3 "boolean_operator"
3683 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3684 (match_operand:SI 2 "gpc_reg_operand" "r")]))]
3688 (define_insn "*boolcsi3_internal2"
3689 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3690 (compare:CC (match_operator:SI 4 "boolean_operator"
3691 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3692 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3694 (clobber (match_scratch:SI 3 "=r,r"))]
3699 [(set_attr "type" "compare")
3700 (set_attr "length" "4,8")])
3703 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3704 (compare:CC (match_operator:SI 4 "boolean_operator"
3705 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3706 (match_operand:SI 2 "gpc_reg_operand" "")])
3708 (clobber (match_scratch:SI 3 ""))]
3709 "TARGET_32BIT && reload_completed"
3710 [(set (match_dup 3) (match_dup 4))
3712 (compare:CC (match_dup 3)
3716 (define_insn "*boolcsi3_internal3"
3717 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3718 (compare:CC (match_operator:SI 4 "boolean_operator"
3719 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3720 (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3722 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3728 [(set_attr "type" "compare")
3729 (set_attr "length" "4,8")])
3732 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
3733 (compare:CC (match_operator:SI 4 "boolean_operator"
3734 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3735 (match_operand:SI 2 "gpc_reg_operand" "")])
3737 (set (match_operand:SI 0 "gpc_reg_operand" "")
3739 "TARGET_32BIT && reload_completed"
3740 [(set (match_dup 0) (match_dup 4))
3742 (compare:CC (match_dup 0)
3746 (define_insn "*boolccsi3_internal1"
3747 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3748 (match_operator:SI 3 "boolean_operator"
3749 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3750 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3754 (define_insn "*boolccsi3_internal2"
3755 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3756 (compare:CC (match_operator:SI 4 "boolean_operator"
3757 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3758 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3760 (clobber (match_scratch:SI 3 "=r,r"))]
3765 [(set_attr "type" "fast_compare,compare")
3766 (set_attr "length" "4,8")])
3769 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3770 (compare:CC (match_operator:SI 4 "boolean_operator"
3771 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3772 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3774 (clobber (match_scratch:SI 3 ""))]
3775 "TARGET_32BIT && reload_completed"
3776 [(set (match_dup 3) (match_dup 4))
3778 (compare:CC (match_dup 3)
3782 (define_insn "*boolccsi3_internal3"
3783 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3784 (compare:CC (match_operator:SI 4 "boolean_operator"
3785 [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3786 (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3788 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3794 [(set_attr "type" "fast_compare,compare")
3795 (set_attr "length" "4,8")])
3798 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
3799 (compare:CC (match_operator:SI 4 "boolean_operator"
3800 [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3801 (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3803 (set (match_operand:SI 0 "gpc_reg_operand" "")
3805 "TARGET_32BIT && reload_completed"
3806 [(set (match_dup 0) (match_dup 4))
3808 (compare:CC (match_dup 0)
3812 ;; maskir insn. We need four forms because things might be in arbitrary
3813 ;; orders. Don't define forms that only set CR fields because these
3814 ;; would modify an input register.
3816 (define_insn "*maskir_internal1"
3817 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3818 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3819 (match_operand:SI 1 "gpc_reg_operand" "0"))
3820 (and:SI (match_dup 2)
3821 (match_operand:SI 3 "gpc_reg_operand" "r"))))]
3825 (define_insn "*maskir_internal2"
3826 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3827 (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3828 (match_operand:SI 1 "gpc_reg_operand" "0"))
3829 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3834 (define_insn "*maskir_internal3"
3835 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3836 (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
3837 (match_operand:SI 3 "gpc_reg_operand" "r"))
3838 (and:SI (not:SI (match_dup 2))
3839 (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3843 (define_insn "*maskir_internal4"
3844 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3845 (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3846 (match_operand:SI 2 "gpc_reg_operand" "r"))
3847 (and:SI (not:SI (match_dup 2))
3848 (match_operand:SI 1 "gpc_reg_operand" "0"))))]