1 ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
2 ;; Copyright (C) 1990-2015 Free Software Foundation, Inc.
3 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 3, or (at your
10 ;; option) any later version.
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 ;; License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
21 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
29 (STACK_POINTER_REGNUM 1)
31 (STATIC_CHAIN_REGNUM 11)
32 (HARD_FRAME_POINTER_REGNUM 31)
38 (ARG_POINTER_REGNUM 67)
49 (FIRST_ALTIVEC_REGNO 77)
50 (LAST_ALTIVEC_REGNO 108)
55 (FRAME_POINTER_REGNUM 113)
59 (FIRST_SPE_HIGH_REGNO 117)
60 (LAST_SPE_HIGH_REGNO 148)
67 (define_c_enum "unspec"
68 [UNSPEC_FRSP ; frsp for POWER machines
69 UNSPEC_PROBE_STACK ; probe stack memory reference
70 UNSPEC_TOCPTR ; address of a word pointing to the TOC
71 UNSPEC_TOC ; address of the TOC (more-or-less)
72 UNSPEC_TOCSLOT ; offset from r1 of toc pointer save slot
74 UNSPEC_MV_CR_OV ; move_from_CR_ov_bit
80 UNSPEC_LD_MPIC ; load_macho_picbase
81 UNSPEC_RELD_MPIC ; re-load_macho_picbase
82 UNSPEC_MPIC_CORRECT ; macho_correct_pic
96 UNSPEC_FIX_TRUNC_TF ; fadd, rounding towards zero
97 UNSPEC_MV_CR_GT ; move_from_CR_gt_bit
115 UNSPEC_MACHOPIC_OFFSET
127 UNSPEC_P8V_RELOAD_FROM_GPR
130 UNSPEC_P8V_RELOAD_FROM_VSX
145 ;; UNSPEC_VOLATILE usage
148 (define_c_enum "unspecv"
150 UNSPECV_LL ; load-locked
151 UNSPECV_SC ; store-conditional
152 UNSPECV_PROBE_STACK_RANGE ; probe range of stack addresses
153 UNSPECV_EH_RR ; eh_reg_restore
154 UNSPECV_ISYNC ; isync instruction
155 UNSPECV_MFTB ; move from time base
156 UNSPECV_NLGR ; non-local goto receiver
157 UNSPECV_MFFS ; Move from FPSCR
158 UNSPECV_MTFSF ; Move to FPSCR Fields
162 ;; Define an insn type attribute. This is used in function unit delay
166 add,logical,shift,insert,
168 exts,cntlz,popcnt,isel,
169 load,store,fpload,fpstore,vecload,vecstore,
171 branch,jmpreg,mfjmpr,mtjmpr,trap,isync,sync,load_l,store_c,
172 cr_logical,delayed_cr,mfcr,mfcrf,mtcr,
173 fpcompare,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,
175 vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,
176 vecfloat,vecfdiv,vecdouble,mffgpr,mftgpr,crypto,
178 (const_string "integer"))
180 ;; What data size does this instruction work on?
181 ;; This is used for insert, mul.
182 (define_attr "size" "8,16,32,64" (const_string "32"))
184 ;; Is this instruction record form ("dot", signed compare to 0, writing CR0)?
185 ;; This is used for add, logical, shift, exts, mul.
186 (define_attr "dot" "no,yes" (const_string "no"))
188 ;; Does this instruction sign-extend its result?
189 ;; This is used for load insns.
190 (define_attr "sign_extend" "no,yes" (const_string "no"))
192 ;; Does this instruction use indexed (that is, reg+reg) addressing?
193 ;; This is used for load and store insns. If operand 0 or 1 is a MEM
194 ;; it is automatically set based on that. If a load or store instruction
195 ;; has fewer than two operands it needs to set this attribute manually
196 ;; or the compiler will crash.
197 (define_attr "indexed" "no,yes"
198 (if_then_else (ior (match_operand 0 "indexed_address_mem")
199 (match_operand 1 "indexed_address_mem"))
201 (const_string "no")))
203 ;; Does this instruction use update addressing?
204 ;; This is used for load and store insns. See the comments for "indexed".
205 (define_attr "update" "no,yes"
206 (if_then_else (ior (match_operand 0 "update_address_mem")
207 (match_operand 1 "update_address_mem"))
209 (const_string "no")))
211 ;; Is this instruction using operands[2] as shift amount, and can that be a
213 ;; This is used for shift insns.
214 (define_attr "maybe_var_shift" "no,yes" (const_string "no"))
216 ;; Is this instruction using a shift amount from a register?
217 ;; This is used for shift insns.
218 (define_attr "var_shift" "no,yes"
219 (if_then_else (and (eq_attr "type" "shift")
220 (eq_attr "maybe_var_shift" "yes"))
221 (if_then_else (match_operand 2 "gpc_reg_operand")
224 (const_string "no")))
226 ;; Define floating point instruction sub-types for use with Xfpu.md
227 (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"))
229 ;; Length (in bytes).
230 ; '(pc)' in the following doesn't include the instruction itself; it is
231 ; calculated as if the instruction had zero size.
232 (define_attr "length" ""
233 (if_then_else (eq_attr "type" "branch")
234 (if_then_else (and (ge (minus (match_dup 0) (pc))
236 (lt (minus (match_dup 0) (pc))
242 ;; Processor type -- this attribute must exactly match the processor_type
243 ;; enumeration in rs6000-opts.h.
245 "ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,
246 ppc750,ppc7400,ppc7450,
247 ppc403,ppc405,ppc440,ppc476,
248 ppc8540,ppc8548,ppce300c2,ppce300c3,ppce500mc,ppce500mc64,ppce5500,ppce6500,
249 power4,power5,power6,power7,power8,
250 rs64a,mpccore,cell,ppca2,titan"
251 (const (symbol_ref "rs6000_cpu_attr")))
254 ;; If this instruction is microcoded on the CELL processor
255 ; The default for load extended, the recorded instructions and rotate/shifts by a variable is always microcoded
256 (define_attr "cell_micro" "not,conditional,always"
257 (if_then_else (ior (and (eq_attr "type" "shift,exts,mul")
258 (eq_attr "dot" "yes"))
259 (and (eq_attr "type" "load")
260 (eq_attr "sign_extend" "yes"))
261 (and (eq_attr "type" "shift")
262 (eq_attr "var_shift" "yes")))
263 (const_string "always")
264 (const_string "not")))
266 (automata_option "ndfa")
279 (include "e300c2c3.md")
280 (include "e500mc.md")
281 (include "e500mc64.md")
284 (include "power4.md")
285 (include "power5.md")
286 (include "power6.md")
287 (include "power7.md")
288 (include "power8.md")
294 (include "predicates.md")
295 (include "constraints.md")
297 (include "darwin.md")
302 ; This mode iterator allows :GPR to be used to indicate the allowable size
303 ; of whole values in GPRs.
304 (define_mode_iterator GPR [SI (DI "TARGET_POWERPC64")])
306 ; Any supported integer mode.
307 (define_mode_iterator INT [QI HI SI DI TI PTI])
309 ; Any supported integer mode that fits in one register.
310 (define_mode_iterator INT1 [QI HI SI (DI "TARGET_POWERPC64")])
312 ; Everything we can extend QImode to.
313 (define_mode_iterator EXTQI [HI SI (DI "TARGET_POWERPC64")])
315 ; Everything we can extend HImode to.
316 (define_mode_iterator EXTHI [SI (DI "TARGET_POWERPC64")])
318 ; Everything we can extend SImode to.
319 (define_mode_iterator EXTSI [(DI "TARGET_POWERPC64")])
321 ; QImode or HImode for small atomic ops
322 (define_mode_iterator QHI [QI HI])
324 ; HImode or SImode for sign extended fusion ops
325 (define_mode_iterator HSI [HI SI])
327 ; SImode or DImode, even if DImode doesn't fit in GPRs.
328 (define_mode_iterator SDI [SI DI])
330 ; The size of a pointer. Also, the size of the value that a record-condition
331 ; (one with a '.') will compare; and the size used for arithmetic carries.
332 (define_mode_iterator P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
334 ; Iterator to add PTImode along with TImode (TImode can go in VSX registers,
335 ; PTImode is GPR only)
336 (define_mode_iterator TI2 [TI PTI])
338 ; Any hardware-supported floating-point mode
339 (define_mode_iterator FP [
340 (SF "TARGET_HARD_FLOAT
341 && ((TARGET_FPRS && TARGET_SINGLE_FLOAT) || TARGET_E500_SINGLE)")
342 (DF "TARGET_HARD_FLOAT
343 && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)")
344 (TF "!TARGET_IEEEQUAD
346 && (TARGET_FPRS || TARGET_E500_DOUBLE)
347 && TARGET_LONG_DOUBLE_128")
351 ; Any fma capable floating-point mode.
352 (define_mode_iterator FMA_F [
353 (SF "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT")
354 (DF "(TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
355 || VECTOR_UNIT_VSX_P (DFmode)")
356 (V2SF "TARGET_PAIRED_FLOAT")
357 (V4SF "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)")
358 (V2DF "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V2DFmode)")
361 ; Floating point move iterators to combine binary and decimal moves
362 (define_mode_iterator FMOVE32 [SF SD])
363 (define_mode_iterator FMOVE64 [DF DD])
364 (define_mode_iterator FMOVE64X [DI DF DD])
365 (define_mode_iterator FMOVE128 [(TF "!TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128")
366 (TD "TARGET_HARD_FLOAT && TARGET_FPRS")])
368 ; Iterators for 128 bit types for direct move
369 (define_mode_iterator FMOVE128_GPR [(TI "TARGET_VSX_TIMODE")
378 ; Whether a floating point move is ok, don't allow SD without hardware FP
379 (define_mode_attr fmove_ok [(SF "")
381 (SD "TARGET_HARD_FLOAT && TARGET_FPRS")
384 ; Convert REAL_VALUE to the appropriate bits
385 (define_mode_attr real_value_to_target [(SF "REAL_VALUE_TO_TARGET_SINGLE")
386 (DF "REAL_VALUE_TO_TARGET_DOUBLE")
387 (SD "REAL_VALUE_TO_TARGET_DECIMAL32")
388 (DD "REAL_VALUE_TO_TARGET_DECIMAL64")])
390 ; Definitions for load to 32-bit fpr register
391 (define_mode_attr f32_lr [(SF "f") (SD "wz")])
392 (define_mode_attr f32_lm [(SF "m") (SD "Z")])
393 (define_mode_attr f32_li [(SF "lfs%U1%X1 %0,%1") (SD "lfiwzx %0,%y1")])
394 (define_mode_attr f32_lv [(SF "lxsspx %x0,%y1") (SD "lxsiwzx %x0,%y1")])
396 ; Definitions for store from 32-bit fpr register
397 (define_mode_attr f32_sr [(SF "f") (SD "wx")])
398 (define_mode_attr f32_sm [(SF "m") (SD "Z")])
399 (define_mode_attr f32_si [(SF "stfs%U0%X0 %1,%0") (SD "stfiwx %1,%y0")])
400 (define_mode_attr f32_sv [(SF "stxsspx %x1,%y0") (SD "stxsiwzx %x1,%y0")])
402 ; Definitions for 32-bit fpr direct move
403 ; At present, the decimal modes are not allowed in the traditional altivec
404 ; registers, so restrict the constraints to just the traditional FPRs.
405 (define_mode_attr f32_dm [(SF "wn") (SD "wh")])
407 ; Definitions for 32-bit VSX
408 (define_mode_attr f32_vsx [(SF "ww") (SD "wn")])
410 ; Definitions for 32-bit use of altivec registers
411 (define_mode_attr f32_av [(SF "wu") (SD "wn")])
413 ; Definitions for 64-bit VSX
414 (define_mode_attr f64_vsx [(DF "ws") (DD "wn")])
416 ; Definitions for 64-bit direct move
417 (define_mode_attr f64_dm [(DF "wk") (DD "wh")])
419 ; Definitions for 64-bit use of altivec registers
420 (define_mode_attr f64_av [(DF "wv") (DD "wn")])
422 ; These modes do not fit in integer registers in 32-bit mode.
423 ; but on e500v2, the gpr are 64 bit registers
424 (define_mode_iterator DIFD [DI (DF "!TARGET_E500_DOUBLE") DD])
426 ; Iterator for reciprocal estimate instructions
427 (define_mode_iterator RECIPF [SF DF V4SF V2DF])
429 ; Iterator for just SF/DF
430 (define_mode_iterator SFDF [SF DF])
432 ; SF/DF suffix for traditional floating instructions
433 (define_mode_attr Ftrad [(SF "s") (DF "")])
435 ; SF/DF suffix for VSX instructions
436 (define_mode_attr Fvsx [(SF "sp") (DF "dp")])
438 ; SF/DF constraint for arithmetic on traditional floating point registers
439 (define_mode_attr Ff [(SF "f") (DF "d")])
441 ; SF/DF constraint for arithmetic on VSX registers
442 (define_mode_attr Fv [(SF "wy") (DF "ws")])
444 ; SF/DF constraint for arithmetic on altivec registers
445 (define_mode_attr Fa [(SF "wu") (DF "wv")])
447 ; s/d suffix for things like fp_addsub_s/fp_addsub_d
448 (define_mode_attr Fs [(SF "s") (DF "d")])
451 (define_mode_attr Ffre [(SF "fres") (DF "fre")])
452 (define_mode_attr FFRE [(SF "FRES") (DF "FRE")])
454 ; Conditional returns.
455 (define_code_iterator any_return [return simple_return])
456 (define_code_attr return_pred [(return "direct_return ()")
457 (simple_return "1")])
458 (define_code_attr return_str [(return "") (simple_return "simple_")])
461 (define_code_iterator iorxor [ior xor])
463 ; Signed/unsigned variants of ops.
464 (define_code_iterator any_extend [sign_extend zero_extend])
465 (define_code_attr u [(sign_extend "") (zero_extend "u")])
466 (define_code_attr su [(sign_extend "s") (zero_extend "u")])
468 ; Various instructions that come in SI and DI forms.
469 ; A generic w/d attribute, for things like cmpw/cmpd.
470 (define_mode_attr wd [(QI "b")
479 ;; How many bits in this mode?
480 (define_mode_attr bits [(QI "8") (HI "16") (SI "32") (DI "64")])
483 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
485 ;; ISEL/ISEL64 target selection
486 (define_mode_attr sel [(SI "") (DI "64")])
488 ;; Bitmask for shift instructions
489 (define_mode_attr hH [(SI "h") (DI "H")])
491 ;; A mode twice the size of the given mode
492 (define_mode_attr dmode [(SI "di") (DI "ti")])
493 (define_mode_attr DMODE [(SI "DI") (DI "TI")])
495 ;; Suffix for reload patterns
496 (define_mode_attr ptrsize [(SI "32bit")
499 (define_mode_attr tptrsize [(SI "TARGET_32BIT")
500 (DI "TARGET_64BIT")])
502 (define_mode_attr mptrsize [(SI "si")
505 (define_mode_attr ptrload [(SI "lwz")
508 (define_mode_attr ptrm [(SI "m")
511 (define_mode_attr rreg [(SF "f")
518 (define_mode_attr rreg2 [(SF "f")
521 (define_mode_attr SI_CONVERT_FP [(SF "TARGET_FCFIDS")
522 (DF "TARGET_FCFID")])
524 (define_mode_attr E500_CONVERT [(SF "!TARGET_FPRS")
525 (DF "TARGET_E500_DOUBLE")])
527 (define_mode_attr TARGET_FLOAT [(SF "TARGET_SINGLE_FLOAT")
528 (DF "TARGET_DOUBLE_FLOAT")])
530 ;; Mode iterator for logical operations on 128-bit types
531 (define_mode_iterator BOOL_128 [TI
533 (V16QI "TARGET_ALTIVEC")
534 (V8HI "TARGET_ALTIVEC")
535 (V4SI "TARGET_ALTIVEC")
536 (V4SF "TARGET_ALTIVEC")
537 (V2DI "TARGET_ALTIVEC")
538 (V2DF "TARGET_ALTIVEC")
539 (V1TI "TARGET_ALTIVEC")])
541 ;; For the GPRs we use 3 constraints for register outputs, two that are the
542 ;; same as the output register, and a third where the output register is an
543 ;; early clobber, so we don't have to deal with register overlaps. For the
544 ;; vector types, we prefer to use the vector registers. For TI mode, allow
547 ;; Mode attribute for boolean operation register constraints for output
548 (define_mode_attr BOOL_REGS_OUTPUT [(TI "&r,r,r,wt,v")
550 (V16QI "wa,v,&?r,?r,?r")
551 (V8HI "wa,v,&?r,?r,?r")
552 (V4SI "wa,v,&?r,?r,?r")
553 (V4SF "wa,v,&?r,?r,?r")
554 (V2DI "wa,v,&?r,?r,?r")
555 (V2DF "wa,v,&?r,?r,?r")
556 (V1TI "wa,v,&?r,?r,?r")])
558 ;; Mode attribute for boolean operation register constraints for operand1
559 (define_mode_attr BOOL_REGS_OP1 [(TI "r,0,r,wt,v")
567 (V1TI "wa,v,r,0,r")])
569 ;; Mode attribute for boolean operation register constraints for operand2
570 (define_mode_attr BOOL_REGS_OP2 [(TI "r,r,0,wt,v")
578 (V1TI "wa,v,r,r,0")])
580 ;; Mode attribute for boolean operation register constraints for operand1
581 ;; for one_cmpl. To simplify things, we repeat the constraint where 0
582 ;; is used for operand1 or operand2
583 (define_mode_attr BOOL_REGS_UNARY [(TI "r,0,0,wt,v")
591 (V1TI "wa,v,r,0,0")])
593 ;; Reload iterator for creating the function to allocate a base register to
594 ;; supplement addressing modes.
595 (define_mode_iterator RELOAD [V16QI V8HI V4SI V2DI V4SF V2DF V1TI
596 SF SD SI DF DD DI TI PTI])
599 ;; Start with fixed-point load and store insns. Here we put only the more
600 ;; complex forms. Basic data transfer is done later.
602 (define_insn "zero_extendqi<mode>2"
603 [(set (match_operand:EXTQI 0 "gpc_reg_operand" "=r,r")
604 (zero_extend:EXTQI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
609 [(set_attr "type" "load,shift")])
611 (define_insn_and_split "*zero_extendqi<mode>2_dot"
612 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
613 (compare:CC (zero_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
615 (clobber (match_scratch:EXTQI 0 "=r,r"))]
616 "rs6000_gen_cell_microcode"
620 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
622 (zero_extend:EXTQI (match_dup 1)))
624 (compare:CC (match_dup 0)
627 [(set_attr "type" "logical")
628 (set_attr "dot" "yes")
629 (set_attr "length" "4,8")])
631 (define_insn_and_split "*zero_extendqi<mode>2_dot2"
632 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
633 (compare:CC (zero_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
635 (set (match_operand:EXTQI 0 "gpc_reg_operand" "=r,r")
636 (zero_extend:EXTQI (match_dup 1)))]
637 "rs6000_gen_cell_microcode"
641 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
643 (zero_extend:EXTQI (match_dup 1)))
645 (compare:CC (match_dup 0)
648 [(set_attr "type" "logical")
649 (set_attr "dot" "yes")
650 (set_attr "length" "4,8")])
653 (define_insn "zero_extendhi<mode>2"
654 [(set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r")
655 (zero_extend:EXTHI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
659 rlwinm %0,%1,0,0xffff"
660 [(set_attr "type" "load,shift")])
662 (define_insn_and_split "*zero_extendhi<mode>2_dot"
663 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
664 (compare:CC (zero_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
666 (clobber (match_scratch:EXTHI 0 "=r,r"))]
667 "rs6000_gen_cell_microcode"
671 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
673 (zero_extend:EXTHI (match_dup 1)))
675 (compare:CC (match_dup 0)
678 [(set_attr "type" "logical")
679 (set_attr "dot" "yes")
680 (set_attr "length" "4,8")])
682 (define_insn_and_split "*zero_extendhi<mode>2_dot2"
683 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
684 (compare:CC (zero_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
686 (set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r")
687 (zero_extend:EXTHI (match_dup 1)))]
688 "rs6000_gen_cell_microcode"
692 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
694 (zero_extend:EXTHI (match_dup 1)))
696 (compare:CC (match_dup 0)
699 [(set_attr "type" "logical")
700 (set_attr "dot" "yes")
701 (set_attr "length" "4,8")])
704 (define_insn "zero_extendsi<mode>2"
705 [(set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r,??wj,!wz,!wu")
706 (zero_extend:EXTSI (match_operand:SI 1 "reg_or_mem_operand" "m,r,r,Z,Z")))]
714 [(set_attr "type" "load,shift,mffgpr,fpload,fpload")])
716 (define_insn_and_split "*zero_extendsi<mode>2_dot"
717 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
718 (compare:CC (zero_extend:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
720 (clobber (match_scratch:EXTSI 0 "=r,r"))]
721 "rs6000_gen_cell_microcode"
725 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
727 (zero_extend:DI (match_dup 1)))
729 (compare:CC (match_dup 0)
732 [(set_attr "type" "shift")
733 (set_attr "dot" "yes")
734 (set_attr "length" "4,8")])
736 (define_insn_and_split "*zero_extendsi<mode>2_dot2"
737 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
738 (compare:CC (zero_extend:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
740 (set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r")
741 (zero_extend:EXTSI (match_dup 1)))]
742 "rs6000_gen_cell_microcode"
746 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
748 (zero_extend:EXTSI (match_dup 1)))
750 (compare:CC (match_dup 0)
753 [(set_attr "type" "shift")
754 (set_attr "dot" "yes")
755 (set_attr "length" "4,8")])
758 (define_insn "extendqi<mode>2"
759 [(set (match_operand:EXTQI 0 "gpc_reg_operand" "=r")
760 (sign_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r")))]
763 [(set_attr "type" "exts")])
765 (define_insn_and_split "*extendqi<mode>2_dot"
766 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
767 (compare:CC (sign_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
769 (clobber (match_scratch:EXTQI 0 "=r,r"))]
770 "rs6000_gen_cell_microcode"
774 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
776 (sign_extend:EXTQI (match_dup 1)))
778 (compare:CC (match_dup 0)
781 [(set_attr "type" "exts")
782 (set_attr "dot" "yes")
783 (set_attr "length" "4,8")])
785 (define_insn_and_split "*extendqi<mode>2_dot2"
786 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
787 (compare:CC (sign_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
789 (set (match_operand:EXTQI 0 "gpc_reg_operand" "=r,r")
790 (sign_extend:EXTQI (match_dup 1)))]
791 "rs6000_gen_cell_microcode"
795 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
797 (sign_extend:EXTQI (match_dup 1)))
799 (compare:CC (match_dup 0)
802 [(set_attr "type" "exts")
803 (set_attr "dot" "yes")
804 (set_attr "length" "4,8")])
807 (define_expand "extendhi<mode>2"
808 [(set (match_operand:EXTHI 0 "gpc_reg_operand" "")
809 (sign_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "")))]
813 (define_insn "*extendhi<mode>2"
814 [(set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r")
815 (sign_extend:EXTHI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
816 "rs6000_gen_cell_microcode"
820 [(set_attr "type" "load,exts")
821 (set_attr "sign_extend" "yes")])
823 (define_insn "*extendhi<mode>2_noload"
824 [(set (match_operand:EXTHI 0 "gpc_reg_operand" "=r")
825 (sign_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r")))]
826 "!rs6000_gen_cell_microcode"
828 [(set_attr "type" "exts")])
830 (define_insn_and_split "*extendhi<mode>2_dot"
831 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
832 (compare:CC (sign_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
834 (clobber (match_scratch:EXTHI 0 "=r,r"))]
835 "rs6000_gen_cell_microcode"
839 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
841 (sign_extend:EXTHI (match_dup 1)))
843 (compare:CC (match_dup 0)
846 [(set_attr "type" "exts")
847 (set_attr "dot" "yes")
848 (set_attr "length" "4,8")])
850 (define_insn_and_split "*extendhi<mode>2_dot2"
851 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
852 (compare:CC (sign_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
854 (set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r")
855 (sign_extend:EXTHI (match_dup 1)))]
856 "rs6000_gen_cell_microcode"
860 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
862 (sign_extend:EXTHI (match_dup 1)))
864 (compare:CC (match_dup 0)
867 [(set_attr "type" "exts")
868 (set_attr "dot" "yes")
869 (set_attr "length" "4,8")])
872 (define_insn "extendsi<mode>2"
873 [(set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r,??wj,!wl,!wu")
874 (sign_extend:EXTSI (match_operand:SI 1 "lwa_operand" "Y,r,r,Z,Z")))]
882 [(set_attr "type" "load,exts,mffgpr,fpload,fpload")
883 (set_attr "sign_extend" "yes")])
885 (define_insn_and_split "*extendsi<mode>2_dot"
886 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
887 (compare:CC (sign_extend:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
889 (clobber (match_scratch:EXTSI 0 "=r,r"))]
890 "rs6000_gen_cell_microcode"
894 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
896 (sign_extend:EXTSI (match_dup 1)))
898 (compare:CC (match_dup 0)
901 [(set_attr "type" "exts")
902 (set_attr "dot" "yes")
903 (set_attr "length" "4,8")])
905 (define_insn_and_split "*extendsi<mode>2_dot2"
906 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
907 (compare:CC (sign_extend:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
909 (set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r")
910 (sign_extend:EXTSI (match_dup 1)))]
911 "rs6000_gen_cell_microcode"
915 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
917 (sign_extend:EXTSI (match_dup 1)))
919 (compare:CC (match_dup 0)
922 [(set_attr "type" "exts")
923 (set_attr "dot" "yes")
924 (set_attr "length" "4,8")])
926 ;; IBM 405, 440, 464 and 476 half-word multiplication operations.
928 (define_insn "*macchwc"
929 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
930 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
931 (match_operand:SI 2 "gpc_reg_operand" "r")
934 (match_operand:HI 1 "gpc_reg_operand" "r")))
935 (match_operand:SI 4 "gpc_reg_operand" "0"))
937 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
938 (plus:SI (mult:SI (ashiftrt:SI
946 [(set_attr "type" "halfmul")])
948 (define_insn "*macchw"
949 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
950 (plus:SI (mult:SI (ashiftrt:SI
951 (match_operand:SI 2 "gpc_reg_operand" "r")
954 (match_operand:HI 1 "gpc_reg_operand" "r")))
955 (match_operand:SI 3 "gpc_reg_operand" "0")))]
958 [(set_attr "type" "halfmul")])
960 (define_insn "*macchwuc"
961 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
962 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
963 (match_operand:SI 2 "gpc_reg_operand" "r")
966 (match_operand:HI 1 "gpc_reg_operand" "r")))
967 (match_operand:SI 4 "gpc_reg_operand" "0"))
969 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
970 (plus:SI (mult:SI (lshiftrt:SI
978 [(set_attr "type" "halfmul")])
980 (define_insn "*macchwu"
981 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
982 (plus:SI (mult:SI (lshiftrt:SI
983 (match_operand:SI 2 "gpc_reg_operand" "r")
986 (match_operand:HI 1 "gpc_reg_operand" "r")))
987 (match_operand:SI 3 "gpc_reg_operand" "0")))]
990 [(set_attr "type" "halfmul")])
992 (define_insn "*machhwc"
993 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
994 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
995 (match_operand:SI 1 "gpc_reg_operand" "%r")
998 (match_operand:SI 2 "gpc_reg_operand" "r")
1000 (match_operand:SI 4 "gpc_reg_operand" "0"))
1002 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1003 (plus:SI (mult:SI (ashiftrt:SI
1012 [(set_attr "type" "halfmul")])
1014 (define_insn "*machhw"
1015 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1016 (plus:SI (mult:SI (ashiftrt:SI
1017 (match_operand:SI 1 "gpc_reg_operand" "%r")
1020 (match_operand:SI 2 "gpc_reg_operand" "r")
1022 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1025 [(set_attr "type" "halfmul")])
1027 (define_insn "*machhwuc"
1028 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1029 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
1030 (match_operand:SI 1 "gpc_reg_operand" "%r")
1033 (match_operand:SI 2 "gpc_reg_operand" "r")
1035 (match_operand:SI 4 "gpc_reg_operand" "0"))
1037 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1038 (plus:SI (mult:SI (lshiftrt:SI
1047 [(set_attr "type" "halfmul")])
1049 (define_insn "*machhwu"
1050 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1051 (plus:SI (mult:SI (lshiftrt:SI
1052 (match_operand:SI 1 "gpc_reg_operand" "%r")
1055 (match_operand:SI 2 "gpc_reg_operand" "r")
1057 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1060 [(set_attr "type" "halfmul")])
1062 (define_insn "*maclhwc"
1063 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1064 (compare:CC (plus:SI (mult:SI (sign_extend:SI
1065 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1067 (match_operand:HI 2 "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 (sign_extend:SI
1078 [(set_attr "type" "halfmul")])
1080 (define_insn "*maclhw"
1081 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1082 (plus:SI (mult:SI (sign_extend:SI
1083 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1085 (match_operand:HI 2 "gpc_reg_operand" "r")))
1086 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1089 [(set_attr "type" "halfmul")])
1091 (define_insn "*maclhwuc"
1092 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1093 (compare:CC (plus:SI (mult:SI (zero_extend:SI
1094 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1096 (match_operand:HI 2 "gpc_reg_operand" "r")))
1097 (match_operand:SI 4 "gpc_reg_operand" "0"))
1099 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1100 (plus:SI (mult:SI (zero_extend:SI
1107 [(set_attr "type" "halfmul")])
1109 (define_insn "*maclhwu"
1110 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1111 (plus:SI (mult:SI (zero_extend:SI
1112 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1114 (match_operand:HI 2 "gpc_reg_operand" "r")))
1115 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1118 [(set_attr "type" "halfmul")])
1120 (define_insn "*nmacchwc"
1121 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1122 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1123 (mult:SI (ashiftrt:SI
1124 (match_operand:SI 2 "gpc_reg_operand" "r")
1127 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1129 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1130 (minus:SI (match_dup 4)
1131 (mult:SI (ashiftrt:SI
1138 [(set_attr "type" "halfmul")])
1140 (define_insn "*nmacchw"
1141 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1142 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1143 (mult:SI (ashiftrt:SI
1144 (match_operand:SI 2 "gpc_reg_operand" "r")
1147 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1150 [(set_attr "type" "halfmul")])
1152 (define_insn "*nmachhwc"
1153 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1154 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1155 (mult:SI (ashiftrt:SI
1156 (match_operand:SI 1 "gpc_reg_operand" "%r")
1159 (match_operand:SI 2 "gpc_reg_operand" "r")
1162 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1163 (minus:SI (match_dup 4)
1164 (mult:SI (ashiftrt:SI
1172 [(set_attr "type" "halfmul")])
1174 (define_insn "*nmachhw"
1175 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1176 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1177 (mult:SI (ashiftrt:SI
1178 (match_operand:SI 1 "gpc_reg_operand" "%r")
1181 (match_operand:SI 2 "gpc_reg_operand" "r")
1185 [(set_attr "type" "halfmul")])
1187 (define_insn "*nmaclhwc"
1188 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1189 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1190 (mult:SI (sign_extend:SI
1191 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1193 (match_operand:HI 2 "gpc_reg_operand" "r"))))
1195 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1196 (minus:SI (match_dup 4)
1197 (mult:SI (sign_extend:SI
1203 [(set_attr "type" "halfmul")])
1205 (define_insn "*nmaclhw"
1206 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1207 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1208 (mult:SI (sign_extend:SI
1209 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1211 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1214 [(set_attr "type" "halfmul")])
1216 (define_insn "*mulchwc"
1217 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1218 (compare:CC (mult:SI (ashiftrt:SI
1219 (match_operand:SI 2 "gpc_reg_operand" "r")
1222 (match_operand:HI 1 "gpc_reg_operand" "r")))
1224 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1225 (mult:SI (ashiftrt:SI
1232 [(set_attr "type" "halfmul")])
1234 (define_insn "*mulchw"
1235 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1236 (mult:SI (ashiftrt:SI
1237 (match_operand:SI 2 "gpc_reg_operand" "r")
1240 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1243 [(set_attr "type" "halfmul")])
1245 (define_insn "*mulchwuc"
1246 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1247 (compare:CC (mult:SI (lshiftrt:SI
1248 (match_operand:SI 2 "gpc_reg_operand" "r")
1251 (match_operand:HI 1 "gpc_reg_operand" "r")))
1253 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1254 (mult:SI (lshiftrt:SI
1261 [(set_attr "type" "halfmul")])
1263 (define_insn "*mulchwu"
1264 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1265 (mult:SI (lshiftrt:SI
1266 (match_operand:SI 2 "gpc_reg_operand" "r")
1269 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1272 [(set_attr "type" "halfmul")])
1274 (define_insn "*mulhhwc"
1275 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1276 (compare:CC (mult:SI (ashiftrt:SI
1277 (match_operand:SI 1 "gpc_reg_operand" "%r")
1280 (match_operand:SI 2 "gpc_reg_operand" "r")
1283 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1284 (mult:SI (ashiftrt:SI
1292 [(set_attr "type" "halfmul")])
1294 (define_insn "*mulhhw"
1295 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1296 (mult:SI (ashiftrt:SI
1297 (match_operand:SI 1 "gpc_reg_operand" "%r")
1300 (match_operand:SI 2 "gpc_reg_operand" "r")
1304 [(set_attr "type" "halfmul")])
1306 (define_insn "*mulhhwuc"
1307 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1308 (compare:CC (mult:SI (lshiftrt:SI
1309 (match_operand:SI 1 "gpc_reg_operand" "%r")
1312 (match_operand:SI 2 "gpc_reg_operand" "r")
1315 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1316 (mult:SI (lshiftrt:SI
1324 [(set_attr "type" "halfmul")])
1326 (define_insn "*mulhhwu"
1327 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1328 (mult:SI (lshiftrt:SI
1329 (match_operand:SI 1 "gpc_reg_operand" "%r")
1332 (match_operand:SI 2 "gpc_reg_operand" "r")
1336 [(set_attr "type" "halfmul")])
1338 (define_insn "*mullhwc"
1339 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1340 (compare:CC (mult:SI (sign_extend:SI
1341 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1343 (match_operand:HI 2 "gpc_reg_operand" "r")))
1345 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1346 (mult:SI (sign_extend:SI
1352 [(set_attr "type" "halfmul")])
1354 (define_insn "*mullhw"
1355 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1356 (mult:SI (sign_extend:SI
1357 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1359 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1362 [(set_attr "type" "halfmul")])
1364 (define_insn "*mullhwuc"
1365 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1366 (compare:CC (mult:SI (zero_extend:SI
1367 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1369 (match_operand:HI 2 "gpc_reg_operand" "r")))
1371 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1372 (mult:SI (zero_extend:SI
1378 [(set_attr "type" "halfmul")])
1380 (define_insn "*mullhwu"
1381 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1382 (mult:SI (zero_extend:SI
1383 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1385 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1388 [(set_attr "type" "halfmul")])
1390 ;; IBM 405, 440, 464 and 476 string-search dlmzb instruction support.
1391 (define_insn "dlmzb"
1392 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1393 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1394 (match_operand:SI 2 "gpc_reg_operand" "r")]
1396 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1397 (unspec:SI [(match_dup 1)
1403 (define_expand "strlensi"
1404 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1405 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1406 (match_operand:QI 2 "const_int_operand" "")
1407 (match_operand 3 "const_int_operand" "")]
1408 UNSPEC_DLMZB_STRLEN))
1409 (clobber (match_scratch:CC 4 "=x"))]
1410 "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1412 rtx result = operands[0];
1413 rtx src = operands[1];
1414 rtx search_char = operands[2];
1415 rtx align = operands[3];
1416 rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1417 rtx loop_label, end_label, mem, cr0, cond;
1418 if (search_char != const0_rtx
1419 || GET_CODE (align) != CONST_INT
1420 || INTVAL (align) < 8)
1422 word1 = gen_reg_rtx (SImode);
1423 word2 = gen_reg_rtx (SImode);
1424 scratch_dlmzb = gen_reg_rtx (SImode);
1425 scratch_string = gen_reg_rtx (Pmode);
1426 loop_label = gen_label_rtx ();
1427 end_label = gen_label_rtx ();
1428 addr = force_reg (Pmode, XEXP (src, 0));
1429 emit_move_insn (scratch_string, addr);
1430 emit_label (loop_label);
1431 mem = change_address (src, SImode, scratch_string);
1432 emit_move_insn (word1, mem);
1433 emit_move_insn (word2, adjust_address (mem, SImode, 4));
1434 cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1435 emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1436 cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1437 emit_jump_insn (gen_rtx_SET (VOIDmode,
1439 gen_rtx_IF_THEN_ELSE (VOIDmode,
1445 emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1446 emit_jump_insn (gen_rtx_SET (VOIDmode,
1448 gen_rtx_LABEL_REF (VOIDmode, loop_label)));
1450 emit_label (end_label);
1451 emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1452 emit_insn (gen_subsi3 (result, scratch_string, addr));
1453 emit_insn (gen_addsi3 (result, result, constm1_rtx));
1457 ;; Fixed-point arithmetic insns.
1459 (define_expand "add<mode>3"
1460 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1461 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1462 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1465 if (<MODE>mode == DImode && !TARGET_POWERPC64)
1467 rtx lo0 = gen_lowpart (SImode, operands[0]);
1468 rtx lo1 = gen_lowpart (SImode, operands[1]);
1469 rtx lo2 = gen_lowpart (SImode, operands[2]);
1470 rtx hi0 = gen_highpart (SImode, operands[0]);
1471 rtx hi1 = gen_highpart (SImode, operands[1]);
1472 rtx hi2 = gen_highpart_mode (SImode, DImode, operands[2]);
1474 if (!reg_or_short_operand (lo2, SImode))
1475 lo2 = force_reg (SImode, lo2);
1476 if (!adde_operand (hi2, SImode))
1477 hi2 = force_reg (SImode, hi2);
1479 emit_insn (gen_addsi3_carry (lo0, lo1, lo2));
1480 emit_insn (gen_addsi3_carry_in (hi0, hi1, hi2));
1484 if (CONST_INT_P (operands[2]) && !add_operand (operands[2], <MODE>mode))
1486 rtx tmp = ((!can_create_pseudo_p ()
1487 || rtx_equal_p (operands[0], operands[1]))
1488 ? operands[0] : gen_reg_rtx (<MODE>mode));
1490 HOST_WIDE_INT val = INTVAL (operands[2]);
1491 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1492 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1494 if (<MODE>mode == DImode && !satisfies_constraint_L (GEN_INT (rest)))
1497 /* The ordering here is important for the prolog expander.
1498 When space is allocated from the stack, adding 'low' first may
1499 produce a temporary deallocation (which would be bad). */
1500 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1501 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1506 (define_insn "*add<mode>3"
1507 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,r")
1508 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,b")
1509 (match_operand:GPR 2 "add_operand" "r,I,L")))]
1515 [(set_attr "type" "add")])
1517 (define_insn "addsi3_high"
1518 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1519 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1520 (high:SI (match_operand 2 "" ""))))]
1521 "TARGET_MACHO && !TARGET_64BIT"
1522 "addis %0,%1,ha16(%2)"
1523 [(set_attr "type" "add")])
1525 (define_insn_and_split "*add<mode>3_dot"
1526 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1527 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
1528 (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
1530 (clobber (match_scratch:GPR 0 "=r,r"))]
1531 "<MODE>mode == Pmode"
1535 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
1537 (plus:GPR (match_dup 1)
1540 (compare:CC (match_dup 0)
1543 [(set_attr "type" "add")
1544 (set_attr "dot" "yes")
1545 (set_attr "length" "4,8")])
1547 (define_insn_and_split "*add<mode>3_dot2"
1548 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1549 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
1550 (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
1552 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1553 (plus:GPR (match_dup 1)
1555 "<MODE>mode == Pmode"
1559 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
1561 (plus:GPR (match_dup 1)
1564 (compare:CC (match_dup 0)
1567 [(set_attr "type" "add")
1568 (set_attr "dot" "yes")
1569 (set_attr "length" "4,8")])
1571 (define_insn_and_split "*add<mode>3_imm_dot"
1572 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1573 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b")
1574 (match_operand:GPR 2 "short_cint_operand" "I,I"))
1576 (clobber (match_scratch:GPR 0 "=r,r"))
1577 (clobber (reg:GPR CA_REGNO))]
1578 "<MODE>mode == Pmode"
1582 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
1584 (plus:GPR (match_dup 1)
1587 (compare:CC (match_dup 0)
1590 [(set_attr "type" "add")
1591 (set_attr "dot" "yes")
1592 (set_attr "length" "4,8")])
1594 (define_insn_and_split "*add<mode>3_imm_dot2"
1595 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1596 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b")
1597 (match_operand:GPR 2 "short_cint_operand" "I,I"))
1599 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1600 (plus:GPR (match_dup 1)
1602 (clobber (reg:GPR CA_REGNO))]
1603 "<MODE>mode == Pmode"
1607 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
1609 (plus:GPR (match_dup 1)
1612 (compare:CC (match_dup 0)
1615 [(set_attr "type" "add")
1616 (set_attr "dot" "yes")
1617 (set_attr "length" "4,8")])
1619 ;; Split an add that we can't do in one insn into two insns, each of which
1620 ;; does one 16-bit part. This is used by combine. Note that the low-order
1621 ;; add should be last in case the result gets used in an address.
1624 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1625 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1626 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1628 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1629 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1631 HOST_WIDE_INT val = INTVAL (operands[2]);
1632 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1633 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1635 operands[4] = GEN_INT (low);
1636 if (<MODE>mode == SImode || satisfies_constraint_L (GEN_INT (rest)))
1637 operands[3] = GEN_INT (rest);
1638 else if (can_create_pseudo_p ())
1640 operands[3] = gen_reg_rtx (DImode);
1641 emit_move_insn (operands[3], operands[2]);
1642 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1650 (define_insn "add<mode>3_carry"
1651 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
1652 (plus:P (match_operand:P 1 "gpc_reg_operand" "r")
1653 (match_operand:P 2 "reg_or_short_operand" "rI")))
1654 (set (reg:P CA_REGNO)
1655 (ltu:P (plus:P (match_dup 1)
1660 [(set_attr "type" "add")])
1662 (define_insn "*add<mode>3_imm_carry_pos"
1663 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
1664 (plus:P (match_operand:P 1 "gpc_reg_operand" "r")
1665 (match_operand:P 2 "short_cint_operand" "n")))
1666 (set (reg:P CA_REGNO)
1667 (geu:P (match_dup 1)
1668 (match_operand:P 3 "const_int_operand" "n")))]
1669 "INTVAL (operands[2]) > 0
1670 && INTVAL (operands[2]) + INTVAL (operands[3]) == 0"
1672 [(set_attr "type" "add")])
1674 (define_insn "*add<mode>3_imm_carry_0"
1675 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
1676 (match_operand:P 1 "gpc_reg_operand" "r"))
1677 (set (reg:P CA_REGNO)
1681 [(set_attr "type" "add")])
1683 (define_insn "*add<mode>3_imm_carry_m1"
1684 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
1685 (plus:P (match_operand:P 1 "gpc_reg_operand" "r")
1687 (set (reg:P CA_REGNO)
1692 [(set_attr "type" "add")])
1694 (define_insn "*add<mode>3_imm_carry_neg"
1695 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
1696 (plus:P (match_operand:P 1 "gpc_reg_operand" "r")
1697 (match_operand:P 2 "short_cint_operand" "n")))
1698 (set (reg:P CA_REGNO)
1699 (gtu:P (match_dup 1)
1700 (match_operand:P 3 "const_int_operand" "n")))]
1701 "INTVAL (operands[2]) < 0
1702 && INTVAL (operands[2]) + INTVAL (operands[3]) == -1"
1704 [(set_attr "type" "add")])
1707 (define_expand "add<mode>3_carry_in"
1709 (set (match_operand:GPR 0 "gpc_reg_operand")
1710 (plus:GPR (plus:GPR (match_operand:GPR 1 "gpc_reg_operand")
1711 (match_operand:GPR 2 "adde_operand"))
1712 (reg:GPR CA_REGNO)))
1713 (clobber (reg:GPR CA_REGNO))])]
1716 if (operands[2] == const0_rtx)
1718 emit_insn (gen_add<mode>3_carry_in_0 (operands[0], operands[1]));
1721 if (operands[2] == constm1_rtx)
1723 emit_insn (gen_add<mode>3_carry_in_m1 (operands[0], operands[1]));
1728 (define_insn "*add<mode>3_carry_in_internal"
1729 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1730 (plus:GPR (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
1731 (match_operand:GPR 2 "gpc_reg_operand" "r"))
1732 (reg:GPR CA_REGNO)))
1733 (clobber (reg:GPR CA_REGNO))]
1736 [(set_attr "type" "add")])
1738 (define_insn "add<mode>3_carry_in_0"
1739 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1740 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
1741 (reg:GPR CA_REGNO)))
1742 (clobber (reg:GPR CA_REGNO))]
1745 [(set_attr "type" "add")])
1747 (define_insn "add<mode>3_carry_in_m1"
1748 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1749 (plus:GPR (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
1752 (clobber (reg:GPR CA_REGNO))]
1755 [(set_attr "type" "add")])
1758 (define_expand "one_cmpl<mode>2"
1759 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1760 (not:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
1763 if (<MODE>mode == DImode && !TARGET_POWERPC64)
1765 rs6000_split_logical (operands, NOT, false, false, false);
1770 (define_insn "*one_cmpl<mode>2"
1771 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1772 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1776 (define_insn_and_split "*one_cmpl<mode>2_dot"
1777 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1778 (compare:CC (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1780 (clobber (match_scratch:GPR 0 "=r,r"))]
1781 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
1785 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
1787 (not:GPR (match_dup 1)))
1789 (compare:CC (match_dup 0)
1792 [(set_attr "type" "logical")
1793 (set_attr "dot" "yes")
1794 (set_attr "length" "4,8")])
1796 (define_insn_and_split "*one_cmpl<mode>2_dot2"
1797 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1798 (compare:CC (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1800 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1801 (not:GPR (match_dup 1)))]
1802 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
1806 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
1808 (not:GPR (match_dup 1)))
1810 (compare:CC (match_dup 0)
1813 [(set_attr "type" "logical")
1814 (set_attr "dot" "yes")
1815 (set_attr "length" "4,8")])
1818 (define_expand "sub<mode>3"
1819 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1820 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1821 (match_operand:SDI 2 "gpc_reg_operand" "")))]
1824 if (<MODE>mode == DImode && !TARGET_POWERPC64)
1826 rtx lo0 = gen_lowpart (SImode, operands[0]);
1827 rtx lo1 = gen_lowpart (SImode, operands[1]);
1828 rtx lo2 = gen_lowpart (SImode, operands[2]);
1829 rtx hi0 = gen_highpart (SImode, operands[0]);
1830 rtx hi1 = gen_highpart_mode (SImode, DImode, operands[1]);
1831 rtx hi2 = gen_highpart (SImode, operands[2]);
1833 if (!reg_or_short_operand (lo1, SImode))
1834 lo1 = force_reg (SImode, lo1);
1835 if (!adde_operand (hi1, SImode))
1836 hi1 = force_reg (SImode, hi1);
1838 emit_insn (gen_subfsi3_carry (lo0, lo2, lo1));
1839 emit_insn (gen_subfsi3_carry_in (hi0, hi2, hi1));
1843 if (short_cint_operand (operands[1], <MODE>mode))
1845 emit_insn (gen_subf<mode>3_imm (operands[0], operands[2], operands[1]));
1850 (define_insn "*subf<mode>3"
1851 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1852 (minus:GPR (match_operand:GPR 2 "gpc_reg_operand" "r")
1853 (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1856 [(set_attr "type" "add")])
1858 (define_insn_and_split "*subf<mode>3_dot"
1859 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1860 (compare:CC (minus:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r")
1861 (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1863 (clobber (match_scratch:GPR 0 "=r,r"))]
1864 "<MODE>mode == Pmode"
1868 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
1870 (minus:GPR (match_dup 2)
1873 (compare:CC (match_dup 0)
1876 [(set_attr "type" "add")
1877 (set_attr "dot" "yes")
1878 (set_attr "length" "4,8")])
1880 (define_insn_and_split "*subf<mode>3_dot2"
1881 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1882 (compare:CC (minus:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r")
1883 (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1885 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1886 (minus:GPR (match_dup 2)
1888 "<MODE>mode == Pmode"
1892 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
1894 (minus:GPR (match_dup 2)
1897 (compare:CC (match_dup 0)
1900 [(set_attr "type" "add")
1901 (set_attr "dot" "yes")
1902 (set_attr "length" "4,8")])
1904 (define_insn "subf<mode>3_imm"
1905 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1906 (minus:GPR (match_operand:GPR 2 "short_cint_operand" "I")
1907 (match_operand:GPR 1 "gpc_reg_operand" "r")))
1908 (clobber (reg:GPR CA_REGNO))]
1911 [(set_attr "type" "add")])
1914 (define_insn "subf<mode>3_carry"
1915 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
1916 (minus:P (match_operand:P 2 "reg_or_short_operand" "rI")
1917 (match_operand:P 1 "gpc_reg_operand" "r")))
1918 (set (reg:P CA_REGNO)
1919 (leu:P (match_dup 1)
1923 [(set_attr "type" "add")])
1925 (define_insn "*subf<mode>3_imm_carry_0"
1926 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
1927 (neg:P (match_operand:P 1 "gpc_reg_operand" "r")))
1928 (set (reg:P CA_REGNO)
1933 [(set_attr "type" "add")])
1935 (define_insn "*subf<mode>3_imm_carry_m1"
1936 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
1937 (not:P (match_operand:P 1 "gpc_reg_operand" "r")))
1938 (set (reg:P CA_REGNO)
1942 [(set_attr "type" "add")])
1945 (define_expand "subf<mode>3_carry_in"
1947 (set (match_operand:GPR 0 "gpc_reg_operand")
1948 (plus:GPR (plus:GPR (not:GPR (match_operand:GPR 1 "gpc_reg_operand"))
1950 (match_operand:GPR 2 "adde_operand")))
1951 (clobber (reg:GPR CA_REGNO))])]
1954 if (operands[2] == const0_rtx)
1956 emit_insn (gen_subf<mode>3_carry_in_0 (operands[0], operands[1]));
1959 if (operands[2] == constm1_rtx)
1961 emit_insn (gen_subf<mode>3_carry_in_m1 (operands[0], operands[1]));
1966 (define_insn "*subf<mode>3_carry_in_internal"
1967 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1968 (plus:GPR (plus:GPR (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r"))
1970 (match_operand:GPR 2 "gpc_reg_operand" "r")))
1971 (clobber (reg:GPR CA_REGNO))]
1974 [(set_attr "type" "add")])
1976 (define_insn "subf<mode>3_carry_in_0"
1977 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1978 (plus:GPR (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r"))
1979 (reg:GPR CA_REGNO)))
1980 (clobber (reg:GPR CA_REGNO))]
1983 [(set_attr "type" "add")])
1985 (define_insn "subf<mode>3_carry_in_m1"
1986 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1987 (plus:GPR (minus:GPR (reg:GPR CA_REGNO)
1988 (match_operand:GPR 1 "gpc_reg_operand" "r"))
1990 (clobber (reg:GPR CA_REGNO))]
1993 [(set_attr "type" "add")])
1995 (define_insn "subf<mode>3_carry_in_xx"
1996 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1997 (plus:GPR (reg:GPR CA_REGNO)
1999 (clobber (reg:GPR CA_REGNO))]
2002 [(set_attr "type" "add")])
2005 (define_insn "neg<mode>2"
2006 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2007 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2010 [(set_attr "type" "add")])
2012 (define_insn_and_split "*neg<mode>2_dot"
2013 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2014 (compare:CC (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
2016 (clobber (match_scratch:GPR 0 "=r,r"))]
2017 "<MODE>mode == Pmode"
2021 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
2023 (neg:GPR (match_dup 1)))
2025 (compare:CC (match_dup 0)
2028 [(set_attr "type" "add")
2029 (set_attr "dot" "yes")
2030 (set_attr "length" "4,8")])
2032 (define_insn_and_split "*neg<mode>2_dot2"
2033 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2034 (compare:CC (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
2036 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2037 (neg:GPR (match_dup 1)))]
2038 "<MODE>mode == Pmode"
2042 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
2044 (neg:GPR (match_dup 1)))
2046 (compare:CC (match_dup 0)
2049 [(set_attr "type" "add")
2050 (set_attr "dot" "yes")
2051 (set_attr "length" "4,8")])
2054 (define_insn "clz<mode>2"
2055 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2056 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2059 [(set_attr "type" "cntlz")])
2061 (define_expand "ctz<mode>2"
2063 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
2065 (and:GPR (match_dup 1)
2068 (clz:GPR (match_dup 3)))
2069 (parallel [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2070 (minus:GPR (match_dup 5)
2072 (clobber (reg:GPR CA_REGNO))])]
2075 operands[2] = gen_reg_rtx (<MODE>mode);
2076 operands[3] = gen_reg_rtx (<MODE>mode);
2077 operands[4] = gen_reg_rtx (<MODE>mode);
2078 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
2081 (define_expand "ffs<mode>2"
2083 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
2085 (and:GPR (match_dup 1)
2088 (clz:GPR (match_dup 3)))
2089 (parallel [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2090 (minus:GPR (match_dup 5)
2092 (clobber (reg:GPR CA_REGNO))])]
2095 operands[2] = gen_reg_rtx (<MODE>mode);
2096 operands[3] = gen_reg_rtx (<MODE>mode);
2097 operands[4] = gen_reg_rtx (<MODE>mode);
2098 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
2102 (define_expand "popcount<mode>2"
2103 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2104 (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
2105 "TARGET_POPCNTB || TARGET_POPCNTD"
2107 rs6000_emit_popcount (operands[0], operands[1]);
2111 (define_insn "popcntb<mode>2"
2112 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2113 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
2117 [(set_attr "type" "popcnt")])
2119 (define_insn "popcntd<mode>2"
2120 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2121 (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
2124 [(set_attr "type" "popcnt")])
2127 (define_expand "parity<mode>2"
2128 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2129 (parity:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
2132 rs6000_emit_parity (operands[0], operands[1]);
2136 (define_insn "parity<mode>2_cmpb"
2137 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2138 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")] UNSPEC_PARITY))]
2139 "TARGET_CMPB && TARGET_POPCNTB"
2141 [(set_attr "type" "popcnt")])
2144 ;; Since the hardware zeros the upper part of the register, save generating the
2145 ;; AND immediate if we are converting to unsigned
2146 (define_insn "*bswaphi2_extenddi"
2147 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
2149 (bswap:HI (match_operand:HI 1 "memory_operand" "Z"))))]
2152 [(set_attr "length" "4")
2153 (set_attr "type" "load")])
2155 (define_insn "*bswaphi2_extendsi"
2156 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2158 (bswap:HI (match_operand:HI 1 "memory_operand" "Z"))))]
2161 [(set_attr "length" "4")
2162 (set_attr "type" "load")])
2164 (define_expand "bswaphi2"
2165 [(parallel [(set (match_operand:HI 0 "reg_or_mem_operand" "")
2167 (match_operand:HI 1 "reg_or_mem_operand" "")))
2168 (clobber (match_scratch:SI 2 ""))])]
2171 if (!REG_P (operands[0]) && !REG_P (operands[1]))
2172 operands[1] = force_reg (HImode, operands[1]);
2175 (define_insn "bswaphi2_internal"
2176 [(set (match_operand:HI 0 "reg_or_mem_operand" "=r,Z,&r")
2178 (match_operand:HI 1 "reg_or_mem_operand" "Z,r,r")))
2179 (clobber (match_scratch:SI 2 "=X,X,&r"))]
2185 [(set_attr "length" "4,4,12")
2186 (set_attr "type" "load,store,*")])
2188 ;; We are always BITS_BIG_ENDIAN, so the (const_int 16) below is
2189 ;; correct for -mlittle as well as -mbig.
2191 [(set (match_operand:HI 0 "gpc_reg_operand" "")
2192 (bswap:HI (match_operand:HI 1 "gpc_reg_operand" "")))
2193 (clobber (match_operand:SI 2 "gpc_reg_operand" ""))]
2196 (zero_extract:SI (match_dup 4)
2200 (and:SI (ashift:SI (match_dup 4)
2202 (const_int 65280))) ;; 0xff00
2204 (ior:SI (match_dup 3)
2208 operands[3] = simplify_gen_subreg (SImode, operands[0], HImode, 0);
2209 operands[4] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
2212 (define_insn "*bswapsi2_extenddi"
2213 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
2215 (bswap:SI (match_operand:SI 1 "memory_operand" "Z"))))]
2218 [(set_attr "length" "4")
2219 (set_attr "type" "load")])
2221 (define_expand "bswapsi2"
2222 [(set (match_operand:SI 0 "reg_or_mem_operand" "")
2224 (match_operand:SI 1 "reg_or_mem_operand" "")))]
2227 if (!REG_P (operands[0]) && !REG_P (operands[1]))
2228 operands[1] = force_reg (SImode, operands[1]);
2231 (define_insn "*bswapsi2_internal"
2232 [(set (match_operand:SI 0 "reg_or_mem_operand" "=r,Z,&r")
2234 (match_operand:SI 1 "reg_or_mem_operand" "Z,r,r")))]
2240 [(set_attr "length" "4,4,12")
2241 (set_attr "type" "load,store,*")])
2243 ;; We are always BITS_BIG_ENDIAN, so the bit positions below in
2244 ;; zero_extract insns do not change for -mlittle.
2246 [(set (match_operand:SI 0 "gpc_reg_operand" "")
2247 (bswap:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2250 (rotate:SI (match_dup 1) (const_int 8)))
2251 (set (zero_extract:SI (match_dup 0)
2255 (set (zero_extract:SI (match_dup 0)
2258 (rotate:SI (match_dup 1)
2262 (define_expand "bswapdi2"
2263 [(parallel [(set (match_operand:DI 0 "reg_or_mem_operand" "")
2265 (match_operand:DI 1 "reg_or_mem_operand" "")))
2266 (clobber (match_scratch:DI 2 ""))
2267 (clobber (match_scratch:DI 3 ""))
2268 (clobber (match_scratch:DI 4 ""))])]
2271 if (!REG_P (operands[0]) && !REG_P (operands[1]))
2272 operands[1] = force_reg (DImode, operands[1]);
2274 if (!TARGET_POWERPC64)
2276 /* 32-bit mode needs fewer scratch registers, but 32-bit addressing mode
2277 that uses 64-bit registers needs the same scratch registers as 64-bit
2279 emit_insn (gen_bswapdi2_32bit (operands[0], operands[1]));
2284 ;; Power7/cell has ldbrx/stdbrx, so use it directly
2285 (define_insn "*bswapdi2_ldbrx"
2286 [(set (match_operand:DI 0 "reg_or_mem_operand" "=&r,Z,??&r")
2287 (bswap:DI (match_operand:DI 1 "reg_or_mem_operand" "Z,r,r")))
2288 (clobber (match_scratch:DI 2 "=X,X,&r"))
2289 (clobber (match_scratch:DI 3 "=X,X,&r"))
2290 (clobber (match_scratch:DI 4 "=X,X,&r"))]
2291 "TARGET_POWERPC64 && TARGET_LDBRX
2292 && (REG_P (operands[0]) || REG_P (operands[1]))"
2297 [(set_attr "length" "4,4,36")
2298 (set_attr "type" "load,store,*")])
2300 ;; Non-power7/cell, fall back to use lwbrx/stwbrx
2301 (define_insn "*bswapdi2_64bit"
2302 [(set (match_operand:DI 0 "reg_or_mem_operand" "=&r,Z,&r")
2303 (bswap:DI (match_operand:DI 1 "reg_or_mem_operand" "Z,r,r")))
2304 (clobber (match_scratch:DI 2 "=&b,&b,&r"))
2305 (clobber (match_scratch:DI 3 "=&r,&r,&r"))
2306 (clobber (match_scratch:DI 4 "=&r,X,&r"))]
2307 "TARGET_POWERPC64 && !TARGET_LDBRX
2308 && (REG_P (operands[0]) || REG_P (operands[1]))
2309 && !(MEM_P (operands[0]) && MEM_VOLATILE_P (operands[0]))
2310 && !(MEM_P (operands[1]) && MEM_VOLATILE_P (operands[1]))"
2312 [(set_attr "length" "16,12,36")])
2315 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2316 (bswap:DI (match_operand:DI 1 "indexed_or_indirect_operand" "")))
2317 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
2318 (clobber (match_operand:DI 3 "gpc_reg_operand" ""))
2319 (clobber (match_operand:DI 4 "gpc_reg_operand" ""))]
2320 "TARGET_POWERPC64 && !TARGET_LDBRX && reload_completed"
2324 rtx dest = operands[0];
2325 rtx src = operands[1];
2326 rtx op2 = operands[2];
2327 rtx op3 = operands[3];
2328 rtx op4 = operands[4];
2329 rtx op3_32 = simplify_gen_subreg (SImode, op3, DImode,
2330 BYTES_BIG_ENDIAN ? 4 : 0);
2331 rtx op4_32 = simplify_gen_subreg (SImode, op4, DImode,
2332 BYTES_BIG_ENDIAN ? 4 : 0);
2338 addr1 = XEXP (src, 0);
2339 if (GET_CODE (addr1) == PLUS)
2341 emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2342 if (TARGET_AVOID_XFORM)
2344 emit_insn (gen_add3_insn (op2, XEXP (addr1, 1), op2));
2348 addr2 = gen_rtx_PLUS (Pmode, op2, XEXP (addr1, 1));
2350 else if (TARGET_AVOID_XFORM)
2352 emit_insn (gen_add3_insn (op2, addr1, GEN_INT (4)));
2357 emit_move_insn (op2, GEN_INT (4));
2358 addr2 = gen_rtx_PLUS (Pmode, op2, addr1);
2361 if (BYTES_BIG_ENDIAN)
2363 word_high = change_address (src, SImode, addr1);
2364 word_low = change_address (src, SImode, addr2);
2368 word_high = change_address (src, SImode, addr2);
2369 word_low = change_address (src, SImode, addr1);
2372 emit_insn (gen_bswapsi2 (op3_32, word_low));
2373 emit_insn (gen_bswapsi2 (op4_32, word_high));
2374 emit_insn (gen_ashldi3 (dest, op3, GEN_INT (32)));
2375 emit_insn (gen_iordi3 (dest, dest, op4));
2380 [(set (match_operand:DI 0 "indexed_or_indirect_operand" "")
2381 (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2382 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
2383 (clobber (match_operand:DI 3 "gpc_reg_operand" ""))
2384 (clobber (match_operand:DI 4 "" ""))]
2385 "TARGET_POWERPC64 && !TARGET_LDBRX && reload_completed"
2389 rtx dest = operands[0];
2390 rtx src = operands[1];
2391 rtx op2 = operands[2];
2392 rtx op3 = operands[3];
2393 rtx src_si = simplify_gen_subreg (SImode, src, DImode,
2394 BYTES_BIG_ENDIAN ? 4 : 0);
2395 rtx op3_si = simplify_gen_subreg (SImode, op3, DImode,
2396 BYTES_BIG_ENDIAN ? 4 : 0);
2402 addr1 = XEXP (dest, 0);
2403 if (GET_CODE (addr1) == PLUS)
2405 emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2406 if (TARGET_AVOID_XFORM)
2408 emit_insn (gen_add3_insn (op2, XEXP (addr1, 1), op2));
2412 addr2 = gen_rtx_PLUS (Pmode, op2, XEXP (addr1, 1));
2414 else if (TARGET_AVOID_XFORM)
2416 emit_insn (gen_add3_insn (op2, addr1, GEN_INT (4)));
2421 emit_move_insn (op2, GEN_INT (4));
2422 addr2 = gen_rtx_PLUS (Pmode, op2, addr1);
2425 emit_insn (gen_lshrdi3 (op3, src, GEN_INT (32)));
2426 if (BYTES_BIG_ENDIAN)
2428 word_high = change_address (dest, SImode, addr1);
2429 word_low = change_address (dest, SImode, addr2);
2433 word_high = change_address (dest, SImode, addr2);
2434 word_low = change_address (dest, SImode, addr1);
2436 emit_insn (gen_bswapsi2 (word_high, src_si));
2437 emit_insn (gen_bswapsi2 (word_low, op3_si));
2442 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2443 (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2444 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
2445 (clobber (match_operand:DI 3 "gpc_reg_operand" ""))
2446 (clobber (match_operand:DI 4 "" ""))]
2447 "TARGET_POWERPC64 && reload_completed"
2451 rtx dest = operands[0];
2452 rtx src = operands[1];
2453 rtx op2 = operands[2];
2454 rtx op3 = operands[3];
2455 int lo_off = BYTES_BIG_ENDIAN ? 4 : 0;
2456 rtx dest_si = simplify_gen_subreg (SImode, dest, DImode, lo_off);
2457 rtx src_si = simplify_gen_subreg (SImode, src, DImode, lo_off);
2458 rtx op2_si = simplify_gen_subreg (SImode, op2, DImode, lo_off);
2459 rtx op3_si = simplify_gen_subreg (SImode, op3, DImode, lo_off);
2461 emit_insn (gen_lshrdi3 (op2, src, GEN_INT (32)));
2462 emit_insn (gen_bswapsi2 (dest_si, src_si));
2463 emit_insn (gen_bswapsi2 (op3_si, op2_si));
2464 emit_insn (gen_ashldi3 (dest, dest, GEN_INT (32)));
2465 emit_insn (gen_iordi3 (dest, dest, op3));
2469 (define_insn "bswapdi2_32bit"
2470 [(set (match_operand:DI 0 "reg_or_mem_operand" "=&r,Z,&r")
2471 (bswap:DI (match_operand:DI 1 "reg_or_mem_operand" "Z,r,r")))
2472 (clobber (match_scratch:SI 2 "=&b,&b,X"))]
2473 "!TARGET_POWERPC64 && (REG_P (operands[0]) || REG_P (operands[1]))"
2475 [(set_attr "length" "16,12,36")])
2478 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2479 (bswap:DI (match_operand:DI 1 "indexed_or_indirect_operand" "")))
2480 (clobber (match_operand:SI 2 "gpc_reg_operand" ""))]
2481 "!TARGET_POWERPC64 && reload_completed"
2485 rtx dest = operands[0];
2486 rtx src = operands[1];
2487 rtx op2 = operands[2];
2488 rtx dest1 = simplify_gen_subreg (SImode, dest, DImode, 0);
2489 rtx dest2 = simplify_gen_subreg (SImode, dest, DImode, 4);
2495 addr1 = XEXP (src, 0);
2496 if (GET_CODE (addr1) == PLUS)
2498 emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2499 if (TARGET_AVOID_XFORM)
2501 emit_insn (gen_add3_insn (op2, XEXP (addr1, 1), op2));
2505 addr2 = gen_rtx_PLUS (SImode, op2, XEXP (addr1, 1));
2507 else if (TARGET_AVOID_XFORM)
2509 emit_insn (gen_add3_insn (op2, addr1, GEN_INT (4)));
2514 emit_move_insn (op2, GEN_INT (4));
2515 addr2 = gen_rtx_PLUS (SImode, op2, addr1);
2518 word1 = change_address (src, SImode, addr1);
2519 word2 = change_address (src, SImode, addr2);
2521 emit_insn (gen_bswapsi2 (dest2, word1));
2522 emit_insn (gen_bswapsi2 (dest1, word2));
2527 [(set (match_operand:DI 0 "indexed_or_indirect_operand" "")
2528 (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2529 (clobber (match_operand:SI 2 "gpc_reg_operand" ""))]
2530 "!TARGET_POWERPC64 && reload_completed"
2534 rtx dest = operands[0];
2535 rtx src = operands[1];
2536 rtx op2 = operands[2];
2537 rtx src1 = simplify_gen_subreg (SImode, src, DImode, 0);
2538 rtx src2 = simplify_gen_subreg (SImode, src, DImode, 4);
2544 addr1 = XEXP (dest, 0);
2545 if (GET_CODE (addr1) == PLUS)
2547 emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2548 if (TARGET_AVOID_XFORM)
2550 emit_insn (gen_add3_insn (op2, XEXP (addr1, 1), op2));
2554 addr2 = gen_rtx_PLUS (SImode, op2, XEXP (addr1, 1));
2556 else if (TARGET_AVOID_XFORM)
2558 emit_insn (gen_add3_insn (op2, addr1, GEN_INT (4)));
2563 emit_move_insn (op2, GEN_INT (4));
2564 addr2 = gen_rtx_PLUS (SImode, op2, addr1);
2567 word1 = change_address (dest, SImode, addr1);
2568 word2 = change_address (dest, SImode, addr2);
2570 emit_insn (gen_bswapsi2 (word2, src1));
2571 emit_insn (gen_bswapsi2 (word1, src2));
2576 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2577 (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2578 (clobber (match_operand:SI 2 "" ""))]
2579 "!TARGET_POWERPC64 && reload_completed"
2583 rtx dest = operands[0];
2584 rtx src = operands[1];
2585 rtx src1 = simplify_gen_subreg (SImode, src, DImode, 0);
2586 rtx src2 = simplify_gen_subreg (SImode, src, DImode, 4);
2587 rtx dest1 = simplify_gen_subreg (SImode, dest, DImode, 0);
2588 rtx dest2 = simplify_gen_subreg (SImode, dest, DImode, 4);
2590 emit_insn (gen_bswapsi2 (dest1, src2));
2591 emit_insn (gen_bswapsi2 (dest2, src1));
2596 (define_insn "mul<mode>3"
2597 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2598 (mult:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2599 (match_operand:GPR 2 "reg_or_short_operand" "r,I")))]
2604 [(set_attr "type" "mul")
2606 (cond [(match_operand:GPR 2 "s8bit_cint_operand" "")
2608 (match_operand:GPR 2 "short_cint_operand" "")
2609 (const_string "16")]
2610 (const_string "<bits>")))])
2612 (define_insn_and_split "*mul<mode>3_dot"
2613 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2614 (compare:CC (mult:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
2615 (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
2617 (clobber (match_scratch:GPR 0 "=r,r"))]
2618 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
2622 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2624 (mult:GPR (match_dup 1)
2627 (compare:CC (match_dup 0)
2630 [(set_attr "type" "mul")
2631 (set_attr "size" "<bits>")
2632 (set_attr "dot" "yes")
2633 (set_attr "length" "4,8")])
2635 (define_insn_and_split "*mul<mode>3_dot2"
2636 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2637 (compare:CC (mult:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
2638 (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
2640 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2641 (mult:GPR (match_dup 1)
2643 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
2647 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2649 (mult:GPR (match_dup 1)
2652 (compare:CC (match_dup 0)
2655 [(set_attr "type" "mul")
2656 (set_attr "size" "<bits>")
2657 (set_attr "dot" "yes")
2658 (set_attr "length" "4,8")])
2661 (define_expand "<su>mul<mode>3_highpart"
2662 [(set (match_operand:GPR 0 "gpc_reg_operand")
2664 (mult:<DMODE> (any_extend:<DMODE>
2665 (match_operand:GPR 1 "gpc_reg_operand"))
2667 (match_operand:GPR 2 "gpc_reg_operand")))
2671 if (<MODE>mode == SImode && TARGET_POWERPC64)
2673 emit_insn (gen_<su>mulsi3_highpart_64 (operands[0], operands[1],
2678 if (!WORDS_BIG_ENDIAN)
2680 emit_insn (gen_<su>mul<mode>3_highpart_le (operands[0], operands[1],
2686 (define_insn "*<su>mul<mode>3_highpart"
2687 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2689 (mult:<DMODE> (any_extend:<DMODE>
2690 (match_operand:GPR 1 "gpc_reg_operand" "r"))
2692 (match_operand:GPR 2 "gpc_reg_operand" "r")))
2694 "WORDS_BIG_ENDIAN && !(<MODE>mode == SImode && TARGET_POWERPC64)"
2695 "mulh<wd><u> %0,%1,%2"
2696 [(set_attr "type" "mul")
2697 (set_attr "size" "<bits>")])
2699 (define_insn "<su>mulsi3_highpart_le"
2700 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2702 (mult:DI (any_extend:DI
2703 (match_operand:SI 1 "gpc_reg_operand" "r"))
2705 (match_operand:SI 2 "gpc_reg_operand" "r")))
2707 "!WORDS_BIG_ENDIAN && !TARGET_POWERPC64"
2709 [(set_attr "type" "mul")])
2711 (define_insn "<su>muldi3_highpart_le"
2712 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
2714 (mult:TI (any_extend:TI
2715 (match_operand:DI 1 "gpc_reg_operand" "r"))
2717 (match_operand:DI 2 "gpc_reg_operand" "r")))
2719 "!WORDS_BIG_ENDIAN && TARGET_POWERPC64"
2721 [(set_attr "type" "mul")
2722 (set_attr "size" "64")])
2724 (define_insn "<su>mulsi3_highpart_64"
2725 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2728 (mult:DI (any_extend:DI
2729 (match_operand:SI 1 "gpc_reg_operand" "r"))
2731 (match_operand:SI 2 "gpc_reg_operand" "r")))
2735 [(set_attr "type" "mul")])
2737 (define_expand "<u>mul<mode><dmode>3"
2738 [(set (match_operand:<DMODE> 0 "gpc_reg_operand")
2739 (mult:<DMODE> (any_extend:<DMODE>
2740 (match_operand:GPR 1 "gpc_reg_operand"))
2742 (match_operand:GPR 2 "gpc_reg_operand"))))]
2743 "!(<MODE>mode == SImode && TARGET_POWERPC64)"
2745 rtx l = gen_reg_rtx (<MODE>mode);
2746 rtx h = gen_reg_rtx (<MODE>mode);
2747 emit_insn (gen_mul<mode>3 (l, operands[1], operands[2]));
2748 emit_insn (gen_<su>mul<mode>3_highpart (h, operands[1], operands[2]));
2749 emit_move_insn (gen_lowpart (<MODE>mode, operands[0]), l);
2750 emit_move_insn (gen_highpart (<MODE>mode, operands[0]), h);
2755 (define_insn "udiv<mode>3"
2756 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2757 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2758 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2761 [(set_attr "type" "div")
2762 (set_attr "size" "<bits>")])
2765 ;; For powers of two we can do sra[wd]i/addze for divide and then adjust for
2766 ;; modulus. If it isn't a power of two, force operands into register and do
2768 (define_expand "div<mode>3"
2769 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2770 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2771 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2774 if (CONST_INT_P (operands[2])
2775 && INTVAL (operands[2]) > 0
2776 && exact_log2 (INTVAL (operands[2])) >= 0)
2778 emit_insn (gen_div<mode>3_sra (operands[0], operands[1], operands[2]));
2782 operands[2] = force_reg (<MODE>mode, operands[2]);
2785 (define_insn "*div<mode>3"
2786 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2787 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2788 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2791 [(set_attr "type" "div")
2792 (set_attr "size" "<bits>")])
2794 (define_insn "div<mode>3_sra"
2795 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2796 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2797 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))
2798 (clobber (reg:GPR CA_REGNO))]
2800 "sra<wd>i %0,%1,%p2\;addze %0,%0"
2801 [(set_attr "type" "two")
2802 (set_attr "length" "8")])
2804 (define_insn_and_split "*div<mode>3_sra_dot"
2805 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2806 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
2807 (match_operand:GPR 2 "exact_log2_cint_operand" "N,N"))
2809 (clobber (match_scratch:GPR 0 "=r,r"))
2810 (clobber (reg:GPR CA_REGNO))]
2811 "<MODE>mode == Pmode"
2813 sra<wd>i %0,%1,%p2\;addze. %0,%0
2815 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2816 [(parallel [(set (match_dup 0)
2817 (div:GPR (match_dup 1)
2819 (clobber (reg:GPR CA_REGNO))])
2821 (compare:CC (match_dup 0)
2824 [(set_attr "type" "two")
2825 (set_attr "length" "8,12")
2826 (set_attr "cell_micro" "not")])
2828 (define_insn_and_split "*div<mode>3_sra_dot2"
2829 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2830 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
2831 (match_operand:GPR 2 "exact_log2_cint_operand" "N,N"))
2833 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2834 (div:GPR (match_dup 1)
2836 (clobber (reg:GPR CA_REGNO))]
2837 "<MODE>mode == Pmode"
2839 sra<wd>i %0,%1,%p2\;addze. %0,%0
2841 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2842 [(parallel [(set (match_dup 0)
2843 (div:GPR (match_dup 1)
2845 (clobber (reg:GPR CA_REGNO))])
2847 (compare:CC (match_dup 0)
2850 [(set_attr "type" "two")
2851 (set_attr "length" "8,12")
2852 (set_attr "cell_micro" "not")])
2854 (define_expand "mod<mode>3"
2855 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2856 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2857 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
2864 if (GET_CODE (operands[2]) != CONST_INT
2865 || INTVAL (operands[2]) <= 0
2866 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2869 temp1 = gen_reg_rtx (<MODE>mode);
2870 temp2 = gen_reg_rtx (<MODE>mode);
2872 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2873 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2874 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
2878 ;; Logical instructions
2879 ;; The logical instructions are mostly combined by using match_operator,
2880 ;; but the plain AND insns are somewhat different because there is no
2881 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2882 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2884 (define_expand "and<mode>3"
2885 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2886 (and:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
2887 (match_operand:SDI 2 "reg_or_cint_operand" "")))]
2890 if (<MODE>mode == DImode && !TARGET_POWERPC64)
2892 rs6000_split_logical (operands, AND, false, false, false);
2896 if (logical_const_operand (operands[2], <MODE>mode)
2897 && !any_mask_operand (operands[2], <MODE>mode))
2899 if (rs6000_gen_cell_microcode)
2901 emit_insn (gen_and<mode>3_imm (operands[0], operands[1], operands[2]));
2905 operands[2] = force_reg (<MODE>mode, operands[2]);
2908 if ((<MODE>mode == DImode && !and64_2_operand (operands[2], <MODE>mode))
2909 || (<MODE>mode != DImode && !and_operand (operands[2], <MODE>mode)))
2910 operands[2] = force_reg (<MODE>mode, operands[2]);
2914 (define_insn "and<mode>3_imm"
2915 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2916 (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r")
2917 (match_operand:GPR 2 "logical_const_operand" "n")))
2918 (clobber (match_scratch:CC 3 "=x"))]
2919 "rs6000_gen_cell_microcode
2920 && !any_mask_operand (operands[2], <MODE>mode)"
2921 "andi%e2. %0,%1,%u2"
2922 [(set_attr "type" "logical")
2923 (set_attr "dot" "yes")])
2925 (define_insn_and_split "*and<mode>3_imm_dot"
2926 [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2927 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2928 (match_operand:GPR 2 "logical_const_operand" "n,n"))
2930 (clobber (match_scratch:GPR 0 "=r,r"))
2931 (clobber (match_scratch:CC 4 "=X,x"))]
2932 "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2933 && rs6000_gen_cell_microcode
2934 && !any_mask_operand (operands[2], <MODE>mode)"
2938 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2939 [(parallel [(set (match_dup 0)
2940 (and:GPR (match_dup 1)
2942 (clobber (match_dup 4))])
2944 (compare:CC (match_dup 0)
2947 [(set_attr "type" "logical")
2948 (set_attr "dot" "yes")
2949 (set_attr "length" "4,8")])
2951 (define_insn_and_split "*and<mode>3_imm_dot2"
2952 [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2953 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2954 (match_operand:GPR 2 "logical_const_operand" "n,n"))
2956 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2957 (and:GPR (match_dup 1)
2959 (clobber (match_scratch:CC 4 "=X,x"))]
2960 "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2961 && rs6000_gen_cell_microcode
2962 && !any_mask_operand (operands[2], <MODE>mode)"
2966 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2967 [(parallel [(set (match_dup 0)
2968 (and:GPR (match_dup 1)
2970 (clobber (match_dup 4))])
2972 (compare:CC (match_dup 0)
2975 [(set_attr "type" "logical")
2976 (set_attr "dot" "yes")
2977 (set_attr "length" "4,8")])
2979 (define_insn_and_split "*and<mode>3_imm_mask_dot"
2980 [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2981 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2982 (match_operand:GPR 2 "logical_const_operand" "n,n"))
2984 (clobber (match_scratch:GPR 0 "=r,r"))]
2985 "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2986 && rs6000_gen_cell_microcode
2987 && any_mask_operand (operands[2], <MODE>mode)"
2991 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2993 (and:GPR (match_dup 1)
2996 (compare:CC (match_dup 0)
2999 [(set_attr "type" "logical")
3000 (set_attr "dot" "yes")
3001 (set_attr "length" "4,8")])
3003 (define_insn_and_split "*and<mode>3_imm_mask_dot2"
3004 [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
3005 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
3006 (match_operand:GPR 2 "logical_const_operand" "n,n"))
3008 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
3009 (and:GPR (match_dup 1)
3011 "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
3012 && rs6000_gen_cell_microcode
3013 && any_mask_operand (operands[2], <MODE>mode)"
3017 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
3019 (and:GPR (match_dup 1)
3022 (compare:CC (match_dup 0)
3025 [(set_attr "type" "logical")
3026 (set_attr "dot" "yes")
3027 (set_attr "length" "4,8")])
3030 (define_insn "*and<mode>3_mask"
3031 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
3032 (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
3033 (match_operand:GPR 2 "any_mask_operand" "S,T")))]
3036 rldic%B2 %0,%1,0,%S2
3037 rlwinm %0,%1,0,%m2,%M2"
3038 [(set_attr "type" "shift")])
3040 (define_insn_and_split "*and<mode>3_mask_dot"
3041 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3042 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r,r,r")
3043 (match_operand:GPR 2 "any_mask_operand" "S,T,S,T"))
3045 (clobber (match_scratch:GPR 0 "=r,r,r,r"))]
3046 "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
3047 && rs6000_gen_cell_microcode
3048 && !logical_const_operand (operands[2], <MODE>mode)"
3050 rldic%B2. %0,%1,0,%S2
3051 rlwinm. %0,%1,0,%m2,%M2
3054 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
3056 (and:GPR (match_dup 1)
3059 (compare:CC (match_dup 0)
3062 [(set_attr "type" "shift")
3063 (set_attr "dot" "yes")
3064 (set_attr "length" "4,4,8,8")])
3066 (define_insn_and_split "*and<mode>3_mask_dot2"
3067 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3068 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r,r,r")
3069 (match_operand:GPR 2 "any_mask_operand" "S,T,S,T"))
3071 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,r,r")
3072 (and:GPR (match_dup 1)
3074 "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
3075 && rs6000_gen_cell_microcode
3076 && !logical_const_operand (operands[2], <MODE>mode)"
3078 rldic%B2. %0,%1,0,%S2
3079 rlwinm. %0,%1,0,%m2,%M2
3082 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
3084 (and:GPR (match_dup 1)
3087 (compare:CC (match_dup 0)
3090 [(set_attr "type" "shift")
3091 (set_attr "dot" "yes")
3092 (set_attr "length" "4,4,8,8")])
3096 (define_insn "andsi3_internal0_nomc"
3097 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3098 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
3099 (match_operand:SI 2 "and_operand" "?r,T")))]
3100 "!rs6000_gen_cell_microcode"
3103 rlwinm %0,%1,0,%m2,%M2"
3104 [(set_attr "type" "logical,shift")])
3107 ;; Handle the PowerPC64 rlwinm corner case
3109 (define_insn_and_split "*andsi3_internal6"
3110 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3111 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3112 (match_operand:SI 2 "mask_operand_wrap" "i")))]
3117 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
3120 (rotate:SI (match_dup 0) (match_dup 5)))]
3123 int mb = extract_MB (operands[2]);
3124 int me = extract_ME (operands[2]);
3125 operands[3] = GEN_INT (me + 1);
3126 operands[5] = GEN_INT (32 - (me + 1));
3127 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
3129 [(set_attr "length" "8")])
3132 (define_expand "<code><mode>3"
3133 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
3134 (iorxor:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
3135 (match_operand:SDI 2 "reg_or_cint_operand" "")))]
3138 if (<MODE>mode == DImode && !TARGET_POWERPC64)
3140 rs6000_split_logical (operands, <CODE>, false, false, false);
3144 if (non_logical_cint_operand (operands[2], <MODE>mode))
3146 rtx tmp = ((!can_create_pseudo_p ()
3147 || rtx_equal_p (operands[0], operands[1]))
3148 ? operands[0] : gen_reg_rtx (<MODE>mode));
3150 HOST_WIDE_INT value = INTVAL (operands[2]);
3151 HOST_WIDE_INT lo = value & 0xffff;
3152 HOST_WIDE_INT hi = value - lo;
3154 emit_insn (gen_<code><mode>3 (tmp, operands[1], GEN_INT (hi)));
3155 emit_insn (gen_<code><mode>3 (operands[0], tmp, GEN_INT (lo)));
3159 if (!reg_or_logical_cint_operand (operands[2], <MODE>mode))
3160 operands[2] = force_reg (<MODE>mode, operands[2]);
3164 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
3165 (iorxor:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
3166 (match_operand:GPR 2 "non_logical_cint_operand" "")))]
3169 (iorxor:GPR (match_dup 1)
3172 (iorxor:GPR (match_dup 3)
3175 operands[3] = ((!can_create_pseudo_p ()
3176 || rtx_equal_p (operands[0], operands[1]))
3177 ? operands[0] : gen_reg_rtx (<MODE>mode));
3179 HOST_WIDE_INT value = INTVAL (operands[2]);
3180 HOST_WIDE_INT lo = value & 0xffff;
3181 HOST_WIDE_INT hi = value - lo;
3183 operands[4] = GEN_INT (hi);
3184 operands[5] = GEN_INT (lo);
3187 (define_insn "*bool<mode>3_imm"
3188 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3189 (match_operator:GPR 3 "boolean_or_operator"
3190 [(match_operand:GPR 1 "gpc_reg_operand" "%r")
3191 (match_operand:GPR 2 "logical_const_operand" "n")]))]
3194 [(set_attr "type" "logical")])
3196 (define_insn "*bool<mode>3"
3197 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3198 (match_operator:GPR 3 "boolean_operator"
3199 [(match_operand:GPR 1 "gpc_reg_operand" "r")
3200 (match_operand:GPR 2 "gpc_reg_operand" "r")]))]
3203 [(set_attr "type" "logical")])
3205 (define_insn_and_split "*bool<mode>3_dot"
3206 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3207 (compare:CC (match_operator:GPR 3 "boolean_operator"
3208 [(match_operand:GPR 1 "gpc_reg_operand" "r,r")
3209 (match_operand:GPR 2 "gpc_reg_operand" "r,r")])
3211 (clobber (match_scratch:GPR 0 "=r,r"))]
3212 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3216 "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
3220 (compare:CC (match_dup 0)
3223 [(set_attr "type" "logical")
3224 (set_attr "dot" "yes")
3225 (set_attr "length" "4,8")])
3227 (define_insn_and_split "*bool<mode>3_dot2"
3228 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3229 (compare:CC (match_operator:GPR 3 "boolean_operator"
3230 [(match_operand:GPR 1 "gpc_reg_operand" "r,r")
3231 (match_operand:GPR 2 "gpc_reg_operand" "r,r")])
3233 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
3235 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3239 "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
3243 (compare:CC (match_dup 0)
3246 [(set_attr "type" "logical")
3247 (set_attr "dot" "yes")
3248 (set_attr "length" "4,8")])
3251 (define_insn "*boolc<mode>3"
3252 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3253 (match_operator:GPR 3 "boolean_operator"
3254 [(not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r"))
3255 (match_operand:GPR 1 "gpc_reg_operand" "r")]))]
3258 [(set_attr "type" "logical")])
3260 (define_insn_and_split "*boolc<mode>3_dot"
3261 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3262 (compare:CC (match_operator:GPR 3 "boolean_operator"
3263 [(not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
3264 (match_operand:GPR 1 "gpc_reg_operand" "r,r")])
3266 (clobber (match_scratch:GPR 0 "=r,r"))]
3267 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3271 "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
3275 (compare:CC (match_dup 0)
3278 [(set_attr "type" "logical")
3279 (set_attr "dot" "yes")
3280 (set_attr "length" "4,8")])
3282 (define_insn_and_split "*boolc<mode>3_dot2"
3283 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3284 (compare:CC (match_operator:GPR 3 "boolean_operator"
3285 [(not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
3286 (match_operand:GPR 1 "gpc_reg_operand" "r,r")])
3288 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
3290 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3294 "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
3298 (compare:CC (match_dup 0)
3301 [(set_attr "type" "logical")
3302 (set_attr "dot" "yes")
3303 (set_attr "length" "4,8")])
3306 (define_insn "*boolcc<mode>3"
3307 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3308 (match_operator:GPR 3 "boolean_operator"
3309 [(not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r"))
3310 (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r"))]))]
3313 [(set_attr "type" "logical")])
3315 (define_insn_and_split "*boolcc<mode>3_dot"
3316 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3317 (compare:CC (match_operator:GPR 3 "boolean_operator"
3318 [(not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
3319 (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r"))])
3321 (clobber (match_scratch:GPR 0 "=r,r"))]
3322 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3326 "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
3330 (compare:CC (match_dup 0)
3333 [(set_attr "type" "logical")
3334 (set_attr "dot" "yes")
3335 (set_attr "length" "4,8")])
3337 (define_insn_and_split "*boolcc<mode>3_dot2"
3338 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3339 (compare:CC (match_operator:GPR 3 "boolean_operator"
3340 [(not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
3341 (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r"))])
3343 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
3345 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3349 "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
3353 (compare:CC (match_dup 0)
3356 [(set_attr "type" "logical")
3357 (set_attr "dot" "yes")
3358 (set_attr "length" "4,8")])
3361 ;; TODO: Should have dots of this as well.
3362 (define_insn "*eqv<mode>3"
3363 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3364 (not:GPR (xor:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
3365 (match_operand:GPR 2 "gpc_reg_operand" "r"))))]
3368 [(set_attr "type" "logical")])
3370 ;; Rotate and shift insns, in all their variants. These support shifts,
3371 ;; field inserts and extracts, and various combinations thereof.
3372 (define_expand "insv"
3373 [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
3374 (match_operand:SI 1 "const_int_operand" "")
3375 (match_operand:SI 2 "const_int_operand" ""))
3376 (match_operand 3 "gpc_reg_operand" ""))]
3380 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3381 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3382 compiler if the address of the structure is taken later. Likewise, do
3383 not handle invalid E500 subregs. */
3384 if (GET_CODE (operands[0]) == SUBREG
3385 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD
3386 || ((TARGET_E500_DOUBLE || TARGET_SPE)
3387 && invalid_e500_subreg (operands[0], GET_MODE (operands[0])))))
3390 if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
3391 emit_insn (gen_insvdi_internal (operands[0], operands[1], operands[2],
3394 emit_insn (gen_insvsi_internal (operands[0], operands[1], operands[2],
3399 (define_insn "insvsi_internal"
3400 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3401 (match_operand:SI 1 "const_int_operand" "i")
3402 (match_operand:SI 2 "const_int_operand" "i"))
3403 (match_operand:SI 3 "gpc_reg_operand" "r"))]
3407 int start = INTVAL (operands[2]) & 31;
3408 int size = INTVAL (operands[1]) & 31;
3410 operands[4] = GEN_INT (32 - start - size);
3411 operands[1] = GEN_INT (start + size - 1);
3412 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3414 [(set_attr "type" "insert")])
3416 (define_insn "*insvsi_internal1"
3417 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3418 (match_operand:SI 1 "const_int_operand" "i")
3419 (match_operand:SI 2 "const_int_operand" "i"))
3420 (rotate:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3421 (match_operand:SI 4 "const_int_operand" "i")))]
3422 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3425 int shift = INTVAL (operands[4]) & 31;
3426 int start = INTVAL (operands[2]) & 31;
3427 int size = INTVAL (operands[1]) & 31;
3429 operands[4] = GEN_INT (shift - start - size);
3430 operands[1] = GEN_INT (start + size - 1);
3431 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3433 [(set_attr "type" "insert")])
3435 (define_insn "*insvsi_internal2"
3436 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3437 (match_operand:SI 1 "const_int_operand" "i")
3438 (match_operand:SI 2 "const_int_operand" "i"))
3439 (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3440 (match_operand:SI 4 "const_int_operand" "i")))]
3441 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3444 int shift = INTVAL (operands[4]) & 31;
3445 int start = INTVAL (operands[2]) & 31;
3446 int size = INTVAL (operands[1]) & 31;
3448 operands[4] = GEN_INT (32 - shift - start - size);
3449 operands[1] = GEN_INT (start + size - 1);
3450 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3452 [(set_attr "type" "insert")])
3454 (define_insn "*insvsi_internal3"
3455 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3456 (match_operand:SI 1 "const_int_operand" "i")
3457 (match_operand:SI 2 "const_int_operand" "i"))
3458 (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3459 (match_operand:SI 4 "const_int_operand" "i")))]
3460 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3463 int shift = INTVAL (operands[4]) & 31;
3464 int start = INTVAL (operands[2]) & 31;
3465 int size = INTVAL (operands[1]) & 31;
3467 operands[4] = GEN_INT (32 - shift - start - size);
3468 operands[1] = GEN_INT (start + size - 1);
3469 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3471 [(set_attr "type" "insert")])
3473 (define_insn "*insvsi_internal4"
3474 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3475 (match_operand:SI 1 "const_int_operand" "i")
3476 (match_operand:SI 2 "const_int_operand" "i"))
3477 (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3478 (match_operand:SI 4 "const_int_operand" "i")
3479 (match_operand:SI 5 "const_int_operand" "i")))]
3480 "INTVAL (operands[4]) >= INTVAL (operands[1])"
3483 int extract_start = INTVAL (operands[5]) & 31;
3484 int extract_size = INTVAL (operands[4]) & 31;
3485 int insert_start = INTVAL (operands[2]) & 31;
3486 int insert_size = INTVAL (operands[1]) & 31;
3488 /* Align extract field with insert field */
3489 operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
3490 operands[1] = GEN_INT (insert_start + insert_size - 1);
3491 return \"rlwimi %0,%3,%h5,%h2,%h1\";
3493 [(set_attr "type" "insert")])
3495 ;; combine patterns for rlwimi
3496 (define_insn "*insvsi_internal5"
3497 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3498 (ior:SI (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3499 (match_operand:SI 1 "mask_operand" "i"))
3500 (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3501 (match_operand:SI 2 "const_int_operand" "i"))
3502 (match_operand:SI 5 "mask_operand" "i"))))]
3503 "INTVAL(operands[1]) == ~INTVAL(operands[5])"
3506 int me = extract_ME(operands[5]);
3507 int mb = extract_MB(operands[5]);
3508 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3509 operands[2] = GEN_INT(mb);
3510 operands[1] = GEN_INT(me);
3511 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3513 [(set_attr "type" "insert")])
3515 (define_insn "*insvsi_internal6"
3516 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3517 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3518 (match_operand:SI 2 "const_int_operand" "i"))
3519 (match_operand:SI 5 "mask_operand" "i"))
3520 (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3521 (match_operand:SI 1 "mask_operand" "i"))))]
3522 "INTVAL(operands[1]) == ~INTVAL(operands[5])"
3525 int me = extract_ME(operands[5]);
3526 int mb = extract_MB(operands[5]);
3527 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3528 operands[2] = GEN_INT(mb);
3529 operands[1] = GEN_INT(me);
3530 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3532 [(set_attr "type" "insert")])
3534 (define_insn "insvdi_internal"
3535 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3536 (match_operand:SI 1 "const_int_operand" "i")
3537 (match_operand:SI 2 "const_int_operand" "i"))
3538 (match_operand:DI 3 "gpc_reg_operand" "r"))]
3542 int start = INTVAL (operands[2]) & 63;
3543 int size = INTVAL (operands[1]) & 63;
3545 operands[1] = GEN_INT (64 - start - size);
3546 return \"rldimi %0,%3,%H1,%H2\";
3548 [(set_attr "type" "insert")
3549 (set_attr "size" "64")])
3551 (define_insn "*insvdi_internal2"
3552 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3553 (match_operand:SI 1 "const_int_operand" "i")
3554 (match_operand:SI 2 "const_int_operand" "i"))
3555 (ashiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3556 (match_operand:SI 4 "const_int_operand" "i")))]
3558 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3561 int shift = INTVAL (operands[4]) & 63;
3562 int start = (INTVAL (operands[2]) & 63) - 32;
3563 int size = INTVAL (operands[1]) & 63;
3565 operands[4] = GEN_INT (64 - shift - start - size);
3566 operands[2] = GEN_INT (start);
3567 operands[1] = GEN_INT (start + size - 1);
3568 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3571 (define_insn "*insvdi_internal3"
3572 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3573 (match_operand:SI 1 "const_int_operand" "i")
3574 (match_operand:SI 2 "const_int_operand" "i"))
3575 (lshiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3576 (match_operand:SI 4 "const_int_operand" "i")))]
3578 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3581 int shift = INTVAL (operands[4]) & 63;
3582 int start = (INTVAL (operands[2]) & 63) - 32;
3583 int size = INTVAL (operands[1]) & 63;
3585 operands[4] = GEN_INT (64 - shift - start - size);
3586 operands[2] = GEN_INT (start);
3587 operands[1] = GEN_INT (start + size - 1);
3588 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3591 (define_expand "extzv"
3592 [(set (match_operand 0 "gpc_reg_operand" "")
3593 (zero_extract (match_operand 1 "gpc_reg_operand" "")
3594 (match_operand:SI 2 "const_int_operand" "")
3595 (match_operand:SI 3 "const_int_operand" "")))]
3599 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3600 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3601 compiler if the address of the structure is taken later. */
3602 if (GET_CODE (operands[0]) == SUBREG
3603 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3606 if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3607 emit_insn (gen_extzvdi_internal (operands[0], operands[1], operands[2],
3610 emit_insn (gen_extzvsi_internal (operands[0], operands[1], operands[2],
3615 (define_insn "extzvsi_internal"
3616 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3617 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3618 (match_operand:SI 2 "const_int_operand" "i")
3619 (match_operand:SI 3 "const_int_operand" "i")))]
3623 int start = INTVAL (operands[3]) & 31;
3624 int size = INTVAL (operands[2]) & 31;
3626 if (start + size >= 32)
3627 operands[3] = const0_rtx;
3629 operands[3] = GEN_INT (start + size);
3630 return \"rlwinm %0,%1,%3,%s2,31\";
3632 [(set_attr "type" "shift")])
3634 (define_insn "*extzvsi_internal1"
3635 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3636 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3637 (match_operand:SI 2 "const_int_operand" "i,i")
3638 (match_operand:SI 3 "const_int_operand" "i,i"))
3640 (clobber (match_scratch:SI 4 "=r,r"))]
3644 int start = INTVAL (operands[3]) & 31;
3645 int size = INTVAL (operands[2]) & 31;
3647 /* Force split for non-cc0 compare. */
3648 if (which_alternative == 1)
3651 /* If the bit-field being tested fits in the upper or lower half of a
3652 word, it is possible to use andiu. or andil. to test it. This is
3653 useful because the condition register set-use delay is smaller for
3654 andi[ul]. than for rlinm. This doesn't work when the starting bit
3655 position is 0 because the LT and GT bits may be set wrong. */
3657 if ((start > 0 && start + size <= 16) || start >= 16)
3659 operands[3] = GEN_INT (((1 << (16 - (start & 15)))
3660 - (1 << (16 - (start & 15) - size))));
3662 return \"andis. %4,%1,%3\";
3664 return \"andi. %4,%1,%3\";
3667 if (start + size >= 32)
3668 operands[3] = const0_rtx;
3670 operands[3] = GEN_INT (start + size);
3671 return \"rlwinm. %4,%1,%3,%s2,31\";
3673 [(set_attr "type" "shift")
3674 (set_attr "dot" "yes")
3675 (set_attr "length" "4,8")])
3678 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3679 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3680 (match_operand:SI 2 "const_int_operand" "")
3681 (match_operand:SI 3 "const_int_operand" ""))
3683 (clobber (match_scratch:SI 4 ""))]
3686 (zero_extract:SI (match_dup 1) (match_dup 2)
3689 (compare:CC (match_dup 4)
3693 (define_insn "*extzvsi_internal2"
3694 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3695 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3696 (match_operand:SI 2 "const_int_operand" "i,i")
3697 (match_operand:SI 3 "const_int_operand" "i,i"))
3699 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3700 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3704 int start = INTVAL (operands[3]) & 31;
3705 int size = INTVAL (operands[2]) & 31;
3707 /* Force split for non-cc0 compare. */
3708 if (which_alternative == 1)
3711 /* Since we are using the output value, we can't ignore any need for
3712 a shift. The bit-field must end at the LSB. */
3713 if (start >= 16 && start + size == 32)
3715 operands[3] = GEN_INT ((1 << size) - 1);
3716 return \"andi. %0,%1,%3\";
3719 if (start + size >= 32)
3720 operands[3] = const0_rtx;
3722 operands[3] = GEN_INT (start + size);
3723 return \"rlwinm. %0,%1,%3,%s2,31\";
3725 [(set_attr "type" "shift")
3726 (set_attr "dot" "yes")
3727 (set_attr "length" "4,8")])
3730 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
3731 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3732 (match_operand:SI 2 "const_int_operand" "")
3733 (match_operand:SI 3 "const_int_operand" ""))
3735 (set (match_operand:SI 0 "gpc_reg_operand" "")
3736 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3739 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3741 (compare:CC (match_dup 0)
3745 (define_insn "extzvdi_internal"
3746 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3747 (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3748 (match_operand:SI 2 "const_int_operand" "i")
3749 (match_operand:SI 3 "const_int_operand" "i")))]
3753 int start = INTVAL (operands[3]) & 63;
3754 int size = INTVAL (operands[2]) & 63;
3756 if (start + size >= 64)
3757 operands[3] = const0_rtx;
3759 operands[3] = GEN_INT (start + size);
3760 operands[2] = GEN_INT (64 - size);
3761 return \"rldicl %0,%1,%3,%2\";
3763 [(set_attr "type" "shift")])
3765 (define_insn "*extzvdi_internal1"
3766 [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3767 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3768 (match_operand:SI 2 "const_int_operand" "i")
3769 (match_operand:SI 3 "const_int_operand" "i"))
3771 (clobber (match_scratch:DI 4 "=r"))]
3772 "TARGET_64BIT && rs6000_gen_cell_microcode"
3775 int start = INTVAL (operands[3]) & 63;
3776 int size = INTVAL (operands[2]) & 63;
3778 if (start + size >= 64)
3779 operands[3] = const0_rtx;
3781 operands[3] = GEN_INT (start + size);
3782 operands[2] = GEN_INT (64 - size);
3783 return \"rldicl. %4,%1,%3,%2\";
3785 [(set_attr "type" "shift")
3786 (set_attr "dot" "yes")])
3788 (define_insn "*extzvdi_internal2"
3789 [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3790 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3791 (match_operand:SI 2 "const_int_operand" "i")
3792 (match_operand:SI 3 "const_int_operand" "i"))
3794 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
3795 (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
3796 "TARGET_64BIT && rs6000_gen_cell_microcode"
3799 int start = INTVAL (operands[3]) & 63;
3800 int size = INTVAL (operands[2]) & 63;
3802 if (start + size >= 64)
3803 operands[3] = const0_rtx;
3805 operands[3] = GEN_INT (start + size);
3806 operands[2] = GEN_INT (64 - size);
3807 return \"rldicl. %0,%1,%3,%2\";
3809 [(set_attr "type" "shift")
3810 (set_attr "dot" "yes")])
3813 (define_insn "rotl<mode>3"
3814 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3815 (rotate:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
3816 (match_operand:SI 2 "reg_or_cint_operand" "rn")))]
3818 "rotl<wd>%I2 %0,%1,%<hH>2"
3819 [(set_attr "type" "shift")
3820 (set_attr "maybe_var_shift" "yes")])
3822 (define_insn "*rotlsi3_64"
3823 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3825 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3826 (match_operand:SI 2 "reg_or_cint_operand" "rn"))))]
3828 "rotlw%I2 %0,%1,%h2"
3829 [(set_attr "type" "shift")
3830 (set_attr "maybe_var_shift" "yes")])
3832 (define_insn_and_split "*rotl<mode>3_dot"
3833 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3834 (compare:CC (rotate:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
3835 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
3837 (clobber (match_scratch:GPR 0 "=r,r"))]
3838 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3840 rotl<wd>%I2. %0,%1,%<hH>2
3842 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
3844 (rotate:GPR (match_dup 1)
3847 (compare:CC (match_dup 0)
3850 [(set_attr "type" "shift")
3851 (set_attr "maybe_var_shift" "yes")
3852 (set_attr "dot" "yes")
3853 (set_attr "length" "4,8")])
3855 (define_insn_and_split "*rotl<mode>3_dot2"
3856 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3857 (compare:CC (rotate:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
3858 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
3860 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
3861 (rotate:GPR (match_dup 1)
3863 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3865 rotl<wd>%I2. %0,%1,%<hH>2
3867 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
3869 (rotate:GPR (match_dup 1)
3872 (compare:CC (match_dup 0)
3875 [(set_attr "type" "shift")
3876 (set_attr "maybe_var_shift" "yes")
3877 (set_attr "dot" "yes")
3878 (set_attr "length" "4,8")])
3881 (define_insn "*rotlsi3_internal4"
3882 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3883 (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3884 (match_operand:SI 2 "reg_or_cint_operand" "rn"))
3885 (match_operand:SI 3 "mask_operand" "n")))]
3887 "rlw%I2nm %0,%1,%h2,%m3,%M3"
3888 [(set_attr "type" "shift")
3889 (set_attr "maybe_var_shift" "yes")])
3891 (define_insn "*rotlsi3_internal5"
3892 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3894 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3895 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
3896 (match_operand:SI 3 "mask_operand" "n,n"))
3898 (clobber (match_scratch:SI 4 "=r,r"))]
3901 rlw%I2nm. %4,%1,%h2,%m3,%M3
3903 [(set_attr "type" "shift")
3904 (set_attr "maybe_var_shift" "yes")
3905 (set_attr "dot" "yes")
3906 (set_attr "length" "4,8")])
3909 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3911 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3912 (match_operand:SI 2 "reg_or_cint_operand" ""))
3913 (match_operand:SI 3 "mask_operand" ""))
3915 (clobber (match_scratch:SI 4 ""))]
3918 (and:SI (rotate:SI (match_dup 1)
3922 (compare:CC (match_dup 4)
3926 (define_insn "*rotlsi3_internal6"
3927 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3929 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3930 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
3931 (match_operand:SI 3 "mask_operand" "n,n"))
3933 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3934 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3937 rlw%I2nm. %0,%1,%h2,%m3,%M3
3939 [(set_attr "type" "shift")
3940 (set_attr "maybe_var_shift" "yes")
3941 (set_attr "dot" "yes")
3942 (set_attr "length" "4,8")])
3945 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
3947 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3948 (match_operand:SI 2 "reg_or_cint_operand" ""))
3949 (match_operand:SI 3 "mask_operand" ""))
3951 (set (match_operand:SI 0 "gpc_reg_operand" "")
3952 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3955 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3957 (compare:CC (match_dup 0)
3961 (define_insn "*rotlsi3_internal7le"
3962 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3965 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3966 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3968 "rlw%I2nm %0,%1,%h2,0xff"
3969 [(set (attr "cell_micro")
3970 (if_then_else (match_operand:SI 2 "const_int_operand" "")
3971 (const_string "not")
3972 (const_string "always")))
3973 (set_attr "type" "shift")])
3975 (define_insn "*rotlsi3_internal7be"
3976 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3979 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3980 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 3)))]
3982 "rlw%I2nm %0,%1,%h2,0xff"
3983 [(set (attr "cell_micro")
3984 (if_then_else (match_operand:SI 2 "const_int_operand" "")
3985 (const_string "not")
3986 (const_string "always")))
3987 (set_attr "type" "shift")])
3989 (define_insn "*rotlsi3_internal8le"
3990 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3991 (compare:CC (zero_extend:SI
3993 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3994 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 0))
3996 (clobber (match_scratch:SI 3 "=r,r"))]
3999 rlw%I2nm. %3,%1,%h2,0xff
4001 [(set_attr "type" "shift")
4002 (set_attr "maybe_var_shift" "yes")
4003 (set_attr "dot" "yes")
4004 (set_attr "length" "4,8")])
4006 (define_insn "*rotlsi3_internal8be"
4007 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4008 (compare:CC (zero_extend:SI
4010 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4011 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 3))
4013 (clobber (match_scratch:SI 3 "=r,r"))]
4016 rlw%I2nm. %3,%1,%h2,0xff
4018 [(set_attr "type" "shift")
4019 (set_attr "maybe_var_shift" "yes")
4020 (set_attr "dot" "yes")
4021 (set_attr "length" "4,8")])
4024 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4025 (compare:CC (zero_extend:SI
4027 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4028 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4030 (clobber (match_scratch:SI 3 ""))]
4031 "!BYTES_BIG_ENDIAN && reload_completed"
4033 (zero_extend:SI (subreg:QI
4034 (rotate:SI (match_dup 1)
4037 (compare:CC (match_dup 3)
4042 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4043 (compare:CC (zero_extend:SI
4045 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4046 (match_operand:SI 2 "reg_or_cint_operand" "")) 3))
4048 (clobber (match_scratch:SI 3 ""))]
4049 "BYTES_BIG_ENDIAN && reload_completed"
4051 (zero_extend:SI (subreg:QI
4052 (rotate:SI (match_dup 1)
4055 (compare:CC (match_dup 3)
4059 (define_insn "*rotlsi3_internal9le"
4060 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4061 (compare:CC (zero_extend:SI
4063 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4064 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 0))
4066 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4067 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4070 rlw%I2nm. %0,%1,%h2,0xff
4072 [(set_attr "type" "shift")
4073 (set_attr "maybe_var_shift" "yes")
4074 (set_attr "dot" "yes")
4075 (set_attr "length" "4,8")])
4077 (define_insn "*rotlsi3_internal9be"
4078 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4079 (compare:CC (zero_extend:SI
4081 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4082 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 3))
4084 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4085 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 3)))]
4088 rlw%I2nm. %0,%1,%h2,0xff
4090 [(set_attr "type" "shift")
4091 (set_attr "maybe_var_shift" "yes")
4092 (set_attr "dot" "yes")
4093 (set_attr "length" "4,8")])
4096 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4097 (compare:CC (zero_extend:SI
4099 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4100 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4102 (set (match_operand:SI 0 "gpc_reg_operand" "")
4103 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4104 "!BYTES_BIG_ENDIAN && reload_completed"
4106 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
4108 (compare:CC (match_dup 0)
4113 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4114 (compare:CC (zero_extend:SI
4116 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4117 (match_operand:SI 2 "reg_or_cint_operand" "")) 3))
4119 (set (match_operand:SI 0 "gpc_reg_operand" "")
4120 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 3)))]
4121 "BYTES_BIG_ENDIAN && reload_completed"
4123 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 3)))
4125 (compare:CC (match_dup 0)
4129 (define_insn "*rotlsi3_internal10le"
4130 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4133 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4134 (match_operand:SI 2 "reg_or_cint_operand" "rn")) 0)))]
4136 "rlw%I2nm %0,%1,%h2,0xffff"
4137 [(set_attr "type" "shift")
4138 (set_attr "maybe_var_shift" "yes")])
4140 (define_insn "*rotlsi3_internal10be"
4141 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4144 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4145 (match_operand:SI 2 "reg_or_cint_operand" "rn")) 2)))]
4147 "rlw%I2nm %0,%1,%h2,0xffff"
4148 [(set_attr "type" "shift")
4149 (set_attr "maybe_var_shift" "yes")])
4151 (define_insn "*rotlsi3_internal11le"
4152 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4153 (compare:CC (zero_extend:SI
4155 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4156 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 0))
4158 (clobber (match_scratch:SI 3 "=r,r"))]
4161 rlw%I2nm. %3,%1,%h2,0xffff
4163 [(set_attr "type" "shift")
4164 (set_attr "maybe_var_shift" "yes")
4165 (set_attr "dot" "yes")
4166 (set_attr "length" "4,8")])
4168 (define_insn "*rotlsi3_internal11be"
4169 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4170 (compare:CC (zero_extend:SI
4172 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4173 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 2))
4175 (clobber (match_scratch:SI 3 "=r,r"))]
4178 rlw%I2nm. %3,%1,%h2,0xffff
4180 [(set_attr "type" "shift")
4181 (set_attr "maybe_var_shift" "yes")
4182 (set_attr "dot" "yes")
4183 (set_attr "length" "4,8")])
4186 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4187 (compare:CC (zero_extend:SI
4189 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4190 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4192 (clobber (match_scratch:SI 3 ""))]
4193 "!BYTES_BIG_ENDIAN && reload_completed"
4195 (zero_extend:SI (subreg:HI
4196 (rotate:SI (match_dup 1)
4199 (compare:CC (match_dup 3)
4204 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4205 (compare:CC (zero_extend:SI
4207 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4208 (match_operand:SI 2 "reg_or_cint_operand" "")) 2))
4210 (clobber (match_scratch:SI 3 ""))]
4211 "BYTES_BIG_ENDIAN && reload_completed"
4213 (zero_extend:SI (subreg:HI
4214 (rotate:SI (match_dup 1)
4217 (compare:CC (match_dup 3)
4221 (define_insn "*rotlsi3_internal12le"
4222 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4223 (compare:CC (zero_extend:SI
4225 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4226 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 0))
4228 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4229 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4232 rlw%I2nm. %0,%1,%h2,0xffff
4234 [(set_attr "type" "shift")
4235 (set_attr "maybe_var_shift" "yes")
4236 (set_attr "dot" "yes")
4237 (set_attr "length" "4,8")])
4239 (define_insn "*rotlsi3_internal12be"
4240 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4241 (compare:CC (zero_extend:SI
4243 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4244 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 2))
4246 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4247 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 2)))]
4250 rlw%I2nm. %0,%1,%h2,0xffff
4252 [(set_attr "type" "shift")
4253 (set_attr "maybe_var_shift" "yes")
4254 (set_attr "dot" "yes")
4255 (set_attr "length" "4,8")])
4258 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4259 (compare:CC (zero_extend:SI
4261 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4262 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4264 (set (match_operand:SI 0 "gpc_reg_operand" "")
4265 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4266 "!BYTES_BIG_ENDIAN && reload_completed"
4268 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
4270 (compare:CC (match_dup 0)
4275 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4276 (compare:CC (zero_extend:SI
4278 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4279 (match_operand:SI 2 "reg_or_cint_operand" "")) 2))
4281 (set (match_operand:SI 0 "gpc_reg_operand" "")
4282 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 2)))]
4283 "BYTES_BIG_ENDIAN && reload_completed"
4285 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 2)))
4287 (compare:CC (match_dup 0)
4292 (define_insn "ashl<mode>3"
4293 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
4294 (ashift:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
4295 (match_operand:SI 2 "reg_or_cint_operand" "rn")))]
4297 "sl<wd>%I2 %0,%1,%<hH>2"
4298 [(set_attr "type" "shift")
4299 (set_attr "maybe_var_shift" "yes")])
4301 (define_insn "*ashlsi3_64"
4302 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4304 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4305 (match_operand:SI 2 "reg_or_cint_operand" "rn"))))]
4308 [(set_attr "type" "shift")
4309 (set_attr "maybe_var_shift" "yes")])
4311 (define_insn_and_split "*ashl<mode>3_dot"
4312 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4313 (compare:CC (ashift:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4314 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4316 (clobber (match_scratch:GPR 0 "=r,r"))]
4317 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4319 sl<wd>%I2. %0,%1,%<hH>2
4321 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4323 (ashift:GPR (match_dup 1)
4326 (compare:CC (match_dup 0)
4329 [(set_attr "type" "shift")
4330 (set_attr "maybe_var_shift" "yes")
4331 (set_attr "dot" "yes")
4332 (set_attr "length" "4,8")])
4334 (define_insn_and_split "*ashl<mode>3_dot2"
4335 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4336 (compare:CC (ashift:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4337 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4339 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
4340 (ashift:GPR (match_dup 1)
4342 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4344 sl<wd>%I2. %0,%1,%<hH>2
4346 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4348 (ashift:GPR (match_dup 1)
4351 (compare:CC (match_dup 0)
4354 [(set_attr "type" "shift")
4355 (set_attr "maybe_var_shift" "yes")
4356 (set_attr "dot" "yes")
4357 (set_attr "length" "4,8")])
4360 (define_insn "rlwinm"
4361 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4362 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4363 (match_operand:SI 2 "const_int_operand" "i"))
4364 (match_operand:SI 3 "mask_operand" "n")))]
4365 "includes_lshift_p (operands[2], operands[3])"
4366 "rlwinm %0,%1,%h2,%m3,%M3"
4367 [(set_attr "type" "shift")])
4370 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4372 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4373 (match_operand:SI 2 "const_int_operand" "i,i"))
4374 (match_operand:SI 3 "mask_operand" "n,n"))
4376 (clobber (match_scratch:SI 4 "=r,r"))]
4377 "includes_lshift_p (operands[2], operands[3])"
4379 rlwinm. %4,%1,%h2,%m3,%M3
4381 [(set_attr "type" "shift")
4382 (set_attr "dot" "yes")
4383 (set_attr "length" "4,8")])
4386 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4388 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4389 (match_operand:SI 2 "const_int_operand" ""))
4390 (match_operand:SI 3 "mask_operand" ""))
4392 (clobber (match_scratch:SI 4 ""))]
4393 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
4395 (and:SI (ashift:SI (match_dup 1) (match_dup 2))
4398 (compare:CC (match_dup 4)
4403 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4405 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4406 (match_operand:SI 2 "const_int_operand" "i,i"))
4407 (match_operand:SI 3 "mask_operand" "n,n"))
4409 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4410 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4411 "includes_lshift_p (operands[2], operands[3])"
4413 rlwinm. %0,%1,%h2,%m3,%M3
4415 [(set_attr "type" "shift")
4416 (set_attr "dot" "yes")
4417 (set_attr "length" "4,8")])
4420 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
4422 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4423 (match_operand:SI 2 "const_int_operand" ""))
4424 (match_operand:SI 3 "mask_operand" ""))
4426 (set (match_operand:SI 0 "gpc_reg_operand" "")
4427 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4428 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
4430 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4432 (compare:CC (match_dup 0)
4437 (define_insn "lshr<mode>3"
4438 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
4439 (lshiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
4440 (match_operand:SI 2 "reg_or_cint_operand" "rn")))]
4442 "sr<wd>%I2 %0,%1,%<hH>2"
4443 [(set_attr "type" "shift")
4444 (set_attr "maybe_var_shift" "yes")])
4446 (define_insn "*lshrsi3_64"
4447 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4449 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4450 (match_operand:SI 2 "reg_or_cint_operand" "rn"))))]
4453 [(set_attr "type" "shift")
4454 (set_attr "maybe_var_shift" "yes")])
4456 (define_insn_and_split "*lshr<mode>3_dot"
4457 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4458 (compare:CC (lshiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4459 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4461 (clobber (match_scratch:GPR 0 "=r,r"))]
4462 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4464 sr<wd>%I2. %0,%1,%<hH>2
4466 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4468 (lshiftrt:GPR (match_dup 1)
4471 (compare:CC (match_dup 0)
4474 [(set_attr "type" "shift")
4475 (set_attr "maybe_var_shift" "yes")
4476 (set_attr "dot" "yes")
4477 (set_attr "length" "4,8")])
4479 (define_insn_and_split "*lshr<mode>3_dot2"
4480 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4481 (compare:CC (lshiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4482 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4484 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
4485 (lshiftrt:GPR (match_dup 1)
4487 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4489 sr<wd>%I2. %0,%1,%<hH>2
4491 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4493 (lshiftrt:GPR (match_dup 1)
4496 (compare:CC (match_dup 0)
4499 [(set_attr "type" "shift")
4500 (set_attr "maybe_var_shift" "yes")
4501 (set_attr "dot" "yes")
4502 (set_attr "length" "4,8")])
4506 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4507 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4508 (match_operand:SI 2 "const_int_operand" "i"))
4509 (match_operand:SI 3 "mask_operand" "n")))]
4510 "includes_rshift_p (operands[2], operands[3])"
4511 "rlwinm %0,%1,%s2,%m3,%M3"
4512 [(set_attr "type" "shift")])
4515 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4517 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4518 (match_operand:SI 2 "const_int_operand" "i,i"))
4519 (match_operand:SI 3 "mask_operand" "n,n"))
4521 (clobber (match_scratch:SI 4 "=r,r"))]
4522 "includes_rshift_p (operands[2], operands[3])"
4524 rlwinm. %4,%1,%s2,%m3,%M3
4526 [(set_attr "type" "shift")
4527 (set_attr "dot" "yes")
4528 (set_attr "length" "4,8")])
4531 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4533 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4534 (match_operand:SI 2 "const_int_operand" ""))
4535 (match_operand:SI 3 "mask_operand" ""))
4537 (clobber (match_scratch:SI 4 ""))]
4538 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4540 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
4543 (compare:CC (match_dup 4)
4548 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4550 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4551 (match_operand:SI 2 "const_int_operand" "i,i"))
4552 (match_operand:SI 3 "mask_operand" "n,n"))
4554 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4555 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4556 "includes_rshift_p (operands[2], operands[3])"
4558 rlwinm. %0,%1,%s2,%m3,%M3
4560 [(set_attr "type" "shift")
4561 (set_attr "dot" "yes")
4562 (set_attr "length" "4,8")])
4565 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
4567 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4568 (match_operand:SI 2 "const_int_operand" ""))
4569 (match_operand:SI 3 "mask_operand" ""))
4571 (set (match_operand:SI 0 "gpc_reg_operand" "")
4572 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4573 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4575 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4577 (compare:CC (match_dup 0)
4581 (define_insn "*lshiftrt_internal1le"
4582 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4585 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4586 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4587 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4588 "rlwinm %0,%1,%s2,0xff"
4589 [(set_attr "type" "shift")])
4591 (define_insn "*lshiftrt_internal1be"
4592 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4595 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4596 (match_operand:SI 2 "const_int_operand" "i")) 3)))]
4597 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4598 "rlwinm %0,%1,%s2,0xff"
4599 [(set_attr "type" "shift")])
4601 (define_insn "*lshiftrt_internal2le"
4602 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4606 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4607 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4609 (clobber (match_scratch:SI 3 "=r,r"))]
4610 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4612 rlwinm. %3,%1,%s2,0xff
4614 [(set_attr "type" "shift")
4615 (set_attr "dot" "yes")
4616 (set_attr "length" "4,8")])
4618 (define_insn "*lshiftrt_internal2be"
4619 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4623 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4624 (match_operand:SI 2 "const_int_operand" "i,i")) 3))
4626 (clobber (match_scratch:SI 3 "=r,r"))]
4627 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4629 rlwinm. %3,%1,%s2,0xff
4631 [(set_attr "type" "shift")
4632 (set_attr "dot" "yes")
4633 (set_attr "length" "4,8")])
4636 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4640 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4641 (match_operand:SI 2 "const_int_operand" "")) 0))
4643 (clobber (match_scratch:SI 3 ""))]
4644 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4646 (zero_extend:SI (subreg:QI
4647 (lshiftrt:SI (match_dup 1)
4650 (compare:CC (match_dup 3)
4655 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4659 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4660 (match_operand:SI 2 "const_int_operand" "")) 3))
4662 (clobber (match_scratch:SI 3 ""))]
4663 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4665 (zero_extend:SI (subreg:QI
4666 (lshiftrt:SI (match_dup 1)
4669 (compare:CC (match_dup 3)
4673 (define_insn "*lshiftrt_internal3le"
4674 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4678 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4679 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4681 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4682 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4683 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4685 rlwinm. %0,%1,%s2,0xff
4687 [(set_attr "type" "shift")
4688 (set_attr "dot" "yes")
4689 (set_attr "length" "4,8")])
4691 (define_insn "*lshiftrt_internal3be"
4692 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4696 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4697 (match_operand:SI 2 "const_int_operand" "i,i")) 3))
4699 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4700 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 3)))]
4701 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4703 rlwinm. %0,%1,%s2,0xff
4705 [(set_attr "type" "shift")
4706 (set_attr "dot" "yes")
4707 (set_attr "length" "4,8")])
4710 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4714 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4715 (match_operand:SI 2 "const_int_operand" "")) 0))
4717 (set (match_operand:SI 0 "gpc_reg_operand" "")
4718 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4719 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4721 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4723 (compare:CC (match_dup 0)
4728 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4732 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4733 (match_operand:SI 2 "const_int_operand" "")) 3))
4735 (set (match_operand:SI 0 "gpc_reg_operand" "")
4736 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 3)))]
4737 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4739 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 3)))
4741 (compare:CC (match_dup 0)
4745 (define_insn "*lshiftrt_internal4le"
4746 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4749 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4750 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4751 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4752 "rlwinm %0,%1,%s2,0xffff"
4753 [(set_attr "type" "shift")])
4755 (define_insn "*lshiftrt_internal4be"
4756 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4759 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4760 (match_operand:SI 2 "const_int_operand" "i")) 2)))]
4761 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4762 "rlwinm %0,%1,%s2,0xffff"
4763 [(set_attr "type" "shift")])
4765 (define_insn "*lshiftrt_internal5le"
4766 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4770 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4771 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4773 (clobber (match_scratch:SI 3 "=r,r"))]
4774 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4776 rlwinm. %3,%1,%s2,0xffff
4778 [(set_attr "type" "shift")
4779 (set_attr "dot" "yes")
4780 (set_attr "length" "4,8")])
4782 (define_insn "*lshiftrt_internal5be"
4783 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4787 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4788 (match_operand:SI 2 "const_int_operand" "i,i")) 2))
4790 (clobber (match_scratch:SI 3 "=r,r"))]
4791 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4793 rlwinm. %3,%1,%s2,0xffff
4795 [(set_attr "type" "shift")
4796 (set_attr "dot" "yes")
4797 (set_attr "length" "4,8")])
4800 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4804 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4805 (match_operand:SI 2 "const_int_operand" "")) 0))
4807 (clobber (match_scratch:SI 3 ""))]
4808 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4810 (zero_extend:SI (subreg:HI
4811 (lshiftrt:SI (match_dup 1)
4814 (compare:CC (match_dup 3)
4819 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4823 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4824 (match_operand:SI 2 "const_int_operand" "")) 2))
4826 (clobber (match_scratch:SI 3 ""))]
4827 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4829 (zero_extend:SI (subreg:HI
4830 (lshiftrt:SI (match_dup 1)
4833 (compare:CC (match_dup 3)
4837 (define_insn "*lshiftrt_internal5le"
4838 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4842 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4843 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4845 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4846 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4847 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4849 rlwinm. %0,%1,%s2,0xffff
4851 [(set_attr "type" "shift")
4852 (set_attr "dot" "yes")
4853 (set_attr "length" "4,8")])
4855 (define_insn "*lshiftrt_internal5be"
4856 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4860 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4861 (match_operand:SI 2 "const_int_operand" "i,i")) 2))
4863 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4864 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 2)))]
4865 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4867 rlwinm. %0,%1,%s2,0xffff
4869 [(set_attr "type" "shift")
4870 (set_attr "dot" "yes")
4871 (set_attr "length" "4,8")])
4874 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4878 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4879 (match_operand:SI 2 "const_int_operand" "")) 0))
4881 (set (match_operand:SI 0 "gpc_reg_operand" "")
4882 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4883 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4885 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4887 (compare:CC (match_dup 0)
4892 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4896 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4897 (match_operand:SI 2 "const_int_operand" "")) 2))
4899 (set (match_operand:SI 0 "gpc_reg_operand" "")
4900 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 2)))]
4901 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4903 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 2)))
4905 (compare:CC (match_dup 0)
4910 (define_expand "ashr<mode>3"
4911 [(parallel [(set (match_operand:GPR 0 "gpc_reg_operand" "")
4912 (ashiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
4913 (match_operand:SI 2 "reg_or_cint_operand" "")))
4914 (clobber (reg:GPR CA_REGNO))])]
4917 /* The generic code does not generate optimal code for the low word
4918 (it should be a rlwimi and a rot). Until we have target code to
4919 solve this generically, keep this expander. */
4921 if (<MODE>mode == DImode && !TARGET_POWERPC64)
4923 if (CONST_INT_P (operands[2]))
4925 emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
4933 (define_insn "*ashr<mode>3"
4934 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
4935 (ashiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
4936 (match_operand:SI 2 "reg_or_cint_operand" "rn")))
4937 (clobber (reg:GPR CA_REGNO))]
4939 "sra<wd>%I2 %0,%1,%<hH>2"
4940 [(set_attr "type" "shift")
4941 (set_attr "maybe_var_shift" "yes")])
4943 (define_insn "*ashrsi3_64"
4944 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4946 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4947 (match_operand:SI 2 "reg_or_cint_operand" "rn"))))
4948 (clobber (reg:SI CA_REGNO))]
4951 [(set_attr "type" "shift")
4952 (set_attr "maybe_var_shift" "yes")])
4954 (define_insn_and_split "*ashr<mode>3_dot"
4955 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4956 (compare:CC (ashiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4957 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4959 (clobber (match_scratch:GPR 0 "=r,r"))
4960 (clobber (reg:GPR CA_REGNO))]
4961 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4963 sra<wd>%I2. %0,%1,%<hH>2
4965 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4966 [(parallel [(set (match_dup 0)
4967 (ashiftrt:GPR (match_dup 1)
4969 (clobber (reg:GPR CA_REGNO))])
4971 (compare:CC (match_dup 0)
4974 [(set_attr "type" "shift")
4975 (set_attr "maybe_var_shift" "yes")
4976 (set_attr "dot" "yes")
4977 (set_attr "length" "4,8")])
4979 (define_insn_and_split "*ashr<mode>3_dot2"
4980 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4981 (compare:CC (ashiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4982 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4984 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
4985 (ashiftrt:GPR (match_dup 1)
4987 (clobber (reg:GPR CA_REGNO))]
4988 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4990 sra<wd>%I2. %0,%1,%<hH>2
4992 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4993 [(parallel [(set (match_dup 0)
4994 (ashiftrt:GPR (match_dup 1)
4996 (clobber (reg:GPR CA_REGNO))])
4998 (compare:CC (match_dup 0)
5001 [(set_attr "type" "shift")
5002 (set_attr "maybe_var_shift" "yes")
5003 (set_attr "dot" "yes")
5004 (set_attr "length" "4,8")])
5006 ;; Builtins to replace a division to generate FRE reciprocal estimate
5007 ;; instructions and the necessary fixup instructions
5008 (define_expand "recip<mode>3"
5009 [(match_operand:RECIPF 0 "gpc_reg_operand" "")
5010 (match_operand:RECIPF 1 "gpc_reg_operand" "")
5011 (match_operand:RECIPF 2 "gpc_reg_operand" "")]
5012 "RS6000_RECIP_HAVE_RE_P (<MODE>mode)"
5014 rs6000_emit_swdiv (operands[0], operands[1], operands[2], false);
5018 ;; Split to create division from FRE/FRES/etc. and fixup instead of the normal
5019 ;; hardware division. This is only done before register allocation and with
5020 ;; -ffast-math. This must appear before the divsf3/divdf3 insns.
5022 [(set (match_operand:RECIPF 0 "gpc_reg_operand" "")
5023 (div:RECIPF (match_operand 1 "gpc_reg_operand" "")
5024 (match_operand 2 "gpc_reg_operand" "")))]
5025 "RS6000_RECIP_AUTO_RE_P (<MODE>mode)
5026 && can_create_pseudo_p () && optimize_insn_for_speed_p ()
5027 && flag_finite_math_only && !flag_trapping_math && flag_reciprocal_math"
5030 rs6000_emit_swdiv (operands[0], operands[1], operands[2], true);
5034 ;; Builtins to replace 1/sqrt(x) with instructions using RSQRTE and the
5035 ;; appropriate fixup.
5036 (define_expand "rsqrt<mode>2"
5037 [(match_operand:RECIPF 0 "gpc_reg_operand" "")
5038 (match_operand:RECIPF 1 "gpc_reg_operand" "")]
5039 "RS6000_RECIP_HAVE_RSQRTE_P (<MODE>mode)"
5041 rs6000_emit_swrsqrt (operands[0], operands[1]);
5045 ;; Floating-point insns, excluding normal data motion. We combine the SF/DF
5046 ;; modes here, and also add in conditional vsx/power8-vector support to access
5047 ;; values in the traditional Altivec registers if the appropriate
5048 ;; -mupper-regs-{df,sf} option is enabled.
5050 (define_expand "abs<mode>2"
5051 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5052 (abs:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")))]
5053 "TARGET_<MODE>_INSN"
5056 (define_insn "*abs<mode>2_fpr"
5057 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5058 (abs:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")))]
5063 [(set_attr "type" "fp")
5064 (set_attr "fp_type" "fp_addsub_<Fs>")])
5066 (define_insn "*nabs<mode>2_fpr"
5067 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5070 (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>"))))]
5075 [(set_attr "type" "fp")
5076 (set_attr "fp_type" "fp_addsub_<Fs>")])
5078 (define_expand "neg<mode>2"
5079 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5080 (neg:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")))]
5081 "TARGET_<MODE>_INSN"
5084 (define_insn "*neg<mode>2_fpr"
5085 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5086 (neg:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")))]
5091 [(set_attr "type" "fp")
5092 (set_attr "fp_type" "fp_addsub_<Fs>")])
5094 (define_expand "add<mode>3"
5095 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5096 (plus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
5097 (match_operand:SFDF 2 "gpc_reg_operand" "")))]
5098 "TARGET_<MODE>_INSN"
5101 (define_insn "*add<mode>3_fpr"
5102 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5103 (plus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
5104 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
5107 fadd<Ftrad> %0,%1,%2
5108 xsadd<Fvsx> %x0,%x1,%x2"
5109 [(set_attr "type" "fp")
5110 (set_attr "fp_type" "fp_addsub_<Fs>")])
5112 (define_expand "sub<mode>3"
5113 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5114 (minus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
5115 (match_operand:SFDF 2 "gpc_reg_operand" "")))]
5116 "TARGET_<MODE>_INSN"
5119 (define_insn "*sub<mode>3_fpr"
5120 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5121 (minus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
5122 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
5125 fsub<Ftrad> %0,%1,%2
5126 xssub<Fvsx> %x0,%x1,%x2"
5127 [(set_attr "type" "fp")
5128 (set_attr "fp_type" "fp_addsub_<Fs>")])
5130 (define_expand "mul<mode>3"
5131 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5132 (mult:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
5133 (match_operand:SFDF 2 "gpc_reg_operand" "")))]
5134 "TARGET_<MODE>_INSN"
5137 (define_insn "*mul<mode>3_fpr"
5138 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5139 (mult:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
5140 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
5143 fmul<Ftrad> %0,%1,%2
5144 xsmul<Fvsx> %x0,%x1,%x2"
5145 [(set_attr "type" "dmul")
5146 (set_attr "fp_type" "fp_mul_<Fs>")])
5148 (define_expand "div<mode>3"
5149 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5150 (div:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
5151 (match_operand:SFDF 2 "gpc_reg_operand" "")))]
5152 "TARGET_<MODE>_INSN && !TARGET_SIMPLE_FPU"
5155 (define_insn "*div<mode>3_fpr"
5156 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5157 (div:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
5158 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
5159 "TARGET_<MODE>_FPR && !TARGET_SIMPLE_FPU"
5161 fdiv<Ftrad> %0,%1,%2
5162 xsdiv<Fvsx> %x0,%x1,%x2"
5163 [(set_attr "type" "<Fs>div")
5164 (set_attr "fp_type" "fp_div_<Fs>")])
5166 (define_insn "sqrt<mode>2"
5167 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5168 (sqrt:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")))]
5169 "TARGET_<MODE>_FPR && !TARGET_SIMPLE_FPU
5170 && (TARGET_PPC_GPOPT || (<MODE>mode == SFmode && TARGET_XILINX_FPU))"
5173 xssqrt<Fvsx> %x0,%x1"
5174 [(set_attr "type" "<Fs>sqrt")
5175 (set_attr "fp_type" "fp_sqrt_<Fs>")])
5177 ;; Floating point reciprocal approximation
5178 (define_insn "fre<Fs>"
5179 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5180 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
5186 [(set_attr "type" "fp")])
5188 (define_insn "*rsqrt<mode>2"
5189 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5190 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
5192 "RS6000_RECIP_HAVE_RSQRTE_P (<MODE>mode)"
5194 frsqrte<Ftrad> %0,%1
5195 xsrsqrte<Fvsx> %x0,%x1"
5196 [(set_attr "type" "fp")])
5198 ;; Floating point comparisons
5199 (define_insn "*cmp<mode>_fpr"
5200 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y,y")
5201 (compare:CCFP (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
5202 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
5206 xscmpudp %0,%x1,%x2"
5207 [(set_attr "type" "fpcompare")])
5209 ;; Floating point conversions
5210 (define_expand "extendsfdf2"
5211 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5212 (float_extend:DF (match_operand:SF 1 "reg_or_none500mem_operand" "")))]
5213 "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
5216 (define_insn_and_split "*extendsfdf2_fpr"
5217 [(set (match_operand:DF 0 "gpc_reg_operand" "=d,?d,d,ws,?ws,wu")
5218 (float_extend:DF (match_operand:SF 1 "reg_or_mem_operand" "0,f,m,0,wy,Z")))]
5219 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5227 "&& reload_completed && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])"
5230 emit_note (NOTE_INSN_DELETED);
5233 [(set_attr "type" "fp,fp,fpload,fp,vecsimple,fpload")])
5235 (define_expand "truncdfsf2"
5236 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5237 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "")))]
5238 "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
5241 (define_insn "*truncdfsf2_fpr"
5242 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5243 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "d")))]
5244 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5246 [(set_attr "type" "fp")])
5248 ;; This expander is here to avoid FLOAT_WORDS_BIGENDIAN tests in
5249 ;; builtins.c and optabs.c that are not correct for IBM long double
5250 ;; when little-endian.
5251 (define_expand "signbittf2"
5253 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))
5255 (subreg:DI (match_dup 2) 0))
5258 (set (match_operand:SI 0 "gpc_reg_operand" "")
5261 && TARGET_HARD_FLOAT
5262 && (TARGET_FPRS || TARGET_E500_DOUBLE)
5263 && TARGET_LONG_DOUBLE_128"
5265 operands[2] = gen_reg_rtx (DFmode);
5266 operands[3] = gen_reg_rtx (DImode);
5267 if (TARGET_POWERPC64)
5269 operands[4] = gen_reg_rtx (DImode);
5270 operands[5] = gen_rtx_LSHIFTRT (DImode, operands[3], GEN_INT (63));
5271 operands[6] = gen_rtx_SUBREG (SImode, operands[4],
5272 WORDS_BIG_ENDIAN ? 4 : 0);
5276 operands[4] = gen_reg_rtx (SImode);
5277 operands[5] = gen_rtx_SUBREG (SImode, operands[3],
5278 WORDS_BIG_ENDIAN ? 0 : 4);
5279 operands[6] = gen_rtx_LSHIFTRT (SImode, operands[4], GEN_INT (31));
5283 (define_expand "copysign<mode>3"
5285 (abs:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")))
5287 (neg:SFDF (abs:SFDF (match_dup 1))))
5288 (set (match_operand:SFDF 0 "gpc_reg_operand" "")
5289 (if_then_else:SFDF (ge (match_operand:SFDF 2 "gpc_reg_operand" "")
5293 "TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT>
5294 && ((TARGET_PPC_GFXOPT
5295 && !HONOR_NANS (<MODE>mode)
5296 && !HONOR_SIGNED_ZEROS (<MODE>mode))
5298 || VECTOR_UNIT_VSX_P (<MODE>mode))"
5300 if (TARGET_CMPB || VECTOR_UNIT_VSX_P (<MODE>mode))
5302 emit_insn (gen_copysign<mode>3_fcpsgn (operands[0], operands[1],
5307 operands[3] = gen_reg_rtx (<MODE>mode);
5308 operands[4] = gen_reg_rtx (<MODE>mode);
5309 operands[5] = CONST0_RTX (<MODE>mode);
5312 ;; Use an unspec rather providing an if-then-else in RTL, to prevent the
5313 ;; compiler from optimizing -0.0
5314 (define_insn "copysign<mode>3_fcpsgn"
5315 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5316 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
5317 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")]
5319 "TARGET_<MODE>_FPR && TARGET_CMPB"
5322 xscpsgndp %x0,%x2,%x1"
5323 [(set_attr "type" "fp")])
5325 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
5326 ;; fsel instruction and some auxiliary computations. Then we just have a
5327 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
5329 ;; For MIN, MAX on non-VSX machines, and conditional move all of the time, we
5330 ;; use DEFINE_EXPAND's that involve a fsel instruction and some auxiliary
5331 ;; computations. Then we just have a single DEFINE_INSN for fsel and the
5332 ;; define_splits to make them if made by combine. On VSX machines we have the
5333 ;; min/max instructions.
5335 ;; On VSX, we only check for TARGET_VSX instead of checking for a vsx/p8 vector
5336 ;; to allow either DF/SF to use only traditional registers.
5338 (define_expand "smax<mode>3"
5339 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5340 (if_then_else:SFDF (ge (match_operand:SFDF 1 "gpc_reg_operand" "")
5341 (match_operand:SFDF 2 "gpc_reg_operand" ""))
5344 "TARGET_<MODE>_FPR && TARGET_PPC_GFXOPT && !flag_trapping_math"
5346 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
5350 (define_insn "*smax<mode>3_vsx"
5351 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5352 (smax:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
5353 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
5354 "TARGET_<MODE>_FPR && TARGET_VSX"
5355 "xsmaxdp %x0,%x1,%x2"
5356 [(set_attr "type" "fp")])
5358 (define_expand "smin<mode>3"
5359 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5360 (if_then_else:SFDF (ge (match_operand:SFDF 1 "gpc_reg_operand" "")
5361 (match_operand:SFDF 2 "gpc_reg_operand" ""))
5364 "TARGET_<MODE>_FPR && TARGET_PPC_GFXOPT && !flag_trapping_math"
5366 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
5370 (define_insn "*smin<mode>3_vsx"
5371 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5372 (smin:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
5373 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
5374 "TARGET_<MODE>_FPR && TARGET_VSX"
5375 "xsmindp %x0,%x1,%x2"
5376 [(set_attr "type" "fp")])
5379 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5380 (match_operator:SFDF 3 "min_max_operator"
5381 [(match_operand:SFDF 1 "gpc_reg_operand" "")
5382 (match_operand:SFDF 2 "gpc_reg_operand" "")]))]
5383 "TARGET_<MODE>_FPR && TARGET_PPC_GFXOPT && !flag_trapping_math
5387 rs6000_emit_minmax (operands[0], GET_CODE (operands[3]), operands[1],
5393 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5394 (match_operator:SF 3 "min_max_operator"
5395 [(match_operand:SF 1 "gpc_reg_operand" "")
5396 (match_operand:SF 2 "gpc_reg_operand" "")]))]
5397 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS
5398 && TARGET_SINGLE_FLOAT && !flag_trapping_math"
5401 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
5402 operands[1], operands[2]);
5406 (define_expand "mov<mode>cc"
5407 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
5408 (if_then_else:GPR (match_operand 1 "comparison_operator" "")
5409 (match_operand:GPR 2 "gpc_reg_operand" "")
5410 (match_operand:GPR 3 "gpc_reg_operand" "")))]
5414 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5420 ;; We use the BASE_REGS for the isel input operands because, if rA is
5421 ;; 0, the value of 0 is placed in rD upon truth. Similarly for rB
5422 ;; because we may switch the operands and rB may end up being rA.
5424 ;; We need 2 patterns: an unsigned and a signed pattern. We could
5425 ;; leave out the mode in operand 4 and use one pattern, but reload can
5426 ;; change the mode underneath our feet and then gets confused trying
5427 ;; to reload the value.
5428 (define_insn "isel_signed_<mode>"
5429 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
5431 (match_operator 1 "scc_comparison_operator"
5432 [(match_operand:CC 4 "cc_reg_operand" "y,y")
5434 (match_operand:GPR 2 "reg_or_cint_operand" "O,b")
5435 (match_operand:GPR 3 "gpc_reg_operand" "r,r")))]
5438 { return output_isel (operands); }"
5439 [(set_attr "type" "isel")
5440 (set_attr "length" "4")])
5442 (define_insn "isel_unsigned_<mode>"
5443 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
5445 (match_operator 1 "scc_comparison_operator"
5446 [(match_operand:CCUNS 4 "cc_reg_operand" "y,y")
5448 (match_operand:GPR 2 "reg_or_cint_operand" "O,b")
5449 (match_operand:GPR 3 "gpc_reg_operand" "r,r")))]
5452 { return output_isel (operands); }"
5453 [(set_attr "type" "isel")
5454 (set_attr "length" "4")])
5456 ;; These patterns can be useful for combine; they let combine know that
5457 ;; isel can handle reversed comparisons so long as the operands are
5460 (define_insn "*isel_reversed_signed_<mode>"
5461 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
5463 (match_operator 1 "scc_rev_comparison_operator"
5464 [(match_operand:CC 4 "cc_reg_operand" "y")
5466 (match_operand:GPR 2 "gpc_reg_operand" "b")
5467 (match_operand:GPR 3 "gpc_reg_operand" "b")))]
5470 { return output_isel (operands); }"
5471 [(set_attr "type" "isel")
5472 (set_attr "length" "4")])
5474 (define_insn "*isel_reversed_unsigned_<mode>"
5475 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
5477 (match_operator 1 "scc_rev_comparison_operator"
5478 [(match_operand:CCUNS 4 "cc_reg_operand" "y")
5480 (match_operand:GPR 2 "gpc_reg_operand" "b")
5481 (match_operand:GPR 3 "gpc_reg_operand" "b")))]
5484 { return output_isel (operands); }"
5485 [(set_attr "type" "isel")
5486 (set_attr "length" "4")])
5488 (define_expand "movsfcc"
5489 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5490 (if_then_else:SF (match_operand 1 "comparison_operator" "")
5491 (match_operand:SF 2 "gpc_reg_operand" "")
5492 (match_operand:SF 3 "gpc_reg_operand" "")))]
5493 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
5496 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5502 (define_insn "*fselsfsf4"
5503 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5504 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5505 (match_operand:SF 4 "zero_fp_constant" "F"))
5506 (match_operand:SF 2 "gpc_reg_operand" "f")
5507 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5508 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
5510 [(set_attr "type" "fp")])
5512 (define_insn "*fseldfsf4"
5513 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5514 (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "d")
5515 (match_operand:DF 4 "zero_fp_constant" "F"))
5516 (match_operand:SF 2 "gpc_reg_operand" "f")
5517 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5518 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_SINGLE_FLOAT"
5520 [(set_attr "type" "fp")])
5522 ;; The conditional move instructions allow us to perform max and min
5523 ;; operations even when
5526 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5527 (match_operator:DF 3 "min_max_operator"
5528 [(match_operand:DF 1 "gpc_reg_operand" "")
5529 (match_operand:DF 2 "gpc_reg_operand" "")]))]
5530 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
5531 && !flag_trapping_math"
5534 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
5535 operands[1], operands[2]);
5539 (define_expand "movdfcc"
5540 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5541 (if_then_else:DF (match_operand 1 "comparison_operator" "")
5542 (match_operand:DF 2 "gpc_reg_operand" "")
5543 (match_operand:DF 3 "gpc_reg_operand" "")))]
5544 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5547 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5553 (define_insn "*fseldfdf4"
5554 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
5555 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "d")
5556 (match_operand:DF 4 "zero_fp_constant" "F"))
5557 (match_operand:DF 2 "gpc_reg_operand" "d")
5558 (match_operand:DF 3 "gpc_reg_operand" "d")))]
5559 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5561 [(set_attr "type" "fp")])
5563 (define_insn "*fselsfdf4"
5564 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
5565 (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5566 (match_operand:SF 4 "zero_fp_constant" "F"))
5567 (match_operand:DF 2 "gpc_reg_operand" "d")
5568 (match_operand:DF 3 "gpc_reg_operand" "d")))]
5569 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_SINGLE_FLOAT"
5571 [(set_attr "type" "fp")])
5573 ;; Conversions to and from floating-point.
5575 ; We don't define lfiwax/lfiwzx with the normal definition, because we
5576 ; don't want to support putting SImode in FPR registers.
5577 (define_insn "lfiwax"
5578 [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wj,!wj")
5579 (unspec:DI [(match_operand:SI 1 "reg_or_indexed_operand" "Z,Z,r")]
5581 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWAX"
5586 [(set_attr "type" "fpload,fpload,mffgpr")])
5588 ; This split must be run before register allocation because it allocates the
5589 ; memory slot that is needed to move values to/from the FPR. We don't allocate
5590 ; it earlier to allow for the combiner to merge insns together where it might
5591 ; not be needed and also in case the insns are deleted as dead code.
5593 (define_insn_and_split "floatsi<mode>2_lfiwax"
5594 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Fv>")
5595 (float:SFDF (match_operand:SI 1 "nonimmediate_operand" "r")))
5596 (clobber (match_scratch:DI 2 "=wj"))]
5597 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWAX
5598 && <SI_CONVERT_FP> && can_create_pseudo_p ()"
5604 rtx dest = operands[0];
5605 rtx src = operands[1];
5608 if (!MEM_P (src) && TARGET_POWERPC64
5609 && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
5610 tmp = convert_to_mode (DImode, src, false);
5614 if (GET_CODE (tmp) == SCRATCH)
5615 tmp = gen_reg_rtx (DImode);
5618 src = rs6000_address_for_fpconvert (src);
5619 emit_insn (gen_lfiwax (tmp, src));
5623 rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5624 emit_move_insn (stack, src);
5625 emit_insn (gen_lfiwax (tmp, stack));
5628 emit_insn (gen_floatdi<mode>2 (dest, tmp));
5631 [(set_attr "length" "12")
5632 (set_attr "type" "fpload")])
5634 (define_insn_and_split "floatsi<mode>2_lfiwax_mem"
5635 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fa>")
5638 (match_operand:SI 1 "indexed_or_indirect_operand" "Z,Z"))))
5639 (clobber (match_scratch:DI 2 "=0,d"))]
5640 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWAX
5647 operands[1] = rs6000_address_for_fpconvert (operands[1]);
5648 if (GET_CODE (operands[2]) == SCRATCH)
5649 operands[2] = gen_reg_rtx (DImode);
5650 emit_insn (gen_lfiwax (operands[2], operands[1]));
5651 emit_insn (gen_floatdi<mode>2 (operands[0], operands[2]));
5654 [(set_attr "length" "8")
5655 (set_attr "type" "fpload")])
5657 (define_insn "lfiwzx"
5658 [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wj,!wj")
5659 (unspec:DI [(match_operand:SI 1 "reg_or_indexed_operand" "Z,Z,r")]
5661 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWZX"
5666 [(set_attr "type" "fpload,fpload,mftgpr")])
5668 (define_insn_and_split "floatunssi<mode>2_lfiwzx"
5669 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Fv>")
5670 (unsigned_float:SFDF (match_operand:SI 1 "nonimmediate_operand" "r")))
5671 (clobber (match_scratch:DI 2 "=wj"))]
5672 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWZX
5679 rtx dest = operands[0];
5680 rtx src = operands[1];
5683 if (!MEM_P (src) && TARGET_POWERPC64
5684 && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
5685 tmp = convert_to_mode (DImode, src, true);
5689 if (GET_CODE (tmp) == SCRATCH)
5690 tmp = gen_reg_rtx (DImode);
5693 src = rs6000_address_for_fpconvert (src);
5694 emit_insn (gen_lfiwzx (tmp, src));
5698 rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5699 emit_move_insn (stack, src);
5700 emit_insn (gen_lfiwzx (tmp, stack));
5703 emit_insn (gen_floatdi<mode>2 (dest, tmp));
5706 [(set_attr "length" "12")
5707 (set_attr "type" "fpload")])
5709 (define_insn_and_split "floatunssi<mode>2_lfiwzx_mem"
5710 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fa>")
5711 (unsigned_float:SFDF
5713 (match_operand:SI 1 "indexed_or_indirect_operand" "Z,Z"))))
5714 (clobber (match_scratch:DI 2 "=0,d"))]
5715 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWZX
5722 operands[1] = rs6000_address_for_fpconvert (operands[1]);
5723 if (GET_CODE (operands[2]) == SCRATCH)
5724 operands[2] = gen_reg_rtx (DImode);
5725 emit_insn (gen_lfiwzx (operands[2], operands[1]));
5726 emit_insn (gen_floatdi<mode>2 (operands[0], operands[2]));
5729 [(set_attr "length" "8")
5730 (set_attr "type" "fpload")])
5732 ; For each of these conversions, there is a define_expand, a define_insn
5733 ; with a '#' template, and a define_split (with C code). The idea is
5734 ; to allow constant folding with the template of the define_insn,
5735 ; then to have the insns split later (between sched1 and final).
5737 (define_expand "floatsidf2"
5738 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5739 (float:DF (match_operand:SI 1 "nonimmediate_operand" "")))
5742 (clobber (match_dup 4))
5743 (clobber (match_dup 5))
5744 (clobber (match_dup 6))])]
5746 && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
5749 if (TARGET_E500_DOUBLE)
5751 if (!REG_P (operands[1]))
5752 operands[1] = force_reg (SImode, operands[1]);
5753 emit_insn (gen_spe_floatsidf2 (operands[0], operands[1]));
5756 else if (TARGET_LFIWAX && TARGET_FCFID)
5758 emit_insn (gen_floatsidf2_lfiwax (operands[0], operands[1]));
5761 else if (TARGET_FCFID)
5763 rtx dreg = operands[1];
5765 dreg = force_reg (SImode, dreg);
5766 dreg = convert_to_mode (DImode, dreg, false);
5767 emit_insn (gen_floatdidf2 (operands[0], dreg));
5771 if (!REG_P (operands[1]))
5772 operands[1] = force_reg (SImode, operands[1]);
5773 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5774 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503601774854144\", DFmode));
5775 operands[4] = rs6000_allocate_stack_temp (DFmode, true, false);
5776 operands[5] = gen_reg_rtx (DFmode);
5777 operands[6] = gen_reg_rtx (SImode);
5780 (define_insn_and_split "*floatsidf2_internal"
5781 [(set (match_operand:DF 0 "gpc_reg_operand" "=&d")
5782 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5783 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5784 (use (match_operand:DF 3 "gpc_reg_operand" "d"))
5785 (clobber (match_operand:DF 4 "offsettable_mem_operand" "=o"))
5786 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&d"))
5787 (clobber (match_operand:SI 6 "gpc_reg_operand" "=&r"))]
5788 "! TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5794 rtx lowword, highword;
5795 gcc_assert (MEM_P (operands[4]));
5796 highword = adjust_address (operands[4], SImode, 0);
5797 lowword = adjust_address (operands[4], SImode, 4);
5798 if (! WORDS_BIG_ENDIAN)
5799 std::swap (lowword, highword);
5801 emit_insn (gen_xorsi3 (operands[6], operands[1],
5802 GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
5803 emit_move_insn (lowword, operands[6]);
5804 emit_move_insn (highword, operands[2]);
5805 emit_move_insn (operands[5], operands[4]);
5806 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5809 [(set_attr "length" "24")
5810 (set_attr "type" "fp")])
5812 ;; If we don't have a direct conversion to single precision, don't enable this
5813 ;; conversion for 32-bit without fast math, because we don't have the insn to
5814 ;; generate the fixup swizzle to avoid double rounding problems.
5815 (define_expand "floatunssisf2"
5816 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5817 (unsigned_float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
5818 "TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT
5821 && ((TARGET_FCFIDUS && TARGET_LFIWZX)
5822 || (TARGET_DOUBLE_FLOAT && TARGET_FCFID
5823 && (TARGET_POWERPC64 || flag_unsafe_math_optimizations)))))"
5828 if (!REG_P (operands[1]))
5829 operands[1] = force_reg (SImode, operands[1]);
5831 else if (TARGET_LFIWZX && TARGET_FCFIDUS)
5833 emit_insn (gen_floatunssisf2_lfiwzx (operands[0], operands[1]));
5838 rtx dreg = operands[1];
5840 dreg = force_reg (SImode, dreg);
5841 dreg = convert_to_mode (DImode, dreg, true);
5842 emit_insn (gen_floatdisf2 (operands[0], dreg));
5847 (define_expand "floatunssidf2"
5848 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5849 (unsigned_float:DF (match_operand:SI 1 "nonimmediate_operand" "")))
5852 (clobber (match_dup 4))
5853 (clobber (match_dup 5))])]
5855 && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
5858 if (TARGET_E500_DOUBLE)
5860 if (!REG_P (operands[1]))
5861 operands[1] = force_reg (SImode, operands[1]);
5862 emit_insn (gen_spe_floatunssidf2 (operands[0], operands[1]));
5865 else if (TARGET_LFIWZX && TARGET_FCFID)
5867 emit_insn (gen_floatunssidf2_lfiwzx (operands[0], operands[1]));
5870 else if (TARGET_FCFID)
5872 rtx dreg = operands[1];
5874 dreg = force_reg (SImode, dreg);
5875 dreg = convert_to_mode (DImode, dreg, true);
5876 emit_insn (gen_floatdidf2 (operands[0], dreg));
5880 if (!REG_P (operands[1]))
5881 operands[1] = force_reg (SImode, operands[1]);
5882 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5883 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503599627370496\", DFmode));
5884 operands[4] = rs6000_allocate_stack_temp (DFmode, true, false);
5885 operands[5] = gen_reg_rtx (DFmode);
5888 (define_insn_and_split "*floatunssidf2_internal"
5889 [(set (match_operand:DF 0 "gpc_reg_operand" "=&d")
5890 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5891 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5892 (use (match_operand:DF 3 "gpc_reg_operand" "d"))
5893 (clobber (match_operand:DF 4 "offsettable_mem_operand" "=o"))
5894 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&d"))]
5895 "! TARGET_FCFIDU && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
5896 && !(TARGET_FCFID && TARGET_POWERPC64)"
5902 rtx lowword, highword;
5903 gcc_assert (MEM_P (operands[4]));
5904 highword = adjust_address (operands[4], SImode, 0);
5905 lowword = adjust_address (operands[4], SImode, 4);
5906 if (! WORDS_BIG_ENDIAN)
5907 std::swap (lowword, highword);
5909 emit_move_insn (lowword, operands[1]);
5910 emit_move_insn (highword, operands[2]);
5911 emit_move_insn (operands[5], operands[4]);
5912 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5915 [(set_attr "length" "20")
5916 (set_attr "type" "fp")])
5918 (define_expand "fix_trunc<mode>si2"
5919 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5920 (fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "")))]
5921 "TARGET_HARD_FLOAT && ((TARGET_FPRS && <TARGET_FLOAT>) || <E500_CONVERT>)"
5924 if (!<E500_CONVERT>)
5929 emit_insn (gen_fix_trunc<mode>si2_stfiwx (operands[0], operands[1]));
5932 tmp = gen_reg_rtx (DImode);
5933 stack = rs6000_allocate_stack_temp (DImode, true, false);
5934 emit_insn (gen_fix_trunc<mode>si2_internal (operands[0], operands[1],
5941 ; Like the convert to float patterns, this insn must be split before
5942 ; register allocation so that it can allocate the memory slot if it
5944 (define_insn_and_split "fix_trunc<mode>si2_stfiwx"
5945 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5946 (fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d")))
5947 (clobber (match_scratch:DI 2 "=d"))]
5948 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
5949 && (<MODE>mode != SFmode || TARGET_SINGLE_FLOAT)
5950 && TARGET_STFIWX && can_create_pseudo_p ()"
5955 rtx dest = operands[0];
5956 rtx src = operands[1];
5957 rtx tmp = operands[2];
5959 if (GET_CODE (tmp) == SCRATCH)
5960 tmp = gen_reg_rtx (DImode);
5962 emit_insn (gen_fctiwz_<mode> (tmp, src));
5965 dest = rs6000_address_for_fpconvert (dest);
5966 emit_insn (gen_stfiwx (dest, tmp));
5969 else if (TARGET_POWERPC64 && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
5971 dest = gen_lowpart (DImode, dest);
5972 emit_move_insn (dest, tmp);
5977 rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5978 emit_insn (gen_stfiwx (stack, tmp));
5979 emit_move_insn (dest, stack);
5983 [(set_attr "length" "12")
5984 (set_attr "type" "fp")])
5986 (define_insn_and_split "fix_trunc<mode>si2_internal"
5987 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,?r")
5988 (fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d,<rreg>")))
5989 (clobber (match_operand:DI 2 "gpc_reg_operand" "=1,d"))
5990 (clobber (match_operand:DI 3 "offsettable_mem_operand" "=o,o"))]
5991 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5998 gcc_assert (MEM_P (operands[3]));
5999 lowword = adjust_address (operands[3], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
6001 emit_insn (gen_fctiwz_<mode> (operands[2], operands[1]));
6002 emit_move_insn (operands[3], operands[2]);
6003 emit_move_insn (operands[0], lowword);
6006 [(set_attr "length" "16")
6007 (set_attr "type" "fp")])
6009 (define_expand "fix_trunc<mode>di2"
6010 [(set (match_operand:DI 0 "gpc_reg_operand" "")
6011 (fix:DI (match_operand:SFDF 1 "gpc_reg_operand" "")))]
6012 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS
6016 (define_insn "*fix_trunc<mode>di2_fctidz"
6017 [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wi")
6018 (fix:DI (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fa>")))]
6019 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS
6024 [(set_attr "type" "fp")])
6026 (define_expand "fixuns_trunc<mode>si2"
6027 [(set (match_operand:SI 0 "gpc_reg_operand" "")
6028 (unsigned_fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "")))]
6030 && ((TARGET_FPRS && <TARGET_FLOAT> && TARGET_FCTIWUZ && TARGET_STFIWX)
6034 if (!<E500_CONVERT>)
6036 emit_insn (gen_fixuns_trunc<mode>si2_stfiwx (operands[0], operands[1]));
6041 (define_insn_and_split "fixuns_trunc<mode>si2_stfiwx"
6042 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
6043 (unsigned_fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d")))
6044 (clobber (match_scratch:DI 2 "=d"))]
6045 "TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT> && TARGET_FCTIWUZ
6046 && TARGET_STFIWX && can_create_pseudo_p ()"
6051 rtx dest = operands[0];
6052 rtx src = operands[1];
6053 rtx tmp = operands[2];
6055 if (GET_CODE (tmp) == SCRATCH)
6056 tmp = gen_reg_rtx (DImode);
6058 emit_insn (gen_fctiwuz_<mode> (tmp, src));
6061 dest = rs6000_address_for_fpconvert (dest);
6062 emit_insn (gen_stfiwx (dest, tmp));
6065 else if (TARGET_POWERPC64 && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
6067 dest = gen_lowpart (DImode, dest);
6068 emit_move_insn (dest, tmp);
6073 rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
6074 emit_insn (gen_stfiwx (stack, tmp));
6075 emit_move_insn (dest, stack);
6079 [(set_attr "length" "12")
6080 (set_attr "type" "fp")])
6082 (define_expand "fixuns_trunc<mode>di2"
6083 [(set (match_operand:DI 0 "register_operand" "")
6084 (unsigned_fix:DI (match_operand:SFDF 1 "register_operand" "")))]
6085 "TARGET_HARD_FLOAT && (TARGET_FCTIDUZ || VECTOR_UNIT_VSX_P (<MODE>mode))"
6088 (define_insn "*fixuns_trunc<mode>di2_fctiduz"
6089 [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wi")
6090 (unsigned_fix:DI (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fa>")))]
6091 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS
6096 [(set_attr "type" "fp")])
6098 ; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] UNSPEC_FCTIWZ))
6099 ; rather than (set (subreg:SI (reg)) (fix:SI ...))
6100 ; because the first makes it clear that operand 0 is not live
6101 ; before the instruction.
6102 (define_insn "fctiwz_<mode>"
6103 [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wi")
6104 (unspec:DI [(fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>"))]
6106 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
6110 [(set_attr "type" "fp")])
6112 (define_insn "fctiwuz_<mode>"
6113 [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wi")
6114 (unspec:DI [(unsigned_fix:SI
6115 (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>"))]
6117 "TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT> && TARGET_FCTIWUZ"
6121 [(set_attr "type" "fp")])
6123 ;; Only optimize (float (fix x)) -> frz if we are in fast-math mode, since
6124 ;; since the friz instruction does not truncate the value if the floating
6125 ;; point value is < LONG_MIN or > LONG_MAX.
6126 (define_insn "*friz"
6127 [(set (match_operand:DF 0 "gpc_reg_operand" "=d,ws")
6128 (float:DF (fix:DI (match_operand:DF 1 "gpc_reg_operand" "d,ws"))))]
6129 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_FPRND
6130 && flag_unsafe_math_optimizations && !flag_trapping_math && TARGET_FRIZ"
6134 [(set_attr "type" "fp")])
6136 ;; Since FCTIWZ doesn't sign extend the upper bits, we have to do a store and a
6137 ;; load to properly sign extend the value, but at least doing a store, load
6138 ;; into a GPR to sign extend, a store from the GPR and a load back into the FPR
6139 ;; if we have 32-bit memory ops
6140 (define_insn_and_split "*round32<mode>2_fprs"
6141 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d")
6143 (fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d"))))
6144 (clobber (match_scratch:DI 2 "=d"))
6145 (clobber (match_scratch:DI 3 "=d"))]
6146 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
6147 && <SI_CONVERT_FP> && TARGET_LFIWAX && TARGET_STFIWX && TARGET_FCFID
6148 && can_create_pseudo_p ()"
6153 rtx dest = operands[0];
6154 rtx src = operands[1];
6155 rtx tmp1 = operands[2];
6156 rtx tmp2 = operands[3];
6157 rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
6159 if (GET_CODE (tmp1) == SCRATCH)
6160 tmp1 = gen_reg_rtx (DImode);
6161 if (GET_CODE (tmp2) == SCRATCH)
6162 tmp2 = gen_reg_rtx (DImode);
6164 emit_insn (gen_fctiwz_<mode> (tmp1, src));
6165 emit_insn (gen_stfiwx (stack, tmp1));
6166 emit_insn (gen_lfiwax (tmp2, stack));
6167 emit_insn (gen_floatdi<mode>2 (dest, tmp2));
6170 [(set_attr "type" "fpload")
6171 (set_attr "length" "16")])
6173 (define_insn_and_split "*roundu32<mode>2_fprs"
6174 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d")
6175 (unsigned_float:SFDF
6176 (unsigned_fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d"))))
6177 (clobber (match_scratch:DI 2 "=d"))
6178 (clobber (match_scratch:DI 3 "=d"))]
6179 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
6180 && TARGET_LFIWZX && TARGET_STFIWX && TARGET_FCFIDU
6181 && can_create_pseudo_p ()"
6186 rtx dest = operands[0];
6187 rtx src = operands[1];
6188 rtx tmp1 = operands[2];
6189 rtx tmp2 = operands[3];
6190 rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
6192 if (GET_CODE (tmp1) == SCRATCH)
6193 tmp1 = gen_reg_rtx (DImode);
6194 if (GET_CODE (tmp2) == SCRATCH)
6195 tmp2 = gen_reg_rtx (DImode);
6197 emit_insn (gen_fctiwuz_<mode> (tmp1, src));
6198 emit_insn (gen_stfiwx (stack, tmp1));
6199 emit_insn (gen_lfiwzx (tmp2, stack));
6200 emit_insn (gen_floatdi<mode>2 (dest, tmp2));
6203 [(set_attr "type" "fpload")
6204 (set_attr "length" "16")])
6206 ;; No VSX equivalent to fctid
6207 (define_insn "lrint<mode>di2"
6208 [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
6209 (unspec:DI [(match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>")]
6211 "TARGET_<MODE>_FPR && TARGET_FPRND"
6213 [(set_attr "type" "fp")])
6215 (define_insn "btrunc<mode>2"
6216 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
6217 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
6219 "TARGET_<MODE>_FPR && TARGET_FPRND"
6223 [(set_attr "type" "fp")
6224 (set_attr "fp_type" "fp_addsub_<Fs>")])
6226 (define_insn "ceil<mode>2"
6227 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
6228 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
6230 "TARGET_<MODE>_FPR && TARGET_FPRND"
6234 [(set_attr "type" "fp")
6235 (set_attr "fp_type" "fp_addsub_<Fs>")])
6237 (define_insn "floor<mode>2"
6238 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
6239 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
6241 "TARGET_<MODE>_FPR && TARGET_FPRND"
6245 [(set_attr "type" "fp")
6246 (set_attr "fp_type" "fp_addsub_<Fs>")])
6248 ;; No VSX equivalent to frin
6249 (define_insn "round<mode>2"
6250 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<rreg2>")
6251 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>")]
6253 "TARGET_<MODE>_FPR && TARGET_FPRND"
6255 [(set_attr "type" "fp")
6256 (set_attr "fp_type" "fp_addsub_<Fs>")])
6258 ; An UNSPEC is used so we don't have to support SImode in FP registers.
6259 (define_insn "stfiwx"
6260 [(set (match_operand:SI 0 "memory_operand" "=Z")
6261 (unspec:SI [(match_operand:DI 1 "gpc_reg_operand" "d")]
6265 [(set_attr "type" "fpstore")])
6267 ;; If we don't have a direct conversion to single precision, don't enable this
6268 ;; conversion for 32-bit without fast math, because we don't have the insn to
6269 ;; generate the fixup swizzle to avoid double rounding problems.
6270 (define_expand "floatsisf2"
6271 [(set (match_operand:SF 0 "gpc_reg_operand" "")
6272 (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
6273 "TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT
6276 && ((TARGET_FCFIDS && TARGET_LFIWAX)
6277 || (TARGET_DOUBLE_FLOAT && TARGET_FCFID
6278 && (TARGET_POWERPC64 || flag_unsafe_math_optimizations)))))"
6283 if (!REG_P (operands[1]))
6284 operands[1] = force_reg (SImode, operands[1]);
6286 else if (TARGET_FCFIDS && TARGET_LFIWAX)
6288 emit_insn (gen_floatsisf2_lfiwax (operands[0], operands[1]));
6291 else if (TARGET_FCFID && TARGET_LFIWAX)
6293 rtx dfreg = gen_reg_rtx (DFmode);
6294 emit_insn (gen_floatsidf2_lfiwax (dfreg, operands[1]));
6295 emit_insn (gen_truncdfsf2 (operands[0], dfreg));
6300 rtx dreg = operands[1];
6302 dreg = force_reg (SImode, dreg);
6303 dreg = convert_to_mode (DImode, dreg, false);
6304 emit_insn (gen_floatdisf2 (operands[0], dreg));
6309 (define_expand "floatdidf2"
6310 [(set (match_operand:DF 0 "gpc_reg_operand" "")
6311 (float:DF (match_operand:DI 1 "gpc_reg_operand" "")))]
6312 "TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS"
6315 (define_insn "*floatdidf2_fpr"
6316 [(set (match_operand:DF 0 "gpc_reg_operand" "=d,ws")
6317 (float:DF (match_operand:DI 1 "gpc_reg_operand" "d,wi")))]
6318 "TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS"
6322 [(set_attr "type" "fp")])
6324 ; Allow the combiner to merge source memory operands to the conversion so that
6325 ; the optimizer/register allocator doesn't try to load the value too early in a
6326 ; GPR and then use store/load to move it to a FPR and suffer from a store-load
6327 ; hit. We will split after reload to avoid the trip through the GPRs
6329 (define_insn_and_split "*floatdidf2_mem"
6330 [(set (match_operand:DF 0 "gpc_reg_operand" "=d,ws")
6331 (float:DF (match_operand:DI 1 "memory_operand" "m,Z")))
6332 (clobber (match_scratch:DI 2 "=d,wi"))]
6333 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS && TARGET_FCFID"
6335 "&& reload_completed"
6336 [(set (match_dup 2) (match_dup 1))
6337 (set (match_dup 0) (float:DF (match_dup 2)))]
6339 [(set_attr "length" "8")
6340 (set_attr "type" "fpload")])
6342 (define_expand "floatunsdidf2"
6343 [(set (match_operand:DF 0 "gpc_reg_operand" "")
6345 (match_operand:DI 1 "gpc_reg_operand" "")))]
6346 "TARGET_HARD_FLOAT && TARGET_FCFIDU"
6349 (define_insn "*floatunsdidf2_fcfidu"
6350 [(set (match_operand:DF 0 "gpc_reg_operand" "=d,ws")
6351 (unsigned_float:DF (match_operand:DI 1 "gpc_reg_operand" "d,wi")))]
6352 "TARGET_HARD_FLOAT && TARGET_FCFIDU"
6356 [(set_attr "type" "fp")
6357 (set_attr "length" "4")])
6359 (define_insn_and_split "*floatunsdidf2_mem"
6360 [(set (match_operand:DF 0 "gpc_reg_operand" "=d,ws")
6361 (unsigned_float:DF (match_operand:DI 1 "memory_operand" "m,Z")))
6362 (clobber (match_scratch:DI 2 "=d,wi"))]
6363 "TARGET_HARD_FLOAT && (TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode))"
6365 "&& reload_completed"
6366 [(set (match_dup 2) (match_dup 1))
6367 (set (match_dup 0) (unsigned_float:DF (match_dup 2)))]
6369 [(set_attr "length" "8")
6370 (set_attr "type" "fpload")])
6372 (define_expand "floatdisf2"
6373 [(set (match_operand:SF 0 "gpc_reg_operand" "")
6374 (float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
6375 "TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6376 && (TARGET_FCFIDS || TARGET_POWERPC64 || flag_unsafe_math_optimizations)"
6381 rtx val = operands[1];
6382 if (!flag_unsafe_math_optimizations)
6384 rtx label = gen_label_rtx ();
6385 val = gen_reg_rtx (DImode);
6386 emit_insn (gen_floatdisf2_internal2 (val, operands[1], label));
6389 emit_insn (gen_floatdisf2_internal1 (operands[0], val));
6394 (define_insn "floatdisf2_fcfids"
6395 [(set (match_operand:SF 0 "gpc_reg_operand" "=f,wy")
6396 (float:SF (match_operand:DI 1 "gpc_reg_operand" "d,wi")))]
6397 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6398 && TARGET_DOUBLE_FLOAT && TARGET_FCFIDS"
6402 [(set_attr "type" "fp")])
6404 (define_insn_and_split "*floatdisf2_mem"
6405 [(set (match_operand:SF 0 "gpc_reg_operand" "=f,wy,wy")
6406 (float:SF (match_operand:DI 1 "memory_operand" "m,m,Z")))
6407 (clobber (match_scratch:DI 2 "=d,d,wi"))]
6408 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6409 && TARGET_DOUBLE_FLOAT && TARGET_FCFIDS"
6411 "&& reload_completed"
6415 emit_move_insn (operands[2], operands[1]);
6416 emit_insn (gen_floatdisf2_fcfids (operands[0], operands[2]));
6419 [(set_attr "length" "8")])
6421 ;; This is not IEEE compliant if rounding mode is "round to nearest".
6422 ;; If the DI->DF conversion is inexact, then it's possible to suffer
6423 ;; from double rounding.
6424 ;; Instead of creating a new cpu type for two FP operations, just use fp
6425 (define_insn_and_split "floatdisf2_internal1"
6426 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6427 (float:SF (match_operand:DI 1 "gpc_reg_operand" "d")))
6428 (clobber (match_scratch:DF 2 "=d"))]
6429 "TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6432 "&& reload_completed"
6434 (float:DF (match_dup 1)))
6436 (float_truncate:SF (match_dup 2)))]
6438 [(set_attr "length" "8")
6439 (set_attr "type" "fp")])
6441 ;; Twiddles bits to avoid double rounding.
6442 ;; Bits that might be truncated when converting to DFmode are replaced
6443 ;; by a bit that won't be lost at that stage, but is below the SFmode
6444 ;; rounding position.
6445 (define_expand "floatdisf2_internal2"
6446 [(parallel [(set (match_dup 3) (ashiftrt:DI (match_operand:DI 1 "" "")
6448 (clobber (reg:DI CA_REGNO))])
6449 (set (match_operand:DI 0 "" "") (and:DI (match_dup 1)
6451 (set (match_dup 3) (plus:DI (match_dup 3)
6453 (set (match_dup 0) (plus:DI (match_dup 0)
6455 (set (match_dup 4) (compare:CCUNS (match_dup 3)
6457 (set (match_dup 0) (ior:DI (match_dup 0)
6459 (set (match_dup 0) (and:DI (match_dup 0)
6461 (set (pc) (if_then_else (geu (match_dup 4) (const_int 0))
6462 (label_ref (match_operand:DI 2 "" ""))
6464 (set (match_dup 0) (match_dup 1))]
6465 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6469 operands[3] = gen_reg_rtx (DImode);
6470 operands[4] = gen_reg_rtx (CCUNSmode);
6473 (define_expand "floatunsdisf2"
6474 [(set (match_operand:SF 0 "gpc_reg_operand" "")
6475 (unsigned_float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
6476 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6477 && TARGET_DOUBLE_FLOAT && TARGET_FCFIDUS"
6480 (define_insn "floatunsdisf2_fcfidus"
6481 [(set (match_operand:SF 0 "gpc_reg_operand" "=f,wu")
6482 (unsigned_float:SF (match_operand:DI 1 "gpc_reg_operand" "d,wi")))]
6483 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6484 && TARGET_DOUBLE_FLOAT && TARGET_FCFIDUS"
6488 [(set_attr "type" "fp")])
6490 (define_insn_and_split "*floatunsdisf2_mem"
6491 [(set (match_operand:SF 0 "gpc_reg_operand" "=f,wy,wy")
6492 (unsigned_float:SF (match_operand:DI 1 "memory_operand" "m,m,Z")))
6493 (clobber (match_scratch:DI 2 "=d,d,wi"))]
6494 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6495 && TARGET_DOUBLE_FLOAT && TARGET_FCFIDUS"
6497 "&& reload_completed"
6501 emit_move_insn (operands[2], operands[1]);
6502 emit_insn (gen_floatunsdisf2_fcfidus (operands[0], operands[2]));
6505 [(set_attr "length" "8")
6506 (set_attr "type" "fpload")])
6508 ;; Define the TImode operations that can be done in a small number
6509 ;; of instructions. The & constraints are to prevent the register
6510 ;; allocator from allocating registers that overlap with the inputs
6511 ;; (for example, having an input in 7,8 and an output in 6,7). We
6512 ;; also allow for the output being the same as one of the inputs.
6514 (define_expand "addti3"
6515 [(set (match_operand:TI 0 "gpc_reg_operand" "")
6516 (plus:TI (match_operand:TI 1 "gpc_reg_operand" "")
6517 (match_operand:TI 2 "reg_or_short_operand" "")))]
6520 rtx lo0 = gen_lowpart (DImode, operands[0]);
6521 rtx lo1 = gen_lowpart (DImode, operands[1]);
6522 rtx lo2 = gen_lowpart (DImode, operands[2]);
6523 rtx hi0 = gen_highpart (DImode, operands[0]);
6524 rtx hi1 = gen_highpart (DImode, operands[1]);
6525 rtx hi2 = gen_highpart_mode (DImode, TImode, operands[2]);
6527 if (!reg_or_short_operand (lo2, DImode))
6528 lo2 = force_reg (DImode, lo2);
6529 if (!adde_operand (hi2, DImode))
6530 hi2 = force_reg (DImode, hi2);
6532 emit_insn (gen_adddi3_carry (lo0, lo1, lo2));
6533 emit_insn (gen_adddi3_carry_in (hi0, hi1, hi2));
6537 (define_expand "subti3"
6538 [(set (match_operand:TI 0 "gpc_reg_operand" "")
6539 (minus:TI (match_operand:TI 1 "reg_or_short_operand" "")
6540 (match_operand:TI 2 "gpc_reg_operand" "")))]
6543 rtx lo0 = gen_lowpart (DImode, operands[0]);
6544 rtx lo1 = gen_lowpart (DImode, operands[1]);
6545 rtx lo2 = gen_lowpart (DImode, operands[2]);
6546 rtx hi0 = gen_highpart (DImode, operands[0]);
6547 rtx hi1 = gen_highpart_mode (DImode, TImode, operands[1]);
6548 rtx hi2 = gen_highpart (DImode, operands[2]);
6550 if (!reg_or_short_operand (lo1, DImode))
6551 lo1 = force_reg (DImode, lo1);
6552 if (!adde_operand (hi1, DImode))
6553 hi1 = force_reg (DImode, hi1);
6555 emit_insn (gen_subfdi3_carry (lo0, lo2, lo1));
6556 emit_insn (gen_subfdi3_carry_in (hi0, hi2, hi1));
6561 ;; Shift by a variable amount is too complex to be worth open-coding. We
6562 ;; just handle shifts by constants.
6563 (define_insn "ashrdi3_no_power"
6564 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
6565 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6566 (match_operand:SI 2 "const_int_operand" "M,i")))
6567 (clobber (reg:SI CA_REGNO))]
6570 switch (which_alternative)
6575 if (WORDS_BIG_ENDIAN)
6576 return \"srawi %0,%1,31\;srawi %L0,%1,%h2\";
6578 return \"srawi %L0,%L1,31\;srawi %0,%L1,%h2\";
6580 if (WORDS_BIG_ENDIAN)
6581 return \"srwi %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;srawi %0,%1,%h2\";
6583 return \"srwi %0,%1,%h2\;insrwi %0,%L1,%h2,0\;srawi %L0,%L1,%h2\";
6586 [(set_attr "type" "two,three")
6587 (set_attr "length" "8,12")])
6589 (define_insn "*ashrdisi3_noppc64be"
6590 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6591 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6592 (const_int 32)) 4))]
6593 "TARGET_32BIT && !TARGET_POWERPC64 && WORDS_BIG_ENDIAN"
6596 if (REGNO (operands[0]) == REGNO (operands[1]))
6599 return \"mr %0,%1\";
6601 [(set_attr "length" "4")])
6604 ;; PowerPC64 DImode operations.
6606 (define_insn "*rotldi3_internal4"
6607 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6608 (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6609 (match_operand:DI 2 "reg_or_cint_operand" "rn"))
6610 (match_operand:DI 3 "mask64_operand" "n")))]
6612 "rld%I2c%B3 %0,%1,%H2,%S3"
6613 [(set_attr "type" "shift")
6614 (set_attr "maybe_var_shift" "yes")])
6616 (define_insn "*rotldi3_internal5"
6617 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6619 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6620 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn"))
6621 (match_operand:DI 3 "mask64_operand" "n,n"))
6623 (clobber (match_scratch:DI 4 "=r,r"))]
6626 rld%I2c%B3. %4,%1,%H2,%S3
6628 [(set_attr "type" "shift")
6629 (set_attr "maybe_var_shift" "yes")
6630 (set_attr "dot" "yes")
6631 (set_attr "length" "4,8")])
6634 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6636 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6637 (match_operand:DI 2 "reg_or_cint_operand" ""))
6638 (match_operand:DI 3 "mask64_operand" ""))
6640 (clobber (match_scratch:DI 4 ""))]
6641 "TARGET_POWERPC64 && reload_completed"
6643 (and:DI (rotate:DI (match_dup 1)
6647 (compare:CC (match_dup 4)
6651 (define_insn "*rotldi3_internal6"
6652 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6654 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6655 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn"))
6656 (match_operand:DI 3 "mask64_operand" "n,n"))
6658 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6659 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6662 rld%I2c%B3. %0,%1,%H2,%S3
6664 [(set_attr "type" "shift")
6665 (set_attr "maybe_var_shift" "yes")
6666 (set_attr "dot" "yes")
6667 (set_attr "length" "4,8")])
6670 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
6672 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6673 (match_operand:DI 2 "reg_or_cint_operand" ""))
6674 (match_operand:DI 3 "mask64_operand" ""))
6676 (set (match_operand:DI 0 "gpc_reg_operand" "")
6677 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6678 "TARGET_POWERPC64 && reload_completed"
6680 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6682 (compare:CC (match_dup 0)
6686 (define_insn "*rotldi3_internal7le"
6687 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6690 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6691 (match_operand:DI 2 "reg_or_cint_operand" "rn")) 0)))]
6692 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN"
6693 "rld%I2cl %0,%1,%H2,56"
6694 [(set_attr "type" "shift")
6695 (set_attr "maybe_var_shift" "yes")])
6697 (define_insn "*rotldi3_internal7be"
6698 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6701 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6702 (match_operand:DI 2 "reg_or_cint_operand" "rn")) 7)))]
6703 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN"
6704 "rld%I2cl %0,%1,%H2,56"
6705 [(set_attr "type" "shift")
6706 (set_attr "maybe_var_shift" "yes")])
6708 (define_insn "*rotldi3_internal8le"
6709 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6710 (compare:CC (zero_extend:DI
6712 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6713 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6715 (clobber (match_scratch:DI 3 "=r,r"))]
6716 "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6718 rld%I2cl. %3,%1,%H2,56
6720 [(set_attr "type" "shift")
6721 (set_attr "maybe_var_shift" "yes")
6722 (set_attr "dot" "yes")
6723 (set_attr "length" "4,8")])
6725 (define_insn "*rotldi3_internal8be"
6726 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6727 (compare:CC (zero_extend:DI
6729 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6730 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 7))
6732 (clobber (match_scratch:DI 3 "=r,r"))]
6733 "TARGET_64BIT && BYTES_BIG_ENDIAN"
6735 rld%I2cl. %3,%1,%H2,56
6737 [(set_attr "type" "shift")
6738 (set_attr "maybe_var_shift" "yes")
6739 (set_attr "dot" "yes")
6740 (set_attr "length" "4,8")])
6743 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6744 (compare:CC (zero_extend:DI
6746 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6747 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6749 (clobber (match_scratch:DI 3 ""))]
6750 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6752 (zero_extend:DI (subreg:QI
6753 (rotate:DI (match_dup 1)
6756 (compare:CC (match_dup 3)
6761 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6762 (compare:CC (zero_extend:DI
6764 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6765 (match_operand:DI 2 "reg_or_cint_operand" "")) 7))
6767 (clobber (match_scratch:DI 3 ""))]
6768 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6770 (zero_extend:DI (subreg:QI
6771 (rotate:DI (match_dup 1)
6774 (compare:CC (match_dup 3)
6778 (define_insn "*rotldi3_internal9le"
6779 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6780 (compare:CC (zero_extend:DI
6782 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6783 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6785 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6786 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6787 "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6789 rld%I2cl. %0,%1,%H2,56
6791 [(set_attr "type" "shift")
6792 (set_attr "maybe_var_shift" "yes")
6793 (set_attr "dot" "yes")
6794 (set_attr "length" "4,8")])
6796 (define_insn "*rotldi3_internal9be"
6797 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6798 (compare:CC (zero_extend:DI
6800 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6801 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 7))
6803 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6804 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 7)))]
6805 "TARGET_64BIT && BYTES_BIG_ENDIAN"
6807 rld%I2cl. %0,%1,%H2,56
6809 [(set_attr "type" "shift")
6810 (set_attr "maybe_var_shift" "yes")
6811 (set_attr "dot" "yes")
6812 (set_attr "length" "4,8")])
6815 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6816 (compare:CC (zero_extend:DI
6818 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6819 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6821 (set (match_operand:DI 0 "gpc_reg_operand" "")
6822 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6823 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6825 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6827 (compare:CC (match_dup 0)
6832 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6833 (compare:CC (zero_extend:DI
6835 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6836 (match_operand:DI 2 "reg_or_cint_operand" "")) 7))
6838 (set (match_operand:DI 0 "gpc_reg_operand" "")
6839 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 7)))]
6840 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6842 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 7)))
6844 (compare:CC (match_dup 0)
6848 (define_insn "*rotldi3_internal10le"
6849 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6852 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6853 (match_operand:DI 2 "reg_or_cint_operand" "rn")) 0)))]
6854 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN"
6855 "rld%I2cl %0,%1,%H2,48"
6856 [(set_attr "type" "shift")
6857 (set_attr "maybe_var_shift" "yes")])
6859 (define_insn "*rotldi3_internal10be"
6860 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6863 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6864 (match_operand:DI 2 "reg_or_cint_operand" "rn")) 6)))]
6865 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN"
6866 "rld%I2cl %0,%1,%H2,48"
6867 [(set_attr "type" "shift")
6868 (set_attr "maybe_var_shift" "yes")])
6870 (define_insn "*rotldi3_internal11le"
6871 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6872 (compare:CC (zero_extend:DI
6874 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6875 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6877 (clobber (match_scratch:DI 3 "=r,r"))]
6878 "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6880 rld%I2cl. %3,%1,%H2,48
6882 [(set_attr "type" "shift")
6883 (set_attr "maybe_var_shift" "yes")
6884 (set_attr "dot" "yes")
6885 (set_attr "length" "4,8")])
6887 (define_insn "*rotldi3_internal11be"
6888 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6889 (compare:CC (zero_extend:DI
6891 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6892 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 6))
6894 (clobber (match_scratch:DI 3 "=r,r"))]
6895 "TARGET_64BIT && BYTES_BIG_ENDIAN"
6897 rld%I2cl. %3,%1,%H2,48
6899 [(set_attr "type" "shift")
6900 (set_attr "maybe_var_shift" "yes")
6901 (set_attr "dot" "yes")
6902 (set_attr "length" "4,8")])
6905 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6906 (compare:CC (zero_extend:DI
6908 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6909 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6911 (clobber (match_scratch:DI 3 ""))]
6912 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6914 (zero_extend:DI (subreg:HI
6915 (rotate:DI (match_dup 1)
6918 (compare:CC (match_dup 3)
6923 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6924 (compare:CC (zero_extend:DI
6926 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6927 (match_operand:DI 2 "reg_or_cint_operand" "")) 6))
6929 (clobber (match_scratch:DI 3 ""))]
6930 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6932 (zero_extend:DI (subreg:HI
6933 (rotate:DI (match_dup 1)
6936 (compare:CC (match_dup 3)
6940 (define_insn "*rotldi3_internal12le"
6941 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6942 (compare:CC (zero_extend:DI
6944 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6945 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6947 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6948 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6949 "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6951 rld%I2cl. %0,%1,%H2,48
6953 [(set_attr "type" "shift")
6954 (set_attr "maybe_var_shift" "yes")
6955 (set_attr "dot" "yes")
6956 (set_attr "length" "4,8")])
6958 (define_insn "*rotldi3_internal12be"
6959 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6960 (compare:CC (zero_extend:DI
6962 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6963 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 6))
6965 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6966 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 6)))]
6967 "TARGET_64BIT && BYTES_BIG_ENDIAN"
6969 rld%I2cl. %0,%1,%H2,48
6971 [(set_attr "type" "shift")
6972 (set_attr "maybe_var_shift" "yes")
6973 (set_attr "dot" "yes")
6974 (set_attr "length" "4,8")])
6977 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6978 (compare:CC (zero_extend:DI
6980 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6981 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6983 (set (match_operand:DI 0 "gpc_reg_operand" "")
6984 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6985 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6987 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6989 (compare:CC (match_dup 0)
6994 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6995 (compare:CC (zero_extend:DI
6997 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6998 (match_operand:DI 2 "reg_or_cint_operand" "")) 6))
7000 (set (match_operand:DI 0 "gpc_reg_operand" "")
7001 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 6)))]
7002 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
7004 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 6)))
7006 (compare:CC (match_dup 0)
7010 (define_insn "*rotldi3_internal13le"
7011 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7014 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7015 (match_operand:DI 2 "reg_or_cint_operand" "rn")) 0)))]
7016 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN"
7017 "rld%I2cl %0,%1,%H2,32"
7018 [(set_attr "type" "shift")
7019 (set_attr "maybe_var_shift" "yes")])
7021 (define_insn "*rotldi3_internal13be"
7022 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7025 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7026 (match_operand:DI 2 "reg_or_cint_operand" "rn")) 4)))]
7027 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN"
7028 "rld%I2cl %0,%1,%H2,32"
7029 [(set_attr "type" "shift")
7030 (set_attr "maybe_var_shift" "yes")])
7032 (define_insn "*rotldi3_internal14le"
7033 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7034 (compare:CC (zero_extend:DI
7036 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7037 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
7039 (clobber (match_scratch:DI 3 "=r,r"))]
7040 "TARGET_64BIT && !BYTES_BIG_ENDIAN"
7042 rld%I2cl. %3,%1,%H2,32
7044 [(set_attr "type" "shift")
7045 (set_attr "maybe_var_shift" "yes")
7046 (set_attr "dot" "yes")
7047 (set_attr "length" "4,8")])
7049 (define_insn "*rotldi3_internal14be"
7050 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7051 (compare:CC (zero_extend:DI
7053 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7054 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 4))
7056 (clobber (match_scratch:DI 3 "=r,r"))]
7057 "TARGET_64BIT && BYTES_BIG_ENDIAN"
7059 rld%I2cl. %3,%1,%H2,32
7061 [(set_attr "type" "shift")
7062 (set_attr "maybe_var_shift" "yes")
7063 (set_attr "dot" "yes")
7064 (set_attr "length" "4,8")])
7067 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
7068 (compare:CC (zero_extend:DI
7070 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7071 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7073 (clobber (match_scratch:DI 3 ""))]
7074 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
7076 (zero_extend:DI (subreg:SI
7077 (rotate:DI (match_dup 1)
7080 (compare:CC (match_dup 3)
7085 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
7086 (compare:CC (zero_extend:DI
7088 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7089 (match_operand:DI 2 "reg_or_cint_operand" "")) 4))
7091 (clobber (match_scratch:DI 3 ""))]
7092 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
7094 (zero_extend:DI (subreg:SI
7095 (rotate:DI (match_dup 1)
7098 (compare:CC (match_dup 3)
7102 (define_insn "*rotldi3_internal15le"
7103 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7104 (compare:CC (zero_extend:DI
7106 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7107 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
7109 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7110 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7111 "TARGET_64BIT && !BYTES_BIG_ENDIAN"
7113 rld%I2cl. %0,%1,%H2,32
7115 [(set_attr "type" "shift")
7116 (set_attr "maybe_var_shift" "yes")
7117 (set_attr "dot" "yes")
7118 (set_attr "length" "4,8")])
7120 (define_insn "*rotldi3_internal15be"
7121 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7122 (compare:CC (zero_extend:DI
7124 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7125 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 4))
7127 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7128 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 4)))]
7129 "TARGET_64BIT && BYTES_BIG_ENDIAN"
7131 rld%I2cl. %0,%1,%H2,32
7133 [(set_attr "type" "shift")
7134 (set_attr "maybe_var_shift" "yes")
7135 (set_attr "dot" "yes")
7136 (set_attr "length" "4,8")])
7139 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
7140 (compare:CC (zero_extend:DI
7142 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7143 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7145 (set (match_operand:DI 0 "gpc_reg_operand" "")
7146 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7147 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
7149 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
7151 (compare:CC (match_dup 0)
7156 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
7157 (compare:CC (zero_extend:DI
7159 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7160 (match_operand:DI 2 "reg_or_cint_operand" "")) 4))
7162 (set (match_operand:DI 0 "gpc_reg_operand" "")
7163 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 4)))]
7164 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
7166 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 4)))
7168 (compare:CC (match_dup 0)
7172 (define_insn "*ashldi3_internal4"
7173 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7174 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7175 (match_operand:SI 2 "const_int_operand" "i"))
7176 (match_operand:DI 3 "const_int_operand" "n")))]
7177 "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
7178 "rldic %0,%1,%H2,%W3"
7179 [(set_attr "type" "shift")])
7181 (define_insn "ashldi3_internal5"
7182 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7184 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7185 (match_operand:SI 2 "const_int_operand" "i,i"))
7186 (match_operand:DI 3 "const_int_operand" "n,n"))
7188 (clobber (match_scratch:DI 4 "=r,r"))]
7189 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
7191 rldic. %4,%1,%H2,%W3
7193 [(set_attr "type" "shift")
7194 (set_attr "dot" "yes")
7195 (set_attr "length" "4,8")])
7198 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
7200 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7201 (match_operand:SI 2 "const_int_operand" ""))
7202 (match_operand:DI 3 "const_int_operand" ""))
7204 (clobber (match_scratch:DI 4 ""))]
7205 "TARGET_POWERPC64 && reload_completed
7206 && includes_rldic_lshift_p (operands[2], operands[3])"
7208 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7211 (compare:CC (match_dup 4)
7215 (define_insn "*ashldi3_internal6"
7216 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
7218 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7219 (match_operand:SI 2 "const_int_operand" "i,i"))
7220 (match_operand:DI 3 "const_int_operand" "n,n"))
7222 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7223 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7224 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
7226 rldic. %0,%1,%H2,%W3
7228 [(set_attr "type" "shift")
7229 (set_attr "dot" "yes")
7230 (set_attr "length" "4,8")])
7233 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
7235 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7236 (match_operand:SI 2 "const_int_operand" ""))
7237 (match_operand:DI 3 "const_int_operand" ""))
7239 (set (match_operand:DI 0 "gpc_reg_operand" "")
7240 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7241 "TARGET_POWERPC64 && reload_completed
7242 && includes_rldic_lshift_p (operands[2], operands[3])"
7244 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7247 (compare:CC (match_dup 0)
7251 (define_insn "*ashldi3_internal7"
7252 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7253 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7254 (match_operand:SI 2 "const_int_operand" "i"))
7255 (match_operand:DI 3 "mask64_operand" "n")))]
7256 "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
7257 "rldicr %0,%1,%H2,%S3"
7258 [(set_attr "type" "shift")])
7260 (define_insn "ashldi3_internal8"
7261 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7263 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7264 (match_operand:SI 2 "const_int_operand" "i,i"))
7265 (match_operand:DI 3 "mask64_operand" "n,n"))
7267 (clobber (match_scratch:DI 4 "=r,r"))]
7268 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
7270 rldicr. %4,%1,%H2,%S3
7272 [(set_attr "type" "shift")
7273 (set_attr "dot" "yes")
7274 (set_attr "length" "4,8")])
7277 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
7279 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7280 (match_operand:SI 2 "const_int_operand" ""))
7281 (match_operand:DI 3 "mask64_operand" ""))
7283 (clobber (match_scratch:DI 4 ""))]
7284 "TARGET_POWERPC64 && reload_completed
7285 && includes_rldicr_lshift_p (operands[2], operands[3])"
7287 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7290 (compare:CC (match_dup 4)
7294 (define_insn "*ashldi3_internal9"
7295 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
7297 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7298 (match_operand:SI 2 "const_int_operand" "i,i"))
7299 (match_operand:DI 3 "mask64_operand" "n,n"))
7301 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7302 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7303 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
7305 rldicr. %0,%1,%H2,%S3
7307 [(set_attr "type" "shift")
7308 (set_attr "dot" "yes")
7309 (set_attr "length" "4,8")])
7312 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
7314 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7315 (match_operand:SI 2 "const_int_operand" ""))
7316 (match_operand:DI 3 "mask64_operand" ""))
7318 (set (match_operand:DI 0 "gpc_reg_operand" "")
7319 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7320 "TARGET_POWERPC64 && reload_completed
7321 && includes_rldicr_lshift_p (operands[2], operands[3])"
7323 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7326 (compare:CC (match_dup 0)
7331 (define_insn_and_split "*anddi3_2rld"
7332 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7333 (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
7334 (match_operand:DI 2 "and_2rld_operand" "n")))]
7339 (and:DI (rotate:DI (match_dup 1)
7343 (and:DI (rotate:DI (match_dup 0)
7347 build_mask64_2_operands (operands[2], &operands[4]);
7349 [(set_attr "length" "8")])
7351 (define_insn_and_split "*anddi3_2rld_dot"
7352 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7353 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
7354 (match_operand:DI 2 "and_2rld_operand" "n,n"))
7356 (clobber (match_scratch:DI 0 "=r,r"))]
7357 "TARGET_64BIT && rs6000_gen_cell_microcode"
7361 "&& reload_completed"
7363 (and:DI (rotate:DI (match_dup 1)
7366 (parallel [(set (match_dup 3)
7367 (compare:CC (and:DI (rotate:DI (match_dup 0)
7371 (clobber (match_dup 0))])]
7373 build_mask64_2_operands (operands[2], &operands[4]);
7375 [(set_attr "type" "two")
7376 (set_attr "dot" "yes")
7377 (set_attr "length" "8,12")])
7379 (define_insn_and_split "*anddi3_2rld_dot2"
7380 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7381 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
7382 (match_operand:DI 2 "and_2rld_operand" "n,n"))
7384 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7385 (and:DI (match_dup 1)
7387 "TARGET_64BIT && rs6000_gen_cell_microcode"
7391 "&& reload_completed"
7393 (and:DI (rotate:DI (match_dup 1)
7396 (parallel [(set (match_dup 3)
7397 (compare:CC (and:DI (rotate:DI (match_dup 0)
7402 (and:DI (rotate:DI (match_dup 0)
7406 build_mask64_2_operands (operands[2], &operands[4]);
7408 [(set_attr "type" "two")
7409 (set_attr "dot" "yes")
7410 (set_attr "length" "8,12")])
7412 ;; 128-bit logical operations expanders
7414 (define_expand "and<mode>3"
7415 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7416 (and:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
7417 (match_operand:BOOL_128 2 "vlogical_operand" "")))]
7421 (define_expand "ior<mode>3"
7422 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7423 (ior:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
7424 (match_operand:BOOL_128 2 "vlogical_operand" "")))]
7428 (define_expand "xor<mode>3"
7429 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7430 (xor:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
7431 (match_operand:BOOL_128 2 "vlogical_operand" "")))]
7435 (define_expand "one_cmpl<mode>2"
7436 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7437 (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")))]
7441 (define_expand "nor<mode>3"
7442 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7444 (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" ""))
7445 (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))))]
7449 (define_expand "andc<mode>3"
7450 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7452 (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))
7453 (match_operand:BOOL_128 1 "vlogical_operand" "")))]
7457 ;; Power8 vector logical instructions.
7458 (define_expand "eqv<mode>3"
7459 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7461 (xor:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
7462 (match_operand:BOOL_128 2 "vlogical_operand" ""))))]
7463 "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
7466 ;; Rewrite nand into canonical form
7467 (define_expand "nand<mode>3"
7468 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7470 (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" ""))
7471 (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))))]
7472 "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
7475 ;; The canonical form is to have the negated element first, so we need to
7476 ;; reverse arguments.
7477 (define_expand "orc<mode>3"
7478 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7480 (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))
7481 (match_operand:BOOL_128 1 "vlogical_operand" "")))]
7482 "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
7485 ;; 128-bit logical operations insns and split operations
7486 (define_insn_and_split "*and<mode>3_internal"
7487 [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7489 (match_operand:BOOL_128 1 "vlogical_operand" "%<BOOL_REGS_OP1>")
7490 (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>")))]
7493 if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7494 return "xxland %x0,%x1,%x2";
7496 if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7497 return "vand %0,%1,%2";
7501 "reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7504 rs6000_split_logical (operands, AND, false, false, false);
7509 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7510 (const_string "vecsimple")
7511 (const_string "integer")))
7512 (set (attr "length")
7514 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7517 (match_test "TARGET_POWERPC64")
7519 (const_string "16"))))])
7522 (define_insn_and_split "*bool<mode>3_internal"
7523 [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7524 (match_operator:BOOL_128 3 "boolean_or_operator"
7525 [(match_operand:BOOL_128 1 "vlogical_operand" "%<BOOL_REGS_OP1>")
7526 (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>")]))]
7529 if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7530 return "xxl%q3 %x0,%x1,%x2";
7532 if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7533 return "v%q3 %0,%1,%2";
7537 "reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7540 rs6000_split_logical (operands, GET_CODE (operands[3]), false, false, false);
7545 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7546 (const_string "vecsimple")
7547 (const_string "integer")))
7548 (set (attr "length")
7550 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7553 (match_test "TARGET_POWERPC64")
7555 (const_string "16"))))])
7558 (define_insn_and_split "*boolc<mode>3_internal1"
7559 [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7560 (match_operator:BOOL_128 3 "boolean_operator"
7562 (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>"))
7563 (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_OP1>")]))]
7564 "TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND)"
7566 if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7567 return "xxl%q3 %x0,%x1,%x2";
7569 if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7570 return "v%q3 %0,%1,%2";
7574 "(TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND))
7575 && reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7578 rs6000_split_logical (operands, GET_CODE (operands[3]), false, false, true);
7583 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7584 (const_string "vecsimple")
7585 (const_string "integer")))
7586 (set (attr "length")
7588 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7591 (match_test "TARGET_POWERPC64")
7593 (const_string "16"))))])
7595 (define_insn_and_split "*boolc<mode>3_internal2"
7596 [(set (match_operand:TI2 0 "int_reg_operand" "=&r,r,r")
7597 (match_operator:TI2 3 "boolean_operator"
7599 (match_operand:TI2 2 "int_reg_operand" "r,0,r"))
7600 (match_operand:TI2 1 "int_reg_operand" "r,r,0")]))]
7601 "!TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
7603 "reload_completed && !TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
7606 rs6000_split_logical (operands, GET_CODE (operands[3]), false, false, true);
7609 [(set_attr "type" "integer")
7610 (set (attr "length")
7612 (match_test "TARGET_POWERPC64")
7614 (const_string "16")))])
7617 (define_insn_and_split "*boolcc<mode>3_internal1"
7618 [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7619 (match_operator:BOOL_128 3 "boolean_operator"
7621 (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_OP1>"))
7623 (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>"))]))]
7624 "TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND)"
7626 if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7627 return "xxl%q3 %x0,%x1,%x2";
7629 if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7630 return "v%q3 %0,%1,%2";
7634 "(TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND))
7635 && reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7638 rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, true);
7643 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7644 (const_string "vecsimple")
7645 (const_string "integer")))
7646 (set (attr "length")
7648 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7651 (match_test "TARGET_POWERPC64")
7653 (const_string "16"))))])
7655 (define_insn_and_split "*boolcc<mode>3_internal2"
7656 [(set (match_operand:TI2 0 "int_reg_operand" "=&r,r,r")
7657 (match_operator:TI2 3 "boolean_operator"
7659 (match_operand:TI2 1 "int_reg_operand" "r,0,r"))
7661 (match_operand:TI2 2 "int_reg_operand" "r,r,0"))]))]
7662 "!TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
7664 "reload_completed && !TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
7667 rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, true);
7670 [(set_attr "type" "integer")
7671 (set (attr "length")
7673 (match_test "TARGET_POWERPC64")
7675 (const_string "16")))])
7679 (define_insn_and_split "*eqv<mode>3_internal1"
7680 [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7683 (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_OP1>")
7684 (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>"))))]
7687 if (vsx_register_operand (operands[0], <MODE>mode))
7688 return "xxleqv %x0,%x1,%x2";
7692 "TARGET_P8_VECTOR && reload_completed
7693 && int_reg_operand (operands[0], <MODE>mode)"
7696 rs6000_split_logical (operands, XOR, true, false, false);
7701 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7702 (const_string "vecsimple")
7703 (const_string "integer")))
7704 (set (attr "length")
7706 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7709 (match_test "TARGET_POWERPC64")
7711 (const_string "16"))))])
7713 (define_insn_and_split "*eqv<mode>3_internal2"
7714 [(set (match_operand:TI2 0 "int_reg_operand" "=&r,r,r")
7717 (match_operand:TI2 1 "int_reg_operand" "r,0,r")
7718 (match_operand:TI2 2 "int_reg_operand" "r,r,0"))))]
7721 "reload_completed && !TARGET_P8_VECTOR"
7724 rs6000_split_logical (operands, XOR, true, false, false);
7727 [(set_attr "type" "integer")
7728 (set (attr "length")
7730 (match_test "TARGET_POWERPC64")
7732 (const_string "16")))])
7734 ;; 128-bit one's complement
7735 (define_insn_and_split "*one_cmpl<mode>3_internal"
7736 [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7738 (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_UNARY>")))]
7741 if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7742 return "xxlnor %x0,%x1,%x1";
7744 if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7745 return "vnor %0,%1,%1";
7749 "reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7752 rs6000_split_logical (operands, NOT, false, false, false);
7757 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7758 (const_string "vecsimple")
7759 (const_string "integer")))
7760 (set (attr "length")
7762 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7765 (match_test "TARGET_POWERPC64")
7767 (const_string "16"))))])
7770 ;; Now define ways of moving data around.
7772 ;; Set up a register with a value from the GOT table
7774 (define_expand "movsi_got"
7775 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7776 (unspec:SI [(match_operand:SI 1 "got_operand" "")
7777 (match_dup 2)] UNSPEC_MOVSI_GOT))]
7778 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7781 if (GET_CODE (operands[1]) == CONST)
7783 rtx offset = const0_rtx;
7784 HOST_WIDE_INT value;
7786 operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
7787 value = INTVAL (offset);
7790 rtx tmp = (!can_create_pseudo_p ()
7792 : gen_reg_rtx (Pmode));
7793 emit_insn (gen_movsi_got (tmp, operands[1]));
7794 emit_insn (gen_addsi3 (operands[0], tmp, offset));
7799 operands[2] = rs6000_got_register (operands[1]);
7802 (define_insn "*movsi_got_internal"
7803 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7804 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7805 (match_operand:SI 2 "gpc_reg_operand" "b")]
7807 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7808 "lwz %0,%a1@got(%2)"
7809 [(set_attr "type" "load")])
7811 ;; Used by sched, shorten_branches and final when the GOT pseudo reg
7812 ;; didn't get allocated to a hard register.
7814 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7815 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7816 (match_operand:SI 2 "memory_operand" "")]
7818 "DEFAULT_ABI == ABI_V4
7820 && (reload_in_progress || reload_completed)"
7821 [(set (match_dup 0) (match_dup 2))
7822 (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)]
7826 ;; For SI, we special-case integers that can't be loaded in one insn. We
7827 ;; do the load 16-bits at a time. We could do this by loading from memory,
7828 ;; and this is even supposed to be faster, but it is simpler not to get
7829 ;; integers in the TOC.
7830 (define_insn "movsi_low"
7831 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7832 (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7833 (match_operand 2 "" ""))))]
7834 "TARGET_MACHO && ! TARGET_64BIT"
7835 "lwz %0,lo16(%2)(%1)"
7836 [(set_attr "type" "load")
7837 (set_attr "length" "4")])
7839 (define_insn "*movsi_internal1"
7840 [(set (match_operand:SI 0 "rs6000_nonimmediate_operand" "=r,r,r,m,r,r,r,r,*c*l,*h,*h")
7841 (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,*h,r,r,0"))]
7842 "!TARGET_SINGLE_FPU &&
7843 (gpc_reg_operand (operands[0], SImode) || gpc_reg_operand (operands[1], SImode))"
7856 [(set_attr "type" "*,*,load,store,*,*,*,mfjmpr,mtjmpr,*,*")
7857 (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4")])
7859 (define_insn "*movsi_internal1_single"
7860 [(set (match_operand:SI 0 "rs6000_nonimmediate_operand" "=r,r,r,m,r,r,r,r,*c*l,*h,*h,m,*f")
7861 (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,*h,r,r,0,f,m"))]
7862 "TARGET_SINGLE_FPU &&
7863 (gpc_reg_operand (operands[0], SImode) || gpc_reg_operand (operands[1], SImode))"
7878 [(set_attr "type" "*,*,load,store,*,*,*,mfjmpr,mtjmpr,*,*,fpstore,fpload")
7879 (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
7881 ;; Split a load of a large constant into the appropriate two-insn
7885 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7886 (match_operand:SI 1 "const_int_operand" ""))]
7887 "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
7888 && (INTVAL (operands[1]) & 0xffff) != 0"
7892 (ior:SI (match_dup 0)
7896 if (rs6000_emit_set_const (operands[0], operands[1]))
7902 (define_insn "*mov<mode>_internal2"
7903 [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
7904 (compare:CC (match_operand:P 1 "gpc_reg_operand" "0,r,r")
7906 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
7912 [(set_attr "type" "cmp,logical,cmp")
7913 (set_attr "dot" "yes")
7914 (set_attr "length" "4,4,8")])
7917 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
7918 (compare:CC (match_operand:P 1 "gpc_reg_operand" "")
7920 (set (match_operand:P 0 "gpc_reg_operand" "") (match_dup 1))]
7922 [(set (match_dup 0) (match_dup 1))
7924 (compare:CC (match_dup 0)
7928 (define_insn "*movhi_internal"
7929 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*c*l,*h")
7930 (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,0"))]
7931 "gpc_reg_operand (operands[0], HImode)
7932 || gpc_reg_operand (operands[1], HImode)"
7941 [(set_attr "type" "*,load,store,*,mfjmpr,mtjmpr,*")])
7943 (define_expand "mov<mode>"
7944 [(set (match_operand:INT 0 "general_operand" "")
7945 (match_operand:INT 1 "any_operand" ""))]
7947 "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
7949 (define_insn "*movqi_internal"
7950 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*c*l,*h")
7951 (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,0"))]
7952 "gpc_reg_operand (operands[0], QImode)
7953 || gpc_reg_operand (operands[1], QImode)"
7962 [(set_attr "type" "*,load,store,*,mfjmpr,mtjmpr,*")])
7964 ;; Here is how to move condition codes around. When we store CC data in
7965 ;; an integer register or memory, we store just the high-order 4 bits.
7966 ;; This lets us not shift in the most common case of CR0.
7967 (define_expand "movcc"
7968 [(set (match_operand:CC 0 "nonimmediate_operand" "")
7969 (match_operand:CC 1 "nonimmediate_operand" ""))]
7973 (define_insn "*movcc_internal1"
7974 [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,?y,y,r,r,r,r,r,cl,r,m")
7975 (match_operand:CC 1 "general_operand" "y,r,r,O,x,y,r,I,h,r,m,r"))]
7976 "register_operand (operands[0], CCmode)
7977 || register_operand (operands[1], CCmode)"
7981 rlwinm %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;rlwinm %1,%1,%f0,0xffffffff
7984 mfcr %0%Q1\;rlwinm %0,%0,%f1,0xf0000000
7992 (cond [(eq_attr "alternative" "0,3")
7993 (const_string "cr_logical")
7994 (eq_attr "alternative" "1,2")
7995 (const_string "mtcr")
7996 (eq_attr "alternative" "6,7")
7997 (const_string "integer")
7998 (eq_attr "alternative" "8")
7999 (const_string "mfjmpr")
8000 (eq_attr "alternative" "9")
8001 (const_string "mtjmpr")
8002 (eq_attr "alternative" "10")
8003 (const_string "load")
8004 (eq_attr "alternative" "11")
8005 (const_string "store")
8006 (match_test "TARGET_MFCRF")
8007 (const_string "mfcrf")
8009 (const_string "mfcr")))
8010 (set_attr "length" "4,4,12,4,4,8,4,4,4,4,4,4")])
8012 ;; For floating-point, we normally deal with the floating-point registers
8013 ;; unless -msoft-float is used. The sole exception is that parameter passing
8014 ;; can produce floating-point values in fixed-point registers. Unless the
8015 ;; value is a simple constant or already in memory, we deal with this by
8016 ;; allocating memory and copying the value explicitly via that memory location.
8018 ;; Move 32-bit binary/decimal floating point
8019 (define_expand "mov<mode>"
8020 [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "")
8021 (match_operand:FMOVE32 1 "any_operand" ""))]
8023 "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
8026 [(set (match_operand:FMOVE32 0 "gpc_reg_operand" "")
8027 (match_operand:FMOVE32 1 "const_double_operand" ""))]
8029 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8030 || (GET_CODE (operands[0]) == SUBREG
8031 && GET_CODE (SUBREG_REG (operands[0])) == REG
8032 && REGNO (SUBREG_REG (operands[0])) <= 31))"
8033 [(set (match_dup 2) (match_dup 3))]
8039 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8040 <real_value_to_target> (rv, l);
8042 if (! TARGET_POWERPC64)
8043 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
8045 operands[2] = gen_lowpart (SImode, operands[0]);
8047 operands[3] = gen_int_mode (l, SImode);
8050 (define_insn "mov<mode>_hardfloat"
8051 [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "=!r,!r,m,f,<f32_vsx>,<f32_vsx>,<f32_lr>,<f32_sm>,<f32_av>,Z,?<f32_dm>,?r,*c*l,!r,*h,!r,!r")
8052 (match_operand:FMOVE32 1 "input_operand" "r,m,r,f,<f32_vsx>,j,<f32_lm>,<f32_sr>,Z,<f32_av>,r,<f32_dm>,r,h,0,G,Fn"))]
8053 "(gpc_reg_operand (operands[0], <MODE>mode)
8054 || gpc_reg_operand (operands[1], <MODE>mode))
8055 && (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT)"
8074 [(set_attr "type" "*,load,store,fp,vecsimple,vecsimple,fpload,fpstore,fpload,fpstore,mftgpr,mffgpr,mtjmpr,mfjmpr,*,*,*")
8075 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,8")])
8077 (define_insn "*mov<mode>_softfloat"
8078 [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "=r,cl,r,r,m,r,r,r,r,*h")
8079 (match_operand:FMOVE32 1 "input_operand" "r,r,h,m,r,I,L,G,Fn,0"))]
8080 "(gpc_reg_operand (operands[0], <MODE>mode)
8081 || gpc_reg_operand (operands[1], <MODE>mode))
8082 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
8094 [(set_attr "type" "*,mtjmpr,mfjmpr,load,store,*,*,*,*,*")
8095 (set_attr "length" "4,4,4,4,4,4,4,4,8,4")])
8098 ;; Move 64-bit binary/decimal floating point
8099 (define_expand "mov<mode>"
8100 [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "")
8101 (match_operand:FMOVE64 1 "any_operand" ""))]
8103 "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
8106 [(set (match_operand:FMOVE64 0 "gpc_reg_operand" "")
8107 (match_operand:FMOVE64 1 "const_int_operand" ""))]
8108 "! TARGET_POWERPC64 && reload_completed
8109 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8110 || (GET_CODE (operands[0]) == SUBREG
8111 && GET_CODE (SUBREG_REG (operands[0])) == REG
8112 && REGNO (SUBREG_REG (operands[0])) <= 31))"
8113 [(set (match_dup 2) (match_dup 4))
8114 (set (match_dup 3) (match_dup 1))]
8117 int endian = (WORDS_BIG_ENDIAN == 0);
8118 HOST_WIDE_INT value = INTVAL (operands[1]);
8120 operands[2] = operand_subword (operands[0], endian, 0, <MODE>mode);
8121 operands[3] = operand_subword (operands[0], 1 - endian, 0, <MODE>mode);
8122 operands[4] = GEN_INT (value >> 32);
8123 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8127 [(set (match_operand:FMOVE64 0 "gpc_reg_operand" "")
8128 (match_operand:FMOVE64 1 "const_double_operand" ""))]
8129 "! TARGET_POWERPC64 && reload_completed
8130 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8131 || (GET_CODE (operands[0]) == SUBREG
8132 && GET_CODE (SUBREG_REG (operands[0])) == REG
8133 && REGNO (SUBREG_REG (operands[0])) <= 31))"
8134 [(set (match_dup 2) (match_dup 4))
8135 (set (match_dup 3) (match_dup 5))]
8138 int endian = (WORDS_BIG_ENDIAN == 0);
8142 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8143 <real_value_to_target> (rv, l);
8145 operands[2] = operand_subword (operands[0], endian, 0, <MODE>mode);
8146 operands[3] = operand_subword (operands[0], 1 - endian, 0, <MODE>mode);
8147 operands[4] = gen_int_mode (l[endian], SImode);
8148 operands[5] = gen_int_mode (l[1 - endian], SImode);
8152 [(set (match_operand:FMOVE64 0 "gpc_reg_operand" "")
8153 (match_operand:FMOVE64 1 "const_double_operand" ""))]
8154 "TARGET_POWERPC64 && reload_completed
8155 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8156 || (GET_CODE (operands[0]) == SUBREG
8157 && GET_CODE (SUBREG_REG (operands[0])) == REG
8158 && REGNO (SUBREG_REG (operands[0])) <= 31))"
8159 [(set (match_dup 2) (match_dup 3))]
8162 int endian = (WORDS_BIG_ENDIAN == 0);
8167 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8168 <real_value_to_target> (rv, l);
8170 operands[2] = gen_lowpart (DImode, operands[0]);
8171 /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN. */
8172 val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32
8173 | ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
8175 operands[3] = gen_int_mode (val, DImode);
8178 ;; Don't have reload use general registers to load a constant. It is
8179 ;; less efficient than loading the constant into an FP register, since
8180 ;; it will probably be used there.
8182 ;; The move constraints are ordered to prefer floating point registers before
8183 ;; general purpose registers to avoid doing a store and a load to get the value
8184 ;; into a floating point register when it is needed for a floating point
8185 ;; operation. Prefer traditional floating point registers over VSX registers,
8186 ;; since the D-form version of the memory instructions does not need a GPR for
8189 (define_insn "*mov<mode>_hardfloat32"
8190 [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=m,d,d,<f64_av>,Z,<f64_vsx>,<f64_vsx>,Y,r,!r,!r,!r,!r")
8191 (match_operand:FMOVE64 1 "input_operand" "d,m,d,Z,<f64_av>,<f64_vsx>,j,r,Y,r,G,H,F"))]
8192 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
8193 && (gpc_reg_operand (operands[0], <MODE>mode)
8194 || gpc_reg_operand (operands[1], <MODE>mode))"
8209 [(set_attr "type" "fpstore,fpload,fp,fpload,fpstore,vecsimple,vecsimple,store,load,two,fp,fp,*")
8210 (set_attr "length" "4,4,4,4,4,4,4,8,8,8,8,12,16")])
8212 (define_insn "*mov<mode>_softfloat32"
8213 [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=Y,r,r,r,r,r")
8214 (match_operand:FMOVE64 1 "input_operand" "r,Y,r,G,H,F"))]
8216 && ((TARGET_FPRS && TARGET_SINGLE_FLOAT)
8217 || TARGET_SOFT_FLOAT || TARGET_E500_SINGLE
8218 || (<MODE>mode == DDmode && TARGET_E500_DOUBLE))
8219 && (gpc_reg_operand (operands[0], <MODE>mode)
8220 || gpc_reg_operand (operands[1], <MODE>mode))"
8222 [(set_attr "type" "store,load,two,*,*,*")
8223 (set_attr "length" "8,8,8,8,12,16")])
8225 ; ld/std require word-aligned displacements -> 'Y' constraint.
8226 ; List Y->r and r->Y before r->r for reload.
8227 (define_insn "*mov<mode>_hardfloat64"
8228 [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=m,d,d,<f64_av>,Z,<f64_vsx>,<f64_vsx>,Y,r,!r,*c*l,!r,*h,!r,!r,!r,r,wg,r,<f64_dm>")
8229 (match_operand:FMOVE64 1 "input_operand" "d,m,d,Z,<f64_av>,<f64_vsx>,j,r,Y,r,r,h,0,G,H,F,wg,r,<f64_dm>,r"))]
8230 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
8231 && (gpc_reg_operand (operands[0], <MODE>mode)
8232 || gpc_reg_operand (operands[1], <MODE>mode))"
8254 [(set_attr "type" "fpstore,fpload,fp,fpload,fpstore,vecsimple,vecsimple,store,load,*,mtjmpr,mfjmpr,*,*,*,*,mftgpr,mffgpr,mftgpr,mffgpr")
8255 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,4,8,12,16,4,4,4,4")])
8257 (define_insn "*mov<mode>_softfloat64"
8258 [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=Y,r,r,cl,r,r,r,r,*h")
8259 (match_operand:FMOVE64 1 "input_operand" "r,Y,r,r,h,G,H,F,0"))]
8260 "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
8261 && (gpc_reg_operand (operands[0], <MODE>mode)
8262 || gpc_reg_operand (operands[1], <MODE>mode))"
8273 [(set_attr "type" "store,load,*,mtjmpr,mfjmpr,*,*,*,*")
8274 (set_attr "length" "4,4,4,4,4,8,12,16,4")])
8276 (define_expand "mov<mode>"
8277 [(set (match_operand:FMOVE128 0 "general_operand" "")
8278 (match_operand:FMOVE128 1 "any_operand" ""))]
8280 "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
8282 ;; It's important to list Y->r and r->Y before r->r because otherwise
8283 ;; reload, given m->r, will try to pick r->r and reload it, which
8284 ;; doesn't make progress.
8286 ;; We can't split little endian direct moves of TDmode, because the words are
8287 ;; not swapped like they are for TImode or TFmode. Subregs therefore are
8288 ;; problematical. Don't allow direct move for this case.
8290 (define_insn_and_split "*mov<mode>_64bit_dm"
8291 [(set (match_operand:FMOVE128 0 "nonimmediate_operand" "=m,d,d,ws,Y,r,r,r,wm")
8292 (match_operand:FMOVE128 1 "input_operand" "d,m,d,j,r,jYGHF,r,wm,r"))]
8293 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_POWERPC64
8294 && (<MODE>mode != TDmode || WORDS_BIG_ENDIAN)
8295 && (gpc_reg_operand (operands[0], <MODE>mode)
8296 || gpc_reg_operand (operands[1], <MODE>mode))"
8298 "&& reload_completed"
8300 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8301 [(set_attr "length" "8,8,8,8,12,12,8,8,8")])
8303 (define_insn_and_split "*movtd_64bit_nodm"
8304 [(set (match_operand:TD 0 "nonimmediate_operand" "=m,d,d,ws,Y,r,r")
8305 (match_operand:TD 1 "input_operand" "d,m,d,j,r,jYGHF,r"))]
8306 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_POWERPC64 && !WORDS_BIG_ENDIAN
8307 && (gpc_reg_operand (operands[0], TDmode)
8308 || gpc_reg_operand (operands[1], TDmode))"
8310 "&& reload_completed"
8312 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8313 [(set_attr "length" "8,8,8,8,12,12,8")])
8315 (define_insn_and_split "*mov<mode>_32bit"
8316 [(set (match_operand:FMOVE128 0 "nonimmediate_operand" "=m,d,d,ws,Y,r,r")
8317 (match_operand:FMOVE128 1 "input_operand" "d,m,d,j,r,jYGHF,r"))]
8318 "TARGET_HARD_FLOAT && TARGET_FPRS && !TARGET_POWERPC64
8319 && (gpc_reg_operand (operands[0], <MODE>mode)
8320 || gpc_reg_operand (operands[1], <MODE>mode))"
8322 "&& reload_completed"
8324 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8325 [(set_attr "length" "8,8,8,8,20,20,16")])
8327 (define_insn_and_split "*mov<mode>_softfloat"
8328 [(set (match_operand:FMOVE128 0 "rs6000_nonimmediate_operand" "=Y,r,r")
8329 (match_operand:FMOVE128 1 "input_operand" "r,YGHF,r"))]
8330 "(TARGET_SOFT_FLOAT || !TARGET_FPRS)
8331 && (gpc_reg_operand (operands[0], <MODE>mode)
8332 || gpc_reg_operand (operands[1], <MODE>mode))"
8334 "&& reload_completed"
8336 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8337 [(set_attr "length" "20,20,16")])
8339 ;; If we are using -ffast-math, easy_fp_constant assumes all constants are
8340 ;; 'easy' in order to allow for reciprocal estimation. Make sure the constant
8341 ;; is in the constant pool before reload occurs. This simplifies accessing
8342 ;; scalars in the traditional Altivec registers.
8345 [(set (match_operand:SFDF 0 "register_operand" "")
8346 (match_operand:SFDF 1 "memory_fp_constant" ""))]
8347 "TARGET_<MODE>_FPR && flag_unsafe_math_optimizations
8348 && !reload_in_progress && !reload_completed && !lra_in_progress"
8349 [(set (match_dup 0) (match_dup 2))]
8351 operands[2] = validize_mem (force_const_mem (<MODE>mode, operands[1]));
8354 (define_expand "extenddftf2"
8355 [(set (match_operand:TF 0 "nonimmediate_operand" "")
8356 (float_extend:TF (match_operand:DF 1 "input_operand" "")))]
8358 && TARGET_HARD_FLOAT
8359 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8360 && TARGET_LONG_DOUBLE_128"
8362 if (TARGET_E500_DOUBLE)
8363 emit_insn (gen_spe_extenddftf2 (operands[0], operands[1]));
8365 emit_insn (gen_extenddftf2_fprs (operands[0], operands[1]));
8369 (define_expand "extenddftf2_fprs"
8370 [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
8371 (float_extend:TF (match_operand:DF 1 "input_operand" "")))
8372 (use (match_dup 2))])]
8374 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
8375 && TARGET_LONG_DOUBLE_128"
8377 operands[2] = CONST0_RTX (DFmode);
8378 /* Generate GOT reference early for SVR4 PIC. */
8379 if (DEFAULT_ABI == ABI_V4 && flag_pic)
8380 operands[2] = validize_mem (force_const_mem (DFmode, operands[2]));
8383 (define_insn_and_split "*extenddftf2_internal"
8384 [(set (match_operand:TF 0 "nonimmediate_operand" "=m,Y,d,&d,r")
8385 (float_extend:TF (match_operand:DF 1 "input_operand" "d,r,md,md,rmGHF")))
8386 (use (match_operand:DF 2 "zero_reg_mem_operand" "d,r,m,d,n"))]
8388 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
8389 && TARGET_LONG_DOUBLE_128"
8391 "&& reload_completed"
8394 const int lo_word = LONG_DOUBLE_LARGE_FIRST ? GET_MODE_SIZE (DFmode) : 0;
8395 const int hi_word = LONG_DOUBLE_LARGE_FIRST ? 0 : GET_MODE_SIZE (DFmode);
8396 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word),
8398 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word),
8403 (define_expand "extendsftf2"
8404 [(set (match_operand:TF 0 "nonimmediate_operand" "")
8405 (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "")))]
8407 && TARGET_HARD_FLOAT
8408 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8409 && TARGET_LONG_DOUBLE_128"
8411 rtx tmp = gen_reg_rtx (DFmode);
8412 emit_insn (gen_extendsfdf2 (tmp, operands[1]));
8413 emit_insn (gen_extenddftf2 (operands[0], tmp));
8417 (define_expand "trunctfdf2"
8418 [(set (match_operand:DF 0 "gpc_reg_operand" "")
8419 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))]
8421 && TARGET_HARD_FLOAT
8422 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8423 && TARGET_LONG_DOUBLE_128"
8426 (define_insn_and_split "trunctfdf2_internal1"
8427 [(set (match_operand:DF 0 "gpc_reg_operand" "=d,?d")
8428 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "0,d")))]
8429 "!TARGET_IEEEQUAD && !TARGET_XL_COMPAT
8430 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8434 "&& reload_completed && REGNO (operands[0]) == REGNO (operands[1])"
8437 emit_note (NOTE_INSN_DELETED);
8440 [(set_attr "type" "fp")])
8442 (define_insn "trunctfdf2_internal2"
8443 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
8444 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "d")))]
8445 "!TARGET_IEEEQUAD && TARGET_XL_COMPAT
8446 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
8447 && TARGET_LONG_DOUBLE_128"
8449 [(set_attr "type" "fp")
8450 (set_attr "fp_type" "fp_addsub_d")])
8452 (define_expand "trunctfsf2"
8453 [(set (match_operand:SF 0 "gpc_reg_operand" "")
8454 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "")))]
8456 && TARGET_HARD_FLOAT
8457 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8458 && TARGET_LONG_DOUBLE_128"
8460 if (TARGET_E500_DOUBLE)
8461 emit_insn (gen_spe_trunctfsf2 (operands[0], operands[1]));
8463 emit_insn (gen_trunctfsf2_fprs (operands[0], operands[1]));
8467 (define_insn_and_split "trunctfsf2_fprs"
8468 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
8469 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "d")))
8470 (clobber (match_scratch:DF 2 "=d"))]
8472 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
8473 && TARGET_LONG_DOUBLE_128"
8475 "&& reload_completed"
8477 (float_truncate:DF (match_dup 1)))
8479 (float_truncate:SF (match_dup 2)))]
8482 (define_expand "floatsitf2"
8483 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8484 (float:TF (match_operand:SI 1 "gpc_reg_operand" "")))]
8486 && TARGET_HARD_FLOAT
8487 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8488 && TARGET_LONG_DOUBLE_128"
8490 rtx tmp = gen_reg_rtx (DFmode);
8491 expand_float (tmp, operands[1], false);
8492 emit_insn (gen_extenddftf2 (operands[0], tmp));
8496 ; fadd, but rounding towards zero.
8497 ; This is probably not the optimal code sequence.
8498 (define_insn "fix_trunc_helper"
8499 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
8500 (unspec:DF [(match_operand:TF 1 "gpc_reg_operand" "d")]
8501 UNSPEC_FIX_TRUNC_TF))
8502 (clobber (match_operand:DF 2 "gpc_reg_operand" "=&d"))]
8503 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
8504 "mffs %2\n\tmtfsb1 31\n\tmtfsb0 30\n\tfadd %0,%1,%L1\n\tmtfsf 1,%2"
8505 [(set_attr "type" "fp")
8506 (set_attr "length" "20")])
8508 (define_expand "fix_trunctfsi2"
8509 [(set (match_operand:SI 0 "gpc_reg_operand" "")
8510 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))]
8511 "!TARGET_IEEEQUAD && TARGET_HARD_FLOAT
8512 && (TARGET_FPRS || TARGET_E500_DOUBLE) && TARGET_LONG_DOUBLE_128"
8514 if (TARGET_E500_DOUBLE)
8515 emit_insn (gen_spe_fix_trunctfsi2 (operands[0], operands[1]));
8517 emit_insn (gen_fix_trunctfsi2_fprs (operands[0], operands[1]));
8521 (define_expand "fix_trunctfsi2_fprs"
8522 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
8523 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))
8524 (clobber (match_dup 2))
8525 (clobber (match_dup 3))
8526 (clobber (match_dup 4))
8527 (clobber (match_dup 5))])]
8529 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8531 operands[2] = gen_reg_rtx (DFmode);
8532 operands[3] = gen_reg_rtx (DFmode);
8533 operands[4] = gen_reg_rtx (DImode);
8534 operands[5] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode));
8537 (define_insn_and_split "*fix_trunctfsi2_internal"
8538 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8539 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "d")))
8540 (clobber (match_operand:DF 2 "gpc_reg_operand" "=d"))
8541 (clobber (match_operand:DF 3 "gpc_reg_operand" "=&d"))
8542 (clobber (match_operand:DI 4 "gpc_reg_operand" "=d"))
8543 (clobber (match_operand:DI 5 "offsettable_mem_operand" "=o"))]
8545 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8551 emit_insn (gen_fix_trunc_helper (operands[2], operands[1], operands[3]));
8553 gcc_assert (MEM_P (operands[5]));
8554 lowword = adjust_address (operands[5], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
8556 emit_insn (gen_fctiwz_df (operands[4], operands[2]));
8557 emit_move_insn (operands[5], operands[4]);
8558 emit_move_insn (operands[0], lowword);
8562 (define_expand "negtf2"
8563 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8564 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "")))]
8566 && TARGET_HARD_FLOAT
8567 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8568 && TARGET_LONG_DOUBLE_128"
8571 (define_insn "negtf2_internal"
8572 [(set (match_operand:TF 0 "gpc_reg_operand" "=d")
8573 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "d")))]
8575 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8578 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8579 return \"fneg %L0,%L1\;fneg %0,%1\";
8581 return \"fneg %0,%1\;fneg %L0,%L1\";
8583 [(set_attr "type" "fp")
8584 (set_attr "length" "8")])
8586 (define_expand "abstf2"
8587 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8588 (abs:TF (match_operand:TF 1 "gpc_reg_operand" "")))]
8590 && TARGET_HARD_FLOAT
8591 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8592 && TARGET_LONG_DOUBLE_128"
8595 rtx label = gen_label_rtx ();
8596 if (TARGET_E500_DOUBLE)
8598 if (flag_finite_math_only && !flag_trapping_math)
8599 emit_insn (gen_spe_abstf2_tst (operands[0], operands[1], label));
8601 emit_insn (gen_spe_abstf2_cmp (operands[0], operands[1], label));
8604 emit_insn (gen_abstf2_internal (operands[0], operands[1], label));
8609 (define_expand "abstf2_internal"
8610 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8611 (match_operand:TF 1 "gpc_reg_operand" ""))
8612 (set (match_dup 3) (match_dup 5))
8613 (set (match_dup 5) (abs:DF (match_dup 5)))
8614 (set (match_dup 4) (compare:CCFP (match_dup 3) (match_dup 5)))
8615 (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
8616 (label_ref (match_operand 2 "" ""))
8618 (set (match_dup 6) (neg:DF (match_dup 6)))]
8620 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
8621 && TARGET_LONG_DOUBLE_128"
8624 const int hi_word = LONG_DOUBLE_LARGE_FIRST ? 0 : GET_MODE_SIZE (DFmode);
8625 const int lo_word = LONG_DOUBLE_LARGE_FIRST ? GET_MODE_SIZE (DFmode) : 0;
8626 operands[3] = gen_reg_rtx (DFmode);
8627 operands[4] = gen_reg_rtx (CCFPmode);
8628 operands[5] = simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word);
8629 operands[6] = simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word);
8632 ;; Reload helper functions used by rs6000_secondary_reload. The patterns all
8633 ;; must have 3 arguments, and scratch register constraint must be a single
8636 ;; Reload patterns to support gpr load/store with misaligned mem.
8637 ;; and multiple gpr load/store at offset >= 0xfffc
8638 (define_expand "reload_<mode>_store"
8639 [(parallel [(match_operand 0 "memory_operand" "=m")
8640 (match_operand 1 "gpc_reg_operand" "r")
8641 (match_operand:GPR 2 "register_operand" "=&b")])]
8644 rs6000_secondary_reload_gpr (operands[1], operands[0], operands[2], true);
8648 (define_expand "reload_<mode>_load"
8649 [(parallel [(match_operand 0 "gpc_reg_operand" "=r")
8650 (match_operand 1 "memory_operand" "m")
8651 (match_operand:GPR 2 "register_operand" "=b")])]
8654 rs6000_secondary_reload_gpr (operands[0], operands[1], operands[2], false);
8659 ;; Reload patterns for various types using the vector registers. We may need
8660 ;; an additional base register to convert the reg+offset addressing to reg+reg
8661 ;; for vector registers and reg+reg or (reg+reg)&(-16) addressing to just an
8662 ;; index register for gpr registers.
8663 (define_expand "reload_<RELOAD:mode>_<P:mptrsize>_store"
8664 [(parallel [(match_operand:RELOAD 0 "memory_operand" "m")
8665 (match_operand:RELOAD 1 "gpc_reg_operand" "wa")
8666 (match_operand:P 2 "register_operand" "=b")])]
8669 rs6000_secondary_reload_inner (operands[1], operands[0], operands[2], true);
8673 (define_expand "reload_<RELOAD:mode>_<P:mptrsize>_load"
8674 [(parallel [(match_operand:RELOAD 0 "gpc_reg_operand" "wa")
8675 (match_operand:RELOAD 1 "memory_operand" "m")
8676 (match_operand:P 2 "register_operand" "=b")])]
8679 rs6000_secondary_reload_inner (operands[0], operands[1], operands[2], false);
8684 ;; Reload sometimes tries to move the address to a GPR, and can generate
8685 ;; invalid RTL for addresses involving AND -16. Allow addresses involving
8686 ;; reg+reg, reg+small constant, or just reg, all wrapped in an AND -16.
8688 (define_insn_and_split "*vec_reload_and_plus_<mptrsize>"
8689 [(set (match_operand:P 0 "gpc_reg_operand" "=b")
8690 (and:P (plus:P (match_operand:P 1 "gpc_reg_operand" "r")
8691 (match_operand:P 2 "reg_or_cint_operand" "rI"))
8693 "TARGET_ALTIVEC && (reload_in_progress || reload_completed)"
8695 "&& reload_completed"
8697 (plus:P (match_dup 1)
8700 (and:P (match_dup 0)
8703 ;; Power8 merge instructions to allow direct move to/from floating point
8704 ;; registers in 32-bit mode. We use TF mode to get two registers to move the
8705 ;; individual 32-bit parts across. Subreg doesn't work too well on the TF
8706 ;; value, since it is allocated in reload and not all of the flow information
8707 ;; is setup for it. We have two patterns to do the two moves between gprs and
8708 ;; fprs. There isn't a dependancy between the two, but we could potentially
8709 ;; schedule other instructions between the two instructions. TFmode is
8710 ;; currently limited to traditional FPR registers. If/when this is changed, we
8711 ;; will need to revist %L to make sure it works with VSX registers, or add an
8712 ;; %x version of %L.
8714 (define_insn "p8_fmrgow_<mode>"
8715 [(set (match_operand:FMOVE64X 0 "register_operand" "=d")
8716 (unspec:FMOVE64X [(match_operand:TF 1 "register_operand" "d")]
8717 UNSPEC_P8V_FMRGOW))]
8718 "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8720 [(set_attr "type" "vecperm")])
8722 (define_insn "p8_mtvsrwz_1"
8723 [(set (match_operand:TF 0 "register_operand" "=d")
8724 (unspec:TF [(match_operand:SI 1 "register_operand" "r")]
8725 UNSPEC_P8V_MTVSRWZ))]
8726 "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8728 [(set_attr "type" "mftgpr")])
8730 (define_insn "p8_mtvsrwz_2"
8731 [(set (match_operand:TF 0 "register_operand" "+d")
8732 (unspec:TF [(match_dup 0)
8733 (match_operand:SI 1 "register_operand" "r")]
8734 UNSPEC_P8V_MTVSRWZ))]
8735 "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8737 [(set_attr "type" "mftgpr")])
8739 (define_insn_and_split "reload_fpr_from_gpr<mode>"
8740 [(set (match_operand:FMOVE64X 0 "register_operand" "=ws")
8741 (unspec:FMOVE64X [(match_operand:FMOVE64X 1 "register_operand" "r")]
8742 UNSPEC_P8V_RELOAD_FROM_GPR))
8743 (clobber (match_operand:TF 2 "register_operand" "=d"))]
8744 "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8746 "&& reload_completed"
8749 rtx dest = operands[0];
8750 rtx src = operands[1];
8751 rtx tmp = operands[2];
8752 rtx gpr_hi_reg = gen_highpart (SImode, src);
8753 rtx gpr_lo_reg = gen_lowpart (SImode, src);
8755 emit_insn (gen_p8_mtvsrwz_1 (tmp, gpr_hi_reg));
8756 emit_insn (gen_p8_mtvsrwz_2 (tmp, gpr_lo_reg));
8757 emit_insn (gen_p8_fmrgow_<mode> (dest, tmp));
8760 [(set_attr "length" "12")
8761 (set_attr "type" "three")])
8763 ;; Move 128 bit values from GPRs to VSX registers in 64-bit mode
8764 (define_insn "p8_mtvsrd_1"
8765 [(set (match_operand:TF 0 "register_operand" "=ws")
8766 (unspec:TF [(match_operand:DI 1 "register_operand" "r")]
8767 UNSPEC_P8V_MTVSRD))]
8768 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8770 [(set_attr "type" "mftgpr")])
8772 (define_insn "p8_mtvsrd_2"
8773 [(set (match_operand:TF 0 "register_operand" "+ws")
8774 (unspec:TF [(match_dup 0)
8775 (match_operand:DI 1 "register_operand" "r")]
8776 UNSPEC_P8V_MTVSRD))]
8777 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8779 [(set_attr "type" "mftgpr")])
8781 (define_insn "p8_xxpermdi_<mode>"
8782 [(set (match_operand:FMOVE128_GPR 0 "register_operand" "=wa")
8783 (unspec:FMOVE128_GPR [(match_operand:TF 1 "register_operand" "ws")]
8784 UNSPEC_P8V_XXPERMDI))]
8785 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8786 "xxpermdi %x0,%1,%L1,0"
8787 [(set_attr "type" "vecperm")])
8789 (define_insn_and_split "reload_vsx_from_gpr<mode>"
8790 [(set (match_operand:FMOVE128_GPR 0 "register_operand" "=wa")
8791 (unspec:FMOVE128_GPR
8792 [(match_operand:FMOVE128_GPR 1 "register_operand" "r")]
8793 UNSPEC_P8V_RELOAD_FROM_GPR))
8794 (clobber (match_operand:TF 2 "register_operand" "=ws"))]
8795 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8797 "&& reload_completed"
8800 rtx dest = operands[0];
8801 rtx src = operands[1];
8802 rtx tmp = operands[2];
8803 rtx gpr_hi_reg = gen_highpart (DImode, src);
8804 rtx gpr_lo_reg = gen_lowpart (DImode, src);
8806 emit_insn (gen_p8_mtvsrd_1 (tmp, gpr_hi_reg));
8807 emit_insn (gen_p8_mtvsrd_2 (tmp, gpr_lo_reg));
8808 emit_insn (gen_p8_xxpermdi_<mode> (dest, tmp));
8810 [(set_attr "length" "12")
8811 (set_attr "type" "three")])
8814 [(set (match_operand:FMOVE128_GPR 0 "nonimmediate_operand" "")
8815 (match_operand:FMOVE128_GPR 1 "input_operand" ""))]
8817 && (int_reg_operand (operands[0], <MODE>mode)
8818 || int_reg_operand (operands[1], <MODE>mode))"
8820 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8822 ;; Move SFmode to a VSX from a GPR register. Because scalar floating point
8823 ;; type is stored internally as double precision in the VSX registers, we have
8824 ;; to convert it from the vector format.
8826 (define_insn_and_split "reload_vsx_from_gprsf"
8827 [(set (match_operand:SF 0 "register_operand" "=wa")
8828 (unspec:SF [(match_operand:SF 1 "register_operand" "r")]
8829 UNSPEC_P8V_RELOAD_FROM_GPR))
8830 (clobber (match_operand:DI 2 "register_operand" "=r"))]
8831 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8833 "&& reload_completed"
8836 rtx op0 = operands[0];
8837 rtx op1 = operands[1];
8838 rtx op2 = operands[2];
8839 /* Also use the destination register to hold the unconverted DImode value.
8840 This is conceptually a separate value from OP0, so we use gen_rtx_REG
8841 rather than simplify_gen_subreg. */
8842 rtx op0_di = gen_rtx_REG (DImode, REGNO (op0));
8843 rtx op1_di = simplify_gen_subreg (DImode, op1, SFmode, 0);
8845 /* Move SF value to upper 32-bits for xscvspdpn. */
8846 emit_insn (gen_ashldi3 (op2, op1_di, GEN_INT (32)));
8847 emit_move_insn (op0_di, op2);
8848 emit_insn (gen_vsx_xscvspdpn_directmove (op0, op0_di));
8851 [(set_attr "length" "8")
8852 (set_attr "type" "two")])
8854 ;; Move 128 bit values from VSX registers to GPRs in 64-bit mode by doing a
8855 ;; normal 64-bit move, followed by an xxpermdi to get the bottom 64-bit value,
8856 ;; and then doing a move of that.
8857 (define_insn "p8_mfvsrd_3_<mode>"
8858 [(set (match_operand:DF 0 "register_operand" "=r")
8859 (unspec:DF [(match_operand:FMOVE128_GPR 1 "register_operand" "wa")]
8860 UNSPEC_P8V_RELOAD_FROM_VSX))]
8861 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8863 [(set_attr "type" "mftgpr")])
8865 (define_insn_and_split "reload_gpr_from_vsx<mode>"
8866 [(set (match_operand:FMOVE128_GPR 0 "register_operand" "=r")
8867 (unspec:FMOVE128_GPR
8868 [(match_operand:FMOVE128_GPR 1 "register_operand" "wa")]
8869 UNSPEC_P8V_RELOAD_FROM_VSX))
8870 (clobber (match_operand:FMOVE128_GPR 2 "register_operand" "=wa"))]
8871 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8873 "&& reload_completed"
8876 rtx dest = operands[0];
8877 rtx src = operands[1];
8878 rtx tmp = operands[2];
8879 rtx gpr_hi_reg = gen_highpart (DFmode, dest);
8880 rtx gpr_lo_reg = gen_lowpart (DFmode, dest);
8882 emit_insn (gen_p8_mfvsrd_3_<mode> (gpr_hi_reg, src));
8883 emit_insn (gen_vsx_xxpermdi_<mode> (tmp, src, src, GEN_INT (3)));
8884 emit_insn (gen_p8_mfvsrd_3_<mode> (gpr_lo_reg, tmp));
8886 [(set_attr "length" "12")
8887 (set_attr "type" "three")])
8889 ;; Move SFmode to a GPR from a VSX register. Because scalar floating point
8890 ;; type is stored internally as double precision, we have to convert it to the
8893 (define_insn_and_split "reload_gpr_from_vsxsf"
8894 [(set (match_operand:SF 0 "register_operand" "=r")
8895 (unspec:SF [(match_operand:SF 1 "register_operand" "wa")]
8896 UNSPEC_P8V_RELOAD_FROM_VSX))
8897 (clobber (match_operand:V4SF 2 "register_operand" "=wa"))]
8898 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8900 "&& reload_completed"
8903 rtx op0 = operands[0];
8904 rtx op1 = operands[1];
8905 rtx op2 = operands[2];
8906 rtx diop0 = simplify_gen_subreg (DImode, op0, SFmode, 0);
8908 emit_insn (gen_vsx_xscvdpspn_scalar (op2, op1));
8909 emit_insn (gen_p8_mfvsrd_4_disf (diop0, op2));
8910 emit_insn (gen_lshrdi3 (diop0, diop0, GEN_INT (32)));
8913 [(set_attr "length" "12")
8914 (set_attr "type" "three")])
8916 (define_insn "p8_mfvsrd_4_disf"
8917 [(set (match_operand:DI 0 "register_operand" "=r")
8918 (unspec:DI [(match_operand:V4SF 1 "register_operand" "wa")]
8919 UNSPEC_P8V_RELOAD_FROM_VSX))]
8920 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8922 [(set_attr "type" "mftgpr")])
8925 ;; Next come the multi-word integer load and store and the load and store
8928 ;; List r->r after r->Y, otherwise reload will try to reload a
8929 ;; non-offsettable address by using r->r which won't make progress.
8930 ;; Use of fprs is disparaged slightly otherwise reload prefers to reload
8931 ;; a gpr into a fpr instead of reloading an invalid 'Y' address
8932 (define_insn "*movdi_internal32"
8933 [(set (match_operand:DI 0 "rs6000_nonimmediate_operand" "=Y,r,r,?m,?*d,?*d,r")
8934 (match_operand:DI 1 "input_operand" "r,Y,r,d,m,d,IJKnGHF"))]
8936 && (gpc_reg_operand (operands[0], DImode)
8937 || gpc_reg_operand (operands[1], DImode))"
8946 [(set_attr "type" "store,load,*,fpstore,fpload,fp,*")])
8949 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8950 (match_operand:DI 1 "const_int_operand" ""))]
8951 "! TARGET_POWERPC64 && reload_completed
8952 && gpr_or_gpr_p (operands[0], operands[1])
8953 && !direct_move_p (operands[0], operands[1])"
8954 [(set (match_dup 2) (match_dup 4))
8955 (set (match_dup 3) (match_dup 1))]
8958 HOST_WIDE_INT value = INTVAL (operands[1]);
8959 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8961 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8963 operands[4] = GEN_INT (value >> 32);
8964 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8968 [(set (match_operand:DIFD 0 "rs6000_nonimmediate_operand" "")
8969 (match_operand:DIFD 1 "input_operand" ""))]
8970 "reload_completed && !TARGET_POWERPC64
8971 && gpr_or_gpr_p (operands[0], operands[1])
8972 && !direct_move_p (operands[0], operands[1])"
8974 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8976 (define_insn "*movdi_internal64"
8977 [(set (match_operand:DI 0 "nonimmediate_operand" "=Y,r,r,r,r,r,?m,?*d,?*d,r,*h,*h,r,?*wg,r,?*wj,?*wi")
8978 (match_operand:DI 1 "input_operand" "r,Y,r,I,L,nF,d,m,d,*h,r,0,*wg,r,*wj,r,O"))]
8980 && (gpc_reg_operand (operands[0], DImode)
8981 || gpc_reg_operand (operands[1], DImode))"
9000 [(set_attr "type" "store,load,*,*,*,*,fpstore,fpload,fp,mfjmpr,mtjmpr,*,mftgpr,mffgpr,mftgpr,mffgpr,vecsimple")
9001 (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4,4,4,4,4")])
9003 ;; Generate all one-bits and clear left or right.
9004 ;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
9006 [(set (match_operand:DI 0 "gpc_reg_operand" "")
9007 (match_operand:DI 1 "mask64_operand" ""))]
9008 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
9009 [(set (match_dup 0) (const_int -1))
9011 (and:DI (rotate:DI (match_dup 0)
9016 ;; Split a load of a large constant into the appropriate five-instruction
9017 ;; sequence. Handle anything in a constant number of insns.
9018 ;; When non-easy constants can go in the TOC, this should use
9019 ;; easy_fp_constant predicate.
9021 [(set (match_operand:DI 0 "gpc_reg_operand" "")
9022 (match_operand:DI 1 "const_int_operand" ""))]
9023 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
9024 [(set (match_dup 0) (match_dup 2))
9025 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
9028 if (rs6000_emit_set_const (operands[0], operands[1]))
9035 [(set (match_operand:DI 0 "gpc_reg_operand" "")
9036 (match_operand:DI 1 "const_scalar_int_operand" ""))]
9037 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
9038 [(set (match_dup 0) (match_dup 2))
9039 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
9042 if (rs6000_emit_set_const (operands[0], operands[1]))
9048 ;; TImode/PTImode is similar, except that we usually want to compute the
9049 ;; address into a register and use lsi/stsi (the exception is during reload).
9051 (define_insn "*mov<mode>_string"
9052 [(set (match_operand:TI2 0 "reg_or_mem_operand" "=Q,Y,????r,????r,????r,r")
9053 (match_operand:TI2 1 "input_operand" "r,r,Q,Y,r,n"))]
9055 && (<MODE>mode != TImode || VECTOR_MEM_NONE_P (TImode))
9056 && (gpc_reg_operand (operands[0], <MODE>mode)
9057 || gpc_reg_operand (operands[1], <MODE>mode))"
9060 switch (which_alternative)
9066 return \"stswi %1,%P0,16\";
9070 /* If the address is not used in the output, we can use lsi. Otherwise,
9071 fall through to generating four loads. */
9073 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
9074 return \"lswi %0,%P1,16\";
9075 /* ... fall through ... */
9082 [(set_attr "type" "store,store,load,load,*,*")
9083 (set_attr "update" "yes")
9084 (set_attr "indexed" "yes")
9085 (set (attr "cell_micro") (if_then_else (match_test "TARGET_STRING")
9086 (const_string "always")
9087 (const_string "conditional")))])
9089 (define_insn "*mov<mode>_ppc64"
9090 [(set (match_operand:TI2 0 "nonimmediate_operand" "=wQ,Y,r,r,r,r")
9091 (match_operand:TI2 1 "input_operand" "r,r,wQ,Y,r,n"))]
9092 "(TARGET_POWERPC64 && VECTOR_MEM_NONE_P (<MODE>mode)
9093 && (gpc_reg_operand (operands[0], <MODE>mode)
9094 || gpc_reg_operand (operands[1], <MODE>mode)))"
9096 return rs6000_output_move_128bit (operands);
9098 [(set_attr "type" "store,store,load,load,*,*")
9099 (set_attr "length" "8")])
9102 [(set (match_operand:TI2 0 "int_reg_operand" "")
9103 (match_operand:TI2 1 "const_scalar_int_operand" ""))]
9105 && (VECTOR_MEM_NONE_P (<MODE>mode)
9106 || (reload_completed && INT_REGNO_P (REGNO (operands[0]))))"
9107 [(set (match_dup 2) (match_dup 4))
9108 (set (match_dup 3) (match_dup 5))]
9111 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
9113 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
9115 if (CONST_WIDE_INT_P (operands[1]))
9117 operands[4] = GEN_INT (CONST_WIDE_INT_ELT (operands[1], 1));
9118 operands[5] = GEN_INT (CONST_WIDE_INT_ELT (operands[1], 0));
9120 else if (CONST_INT_P (operands[1]))
9122 operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
9123 operands[5] = operands[1];
9130 [(set (match_operand:TI2 0 "nonimmediate_operand" "")
9131 (match_operand:TI2 1 "input_operand" ""))]
9133 && gpr_or_gpr_p (operands[0], operands[1])
9134 && !direct_move_p (operands[0], operands[1])
9135 && !quad_load_store_p (operands[0], operands[1])"
9137 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
9139 (define_expand "load_multiple"
9140 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
9141 (match_operand:SI 1 "" ""))
9142 (use (match_operand:SI 2 "" ""))])]
9143 "TARGET_STRING && !TARGET_POWERPC64"
9151 /* Support only loading a constant number of fixed-point registers from
9152 memory and only bother with this if more than two; the machine
9153 doesn't support more than eight. */
9154 if (GET_CODE (operands[2]) != CONST_INT
9155 || INTVAL (operands[2]) <= 2
9156 || INTVAL (operands[2]) > 8
9157 || GET_CODE (operands[1]) != MEM
9158 || GET_CODE (operands[0]) != REG
9159 || REGNO (operands[0]) >= 32)
9162 count = INTVAL (operands[2]);
9163 regno = REGNO (operands[0]);
9165 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
9166 op1 = replace_equiv_address (operands[1],
9167 force_reg (SImode, XEXP (operands[1], 0)));
9169 for (i = 0; i < count; i++)
9170 XVECEXP (operands[3], 0, i)
9171 = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
9172 adjust_address_nv (op1, SImode, i * 4));
9175 (define_insn "*ldmsi8"
9176 [(match_parallel 0 "load_multiple_operation"
9177 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9178 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9179 (set (match_operand:SI 3 "gpc_reg_operand" "")
9180 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9181 (set (match_operand:SI 4 "gpc_reg_operand" "")
9182 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9183 (set (match_operand:SI 5 "gpc_reg_operand" "")
9184 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
9185 (set (match_operand:SI 6 "gpc_reg_operand" "")
9186 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
9187 (set (match_operand:SI 7 "gpc_reg_operand" "")
9188 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
9189 (set (match_operand:SI 8 "gpc_reg_operand" "")
9190 (mem:SI (plus:SI (match_dup 1) (const_int 24))))
9191 (set (match_operand:SI 9 "gpc_reg_operand" "")
9192 (mem:SI (plus:SI (match_dup 1) (const_int 28))))])]
9193 "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
9195 { return rs6000_output_load_multiple (operands); }"
9196 [(set_attr "type" "load")
9197 (set_attr "update" "yes")
9198 (set_attr "indexed" "yes")
9199 (set_attr "length" "32")])
9201 (define_insn "*ldmsi7"
9202 [(match_parallel 0 "load_multiple_operation"
9203 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9204 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9205 (set (match_operand:SI 3 "gpc_reg_operand" "")
9206 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9207 (set (match_operand:SI 4 "gpc_reg_operand" "")
9208 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9209 (set (match_operand:SI 5 "gpc_reg_operand" "")
9210 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
9211 (set (match_operand:SI 6 "gpc_reg_operand" "")
9212 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
9213 (set (match_operand:SI 7 "gpc_reg_operand" "")
9214 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
9215 (set (match_operand:SI 8 "gpc_reg_operand" "")
9216 (mem:SI (plus:SI (match_dup 1) (const_int 24))))])]
9217 "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
9219 { return rs6000_output_load_multiple (operands); }"
9220 [(set_attr "type" "load")
9221 (set_attr "update" "yes")
9222 (set_attr "indexed" "yes")
9223 (set_attr "length" "32")])
9225 (define_insn "*ldmsi6"
9226 [(match_parallel 0 "load_multiple_operation"
9227 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9228 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9229 (set (match_operand:SI 3 "gpc_reg_operand" "")
9230 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9231 (set (match_operand:SI 4 "gpc_reg_operand" "")
9232 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9233 (set (match_operand:SI 5 "gpc_reg_operand" "")
9234 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
9235 (set (match_operand:SI 6 "gpc_reg_operand" "")
9236 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
9237 (set (match_operand:SI 7 "gpc_reg_operand" "")
9238 (mem:SI (plus:SI (match_dup 1) (const_int 20))))])]
9239 "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
9241 { return rs6000_output_load_multiple (operands); }"
9242 [(set_attr "type" "load")
9243 (set_attr "update" "yes")
9244 (set_attr "indexed" "yes")
9245 (set_attr "length" "32")])
9247 (define_insn "*ldmsi5"
9248 [(match_parallel 0 "load_multiple_operation"
9249 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9250 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9251 (set (match_operand:SI 3 "gpc_reg_operand" "")
9252 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9253 (set (match_operand:SI 4 "gpc_reg_operand" "")
9254 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9255 (set (match_operand:SI 5 "gpc_reg_operand" "")
9256 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
9257 (set (match_operand:SI 6 "gpc_reg_operand" "")
9258 (mem:SI (plus:SI (match_dup 1) (const_int 16))))])]
9259 "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
9261 { return rs6000_output_load_multiple (operands); }"
9262 [(set_attr "type" "load")
9263 (set_attr "update" "yes")
9264 (set_attr "indexed" "yes")
9265 (set_attr "length" "32")])
9267 (define_insn "*ldmsi4"
9268 [(match_parallel 0 "load_multiple_operation"
9269 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9270 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9271 (set (match_operand:SI 3 "gpc_reg_operand" "")
9272 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9273 (set (match_operand:SI 4 "gpc_reg_operand" "")
9274 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
9275 (set (match_operand:SI 5 "gpc_reg_operand" "")
9276 (mem:SI (plus:SI (match_dup 1) (const_int 12))))])]
9277 "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
9279 { return rs6000_output_load_multiple (operands); }"
9280 [(set_attr "type" "load")
9281 (set_attr "update" "yes")
9282 (set_attr "indexed" "yes")
9283 (set_attr "length" "32")])
9285 (define_insn "*ldmsi3"
9286 [(match_parallel 0 "load_multiple_operation"
9287 [(set (match_operand:SI 2 "gpc_reg_operand" "")
9288 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
9289 (set (match_operand:SI 3 "gpc_reg_operand" "")
9290 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
9291 (set (match_operand:SI 4 "gpc_reg_operand" "")
9292 (mem:SI (plus:SI (match_dup 1) (const_int 8))))])]
9293 "TARGET_STRING && XVECLEN (operands[0], 0) == 3"
9295 { return rs6000_output_load_multiple (operands); }"
9296 [(set_attr "type" "load")
9297 (set_attr "update" "yes")
9298 (set_attr "indexed" "yes")
9299 (set_attr "length" "32")])
9301 (define_expand "store_multiple"
9302 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
9303 (match_operand:SI 1 "" ""))
9304 (clobber (scratch:SI))
9305 (use (match_operand:SI 2 "" ""))])]
9306 "TARGET_STRING && !TARGET_POWERPC64"
9315 /* Support only storing a constant number of fixed-point registers to
9316 memory and only bother with this if more than two; the machine
9317 doesn't support more than eight. */
9318 if (GET_CODE (operands[2]) != CONST_INT
9319 || INTVAL (operands[2]) <= 2
9320 || INTVAL (operands[2]) > 8
9321 || GET_CODE (operands[0]) != MEM
9322 || GET_CODE (operands[1]) != REG
9323 || REGNO (operands[1]) >= 32)
9326 count = INTVAL (operands[2]);
9327 regno = REGNO (operands[1]);
9329 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
9330 to = force_reg (SImode, XEXP (operands[0], 0));
9331 op0 = replace_equiv_address (operands[0], to);
9333 XVECEXP (operands[3], 0, 0)
9334 = gen_rtx_SET (VOIDmode, adjust_address_nv (op0, SImode, 0), operands[1]);
9335 XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
9336 gen_rtx_SCRATCH (SImode));
9338 for (i = 1; i < count; i++)
9339 XVECEXP (operands[3], 0, i + 1)
9340 = gen_rtx_SET (VOIDmode,
9341 adjust_address_nv (op0, SImode, i * 4),
9342 gen_rtx_REG (SImode, regno + i));
9345 (define_insn "*stmsi8"
9346 [(match_parallel 0 "store_multiple_operation"
9347 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9348 (match_operand:SI 2 "gpc_reg_operand" "r"))
9349 (clobber (match_scratch:SI 3 "=X"))
9350 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9351 (match_operand:SI 4 "gpc_reg_operand" "r"))
9352 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9353 (match_operand:SI 5 "gpc_reg_operand" "r"))
9354 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9355 (match_operand:SI 6 "gpc_reg_operand" "r"))
9356 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9357 (match_operand:SI 7 "gpc_reg_operand" "r"))
9358 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9359 (match_operand:SI 8 "gpc_reg_operand" "r"))
9360 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9361 (match_operand:SI 9 "gpc_reg_operand" "r"))
9362 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
9363 (match_operand:SI 10 "gpc_reg_operand" "r"))])]
9364 "TARGET_STRING && XVECLEN (operands[0], 0) == 9"
9366 [(set_attr "type" "store")
9367 (set_attr "update" "yes")
9368 (set_attr "indexed" "yes")
9369 (set_attr "cell_micro" "always")])
9371 (define_insn "*stmsi7"
9372 [(match_parallel 0 "store_multiple_operation"
9373 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9374 (match_operand:SI 2 "gpc_reg_operand" "r"))
9375 (clobber (match_scratch:SI 3 "=X"))
9376 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9377 (match_operand:SI 4 "gpc_reg_operand" "r"))
9378 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9379 (match_operand:SI 5 "gpc_reg_operand" "r"))
9380 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9381 (match_operand:SI 6 "gpc_reg_operand" "r"))
9382 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9383 (match_operand:SI 7 "gpc_reg_operand" "r"))
9384 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9385 (match_operand:SI 8 "gpc_reg_operand" "r"))
9386 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9387 (match_operand:SI 9 "gpc_reg_operand" "r"))])]
9388 "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
9390 [(set_attr "type" "store")
9391 (set_attr "update" "yes")
9392 (set_attr "indexed" "yes")
9393 (set_attr "cell_micro" "always")])
9395 (define_insn "*stmsi6"
9396 [(match_parallel 0 "store_multiple_operation"
9397 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9398 (match_operand:SI 2 "gpc_reg_operand" "r"))
9399 (clobber (match_scratch:SI 3 "=X"))
9400 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9401 (match_operand:SI 4 "gpc_reg_operand" "r"))
9402 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9403 (match_operand:SI 5 "gpc_reg_operand" "r"))
9404 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9405 (match_operand:SI 6 "gpc_reg_operand" "r"))
9406 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9407 (match_operand:SI 7 "gpc_reg_operand" "r"))
9408 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9409 (match_operand:SI 8 "gpc_reg_operand" "r"))])]
9410 "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
9412 [(set_attr "type" "store")
9413 (set_attr "update" "yes")
9414 (set_attr "indexed" "yes")
9415 (set_attr "cell_micro" "always")])
9417 (define_insn "*stmsi5"
9418 [(match_parallel 0 "store_multiple_operation"
9419 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9420 (match_operand:SI 2 "gpc_reg_operand" "r"))
9421 (clobber (match_scratch:SI 3 "=X"))
9422 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9423 (match_operand:SI 4 "gpc_reg_operand" "r"))
9424 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9425 (match_operand:SI 5 "gpc_reg_operand" "r"))
9426 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9427 (match_operand:SI 6 "gpc_reg_operand" "r"))
9428 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9429 (match_operand:SI 7 "gpc_reg_operand" "r"))])]
9430 "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
9432 [(set_attr "type" "store")
9433 (set_attr "update" "yes")
9434 (set_attr "indexed" "yes")
9435 (set_attr "cell_micro" "always")])
9437 (define_insn "*stmsi4"
9438 [(match_parallel 0 "store_multiple_operation"
9439 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9440 (match_operand:SI 2 "gpc_reg_operand" "r"))
9441 (clobber (match_scratch:SI 3 "=X"))
9442 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9443 (match_operand:SI 4 "gpc_reg_operand" "r"))
9444 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9445 (match_operand:SI 5 "gpc_reg_operand" "r"))
9446 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9447 (match_operand:SI 6 "gpc_reg_operand" "r"))])]
9448 "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
9450 [(set_attr "type" "store")
9451 (set_attr "update" "yes")
9452 (set_attr "indexed" "yes")
9453 (set_attr "cell_micro" "always")])
9455 (define_insn "*stmsi3"
9456 [(match_parallel 0 "store_multiple_operation"
9457 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9458 (match_operand:SI 2 "gpc_reg_operand" "r"))
9459 (clobber (match_scratch:SI 3 "=X"))
9460 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9461 (match_operand:SI 4 "gpc_reg_operand" "r"))
9462 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9463 (match_operand:SI 5 "gpc_reg_operand" "r"))])]
9464 "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
9466 [(set_attr "type" "store")
9467 (set_attr "update" "yes")
9468 (set_attr "indexed" "yes")
9469 (set_attr "cell_micro" "always")])
9471 (define_expand "setmemsi"
9472 [(parallel [(set (match_operand:BLK 0 "" "")
9473 (match_operand 2 "const_int_operand" ""))
9474 (use (match_operand:SI 1 "" ""))
9475 (use (match_operand:SI 3 "" ""))])]
9479 /* If value to set is not zero, use the library routine. */
9480 if (operands[2] != const0_rtx)
9483 if (expand_block_clear (operands))
9489 ;; String/block move insn.
9490 ;; Argument 0 is the destination
9491 ;; Argument 1 is the source
9492 ;; Argument 2 is the length
9493 ;; Argument 3 is the alignment
9495 (define_expand "movmemsi"
9496 [(parallel [(set (match_operand:BLK 0 "" "")
9497 (match_operand:BLK 1 "" ""))
9498 (use (match_operand:SI 2 "" ""))
9499 (use (match_operand:SI 3 "" ""))])]
9503 if (expand_block_move (operands))
9509 ;; Move up to 32 bytes at a time. The fixed registers are needed because the
9510 ;; register allocator doesn't have a clue about allocating 8 word registers.
9511 ;; rD/rS = r5 is preferred, efficient form.
9512 (define_expand "movmemsi_8reg"
9513 [(parallel [(set (match_operand 0 "" "")
9514 (match_operand 1 "" ""))
9515 (use (match_operand 2 "" ""))
9516 (use (match_operand 3 "" ""))
9517 (clobber (reg:SI 5))
9518 (clobber (reg:SI 6))
9519 (clobber (reg:SI 7))
9520 (clobber (reg:SI 8))
9521 (clobber (reg:SI 9))
9522 (clobber (reg:SI 10))
9523 (clobber (reg:SI 11))
9524 (clobber (reg:SI 12))
9525 (clobber (match_scratch:SI 4 ""))])]
9530 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9531 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9532 (use (match_operand:SI 2 "immediate_operand" "i"))
9533 (use (match_operand:SI 3 "immediate_operand" "i"))
9534 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9535 (clobber (reg:SI 6))
9536 (clobber (reg:SI 7))
9537 (clobber (reg:SI 8))
9538 (clobber (reg:SI 9))
9539 (clobber (reg:SI 10))
9540 (clobber (reg:SI 11))
9541 (clobber (reg:SI 12))
9542 (clobber (match_scratch:SI 5 "=X"))]
9544 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9545 || INTVAL (operands[2]) == 0)
9546 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9547 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9548 && REGNO (operands[4]) == 5"
9549 "lswi %4,%1,%2\;stswi %4,%0,%2"
9550 [(set_attr "type" "store")
9551 (set_attr "update" "yes")
9552 (set_attr "indexed" "yes")
9553 (set_attr "cell_micro" "always")
9554 (set_attr "length" "8")])
9556 ;; Move up to 24 bytes at a time. The fixed registers are needed because the
9557 ;; register allocator doesn't have a clue about allocating 6 word registers.
9558 ;; rD/rS = r5 is preferred, efficient form.
9559 (define_expand "movmemsi_6reg"
9560 [(parallel [(set (match_operand 0 "" "")
9561 (match_operand 1 "" ""))
9562 (use (match_operand 2 "" ""))
9563 (use (match_operand 3 "" ""))
9564 (clobber (reg:SI 5))
9565 (clobber (reg:SI 6))
9566 (clobber (reg:SI 7))
9567 (clobber (reg:SI 8))
9568 (clobber (reg:SI 9))
9569 (clobber (reg:SI 10))
9570 (clobber (match_scratch:SI 4 ""))])]
9575 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9576 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9577 (use (match_operand:SI 2 "immediate_operand" "i"))
9578 (use (match_operand:SI 3 "immediate_operand" "i"))
9579 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9580 (clobber (reg:SI 6))
9581 (clobber (reg:SI 7))
9582 (clobber (reg:SI 8))
9583 (clobber (reg:SI 9))
9584 (clobber (reg:SI 10))
9585 (clobber (match_scratch:SI 5 "=X"))]
9587 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9588 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9589 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9590 && REGNO (operands[4]) == 5"
9591 "lswi %4,%1,%2\;stswi %4,%0,%2"
9592 [(set_attr "type" "store")
9593 (set_attr "update" "yes")
9594 (set_attr "indexed" "yes")
9595 (set_attr "cell_micro" "always")
9596 (set_attr "length" "8")])
9598 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
9599 ;; problems with TImode.
9600 ;; rD/rS = r5 is preferred, efficient form.
9601 (define_expand "movmemsi_4reg"
9602 [(parallel [(set (match_operand 0 "" "")
9603 (match_operand 1 "" ""))
9604 (use (match_operand 2 "" ""))
9605 (use (match_operand 3 "" ""))
9606 (clobber (reg:SI 5))
9607 (clobber (reg:SI 6))
9608 (clobber (reg:SI 7))
9609 (clobber (reg:SI 8))
9610 (clobber (match_scratch:SI 4 ""))])]
9615 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9616 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9617 (use (match_operand:SI 2 "immediate_operand" "i"))
9618 (use (match_operand:SI 3 "immediate_operand" "i"))
9619 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9620 (clobber (reg:SI 6))
9621 (clobber (reg:SI 7))
9622 (clobber (reg:SI 8))
9623 (clobber (match_scratch:SI 5 "=X"))]
9625 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9626 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9627 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9628 && REGNO (operands[4]) == 5"
9629 "lswi %4,%1,%2\;stswi %4,%0,%2"
9630 [(set_attr "type" "store")
9631 (set_attr "update" "yes")
9632 (set_attr "indexed" "yes")
9633 (set_attr "cell_micro" "always")
9634 (set_attr "length" "8")])
9636 ;; Move up to 8 bytes at a time.
9637 (define_expand "movmemsi_2reg"
9638 [(parallel [(set (match_operand 0 "" "")
9639 (match_operand 1 "" ""))
9640 (use (match_operand 2 "" ""))
9641 (use (match_operand 3 "" ""))
9642 (clobber (match_scratch:DI 4 ""))
9643 (clobber (match_scratch:SI 5 ""))])]
9644 "TARGET_STRING && ! TARGET_POWERPC64"
9648 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9649 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9650 (use (match_operand:SI 2 "immediate_operand" "i"))
9651 (use (match_operand:SI 3 "immediate_operand" "i"))
9652 (clobber (match_scratch:DI 4 "=&r"))
9653 (clobber (match_scratch:SI 5 "=X"))]
9654 "TARGET_STRING && ! TARGET_POWERPC64
9655 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9656 "lswi %4,%1,%2\;stswi %4,%0,%2"
9657 [(set_attr "type" "store")
9658 (set_attr "update" "yes")
9659 (set_attr "indexed" "yes")
9660 (set_attr "cell_micro" "always")
9661 (set_attr "length" "8")])
9663 ;; Move up to 4 bytes at a time.
9664 (define_expand "movmemsi_1reg"
9665 [(parallel [(set (match_operand 0 "" "")
9666 (match_operand 1 "" ""))
9667 (use (match_operand 2 "" ""))
9668 (use (match_operand 3 "" ""))
9669 (clobber (match_scratch:SI 4 ""))
9670 (clobber (match_scratch:SI 5 ""))])]
9675 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9676 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9677 (use (match_operand:SI 2 "immediate_operand" "i"))
9678 (use (match_operand:SI 3 "immediate_operand" "i"))
9679 (clobber (match_scratch:SI 4 "=&r"))
9680 (clobber (match_scratch:SI 5 "=X"))]
9681 "TARGET_STRING && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9682 "lswi %4,%1,%2\;stswi %4,%0,%2"
9683 [(set_attr "type" "store")
9684 (set_attr "update" "yes")
9685 (set_attr "indexed" "yes")
9686 (set_attr "cell_micro" "always")
9687 (set_attr "length" "8")])
9689 ;; Define insns that do load or store with update. Some of these we can
9690 ;; get by using pre-decrement or pre-increment, but the hardware can also
9691 ;; do cases where the increment is not the size of the object.
9693 ;; In all these cases, we use operands 0 and 1 for the register being
9694 ;; incremented because those are the operands that local-alloc will
9695 ;; tie and these are the pair most likely to be tieable (and the ones
9696 ;; that will benefit the most).
9698 (define_insn "*movdi_update1"
9699 [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
9700 (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9701 (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
9702 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9703 (plus:DI (match_dup 1) (match_dup 2)))]
9704 "TARGET_POWERPC64 && TARGET_UPDATE
9705 && (!avoiding_indexed_address_p (DImode)
9706 || !gpc_reg_operand (operands[2], DImode))"
9710 [(set_attr "type" "load")
9711 (set_attr "update" "yes")
9712 (set_attr "indexed" "yes,no")])
9714 (define_insn "movdi_<mode>_update"
9715 [(set (mem:DI (plus:P (match_operand:P 1 "gpc_reg_operand" "0,0")
9716 (match_operand:P 2 "reg_or_aligned_short_operand" "r,I")))
9717 (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9718 (set (match_operand:P 0 "gpc_reg_operand" "=b,b")
9719 (plus:P (match_dup 1) (match_dup 2)))]
9720 "TARGET_POWERPC64 && TARGET_UPDATE
9721 && (!avoiding_indexed_address_p (Pmode)
9722 || !gpc_reg_operand (operands[2], Pmode)
9723 || (REG_P (operands[0])
9724 && REGNO (operands[0]) == STACK_POINTER_REGNUM))"
9728 [(set_attr "type" "store")
9729 (set_attr "update" "yes")
9730 (set_attr "indexed" "yes,no")])
9732 ;; This pattern is only conditional on TARGET_POWERPC64, as it is
9733 ;; needed for stack allocation, even if the user passes -mno-update.
9734 (define_insn "movdi_<mode>_update_stack"
9735 [(set (mem:DI (plus:P (match_operand:P 1 "gpc_reg_operand" "0,0")
9736 (match_operand:P 2 "reg_or_aligned_short_operand" "r,I")))
9737 (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9738 (set (match_operand:P 0 "gpc_reg_operand" "=b,b")
9739 (plus:P (match_dup 1) (match_dup 2)))]
9744 [(set_attr "type" "store")
9745 (set_attr "update" "yes")
9746 (set_attr "indexed" "yes,no")])
9748 (define_insn "*movsi_update1"
9749 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9750 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9751 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9752 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9753 (plus:SI (match_dup 1) (match_dup 2)))]
9755 && (!avoiding_indexed_address_p (SImode)
9756 || !gpc_reg_operand (operands[2], SImode))"
9760 [(set_attr "type" "load")
9761 (set_attr "update" "yes")
9762 (set_attr "indexed" "yes,no")])
9764 (define_insn "*movsi_update2"
9765 [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
9767 (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
9768 (match_operand:DI 2 "gpc_reg_operand" "r")))))
9769 (set (match_operand:DI 0 "gpc_reg_operand" "=b")
9770 (plus:DI (match_dup 1) (match_dup 2)))]
9771 "TARGET_POWERPC64 && rs6000_gen_cell_microcode
9772 && !avoiding_indexed_address_p (DImode)"
9774 [(set_attr "type" "load")
9775 (set_attr "sign_extend" "yes")
9776 (set_attr "update" "yes")
9777 (set_attr "indexed" "yes")])
9779 (define_insn "movsi_update"
9780 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9781 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9782 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9783 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9784 (plus:SI (match_dup 1) (match_dup 2)))]
9786 && (!avoiding_indexed_address_p (SImode)
9787 || !gpc_reg_operand (operands[2], SImode)
9788 || (REG_P (operands[0])
9789 && REGNO (operands[0]) == STACK_POINTER_REGNUM))"
9793 [(set_attr "type" "store")
9794 (set_attr "update" "yes")
9795 (set_attr "indexed" "yes,no")])
9797 ;; This is an unconditional pattern; needed for stack allocation, even
9798 ;; if the user passes -mno-update.
9799 (define_insn "movsi_update_stack"
9800 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9801 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9802 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9803 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9804 (plus:SI (match_dup 1) (match_dup 2)))]
9809 [(set_attr "type" "store")
9810 (set_attr "update" "yes")
9811 (set_attr "indexed" "yes,no")])
9813 (define_insn "*movhi_update1"
9814 [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
9815 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9816 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9817 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9818 (plus:SI (match_dup 1) (match_dup 2)))]
9820 && (!avoiding_indexed_address_p (SImode)
9821 || !gpc_reg_operand (operands[2], SImode))"
9825 [(set_attr "type" "load")
9826 (set_attr "update" "yes")
9827 (set_attr "indexed" "yes,no")])
9829 (define_insn "*movhi_update2"
9830 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9832 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9833 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9834 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9835 (plus:SI (match_dup 1) (match_dup 2)))]
9837 && (!avoiding_indexed_address_p (SImode)
9838 || !gpc_reg_operand (operands[2], SImode))"
9842 [(set_attr "type" "load")
9843 (set_attr "update" "yes")
9844 (set_attr "indexed" "yes,no")])
9846 (define_insn "*movhi_update3"
9847 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9849 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9850 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9851 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9852 (plus:SI (match_dup 1) (match_dup 2)))]
9853 "TARGET_UPDATE && rs6000_gen_cell_microcode
9854 && (!avoiding_indexed_address_p (SImode)
9855 || !gpc_reg_operand (operands[2], SImode))"
9859 [(set_attr "type" "load")
9860 (set_attr "sign_extend" "yes")
9861 (set_attr "update" "yes")
9862 (set_attr "indexed" "yes,no")])
9864 (define_insn "*movhi_update4"
9865 [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9866 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9867 (match_operand:HI 3 "gpc_reg_operand" "r,r"))
9868 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9869 (plus:SI (match_dup 1) (match_dup 2)))]
9871 && (!avoiding_indexed_address_p (SImode)
9872 || !gpc_reg_operand (operands[2], SImode))"
9876 [(set_attr "type" "store")
9877 (set_attr "update" "yes")
9878 (set_attr "indexed" "yes,no")])
9880 (define_insn "*movqi_update1"
9881 [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
9882 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9883 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9884 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9885 (plus:SI (match_dup 1) (match_dup 2)))]
9887 && (!avoiding_indexed_address_p (SImode)
9888 || !gpc_reg_operand (operands[2], SImode))"
9892 [(set_attr "type" "load")
9893 (set_attr "update" "yes")
9894 (set_attr "indexed" "yes,no")])
9896 (define_insn "*movqi_update2"
9897 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9899 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9900 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9901 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9902 (plus:SI (match_dup 1) (match_dup 2)))]
9904 && (!avoiding_indexed_address_p (SImode)
9905 || !gpc_reg_operand (operands[2], SImode))"
9909 [(set_attr "type" "load")
9910 (set_attr "update" "yes")
9911 (set_attr "indexed" "yes,no")])
9913 (define_insn "*movqi_update3"
9914 [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9915 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9916 (match_operand:QI 3 "gpc_reg_operand" "r,r"))
9917 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9918 (plus:SI (match_dup 1) (match_dup 2)))]
9920 && (!avoiding_indexed_address_p (SImode)
9921 || !gpc_reg_operand (operands[2], SImode))"
9925 [(set_attr "type" "store")
9926 (set_attr "update" "yes")
9927 (set_attr "indexed" "yes,no")])
9929 (define_insn "*movsf_update1"
9930 [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
9931 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9932 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9933 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9934 (plus:SI (match_dup 1) (match_dup 2)))]
9935 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT && TARGET_UPDATE
9936 && (!avoiding_indexed_address_p (SImode)
9937 || !gpc_reg_operand (operands[2], SImode))"
9941 [(set_attr "type" "fpload")
9942 (set_attr "update" "yes")
9943 (set_attr "indexed" "yes,no")])
9945 (define_insn "*movsf_update2"
9946 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9947 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9948 (match_operand:SF 3 "gpc_reg_operand" "f,f"))
9949 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9950 (plus:SI (match_dup 1) (match_dup 2)))]
9951 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT && TARGET_UPDATE
9952 && (!avoiding_indexed_address_p (SImode)
9953 || !gpc_reg_operand (operands[2], SImode))"
9957 [(set_attr "type" "fpstore")
9958 (set_attr "update" "yes")
9959 (set_attr "indexed" "yes,no")])
9961 (define_insn "*movsf_update3"
9962 [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
9963 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9964 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9965 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9966 (plus:SI (match_dup 1) (match_dup 2)))]
9967 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE
9968 && (!avoiding_indexed_address_p (SImode)
9969 || !gpc_reg_operand (operands[2], SImode))"
9973 [(set_attr "type" "load")
9974 (set_attr "update" "yes")
9975 (set_attr "indexed" "yes,no")])
9977 (define_insn "*movsf_update4"
9978 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9979 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9980 (match_operand:SF 3 "gpc_reg_operand" "r,r"))
9981 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9982 (plus:SI (match_dup 1) (match_dup 2)))]
9983 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE
9984 && (!avoiding_indexed_address_p (SImode)
9985 || !gpc_reg_operand (operands[2], SImode))"
9989 [(set_attr "type" "store")
9990 (set_attr "update" "yes")
9991 (set_attr "indexed" "yes,no")])
9993 (define_insn "*movdf_update1"
9994 [(set (match_operand:DF 3 "gpc_reg_operand" "=d,d")
9995 (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9996 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9997 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9998 (plus:SI (match_dup 1) (match_dup 2)))]
9999 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_UPDATE
10000 && (!avoiding_indexed_address_p (SImode)
10001 || !gpc_reg_operand (operands[2], SImode))"
10005 [(set_attr "type" "fpload")
10006 (set_attr "update" "yes")
10007 (set_attr "indexed" "yes,no")])
10009 (define_insn "*movdf_update2"
10010 [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
10011 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
10012 (match_operand:DF 3 "gpc_reg_operand" "d,d"))
10013 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
10014 (plus:SI (match_dup 1) (match_dup 2)))]
10015 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_UPDATE
10016 && (!avoiding_indexed_address_p (SImode)
10017 || !gpc_reg_operand (operands[2], SImode))"
10021 [(set_attr "type" "fpstore")
10022 (set_attr "update" "yes")
10023 (set_attr "indexed" "yes,no")])
10026 ;; After inserting conditional returns we can sometimes have
10027 ;; unnecessary register moves. Unfortunately we cannot have a
10028 ;; modeless peephole here, because some single SImode sets have early
10029 ;; clobber outputs. Although those sets expand to multi-ppc-insn
10030 ;; sequences, using get_attr_length here will smash the operands
10031 ;; array. Neither is there an early_cobbler_p predicate.
10032 ;; Disallow subregs for E500 so we don't munge frob_di_df_2.
10033 ;; Also this optimization interferes with scalars going into
10034 ;; altivec registers (the code does reloading through the FPRs).
10036 [(set (match_operand:DF 0 "gpc_reg_operand" "")
10037 (match_operand:DF 1 "any_operand" ""))
10038 (set (match_operand:DF 2 "gpc_reg_operand" "")
10040 "!(TARGET_E500_DOUBLE && GET_CODE (operands[2]) == SUBREG)
10041 && !TARGET_UPPER_REGS_DF
10042 && peep2_reg_dead_p (2, operands[0])"
10043 [(set (match_dup 2) (match_dup 1))])
10046 [(set (match_operand:SF 0 "gpc_reg_operand" "")
10047 (match_operand:SF 1 "any_operand" ""))
10048 (set (match_operand:SF 2 "gpc_reg_operand" "")
10050 "!TARGET_UPPER_REGS_SF
10051 && peep2_reg_dead_p (2, operands[0])"
10052 [(set (match_dup 2) (match_dup 1))])
10057 ;; Mode attributes for different ABIs.
10058 (define_mode_iterator TLSmode [(SI "! TARGET_64BIT") (DI "TARGET_64BIT")])
10059 (define_mode_attr tls_abi_suffix [(SI "32") (DI "64")])
10060 (define_mode_attr tls_sysv_suffix [(SI "si") (DI "di")])
10061 (define_mode_attr tls_insn_suffix [(SI "wz") (DI "d")])
10063 (define_insn_and_split "tls_gd_aix<TLSmode:tls_abi_suffix>"
10064 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10065 (call (mem:TLSmode (match_operand:TLSmode 3 "symbol_ref_operand" "s"))
10066 (match_operand 4 "" "g")))
10067 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10068 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10070 (clobber (reg:SI LR_REGNO))]
10071 "HAVE_AS_TLS && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
10073 if (TARGET_CMODEL != CMODEL_SMALL)
10074 return "addis %0,%1,%2@got@tlsgd@ha\;addi %0,%0,%2@got@tlsgd@l\;"
10077 return "addi %0,%1,%2@got@tlsgd\;bl %z3\;nop";
10079 "&& TARGET_TLS_MARKERS"
10080 [(set (match_dup 0)
10081 (unspec:TLSmode [(match_dup 1)
10084 (parallel [(set (match_dup 0)
10085 (call (mem:TLSmode (match_dup 3))
10087 (unspec:TLSmode [(match_dup 2)] UNSPEC_TLSGD)
10088 (clobber (reg:SI LR_REGNO))])]
10090 [(set_attr "type" "two")
10091 (set (attr "length")
10092 (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
10096 (define_insn_and_split "tls_gd_sysv<TLSmode:tls_sysv_suffix>"
10097 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10098 (call (mem:TLSmode (match_operand:TLSmode 3 "symbol_ref_operand" "s"))
10099 (match_operand 4 "" "g")))
10100 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10101 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10103 (clobber (reg:SI LR_REGNO))]
10104 "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4"
10108 if (TARGET_SECURE_PLT && flag_pic == 2)
10109 return "addi %0,%1,%2@got@tlsgd\;bl %z3+32768@plt";
10111 return "addi %0,%1,%2@got@tlsgd\;bl %z3@plt";
10114 return "addi %0,%1,%2@got@tlsgd\;bl %z3";
10116 "&& TARGET_TLS_MARKERS"
10117 [(set (match_dup 0)
10118 (unspec:TLSmode [(match_dup 1)
10121 (parallel [(set (match_dup 0)
10122 (call (mem:TLSmode (match_dup 3))
10124 (unspec:TLSmode [(match_dup 2)] UNSPEC_TLSGD)
10125 (clobber (reg:SI LR_REGNO))])]
10127 [(set_attr "type" "two")
10128 (set_attr "length" "8")])
10130 (define_insn_and_split "*tls_gd<TLSmode:tls_abi_suffix>"
10131 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10132 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10133 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10135 "HAVE_AS_TLS && TARGET_TLS_MARKERS"
10136 "addi %0,%1,%2@got@tlsgd"
10137 "&& TARGET_CMODEL != CMODEL_SMALL"
10138 [(set (match_dup 3)
10140 (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGD)))
10142 (lo_sum:TLSmode (match_dup 3)
10143 (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGD)))]
10146 operands[3] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
10148 [(set (attr "length")
10149 (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
10153 (define_insn "*tls_gd_high<TLSmode:tls_abi_suffix>"
10154 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10156 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10157 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10159 "HAVE_AS_TLS && TARGET_TLS_MARKERS && TARGET_CMODEL != CMODEL_SMALL"
10160 "addis %0,%1,%2@got@tlsgd@ha"
10161 [(set_attr "length" "4")])
10163 (define_insn "*tls_gd_low<TLSmode:tls_abi_suffix>"
10164 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10165 (lo_sum:TLSmode (match_operand:TLSmode 1 "gpc_reg_operand" "b")
10166 (unspec:TLSmode [(match_operand:TLSmode 3 "gpc_reg_operand" "b")
10167 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10169 "HAVE_AS_TLS && TARGET_TLS_MARKERS && TARGET_CMODEL != CMODEL_SMALL"
10170 "addi %0,%1,%2@got@tlsgd@l"
10171 [(set_attr "length" "4")])
10173 (define_insn "*tls_gd_call_aix<TLSmode:tls_abi_suffix>"
10174 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10175 (call (mem:TLSmode (match_operand:TLSmode 1 "symbol_ref_operand" "s"))
10176 (match_operand 2 "" "g")))
10177 (unspec:TLSmode [(match_operand:TLSmode 3 "rs6000_tls_symbol_ref" "")]
10179 (clobber (reg:SI LR_REGNO))]
10180 "HAVE_AS_TLS && TARGET_TLS_MARKERS
10181 && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
10182 "bl %z1(%3@tlsgd)\;nop"
10183 [(set_attr "type" "branch")
10184 (set_attr "length" "8")])
10186 (define_insn "*tls_gd_call_sysv<TLSmode:tls_abi_suffix>"
10187 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10188 (call (mem:TLSmode (match_operand:TLSmode 1 "symbol_ref_operand" "s"))
10189 (match_operand 2 "" "g")))
10190 (unspec:TLSmode [(match_operand:TLSmode 3 "rs6000_tls_symbol_ref" "")]
10192 (clobber (reg:SI LR_REGNO))]
10193 "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4 && TARGET_TLS_MARKERS"
10197 if (TARGET_SECURE_PLT && flag_pic == 2)
10198 return "bl %z1+32768(%3@tlsgd)@plt";
10199 return "bl %z1(%3@tlsgd)@plt";
10201 return "bl %z1(%3@tlsgd)";
10203 [(set_attr "type" "branch")
10204 (set_attr "length" "4")])
10206 (define_insn_and_split "tls_ld_aix<TLSmode:tls_abi_suffix>"
10207 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10208 (call (mem:TLSmode (match_operand:TLSmode 2 "symbol_ref_operand" "s"))
10209 (match_operand 3 "" "g")))
10210 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
10212 (clobber (reg:SI LR_REGNO))]
10213 "HAVE_AS_TLS && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
10215 if (TARGET_CMODEL != CMODEL_SMALL)
10216 return "addis %0,%1,%&@got@tlsld@ha\;addi %0,%0,%&@got@tlsld@l\;"
10219 return "addi %0,%1,%&@got@tlsld\;bl %z2\;nop";
10221 "&& TARGET_TLS_MARKERS"
10222 [(set (match_dup 0)
10223 (unspec:TLSmode [(match_dup 1)]
10225 (parallel [(set (match_dup 0)
10226 (call (mem:TLSmode (match_dup 2))
10228 (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
10229 (clobber (reg:SI LR_REGNO))])]
10231 [(set_attr "type" "two")
10232 (set (attr "length")
10233 (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
10237 (define_insn_and_split "tls_ld_sysv<TLSmode:tls_sysv_suffix>"
10238 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10239 (call (mem:TLSmode (match_operand:TLSmode 2 "symbol_ref_operand" "s"))
10240 (match_operand 3 "" "g")))
10241 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
10243 (clobber (reg:SI LR_REGNO))]
10244 "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4"
10248 if (TARGET_SECURE_PLT && flag_pic == 2)
10249 return "addi %0,%1,%&@got@tlsld\;bl %z2+32768@plt";
10251 return "addi %0,%1,%&@got@tlsld\;bl %z2@plt";
10254 return "addi %0,%1,%&@got@tlsld\;bl %z2";
10256 "&& TARGET_TLS_MARKERS"
10257 [(set (match_dup 0)
10258 (unspec:TLSmode [(match_dup 1)]
10260 (parallel [(set (match_dup 0)
10261 (call (mem:TLSmode (match_dup 2))
10263 (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
10264 (clobber (reg:SI LR_REGNO))])]
10266 [(set_attr "length" "8")])
10268 (define_insn_and_split "*tls_ld<TLSmode:tls_abi_suffix>"
10269 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10270 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
10272 "HAVE_AS_TLS && TARGET_TLS_MARKERS"
10273 "addi %0,%1,%&@got@tlsld"
10274 "&& TARGET_CMODEL != CMODEL_SMALL"
10275 [(set (match_dup 2)
10277 (unspec:TLSmode [(const_int 0) (match_dup 1)] UNSPEC_TLSLD)))
10279 (lo_sum:TLSmode (match_dup 2)
10280 (unspec:TLSmode [(const_int 0) (match_dup 1)] UNSPEC_TLSLD)))]
10283 operands[2] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
10285 [(set (attr "length")
10286 (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
10290 (define_insn "*tls_ld_high<TLSmode:tls_abi_suffix>"
10291 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10293 (unspec:TLSmode [(const_int 0)
10294 (match_operand:TLSmode 1 "gpc_reg_operand" "b")]
10296 "HAVE_AS_TLS && TARGET_TLS_MARKERS && TARGET_CMODEL != CMODEL_SMALL"
10297 "addis %0,%1,%&@got@tlsld@ha"
10298 [(set_attr "length" "4")])
10300 (define_insn "*tls_ld_low<TLSmode:tls_abi_suffix>"
10301 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10302 (lo_sum:TLSmode (match_operand:TLSmode 1 "gpc_reg_operand" "b")
10303 (unspec:TLSmode [(const_int 0)
10304 (match_operand:TLSmode 2 "gpc_reg_operand" "b")]
10306 "HAVE_AS_TLS && TARGET_TLS_MARKERS && TARGET_CMODEL != CMODEL_SMALL"
10307 "addi %0,%1,%&@got@tlsld@l"
10308 [(set_attr "length" "4")])
10310 (define_insn "*tls_ld_call_aix<TLSmode:tls_abi_suffix>"
10311 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10312 (call (mem:TLSmode (match_operand:TLSmode 1 "symbol_ref_operand" "s"))
10313 (match_operand 2 "" "g")))
10314 (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
10315 (clobber (reg:SI LR_REGNO))]
10316 "HAVE_AS_TLS && TARGET_TLS_MARKERS
10317 && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
10318 "bl %z1(%&@tlsld)\;nop"
10319 [(set_attr "type" "branch")
10320 (set_attr "length" "8")])
10322 (define_insn "*tls_ld_call_sysv<TLSmode:tls_abi_suffix>"
10323 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10324 (call (mem:TLSmode (match_operand:TLSmode 1 "symbol_ref_operand" "s"))
10325 (match_operand 2 "" "g")))
10326 (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
10327 (clobber (reg:SI LR_REGNO))]
10328 "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4 && TARGET_TLS_MARKERS"
10332 if (TARGET_SECURE_PLT && flag_pic == 2)
10333 return "bl %z1+32768(%&@tlsld)@plt";
10334 return "bl %z1(%&@tlsld)@plt";
10336 return "bl %z1(%&@tlsld)";
10338 [(set_attr "type" "branch")
10339 (set_attr "length" "4")])
10341 (define_insn "tls_dtprel_<TLSmode:tls_abi_suffix>"
10342 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10343 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10344 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10345 UNSPEC_TLSDTPREL))]
10347 "addi %0,%1,%2@dtprel")
10349 (define_insn "tls_dtprel_ha_<TLSmode:tls_abi_suffix>"
10350 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10351 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10352 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10353 UNSPEC_TLSDTPRELHA))]
10355 "addis %0,%1,%2@dtprel@ha")
10357 (define_insn "tls_dtprel_lo_<TLSmode:tls_abi_suffix>"
10358 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10359 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10360 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10361 UNSPEC_TLSDTPRELLO))]
10363 "addi %0,%1,%2@dtprel@l")
10365 (define_insn_and_split "tls_got_dtprel_<TLSmode:tls_abi_suffix>"
10366 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10367 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10368 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10369 UNSPEC_TLSGOTDTPREL))]
10371 "l<TLSmode:tls_insn_suffix> %0,%2@got@dtprel(%1)"
10372 "&& TARGET_CMODEL != CMODEL_SMALL"
10373 [(set (match_dup 3)
10375 (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGOTDTPREL)))
10377 (lo_sum:TLSmode (match_dup 3)
10378 (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGOTDTPREL)))]
10381 operands[3] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
10383 [(set (attr "length")
10384 (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
10388 (define_insn "*tls_got_dtprel_high<TLSmode:tls_abi_suffix>"
10389 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10391 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10392 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10393 UNSPEC_TLSGOTDTPREL)))]
10394 "HAVE_AS_TLS && TARGET_CMODEL != CMODEL_SMALL"
10395 "addis %0,%1,%2@got@dtprel@ha"
10396 [(set_attr "length" "4")])
10398 (define_insn "*tls_got_dtprel_low<TLSmode:tls_abi_suffix>"
10399 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10400 (lo_sum:TLSmode (match_operand:TLSmode 1 "gpc_reg_operand" "b")
10401 (unspec:TLSmode [(match_operand:TLSmode 3 "gpc_reg_operand" "b")
10402 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10403 UNSPEC_TLSGOTDTPREL)))]
10404 "HAVE_AS_TLS && TARGET_CMODEL != CMODEL_SMALL"
10405 "l<TLSmode:tls_insn_suffix> %0,%2@got@dtprel@l(%1)"
10406 [(set_attr "length" "4")])
10408 (define_insn "tls_tprel_<TLSmode:tls_abi_suffix>"
10409 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10410 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10411 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10414 "addi %0,%1,%2@tprel")
10416 (define_insn "tls_tprel_ha_<TLSmode:tls_abi_suffix>"
10417 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10418 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10419 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10420 UNSPEC_TLSTPRELHA))]
10422 "addis %0,%1,%2@tprel@ha")
10424 (define_insn "tls_tprel_lo_<TLSmode:tls_abi_suffix>"
10425 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10426 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10427 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10428 UNSPEC_TLSTPRELLO))]
10430 "addi %0,%1,%2@tprel@l")
10432 ;; "b" output constraint here and on tls_tls input to support linker tls
10433 ;; optimization. The linker may edit the instructions emitted by a
10434 ;; tls_got_tprel/tls_tls pair to addis,addi.
10435 (define_insn_and_split "tls_got_tprel_<TLSmode:tls_abi_suffix>"
10436 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10437 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10438 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10439 UNSPEC_TLSGOTTPREL))]
10441 "l<TLSmode:tls_insn_suffix> %0,%2@got@tprel(%1)"
10442 "&& TARGET_CMODEL != CMODEL_SMALL"
10443 [(set (match_dup 3)
10445 (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGOTTPREL)))
10447 (lo_sum:TLSmode (match_dup 3)
10448 (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGOTTPREL)))]
10451 operands[3] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
10453 [(set (attr "length")
10454 (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
10458 (define_insn "*tls_got_tprel_high<TLSmode:tls_abi_suffix>"
10459 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10461 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10462 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10463 UNSPEC_TLSGOTTPREL)))]
10464 "HAVE_AS_TLS && TARGET_CMODEL != CMODEL_SMALL"
10465 "addis %0,%1,%2@got@tprel@ha"
10466 [(set_attr "length" "4")])
10468 (define_insn "*tls_got_tprel_low<TLSmode:tls_abi_suffix>"
10469 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10470 (lo_sum:TLSmode (match_operand:TLSmode 1 "gpc_reg_operand" "b")
10471 (unspec:TLSmode [(match_operand:TLSmode 3 "gpc_reg_operand" "b")
10472 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10473 UNSPEC_TLSGOTTPREL)))]
10474 "HAVE_AS_TLS && TARGET_CMODEL != CMODEL_SMALL"
10475 "l<TLSmode:tls_insn_suffix> %0,%2@got@tprel@l(%1)"
10476 [(set_attr "length" "4")])
10478 (define_insn "tls_tls_<TLSmode:tls_abi_suffix>"
10479 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10480 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10481 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10483 "TARGET_ELF && HAVE_AS_TLS"
10484 "add %0,%1,%2@tls")
10486 (define_expand "tls_get_tpointer"
10487 [(set (match_operand:SI 0 "gpc_reg_operand" "")
10488 (unspec:SI [(const_int 0)] UNSPEC_TLSTLS))]
10489 "TARGET_XCOFF && HAVE_AS_TLS"
10492 emit_insn (gen_tls_get_tpointer_internal ());
10493 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
10497 (define_insn "tls_get_tpointer_internal"
10499 (unspec:SI [(const_int 0)] UNSPEC_TLSTLS))
10500 (clobber (reg:SI LR_REGNO))]
10501 "TARGET_XCOFF && HAVE_AS_TLS"
10502 "bla __get_tpointer")
10504 (define_expand "tls_get_addr<mode>"
10505 [(set (match_operand:P 0 "gpc_reg_operand" "")
10506 (unspec:P [(match_operand:P 1 "gpc_reg_operand" "")
10507 (match_operand:P 2 "gpc_reg_operand" "")] UNSPEC_TLSTLS))]
10508 "TARGET_XCOFF && HAVE_AS_TLS"
10511 emit_move_insn (gen_rtx_REG (Pmode, 3), operands[1]);
10512 emit_move_insn (gen_rtx_REG (Pmode, 4), operands[2]);
10513 emit_insn (gen_tls_get_addr_internal<mode> ());
10514 emit_move_insn (operands[0], gen_rtx_REG (Pmode, 3));
10518 (define_insn "tls_get_addr_internal<mode>"
10520 (unspec:P [(reg:P 3) (reg:P 4)] UNSPEC_TLSTLS))
10521 (clobber (reg:P 0))
10522 (clobber (reg:P 4))
10523 (clobber (reg:P 5))
10524 (clobber (reg:P 11))
10525 (clobber (reg:CC CR0_REGNO))
10526 (clobber (reg:P LR_REGNO))]
10527 "TARGET_XCOFF && HAVE_AS_TLS"
10528 "bla __tls_get_addr")
10530 ;; Next come insns related to the calling sequence.
10532 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
10533 ;; We move the back-chain and decrement the stack pointer.
10535 (define_expand "allocate_stack"
10536 [(set (match_operand 0 "gpc_reg_operand" "")
10537 (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
10539 (minus (reg 1) (match_dup 1)))]
10542 { rtx chain = gen_reg_rtx (Pmode);
10543 rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
10545 rtx insn, par, set, mem;
10547 emit_move_insn (chain, stack_bot);
10549 /* Check stack bounds if necessary. */
10550 if (crtl->limit_stack)
10553 available = expand_binop (Pmode, sub_optab,
10554 stack_pointer_rtx, stack_limit_rtx,
10555 NULL_RTX, 1, OPTAB_WIDEN);
10556 emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
10559 if (GET_CODE (operands[1]) != CONST_INT
10560 || INTVAL (operands[1]) < -32767
10561 || INTVAL (operands[1]) > 32768)
10563 neg_op0 = gen_reg_rtx (Pmode);
10565 emit_insn (gen_negsi2 (neg_op0, operands[1]));
10567 emit_insn (gen_negdi2 (neg_op0, operands[1]));
10570 neg_op0 = GEN_INT (- INTVAL (operands[1]));
10572 insn = emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update_stack
10573 : gen_movdi_di_update_stack))
10574 (stack_pointer_rtx, stack_pointer_rtx, neg_op0,
10576 /* Since we didn't use gen_frame_mem to generate the MEM, grab
10577 it now and set the alias set/attributes. The above gen_*_update
10578 calls will generate a PARALLEL with the MEM set being the first
10580 par = PATTERN (insn);
10581 gcc_assert (GET_CODE (par) == PARALLEL);
10582 set = XVECEXP (par, 0, 0);
10583 gcc_assert (GET_CODE (set) == SET);
10584 mem = SET_DEST (set);
10585 gcc_assert (MEM_P (mem));
10586 MEM_NOTRAP_P (mem) = 1;
10587 set_mem_alias_set (mem, get_frame_alias_set ());
10589 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
10593 ;; These patterns say how to save and restore the stack pointer. We need not
10594 ;; save the stack pointer at function level since we are careful to
10595 ;; preserve the backchain. At block level, we have to restore the backchain
10596 ;; when we restore the stack pointer.
10598 ;; For nonlocal gotos, we must save both the stack pointer and its
10599 ;; backchain and restore both. Note that in the nonlocal case, the
10600 ;; save area is a memory location.
10602 (define_expand "save_stack_function"
10603 [(match_operand 0 "any_operand" "")
10604 (match_operand 1 "any_operand" "")]
10608 (define_expand "restore_stack_function"
10609 [(match_operand 0 "any_operand" "")
10610 (match_operand 1 "any_operand" "")]
10614 ;; Adjust stack pointer (op0) to a new value (op1).
10615 ;; First copy old stack backchain to new location, and ensure that the
10616 ;; scheduler won't reorder the sp assignment before the backchain write.
10617 (define_expand "restore_stack_block"
10618 [(set (match_dup 2) (match_dup 3))
10619 (set (match_dup 4) (match_dup 2))
10621 (set (match_operand 0 "register_operand" "")
10622 (match_operand 1 "register_operand" ""))]
10628 operands[1] = force_reg (Pmode, operands[1]);
10629 operands[2] = gen_reg_rtx (Pmode);
10630 operands[3] = gen_frame_mem (Pmode, operands[0]);
10631 operands[4] = gen_frame_mem (Pmode, operands[1]);
10632 p = rtvec_alloc (1);
10633 RTVEC_ELT (p, 0) = gen_rtx_SET (VOIDmode,
10634 gen_frame_mem (BLKmode, operands[0]),
10636 operands[5] = gen_rtx_PARALLEL (VOIDmode, p);
10639 (define_expand "save_stack_nonlocal"
10640 [(set (match_dup 3) (match_dup 4))
10641 (set (match_operand 0 "memory_operand" "") (match_dup 3))
10642 (set (match_dup 2) (match_operand 1 "register_operand" ""))]
10646 int units_per_word = (TARGET_32BIT) ? 4 : 8;
10648 /* Copy the backchain to the first word, sp to the second. */
10649 operands[0] = adjust_address_nv (operands[0], Pmode, 0);
10650 operands[2] = adjust_address_nv (operands[0], Pmode, units_per_word);
10651 operands[3] = gen_reg_rtx (Pmode);
10652 operands[4] = gen_frame_mem (Pmode, operands[1]);
10655 (define_expand "restore_stack_nonlocal"
10656 [(set (match_dup 2) (match_operand 1 "memory_operand" ""))
10657 (set (match_dup 3) (match_dup 4))
10658 (set (match_dup 5) (match_dup 2))
10660 (set (match_operand 0 "register_operand" "") (match_dup 3))]
10664 int units_per_word = (TARGET_32BIT) ? 4 : 8;
10667 /* Restore the backchain from the first word, sp from the second. */
10668 operands[2] = gen_reg_rtx (Pmode);
10669 operands[3] = gen_reg_rtx (Pmode);
10670 operands[1] = adjust_address_nv (operands[1], Pmode, 0);
10671 operands[4] = adjust_address_nv (operands[1], Pmode, units_per_word);
10672 operands[5] = gen_frame_mem (Pmode, operands[3]);
10673 p = rtvec_alloc (1);
10674 RTVEC_ELT (p, 0) = gen_rtx_SET (VOIDmode,
10675 gen_frame_mem (BLKmode, operands[0]),
10677 operands[6] = gen_rtx_PARALLEL (VOIDmode, p);
10680 ;; TOC register handling.
10682 ;; Code to initialize the TOC register...
10684 (define_insn "load_toc_aix_si"
10685 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10686 (unspec:SI [(const_int 0)] UNSPEC_TOC))
10687 (use (reg:SI 2))])]
10688 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) && TARGET_32BIT"
10692 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
10693 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
10694 operands[2] = gen_rtx_REG (Pmode, 2);
10695 return \"lwz %0,%1(%2)\";
10697 [(set_attr "type" "load")
10698 (set_attr "update" "no")
10699 (set_attr "indexed" "no")])
10701 (define_insn "load_toc_aix_di"
10702 [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10703 (unspec:DI [(const_int 0)] UNSPEC_TOC))
10704 (use (reg:DI 2))])]
10705 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) && TARGET_64BIT"
10709 #ifdef TARGET_RELOCATABLE
10710 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
10711 !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
10713 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
10716 strcat (buf, \"@toc\");
10717 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
10718 operands[2] = gen_rtx_REG (Pmode, 2);
10719 return \"ld %0,%1(%2)\";
10721 [(set_attr "type" "load")
10722 (set_attr "update" "no")
10723 (set_attr "indexed" "no")])
10725 (define_insn "load_toc_v4_pic_si"
10726 [(set (reg:SI LR_REGNO)
10727 (unspec:SI [(const_int 0)] UNSPEC_TOC))]
10728 "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
10729 "bl _GLOBAL_OFFSET_TABLE_@local-4"
10730 [(set_attr "type" "branch")
10731 (set_attr "length" "4")])
10733 (define_expand "load_toc_v4_PIC_1"
10734 [(parallel [(set (reg:SI LR_REGNO)
10735 (match_operand:SI 0 "immediate_operand" "s"))
10736 (use (unspec [(match_dup 0)] UNSPEC_TOC))])]
10737 "TARGET_ELF && DEFAULT_ABI == ABI_V4
10738 && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
10741 (define_insn "load_toc_v4_PIC_1_normal"
10742 [(set (reg:SI LR_REGNO)
10743 (match_operand:SI 0 "immediate_operand" "s"))
10744 (use (unspec [(match_dup 0)] UNSPEC_TOC))]
10745 "!TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4
10746 && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
10747 "bcl 20,31,%0\\n%0:"
10748 [(set_attr "type" "branch")
10749 (set_attr "length" "4")])
10751 (define_insn "load_toc_v4_PIC_1_476"
10752 [(set (reg:SI LR_REGNO)
10753 (match_operand:SI 0 "immediate_operand" "s"))
10754 (use (unspec [(match_dup 0)] UNSPEC_TOC))]
10755 "TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4
10756 && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
10760 static char templ[32];
10762 get_ppc476_thunk_name (name);
10763 sprintf (templ, \"bl %s\\n%%0:\", name);
10766 [(set_attr "type" "branch")
10767 (set_attr "length" "4")])
10769 (define_expand "load_toc_v4_PIC_1b"
10770 [(parallel [(set (reg:SI LR_REGNO)
10771 (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
10772 (label_ref (match_operand 1 "" ""))]
10775 "TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
10778 (define_insn "load_toc_v4_PIC_1b_normal"
10779 [(set (reg:SI LR_REGNO)
10780 (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
10781 (label_ref (match_operand 1 "" ""))]
10784 "!TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
10785 "bcl 20,31,$+8\;.long %0-$"
10786 [(set_attr "type" "branch")
10787 (set_attr "length" "8")])
10789 (define_insn "load_toc_v4_PIC_1b_476"
10790 [(set (reg:SI LR_REGNO)
10791 (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
10792 (label_ref (match_operand 1 "" ""))]
10795 "TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
10799 static char templ[32];
10801 get_ppc476_thunk_name (name);
10802 sprintf (templ, \"bl %s\\n\\tb $+8\\n\\t.long %%0-$\", name);
10805 [(set_attr "type" "branch")
10806 (set_attr "length" "16")])
10808 (define_insn "load_toc_v4_PIC_2"
10809 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10810 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10811 (minus:SI (match_operand:SI 2 "immediate_operand" "s")
10812 (match_operand:SI 3 "immediate_operand" "s")))))]
10813 "TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
10815 [(set_attr "type" "load")])
10817 (define_insn "load_toc_v4_PIC_3b"
10818 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10819 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10821 (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
10822 (match_operand:SI 3 "symbol_ref_operand" "s")))))]
10823 "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI == ABI_V4 && flag_pic"
10824 "addis %0,%1,%2-%3@ha")
10826 (define_insn "load_toc_v4_PIC_3c"
10827 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10828 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10829 (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
10830 (match_operand:SI 3 "symbol_ref_operand" "s"))))]
10831 "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI == ABI_V4 && flag_pic"
10832 "addi %0,%1,%2-%3@l")
10834 ;; If the TOC is shared over a translation unit, as happens with all
10835 ;; the kinds of PIC that we support, we need to restore the TOC
10836 ;; pointer only when jumping over units of translation.
10837 ;; On Darwin, we need to reload the picbase.
10839 (define_expand "builtin_setjmp_receiver"
10840 [(use (label_ref (match_operand 0 "" "")))]
10841 "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
10842 || (TARGET_TOC && TARGET_MINIMAL_TOC)
10843 || (DEFAULT_ABI == ABI_DARWIN && flag_pic)"
10847 if (DEFAULT_ABI == ABI_DARWIN)
10849 rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, MACHOPIC_FUNCTION_BASE_NAME);
10850 rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
10854 crtl->uses_pic_offset_table = 1;
10855 ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\",
10856 CODE_LABEL_NUMBER (operands[0]));
10857 tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
10859 emit_insn (gen_load_macho_picbase (tmplabrtx));
10860 emit_move_insn (picreg, gen_rtx_REG (Pmode, LR_REGNO));
10861 emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
10865 rs6000_emit_load_toc_table (FALSE);
10869 ;; Largetoc support
10870 (define_insn "*largetoc_high"
10871 [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
10873 (unspec [(match_operand:DI 1 "" "")
10874 (match_operand:DI 2 "gpc_reg_operand" "b")]
10876 "TARGET_ELF && TARGET_CMODEL != CMODEL_SMALL"
10877 "addis %0,%2,%1@toc@ha")
10879 (define_insn "*largetoc_high_aix<mode>"
10880 [(set (match_operand:P 0 "gpc_reg_operand" "=b*r")
10882 (unspec [(match_operand:P 1 "" "")
10883 (match_operand:P 2 "gpc_reg_operand" "b")]
10885 "TARGET_XCOFF && TARGET_CMODEL != CMODEL_SMALL"
10886 "addis %0,%1@u(%2)")
10888 (define_insn "*largetoc_high_plus"
10889 [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
10892 (unspec [(match_operand:DI 1 "" "")
10893 (match_operand:DI 2 "gpc_reg_operand" "b")]
10895 (match_operand:DI 3 "add_cint_operand" "n"))))]
10896 "TARGET_ELF && TARGET_CMODEL != CMODEL_SMALL"
10897 "addis %0,%2,%1+%3@toc@ha")
10899 (define_insn "*largetoc_high_plus_aix<mode>"
10900 [(set (match_operand:P 0 "gpc_reg_operand" "=b*r")
10903 (unspec [(match_operand:P 1 "" "")
10904 (match_operand:P 2 "gpc_reg_operand" "b")]
10906 (match_operand:P 3 "add_cint_operand" "n"))))]
10907 "TARGET_XCOFF && TARGET_CMODEL != CMODEL_SMALL"
10908 "addis %0,%1+%3@u(%2)")
10910 (define_insn "*largetoc_low"
10911 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10912 (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b")
10913 (match_operand:DI 2 "" "")))]
10914 "TARGET_ELF && TARGET_CMODEL != CMODEL_SMALL"
10917 (define_insn "*largetoc_low_aix<mode>"
10918 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
10919 (lo_sum:P (match_operand:P 1 "gpc_reg_operand" "b")
10920 (match_operand:P 2 "" "")))]
10921 "TARGET_XCOFF && TARGET_CMODEL != CMODEL_SMALL"
10924 (define_insn_and_split "*tocref<mode>"
10925 [(set (match_operand:P 0 "gpc_reg_operand" "=b")
10926 (match_operand:P 1 "small_toc_ref" "R"))]
10929 "&& TARGET_CMODEL != CMODEL_SMALL && reload_completed"
10930 [(set (match_dup 0) (high:P (match_dup 1)))
10931 (set (match_dup 0) (lo_sum:P (match_dup 0) (match_dup 1)))])
10933 ;; Elf specific ways of loading addresses for non-PIC code.
10934 ;; The output of this could be r0, but we make a very strong
10935 ;; preference for a base register because it will usually
10936 ;; be needed there.
10937 (define_insn "elf_high"
10938 [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
10939 (high:SI (match_operand 1 "" "")))]
10940 "TARGET_ELF && ! TARGET_64BIT"
10943 (define_insn "elf_low"
10944 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10945 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10946 (match_operand 2 "" "")))]
10947 "TARGET_ELF && ! TARGET_64BIT"
10950 ;; Call and call_value insns
10951 (define_expand "call"
10952 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10953 (match_operand 1 "" ""))
10954 (use (match_operand 2 "" ""))
10955 (clobber (reg:SI LR_REGNO))])]
10960 if (MACHOPIC_INDIRECT)
10961 operands[0] = machopic_indirect_call_target (operands[0]);
10964 gcc_assert (GET_CODE (operands[0]) == MEM);
10965 gcc_assert (GET_CODE (operands[1]) == CONST_INT);
10967 operands[0] = XEXP (operands[0], 0);
10969 if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
10971 rs6000_call_aix (NULL_RTX, operands[0], operands[1], operands[2]);
10975 if (GET_CODE (operands[0]) != SYMBOL_REF
10976 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[2]) & CALL_LONG) != 0))
10978 if (INTVAL (operands[2]) & CALL_LONG)
10979 operands[0] = rs6000_longcall_ref (operands[0]);
10981 switch (DEFAULT_ABI)
10985 operands[0] = force_reg (Pmode, operands[0]);
10989 gcc_unreachable ();
10994 (define_expand "call_value"
10995 [(parallel [(set (match_operand 0 "" "")
10996 (call (mem:SI (match_operand 1 "address_operand" ""))
10997 (match_operand 2 "" "")))
10998 (use (match_operand 3 "" ""))
10999 (clobber (reg:SI LR_REGNO))])]
11004 if (MACHOPIC_INDIRECT)
11005 operands[1] = machopic_indirect_call_target (operands[1]);
11008 gcc_assert (GET_CODE (operands[1]) == MEM);
11009 gcc_assert (GET_CODE (operands[2]) == CONST_INT);
11011 operands[1] = XEXP (operands[1], 0);
11013 if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
11015 rs6000_call_aix (operands[0], operands[1], operands[2], operands[3]);
11019 if (GET_CODE (operands[1]) != SYMBOL_REF
11020 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[3]) & CALL_LONG) != 0))
11022 if (INTVAL (operands[3]) & CALL_LONG)
11023 operands[1] = rs6000_longcall_ref (operands[1]);
11025 switch (DEFAULT_ABI)
11029 operands[1] = force_reg (Pmode, operands[1]);
11033 gcc_unreachable ();
11038 ;; Call to function in current module. No TOC pointer reload needed.
11039 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
11040 ;; either the function was not prototyped, or it was prototyped as a
11041 ;; variable argument function. It is > 0 if FP registers were passed
11042 ;; and < 0 if they were not.
11044 (define_insn "*call_local32"
11045 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
11046 (match_operand 1 "" "g,g"))
11047 (use (match_operand:SI 2 "immediate_operand" "O,n"))
11048 (clobber (reg:SI LR_REGNO))]
11049 "(INTVAL (operands[2]) & CALL_LONG) == 0"
11052 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11053 output_asm_insn (\"crxor 6,6,6\", operands);
11055 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11056 output_asm_insn (\"creqv 6,6,6\", operands);
11058 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
11060 [(set_attr "type" "branch")
11061 (set_attr "length" "4,8")])
11063 (define_insn "*call_local64"
11064 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
11065 (match_operand 1 "" "g,g"))
11066 (use (match_operand:SI 2 "immediate_operand" "O,n"))
11067 (clobber (reg:SI LR_REGNO))]
11068 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
11071 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11072 output_asm_insn (\"crxor 6,6,6\", operands);
11074 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11075 output_asm_insn (\"creqv 6,6,6\", operands);
11077 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
11079 [(set_attr "type" "branch")
11080 (set_attr "length" "4,8")])
11082 (define_insn "*call_value_local32"
11083 [(set (match_operand 0 "" "")
11084 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
11085 (match_operand 2 "" "g,g")))
11086 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11087 (clobber (reg:SI LR_REGNO))]
11088 "(INTVAL (operands[3]) & CALL_LONG) == 0"
11091 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11092 output_asm_insn (\"crxor 6,6,6\", operands);
11094 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11095 output_asm_insn (\"creqv 6,6,6\", operands);
11097 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
11099 [(set_attr "type" "branch")
11100 (set_attr "length" "4,8")])
11103 (define_insn "*call_value_local64"
11104 [(set (match_operand 0 "" "")
11105 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
11106 (match_operand 2 "" "g,g")))
11107 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11108 (clobber (reg:SI LR_REGNO))]
11109 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
11112 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11113 output_asm_insn (\"crxor 6,6,6\", operands);
11115 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11116 output_asm_insn (\"creqv 6,6,6\", operands);
11118 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
11120 [(set_attr "type" "branch")
11121 (set_attr "length" "4,8")])
11124 ;; A function pointer under System V is just a normal pointer
11125 ;; operands[0] is the function pointer
11126 ;; operands[1] is the stack size to clean up
11127 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
11128 ;; which indicates how to set cr1
11130 (define_insn "*call_indirect_nonlocal_sysv<mode>"
11131 [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l,c,*l"))
11132 (match_operand 1 "" "g,g,g,g"))
11133 (use (match_operand:SI 2 "immediate_operand" "O,O,n,n"))
11134 (clobber (reg:SI LR_REGNO))]
11135 "DEFAULT_ABI == ABI_V4
11136 || DEFAULT_ABI == ABI_DARWIN"
11138 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11139 output_asm_insn ("crxor 6,6,6", operands);
11141 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11142 output_asm_insn ("creqv 6,6,6", operands);
11146 [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
11147 (set_attr "length" "4,4,8,8")])
11149 (define_insn_and_split "*call_nonlocal_sysv<mode>"
11150 [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s"))
11151 (match_operand 1 "" "g,g"))
11152 (use (match_operand:SI 2 "immediate_operand" "O,n"))
11153 (clobber (reg:SI LR_REGNO))]
11154 "(DEFAULT_ABI == ABI_DARWIN
11155 || (DEFAULT_ABI == ABI_V4
11156 && (INTVAL (operands[2]) & CALL_LONG) == 0))"
11158 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11159 output_asm_insn ("crxor 6,6,6", operands);
11161 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11162 output_asm_insn ("creqv 6,6,6", operands);
11165 return output_call(insn, operands, 0, 2);
11167 if (DEFAULT_ABI == ABI_V4 && flag_pic)
11169 gcc_assert (!TARGET_SECURE_PLT);
11170 return "bl %z0@plt";
11176 "DEFAULT_ABI == ABI_V4
11177 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0])
11178 && (INTVAL (operands[2]) & CALL_LONG) == 0"
11179 [(parallel [(call (mem:SI (match_dup 0))
11181 (use (match_dup 2))
11182 (use (match_dup 3))
11183 (clobber (reg:SI LR_REGNO))])]
11185 operands[3] = pic_offset_table_rtx;
11187 [(set_attr "type" "branch,branch")
11188 (set_attr "length" "4,8")])
11190 (define_insn "*call_nonlocal_sysv_secure<mode>"
11191 [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s"))
11192 (match_operand 1 "" "g,g"))
11193 (use (match_operand:SI 2 "immediate_operand" "O,n"))
11194 (use (match_operand:SI 3 "register_operand" "r,r"))
11195 (clobber (reg:SI LR_REGNO))]
11196 "(DEFAULT_ABI == ABI_V4
11197 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0])
11198 && (INTVAL (operands[2]) & CALL_LONG) == 0)"
11200 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11201 output_asm_insn ("crxor 6,6,6", operands);
11203 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11204 output_asm_insn ("creqv 6,6,6", operands);
11207 /* The magic 32768 offset here and in the other sysv call insns
11208 corresponds to the offset of r30 in .got2, as given by LCTOC1.
11209 See sysv4.h:toc_section. */
11210 return "bl %z0+32768@plt";
11212 return "bl %z0@plt";
11214 [(set_attr "type" "branch,branch")
11215 (set_attr "length" "4,8")])
11217 (define_insn "*call_value_indirect_nonlocal_sysv<mode>"
11218 [(set (match_operand 0 "" "")
11219 (call (mem:SI (match_operand:P 1 "register_operand" "c,*l,c,*l"))
11220 (match_operand 2 "" "g,g,g,g")))
11221 (use (match_operand:SI 3 "immediate_operand" "O,O,n,n"))
11222 (clobber (reg:SI LR_REGNO))]
11223 "DEFAULT_ABI == ABI_V4
11224 || DEFAULT_ABI == ABI_DARWIN"
11226 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11227 output_asm_insn ("crxor 6,6,6", operands);
11229 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11230 output_asm_insn ("creqv 6,6,6", operands);
11234 [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
11235 (set_attr "length" "4,4,8,8")])
11237 (define_insn_and_split "*call_value_nonlocal_sysv<mode>"
11238 [(set (match_operand 0 "" "")
11239 (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s"))
11240 (match_operand 2 "" "g,g")))
11241 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11242 (clobber (reg:SI LR_REGNO))]
11243 "(DEFAULT_ABI == ABI_DARWIN
11244 || (DEFAULT_ABI == ABI_V4
11245 && (INTVAL (operands[3]) & CALL_LONG) == 0))"
11247 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11248 output_asm_insn ("crxor 6,6,6", operands);
11250 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11251 output_asm_insn ("creqv 6,6,6", operands);
11254 return output_call(insn, operands, 1, 3);
11256 if (DEFAULT_ABI == ABI_V4 && flag_pic)
11258 gcc_assert (!TARGET_SECURE_PLT);
11259 return "bl %z1@plt";
11265 "DEFAULT_ABI == ABI_V4
11266 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1])
11267 && (INTVAL (operands[3]) & CALL_LONG) == 0"
11268 [(parallel [(set (match_dup 0)
11269 (call (mem:SI (match_dup 1))
11271 (use (match_dup 3))
11272 (use (match_dup 4))
11273 (clobber (reg:SI LR_REGNO))])]
11275 operands[4] = pic_offset_table_rtx;
11277 [(set_attr "type" "branch,branch")
11278 (set_attr "length" "4,8")])
11280 (define_insn "*call_value_nonlocal_sysv_secure<mode>"
11281 [(set (match_operand 0 "" "")
11282 (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s"))
11283 (match_operand 2 "" "g,g")))
11284 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11285 (use (match_operand:SI 4 "register_operand" "r,r"))
11286 (clobber (reg:SI LR_REGNO))]
11287 "(DEFAULT_ABI == ABI_V4
11288 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1])
11289 && (INTVAL (operands[3]) & CALL_LONG) == 0)"
11291 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11292 output_asm_insn ("crxor 6,6,6", operands);
11294 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11295 output_asm_insn ("creqv 6,6,6", operands);
11298 return "bl %z1+32768@plt";
11300 return "bl %z1@plt";
11302 [(set_attr "type" "branch,branch")
11303 (set_attr "length" "4,8")])
11306 ;; Call to AIX abi function in the same module.
11308 (define_insn "*call_local_aix<mode>"
11309 [(call (mem:SI (match_operand:P 0 "current_file_function_operand" "s"))
11310 (match_operand 1 "" "g"))
11311 (clobber (reg:P LR_REGNO))]
11312 "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11314 [(set_attr "type" "branch")
11315 (set_attr "length" "4")])
11317 (define_insn "*call_value_local_aix<mode>"
11318 [(set (match_operand 0 "" "")
11319 (call (mem:SI (match_operand:P 1 "current_file_function_operand" "s"))
11320 (match_operand 2 "" "g")))
11321 (clobber (reg:P LR_REGNO))]
11322 "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11324 [(set_attr "type" "branch")
11325 (set_attr "length" "4")])
11327 ;; Call to AIX abi function which may be in another module.
11328 ;; Restore the TOC pointer (r2) after the call.
11330 (define_insn "*call_nonlocal_aix<mode>"
11331 [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s"))
11332 (match_operand 1 "" "g"))
11333 (clobber (reg:P LR_REGNO))]
11334 "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11336 [(set_attr "type" "branch")
11337 (set_attr "length" "8")])
11339 (define_insn "*call_value_nonlocal_aix<mode>"
11340 [(set (match_operand 0 "" "")
11341 (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s"))
11342 (match_operand 2 "" "g")))
11343 (clobber (reg:P LR_REGNO))]
11344 "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11346 [(set_attr "type" "branch")
11347 (set_attr "length" "8")])
11349 ;; Call to indirect functions with the AIX abi using a 3 word descriptor.
11350 ;; Operand0 is the addresss of the function to call
11351 ;; Operand2 is the location in the function descriptor to load r2 from
11352 ;; Operand3 is the offset of the stack location holding the current TOC pointer
11354 (define_insn "*call_indirect_aix<mode>"
11355 [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l"))
11356 (match_operand 1 "" "g,g"))
11357 (use (match_operand:P 2 "memory_operand" "<ptrm>,<ptrm>"))
11358 (set (reg:P TOC_REGNUM) (unspec [(match_operand:P 3 "const_int_operand" "n,n")] UNSPEC_TOCSLOT))
11359 (clobber (reg:P LR_REGNO))]
11360 "DEFAULT_ABI == ABI_AIX"
11361 "<ptrload> 2,%2\;b%T0l\;<ptrload> 2,%3(1)"
11362 [(set_attr "type" "jmpreg")
11363 (set_attr "length" "12")])
11365 (define_insn "*call_value_indirect_aix<mode>"
11366 [(set (match_operand 0 "" "")
11367 (call (mem:SI (match_operand:P 1 "register_operand" "c,*l"))
11368 (match_operand 2 "" "g,g")))
11369 (use (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
11370 (set (reg:P TOC_REGNUM) (unspec [(match_operand:P 4 "const_int_operand" "n,n")] UNSPEC_TOCSLOT))
11371 (clobber (reg:P LR_REGNO))]
11372 "DEFAULT_ABI == ABI_AIX"
11373 "<ptrload> 2,%3\;b%T1l\;<ptrload> 2,%4(1)"
11374 [(set_attr "type" "jmpreg")
11375 (set_attr "length" "12")])
11377 ;; Call to indirect functions with the ELFv2 ABI.
11378 ;; Operand0 is the addresss of the function to call
11379 ;; Operand2 is the offset of the stack location holding the current TOC pointer
11381 (define_insn "*call_indirect_elfv2<mode>"
11382 [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l"))
11383 (match_operand 1 "" "g,g"))
11384 (set (reg:P TOC_REGNUM) (unspec [(match_operand:P 2 "const_int_operand" "n,n")] UNSPEC_TOCSLOT))
11385 (clobber (reg:P LR_REGNO))]
11386 "DEFAULT_ABI == ABI_ELFv2"
11387 "b%T0l\;<ptrload> 2,%2(1)"
11388 [(set_attr "type" "jmpreg")
11389 (set_attr "length" "8")])
11391 (define_insn "*call_value_indirect_elfv2<mode>"
11392 [(set (match_operand 0 "" "")
11393 (call (mem:SI (match_operand:P 1 "register_operand" "c,*l"))
11394 (match_operand 2 "" "g,g")))
11395 (set (reg:P TOC_REGNUM) (unspec [(match_operand:P 3 "const_int_operand" "n,n")] UNSPEC_TOCSLOT))
11396 (clobber (reg:P LR_REGNO))]
11397 "DEFAULT_ABI == ABI_ELFv2"
11398 "b%T1l\;<ptrload> 2,%3(1)"
11399 [(set_attr "type" "jmpreg")
11400 (set_attr "length" "8")])
11403 ;; Call subroutine returning any type.
11404 (define_expand "untyped_call"
11405 [(parallel [(call (match_operand 0 "" "")
11407 (match_operand 1 "" "")
11408 (match_operand 2 "" "")])]
11414 emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
11416 for (i = 0; i < XVECLEN (operands[2], 0); i++)
11418 rtx set = XVECEXP (operands[2], 0, i);
11419 emit_move_insn (SET_DEST (set), SET_SRC (set));
11422 /* The optimizer does not know that the call sets the function value
11423 registers we stored in the result block. We avoid problems by
11424 claiming that all hard registers are used and clobbered at this
11426 emit_insn (gen_blockage ());
11431 ;; sibling call patterns
11432 (define_expand "sibcall"
11433 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
11434 (match_operand 1 "" ""))
11435 (use (match_operand 2 "" ""))
11436 (use (reg:SI LR_REGNO))
11442 if (MACHOPIC_INDIRECT)
11443 operands[0] = machopic_indirect_call_target (operands[0]);
11446 gcc_assert (GET_CODE (operands[0]) == MEM);
11447 gcc_assert (GET_CODE (operands[1]) == CONST_INT);
11449 operands[0] = XEXP (operands[0], 0);
11451 if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
11453 rs6000_sibcall_aix (NULL_RTX, operands[0], operands[1], operands[2]);
11458 (define_expand "sibcall_value"
11459 [(parallel [(set (match_operand 0 "register_operand" "")
11460 (call (mem:SI (match_operand 1 "address_operand" ""))
11461 (match_operand 2 "" "")))
11462 (use (match_operand 3 "" ""))
11463 (use (reg:SI LR_REGNO))
11469 if (MACHOPIC_INDIRECT)
11470 operands[1] = machopic_indirect_call_target (operands[1]);
11473 gcc_assert (GET_CODE (operands[1]) == MEM);
11474 gcc_assert (GET_CODE (operands[2]) == CONST_INT);
11476 operands[1] = XEXP (operands[1], 0);
11478 if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
11480 rs6000_sibcall_aix (operands[0], operands[1], operands[2], operands[3]);
11485 ;; this and similar patterns must be marked as using LR, otherwise
11486 ;; dataflow will try to delete the store into it. This is true
11487 ;; even when the actual reg to jump to is in CTR, when LR was
11488 ;; saved and restored around the PIC-setting BCL.
11489 (define_insn "*sibcall_local32"
11490 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
11491 (match_operand 1 "" "g,g"))
11492 (use (match_operand:SI 2 "immediate_operand" "O,n"))
11493 (use (reg:SI LR_REGNO))
11495 "(INTVAL (operands[2]) & CALL_LONG) == 0"
11498 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11499 output_asm_insn (\"crxor 6,6,6\", operands);
11501 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11502 output_asm_insn (\"creqv 6,6,6\", operands);
11504 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
11506 [(set_attr "type" "branch")
11507 (set_attr "length" "4,8")])
11509 (define_insn "*sibcall_local64"
11510 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
11511 (match_operand 1 "" "g,g"))
11512 (use (match_operand:SI 2 "immediate_operand" "O,n"))
11513 (use (reg:SI LR_REGNO))
11515 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
11518 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11519 output_asm_insn (\"crxor 6,6,6\", operands);
11521 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11522 output_asm_insn (\"creqv 6,6,6\", operands);
11524 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
11526 [(set_attr "type" "branch")
11527 (set_attr "length" "4,8")])
11529 (define_insn "*sibcall_value_local32"
11530 [(set (match_operand 0 "" "")
11531 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
11532 (match_operand 2 "" "g,g")))
11533 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11534 (use (reg:SI LR_REGNO))
11536 "(INTVAL (operands[3]) & CALL_LONG) == 0"
11539 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11540 output_asm_insn (\"crxor 6,6,6\", operands);
11542 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11543 output_asm_insn (\"creqv 6,6,6\", operands);
11545 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
11547 [(set_attr "type" "branch")
11548 (set_attr "length" "4,8")])
11550 (define_insn "*sibcall_value_local64"
11551 [(set (match_operand 0 "" "")
11552 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
11553 (match_operand 2 "" "g,g")))
11554 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11555 (use (reg:SI LR_REGNO))
11557 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
11560 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11561 output_asm_insn (\"crxor 6,6,6\", operands);
11563 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11564 output_asm_insn (\"creqv 6,6,6\", operands);
11566 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
11568 [(set_attr "type" "branch")
11569 (set_attr "length" "4,8")])
11571 (define_insn "*sibcall_nonlocal_sysv<mode>"
11572 [(call (mem:SI (match_operand:P 0 "call_operand" "s,s,c,c"))
11573 (match_operand 1 "" ""))
11574 (use (match_operand 2 "immediate_operand" "O,n,O,n"))
11575 (use (reg:SI LR_REGNO))
11577 "(DEFAULT_ABI == ABI_DARWIN
11578 || DEFAULT_ABI == ABI_V4)
11579 && (INTVAL (operands[2]) & CALL_LONG) == 0"
11582 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11583 output_asm_insn (\"crxor 6,6,6\", operands);
11585 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11586 output_asm_insn (\"creqv 6,6,6\", operands);
11588 if (which_alternative >= 2)
11590 else if (DEFAULT_ABI == ABI_V4 && flag_pic)
11592 gcc_assert (!TARGET_SECURE_PLT);
11593 return \"b %z0@plt\";
11598 [(set_attr "type" "branch")
11599 (set_attr "length" "4,8,4,8")])
11601 (define_insn "*sibcall_value_nonlocal_sysv<mode>"
11602 [(set (match_operand 0 "" "")
11603 (call (mem:SI (match_operand:P 1 "call_operand" "s,s,c,c"))
11604 (match_operand 2 "" "")))
11605 (use (match_operand:SI 3 "immediate_operand" "O,n,O,n"))
11606 (use (reg:SI LR_REGNO))
11608 "(DEFAULT_ABI == ABI_DARWIN
11609 || DEFAULT_ABI == ABI_V4)
11610 && (INTVAL (operands[3]) & CALL_LONG) == 0"
11613 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11614 output_asm_insn (\"crxor 6,6,6\", operands);
11616 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11617 output_asm_insn (\"creqv 6,6,6\", operands);
11619 if (which_alternative >= 2)
11621 else if (DEFAULT_ABI == ABI_V4 && flag_pic)
11623 gcc_assert (!TARGET_SECURE_PLT);
11624 return \"b %z1@plt\";
11629 [(set_attr "type" "branch")
11630 (set_attr "length" "4,8,4,8")])
11632 ;; AIX ABI sibling call patterns.
11634 (define_insn "*sibcall_aix<mode>"
11635 [(call (mem:SI (match_operand:P 0 "call_operand" "s,c"))
11636 (match_operand 1 "" "g,g"))
11638 "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11642 [(set_attr "type" "branch")
11643 (set_attr "length" "4")])
11645 (define_insn "*sibcall_value_aix<mode>"
11646 [(set (match_operand 0 "" "")
11647 (call (mem:SI (match_operand:P 1 "call_operand" "s,c"))
11648 (match_operand 2 "" "g,g")))
11650 "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11654 [(set_attr "type" "branch")
11655 (set_attr "length" "4")])
11657 (define_expand "sibcall_epilogue"
11658 [(use (const_int 0))]
11661 if (!TARGET_SCHED_PROLOG)
11662 emit_insn (gen_blockage ());
11663 rs6000_emit_epilogue (TRUE);
11667 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
11668 ;; all of memory. This blocks insns from being moved across this point.
11670 (define_insn "blockage"
11671 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCK)]
11675 (define_expand "probe_stack_address"
11676 [(use (match_operand 0 "address_operand"))]
11679 operands[0] = gen_rtx_MEM (Pmode, operands[0]);
11680 MEM_VOLATILE_P (operands[0]) = 1;
11683 emit_insn (gen_probe_stack_di (operands[0]));
11685 emit_insn (gen_probe_stack_si (operands[0]));
11689 (define_insn "probe_stack_<mode>"
11690 [(set (match_operand:P 0 "memory_operand" "=m")
11691 (unspec:P [(const_int 0)] UNSPEC_PROBE_STACK))]
11694 operands[1] = gen_rtx_REG (Pmode, 0);
11695 return "st<wd>%U0%X0 %1,%0";
11697 [(set_attr "type" "store")
11698 (set (attr "update")
11699 (if_then_else (match_operand 0 "update_address_mem")
11700 (const_string "yes")
11701 (const_string "no")))
11702 (set (attr "indexed")
11703 (if_then_else (match_operand 0 "indexed_address_mem")
11704 (const_string "yes")
11705 (const_string "no")))
11706 (set_attr "length" "4")])
11708 (define_insn "probe_stack_range<P:mode>"
11709 [(set (match_operand:P 0 "register_operand" "=r")
11710 (unspec_volatile:P [(match_operand:P 1 "register_operand" "0")
11711 (match_operand:P 2 "register_operand" "r")]
11712 UNSPECV_PROBE_STACK_RANGE))]
11714 "* return output_probe_stack_range (operands[0], operands[2]);"
11715 [(set_attr "type" "three")])
11717 ;; Compare insns are next. Note that the RS/6000 has two types of compares,
11718 ;; signed & unsigned, and one type of branch.
11720 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
11721 ;; insns, and branches.
11723 (define_expand "cbranch<mode>4"
11724 [(use (match_operator 0 "rs6000_cbranch_operator"
11725 [(match_operand:GPR 1 "gpc_reg_operand" "")
11726 (match_operand:GPR 2 "reg_or_short_operand" "")]))
11727 (use (match_operand 3 ""))]
11731 /* Take care of the possibility that operands[2] might be negative but
11732 this might be a logical operation. That insn doesn't exist. */
11733 if (GET_CODE (operands[2]) == CONST_INT
11734 && INTVAL (operands[2]) < 0)
11736 operands[2] = force_reg (<MODE>mode, operands[2]);
11737 operands[0] = gen_rtx_fmt_ee (GET_CODE (operands[0]),
11738 GET_MODE (operands[0]),
11739 operands[1], operands[2]);
11742 rs6000_emit_cbranch (<MODE>mode, operands);
11746 (define_expand "cbranch<mode>4"
11747 [(use (match_operator 0 "rs6000_cbranch_operator"
11748 [(match_operand:FP 1 "gpc_reg_operand" "")
11749 (match_operand:FP 2 "gpc_reg_operand" "")]))
11750 (use (match_operand 3 ""))]
11754 rs6000_emit_cbranch (<MODE>mode, operands);
11758 (define_expand "cstore<mode>4_unsigned"
11759 [(use (match_operator 1 "unsigned_comparison_operator"
11760 [(match_operand:P 2 "gpc_reg_operand" "")
11761 (match_operand:P 3 "reg_or_short_operand" "")]))
11762 (clobber (match_operand:P 0 "register_operand"))]
11765 enum rtx_code cond_code = GET_CODE (operands[1]);
11767 rtx op0 = operands[0];
11768 rtx op1 = operands[2];
11769 rtx op2 = operands[3];
11771 if (cond_code == GEU || cond_code == LTU)
11773 cond_code = swap_condition (cond_code);
11778 if (!gpc_reg_operand (op1, <MODE>mode))
11779 op1 = force_reg (<MODE>mode, op1);
11780 if (!reg_or_short_operand (op2, <MODE>mode))
11781 op2 = force_reg (<MODE>mode, op2);
11783 rtx tmp = gen_reg_rtx (<MODE>mode);
11784 rtx tmp2 = gen_reg_rtx (<MODE>mode);
11786 emit_insn (gen_subf<mode>3_carry (tmp, op1, op2));
11787 emit_insn (gen_subf<mode>3_carry_in_xx (tmp2));
11789 if (cond_code == LEU)
11790 emit_insn (gen_add<mode>3 (op0, tmp2, const1_rtx));
11792 emit_insn (gen_neg<mode>2 (op0, tmp2));
11797 (define_expand "cstore<mode>4"
11798 [(use (match_operator 1 "rs6000_cbranch_operator"
11799 [(match_operand:GPR 2 "gpc_reg_operand" "")
11800 (match_operand:GPR 3 "reg_or_short_operand" "")]))
11801 (clobber (match_operand:GPR 0 "register_operand"))]
11804 /* Use ISEL if the user asked for it. */
11806 rs6000_emit_sISEL (<MODE>mode, operands);
11808 /* Expanding EQ and NE directly to some machine instructions does not help
11809 but does hurt combine. So don't. */
11810 else if (GET_CODE (operands[1]) == EQ)
11811 emit_insn (gen_eq<mode>3 (operands[0], operands[2], operands[3]));
11812 else if (<MODE>mode == Pmode
11813 && GET_CODE (operands[1]) == NE)
11814 emit_insn (gen_ne<mode>3 (operands[0], operands[2], operands[3]));
11815 else if (GET_CODE (operands[1]) == NE)
11817 rtx tmp = gen_reg_rtx (<MODE>mode);
11818 emit_insn (gen_eq<mode>3 (tmp, operands[2], operands[3]));
11819 emit_insn (gen_xor<mode>3 (operands[0], tmp, const1_rtx));
11822 /* Expanding the unsigned comparisons however helps a lot: all the neg_ltu
11823 etc. combinations magically work out just right. */
11824 else if (<MODE>mode == Pmode
11825 && unsigned_comparison_operator (operands[1], VOIDmode))
11826 emit_insn (gen_cstore<mode>4_unsigned (operands[0], operands[1],
11827 operands[2], operands[3]));
11829 /* The generic code knows tricks to compute signed comparisons against
11830 zero. Let it do its thing. */
11831 else if (operands[3] == const0_rtx
11832 && signed_comparison_operator (operands[1], VOIDmode))
11835 /* Everything else, use the mfcr brute force. */
11837 rs6000_emit_sCOND (<MODE>mode, operands);
11842 (define_expand "cstore<mode>4"
11843 [(use (match_operator 1 "rs6000_cbranch_operator"
11844 [(match_operand:FP 2 "gpc_reg_operand" "")
11845 (match_operand:FP 3 "gpc_reg_operand" "")]))
11846 (clobber (match_operand:SI 0 "register_operand"))]
11849 rs6000_emit_sCOND (<MODE>mode, operands);
11854 (define_expand "stack_protect_set"
11855 [(match_operand 0 "memory_operand" "")
11856 (match_operand 1 "memory_operand" "")]
11859 #ifdef TARGET_THREAD_SSP_OFFSET
11860 rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
11861 rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
11862 operands[1] = gen_rtx_MEM (Pmode, addr);
11865 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
11867 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
11871 (define_insn "stack_protect_setsi"
11872 [(set (match_operand:SI 0 "memory_operand" "=m")
11873 (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET))
11874 (set (match_scratch:SI 2 "=&r") (const_int 0))]
11876 "lwz%U1%X1 %2,%1\;stw%U0%X0 %2,%0\;li %2,0"
11877 [(set_attr "type" "three")
11878 (set_attr "length" "12")])
11880 (define_insn "stack_protect_setdi"
11881 [(set (match_operand:DI 0 "memory_operand" "=Y")
11882 (unspec:DI [(match_operand:DI 1 "memory_operand" "Y")] UNSPEC_SP_SET))
11883 (set (match_scratch:DI 2 "=&r") (const_int 0))]
11885 "ld%U1%X1 %2,%1\;std%U0%X0 %2,%0\;li %2,0"
11886 [(set_attr "type" "three")
11887 (set_attr "length" "12")])
11889 (define_expand "stack_protect_test"
11890 [(match_operand 0 "memory_operand" "")
11891 (match_operand 1 "memory_operand" "")
11892 (match_operand 2 "" "")]
11895 rtx test, op0, op1;
11896 #ifdef TARGET_THREAD_SSP_OFFSET
11897 rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
11898 rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
11899 operands[1] = gen_rtx_MEM (Pmode, addr);
11902 op1 = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, operands[1]), UNSPEC_SP_TEST);
11903 test = gen_rtx_EQ (VOIDmode, op0, op1);
11904 emit_jump_insn (gen_cbranchsi4 (test, op0, op1, operands[2]));
11908 (define_insn "stack_protect_testsi"
11909 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
11910 (unspec:CCEQ [(match_operand:SI 1 "memory_operand" "m,m")
11911 (match_operand:SI 2 "memory_operand" "m,m")]
11913 (set (match_scratch:SI 4 "=r,r") (const_int 0))
11914 (clobber (match_scratch:SI 3 "=&r,&r"))]
11917 lwz%U1%X1 %3,%1\;lwz%U2%X2 %4,%2\;xor. %3,%3,%4\;li %4,0
11918 lwz%U1%X1 %3,%1\;lwz%U2%X2 %4,%2\;cmplw %0,%3,%4\;li %3,0\;li %4,0"
11919 [(set_attr "length" "16,20")])
11921 (define_insn "stack_protect_testdi"
11922 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
11923 (unspec:CCEQ [(match_operand:DI 1 "memory_operand" "Y,Y")
11924 (match_operand:DI 2 "memory_operand" "Y,Y")]
11926 (set (match_scratch:DI 4 "=r,r") (const_int 0))
11927 (clobber (match_scratch:DI 3 "=&r,&r"))]
11930 ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;xor. %3,%3,%4\;li %4,0
11931 ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;cmpld %0,%3,%4\;li %3,0\;li %4,0"
11932 [(set_attr "length" "16,20")])
11935 ;; Here are the actual compare insns.
11936 (define_insn "*cmp<mode>_internal1"
11937 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
11938 (compare:CC (match_operand:GPR 1 "gpc_reg_operand" "r")
11939 (match_operand:GPR 2 "reg_or_short_operand" "rI")))]
11941 "cmp<wd>%I2 %0,%1,%2"
11942 [(set_attr "type" "cmp")])
11944 ;; If we are comparing a register for equality with a large constant,
11945 ;; we can do this with an XOR followed by a compare. But this is profitable
11946 ;; only if the large constant is only used for the comparison (and in this
11947 ;; case we already have a register to reuse as scratch).
11949 ;; For 64-bit registers, we could only do so if the constant's bit 15 is clear:
11950 ;; otherwise we'd need to XOR with FFFFFFFF????0000 which is not available.
11953 [(set (match_operand:SI 0 "register_operand")
11954 (match_operand:SI 1 "logical_const_operand" ""))
11955 (set (match_dup 0) (match_operator:SI 3 "boolean_or_operator"
11957 (match_operand:SI 2 "logical_const_operand" "")]))
11958 (set (match_operand:CC 4 "cc_reg_operand" "")
11959 (compare:CC (match_operand:SI 5 "gpc_reg_operand" "")
11962 (if_then_else (match_operator 6 "equality_operator"
11963 [(match_dup 4) (const_int 0)])
11964 (match_operand 7 "" "")
11965 (match_operand 8 "" "")))]
11966 "peep2_reg_dead_p (3, operands[0])
11967 && peep2_reg_dead_p (4, operands[4])"
11968 [(set (match_dup 0) (xor:SI (match_dup 5) (match_dup 9)))
11969 (set (match_dup 4) (compare:CC (match_dup 0) (match_dup 10)))
11970 (set (pc) (if_then_else (match_dup 6) (match_dup 7) (match_dup 8)))]
11973 /* Get the constant we are comparing against, and see what it looks like
11974 when sign-extended from 16 to 32 bits. Then see what constant we could
11975 XOR with SEXTC to get the sign-extended value. */
11976 rtx cnst = simplify_const_binary_operation (GET_CODE (operands[3]),
11978 operands[1], operands[2]);
11979 HOST_WIDE_INT c = INTVAL (cnst);
11980 HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
11981 HOST_WIDE_INT xorv = c ^ sextc;
11983 operands[9] = GEN_INT (xorv);
11984 operands[10] = GEN_INT (sextc);
11987 (define_insn "*cmpsi_internal2"
11988 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11989 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11990 (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
11992 "cmplw%I2 %0,%1,%b2"
11993 [(set_attr "type" "cmp")])
11995 (define_insn "*cmpdi_internal2"
11996 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11997 (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
11998 (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
12000 "cmpld%I2 %0,%1,%b2"
12001 [(set_attr "type" "cmp")])
12003 ;; The following two insns don't exist as single insns, but if we provide
12004 ;; them, we can swap an add and compare, which will enable us to overlap more
12005 ;; of the required delay between a compare and branch. We generate code for
12006 ;; them by splitting.
12009 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
12010 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
12011 (match_operand:SI 2 "short_cint_operand" "i")))
12012 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
12013 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
12016 [(set_attr "length" "8")])
12019 [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
12020 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
12021 (match_operand:SI 2 "u_short_cint_operand" "i")))
12022 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
12023 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
12026 [(set_attr "length" "8")])
12029 [(set (match_operand:CC 3 "cc_reg_operand" "")
12030 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
12031 (match_operand:SI 2 "short_cint_operand" "")))
12032 (set (match_operand:SI 0 "gpc_reg_operand" "")
12033 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
12035 [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
12036 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
12039 [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
12040 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
12041 (match_operand:SI 2 "u_short_cint_operand" "")))
12042 (set (match_operand:SI 0 "gpc_reg_operand" "")
12043 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
12045 [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
12046 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
12048 ;; Only need to compare second words if first words equal
12049 (define_insn "*cmptf_internal1"
12050 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
12051 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "d")
12052 (match_operand:TF 2 "gpc_reg_operand" "d")))]
12053 "!TARGET_IEEEQUAD && !TARGET_XL_COMPAT
12054 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LONG_DOUBLE_128"
12055 "fcmpu %0,%1,%2\;bne %0,$+8\;fcmpu %0,%L1,%L2"
12056 [(set_attr "type" "fpcompare")
12057 (set_attr "length" "12")])
12059 (define_insn_and_split "*cmptf_internal2"
12060 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
12061 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "d")
12062 (match_operand:TF 2 "gpc_reg_operand" "d")))
12063 (clobber (match_scratch:DF 3 "=d"))
12064 (clobber (match_scratch:DF 4 "=d"))
12065 (clobber (match_scratch:DF 5 "=d"))
12066 (clobber (match_scratch:DF 6 "=d"))
12067 (clobber (match_scratch:DF 7 "=d"))
12068 (clobber (match_scratch:DF 8 "=d"))
12069 (clobber (match_scratch:DF 9 "=d"))
12070 (clobber (match_scratch:DF 10 "=d"))
12071 (clobber (match_scratch:GPR 11 "=b"))]
12072 "!TARGET_IEEEQUAD && TARGET_XL_COMPAT
12073 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LONG_DOUBLE_128"
12075 "&& reload_completed"
12076 [(set (match_dup 3) (match_dup 14))
12077 (set (match_dup 4) (match_dup 15))
12078 (set (match_dup 9) (abs:DF (match_dup 5)))
12079 (set (match_dup 0) (compare:CCFP (match_dup 9) (match_dup 3)))
12080 (set (pc) (if_then_else (ne (match_dup 0) (const_int 0))
12081 (label_ref (match_dup 12))
12083 (set (match_dup 0) (compare:CCFP (match_dup 5) (match_dup 7)))
12084 (set (pc) (label_ref (match_dup 13)))
12086 (set (match_dup 10) (minus:DF (match_dup 5) (match_dup 7)))
12087 (set (match_dup 9) (minus:DF (match_dup 6) (match_dup 8)))
12088 (set (match_dup 9) (plus:DF (match_dup 10) (match_dup 9)))
12089 (set (match_dup 0) (compare:CCFP (match_dup 9) (match_dup 4)))
12092 REAL_VALUE_TYPE rv;
12093 const int lo_word = LONG_DOUBLE_LARGE_FIRST ? GET_MODE_SIZE (DFmode) : 0;
12094 const int hi_word = LONG_DOUBLE_LARGE_FIRST ? 0 : GET_MODE_SIZE (DFmode);
12096 operands[5] = simplify_gen_subreg (DFmode, operands[1], TFmode, hi_word);
12097 operands[6] = simplify_gen_subreg (DFmode, operands[1], TFmode, lo_word);
12098 operands[7] = simplify_gen_subreg (DFmode, operands[2], TFmode, hi_word);
12099 operands[8] = simplify_gen_subreg (DFmode, operands[2], TFmode, lo_word);
12100 operands[12] = gen_label_rtx ();
12101 operands[13] = gen_label_rtx ();
12103 operands[14] = force_const_mem (DFmode,
12104 CONST_DOUBLE_FROM_REAL_VALUE (rv, DFmode));
12105 operands[15] = force_const_mem (DFmode,
12106 CONST_DOUBLE_FROM_REAL_VALUE (dconst0,
12111 tocref = create_TOC_reference (XEXP (operands[14], 0), operands[11]);
12112 operands[14] = gen_const_mem (DFmode, tocref);
12113 tocref = create_TOC_reference (XEXP (operands[15], 0), operands[11]);
12114 operands[15] = gen_const_mem (DFmode, tocref);
12115 set_mem_alias_set (operands[14], get_TOC_alias_set ());
12116 set_mem_alias_set (operands[15], get_TOC_alias_set ());
12120 ;; Now we have the scc insns. We can do some combinations because of the
12121 ;; way the machine works.
12123 ;; Note that this is probably faster if we can put an insn between the
12124 ;; mfcr and rlinm, but this is tricky. Let's leave it for now. In most
12125 ;; cases the insns below which don't use an intermediate CR field will
12126 ;; be used instead.
12128 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12129 (match_operator:SI 1 "scc_comparison_operator"
12130 [(match_operand 2 "cc_reg_operand" "y")
12133 "mfcr %0%Q2\;rlwinm %0,%0,%J1,1"
12134 [(set (attr "type")
12135 (cond [(match_test "TARGET_MFCRF")
12136 (const_string "mfcrf")
12138 (const_string "mfcr")))
12139 (set_attr "length" "8")])
12141 ;; Same as above, but get the GT bit.
12142 (define_insn "move_from_CR_gt_bit"
12143 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12144 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_GT))]
12145 "TARGET_HARD_FLOAT && !TARGET_FPRS"
12146 "mfcr %0\;rlwinm %0,%0,%D1,31,31"
12147 [(set_attr "type" "mfcr")
12148 (set_attr "length" "8")])
12150 ;; Same as above, but get the OV/ORDERED bit.
12151 (define_insn "move_from_CR_ov_bit"
12152 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12153 (unspec:SI [(match_operand:CC 1 "cc_reg_operand" "y")]
12156 "mfcr %0\;rlwinm %0,%0,%t1,1"
12157 [(set_attr "type" "mfcr")
12158 (set_attr "length" "8")])
12161 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12162 (match_operator:DI 1 "scc_comparison_operator"
12163 [(match_operand 2 "cc_reg_operand" "y")
12166 "mfcr %0%Q2\;rlwinm %0,%0,%J1,1"
12167 [(set (attr "type")
12168 (cond [(match_test "TARGET_MFCRF")
12169 (const_string "mfcrf")
12171 (const_string "mfcr")))
12172 (set_attr "length" "8")])
12175 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12176 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
12177 [(match_operand 2 "cc_reg_operand" "y,y")
12180 (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
12181 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
12184 mfcr %3%Q2\;rlwinm. %3,%3,%J1,1
12186 [(set_attr "type" "shift")
12187 (set_attr "dot" "yes")
12188 (set_attr "length" "8,16")])
12191 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12192 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
12193 [(match_operand 2 "cc_reg_operand" "")
12196 (set (match_operand:SI 3 "gpc_reg_operand" "")
12197 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
12198 "TARGET_32BIT && reload_completed"
12199 [(set (match_dup 3)
12200 (match_op_dup 1 [(match_dup 2) (const_int 0)]))
12202 (compare:CC (match_dup 3)
12207 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12208 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
12209 [(match_operand 2 "cc_reg_operand" "y")
12211 (match_operand:SI 3 "const_int_operand" "n")))]
12215 int is_bit = ccr_bit (operands[1], 1);
12216 int put_bit = 31 - (INTVAL (operands[3]) & 31);
12219 if (is_bit >= put_bit)
12220 count = is_bit - put_bit;
12222 count = 32 - (put_bit - is_bit);
12224 operands[4] = GEN_INT (count);
12225 operands[5] = GEN_INT (put_bit);
12227 return \"mfcr %0%Q2\;rlwinm %0,%0,%4,%5,%5\";
12229 [(set (attr "type")
12230 (cond [(match_test "TARGET_MFCRF")
12231 (const_string "mfcrf")
12233 (const_string "mfcr")))
12234 (set_attr "length" "8")])
12237 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12239 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
12240 [(match_operand 2 "cc_reg_operand" "y,y")
12242 (match_operand:SI 3 "const_int_operand" "n,n"))
12244 (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
12245 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
12250 int is_bit = ccr_bit (operands[1], 1);
12251 int put_bit = 31 - (INTVAL (operands[3]) & 31);
12254 /* Force split for non-cc0 compare. */
12255 if (which_alternative == 1)
12258 if (is_bit >= put_bit)
12259 count = is_bit - put_bit;
12261 count = 32 - (put_bit - is_bit);
12263 operands[5] = GEN_INT (count);
12264 operands[6] = GEN_INT (put_bit);
12266 return \"mfcr %4%Q2\;rlwinm. %4,%4,%5,%6,%6\";
12268 [(set_attr "type" "shift")
12269 (set_attr "dot" "yes")
12270 (set_attr "length" "8,16")])
12273 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
12275 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
12276 [(match_operand 2 "cc_reg_operand" "")
12278 (match_operand:SI 3 "const_int_operand" ""))
12280 (set (match_operand:SI 4 "gpc_reg_operand" "")
12281 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
12284 [(set (match_dup 4)
12285 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
12288 (compare:CC (match_dup 4)
12292 ;; There is a 3 cycle delay between consecutive mfcr instructions
12293 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
12296 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12297 (match_operator:SI 1 "scc_comparison_operator"
12298 [(match_operand 2 "cc_reg_operand" "y")
12300 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
12301 (match_operator:SI 4 "scc_comparison_operator"
12302 [(match_operand 5 "cc_reg_operand" "y")
12304 "REGNO (operands[2]) != REGNO (operands[5])"
12305 "mfcr %3\;rlwinm %0,%3,%J1,1\;rlwinm %3,%3,%J4,1"
12306 [(set_attr "type" "mfcr")
12307 (set_attr "length" "12")])
12310 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12311 (match_operator:DI 1 "scc_comparison_operator"
12312 [(match_operand 2 "cc_reg_operand" "y")
12314 (set (match_operand:DI 3 "gpc_reg_operand" "=r")
12315 (match_operator:DI 4 "scc_comparison_operator"
12316 [(match_operand 5 "cc_reg_operand" "y")
12318 "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
12319 "mfcr %3\;rlwinm %0,%3,%J1,1\;rlwinm %3,%3,%J4,1"
12320 [(set_attr "type" "mfcr")
12321 (set_attr "length" "12")])
12324 (define_mode_attr scc_eq_op2 [(SI "rKLI")
12327 (define_insn_and_split "eq<mode>3"
12328 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
12329 (eq:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
12330 (match_operand:GPR 2 "scc_eq_operand" "<scc_eq_op2>")))
12331 (clobber (match_scratch:GPR 3 "=r"))
12332 (clobber (match_scratch:GPR 4 "=r"))]
12336 [(set (match_dup 4)
12337 (clz:GPR (match_dup 3)))
12339 (lshiftrt:GPR (match_dup 4)
12342 operands[3] = rs6000_emit_eqne (<MODE>mode,
12343 operands[1], operands[2], operands[3]);
12345 if (GET_CODE (operands[4]) == SCRATCH)
12346 operands[4] = gen_reg_rtx (<MODE>mode);
12348 operands[5] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
12350 [(set (attr "length")
12351 (if_then_else (match_test "operands[2] == const0_rtx")
12353 (const_string "12")))])
12355 (define_insn_and_split "ne<mode>3"
12356 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12357 (ne:P (match_operand:P 1 "gpc_reg_operand" "r")
12358 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>")))
12359 (clobber (match_scratch:P 3 "=r"))
12360 (clobber (match_scratch:P 4 "=r"))
12361 (clobber (reg:P CA_REGNO))]
12365 [(parallel [(set (match_dup 4)
12366 (plus:P (match_dup 3)
12368 (set (reg:P CA_REGNO)
12369 (ne:P (match_dup 3)
12371 (parallel [(set (match_dup 0)
12372 (plus:P (plus:P (not:P (match_dup 4))
12375 (clobber (reg:P CA_REGNO))])]
12377 operands[3] = rs6000_emit_eqne (<MODE>mode,
12378 operands[1], operands[2], operands[3]);
12380 if (GET_CODE (operands[4]) == SCRATCH)
12381 operands[4] = gen_reg_rtx (<MODE>mode);
12383 [(set (attr "length")
12384 (if_then_else (match_test "operands[2] == const0_rtx")
12386 (const_string "12")))])
12388 (define_insn_and_split "*neg_eq_<mode>"
12389 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12390 (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "r")
12391 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))))
12392 (clobber (match_scratch:P 3 "=r"))
12393 (clobber (match_scratch:P 4 "=r"))
12394 (clobber (reg:P CA_REGNO))]
12398 [(parallel [(set (match_dup 4)
12399 (plus:P (match_dup 3)
12401 (set (reg:P CA_REGNO)
12402 (ne:P (match_dup 3)
12404 (parallel [(set (match_dup 0)
12405 (plus:P (reg:P CA_REGNO)
12407 (clobber (reg:P CA_REGNO))])]
12409 operands[3] = rs6000_emit_eqne (<MODE>mode,
12410 operands[1], operands[2], operands[3]);
12412 if (GET_CODE (operands[4]) == SCRATCH)
12413 operands[4] = gen_reg_rtx (<MODE>mode);
12415 [(set (attr "length")
12416 (if_then_else (match_test "operands[2] == const0_rtx")
12418 (const_string "12")))])
12420 (define_insn_and_split "*neg_ne_<mode>"
12421 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12422 (neg:P (ne:P (match_operand:P 1 "gpc_reg_operand" "r")
12423 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))))
12424 (clobber (match_scratch:P 3 "=r"))
12425 (clobber (match_scratch:P 4 "=r"))
12426 (clobber (reg:P CA_REGNO))]
12430 [(parallel [(set (match_dup 4)
12431 (neg:P (match_dup 3)))
12432 (set (reg:P CA_REGNO)
12433 (eq:P (match_dup 3)
12435 (parallel [(set (match_dup 0)
12436 (plus:P (reg:P CA_REGNO)
12438 (clobber (reg:P CA_REGNO))])]
12440 operands[3] = rs6000_emit_eqne (<MODE>mode,
12441 operands[1], operands[2], operands[3]);
12443 if (GET_CODE (operands[4]) == SCRATCH)
12444 operands[4] = gen_reg_rtx (<MODE>mode);
12446 [(set (attr "length")
12447 (if_then_else (match_test "operands[2] == const0_rtx")
12449 (const_string "12")))])
12451 (define_insn_and_split "*plus_eq_<mode>"
12452 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12453 (plus:P (eq:P (match_operand:P 1 "gpc_reg_operand" "r")
12454 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))
12455 (match_operand:P 3 "gpc_reg_operand" "r")))
12456 (clobber (match_scratch:P 4 "=r"))
12457 (clobber (match_scratch:P 5 "=r"))
12458 (clobber (reg:P CA_REGNO))]
12462 [(parallel [(set (match_dup 5)
12463 (neg:P (match_dup 4)))
12464 (set (reg:P CA_REGNO)
12465 (eq:P (match_dup 4)
12467 (parallel [(set (match_dup 0)
12468 (plus:P (match_dup 3)
12470 (clobber (reg:P CA_REGNO))])]
12472 operands[4] = rs6000_emit_eqne (<MODE>mode,
12473 operands[1], operands[2], operands[4]);
12475 if (GET_CODE (operands[5]) == SCRATCH)
12476 operands[5] = gen_reg_rtx (<MODE>mode);
12478 [(set (attr "length")
12479 (if_then_else (match_test "operands[2] == const0_rtx")
12481 (const_string "12")))])
12483 (define_insn_and_split "*plus_ne_<mode>"
12484 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12485 (plus:P (ne:P (match_operand:P 1 "gpc_reg_operand" "r")
12486 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))
12487 (match_operand:P 3 "gpc_reg_operand" "r")))
12488 (clobber (match_scratch:P 4 "=r"))
12489 (clobber (match_scratch:P 5 "=r"))
12490 (clobber (reg:P CA_REGNO))]
12494 [(parallel [(set (match_dup 5)
12495 (plus:P (match_dup 4)
12497 (set (reg:P CA_REGNO)
12498 (ne:P (match_dup 4)
12500 (parallel [(set (match_dup 0)
12501 (plus:P (match_dup 3)
12503 (clobber (reg:P CA_REGNO))])]
12505 operands[4] = rs6000_emit_eqne (<MODE>mode,
12506 operands[1], operands[2], operands[4]);
12508 if (GET_CODE (operands[5]) == SCRATCH)
12509 operands[5] = gen_reg_rtx (<MODE>mode);
12511 [(set (attr "length")
12512 (if_then_else (match_test "operands[2] == const0_rtx")
12514 (const_string "12")))])
12516 (define_insn_and_split "*minus_eq_<mode>"
12517 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12518 (minus:P (match_operand:P 3 "gpc_reg_operand" "r")
12519 (eq:P (match_operand:P 1 "gpc_reg_operand" "r")
12520 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))))
12521 (clobber (match_scratch:P 4 "=r"))
12522 (clobber (match_scratch:P 5 "=r"))
12523 (clobber (reg:P CA_REGNO))]
12527 [(parallel [(set (match_dup 5)
12528 (plus:P (match_dup 4)
12530 (set (reg:P CA_REGNO)
12531 (ne:P (match_dup 4)
12533 (parallel [(set (match_dup 0)
12534 (plus:P (plus:P (match_dup 3)
12537 (clobber (reg:P CA_REGNO))])]
12539 operands[4] = rs6000_emit_eqne (<MODE>mode,
12540 operands[1], operands[2], operands[4]);
12542 if (GET_CODE (operands[5]) == SCRATCH)
12543 operands[5] = gen_reg_rtx (<MODE>mode);
12545 [(set (attr "length")
12546 (if_then_else (match_test "operands[2] == const0_rtx")
12548 (const_string "12")))])
12550 (define_insn_and_split "*minus_ne_<mode>"
12551 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12552 (minus:P (match_operand:P 3 "gpc_reg_operand" "r")
12553 (ne:P (match_operand:P 1 "gpc_reg_operand" "r")
12554 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))))
12555 (clobber (match_scratch:P 4 "=r"))
12556 (clobber (match_scratch:P 5 "=r"))
12557 (clobber (reg:P CA_REGNO))]
12561 [(parallel [(set (match_dup 5)
12562 (neg:P (match_dup 4)))
12563 (set (reg:P CA_REGNO)
12564 (eq:P (match_dup 4)
12566 (parallel [(set (match_dup 0)
12567 (plus:P (plus:P (match_dup 3)
12570 (clobber (reg:P CA_REGNO))])]
12572 operands[4] = rs6000_emit_eqne (<MODE>mode,
12573 operands[1], operands[2], operands[4]);
12575 if (GET_CODE (operands[5]) == SCRATCH)
12576 operands[5] = gen_reg_rtx (<MODE>mode);
12578 [(set (attr "length")
12579 (if_then_else (match_test "operands[2] == const0_rtx")
12581 (const_string "12")))])
12583 (define_insn_and_split "*eqsi3_ext<mode>"
12584 [(set (match_operand:EXTSI 0 "gpc_reg_operand" "=r")
12585 (eq:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r")
12586 (match_operand:SI 2 "scc_eq_operand" "rKLI")))
12587 (clobber (match_scratch:SI 3 "=r"))
12588 (clobber (match_scratch:SI 4 "=r"))]
12592 [(set (match_dup 4)
12593 (clz:SI (match_dup 3)))
12596 (lshiftrt:SI (match_dup 4)
12599 operands[3] = rs6000_emit_eqne (SImode,
12600 operands[1], operands[2], operands[3]);
12602 if (GET_CODE (operands[4]) == SCRATCH)
12603 operands[4] = gen_reg_rtx (SImode);
12605 [(set (attr "length")
12606 (if_then_else (match_test "operands[2] == const0_rtx")
12608 (const_string "12")))])
12610 (define_insn_and_split "*nesi3_ext<mode>"
12611 [(set (match_operand:EXTSI 0 "gpc_reg_operand" "=r")
12612 (ne:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r")
12613 (match_operand:SI 2 "scc_eq_operand" "rKLI")))
12614 (clobber (match_scratch:SI 3 "=r"))
12615 (clobber (match_scratch:SI 4 "=r"))
12616 (clobber (match_scratch:EXTSI 5 "=r"))]
12620 [(set (match_dup 4)
12621 (clz:SI (match_dup 3)))
12624 (lshiftrt:SI (match_dup 4)
12627 (xor:EXTSI (match_dup 5)
12630 operands[3] = rs6000_emit_eqne (SImode,
12631 operands[1], operands[2], operands[3]);
12633 if (GET_CODE (operands[4]) == SCRATCH)
12634 operands[4] = gen_reg_rtx (SImode);
12635 if (GET_CODE (operands[5]) == SCRATCH)
12636 operands[5] = gen_reg_rtx (<MODE>mode);
12638 [(set (attr "length")
12639 (if_then_else (match_test "operands[2] == const0_rtx")
12640 (const_string "12")
12641 (const_string "16")))])
12643 ;; Define both directions of branch and return. If we need a reload
12644 ;; register, we'd rather use CR0 since it is much easier to copy a
12645 ;; register CC value to there.
12649 (if_then_else (match_operator 1 "branch_comparison_operator"
12651 "cc_reg_operand" "y")
12653 (label_ref (match_operand 0 "" ""))
12658 return output_cbranch (operands[1], \"%l0\", 0, insn);
12660 [(set_attr "type" "branch")])
12664 (if_then_else (match_operator 0 "branch_comparison_operator"
12666 "cc_reg_operand" "y")
12673 return output_cbranch (operands[0], NULL, 0, insn);
12675 [(set_attr "type" "jmpreg")
12676 (set_attr "length" "4")])
12680 (if_then_else (match_operator 1 "branch_comparison_operator"
12682 "cc_reg_operand" "y")
12685 (label_ref (match_operand 0 "" ""))))]
12689 return output_cbranch (operands[1], \"%l0\", 1, insn);
12691 [(set_attr "type" "branch")])
12695 (if_then_else (match_operator 0 "branch_comparison_operator"
12697 "cc_reg_operand" "y")
12704 return output_cbranch (operands[0], NULL, 1, insn);
12706 [(set_attr "type" "jmpreg")
12707 (set_attr "length" "4")])
12709 ;; Logic on condition register values.
12711 ; This pattern matches things like
12712 ; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
12713 ; (eq:SI (reg:CCFP 68) (const_int 0)))
12715 ; which are generated by the branch logic.
12716 ; Prefer destructive operations where BT = BB (for crXX BT,BA,BB)
12718 (define_insn "*cceq_ior_compare"
12719 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
12720 (compare:CCEQ (match_operator:SI 1 "boolean_operator"
12721 [(match_operator:SI 2
12722 "branch_positive_comparison_operator"
12724 "cc_reg_operand" "y,y")
12726 (match_operator:SI 4
12727 "branch_positive_comparison_operator"
12729 "cc_reg_operand" "0,y")
12733 "cr%q1 %E0,%j2,%j4"
12734 [(set_attr "type" "cr_logical,delayed_cr")])
12736 ; Why is the constant -1 here, but 1 in the previous pattern?
12737 ; Because ~1 has all but the low bit set.
12739 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
12740 (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
12741 [(not:SI (match_operator:SI 2
12742 "branch_positive_comparison_operator"
12744 "cc_reg_operand" "y,y")
12746 (match_operator:SI 4
12747 "branch_positive_comparison_operator"
12749 "cc_reg_operand" "0,y")
12753 "cr%q1 %E0,%j2,%j4"
12754 [(set_attr "type" "cr_logical,delayed_cr")])
12756 (define_insn "*cceq_rev_compare"
12757 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
12758 (compare:CCEQ (match_operator:SI 1
12759 "branch_positive_comparison_operator"
12761 "cc_reg_operand" "0,y")
12766 [(set_attr "type" "cr_logical,delayed_cr")])
12768 ;; If we are comparing the result of two comparisons, this can be done
12769 ;; using creqv or crxor.
12771 (define_insn_and_split ""
12772 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
12773 (compare:CCEQ (match_operator 1 "branch_comparison_operator"
12774 [(match_operand 2 "cc_reg_operand" "y")
12776 (match_operator 3 "branch_comparison_operator"
12777 [(match_operand 4 "cc_reg_operand" "y")
12782 [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
12786 int positive_1, positive_2;
12788 positive_1 = branch_positive_comparison_operator (operands[1],
12789 GET_MODE (operands[1]));
12790 positive_2 = branch_positive_comparison_operator (operands[3],
12791 GET_MODE (operands[3]));
12794 operands[1] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[2]),
12795 GET_CODE (operands[1])),
12797 operands[2], const0_rtx);
12798 else if (GET_MODE (operands[1]) != SImode)
12799 operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode,
12800 operands[2], const0_rtx);
12803 operands[3] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[4]),
12804 GET_CODE (operands[3])),
12806 operands[4], const0_rtx);
12807 else if (GET_MODE (operands[3]) != SImode)
12808 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
12809 operands[4], const0_rtx);
12811 if (positive_1 == positive_2)
12813 operands[1] = gen_rtx_NOT (SImode, operands[1]);
12814 operands[5] = constm1_rtx;
12818 operands[5] = const1_rtx;
12822 ;; Unconditional branch and return.
12824 (define_insn "jump"
12826 (label_ref (match_operand 0 "" "")))]
12829 [(set_attr "type" "branch")])
12831 (define_insn "<return_str>return"
12835 [(set_attr "type" "jmpreg")])
12837 (define_expand "indirect_jump"
12838 [(set (pc) (match_operand 0 "register_operand" ""))])
12840 (define_insn "*indirect_jump<mode>"
12841 [(set (pc) (match_operand:P 0 "register_operand" "c,*l"))]
12846 [(set_attr "type" "jmpreg")])
12848 ;; Table jump for switch statements:
12849 (define_expand "tablejump"
12850 [(use (match_operand 0 "" ""))
12851 (use (label_ref (match_operand 1 "" "")))]
12856 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
12858 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
12862 (define_expand "tablejumpsi"
12863 [(set (match_dup 3)
12864 (plus:SI (match_operand:SI 0 "" "")
12866 (parallel [(set (pc) (match_dup 3))
12867 (use (label_ref (match_operand 1 "" "")))])]
12870 { operands[0] = force_reg (SImode, operands[0]);
12871 operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
12872 operands[3] = gen_reg_rtx (SImode);
12875 (define_expand "tablejumpdi"
12876 [(set (match_dup 4)
12877 (sign_extend:DI (match_operand:SI 0 "lwa_operand" "")))
12879 (plus:DI (match_dup 4)
12881 (parallel [(set (pc) (match_dup 3))
12882 (use (label_ref (match_operand 1 "" "")))])]
12885 { operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
12886 operands[3] = gen_reg_rtx (DImode);
12887 operands[4] = gen_reg_rtx (DImode);
12890 (define_insn "*tablejump<mode>_internal1"
12892 (match_operand:P 0 "register_operand" "c,*l"))
12893 (use (label_ref (match_operand 1 "" "")))]
12898 [(set_attr "type" "jmpreg")])
12905 (define_insn "group_ending_nop"
12906 [(unspec [(const_int 0)] UNSPEC_GRP_END_NOP)]
12910 if (rs6000_cpu_attr == CPU_POWER6)
12911 return \"ori 1,1,0\";
12912 return \"ori 2,2,0\";
12915 ;; Define the subtract-one-and-jump insns, starting with the template
12916 ;; so loop.c knows what to generate.
12918 (define_expand "doloop_end"
12919 [(use (match_operand 0 "" "")) ; loop pseudo
12920 (use (match_operand 1 "" ""))] ; label
12926 if (GET_MODE (operands[0]) != DImode)
12928 emit_jump_insn (gen_ctrdi (operands[0], operands[1]));
12932 if (GET_MODE (operands[0]) != SImode)
12934 emit_jump_insn (gen_ctrsi (operands[0], operands[1]));
12939 (define_expand "ctr<mode>"
12940 [(parallel [(set (pc)
12941 (if_then_else (ne (match_operand:P 0 "register_operand" "")
12943 (label_ref (match_operand 1 "" ""))
12946 (plus:P (match_dup 0)
12948 (clobber (match_scratch:CC 2 ""))
12949 (clobber (match_scratch:P 3 ""))])]
12953 ;; We need to be able to do this for any operand, including MEM, or we
12954 ;; will cause reload to blow up since we don't allow output reloads on
12956 ;; For the length attribute to be calculated correctly, the
12957 ;; label MUST be operand 0.
12959 (define_insn "*ctr<mode>_internal1"
12961 (if_then_else (ne (match_operand:P 1 "register_operand" "c,*b,*b,*b")
12963 (label_ref (match_operand 0 "" ""))
12965 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*c*l")
12966 (plus:P (match_dup 1)
12968 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
12969 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
12973 if (which_alternative != 0)
12975 else if (get_attr_length (insn) == 4)
12976 return \"bdnz %l0\";
12978 return \"bdz $+8\;b %l0\";
12980 [(set_attr "type" "branch")
12981 (set_attr "length" "*,16,20,20")])
12983 (define_insn "*ctr<mode>_internal2"
12985 (if_then_else (ne (match_operand:P 1 "register_operand" "c,*b,*b,*b")
12988 (label_ref (match_operand 0 "" ""))))
12989 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*c*l")
12990 (plus:P (match_dup 1)
12992 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
12993 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
12997 if (which_alternative != 0)
12999 else if (get_attr_length (insn) == 4)
13000 return \"bdz %l0\";
13002 return \"bdnz $+8\;b %l0\";
13004 [(set_attr "type" "branch")
13005 (set_attr "length" "*,16,20,20")])
13007 ;; Similar but use EQ
13009 (define_insn "*ctr<mode>_internal5"
13011 (if_then_else (eq (match_operand:P 1 "register_operand" "c,*b,*b,*b")
13013 (label_ref (match_operand 0 "" ""))
13015 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*c*l")
13016 (plus:P (match_dup 1)
13018 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13019 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13023 if (which_alternative != 0)
13025 else if (get_attr_length (insn) == 4)
13026 return \"bdz %l0\";
13028 return \"bdnz $+8\;b %l0\";
13030 [(set_attr "type" "branch")
13031 (set_attr "length" "*,16,20,20")])
13033 (define_insn "*ctr<mode>_internal6"
13035 (if_then_else (eq (match_operand:P 1 "register_operand" "c,*b,*b,*b")
13038 (label_ref (match_operand 0 "" ""))))
13039 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*c*l")
13040 (plus:P (match_dup 1)
13042 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13043 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13047 if (which_alternative != 0)
13049 else if (get_attr_length (insn) == 4)
13050 return \"bdnz %l0\";
13052 return \"bdz $+8\;b %l0\";
13054 [(set_attr "type" "branch")
13055 (set_attr "length" "*,16,20,20")])
13057 ;; Now the splitters if we could not allocate the CTR register
13061 (if_then_else (match_operator 2 "comparison_operator"
13062 [(match_operand:P 1 "gpc_reg_operand" "")
13064 (match_operand 5 "" "")
13065 (match_operand 6 "" "")))
13066 (set (match_operand:P 0 "gpc_reg_operand" "")
13067 (plus:P (match_dup 1) (const_int -1)))
13068 (clobber (match_scratch:CC 3 ""))
13069 (clobber (match_scratch:P 4 ""))]
13071 [(set (match_dup 3)
13072 (compare:CC (match_dup 1)
13075 (plus:P (match_dup 1)
13077 (set (pc) (if_then_else (match_dup 7)
13081 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
13082 operands[3], const0_rtx); }")
13086 (if_then_else (match_operator 2 "comparison_operator"
13087 [(match_operand:P 1 "gpc_reg_operand" "")
13089 (match_operand 5 "" "")
13090 (match_operand 6 "" "")))
13091 (set (match_operand:P 0 "nonimmediate_operand" "")
13092 (plus:P (match_dup 1) (const_int -1)))
13093 (clobber (match_scratch:CC 3 ""))
13094 (clobber (match_scratch:P 4 ""))]
13095 "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
13096 [(set (match_dup 3)
13097 (compare:CC (match_dup 1)
13100 (plus:P (match_dup 1)
13104 (set (pc) (if_then_else (match_dup 7)
13108 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
13109 operands[3], const0_rtx); }")
13111 (define_insn "trap"
13112 [(trap_if (const_int 1) (const_int 0))]
13115 [(set_attr "type" "trap")])
13117 (define_expand "ctrap<mode>4"
13118 [(trap_if (match_operator 0 "ordered_comparison_operator"
13119 [(match_operand:GPR 1 "register_operand")
13120 (match_operand:GPR 2 "reg_or_short_operand")])
13121 (match_operand 3 "zero_constant" ""))]
13126 [(trap_if (match_operator 0 "ordered_comparison_operator"
13127 [(match_operand:GPR 1 "register_operand" "r")
13128 (match_operand:GPR 2 "reg_or_short_operand" "rI")])
13131 "t<wd>%V0%I2 %1,%2"
13132 [(set_attr "type" "trap")])
13134 ;; Insns related to generating the function prologue and epilogue.
13136 (define_expand "prologue"
13137 [(use (const_int 0))]
13140 rs6000_emit_prologue ();
13141 if (!TARGET_SCHED_PROLOG)
13142 emit_insn (gen_blockage ());
13146 (define_insn "*movesi_from_cr_one"
13147 [(match_parallel 0 "mfcr_operation"
13148 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
13149 (unspec:SI [(match_operand:CC 2 "cc_reg_operand" "y")
13150 (match_operand 3 "immediate_operand" "n")]
13151 UNSPEC_MOVESI_FROM_CR))])]
13157 for (i = 0; i < XVECLEN (operands[0], 0); i++)
13159 mask = INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
13160 operands[4] = GEN_INT (mask);
13161 output_asm_insn (\"mfcr %1,%4\", operands);
13165 [(set_attr "type" "mfcrf")])
13167 (define_insn "movesi_from_cr"
13168 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13169 (unspec:SI [(reg:CC CR0_REGNO) (reg:CC CR1_REGNO)
13170 (reg:CC CR2_REGNO) (reg:CC CR3_REGNO)
13171 (reg:CC CR4_REGNO) (reg:CC CR5_REGNO)
13172 (reg:CC CR6_REGNO) (reg:CC CR7_REGNO)]
13173 UNSPEC_MOVESI_FROM_CR))]
13176 [(set_attr "type" "mfcr")])
13178 (define_insn "*crsave"
13179 [(match_parallel 0 "crsave_operation"
13180 [(set (match_operand:SI 1 "memory_operand" "=m")
13181 (match_operand:SI 2 "gpc_reg_operand" "r"))])]
13184 [(set_attr "type" "store")])
13186 (define_insn "*stmw"
13187 [(match_parallel 0 "stmw_operation"
13188 [(set (match_operand:SI 1 "memory_operand" "=m")
13189 (match_operand:SI 2 "gpc_reg_operand" "r"))])]
13192 [(set_attr "type" "store")
13193 (set_attr "update" "yes")
13194 (set_attr "indexed" "yes")])
13196 ; The following comment applies to:
13200 ; return_and_restore_gpregs*
13201 ; return_and_restore_fpregs*
13202 ; return_and_restore_fpregs_aix*
13204 ; The out-of-line save / restore functions expects one input argument.
13205 ; Since those are not standard call_insn's, we must avoid using
13206 ; MATCH_OPERAND for that argument. That way the register rename
13207 ; optimization will not try to rename this register.
13208 ; Each pattern is repeated for each possible register number used in
13209 ; various ABIs (r11, r1, and for some functions r12)
13211 (define_insn "*save_gpregs_<mode>_r11"
13212 [(match_parallel 0 "any_parallel_operand"
13213 [(clobber (reg:P 65))
13214 (use (match_operand:P 1 "symbol_ref_operand" "s"))
13216 (set (match_operand:P 2 "memory_operand" "=m")
13217 (match_operand:P 3 "gpc_reg_operand" "r"))])]
13220 [(set_attr "type" "branch")
13221 (set_attr "length" "4")])
13223 (define_insn "*save_gpregs_<mode>_r12"
13224 [(match_parallel 0 "any_parallel_operand"
13225 [(clobber (reg:P 65))
13226 (use (match_operand:P 1 "symbol_ref_operand" "s"))
13228 (set (match_operand:P 2 "memory_operand" "=m")
13229 (match_operand:P 3 "gpc_reg_operand" "r"))])]
13232 [(set_attr "type" "branch")
13233 (set_attr "length" "4")])
13235 (define_insn "*save_gpregs_<mode>_r1"
13236 [(match_parallel 0 "any_parallel_operand"
13237 [(clobber (reg:P 65))
13238 (use (match_operand:P 1 "symbol_ref_operand" "s"))
13240 (set (match_operand:P 2 "memory_operand" "=m")
13241 (match_operand:P 3 "gpc_reg_operand" "r"))])]
13244 [(set_attr "type" "branch")
13245 (set_attr "length" "4")])
13247 (define_insn "*save_fpregs_<mode>_r11"
13248 [(match_parallel 0 "any_parallel_operand"
13249 [(clobber (reg:P 65))
13250 (use (match_operand:P 1 "symbol_ref_operand" "s"))
13252 (set (match_operand:DF 2 "memory_operand" "=m")
13253 (match_operand:DF 3 "gpc_reg_operand" "d"))])]
13256 [(set_attr "type" "branch")
13257 (set_attr "length" "4")])
13259 (define_insn "*save_fpregs_<mode>_r12"
13260 [(match_parallel 0 "any_parallel_operand"
13261 [(clobber (reg:P 65))
13262 (use (match_operand:P 1 "symbol_ref_operand" "s"))
13264 (set (match_operand:DF 2 "memory_operand" "=m")
13265 (match_operand:DF 3 "gpc_reg_operand" "d"))])]
13268 [(set_attr "type" "branch")
13269 (set_attr "length" "4")])
13271 (define_insn "*save_fpregs_<mode>_r1"
13272 [(match_parallel 0 "any_parallel_operand"
13273 [(clobber (reg:P 65))
13274 (use (match_operand:P 1 "symbol_ref_operand" "s"))
13276 (set (match_operand:DF 2 "memory_operand" "=m")
13277 (match_operand:DF 3 "gpc_reg_operand" "d"))])]
13280 [(set_attr "type" "branch")
13281 (set_attr "length" "4")])
13283 ; This is to explain that changes to the stack pointer should
13284 ; not be moved over loads from or stores to stack memory.
13285 (define_insn "stack_tie"
13286 [(match_parallel 0 "tie_operand"
13287 [(set (mem:BLK (reg 1)) (const_int 0))])]
13290 [(set_attr "length" "0")])
13292 (define_expand "epilogue"
13293 [(use (const_int 0))]
13296 if (!TARGET_SCHED_PROLOG)
13297 emit_insn (gen_blockage ());
13298 rs6000_emit_epilogue (FALSE);
13302 ; On some processors, doing the mtcrf one CC register at a time is
13303 ; faster (like on the 604e). On others, doing them all at once is
13304 ; faster; for instance, on the 601 and 750.
13306 (define_expand "movsi_to_cr_one"
13307 [(set (match_operand:CC 0 "cc_reg_operand" "")
13308 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "")
13309 (match_dup 2)] UNSPEC_MOVESI_TO_CR))]
13311 "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
13313 (define_insn "*movsi_to_cr"
13314 [(match_parallel 0 "mtcrf_operation"
13315 [(set (match_operand:CC 1 "cc_reg_operand" "=y")
13316 (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
13317 (match_operand 3 "immediate_operand" "n")]
13318 UNSPEC_MOVESI_TO_CR))])]
13324 for (i = 0; i < XVECLEN (operands[0], 0); i++)
13325 mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
13326 operands[4] = GEN_INT (mask);
13327 return \"mtcrf %4,%2\";
13329 [(set_attr "type" "mtcr")])
13331 (define_insn "*mtcrfsi"
13332 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
13333 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
13334 (match_operand 2 "immediate_operand" "n")]
13335 UNSPEC_MOVESI_TO_CR))]
13336 "GET_CODE (operands[0]) == REG
13337 && CR_REGNO_P (REGNO (operands[0]))
13338 && GET_CODE (operands[2]) == CONST_INT
13339 && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
13341 [(set_attr "type" "mtcr")])
13343 ; The load-multiple instructions have similar properties.
13344 ; Note that "load_multiple" is a name known to the machine-independent
13345 ; code that actually corresponds to the PowerPC load-string.
13347 (define_insn "*lmw"
13348 [(match_parallel 0 "lmw_operation"
13349 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
13350 (match_operand:SI 2 "memory_operand" "m"))])]
13353 [(set_attr "type" "load")
13354 (set_attr "update" "yes")
13355 (set_attr "indexed" "yes")
13356 (set_attr "cell_micro" "always")])
13358 (define_insn "*return_internal_<mode>"
13360 (use (match_operand:P 0 "register_operand" "lc"))]
13363 [(set_attr "type" "jmpreg")])
13365 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
13366 ; stuff was in GCC. Oh, and "any_parallel_operand" is a bit flexible...
13368 ; The following comment applies to:
13372 ; return_and_restore_gpregs*
13373 ; return_and_restore_fpregs*
13374 ; return_and_restore_fpregs_aix*
13376 ; The out-of-line save / restore functions expects one input argument.
13377 ; Since those are not standard call_insn's, we must avoid using
13378 ; MATCH_OPERAND for that argument. That way the register rename
13379 ; optimization will not try to rename this register.
13380 ; Each pattern is repeated for each possible register number used in
13381 ; various ABIs (r11, r1, and for some functions r12)
13383 (define_insn "*restore_gpregs_<mode>_r11"
13384 [(match_parallel 0 "any_parallel_operand"
13385 [(clobber (match_operand:P 1 "register_operand" "=l"))
13386 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13388 (set (match_operand:P 3 "gpc_reg_operand" "=r")
13389 (match_operand:P 4 "memory_operand" "m"))])]
13392 [(set_attr "type" "branch")
13393 (set_attr "length" "4")])
13395 (define_insn "*restore_gpregs_<mode>_r12"
13396 [(match_parallel 0 "any_parallel_operand"
13397 [(clobber (match_operand:P 1 "register_operand" "=l"))
13398 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13400 (set (match_operand:P 3 "gpc_reg_operand" "=r")
13401 (match_operand:P 4 "memory_operand" "m"))])]
13404 [(set_attr "type" "branch")
13405 (set_attr "length" "4")])
13407 (define_insn "*restore_gpregs_<mode>_r1"
13408 [(match_parallel 0 "any_parallel_operand"
13409 [(clobber (match_operand:P 1 "register_operand" "=l"))
13410 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13412 (set (match_operand:P 3 "gpc_reg_operand" "=r")
13413 (match_operand:P 4 "memory_operand" "m"))])]
13416 [(set_attr "type" "branch")
13417 (set_attr "length" "4")])
13419 (define_insn "*return_and_restore_gpregs_<mode>_r11"
13420 [(match_parallel 0 "any_parallel_operand"
13422 (clobber (match_operand:P 1 "register_operand" "=l"))
13423 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13425 (set (match_operand:P 3 "gpc_reg_operand" "=r")
13426 (match_operand:P 4 "memory_operand" "m"))])]
13429 [(set_attr "type" "branch")
13430 (set_attr "length" "4")])
13432 (define_insn "*return_and_restore_gpregs_<mode>_r12"
13433 [(match_parallel 0 "any_parallel_operand"
13435 (clobber (match_operand:P 1 "register_operand" "=l"))
13436 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13438 (set (match_operand:P 3 "gpc_reg_operand" "=r")
13439 (match_operand:P 4 "memory_operand" "m"))])]
13442 [(set_attr "type" "branch")
13443 (set_attr "length" "4")])
13445 (define_insn "*return_and_restore_gpregs_<mode>_r1"
13446 [(match_parallel 0 "any_parallel_operand"
13448 (clobber (match_operand:P 1 "register_operand" "=l"))
13449 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13451 (set (match_operand:P 3 "gpc_reg_operand" "=r")
13452 (match_operand:P 4 "memory_operand" "m"))])]
13455 [(set_attr "type" "branch")
13456 (set_attr "length" "4")])
13458 (define_insn "*return_and_restore_fpregs_<mode>_r11"
13459 [(match_parallel 0 "any_parallel_operand"
13461 (clobber (match_operand:P 1 "register_operand" "=l"))
13462 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13464 (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13465 (match_operand:DF 4 "memory_operand" "m"))])]
13468 [(set_attr "type" "branch")
13469 (set_attr "length" "4")])
13471 (define_insn "*return_and_restore_fpregs_<mode>_r12"
13472 [(match_parallel 0 "any_parallel_operand"
13474 (clobber (match_operand:P 1 "register_operand" "=l"))
13475 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13477 (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13478 (match_operand:DF 4 "memory_operand" "m"))])]
13481 [(set_attr "type" "branch")
13482 (set_attr "length" "4")])
13484 (define_insn "*return_and_restore_fpregs_<mode>_r1"
13485 [(match_parallel 0 "any_parallel_operand"
13487 (clobber (match_operand:P 1 "register_operand" "=l"))
13488 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13490 (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13491 (match_operand:DF 4 "memory_operand" "m"))])]
13494 [(set_attr "type" "branch")
13495 (set_attr "length" "4")])
13497 (define_insn "*return_and_restore_fpregs_aix_<mode>_r11"
13498 [(match_parallel 0 "any_parallel_operand"
13500 (use (match_operand:P 1 "register_operand" "l"))
13501 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13503 (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13504 (match_operand:DF 4 "memory_operand" "m"))])]
13507 [(set_attr "type" "branch")
13508 (set_attr "length" "4")])
13510 (define_insn "*return_and_restore_fpregs_aix_<mode>_r1"
13511 [(match_parallel 0 "any_parallel_operand"
13513 (use (match_operand:P 1 "register_operand" "l"))
13514 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13516 (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13517 (match_operand:DF 4 "memory_operand" "m"))])]
13520 [(set_attr "type" "branch")
13521 (set_attr "length" "4")])
13523 ; This is used in compiling the unwind routines.
13524 (define_expand "eh_return"
13525 [(use (match_operand 0 "general_operand" ""))]
13530 emit_insn (gen_eh_set_lr_si (operands[0]));
13532 emit_insn (gen_eh_set_lr_di (operands[0]));
13536 ; We can't expand this before we know where the link register is stored.
13537 (define_insn "eh_set_lr_<mode>"
13538 [(unspec_volatile [(match_operand:P 0 "register_operand" "r")]
13540 (clobber (match_scratch:P 1 "=&b"))]
13545 [(unspec_volatile [(match_operand 0 "register_operand" "")] UNSPECV_EH_RR)
13546 (clobber (match_scratch 1 ""))]
13551 rs6000_emit_eh_reg_restore (operands[0], operands[1]);
13555 (define_insn "prefetch"
13556 [(prefetch (match_operand 0 "indexed_or_indirect_address" "a")
13557 (match_operand:SI 1 "const_int_operand" "n")
13558 (match_operand:SI 2 "const_int_operand" "n"))]
13562 if (GET_CODE (operands[0]) == REG)
13563 return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
13564 return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
13566 [(set_attr "type" "load")])
13568 (define_insn "bpermd_<mode>"
13569 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
13570 (unspec:P [(match_operand:P 1 "gpc_reg_operand" "r")
13571 (match_operand:P 2 "gpc_reg_operand" "r")] UNSPEC_BPERM))]
13574 [(set_attr "type" "popcnt")])
13577 ;; Builtin fma support. Handle
13578 ;; Note that the conditions for expansion are in the FMA_F iterator.
13580 (define_expand "fma<mode>4"
13581 [(set (match_operand:FMA_F 0 "register_operand" "")
13583 (match_operand:FMA_F 1 "register_operand" "")
13584 (match_operand:FMA_F 2 "register_operand" "")
13585 (match_operand:FMA_F 3 "register_operand" "")))]
13589 (define_insn "*fma<mode>4_fpr"
13590 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
13592 (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>,<Fv>")
13593 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
13594 (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>")))]
13595 "TARGET_<MODE>_FPR"
13597 fmadd<Ftrad> %0,%1,%2,%3
13598 xsmadda<Fvsx> %x0,%x1,%x2
13599 xsmaddm<Fvsx> %x0,%x1,%x3"
13600 [(set_attr "type" "fp")
13601 (set_attr "fp_type" "fp_maddsub_<Fs>")])
13603 ; Altivec only has fma and nfms.
13604 (define_expand "fms<mode>4"
13605 [(set (match_operand:FMA_F 0 "register_operand" "")
13607 (match_operand:FMA_F 1 "register_operand" "")
13608 (match_operand:FMA_F 2 "register_operand" "")
13609 (neg:FMA_F (match_operand:FMA_F 3 "register_operand" ""))))]
13610 "!VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
13613 (define_insn "*fms<mode>4_fpr"
13614 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
13616 (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>,<Fv>")
13617 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
13618 (neg:SFDF (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>"))))]
13619 "TARGET_<MODE>_FPR"
13621 fmsub<Ftrad> %0,%1,%2,%3
13622 xsmsuba<Fvsx> %x0,%x1,%x2
13623 xsmsubm<Fvsx> %x0,%x1,%x3"
13624 [(set_attr "type" "fp")
13625 (set_attr "fp_type" "fp_maddsub_<Fs>")])
13627 ;; If signed zeros are ignored, -(a * b - c) = -a * b + c.
13628 (define_expand "fnma<mode>4"
13629 [(set (match_operand:FMA_F 0 "register_operand" "")
13632 (match_operand:FMA_F 1 "register_operand" "")
13633 (match_operand:FMA_F 2 "register_operand" "")
13634 (neg:FMA_F (match_operand:FMA_F 3 "register_operand" "")))))]
13635 "!HONOR_SIGNED_ZEROS (<MODE>mode)"
13638 ;; If signed zeros are ignored, -(a * b + c) = -a * b - c.
13639 (define_expand "fnms<mode>4"
13640 [(set (match_operand:FMA_F 0 "register_operand" "")
13643 (match_operand:FMA_F 1 "register_operand" "")
13644 (match_operand:FMA_F 2 "register_operand" "")
13645 (match_operand:FMA_F 3 "register_operand" ""))))]
13646 "!HONOR_SIGNED_ZEROS (<MODE>mode) && !VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
13649 ; Not an official optab name, but used from builtins.
13650 (define_expand "nfma<mode>4"
13651 [(set (match_operand:FMA_F 0 "register_operand" "")
13654 (match_operand:FMA_F 1 "register_operand" "")
13655 (match_operand:FMA_F 2 "register_operand" "")
13656 (match_operand:FMA_F 3 "register_operand" ""))))]
13657 "!VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
13660 (define_insn "*nfma<mode>4_fpr"
13661 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
13664 (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>,<Fv>")
13665 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
13666 (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>"))))]
13667 "TARGET_<MODE>_FPR"
13669 fnmadd<Ftrad> %0,%1,%2,%3
13670 xsnmadda<Fvsx> %x0,%x1,%x2
13671 xsnmaddm<Fvsx> %x0,%x1,%x3"
13672 [(set_attr "type" "fp")
13673 (set_attr "fp_type" "fp_maddsub_<Fs>")])
13675 ; Not an official optab name, but used from builtins.
13676 (define_expand "nfms<mode>4"
13677 [(set (match_operand:FMA_F 0 "register_operand" "")
13680 (match_operand:FMA_F 1 "register_operand" "")
13681 (match_operand:FMA_F 2 "register_operand" "")
13682 (neg:FMA_F (match_operand:FMA_F 3 "register_operand" "")))))]
13686 (define_insn "*nfmssf4_fpr"
13687 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
13690 (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>,<Fv>")
13691 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
13693 (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>")))))]
13694 "TARGET_<MODE>_FPR"
13696 fnmsub<Ftrad> %0,%1,%2,%3
13697 xsnmsuba<Fvsx> %x0,%x1,%x2
13698 xsnmsubm<Fvsx> %x0,%x1,%x3"
13699 [(set_attr "type" "fp")
13700 (set_attr "fp_type" "fp_maddsub_<Fs>")])
13703 (define_expand "rs6000_get_timebase"
13704 [(use (match_operand:DI 0 "gpc_reg_operand" ""))]
13707 if (TARGET_POWERPC64)
13708 emit_insn (gen_rs6000_mftb_di (operands[0]));
13710 emit_insn (gen_rs6000_get_timebase_ppc32 (operands[0]));
13714 (define_insn "rs6000_get_timebase_ppc32"
13715 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13716 (unspec_volatile:DI [(const_int 0)] UNSPECV_MFTB))
13717 (clobber (match_scratch:SI 1 "=r"))
13718 (clobber (match_scratch:CC 2 "=y"))]
13719 "!TARGET_POWERPC64"
13721 if (WORDS_BIG_ENDIAN)
13724 return "mfspr %0,269\;"
13732 return "mftbu %0\;"
13741 return "mfspr %L0,269\;"
13749 return "mftbu %L0\;"
13756 [(set_attr "length" "20")])
13758 (define_insn "rs6000_mftb_<mode>"
13759 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
13760 (unspec_volatile:GPR [(const_int 0)] UNSPECV_MFTB))]
13764 return "mfspr %0,268";
13770 (define_insn "rs6000_mffs"
13771 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
13772 (unspec_volatile:DF [(const_int 0)] UNSPECV_MFFS))]
13773 "TARGET_HARD_FLOAT && TARGET_FPRS"
13776 (define_insn "rs6000_mtfsf"
13777 [(unspec_volatile [(match_operand:SI 0 "const_int_operand" "i")
13778 (match_operand:DF 1 "gpc_reg_operand" "d")]
13780 "TARGET_HARD_FLOAT && TARGET_FPRS"
13784 ;; Power8 fusion support for fusing an addis instruction with a D-form load of
13785 ;; a GPR. The addis instruction must be adjacent to the load, and use the same
13786 ;; register that is being loaded. The fused ops must be physically adjacent.
13788 ;; Find cases where the addis that feeds into a load instruction is either used
13789 ;; once or is the same as the target register, and replace it with the fusion
13793 [(set (match_operand:P 0 "base_reg_operand" "")
13794 (match_operand:P 1 "fusion_gpr_addis" ""))
13795 (set (match_operand:INT1 2 "base_reg_operand" "")
13796 (match_operand:INT1 3 "fusion_gpr_mem_load" ""))]
13798 && fusion_gpr_load_p (operands[0], operands[1], operands[2],
13802 expand_fusion_gpr_load (operands);
13806 ;; Fusion insn, created by the define_peephole2 above (and eventually by
13809 (define_insn "fusion_gpr_load_<mode>"
13810 [(set (match_operand:INT1 0 "base_reg_operand" "=&b")
13811 (unspec:INT1 [(match_operand:INT1 1 "fusion_gpr_mem_combo" "")]
13812 UNSPEC_FUSION_GPR))]
13815 return emit_fusion_gpr_load (operands[0], operands[1]);
13817 [(set_attr "type" "load")
13818 (set_attr "length" "8")])
13821 ;; Miscellaneous ISA 2.06 (power7) instructions
13822 (define_insn "addg6s"
13823 [(set (match_operand:SI 0 "register_operand" "=r")
13824 (unspec:SI [(match_operand:SI 1 "register_operand" "r")
13825 (match_operand:SI 2 "register_operand" "r")]
13829 [(set_attr "type" "integer")
13830 (set_attr "length" "4")])
13832 (define_insn "cdtbcd"
13833 [(set (match_operand:SI 0 "register_operand" "=r")
13834 (unspec:SI [(match_operand:SI 1 "register_operand" "r")]
13838 [(set_attr "type" "integer")
13839 (set_attr "length" "4")])
13841 (define_insn "cbcdtd"
13842 [(set (match_operand:SI 0 "register_operand" "=r")
13843 (unspec:SI [(match_operand:SI 1 "register_operand" "r")]
13847 [(set_attr "type" "integer")
13848 (set_attr "length" "4")])
13850 (define_int_iterator UNSPEC_DIV_EXTEND [UNSPEC_DIVE
13855 (define_int_attr div_extend [(UNSPEC_DIVE "e")
13856 (UNSPEC_DIVEO "eo")
13857 (UNSPEC_DIVEU "eu")
13858 (UNSPEC_DIVEUO "euo")])
13860 (define_insn "div<div_extend>_<mode>"
13861 [(set (match_operand:GPR 0 "register_operand" "=r")
13862 (unspec:GPR [(match_operand:GPR 1 "register_operand" "r")
13863 (match_operand:GPR 2 "register_operand" "r")]
13864 UNSPEC_DIV_EXTEND))]
13866 "div<wd><div_extend> %0,%1,%2"
13867 [(set_attr "type" "div")
13868 (set_attr "size" "<bits>")])
13871 ;; Pack/unpack 128-bit floating point types that take 2 scalar registers
13873 ; Type of the 64-bit part when packing/unpacking 128-bit floating point types
13874 (define_mode_attr FP128_64 [(TF "DF") (TD "DI")])
13876 (define_expand "unpack<mode>"
13877 [(set (match_operand:<FP128_64> 0 "nonimmediate_operand" "")
13879 [(match_operand:FMOVE128 1 "register_operand" "")
13880 (match_operand:QI 2 "const_0_to_1_operand" "")]
13881 UNSPEC_UNPACK_128BIT))]
13885 (define_insn_and_split "unpack<mode>_dm"
13886 [(set (match_operand:<FP128_64> 0 "nonimmediate_operand" "=d,m,d,r,m")
13888 [(match_operand:FMOVE128 1 "register_operand" "d,d,r,d,r")
13889 (match_operand:QI 2 "const_0_to_1_operand" "i,i,i,i,i")]
13890 UNSPEC_UNPACK_128BIT))]
13891 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
13893 "&& reload_completed"
13894 [(set (match_dup 0) (match_dup 3))]
13896 unsigned fp_regno = REGNO (operands[1]) + UINTVAL (operands[2]);
13898 if (REG_P (operands[0]) && REGNO (operands[0]) == fp_regno)
13900 emit_note (NOTE_INSN_DELETED);
13904 operands[3] = gen_rtx_REG (<FP128_64>mode, fp_regno);
13906 [(set_attr "type" "fp,fpstore,mffgpr,mftgpr,store")
13907 (set_attr "length" "4")])
13909 (define_insn_and_split "unpack<mode>_nodm"
13910 [(set (match_operand:<FP128_64> 0 "nonimmediate_operand" "=d,m")
13912 [(match_operand:FMOVE128 1 "register_operand" "d,d")
13913 (match_operand:QI 2 "const_0_to_1_operand" "i,i")]
13914 UNSPEC_UNPACK_128BIT))]
13915 "!TARGET_POWERPC64 || !TARGET_DIRECT_MOVE"
13917 "&& reload_completed"
13918 [(set (match_dup 0) (match_dup 3))]
13920 unsigned fp_regno = REGNO (operands[1]) + UINTVAL (operands[2]);
13922 if (REG_P (operands[0]) && REGNO (operands[0]) == fp_regno)
13924 emit_note (NOTE_INSN_DELETED);
13928 operands[3] = gen_rtx_REG (<FP128_64>mode, fp_regno);
13930 [(set_attr "type" "fp,fpstore")
13931 (set_attr "length" "4")])
13933 (define_insn_and_split "pack<mode>"
13934 [(set (match_operand:FMOVE128 0 "register_operand" "=d,&d")
13936 [(match_operand:<FP128_64> 1 "register_operand" "0,d")
13937 (match_operand:<FP128_64> 2 "register_operand" "d,d")]
13938 UNSPEC_PACK_128BIT))]
13943 "&& reload_completed && REGNO (operands[0]) != REGNO (operands[1])"
13944 [(set (match_dup 3) (match_dup 1))
13945 (set (match_dup 4) (match_dup 2))]
13947 unsigned dest_hi = REGNO (operands[0]);
13948 unsigned dest_lo = dest_hi + 1;
13950 gcc_assert (!IN_RANGE (REGNO (operands[1]), dest_hi, dest_lo));
13951 gcc_assert (!IN_RANGE (REGNO (operands[2]), dest_hi, dest_lo));
13953 operands[3] = gen_rtx_REG (<FP128_64>mode, dest_hi);
13954 operands[4] = gen_rtx_REG (<FP128_64>mode, dest_lo);
13956 [(set_attr "type" "fp,fp")
13957 (set_attr "length" "4,8")])
13959 (define_insn "unpackv1ti"
13960 [(set (match_operand:DI 0 "register_operand" "=d,d")
13961 (unspec:DI [(match_operand:V1TI 1 "register_operand" "0,wa")
13962 (match_operand:QI 2 "const_0_to_1_operand" "O,i")]
13963 UNSPEC_UNPACK_128BIT))]
13966 if (REGNO (operands[0]) == REGNO (operands[1]) && INTVAL (operands[2]) == 0)
13967 return ASM_COMMENT_START " xxpermdi to same register";
13969 operands[3] = GEN_INT (INTVAL (operands[2]) == 0 ? 0 : 3);
13970 return "xxpermdi %x0,%x1,%x1,%3";
13972 [(set_attr "type" "vecperm")
13973 (set_attr "length" "4")])
13975 (define_insn "packv1ti"
13976 [(set (match_operand:V1TI 0 "register_operand" "=wa")
13978 [(match_operand:DI 1 "register_operand" "d")
13979 (match_operand:DI 2 "register_operand" "d")]
13980 UNSPEC_PACK_128BIT))]
13982 "xxpermdi %x0,%x1,%x2,0"
13983 [(set_attr "type" "vecperm")
13984 (set_attr "length" "4")])
13988 (include "sync.md")
13989 (include "vector.md")
13991 (include "altivec.md")
13994 (include "paired.md")
13995 (include "crypto.md")