1 ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
2 ;; Copyright (C) 1990-2014 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)
73 UNSPEC_MV_CR_OV ; move_from_CR_ov_bit
79 UNSPEC_LD_MPIC ; load_macho_picbase
80 UNSPEC_RELD_MPIC ; re-load_macho_picbase
81 UNSPEC_MPIC_CORRECT ; macho_correct_pic
95 UNSPEC_FIX_TRUNC_TF ; fadd, rounding towards zero
96 UNSPEC_MV_CR_GT ; move_from_CR_gt_bit
114 UNSPEC_MACHOPIC_OFFSET
126 UNSPEC_P8V_RELOAD_FROM_GPR
129 UNSPEC_P8V_RELOAD_FROM_VSX
144 ;; UNSPEC_VOLATILE usage
147 (define_c_enum "unspecv"
149 UNSPECV_LL ; load-locked
150 UNSPECV_SC ; store-conditional
151 UNSPECV_PROBE_STACK_RANGE ; probe range of stack addresses
152 UNSPECV_EH_RR ; eh_reg_restore
153 UNSPECV_ISYNC ; isync instruction
154 UNSPECV_MFTB ; move from time base
155 UNSPECV_NLGR ; non-local goto receiver
156 UNSPECV_MFFS ; Move from FPSCR
157 UNSPECV_MTFSF ; Move to FPSCR Fields
161 ;; Define an insn type attribute. This is used in function unit delay
165 add,logical,shift,insert,
167 exts,cntlz,popcnt,isel,
168 load,store,fpload,fpstore,vecload,vecstore,
170 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 (eq_attr "type" "compare")
258 (and (eq_attr "type" "shift,exts,mul")
259 (eq_attr "dot" "yes"))
260 (and (eq_attr "type" "load")
261 (eq_attr "sign_extend" "yes"))
262 (and (eq_attr "type" "shift")
263 (eq_attr "var_shift" "yes")))
264 (const_string "always")
265 (const_string "not")))
267 (automata_option "ndfa")
280 (include "e300c2c3.md")
281 (include "e500mc.md")
282 (include "e500mc64.md")
285 (include "power4.md")
286 (include "power5.md")
287 (include "power6.md")
288 (include "power7.md")
289 (include "power8.md")
295 (include "predicates.md")
296 (include "constraints.md")
298 (include "darwin.md")
303 ; This mode iterator allows :GPR to be used to indicate the allowable size
304 ; of whole values in GPRs.
305 (define_mode_iterator GPR [SI (DI "TARGET_POWERPC64")])
307 ; Any supported integer mode.
308 (define_mode_iterator INT [QI HI SI DI TI PTI])
310 ; Any supported integer mode that fits in one register.
311 (define_mode_iterator INT1 [QI HI SI (DI "TARGET_POWERPC64")])
313 ; Everything we can extend QImode to.
314 (define_mode_iterator EXTQI [HI SI (DI "TARGET_POWERPC64")])
316 ; Everything we can extend HImode to.
317 (define_mode_iterator EXTHI [SI (DI "TARGET_POWERPC64")])
319 ; Everything we can extend SImode to.
320 (define_mode_iterator EXTSI [(DI "TARGET_POWERPC64")])
322 ; QImode or HImode for small atomic ops
323 (define_mode_iterator QHI [QI HI])
325 ; HImode or SImode for sign extended fusion ops
326 (define_mode_iterator HSI [HI SI])
328 ; SImode or DImode, even if DImode doesn't fit in GPRs.
329 (define_mode_iterator SDI [SI DI])
331 ; The size of a pointer. Also, the size of the value that a record-condition
332 ; (one with a '.') will compare; and the size used for arithmetic carries.
333 (define_mode_iterator P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
335 ; Iterator to add PTImode along with TImode (TImode can go in VSX registers,
336 ; PTImode is GPR only)
337 (define_mode_iterator TI2 [TI PTI])
339 ; Any hardware-supported floating-point mode
340 (define_mode_iterator FP [
341 (SF "TARGET_HARD_FLOAT
342 && ((TARGET_FPRS && TARGET_SINGLE_FLOAT) || TARGET_E500_SINGLE)")
343 (DF "TARGET_HARD_FLOAT
344 && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)")
345 (TF "!TARGET_IEEEQUAD
347 && (TARGET_FPRS || TARGET_E500_DOUBLE)
348 && TARGET_LONG_DOUBLE_128")
352 ; Any fma capable floating-point mode.
353 (define_mode_iterator FMA_F [
354 (SF "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT")
355 (DF "(TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
356 || VECTOR_UNIT_VSX_P (DFmode)")
357 (V2SF "TARGET_PAIRED_FLOAT")
358 (V4SF "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)")
359 (V2DF "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V2DFmode)")
362 ; Floating point move iterators to combine binary and decimal moves
363 (define_mode_iterator FMOVE32 [SF SD])
364 (define_mode_iterator FMOVE64 [DF DD])
365 (define_mode_iterator FMOVE64X [DI DF DD])
366 (define_mode_iterator FMOVE128 [(TF "!TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128")
367 (TD "TARGET_HARD_FLOAT && TARGET_FPRS")])
369 ; Iterators for 128 bit types for direct move
370 (define_mode_iterator FMOVE128_GPR [(TI "TARGET_VSX_TIMODE")
379 ; Whether a floating point move is ok, don't allow SD without hardware FP
380 (define_mode_attr fmove_ok [(SF "")
382 (SD "TARGET_HARD_FLOAT && TARGET_FPRS")
385 ; Convert REAL_VALUE to the appropriate bits
386 (define_mode_attr real_value_to_target [(SF "REAL_VALUE_TO_TARGET_SINGLE")
387 (DF "REAL_VALUE_TO_TARGET_DOUBLE")
388 (SD "REAL_VALUE_TO_TARGET_DECIMAL32")
389 (DD "REAL_VALUE_TO_TARGET_DECIMAL64")])
391 ; Definitions for load to 32-bit fpr register
392 (define_mode_attr f32_lr [(SF "f") (SD "wz")])
393 (define_mode_attr f32_lm [(SF "m") (SD "Z")])
394 (define_mode_attr f32_li [(SF "lfs%U1%X1 %0,%1") (SD "lfiwzx %0,%y1")])
395 (define_mode_attr f32_lv [(SF "lxsspx %x0,%y1") (SD "lxsiwzx %x0,%y1")])
397 ; Definitions for store from 32-bit fpr register
398 (define_mode_attr f32_sr [(SF "f") (SD "wx")])
399 (define_mode_attr f32_sm [(SF "m") (SD "Z")])
400 (define_mode_attr f32_si [(SF "stfs%U0%X0 %1,%0") (SD "stfiwx %1,%y0")])
401 (define_mode_attr f32_sv [(SF "stxsspx %x1,%y0") (SD "stxsiwzx %x1,%y0")])
403 ; Definitions for 32-bit fpr direct move
404 (define_mode_attr f32_dm [(SF "wn") (SD "wh")])
406 ; These modes do not fit in integer registers in 32-bit mode.
407 ; but on e500v2, the gpr are 64 bit registers
408 (define_mode_iterator DIFD [DI (DF "!TARGET_E500_DOUBLE") DD])
410 ; Iterator for reciprocal estimate instructions
411 (define_mode_iterator RECIPF [SF DF V4SF V2DF])
413 ; Iterator for just SF/DF
414 (define_mode_iterator SFDF [SF DF])
416 ; SF/DF suffix for traditional floating instructions
417 (define_mode_attr Ftrad [(SF "s") (DF "")])
419 ; SF/DF suffix for VSX instructions
420 (define_mode_attr Fvsx [(SF "sp") (DF "dp")])
422 ; SF/DF constraint for arithmetic on traditional floating point registers
423 (define_mode_attr Ff [(SF "f") (DF "d")])
425 ; SF/DF constraint for arithmetic on VSX registers
426 (define_mode_attr Fv [(SF "wy") (DF "ws")])
428 ; s/d suffix for things like fp_addsub_s/fp_addsub_d
429 (define_mode_attr Fs [(SF "s") (DF "d")])
432 (define_mode_attr Ffre [(SF "fres") (DF "fre")])
433 (define_mode_attr FFRE [(SF "FRES") (DF "FRE")])
435 ; Conditional returns.
436 (define_code_iterator any_return [return simple_return])
437 (define_code_attr return_pred [(return "direct_return ()")
438 (simple_return "1")])
439 (define_code_attr return_str [(return "") (simple_return "simple_")])
442 (define_code_iterator iorxor [ior xor])
443 (define_code_attr iorxor [(ior "ior") (xor "xor")])
444 (define_code_attr IORXOR [(ior "IOR") (xor "XOR")])
446 ; Signed/unsigned variants of ops.
447 (define_code_iterator any_extend [sign_extend zero_extend])
448 (define_code_attr u [(sign_extend "") (zero_extend "u")])
449 (define_code_attr su [(sign_extend "s") (zero_extend "u")])
451 ; Various instructions that come in SI and DI forms.
452 ; A generic w/d attribute, for things like cmpw/cmpd.
453 (define_mode_attr wd [(QI "b")
462 ;; How many bits in this mode?
463 (define_mode_attr bits [(QI "8") (HI "16") (SI "32") (DI "64")])
466 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
468 ;; ISEL/ISEL64 target selection
469 (define_mode_attr sel [(SI "") (DI "64")])
471 ;; Bitmask for shift instructions
472 (define_mode_attr hH [(SI "h") (DI "H")])
474 ;; A mode twice the size of the given mode
475 (define_mode_attr dmode [(SI "di") (DI "ti")])
476 (define_mode_attr DMODE [(SI "DI") (DI "TI")])
478 ;; Suffix for reload patterns
479 (define_mode_attr ptrsize [(SI "32bit")
482 (define_mode_attr tptrsize [(SI "TARGET_32BIT")
483 (DI "TARGET_64BIT")])
485 (define_mode_attr mptrsize [(SI "si")
488 (define_mode_attr ptrload [(SI "lwz")
491 (define_mode_attr ptrm [(SI "m")
494 (define_mode_attr rreg [(SF "f")
501 (define_mode_attr rreg2 [(SF "f")
504 (define_mode_attr SI_CONVERT_FP [(SF "TARGET_FCFIDS")
505 (DF "TARGET_FCFID")])
507 (define_mode_attr E500_CONVERT [(SF "!TARGET_FPRS")
508 (DF "TARGET_E500_DOUBLE")])
510 (define_mode_attr TARGET_FLOAT [(SF "TARGET_SINGLE_FLOAT")
511 (DF "TARGET_DOUBLE_FLOAT")])
513 ;; Mode iterator for logical operations on 128-bit types
514 (define_mode_iterator BOOL_128 [TI
516 (V16QI "TARGET_ALTIVEC")
517 (V8HI "TARGET_ALTIVEC")
518 (V4SI "TARGET_ALTIVEC")
519 (V4SF "TARGET_ALTIVEC")
520 (V2DI "TARGET_ALTIVEC")
521 (V2DF "TARGET_ALTIVEC")
522 (V1TI "TARGET_ALTIVEC")])
524 ;; For the GPRs we use 3 constraints for register outputs, two that are the
525 ;; same as the output register, and a third where the output register is an
526 ;; early clobber, so we don't have to deal with register overlaps. For the
527 ;; vector types, we prefer to use the vector registers. For TI mode, allow
530 ;; Mode attribute for boolean operation register constraints for output
531 (define_mode_attr BOOL_REGS_OUTPUT [(TI "&r,r,r,wa,v")
533 (V16QI "wa,v,&?r,?r,?r")
534 (V8HI "wa,v,&?r,?r,?r")
535 (V4SI "wa,v,&?r,?r,?r")
536 (V4SF "wa,v,&?r,?r,?r")
537 (V2DI "wa,v,&?r,?r,?r")
538 (V2DF "wa,v,&?r,?r,?r")
539 (V1TI "wa,v,&?r,?r,?r")])
541 ;; Mode attribute for boolean operation register constraints for operand1
542 (define_mode_attr BOOL_REGS_OP1 [(TI "r,0,r,wa,v")
550 (V1TI "wa,v,r,0,r")])
552 ;; Mode attribute for boolean operation register constraints for operand2
553 (define_mode_attr BOOL_REGS_OP2 [(TI "r,r,0,wa,v")
561 (V1TI "wa,v,r,r,0")])
563 ;; Mode attribute for boolean operation register constraints for operand1
564 ;; for one_cmpl. To simplify things, we repeat the constraint where 0
565 ;; is used for operand1 or operand2
566 (define_mode_attr BOOL_REGS_UNARY [(TI "r,0,0,wa,v")
574 (V1TI "wa,v,r,0,0")])
576 ;; Start with fixed-point load and store insns. Here we put only the more
577 ;; complex forms. Basic data transfer is done later.
579 (define_insn "zero_extendqi<mode>2"
580 [(set (match_operand:EXTQI 0 "gpc_reg_operand" "=r,r")
581 (zero_extend:EXTQI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
586 [(set_attr "type" "load,shift")])
588 (define_insn_and_split "*zero_extendqi<mode>2_dot"
589 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
590 (compare:CC (zero_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
592 (clobber (match_scratch:EXTQI 0 "=r,r"))]
593 "rs6000_gen_cell_microcode"
597 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
599 (zero_extend:EXTQI (match_dup 1)))
601 (compare:CC (match_dup 0)
604 [(set_attr "type" "logical")
605 (set_attr "dot" "yes")
606 (set_attr "length" "4,8")])
608 (define_insn_and_split "*zero_extendqi<mode>2_dot2"
609 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
610 (compare:CC (zero_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
612 (set (match_operand:EXTQI 0 "gpc_reg_operand" "=r,r")
613 (zero_extend:EXTQI (match_dup 1)))]
614 "rs6000_gen_cell_microcode"
618 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
620 (zero_extend:EXTQI (match_dup 1)))
622 (compare:CC (match_dup 0)
625 [(set_attr "type" "logical")
626 (set_attr "dot" "yes")
627 (set_attr "length" "4,8")])
630 (define_insn "zero_extendhi<mode>2"
631 [(set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r")
632 (zero_extend:EXTHI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
636 rlwinm %0,%1,0,0xffff"
637 [(set_attr "type" "load,shift")])
639 (define_insn_and_split "*zero_extendhi<mode>2_dot"
640 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
641 (compare:CC (zero_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
643 (clobber (match_scratch:EXTHI 0 "=r,r"))]
644 "rs6000_gen_cell_microcode"
648 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
650 (zero_extend:EXTHI (match_dup 1)))
652 (compare:CC (match_dup 0)
655 [(set_attr "type" "logical")
656 (set_attr "dot" "yes")
657 (set_attr "length" "4,8")])
659 (define_insn_and_split "*zero_extendhi<mode>2_dot2"
660 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
661 (compare:CC (zero_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
663 (set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r")
664 (zero_extend:EXTHI (match_dup 1)))]
665 "rs6000_gen_cell_microcode"
669 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
671 (zero_extend:EXTHI (match_dup 1)))
673 (compare:CC (match_dup 0)
676 [(set_attr "type" "logical")
677 (set_attr "dot" "yes")
678 (set_attr "length" "4,8")])
681 (define_insn "zero_extendsi<mode>2"
682 [(set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r,??wj,!wz,!wu")
683 (zero_extend:EXTSI (match_operand:SI 1 "reg_or_mem_operand" "m,r,r,Z,Z")))]
691 [(set_attr "type" "load,shift,mffgpr,fpload,fpload")])
693 (define_insn_and_split "*zero_extendsi<mode>2_dot"
694 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
695 (compare:CC (zero_extend:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
697 (clobber (match_scratch:EXTSI 0 "=r,r"))]
698 "rs6000_gen_cell_microcode"
702 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
704 (zero_extend:DI (match_dup 1)))
706 (compare:CC (match_dup 0)
709 [(set_attr "type" "shift")
710 (set_attr "dot" "yes")
711 (set_attr "length" "4,8")])
713 (define_insn_and_split "*zero_extendsi<mode>2_dot2"
714 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
715 (compare:CC (zero_extend:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
717 (set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r")
718 (zero_extend:EXTSI (match_dup 1)))]
719 "rs6000_gen_cell_microcode"
723 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
725 (zero_extend:EXTSI (match_dup 1)))
727 (compare:CC (match_dup 0)
730 [(set_attr "type" "shift")
731 (set_attr "dot" "yes")
732 (set_attr "length" "4,8")])
735 (define_insn "extendqi<mode>2"
736 [(set (match_operand:EXTQI 0 "gpc_reg_operand" "=r")
737 (sign_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r")))]
740 [(set_attr "type" "exts")])
742 (define_insn_and_split "*extendqi<mode>2_dot"
743 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
744 (compare:CC (sign_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
746 (clobber (match_scratch:EXTQI 0 "=r,r"))]
747 "rs6000_gen_cell_microcode"
751 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
753 (sign_extend:EXTQI (match_dup 1)))
755 (compare:CC (match_dup 0)
758 [(set_attr "type" "exts")
759 (set_attr "dot" "yes")
760 (set_attr "length" "4,8")])
762 (define_insn_and_split "*extendqi<mode>2_dot2"
763 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
764 (compare:CC (sign_extend:EXTQI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
766 (set (match_operand:EXTQI 0 "gpc_reg_operand" "=r,r")
767 (sign_extend:EXTQI (match_dup 1)))]
768 "rs6000_gen_cell_microcode"
772 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
774 (sign_extend:EXTQI (match_dup 1)))
776 (compare:CC (match_dup 0)
779 [(set_attr "type" "exts")
780 (set_attr "dot" "yes")
781 (set_attr "length" "4,8")])
784 (define_expand "extendhi<mode>2"
785 [(set (match_operand:EXTHI 0 "gpc_reg_operand" "")
786 (sign_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "")))]
790 (define_insn "*extendhi<mode>2"
791 [(set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r")
792 (sign_extend:EXTHI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
793 "rs6000_gen_cell_microcode"
797 [(set_attr "type" "load,exts")
798 (set_attr "sign_extend" "yes")])
800 (define_insn "*extendhi<mode>2_noload"
801 [(set (match_operand:EXTHI 0 "gpc_reg_operand" "=r")
802 (sign_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r")))]
803 "!rs6000_gen_cell_microcode"
805 [(set_attr "type" "exts")])
807 (define_insn_and_split "*extendhi<mode>2_dot"
808 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
809 (compare:CC (sign_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
811 (clobber (match_scratch:EXTHI 0 "=r,r"))]
812 "rs6000_gen_cell_microcode"
816 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
818 (sign_extend:EXTHI (match_dup 1)))
820 (compare:CC (match_dup 0)
823 [(set_attr "type" "exts")
824 (set_attr "dot" "yes")
825 (set_attr "length" "4,8")])
827 (define_insn_and_split "*extendhi<mode>2_dot2"
828 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
829 (compare:CC (sign_extend:EXTHI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
831 (set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r")
832 (sign_extend:EXTHI (match_dup 1)))]
833 "rs6000_gen_cell_microcode"
837 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
839 (sign_extend:EXTHI (match_dup 1)))
841 (compare:CC (match_dup 0)
844 [(set_attr "type" "exts")
845 (set_attr "dot" "yes")
846 (set_attr "length" "4,8")])
849 (define_insn "extendsi<mode>2"
850 [(set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r,??wj,!wl,!wu")
851 (sign_extend:EXTSI (match_operand:SI 1 "lwa_operand" "Y,r,r,Z,Z")))]
859 [(set_attr "type" "load,exts,mffgpr,fpload,fpload")
860 (set_attr "sign_extend" "yes")])
862 (define_insn_and_split "*extendsi<mode>2_dot"
863 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
864 (compare:CC (sign_extend:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
866 (clobber (match_scratch:EXTSI 0 "=r,r"))]
867 "rs6000_gen_cell_microcode"
871 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
873 (sign_extend:EXTSI (match_dup 1)))
875 (compare:CC (match_dup 0)
878 [(set_attr "type" "exts")
879 (set_attr "dot" "yes")
880 (set_attr "length" "4,8")])
882 (define_insn_and_split "*extendsi<mode>2_dot2"
883 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
884 (compare:CC (sign_extend:EXTSI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
886 (set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r")
887 (sign_extend:EXTSI (match_dup 1)))]
888 "rs6000_gen_cell_microcode"
892 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
894 (sign_extend:EXTSI (match_dup 1)))
896 (compare:CC (match_dup 0)
899 [(set_attr "type" "exts")
900 (set_attr "dot" "yes")
901 (set_attr "length" "4,8")])
903 ;; IBM 405, 440, 464 and 476 half-word multiplication operations.
905 (define_insn "*macchwc"
906 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
907 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
908 (match_operand:SI 2 "gpc_reg_operand" "r")
911 (match_operand:HI 1 "gpc_reg_operand" "r")))
912 (match_operand:SI 4 "gpc_reg_operand" "0"))
914 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
915 (plus:SI (mult:SI (ashiftrt:SI
923 [(set_attr "type" "halfmul")])
925 (define_insn "*macchw"
926 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
927 (plus:SI (mult:SI (ashiftrt:SI
928 (match_operand:SI 2 "gpc_reg_operand" "r")
931 (match_operand:HI 1 "gpc_reg_operand" "r")))
932 (match_operand:SI 3 "gpc_reg_operand" "0")))]
935 [(set_attr "type" "halfmul")])
937 (define_insn "*macchwuc"
938 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
939 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
940 (match_operand:SI 2 "gpc_reg_operand" "r")
943 (match_operand:HI 1 "gpc_reg_operand" "r")))
944 (match_operand:SI 4 "gpc_reg_operand" "0"))
946 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
947 (plus:SI (mult:SI (lshiftrt:SI
955 [(set_attr "type" "halfmul")])
957 (define_insn "*macchwu"
958 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
959 (plus:SI (mult:SI (lshiftrt:SI
960 (match_operand:SI 2 "gpc_reg_operand" "r")
963 (match_operand:HI 1 "gpc_reg_operand" "r")))
964 (match_operand:SI 3 "gpc_reg_operand" "0")))]
967 [(set_attr "type" "halfmul")])
969 (define_insn "*machhwc"
970 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
971 (compare:CC (plus:SI (mult:SI (ashiftrt:SI
972 (match_operand:SI 1 "gpc_reg_operand" "%r")
975 (match_operand:SI 2 "gpc_reg_operand" "r")
977 (match_operand:SI 4 "gpc_reg_operand" "0"))
979 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
980 (plus:SI (mult:SI (ashiftrt:SI
989 [(set_attr "type" "halfmul")])
991 (define_insn "*machhw"
992 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
993 (plus:SI (mult:SI (ashiftrt:SI
994 (match_operand:SI 1 "gpc_reg_operand" "%r")
997 (match_operand:SI 2 "gpc_reg_operand" "r")
999 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1002 [(set_attr "type" "halfmul")])
1004 (define_insn "*machhwuc"
1005 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1006 (compare:CC (plus:SI (mult:SI (lshiftrt:SI
1007 (match_operand:SI 1 "gpc_reg_operand" "%r")
1010 (match_operand:SI 2 "gpc_reg_operand" "r")
1012 (match_operand:SI 4 "gpc_reg_operand" "0"))
1014 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1015 (plus:SI (mult:SI (lshiftrt:SI
1024 [(set_attr "type" "halfmul")])
1026 (define_insn "*machhwu"
1027 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1028 (plus:SI (mult:SI (lshiftrt:SI
1029 (match_operand:SI 1 "gpc_reg_operand" "%r")
1032 (match_operand:SI 2 "gpc_reg_operand" "r")
1034 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1037 [(set_attr "type" "halfmul")])
1039 (define_insn "*maclhwc"
1040 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1041 (compare:CC (plus:SI (mult:SI (sign_extend:SI
1042 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1044 (match_operand:HI 2 "gpc_reg_operand" "r")))
1045 (match_operand:SI 4 "gpc_reg_operand" "0"))
1047 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1048 (plus:SI (mult:SI (sign_extend:SI
1055 [(set_attr "type" "halfmul")])
1057 (define_insn "*maclhw"
1058 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1059 (plus:SI (mult:SI (sign_extend:SI
1060 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1062 (match_operand:HI 2 "gpc_reg_operand" "r")))
1063 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1066 [(set_attr "type" "halfmul")])
1068 (define_insn "*maclhwuc"
1069 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1070 (compare:CC (plus:SI (mult:SI (zero_extend:SI
1071 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1073 (match_operand:HI 2 "gpc_reg_operand" "r")))
1074 (match_operand:SI 4 "gpc_reg_operand" "0"))
1076 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1077 (plus:SI (mult:SI (zero_extend:SI
1084 [(set_attr "type" "halfmul")])
1086 (define_insn "*maclhwu"
1087 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1088 (plus:SI (mult:SI (zero_extend:SI
1089 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1091 (match_operand:HI 2 "gpc_reg_operand" "r")))
1092 (match_operand:SI 3 "gpc_reg_operand" "0")))]
1095 [(set_attr "type" "halfmul")])
1097 (define_insn "*nmacchwc"
1098 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1099 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1100 (mult:SI (ashiftrt:SI
1101 (match_operand:SI 2 "gpc_reg_operand" "r")
1104 (match_operand:HI 1 "gpc_reg_operand" "r"))))
1106 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1107 (minus:SI (match_dup 4)
1108 (mult:SI (ashiftrt:SI
1115 [(set_attr "type" "halfmul")])
1117 (define_insn "*nmacchw"
1118 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1119 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1120 (mult:SI (ashiftrt:SI
1121 (match_operand:SI 2 "gpc_reg_operand" "r")
1124 (match_operand:HI 1 "gpc_reg_operand" "r")))))]
1127 [(set_attr "type" "halfmul")])
1129 (define_insn "*nmachhwc"
1130 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1131 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1132 (mult:SI (ashiftrt:SI
1133 (match_operand:SI 1 "gpc_reg_operand" "%r")
1136 (match_operand:SI 2 "gpc_reg_operand" "r")
1139 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1140 (minus:SI (match_dup 4)
1141 (mult:SI (ashiftrt:SI
1149 [(set_attr "type" "halfmul")])
1151 (define_insn "*nmachhw"
1152 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1153 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1154 (mult:SI (ashiftrt:SI
1155 (match_operand:SI 1 "gpc_reg_operand" "%r")
1158 (match_operand:SI 2 "gpc_reg_operand" "r")
1162 [(set_attr "type" "halfmul")])
1164 (define_insn "*nmaclhwc"
1165 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1166 (compare:CC (minus:SI (match_operand:SI 4 "gpc_reg_operand" "0")
1167 (mult:SI (sign_extend:SI
1168 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1170 (match_operand:HI 2 "gpc_reg_operand" "r"))))
1172 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1173 (minus:SI (match_dup 4)
1174 (mult:SI (sign_extend:SI
1180 [(set_attr "type" "halfmul")])
1182 (define_insn "*nmaclhw"
1183 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1184 (minus:SI (match_operand:SI 3 "gpc_reg_operand" "0")
1185 (mult:SI (sign_extend:SI
1186 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1188 (match_operand:HI 2 "gpc_reg_operand" "r")))))]
1191 [(set_attr "type" "halfmul")])
1193 (define_insn "*mulchwc"
1194 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1195 (compare:CC (mult:SI (ashiftrt:SI
1196 (match_operand:SI 2 "gpc_reg_operand" "r")
1199 (match_operand:HI 1 "gpc_reg_operand" "r")))
1201 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1202 (mult:SI (ashiftrt:SI
1209 [(set_attr "type" "halfmul")])
1211 (define_insn "*mulchw"
1212 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1213 (mult:SI (ashiftrt:SI
1214 (match_operand:SI 2 "gpc_reg_operand" "r")
1217 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1220 [(set_attr "type" "halfmul")])
1222 (define_insn "*mulchwuc"
1223 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1224 (compare:CC (mult:SI (lshiftrt:SI
1225 (match_operand:SI 2 "gpc_reg_operand" "r")
1228 (match_operand:HI 1 "gpc_reg_operand" "r")))
1230 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1231 (mult:SI (lshiftrt:SI
1238 [(set_attr "type" "halfmul")])
1240 (define_insn "*mulchwu"
1241 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1242 (mult:SI (lshiftrt:SI
1243 (match_operand:SI 2 "gpc_reg_operand" "r")
1246 (match_operand:HI 1 "gpc_reg_operand" "r"))))]
1249 [(set_attr "type" "halfmul")])
1251 (define_insn "*mulhhwc"
1252 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1253 (compare:CC (mult:SI (ashiftrt:SI
1254 (match_operand:SI 1 "gpc_reg_operand" "%r")
1257 (match_operand:SI 2 "gpc_reg_operand" "r")
1260 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1261 (mult:SI (ashiftrt:SI
1269 [(set_attr "type" "halfmul")])
1271 (define_insn "*mulhhw"
1272 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1273 (mult:SI (ashiftrt:SI
1274 (match_operand:SI 1 "gpc_reg_operand" "%r")
1277 (match_operand:SI 2 "gpc_reg_operand" "r")
1281 [(set_attr "type" "halfmul")])
1283 (define_insn "*mulhhwuc"
1284 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1285 (compare:CC (mult:SI (lshiftrt:SI
1286 (match_operand:SI 1 "gpc_reg_operand" "%r")
1289 (match_operand:SI 2 "gpc_reg_operand" "r")
1292 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1293 (mult:SI (lshiftrt:SI
1301 [(set_attr "type" "halfmul")])
1303 (define_insn "*mulhhwu"
1304 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1305 (mult:SI (lshiftrt:SI
1306 (match_operand:SI 1 "gpc_reg_operand" "%r")
1309 (match_operand:SI 2 "gpc_reg_operand" "r")
1313 [(set_attr "type" "halfmul")])
1315 (define_insn "*mullhwc"
1316 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1317 (compare:CC (mult:SI (sign_extend:SI
1318 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1320 (match_operand:HI 2 "gpc_reg_operand" "r")))
1322 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1323 (mult:SI (sign_extend:SI
1329 [(set_attr "type" "halfmul")])
1331 (define_insn "*mullhw"
1332 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1333 (mult:SI (sign_extend:SI
1334 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1336 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1339 [(set_attr "type" "halfmul")])
1341 (define_insn "*mullhwuc"
1342 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1343 (compare:CC (mult:SI (zero_extend:SI
1344 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1346 (match_operand:HI 2 "gpc_reg_operand" "r")))
1348 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1349 (mult:SI (zero_extend:SI
1355 [(set_attr "type" "halfmul")])
1357 (define_insn "*mullhwu"
1358 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1359 (mult:SI (zero_extend:SI
1360 (match_operand:HI 1 "gpc_reg_operand" "%r"))
1362 (match_operand:HI 2 "gpc_reg_operand" "r"))))]
1365 [(set_attr "type" "halfmul")])
1367 ;; IBM 405, 440, 464 and 476 string-search dlmzb instruction support.
1368 (define_insn "dlmzb"
1369 [(set (match_operand:CC 3 "cc_reg_operand" "=x")
1370 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
1371 (match_operand:SI 2 "gpc_reg_operand" "r")]
1373 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1374 (unspec:SI [(match_dup 1)
1380 (define_expand "strlensi"
1381 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1382 (unspec:SI [(match_operand:BLK 1 "general_operand" "")
1383 (match_operand:QI 2 "const_int_operand" "")
1384 (match_operand 3 "const_int_operand" "")]
1385 UNSPEC_DLMZB_STRLEN))
1386 (clobber (match_scratch:CC 4 "=x"))]
1387 "TARGET_DLMZB && WORDS_BIG_ENDIAN && !optimize_size"
1389 rtx result = operands[0];
1390 rtx src = operands[1];
1391 rtx search_char = operands[2];
1392 rtx align = operands[3];
1393 rtx addr, scratch_string, word1, word2, scratch_dlmzb;
1394 rtx loop_label, end_label, mem, cr0, cond;
1395 if (search_char != const0_rtx
1396 || GET_CODE (align) != CONST_INT
1397 || INTVAL (align) < 8)
1399 word1 = gen_reg_rtx (SImode);
1400 word2 = gen_reg_rtx (SImode);
1401 scratch_dlmzb = gen_reg_rtx (SImode);
1402 scratch_string = gen_reg_rtx (Pmode);
1403 loop_label = gen_label_rtx ();
1404 end_label = gen_label_rtx ();
1405 addr = force_reg (Pmode, XEXP (src, 0));
1406 emit_move_insn (scratch_string, addr);
1407 emit_label (loop_label);
1408 mem = change_address (src, SImode, scratch_string);
1409 emit_move_insn (word1, mem);
1410 emit_move_insn (word2, adjust_address (mem, SImode, 4));
1411 cr0 = gen_rtx_REG (CCmode, CR0_REGNO);
1412 emit_insn (gen_dlmzb (scratch_dlmzb, word1, word2, cr0));
1413 cond = gen_rtx_NE (VOIDmode, cr0, const0_rtx);
1414 emit_jump_insn (gen_rtx_SET (VOIDmode,
1416 gen_rtx_IF_THEN_ELSE (VOIDmode,
1422 emit_insn (gen_addsi3 (scratch_string, scratch_string, GEN_INT (8)));
1423 emit_jump_insn (gen_rtx_SET (VOIDmode,
1425 gen_rtx_LABEL_REF (VOIDmode, loop_label)));
1427 emit_label (end_label);
1428 emit_insn (gen_addsi3 (scratch_string, scratch_string, scratch_dlmzb));
1429 emit_insn (gen_subsi3 (result, scratch_string, addr));
1430 emit_insn (gen_addsi3 (result, result, constm1_rtx));
1434 ;; Fixed-point arithmetic insns.
1436 (define_expand "add<mode>3"
1437 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1438 (plus:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
1439 (match_operand:SDI 2 "reg_or_add_cint_operand" "")))]
1442 if (<MODE>mode == DImode && ! TARGET_POWERPC64)
1444 if (non_short_cint_operand (operands[2], DImode))
1447 else if (GET_CODE (operands[2]) == CONST_INT
1448 && ! add_operand (operands[2], <MODE>mode))
1450 rtx tmp = ((!can_create_pseudo_p ()
1451 || rtx_equal_p (operands[0], operands[1]))
1452 ? operands[0] : gen_reg_rtx (<MODE>mode));
1454 HOST_WIDE_INT val = INTVAL (operands[2]);
1455 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1456 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1458 if (<MODE>mode == DImode && !satisfies_constraint_L (GEN_INT (rest)))
1461 /* The ordering here is important for the prolog expander.
1462 When space is allocated from the stack, adding 'low' first may
1463 produce a temporary deallocation (which would be bad). */
1464 emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (rest)));
1465 emit_insn (gen_add<mode>3 (operands[0], tmp, GEN_INT (low)));
1470 ;; Discourage ai/addic because of carry but provide it in an alternative
1471 ;; allowing register zero as source.
1472 (define_insn "*add<mode>3_internal1"
1473 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,?r,r")
1474 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,b,r,b")
1475 (match_operand:GPR 2 "add_operand" "r,I,I,L")))]
1476 "!DECIMAL_FLOAT_MODE_P (GET_MODE (operands[0])) && !DECIMAL_FLOAT_MODE_P (GET_MODE (operands[1]))"
1482 [(set_attr "type" "add")])
1484 (define_insn "addsi3_high"
1485 [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1486 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1487 (high:SI (match_operand 2 "" ""))))]
1488 "TARGET_MACHO && !TARGET_64BIT"
1489 "addis %0,%1,ha16(%2)"
1490 [(set_attr "type" "add")])
1492 (define_insn "*add<mode>3_internal2"
1493 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1494 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1495 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1497 (clobber (match_scratch:P 3 "=r,r,r,r"))]
1504 [(set_attr "type" "add,compare,compare,compare")
1505 (set_attr "dot" "yes")
1506 (set_attr "length" "4,4,8,8")])
1509 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1510 (compare:CC (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1511 (match_operand:GPR 2 "reg_or_short_operand" ""))
1513 (clobber (match_scratch:GPR 3 ""))]
1516 (plus:GPR (match_dup 1)
1519 (compare:CC (match_dup 3)
1523 (define_insn "*add<mode>3_internal3"
1524 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1525 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "%r,r,r,r")
1526 (match_operand:P 2 "reg_or_short_operand" "r,I,r,I"))
1528 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
1529 (plus:P (match_dup 1)
1537 [(set_attr "type" "add,compare,compare,compare")
1538 (set_attr "dot" "yes")
1539 (set_attr "length" "4,4,8,8")])
1542 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1543 (compare:CC (plus:P (match_operand:P 1 "gpc_reg_operand" "")
1544 (match_operand:P 2 "reg_or_short_operand" ""))
1546 (set (match_operand:P 0 "gpc_reg_operand" "")
1547 (plus:P (match_dup 1) (match_dup 2)))]
1550 (plus:P (match_dup 1)
1553 (compare:CC (match_dup 0)
1557 ;; Split an add that we can't do in one insn into two insns, each of which
1558 ;; does one 16-bit part. This is used by combine. Note that the low-order
1559 ;; add should be last in case the result gets used in an address.
1562 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1563 (plus:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
1564 (match_operand:GPR 2 "non_add_cint_operand" "")))]
1566 [(set (match_dup 0) (plus:GPR (match_dup 1) (match_dup 3)))
1567 (set (match_dup 0) (plus:GPR (match_dup 0) (match_dup 4)))]
1569 HOST_WIDE_INT val = INTVAL (operands[2]);
1570 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1571 HOST_WIDE_INT rest = trunc_int_for_mode (val - low, <MODE>mode);
1573 operands[4] = GEN_INT (low);
1574 if (<MODE>mode == SImode || satisfies_constraint_L (GEN_INT (rest)))
1575 operands[3] = GEN_INT (rest);
1576 else if (can_create_pseudo_p ())
1578 operands[3] = gen_reg_rtx (DImode);
1579 emit_move_insn (operands[3], operands[2]);
1580 emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
1587 (define_expand "one_cmpl<mode>2"
1588 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1589 (not:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
1592 if (<MODE>mode == DImode && !TARGET_POWERPC64)
1594 rs6000_split_logical (operands, NOT, false, false, false);
1599 (define_insn "*one_cmpl<mode>2"
1600 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1601 (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1605 (define_insn_and_split "*one_cmpl<mode>2_dot"
1606 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1607 (compare:CC (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1609 (clobber (match_scratch:GPR 0 "=r,r"))]
1610 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
1614 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
1616 (not:GPR (match_dup 1)))
1618 (compare:CC (match_dup 0)
1621 [(set_attr "type" "logical")
1622 (set_attr "dot" "yes")
1623 (set_attr "length" "4,8")])
1625 (define_insn_and_split "*one_cmpl<mode>2_dot2"
1626 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1627 (compare:CC (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1629 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1630 (not:GPR (match_dup 1)))]
1631 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
1635 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
1637 (not:GPR (match_dup 1)))
1639 (compare:CC (match_dup 0)
1642 [(set_attr "type" "logical")
1643 (set_attr "dot" "yes")
1644 (set_attr "length" "4,8")])
1647 (define_expand "sub<mode>3"
1648 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1649 (minus:SDI (match_operand:SDI 1 "reg_or_short_operand" "")
1650 (match_operand:SDI 2 "gpc_reg_operand" "")))]
1653 if (short_cint_operand (operands[1], <MODE>mode)
1654 && !(<MODE>mode == DImode && !TARGET_POWERPC64))
1656 emit_insn (gen_subf<mode>3_imm (operands[0], operands[2], operands[1]));
1661 (define_insn "*subf<mode>3"
1662 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1663 (minus:GPR (match_operand:GPR 2 "gpc_reg_operand" "r")
1664 (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1667 [(set_attr "type" "add")])
1669 (define_insn_and_split "*subf<mode>3_dot"
1670 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1671 (compare:CC (minus:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r")
1672 (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1674 (clobber (match_scratch:GPR 0 "=r,r"))]
1675 "<MODE>mode == Pmode"
1679 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
1681 (minus:GPR (match_dup 2)
1684 (compare:CC (match_dup 0)
1687 [(set_attr "type" "add")
1688 (set_attr "dot" "yes")
1689 (set_attr "length" "4,8")])
1691 (define_insn_and_split "*subf<mode>3_dot2"
1692 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1693 (compare:CC (minus:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r")
1694 (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1696 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1697 (minus:GPR (match_dup 2)
1699 "<MODE>mode == Pmode"
1703 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
1705 (minus:GPR (match_dup 2)
1708 (compare:CC (match_dup 0)
1711 [(set_attr "type" "add")
1712 (set_attr "dot" "yes")
1713 (set_attr "length" "4,8")])
1715 (define_insn "subf<mode>3_imm"
1716 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1717 (minus:GPR (match_operand:GPR 2 "short_cint_operand" "I")
1718 (match_operand:GPR 1 "gpc_reg_operand" "r")))
1719 (clobber (reg:GPR CA_REGNO))]
1722 [(set_attr "type" "add")])
1725 (define_expand "neg<mode>2"
1726 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
1727 (neg:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
1731 (define_insn "*neg<mode>2"
1732 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1733 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1736 [(set_attr "type" "add")])
1738 (define_insn_and_split "*neg<mode>2_dot"
1739 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1740 (compare:CC (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1742 (clobber (match_scratch:GPR 0 "=r,r"))]
1743 "<MODE>mode == Pmode"
1747 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
1749 (neg:GPR (match_dup 1)))
1751 (compare:CC (match_dup 0)
1754 [(set_attr "type" "add")
1755 (set_attr "dot" "yes")
1756 (set_attr "length" "4,8")])
1758 (define_insn_and_split "*neg<mode>2_dot2"
1759 [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1760 (compare:CC (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
1762 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
1763 (neg:GPR (match_dup 1)))]
1764 "<MODE>mode == Pmode"
1768 "&& reload_completed && cc_reg_not_cr0_operand (operands[2], CCmode)"
1770 (neg:GPR (match_dup 1)))
1772 (compare:CC (match_dup 0)
1775 [(set_attr "type" "add")
1776 (set_attr "dot" "yes")
1777 (set_attr "length" "4,8")])
1780 (define_insn "clz<mode>2"
1781 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1782 (clz:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1785 [(set_attr "type" "cntlz")])
1787 (define_expand "ctz<mode>2"
1789 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
1791 (and:GPR (match_dup 1)
1794 (clz:GPR (match_dup 3)))
1795 (parallel [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1796 (minus:GPR (match_dup 5)
1798 (clobber (reg:GPR CA_REGNO))])]
1801 operands[2] = gen_reg_rtx (<MODE>mode);
1802 operands[3] = gen_reg_rtx (<MODE>mode);
1803 operands[4] = gen_reg_rtx (<MODE>mode);
1804 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1);
1807 (define_expand "ffs<mode>2"
1809 (neg:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))
1811 (and:GPR (match_dup 1)
1814 (clz:GPR (match_dup 3)))
1815 (parallel [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1816 (minus:GPR (match_dup 5)
1818 (clobber (reg:GPR CA_REGNO))])]
1821 operands[2] = gen_reg_rtx (<MODE>mode);
1822 operands[3] = gen_reg_rtx (<MODE>mode);
1823 operands[4] = gen_reg_rtx (<MODE>mode);
1824 operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode));
1828 (define_expand "popcount<mode>2"
1829 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1830 (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
1831 "TARGET_POPCNTB || TARGET_POPCNTD"
1833 rs6000_emit_popcount (operands[0], operands[1]);
1837 (define_insn "popcntb<mode>2"
1838 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1839 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")]
1843 [(set_attr "type" "popcnt")])
1845 (define_insn "popcntd<mode>2"
1846 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1847 (popcount:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
1850 [(set_attr "type" "popcnt")])
1853 (define_expand "parity<mode>2"
1854 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
1855 (parity:GPR (match_operand:GPR 1 "gpc_reg_operand" "")))]
1858 rs6000_emit_parity (operands[0], operands[1]);
1862 (define_insn "parity<mode>2_cmpb"
1863 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
1864 (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")] UNSPEC_PARITY))]
1865 "TARGET_CMPB && TARGET_POPCNTB"
1867 [(set_attr "type" "popcnt")])
1870 ;; Since the hardware zeros the upper part of the register, save generating the
1871 ;; AND immediate if we are converting to unsigned
1872 (define_insn "*bswaphi2_extenddi"
1873 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
1875 (bswap:HI (match_operand:HI 1 "memory_operand" "Z"))))]
1878 [(set_attr "length" "4")
1879 (set_attr "type" "load")])
1881 (define_insn "*bswaphi2_extendsi"
1882 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1884 (bswap:HI (match_operand:HI 1 "memory_operand" "Z"))))]
1887 [(set_attr "length" "4")
1888 (set_attr "type" "load")])
1890 (define_expand "bswaphi2"
1891 [(parallel [(set (match_operand:HI 0 "reg_or_mem_operand" "")
1893 (match_operand:HI 1 "reg_or_mem_operand" "")))
1894 (clobber (match_scratch:SI 2 ""))])]
1897 if (!REG_P (operands[0]) && !REG_P (operands[1]))
1898 operands[1] = force_reg (HImode, operands[1]);
1901 (define_insn "bswaphi2_internal"
1902 [(set (match_operand:HI 0 "reg_or_mem_operand" "=r,Z,&r")
1904 (match_operand:HI 1 "reg_or_mem_operand" "Z,r,r")))
1905 (clobber (match_scratch:SI 2 "=X,X,&r"))]
1911 [(set_attr "length" "4,4,12")
1912 (set_attr "type" "load,store,*")])
1914 ;; We are always BITS_BIG_ENDIAN, so the (const_int 16) below is
1915 ;; correct for -mlittle as well as -mbig.
1917 [(set (match_operand:HI 0 "gpc_reg_operand" "")
1918 (bswap:HI (match_operand:HI 1 "gpc_reg_operand" "")))
1919 (clobber (match_operand:SI 2 "gpc_reg_operand" ""))]
1922 (zero_extract:SI (match_dup 4)
1926 (and:SI (ashift:SI (match_dup 4)
1928 (const_int 65280))) ;; 0xff00
1930 (ior:SI (match_dup 3)
1934 operands[3] = simplify_gen_subreg (SImode, operands[0], HImode, 0);
1935 operands[4] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
1938 (define_insn "*bswapsi2_extenddi"
1939 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
1941 (bswap:SI (match_operand:SI 1 "memory_operand" "Z"))))]
1944 [(set_attr "length" "4")
1945 (set_attr "type" "load")])
1947 (define_expand "bswapsi2"
1948 [(set (match_operand:SI 0 "reg_or_mem_operand" "")
1950 (match_operand:SI 1 "reg_or_mem_operand" "")))]
1953 if (!REG_P (operands[0]) && !REG_P (operands[1]))
1954 operands[1] = force_reg (SImode, operands[1]);
1957 (define_insn "*bswapsi2_internal"
1958 [(set (match_operand:SI 0 "reg_or_mem_operand" "=r,Z,&r")
1960 (match_operand:SI 1 "reg_or_mem_operand" "Z,r,r")))]
1966 [(set_attr "length" "4,4,12")
1967 (set_attr "type" "load,store,*")])
1969 ;; We are always BITS_BIG_ENDIAN, so the bit positions below in
1970 ;; zero_extract insns do not change for -mlittle.
1972 [(set (match_operand:SI 0 "gpc_reg_operand" "")
1973 (bswap:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1976 (rotate:SI (match_dup 1) (const_int 8)))
1977 (set (zero_extract:SI (match_dup 0)
1981 (set (zero_extract:SI (match_dup 0)
1984 (rotate:SI (match_dup 1)
1988 (define_expand "bswapdi2"
1989 [(parallel [(set (match_operand:DI 0 "reg_or_mem_operand" "")
1991 (match_operand:DI 1 "reg_or_mem_operand" "")))
1992 (clobber (match_scratch:DI 2 ""))
1993 (clobber (match_scratch:DI 3 ""))
1994 (clobber (match_scratch:DI 4 ""))])]
1997 if (!REG_P (operands[0]) && !REG_P (operands[1]))
1998 operands[1] = force_reg (DImode, operands[1]);
2000 if (!TARGET_POWERPC64)
2002 /* 32-bit mode needs fewer scratch registers, but 32-bit addressing mode
2003 that uses 64-bit registers needs the same scratch registers as 64-bit
2005 emit_insn (gen_bswapdi2_32bit (operands[0], operands[1]));
2010 ;; Power7/cell has ldbrx/stdbrx, so use it directly
2011 (define_insn "*bswapdi2_ldbrx"
2012 [(set (match_operand:DI 0 "reg_or_mem_operand" "=&r,Z,??&r")
2013 (bswap:DI (match_operand:DI 1 "reg_or_mem_operand" "Z,r,r")))
2014 (clobber (match_scratch:DI 2 "=X,X,&r"))
2015 (clobber (match_scratch:DI 3 "=X,X,&r"))
2016 (clobber (match_scratch:DI 4 "=X,X,&r"))]
2017 "TARGET_POWERPC64 && TARGET_LDBRX
2018 && (REG_P (operands[0]) || REG_P (operands[1]))"
2023 [(set_attr "length" "4,4,36")
2024 (set_attr "type" "load,store,*")])
2026 ;; Non-power7/cell, fall back to use lwbrx/stwbrx
2027 (define_insn "*bswapdi2_64bit"
2028 [(set (match_operand:DI 0 "reg_or_mem_operand" "=&r,Z,&r")
2029 (bswap:DI (match_operand:DI 1 "reg_or_mem_operand" "Z,r,r")))
2030 (clobber (match_scratch:DI 2 "=&b,&b,&r"))
2031 (clobber (match_scratch:DI 3 "=&r,&r,&r"))
2032 (clobber (match_scratch:DI 4 "=&r,X,&r"))]
2033 "TARGET_POWERPC64 && !TARGET_LDBRX
2034 && (REG_P (operands[0]) || REG_P (operands[1]))
2035 && !(MEM_P (operands[0]) && MEM_VOLATILE_P (operands[0]))
2036 && !(MEM_P (operands[1]) && MEM_VOLATILE_P (operands[1]))"
2038 [(set_attr "length" "16,12,36")])
2041 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2042 (bswap:DI (match_operand:DI 1 "indexed_or_indirect_operand" "")))
2043 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
2044 (clobber (match_operand:DI 3 "gpc_reg_operand" ""))
2045 (clobber (match_operand:DI 4 "gpc_reg_operand" ""))]
2046 "TARGET_POWERPC64 && !TARGET_LDBRX && reload_completed"
2050 rtx dest = operands[0];
2051 rtx src = operands[1];
2052 rtx op2 = operands[2];
2053 rtx op3 = operands[3];
2054 rtx op4 = operands[4];
2055 rtx op3_32 = simplify_gen_subreg (SImode, op3, DImode,
2056 BYTES_BIG_ENDIAN ? 4 : 0);
2057 rtx op4_32 = simplify_gen_subreg (SImode, op4, DImode,
2058 BYTES_BIG_ENDIAN ? 4 : 0);
2064 addr1 = XEXP (src, 0);
2065 if (GET_CODE (addr1) == PLUS)
2067 emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2068 if (TARGET_AVOID_XFORM)
2070 emit_insn (gen_add3_insn (op2, XEXP (addr1, 1), op2));
2074 addr2 = gen_rtx_PLUS (Pmode, op2, XEXP (addr1, 1));
2076 else if (TARGET_AVOID_XFORM)
2078 emit_insn (gen_add3_insn (op2, addr1, GEN_INT (4)));
2083 emit_move_insn (op2, GEN_INT (4));
2084 addr2 = gen_rtx_PLUS (Pmode, op2, addr1);
2087 if (BYTES_BIG_ENDIAN)
2089 word_high = change_address (src, SImode, addr1);
2090 word_low = change_address (src, SImode, addr2);
2094 word_high = change_address (src, SImode, addr2);
2095 word_low = change_address (src, SImode, addr1);
2098 emit_insn (gen_bswapsi2 (op3_32, word_low));
2099 emit_insn (gen_bswapsi2 (op4_32, word_high));
2100 emit_insn (gen_ashldi3 (dest, op3, GEN_INT (32)));
2101 emit_insn (gen_iordi3 (dest, dest, op4));
2106 [(set (match_operand:DI 0 "indexed_or_indirect_operand" "")
2107 (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2108 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
2109 (clobber (match_operand:DI 3 "gpc_reg_operand" ""))
2110 (clobber (match_operand:DI 4 "" ""))]
2111 "TARGET_POWERPC64 && !TARGET_LDBRX && reload_completed"
2115 rtx dest = operands[0];
2116 rtx src = operands[1];
2117 rtx op2 = operands[2];
2118 rtx op3 = operands[3];
2119 rtx src_si = simplify_gen_subreg (SImode, src, DImode,
2120 BYTES_BIG_ENDIAN ? 4 : 0);
2121 rtx op3_si = simplify_gen_subreg (SImode, op3, DImode,
2122 BYTES_BIG_ENDIAN ? 4 : 0);
2128 addr1 = XEXP (dest, 0);
2129 if (GET_CODE (addr1) == PLUS)
2131 emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2132 if (TARGET_AVOID_XFORM)
2134 emit_insn (gen_add3_insn (op2, XEXP (addr1, 1), op2));
2138 addr2 = gen_rtx_PLUS (Pmode, op2, XEXP (addr1, 1));
2140 else if (TARGET_AVOID_XFORM)
2142 emit_insn (gen_add3_insn (op2, addr1, GEN_INT (4)));
2147 emit_move_insn (op2, GEN_INT (4));
2148 addr2 = gen_rtx_PLUS (Pmode, op2, addr1);
2151 emit_insn (gen_lshrdi3 (op3, src, GEN_INT (32)));
2152 if (BYTES_BIG_ENDIAN)
2154 word_high = change_address (dest, SImode, addr1);
2155 word_low = change_address (dest, SImode, addr2);
2159 word_high = change_address (dest, SImode, addr2);
2160 word_low = change_address (dest, SImode, addr1);
2162 emit_insn (gen_bswapsi2 (word_high, src_si));
2163 emit_insn (gen_bswapsi2 (word_low, op3_si));
2168 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2169 (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2170 (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
2171 (clobber (match_operand:DI 3 "gpc_reg_operand" ""))
2172 (clobber (match_operand:DI 4 "" ""))]
2173 "TARGET_POWERPC64 && reload_completed"
2177 rtx dest = operands[0];
2178 rtx src = operands[1];
2179 rtx op2 = operands[2];
2180 rtx op3 = operands[3];
2181 int lo_off = BYTES_BIG_ENDIAN ? 4 : 0;
2182 rtx dest_si = simplify_gen_subreg (SImode, dest, DImode, lo_off);
2183 rtx src_si = simplify_gen_subreg (SImode, src, DImode, lo_off);
2184 rtx op2_si = simplify_gen_subreg (SImode, op2, DImode, lo_off);
2185 rtx op3_si = simplify_gen_subreg (SImode, op3, DImode, lo_off);
2187 emit_insn (gen_lshrdi3 (op2, src, GEN_INT (32)));
2188 emit_insn (gen_bswapsi2 (dest_si, src_si));
2189 emit_insn (gen_bswapsi2 (op3_si, op2_si));
2190 emit_insn (gen_ashldi3 (dest, dest, GEN_INT (32)));
2191 emit_insn (gen_iordi3 (dest, dest, op3));
2195 (define_insn "bswapdi2_32bit"
2196 [(set (match_operand:DI 0 "reg_or_mem_operand" "=&r,Z,&r")
2197 (bswap:DI (match_operand:DI 1 "reg_or_mem_operand" "Z,r,r")))
2198 (clobber (match_scratch:SI 2 "=&b,&b,X"))]
2199 "!TARGET_POWERPC64 && (REG_P (operands[0]) || REG_P (operands[1]))"
2201 [(set_attr "length" "16,12,36")])
2204 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2205 (bswap:DI (match_operand:DI 1 "indexed_or_indirect_operand" "")))
2206 (clobber (match_operand:SI 2 "gpc_reg_operand" ""))]
2207 "!TARGET_POWERPC64 && reload_completed"
2211 rtx dest = operands[0];
2212 rtx src = operands[1];
2213 rtx op2 = operands[2];
2214 rtx dest1 = simplify_gen_subreg (SImode, dest, DImode, 0);
2215 rtx dest2 = simplify_gen_subreg (SImode, dest, DImode, 4);
2221 addr1 = XEXP (src, 0);
2222 if (GET_CODE (addr1) == PLUS)
2224 emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2225 if (TARGET_AVOID_XFORM)
2227 emit_insn (gen_add3_insn (op2, XEXP (addr1, 1), op2));
2231 addr2 = gen_rtx_PLUS (SImode, op2, XEXP (addr1, 1));
2233 else if (TARGET_AVOID_XFORM)
2235 emit_insn (gen_add3_insn (op2, addr1, GEN_INT (4)));
2240 emit_move_insn (op2, GEN_INT (4));
2241 addr2 = gen_rtx_PLUS (SImode, op2, addr1);
2244 word1 = change_address (src, SImode, addr1);
2245 word2 = change_address (src, SImode, addr2);
2247 emit_insn (gen_bswapsi2 (dest2, word1));
2248 emit_insn (gen_bswapsi2 (dest1, word2));
2253 [(set (match_operand:DI 0 "indexed_or_indirect_operand" "")
2254 (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2255 (clobber (match_operand:SI 2 "gpc_reg_operand" ""))]
2256 "!TARGET_POWERPC64 && reload_completed"
2260 rtx dest = operands[0];
2261 rtx src = operands[1];
2262 rtx op2 = operands[2];
2263 rtx src1 = simplify_gen_subreg (SImode, src, DImode, 0);
2264 rtx src2 = simplify_gen_subreg (SImode, src, DImode, 4);
2270 addr1 = XEXP (dest, 0);
2271 if (GET_CODE (addr1) == PLUS)
2273 emit_insn (gen_add3_insn (op2, XEXP (addr1, 0), GEN_INT (4)));
2274 if (TARGET_AVOID_XFORM)
2276 emit_insn (gen_add3_insn (op2, XEXP (addr1, 1), op2));
2280 addr2 = gen_rtx_PLUS (SImode, op2, XEXP (addr1, 1));
2282 else if (TARGET_AVOID_XFORM)
2284 emit_insn (gen_add3_insn (op2, addr1, GEN_INT (4)));
2289 emit_move_insn (op2, GEN_INT (4));
2290 addr2 = gen_rtx_PLUS (SImode, op2, addr1);
2293 word1 = change_address (dest, SImode, addr1);
2294 word2 = change_address (dest, SImode, addr2);
2296 emit_insn (gen_bswapsi2 (word2, src1));
2297 emit_insn (gen_bswapsi2 (word1, src2));
2302 [(set (match_operand:DI 0 "gpc_reg_operand" "")
2303 (bswap:DI (match_operand:DI 1 "gpc_reg_operand" "")))
2304 (clobber (match_operand:SI 2 "" ""))]
2305 "!TARGET_POWERPC64 && reload_completed"
2309 rtx dest = operands[0];
2310 rtx src = operands[1];
2311 rtx src1 = simplify_gen_subreg (SImode, src, DImode, 0);
2312 rtx src2 = simplify_gen_subreg (SImode, src, DImode, 4);
2313 rtx dest1 = simplify_gen_subreg (SImode, dest, DImode, 0);
2314 rtx dest2 = simplify_gen_subreg (SImode, dest, DImode, 4);
2316 emit_insn (gen_bswapsi2 (dest1, src2));
2317 emit_insn (gen_bswapsi2 (dest2, src1));
2322 (define_insn "mul<mode>3"
2323 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2324 (mult:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2325 (match_operand:GPR 2 "reg_or_short_operand" "r,I")))]
2330 [(set_attr "type" "mul")
2332 (cond [(match_operand:GPR 2 "s8bit_cint_operand" "")
2334 (match_operand:GPR 2 "short_cint_operand" "")
2335 (const_string "16")]
2336 (const_string "<bits>")))])
2338 (define_insn_and_split "*mul<mode>3_dot"
2339 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2340 (compare:CC (mult:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
2341 (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
2343 (clobber (match_scratch:GPR 0 "=r,r"))]
2344 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
2348 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2350 (mult:GPR (match_dup 1)
2353 (compare:CC (match_dup 0)
2356 [(set_attr "type" "mul")
2357 (set_attr "size" "<bits>")
2358 (set_attr "dot" "yes")
2359 (set_attr "length" "4,8")])
2361 (define_insn_and_split "*mul<mode>3_dot2"
2362 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2363 (compare:CC (mult:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
2364 (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
2366 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2367 (mult:GPR (match_dup 1)
2369 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
2373 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2375 (mult:GPR (match_dup 1)
2378 (compare:CC (match_dup 0)
2381 [(set_attr "type" "mul")
2382 (set_attr "size" "<bits>")
2383 (set_attr "dot" "yes")
2384 (set_attr "length" "4,8")])
2387 (define_expand "<su>mul<mode>3_highpart"
2388 [(set (match_operand:GPR 0 "gpc_reg_operand")
2390 (mult:<DMODE> (any_extend:<DMODE>
2391 (match_operand:GPR 1 "gpc_reg_operand"))
2393 (match_operand:GPR 2 "gpc_reg_operand")))
2397 if (<MODE>mode == SImode && TARGET_POWERPC64)
2399 emit_insn (gen_<su>mulsi3_highpart_64 (operands[0], operands[1],
2404 if (!WORDS_BIG_ENDIAN)
2406 emit_insn (gen_<su>mul<mode>3_highpart_le (operands[0], operands[1],
2412 (define_insn "*<su>mul<mode>3_highpart"
2413 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2415 (mult:<DMODE> (any_extend:<DMODE>
2416 (match_operand:GPR 1 "gpc_reg_operand" "r"))
2418 (match_operand:GPR 2 "gpc_reg_operand" "r")))
2420 "WORDS_BIG_ENDIAN && !(<MODE>mode == SImode && TARGET_POWERPC64)"
2421 "mulh<wd><u> %0,%1,%2"
2422 [(set_attr "type" "mul")
2423 (set_attr "size" "<bits>")])
2425 (define_insn "<su>mulsi3_highpart_le"
2426 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2428 (mult:DI (any_extend:DI
2429 (match_operand:SI 1 "gpc_reg_operand" "r"))
2431 (match_operand:SI 2 "gpc_reg_operand" "r")))
2433 "!WORDS_BIG_ENDIAN && !TARGET_POWERPC64"
2435 [(set_attr "type" "mul")])
2437 (define_insn "<su>muldi3_highpart_le"
2438 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
2440 (mult:TI (any_extend:TI
2441 (match_operand:DI 1 "gpc_reg_operand" "r"))
2443 (match_operand:DI 2 "gpc_reg_operand" "r")))
2445 "!WORDS_BIG_ENDIAN && TARGET_POWERPC64"
2447 [(set_attr "type" "mul")
2448 (set_attr "size" "64")])
2450 (define_insn "<su>mulsi3_highpart_64"
2451 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2454 (mult:DI (any_extend:DI
2455 (match_operand:SI 1 "gpc_reg_operand" "r"))
2457 (match_operand:SI 2 "gpc_reg_operand" "r")))
2461 [(set_attr "type" "mul")])
2463 (define_expand "<u>mul<mode><dmode>3"
2464 [(set (match_operand:<DMODE> 0 "gpc_reg_operand")
2465 (mult:<DMODE> (any_extend:<DMODE>
2466 (match_operand:GPR 1 "gpc_reg_operand"))
2468 (match_operand:GPR 2 "gpc_reg_operand"))))]
2469 "!(<MODE>mode == SImode && TARGET_POWERPC64)"
2471 rtx l = gen_reg_rtx (<MODE>mode);
2472 rtx h = gen_reg_rtx (<MODE>mode);
2473 emit_insn (gen_mul<mode>3 (l, operands[1], operands[2]));
2474 emit_insn (gen_<su>mul<mode>3_highpart (h, operands[1], operands[2]));
2475 emit_move_insn (gen_lowpart (<MODE>mode, operands[0]), l);
2476 emit_move_insn (gen_highpart (<MODE>mode, operands[0]), h);
2481 (define_insn "udiv<mode>3"
2482 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2483 (udiv:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2484 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2487 [(set_attr "type" "div")
2488 (set_attr "size" "<bits>")])
2491 ;; For powers of two we can do sra[wd]i/addze for divide and then adjust for
2492 ;; modulus. If it isn't a power of two, force operands into register and do
2494 (define_expand "div<mode>3"
2495 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2496 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2497 (match_operand:GPR 2 "reg_or_cint_operand" "")))]
2500 if (CONST_INT_P (operands[2])
2501 && INTVAL (operands[2]) > 0
2502 && exact_log2 (INTVAL (operands[2])) >= 0)
2504 emit_insn (gen_div<mode>3_sra (operands[0], operands[1], operands[2]));
2508 operands[2] = force_reg (<MODE>mode, operands[2]);
2511 (define_insn "*div<mode>3"
2512 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2513 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2514 (match_operand:GPR 2 "gpc_reg_operand" "r")))]
2517 [(set_attr "type" "div")
2518 (set_attr "size" "<bits>")])
2520 (define_insn "div<mode>3_sra"
2521 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2522 (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
2523 (match_operand:GPR 2 "exact_log2_cint_operand" "N")))
2524 (clobber (reg:GPR CA_REGNO))]
2526 "sra<wd>i %0,%1,%p2\;addze %0,%0"
2527 [(set_attr "type" "two")
2528 (set_attr "length" "8")])
2530 (define_insn_and_split "*div<mode>3_sra_dot"
2531 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2532 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
2533 (match_operand:GPR 2 "exact_log2_cint_operand" "N,N"))
2535 (clobber (match_scratch:GPR 0 "=r,r"))
2536 (clobber (reg:GPR CA_REGNO))]
2537 "<MODE>mode == Pmode"
2539 sra<wd>i %0,%1,%p2\;addze. %0,%0
2541 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2542 [(parallel [(set (match_dup 0)
2543 (div:GPR (match_dup 1)
2545 (clobber (reg:GPR CA_REGNO))])
2547 (compare:CC (match_dup 0)
2550 [(set_attr "type" "two")
2551 (set_attr "length" "8,12")
2552 (set_attr "cell_micro" "not")])
2554 (define_insn_and_split "*div<mode>3_sra_dot2"
2555 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2556 (compare:CC (div:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
2557 (match_operand:GPR 2 "exact_log2_cint_operand" "N,N"))
2559 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2560 (div:GPR (match_dup 1)
2562 (clobber (reg:GPR CA_REGNO))]
2563 "<MODE>mode == Pmode"
2565 sra<wd>i %0,%1,%p2\;addze. %0,%0
2567 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2568 [(parallel [(set (match_dup 0)
2569 (div:GPR (match_dup 1)
2571 (clobber (reg:GPR CA_REGNO))])
2573 (compare:CC (match_dup 0)
2576 [(set_attr "type" "two")
2577 (set_attr "length" "8,12")
2578 (set_attr "cell_micro" "not")])
2580 (define_expand "mod<mode>3"
2581 [(use (match_operand:GPR 0 "gpc_reg_operand" ""))
2582 (use (match_operand:GPR 1 "gpc_reg_operand" ""))
2583 (use (match_operand:GPR 2 "reg_or_cint_operand" ""))]
2590 if (GET_CODE (operands[2]) != CONST_INT
2591 || INTVAL (operands[2]) <= 0
2592 || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2595 temp1 = gen_reg_rtx (<MODE>mode);
2596 temp2 = gen_reg_rtx (<MODE>mode);
2598 emit_insn (gen_div<mode>3 (temp1, operands[1], operands[2]));
2599 emit_insn (gen_ashl<mode>3 (temp2, temp1, GEN_INT (i)));
2600 emit_insn (gen_sub<mode>3 (operands[0], operands[1], temp2));
2604 ;; Logical instructions
2605 ;; The logical instructions are mostly combined by using match_operator,
2606 ;; but the plain AND insns are somewhat different because there is no
2607 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2608 ;; those rotate-and-mask operations. Thus, the AND insns come first.
2610 (define_expand "and<mode>3"
2611 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2612 (and:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
2613 (match_operand:SDI 2 "reg_or_cint_operand" "")))]
2616 if (<MODE>mode == DImode && !TARGET_POWERPC64)
2618 rs6000_split_logical (operands, AND, false, false, false);
2622 if (logical_const_operand (operands[2], <MODE>mode)
2623 && !any_mask_operand (operands[2], <MODE>mode))
2625 emit_insn (gen_and<mode>3_imm (operands[0], operands[1], operands[2]));
2629 if ((<MODE>mode == DImode && !and64_2_operand (operands[2], <MODE>mode))
2630 || (<MODE>mode != DImode && !and_operand (operands[2], <MODE>mode)))
2631 operands[2] = force_reg (<MODE>mode, operands[2]);
2635 (define_insn "and<mode>3_imm"
2636 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2637 (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r")
2638 (match_operand:GPR 2 "logical_const_operand" "n")))
2639 (clobber (match_scratch:CC 3 "=x"))]
2640 "rs6000_gen_cell_microcode
2641 && !any_mask_operand (operands[2], <MODE>mode)"
2642 "andi%e2. %0,%1,%u2"
2643 [(set_attr "type" "logical")
2644 (set_attr "dot" "yes")])
2646 (define_insn_and_split "*and<mode>3_imm_dot"
2647 [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2648 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2649 (match_operand:GPR 2 "logical_const_operand" "n,n"))
2651 (clobber (match_scratch:GPR 0 "=r,r"))
2652 (clobber (match_scratch:CC 4 "=X,x"))]
2653 "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2654 && rs6000_gen_cell_microcode
2655 && !any_mask_operand (operands[2], <MODE>mode)"
2659 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2660 [(parallel [(set (match_dup 0)
2661 (and:GPR (match_dup 1)
2663 (clobber (match_dup 4))])
2665 (compare:CC (match_dup 0)
2668 [(set_attr "type" "logical")
2669 (set_attr "dot" "yes")
2670 (set_attr "length" "4,8")])
2672 (define_insn_and_split "*and<mode>3_imm_dot2"
2673 [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2674 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2675 (match_operand:GPR 2 "logical_const_operand" "n,n"))
2677 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2678 (and:GPR (match_dup 1)
2680 (clobber (match_scratch:CC 4 "=X,x"))]
2681 "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2682 && rs6000_gen_cell_microcode
2683 && !any_mask_operand (operands[2], <MODE>mode)"
2687 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2688 [(parallel [(set (match_dup 0)
2689 (and:GPR (match_dup 1)
2691 (clobber (match_dup 4))])
2693 (compare:CC (match_dup 0)
2696 [(set_attr "type" "logical")
2697 (set_attr "dot" "yes")
2698 (set_attr "length" "4,8")])
2700 (define_insn_and_split "*and<mode>3_imm_mask_dot"
2701 [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2702 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2703 (match_operand:GPR 2 "logical_const_operand" "n,n"))
2705 (clobber (match_scratch:GPR 0 "=r,r"))]
2706 "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2707 && rs6000_gen_cell_microcode
2708 && any_mask_operand (operands[2], <MODE>mode)"
2712 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2714 (and:GPR (match_dup 1)
2717 (compare:CC (match_dup 0)
2720 [(set_attr "type" "logical")
2721 (set_attr "dot" "yes")
2722 (set_attr "length" "4,8")])
2724 (define_insn_and_split "*and<mode>3_imm_mask_dot2"
2725 [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
2726 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2727 (match_operand:GPR 2 "logical_const_operand" "n,n"))
2729 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2730 (and:GPR (match_dup 1)
2732 "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2733 && rs6000_gen_cell_microcode
2734 && any_mask_operand (operands[2], <MODE>mode)"
2738 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2740 (and:GPR (match_dup 1)
2743 (compare:CC (match_dup 0)
2746 [(set_attr "type" "logical")
2747 (set_attr "dot" "yes")
2748 (set_attr "length" "4,8")])
2751 (define_insn "*and<mode>3_mask"
2752 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2753 (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r")
2754 (match_operand:GPR 2 "any_mask_operand" "S,T")))]
2757 rldic%B2 %0,%1,0,%S2
2758 rlwinm %0,%1,0,%m2,%M2"
2759 [(set_attr "type" "shift")])
2761 (define_insn_and_split "*and<mode>3_mask_dot"
2762 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
2763 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r,r,r")
2764 (match_operand:GPR 2 "any_mask_operand" "S,T,S,T"))
2766 (clobber (match_scratch:GPR 0 "=r,r,r,r"))]
2767 "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2768 && rs6000_gen_cell_microcode
2769 && !logical_const_operand (operands[2], <MODE>mode)"
2771 rldic%B2. %0,%1,0,%S2
2772 rlwinm. %0,%1,0,%m2,%M2
2775 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2777 (and:GPR (match_dup 1)
2780 (compare:CC (match_dup 0)
2783 [(set_attr "type" "shift")
2784 (set_attr "dot" "yes")
2785 (set_attr "length" "4,4,8,8")])
2787 (define_insn_and_split "*and<mode>3_mask_dot2"
2788 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
2789 (compare:CC (and:GPR (match_operand:GPR 1 "gpc_reg_operand" "%r,r,r,r")
2790 (match_operand:GPR 2 "any_mask_operand" "S,T,S,T"))
2792 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r,r,r")
2793 (and:GPR (match_dup 1)
2795 "(<MODE>mode == Pmode || UINTVAL (operands[2]) <= 0x7fffffff)
2796 && rs6000_gen_cell_microcode
2797 && !logical_const_operand (operands[2], <MODE>mode)"
2799 rldic%B2. %0,%1,0,%S2
2800 rlwinm. %0,%1,0,%m2,%M2
2803 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
2805 (and:GPR (match_dup 1)
2808 (compare:CC (match_dup 0)
2811 [(set_attr "type" "shift")
2812 (set_attr "dot" "yes")
2813 (set_attr "length" "4,4,8,8")])
2817 (define_insn "andsi3_internal0_nomc"
2818 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2819 (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2820 (match_operand:SI 2 "and_operand" "?r,T")))]
2821 "!rs6000_gen_cell_microcode"
2824 rlwinm %0,%1,0,%m2,%M2"
2825 [(set_attr "type" "logical,shift")])
2828 ;; Handle the PowerPC64 rlwinm corner case
2830 (define_insn_and_split "*andsi3_internal6"
2831 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2832 (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2833 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2838 (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2841 (rotate:SI (match_dup 0) (match_dup 5)))]
2844 int mb = extract_MB (operands[2]);
2845 int me = extract_ME (operands[2]);
2846 operands[3] = GEN_INT (me + 1);
2847 operands[5] = GEN_INT (32 - (me + 1));
2848 operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2850 [(set_attr "length" "8")])
2853 (define_expand "<iorxor><mode>3"
2854 [(set (match_operand:SDI 0 "gpc_reg_operand" "")
2855 (iorxor:SDI (match_operand:SDI 1 "gpc_reg_operand" "")
2856 (match_operand:SDI 2 "reg_or_cint_operand" "")))]
2859 if (<MODE>mode == DImode && !TARGET_POWERPC64)
2861 rs6000_split_logical (operands, <IORXOR>, false, false, false);
2865 if (non_logical_cint_operand (operands[2], <MODE>mode))
2867 rtx tmp = ((!can_create_pseudo_p ()
2868 || rtx_equal_p (operands[0], operands[1]))
2869 ? operands[0] : gen_reg_rtx (<MODE>mode));
2871 HOST_WIDE_INT value = INTVAL (operands[2]);
2872 HOST_WIDE_INT lo = value & 0xffff;
2873 HOST_WIDE_INT hi = value - lo;
2875 emit_insn (gen_<iorxor><mode>3 (tmp, operands[1], GEN_INT (hi)));
2876 emit_insn (gen_<iorxor><mode>3 (operands[0], tmp, GEN_INT (lo)));
2880 if (!reg_or_logical_cint_operand (operands[2], <MODE>mode))
2881 operands[2] = force_reg (<MODE>mode, operands[2]);
2885 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
2886 (iorxor:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
2887 (match_operand:GPR 2 "non_logical_cint_operand" "")))]
2890 (iorxor:GPR (match_dup 1)
2893 (iorxor:GPR (match_dup 3)
2896 operands[3] = ((!can_create_pseudo_p ()
2897 || rtx_equal_p (operands[0], operands[1]))
2898 ? operands[0] : gen_reg_rtx (<MODE>mode));
2900 HOST_WIDE_INT value = INTVAL (operands[2]);
2901 HOST_WIDE_INT lo = value & 0xffff;
2902 HOST_WIDE_INT hi = value - lo;
2904 operands[4] = GEN_INT (hi);
2905 operands[5] = GEN_INT (lo);
2908 (define_insn "*bool<mode>3_imm"
2909 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2910 (match_operator:GPR 3 "boolean_or_operator"
2911 [(match_operand:GPR 1 "gpc_reg_operand" "%r")
2912 (match_operand:GPR 2 "logical_const_operand" "n")]))]
2915 [(set_attr "type" "logical")])
2917 (define_insn "*bool<mode>3"
2918 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2919 (match_operator:GPR 3 "boolean_operator"
2920 [(match_operand:GPR 1 "gpc_reg_operand" "r")
2921 (match_operand:GPR 2 "gpc_reg_operand" "r")]))]
2924 [(set_attr "type" "logical")])
2926 (define_insn_and_split "*bool<mode>3_dot"
2927 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2928 (compare:CC (match_operator:GPR 3 "boolean_operator"
2929 [(match_operand:GPR 1 "gpc_reg_operand" "r,r")
2930 (match_operand:GPR 2 "gpc_reg_operand" "r,r")])
2932 (clobber (match_scratch:GPR 0 "=r,r"))]
2933 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
2937 "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
2941 (compare:CC (match_dup 0)
2944 [(set_attr "type" "logical")
2945 (set_attr "dot" "yes")
2946 (set_attr "length" "4,8")])
2948 (define_insn_and_split "*bool<mode>3_dot2"
2949 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2950 (compare:CC (match_operator:GPR 3 "boolean_operator"
2951 [(match_operand:GPR 1 "gpc_reg_operand" "r,r")
2952 (match_operand:GPR 2 "gpc_reg_operand" "r,r")])
2954 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
2956 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
2960 "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
2964 (compare:CC (match_dup 0)
2967 [(set_attr "type" "logical")
2968 (set_attr "dot" "yes")
2969 (set_attr "length" "4,8")])
2972 (define_insn "*boolc<mode>3"
2973 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
2974 (match_operator:GPR 3 "boolean_operator"
2975 [(not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r"))
2976 (match_operand:GPR 1 "gpc_reg_operand" "r")]))]
2979 [(set_attr "type" "logical")])
2981 (define_insn_and_split "*boolc<mode>3_dot"
2982 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2983 (compare:CC (match_operator:GPR 3 "boolean_operator"
2984 [(not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
2985 (match_operand:GPR 1 "gpc_reg_operand" "r,r")])
2987 (clobber (match_scratch:GPR 0 "=r,r"))]
2988 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
2992 "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
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 "*boolc<mode>3_dot2"
3004 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3005 (compare:CC (match_operator:GPR 3 "boolean_operator"
3006 [(not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r"))
3007 (match_operand:GPR 1 "gpc_reg_operand" "r,r")])
3009 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
3011 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3015 "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
3019 (compare:CC (match_dup 0)
3022 [(set_attr "type" "logical")
3023 (set_attr "dot" "yes")
3024 (set_attr "length" "4,8")])
3027 (define_insn "*boolcc<mode>3"
3028 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3029 (match_operator:GPR 3 "boolean_operator"
3030 [(not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r"))
3031 (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r"))]))]
3034 [(set_attr "type" "logical")])
3036 (define_insn_and_split "*boolcc<mode>3_dot"
3037 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3038 (compare:CC (match_operator:GPR 3 "boolean_operator"
3039 [(not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
3040 (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r"))])
3042 (clobber (match_scratch:GPR 0 "=r,r"))]
3043 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3047 "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
3051 (compare:CC (match_dup 0)
3054 [(set_attr "type" "logical")
3055 (set_attr "dot" "yes")
3056 (set_attr "length" "4,8")])
3058 (define_insn_and_split "*boolcc<mode>3_dot2"
3059 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3060 (compare:CC (match_operator:GPR 3 "boolean_operator"
3061 [(not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r"))
3062 (not:GPR (match_operand:GPR 2 "gpc_reg_operand" "r,r"))])
3064 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
3066 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3070 "&& reload_completed && cc_reg_not_cr0_operand (operands[4], CCmode)"
3074 (compare:CC (match_dup 0)
3077 [(set_attr "type" "logical")
3078 (set_attr "dot" "yes")
3079 (set_attr "length" "4,8")])
3082 ;; TODO: Should have dots of this as well.
3083 (define_insn "*eqv<mode>3"
3084 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3085 (not:GPR (xor:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
3086 (match_operand:GPR 2 "gpc_reg_operand" "r"))))]
3089 [(set_attr "type" "logical")])
3091 ;; Rotate and shift insns, in all their variants. These support shifts,
3092 ;; field inserts and extracts, and various combinations thereof.
3093 (define_expand "insv"
3094 [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
3095 (match_operand:SI 1 "const_int_operand" "")
3096 (match_operand:SI 2 "const_int_operand" ""))
3097 (match_operand 3 "gpc_reg_operand" ""))]
3101 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3102 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3103 compiler if the address of the structure is taken later. Likewise, do
3104 not handle invalid E500 subregs. */
3105 if (GET_CODE (operands[0]) == SUBREG
3106 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD
3107 || ((TARGET_E500_DOUBLE || TARGET_SPE)
3108 && invalid_e500_subreg (operands[0], GET_MODE (operands[0])))))
3111 if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
3112 emit_insn (gen_insvdi_internal (operands[0], operands[1], operands[2],
3115 emit_insn (gen_insvsi_internal (operands[0], operands[1], operands[2],
3120 (define_insn "insvsi_internal"
3121 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3122 (match_operand:SI 1 "const_int_operand" "i")
3123 (match_operand:SI 2 "const_int_operand" "i"))
3124 (match_operand:SI 3 "gpc_reg_operand" "r"))]
3128 int start = INTVAL (operands[2]) & 31;
3129 int size = INTVAL (operands[1]) & 31;
3131 operands[4] = GEN_INT (32 - start - size);
3132 operands[1] = GEN_INT (start + size - 1);
3133 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3135 [(set_attr "type" "insert")])
3137 (define_insn "*insvsi_internal1"
3138 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3139 (match_operand:SI 1 "const_int_operand" "i")
3140 (match_operand:SI 2 "const_int_operand" "i"))
3141 (rotate:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3142 (match_operand:SI 4 "const_int_operand" "i")))]
3143 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3146 int shift = INTVAL (operands[4]) & 31;
3147 int start = INTVAL (operands[2]) & 31;
3148 int size = INTVAL (operands[1]) & 31;
3150 operands[4] = GEN_INT (shift - start - size);
3151 operands[1] = GEN_INT (start + size - 1);
3152 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3154 [(set_attr "type" "insert")])
3156 (define_insn "*insvsi_internal2"
3157 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3158 (match_operand:SI 1 "const_int_operand" "i")
3159 (match_operand:SI 2 "const_int_operand" "i"))
3160 (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3161 (match_operand:SI 4 "const_int_operand" "i")))]
3162 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3165 int shift = INTVAL (operands[4]) & 31;
3166 int start = INTVAL (operands[2]) & 31;
3167 int size = INTVAL (operands[1]) & 31;
3169 operands[4] = GEN_INT (32 - shift - start - size);
3170 operands[1] = GEN_INT (start + size - 1);
3171 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3173 [(set_attr "type" "insert")])
3175 (define_insn "*insvsi_internal3"
3176 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3177 (match_operand:SI 1 "const_int_operand" "i")
3178 (match_operand:SI 2 "const_int_operand" "i"))
3179 (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3180 (match_operand:SI 4 "const_int_operand" "i")))]
3181 "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3184 int shift = INTVAL (operands[4]) & 31;
3185 int start = INTVAL (operands[2]) & 31;
3186 int size = INTVAL (operands[1]) & 31;
3188 operands[4] = GEN_INT (32 - shift - start - size);
3189 operands[1] = GEN_INT (start + size - 1);
3190 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3192 [(set_attr "type" "insert")])
3194 (define_insn "*insvsi_internal4"
3195 [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3196 (match_operand:SI 1 "const_int_operand" "i")
3197 (match_operand:SI 2 "const_int_operand" "i"))
3198 (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3199 (match_operand:SI 4 "const_int_operand" "i")
3200 (match_operand:SI 5 "const_int_operand" "i")))]
3201 "INTVAL (operands[4]) >= INTVAL (operands[1])"
3204 int extract_start = INTVAL (operands[5]) & 31;
3205 int extract_size = INTVAL (operands[4]) & 31;
3206 int insert_start = INTVAL (operands[2]) & 31;
3207 int insert_size = INTVAL (operands[1]) & 31;
3209 /* Align extract field with insert field */
3210 operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
3211 operands[1] = GEN_INT (insert_start + insert_size - 1);
3212 return \"rlwimi %0,%3,%h5,%h2,%h1\";
3214 [(set_attr "type" "insert")])
3216 ;; combine patterns for rlwimi
3217 (define_insn "*insvsi_internal5"
3218 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3219 (ior:SI (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3220 (match_operand:SI 1 "mask_operand" "i"))
3221 (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3222 (match_operand:SI 2 "const_int_operand" "i"))
3223 (match_operand:SI 5 "mask_operand" "i"))))]
3224 "INTVAL(operands[1]) == ~INTVAL(operands[5])"
3227 int me = extract_ME(operands[5]);
3228 int mb = extract_MB(operands[5]);
3229 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3230 operands[2] = GEN_INT(mb);
3231 operands[1] = GEN_INT(me);
3232 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3234 [(set_attr "type" "insert")])
3236 (define_insn "*insvsi_internal6"
3237 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3238 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3239 (match_operand:SI 2 "const_int_operand" "i"))
3240 (match_operand:SI 5 "mask_operand" "i"))
3241 (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3242 (match_operand:SI 1 "mask_operand" "i"))))]
3243 "INTVAL(operands[1]) == ~INTVAL(operands[5])"
3246 int me = extract_ME(operands[5]);
3247 int mb = extract_MB(operands[5]);
3248 operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3249 operands[2] = GEN_INT(mb);
3250 operands[1] = GEN_INT(me);
3251 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3253 [(set_attr "type" "insert")])
3255 (define_insn "insvdi_internal"
3256 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3257 (match_operand:SI 1 "const_int_operand" "i")
3258 (match_operand:SI 2 "const_int_operand" "i"))
3259 (match_operand:DI 3 "gpc_reg_operand" "r"))]
3263 int start = INTVAL (operands[2]) & 63;
3264 int size = INTVAL (operands[1]) & 63;
3266 operands[1] = GEN_INT (64 - start - size);
3267 return \"rldimi %0,%3,%H1,%H2\";
3269 [(set_attr "type" "insert")
3270 (set_attr "size" "64")])
3272 (define_insn "*insvdi_internal2"
3273 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3274 (match_operand:SI 1 "const_int_operand" "i")
3275 (match_operand:SI 2 "const_int_operand" "i"))
3276 (ashiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3277 (match_operand:SI 4 "const_int_operand" "i")))]
3279 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3282 int shift = INTVAL (operands[4]) & 63;
3283 int start = (INTVAL (operands[2]) & 63) - 32;
3284 int size = INTVAL (operands[1]) & 63;
3286 operands[4] = GEN_INT (64 - shift - start - size);
3287 operands[2] = GEN_INT (start);
3288 operands[1] = GEN_INT (start + size - 1);
3289 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3292 (define_insn "*insvdi_internal3"
3293 [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3294 (match_operand:SI 1 "const_int_operand" "i")
3295 (match_operand:SI 2 "const_int_operand" "i"))
3296 (lshiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3297 (match_operand:SI 4 "const_int_operand" "i")))]
3299 && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3302 int shift = INTVAL (operands[4]) & 63;
3303 int start = (INTVAL (operands[2]) & 63) - 32;
3304 int size = INTVAL (operands[1]) & 63;
3306 operands[4] = GEN_INT (64 - shift - start - size);
3307 operands[2] = GEN_INT (start);
3308 operands[1] = GEN_INT (start + size - 1);
3309 return \"rlwimi %0,%3,%h4,%h2,%h1\";
3312 (define_expand "extzv"
3313 [(set (match_operand 0 "gpc_reg_operand" "")
3314 (zero_extract (match_operand 1 "gpc_reg_operand" "")
3315 (match_operand:SI 2 "const_int_operand" "")
3316 (match_operand:SI 3 "const_int_operand" "")))]
3320 /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3321 the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3322 compiler if the address of the structure is taken later. */
3323 if (GET_CODE (operands[0]) == SUBREG
3324 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3327 if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3328 emit_insn (gen_extzvdi_internal (operands[0], operands[1], operands[2],
3331 emit_insn (gen_extzvsi_internal (operands[0], operands[1], operands[2],
3336 (define_insn "extzvsi_internal"
3337 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3338 (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3339 (match_operand:SI 2 "const_int_operand" "i")
3340 (match_operand:SI 3 "const_int_operand" "i")))]
3344 int start = INTVAL (operands[3]) & 31;
3345 int size = INTVAL (operands[2]) & 31;
3347 if (start + size >= 32)
3348 operands[3] = const0_rtx;
3350 operands[3] = GEN_INT (start + size);
3351 return \"rlwinm %0,%1,%3,%s2,31\";
3353 [(set_attr "type" "shift")])
3355 (define_insn "*extzvsi_internal1"
3356 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3357 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3358 (match_operand:SI 2 "const_int_operand" "i,i")
3359 (match_operand:SI 3 "const_int_operand" "i,i"))
3361 (clobber (match_scratch:SI 4 "=r,r"))]
3365 int start = INTVAL (operands[3]) & 31;
3366 int size = INTVAL (operands[2]) & 31;
3368 /* Force split for non-cc0 compare. */
3369 if (which_alternative == 1)
3372 /* If the bit-field being tested fits in the upper or lower half of a
3373 word, it is possible to use andiu. or andil. to test it. This is
3374 useful because the condition register set-use delay is smaller for
3375 andi[ul]. than for rlinm. This doesn't work when the starting bit
3376 position is 0 because the LT and GT bits may be set wrong. */
3378 if ((start > 0 && start + size <= 16) || start >= 16)
3380 operands[3] = GEN_INT (((1 << (16 - (start & 15)))
3381 - (1 << (16 - (start & 15) - size))));
3383 return \"andis. %4,%1,%3\";
3385 return \"andi. %4,%1,%3\";
3388 if (start + size >= 32)
3389 operands[3] = const0_rtx;
3391 operands[3] = GEN_INT (start + size);
3392 return \"rlwinm. %4,%1,%3,%s2,31\";
3394 [(set_attr "type" "shift")
3395 (set_attr "dot" "yes")
3396 (set_attr "length" "4,8")])
3399 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3400 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3401 (match_operand:SI 2 "const_int_operand" "")
3402 (match_operand:SI 3 "const_int_operand" ""))
3404 (clobber (match_scratch:SI 4 ""))]
3407 (zero_extract:SI (match_dup 1) (match_dup 2)
3410 (compare:CC (match_dup 4)
3414 (define_insn "*extzvsi_internal2"
3415 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3416 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3417 (match_operand:SI 2 "const_int_operand" "i,i")
3418 (match_operand:SI 3 "const_int_operand" "i,i"))
3420 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3421 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3425 int start = INTVAL (operands[3]) & 31;
3426 int size = INTVAL (operands[2]) & 31;
3428 /* Force split for non-cc0 compare. */
3429 if (which_alternative == 1)
3432 /* Since we are using the output value, we can't ignore any need for
3433 a shift. The bit-field must end at the LSB. */
3434 if (start >= 16 && start + size == 32)
3436 operands[3] = GEN_INT ((1 << size) - 1);
3437 return \"andi. %0,%1,%3\";
3440 if (start + size >= 32)
3441 operands[3] = const0_rtx;
3443 operands[3] = GEN_INT (start + size);
3444 return \"rlwinm. %0,%1,%3,%s2,31\";
3446 [(set_attr "type" "shift")
3447 (set_attr "dot" "yes")
3448 (set_attr "length" "4,8")])
3451 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
3452 (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3453 (match_operand:SI 2 "const_int_operand" "")
3454 (match_operand:SI 3 "const_int_operand" ""))
3456 (set (match_operand:SI 0 "gpc_reg_operand" "")
3457 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3460 (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3462 (compare:CC (match_dup 0)
3466 (define_insn "extzvdi_internal"
3467 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3468 (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3469 (match_operand:SI 2 "const_int_operand" "i")
3470 (match_operand:SI 3 "const_int_operand" "i")))]
3474 int start = INTVAL (operands[3]) & 63;
3475 int size = INTVAL (operands[2]) & 63;
3477 if (start + size >= 64)
3478 operands[3] = const0_rtx;
3480 operands[3] = GEN_INT (start + size);
3481 operands[2] = GEN_INT (64 - size);
3482 return \"rldicl %0,%1,%3,%2\";
3484 [(set_attr "type" "shift")])
3486 (define_insn "*extzvdi_internal1"
3487 [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3488 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3489 (match_operand:SI 2 "const_int_operand" "i")
3490 (match_operand:SI 3 "const_int_operand" "i"))
3492 (clobber (match_scratch:DI 4 "=r"))]
3493 "TARGET_64BIT && rs6000_gen_cell_microcode"
3496 int start = INTVAL (operands[3]) & 63;
3497 int size = INTVAL (operands[2]) & 63;
3499 if (start + size >= 64)
3500 operands[3] = const0_rtx;
3502 operands[3] = GEN_INT (start + size);
3503 operands[2] = GEN_INT (64 - size);
3504 return \"rldicl. %4,%1,%3,%2\";
3506 [(set_attr "type" "shift")
3507 (set_attr "dot" "yes")])
3509 (define_insn "*extzvdi_internal2"
3510 [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3511 (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3512 (match_operand:SI 2 "const_int_operand" "i")
3513 (match_operand:SI 3 "const_int_operand" "i"))
3515 (set (match_operand:DI 0 "gpc_reg_operand" "=r")
3516 (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
3517 "TARGET_64BIT && rs6000_gen_cell_microcode"
3520 int start = INTVAL (operands[3]) & 63;
3521 int size = INTVAL (operands[2]) & 63;
3523 if (start + size >= 64)
3524 operands[3] = const0_rtx;
3526 operands[3] = GEN_INT (start + size);
3527 operands[2] = GEN_INT (64 - size);
3528 return \"rldicl. %0,%1,%3,%2\";
3530 [(set_attr "type" "shift")
3531 (set_attr "dot" "yes")])
3534 (define_insn "rotl<mode>3"
3535 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
3536 (rotate:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
3537 (match_operand:SI 2 "reg_or_cint_operand" "rn")))]
3539 "rotl<wd>%I2 %0,%1,%<hH>2"
3540 [(set_attr "type" "shift")
3541 (set_attr "maybe_var_shift" "yes")])
3543 (define_insn "*rotlsi3_64"
3544 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3546 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3547 (match_operand:SI 2 "reg_or_cint_operand" "rn"))))]
3549 "rotlw%I2 %0,%1,%h2"
3550 [(set_attr "type" "shift")
3551 (set_attr "maybe_var_shift" "yes")])
3553 (define_insn_and_split "*rotl<mode>3_dot"
3554 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3555 (compare:CC (rotate:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
3556 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
3558 (clobber (match_scratch:GPR 0 "=r,r"))]
3559 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3561 rotl<wd>%I2. %0,%1,%<hH>2
3563 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
3565 (rotate:GPR (match_dup 1)
3568 (compare:CC (match_dup 0)
3571 [(set_attr "type" "shift")
3572 (set_attr "maybe_var_shift" "yes")
3573 (set_attr "dot" "yes")
3574 (set_attr "length" "4,8")])
3576 (define_insn_and_split "*rotl<mode>3_dot2"
3577 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3578 (compare:CC (rotate:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
3579 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
3581 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
3582 (rotate:GPR (match_dup 1)
3584 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
3586 rotl<wd>%I2. %0,%1,%<hH>2
3588 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
3590 (rotate:GPR (match_dup 1)
3593 (compare:CC (match_dup 0)
3596 [(set_attr "type" "shift")
3597 (set_attr "maybe_var_shift" "yes")
3598 (set_attr "dot" "yes")
3599 (set_attr "length" "4,8")])
3602 (define_insn "*rotlsi3_internal4"
3603 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3604 (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3605 (match_operand:SI 2 "reg_or_cint_operand" "rn"))
3606 (match_operand:SI 3 "mask_operand" "n")))]
3608 "rlw%I2nm %0,%1,%h2,%m3,%M3"
3609 [(set_attr "type" "shift")
3610 (set_attr "maybe_var_shift" "yes")])
3612 (define_insn "*rotlsi3_internal5"
3613 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3615 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3616 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
3617 (match_operand:SI 3 "mask_operand" "n,n"))
3619 (clobber (match_scratch:SI 4 "=r,r"))]
3622 rlw%I2nm. %4,%1,%h2,%m3,%M3
3624 [(set_attr "type" "shift")
3625 (set_attr "maybe_var_shift" "yes")
3626 (set_attr "dot" "yes")
3627 (set_attr "length" "4,8")])
3630 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3632 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3633 (match_operand:SI 2 "reg_or_cint_operand" ""))
3634 (match_operand:SI 3 "mask_operand" ""))
3636 (clobber (match_scratch:SI 4 ""))]
3639 (and:SI (rotate:SI (match_dup 1)
3643 (compare:CC (match_dup 4)
3647 (define_insn "*rotlsi3_internal6"
3648 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3650 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3651 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
3652 (match_operand:SI 3 "mask_operand" "n,n"))
3654 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3655 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3658 rlw%I2nm. %0,%1,%h2,%m3,%M3
3660 [(set_attr "type" "shift")
3661 (set_attr "maybe_var_shift" "yes")
3662 (set_attr "dot" "yes")
3663 (set_attr "length" "4,8")])
3666 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
3668 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3669 (match_operand:SI 2 "reg_or_cint_operand" ""))
3670 (match_operand:SI 3 "mask_operand" ""))
3672 (set (match_operand:SI 0 "gpc_reg_operand" "")
3673 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3676 (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3678 (compare:CC (match_dup 0)
3682 (define_insn "*rotlsi3_internal7le"
3683 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3686 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3687 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3689 "rlw%I2nm %0,%1,%h2,0xff"
3690 [(set (attr "cell_micro")
3691 (if_then_else (match_operand:SI 2 "const_int_operand" "")
3692 (const_string "not")
3693 (const_string "always")))
3694 (set_attr "type" "shift")])
3696 (define_insn "*rotlsi3_internal7be"
3697 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3700 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3701 (match_operand:SI 2 "reg_or_cint_operand" "ri")) 3)))]
3703 "rlw%I2nm %0,%1,%h2,0xff"
3704 [(set (attr "cell_micro")
3705 (if_then_else (match_operand:SI 2 "const_int_operand" "")
3706 (const_string "not")
3707 (const_string "always")))
3708 (set_attr "type" "shift")])
3710 (define_insn "*rotlsi3_internal8le"
3711 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3712 (compare:CC (zero_extend:SI
3714 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3715 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 0))
3717 (clobber (match_scratch:SI 3 "=r,r"))]
3720 rlw%I2nm. %3,%1,%h2,0xff
3722 [(set_attr "type" "shift")
3723 (set_attr "maybe_var_shift" "yes")
3724 (set_attr "dot" "yes")
3725 (set_attr "length" "4,8")])
3727 (define_insn "*rotlsi3_internal8be"
3728 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3729 (compare:CC (zero_extend:SI
3731 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3732 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 3))
3734 (clobber (match_scratch:SI 3 "=r,r"))]
3737 rlw%I2nm. %3,%1,%h2,0xff
3739 [(set_attr "type" "shift")
3740 (set_attr "maybe_var_shift" "yes")
3741 (set_attr "dot" "yes")
3742 (set_attr "length" "4,8")])
3745 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3746 (compare:CC (zero_extend:SI
3748 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3749 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3751 (clobber (match_scratch:SI 3 ""))]
3752 "!BYTES_BIG_ENDIAN && reload_completed"
3754 (zero_extend:SI (subreg:QI
3755 (rotate:SI (match_dup 1)
3758 (compare:CC (match_dup 3)
3763 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3764 (compare:CC (zero_extend:SI
3766 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3767 (match_operand:SI 2 "reg_or_cint_operand" "")) 3))
3769 (clobber (match_scratch:SI 3 ""))]
3770 "BYTES_BIG_ENDIAN && reload_completed"
3772 (zero_extend:SI (subreg:QI
3773 (rotate:SI (match_dup 1)
3776 (compare:CC (match_dup 3)
3780 (define_insn "*rotlsi3_internal9le"
3781 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3782 (compare:CC (zero_extend:SI
3784 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3785 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 0))
3787 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3788 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3791 rlw%I2nm. %0,%1,%h2,0xff
3793 [(set_attr "type" "shift")
3794 (set_attr "maybe_var_shift" "yes")
3795 (set_attr "dot" "yes")
3796 (set_attr "length" "4,8")])
3798 (define_insn "*rotlsi3_internal9be"
3799 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3800 (compare:CC (zero_extend:SI
3802 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3803 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 3))
3805 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3806 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 3)))]
3809 rlw%I2nm. %0,%1,%h2,0xff
3811 [(set_attr "type" "shift")
3812 (set_attr "maybe_var_shift" "yes")
3813 (set_attr "dot" "yes")
3814 (set_attr "length" "4,8")])
3817 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
3818 (compare:CC (zero_extend:SI
3820 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3821 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3823 (set (match_operand:SI 0 "gpc_reg_operand" "")
3824 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3825 "!BYTES_BIG_ENDIAN && reload_completed"
3827 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3829 (compare:CC (match_dup 0)
3834 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
3835 (compare:CC (zero_extend:SI
3837 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3838 (match_operand:SI 2 "reg_or_cint_operand" "")) 3))
3840 (set (match_operand:SI 0 "gpc_reg_operand" "")
3841 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 3)))]
3842 "BYTES_BIG_ENDIAN && reload_completed"
3844 (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 3)))
3846 (compare:CC (match_dup 0)
3850 (define_insn "*rotlsi3_internal10le"
3851 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3854 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3855 (match_operand:SI 2 "reg_or_cint_operand" "rn")) 0)))]
3857 "rlw%I2nm %0,%1,%h2,0xffff"
3858 [(set_attr "type" "shift")
3859 (set_attr "maybe_var_shift" "yes")])
3861 (define_insn "*rotlsi3_internal10be"
3862 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3865 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3866 (match_operand:SI 2 "reg_or_cint_operand" "rn")) 2)))]
3868 "rlw%I2nm %0,%1,%h2,0xffff"
3869 [(set_attr "type" "shift")
3870 (set_attr "maybe_var_shift" "yes")])
3872 (define_insn "*rotlsi3_internal11le"
3873 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3874 (compare:CC (zero_extend:SI
3876 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3877 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 0))
3879 (clobber (match_scratch:SI 3 "=r,r"))]
3882 rlw%I2nm. %3,%1,%h2,0xffff
3884 [(set_attr "type" "shift")
3885 (set_attr "maybe_var_shift" "yes")
3886 (set_attr "dot" "yes")
3887 (set_attr "length" "4,8")])
3889 (define_insn "*rotlsi3_internal11be"
3890 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3891 (compare:CC (zero_extend:SI
3893 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3894 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 2))
3896 (clobber (match_scratch:SI 3 "=r,r"))]
3899 rlw%I2nm. %3,%1,%h2,0xffff
3901 [(set_attr "type" "shift")
3902 (set_attr "maybe_var_shift" "yes")
3903 (set_attr "dot" "yes")
3904 (set_attr "length" "4,8")])
3907 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3908 (compare:CC (zero_extend:SI
3910 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3911 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3913 (clobber (match_scratch:SI 3 ""))]
3914 "!BYTES_BIG_ENDIAN && reload_completed"
3916 (zero_extend:SI (subreg:HI
3917 (rotate:SI (match_dup 1)
3920 (compare:CC (match_dup 3)
3925 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
3926 (compare:CC (zero_extend:SI
3928 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3929 (match_operand:SI 2 "reg_or_cint_operand" "")) 2))
3931 (clobber (match_scratch:SI 3 ""))]
3932 "BYTES_BIG_ENDIAN && reload_completed"
3934 (zero_extend:SI (subreg:HI
3935 (rotate:SI (match_dup 1)
3938 (compare:CC (match_dup 3)
3942 (define_insn "*rotlsi3_internal12le"
3943 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3944 (compare:CC (zero_extend:SI
3946 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3947 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 0))
3949 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3950 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3953 rlw%I2nm. %0,%1,%h2,0xffff
3955 [(set_attr "type" "shift")
3956 (set_attr "maybe_var_shift" "yes")
3957 (set_attr "dot" "yes")
3958 (set_attr "length" "4,8")])
3960 (define_insn "*rotlsi3_internal12be"
3961 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3962 (compare:CC (zero_extend:SI
3964 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3965 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn")) 2))
3967 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3968 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 2)))]
3971 rlw%I2nm. %0,%1,%h2,0xffff
3973 [(set_attr "type" "shift")
3974 (set_attr "maybe_var_shift" "yes")
3975 (set_attr "dot" "yes")
3976 (set_attr "length" "4,8")])
3979 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
3980 (compare:CC (zero_extend:SI
3982 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3983 (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3985 (set (match_operand:SI 0 "gpc_reg_operand" "")
3986 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3987 "!BYTES_BIG_ENDIAN && reload_completed"
3989 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3991 (compare:CC (match_dup 0)
3996 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
3997 (compare:CC (zero_extend:SI
3999 (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4000 (match_operand:SI 2 "reg_or_cint_operand" "")) 2))
4002 (set (match_operand:SI 0 "gpc_reg_operand" "")
4003 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 2)))]
4004 "BYTES_BIG_ENDIAN && reload_completed"
4006 (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 2)))
4008 (compare:CC (match_dup 0)
4013 (define_insn "ashl<mode>3"
4014 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
4015 (ashift:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
4016 (match_operand:SI 2 "reg_or_cint_operand" "rn")))]
4018 "sl<wd>%I2 %0,%1,%<hH>2"
4019 [(set_attr "type" "shift")
4020 (set_attr "maybe_var_shift" "yes")])
4022 (define_insn "*ashlsi3_64"
4023 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4025 (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4026 (match_operand:SI 2 "reg_or_cint_operand" "rn"))))]
4029 [(set_attr "type" "shift")
4030 (set_attr "maybe_var_shift" "yes")])
4032 (define_insn_and_split "*ashl<mode>3_dot"
4033 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4034 (compare:CC (ashift:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4035 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4037 (clobber (match_scratch:GPR 0 "=r,r"))]
4038 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4040 sl<wd>%I2. %0,%1,%<hH>2
4042 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4044 (ashift:GPR (match_dup 1)
4047 (compare:CC (match_dup 0)
4050 [(set_attr "type" "shift")
4051 (set_attr "maybe_var_shift" "yes")
4052 (set_attr "dot" "yes")
4053 (set_attr "length" "4,8")])
4055 (define_insn_and_split "*ashl<mode>3_dot2"
4056 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4057 (compare:CC (ashift:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4058 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4060 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
4061 (ashift:GPR (match_dup 1)
4063 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4065 sl<wd>%I2. %0,%1,%<hH>2
4067 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4069 (ashift:GPR (match_dup 1)
4072 (compare:CC (match_dup 0)
4075 [(set_attr "type" "shift")
4076 (set_attr "maybe_var_shift" "yes")
4077 (set_attr "dot" "yes")
4078 (set_attr "length" "4,8")])
4081 (define_insn "rlwinm"
4082 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4083 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4084 (match_operand:SI 2 "const_int_operand" "i"))
4085 (match_operand:SI 3 "mask_operand" "n")))]
4086 "includes_lshift_p (operands[2], operands[3])"
4087 "rlwinm %0,%1,%h2,%m3,%M3"
4088 [(set_attr "type" "shift")])
4091 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4093 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4094 (match_operand:SI 2 "const_int_operand" "i,i"))
4095 (match_operand:SI 3 "mask_operand" "n,n"))
4097 (clobber (match_scratch:SI 4 "=r,r"))]
4098 "includes_lshift_p (operands[2], operands[3])"
4100 rlwinm. %4,%1,%h2,%m3,%M3
4102 [(set_attr "type" "shift")
4103 (set_attr "dot" "yes")
4104 (set_attr "length" "4,8")])
4107 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4109 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4110 (match_operand:SI 2 "const_int_operand" ""))
4111 (match_operand:SI 3 "mask_operand" ""))
4113 (clobber (match_scratch:SI 4 ""))]
4114 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
4116 (and:SI (ashift:SI (match_dup 1) (match_dup 2))
4119 (compare:CC (match_dup 4)
4124 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4126 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4127 (match_operand:SI 2 "const_int_operand" "i,i"))
4128 (match_operand:SI 3 "mask_operand" "n,n"))
4130 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4131 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4132 "includes_lshift_p (operands[2], operands[3])"
4134 rlwinm. %0,%1,%h2,%m3,%M3
4136 [(set_attr "type" "shift")
4137 (set_attr "dot" "yes")
4138 (set_attr "length" "4,8")])
4141 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
4143 (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4144 (match_operand:SI 2 "const_int_operand" ""))
4145 (match_operand:SI 3 "mask_operand" ""))
4147 (set (match_operand:SI 0 "gpc_reg_operand" "")
4148 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4149 "includes_lshift_p (operands[2], operands[3]) && reload_completed"
4151 (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4153 (compare:CC (match_dup 0)
4158 (define_insn "lshr<mode>3"
4159 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
4160 (lshiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
4161 (match_operand:SI 2 "reg_or_cint_operand" "rn")))]
4163 "sr<wd>%I2 %0,%1,%<hH>2"
4164 [(set_attr "type" "shift")
4165 (set_attr "maybe_var_shift" "yes")])
4167 (define_insn "*lshrsi3_64"
4168 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4170 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4171 (match_operand:SI 2 "reg_or_cint_operand" "rn"))))]
4174 [(set_attr "type" "shift")
4175 (set_attr "maybe_var_shift" "yes")])
4177 (define_insn_and_split "*lshr<mode>3_dot"
4178 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4179 (compare:CC (lshiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4180 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4182 (clobber (match_scratch:GPR 0 "=r,r"))]
4183 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4185 sr<wd>%I2. %0,%1,%<hH>2
4187 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4189 (lshiftrt:GPR (match_dup 1)
4192 (compare:CC (match_dup 0)
4195 [(set_attr "type" "shift")
4196 (set_attr "maybe_var_shift" "yes")
4197 (set_attr "dot" "yes")
4198 (set_attr "length" "4,8")])
4200 (define_insn_and_split "*lshr<mode>3_dot2"
4201 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4202 (compare:CC (lshiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4203 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4205 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
4206 (lshiftrt:GPR (match_dup 1)
4208 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4210 sr<wd>%I2. %0,%1,%<hH>2
4212 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4214 (lshiftrt:GPR (match_dup 1)
4217 (compare:CC (match_dup 0)
4220 [(set_attr "type" "shift")
4221 (set_attr "maybe_var_shift" "yes")
4222 (set_attr "dot" "yes")
4223 (set_attr "length" "4,8")])
4227 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4228 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4229 (match_operand:SI 2 "const_int_operand" "i"))
4230 (match_operand:SI 3 "mask_operand" "n")))]
4231 "includes_rshift_p (operands[2], operands[3])"
4232 "rlwinm %0,%1,%s2,%m3,%M3"
4233 [(set_attr "type" "shift")])
4236 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4238 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4239 (match_operand:SI 2 "const_int_operand" "i,i"))
4240 (match_operand:SI 3 "mask_operand" "n,n"))
4242 (clobber (match_scratch:SI 4 "=r,r"))]
4243 "includes_rshift_p (operands[2], operands[3])"
4245 rlwinm. %4,%1,%s2,%m3,%M3
4247 [(set_attr "type" "shift")
4248 (set_attr "dot" "yes")
4249 (set_attr "length" "4,8")])
4252 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4254 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4255 (match_operand:SI 2 "const_int_operand" ""))
4256 (match_operand:SI 3 "mask_operand" ""))
4258 (clobber (match_scratch:SI 4 ""))]
4259 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4261 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
4264 (compare:CC (match_dup 4)
4269 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4271 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4272 (match_operand:SI 2 "const_int_operand" "i,i"))
4273 (match_operand:SI 3 "mask_operand" "n,n"))
4275 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4276 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4277 "includes_rshift_p (operands[2], operands[3])"
4279 rlwinm. %0,%1,%s2,%m3,%M3
4281 [(set_attr "type" "shift")
4282 (set_attr "dot" "yes")
4283 (set_attr "length" "4,8")])
4286 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
4288 (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4289 (match_operand:SI 2 "const_int_operand" ""))
4290 (match_operand:SI 3 "mask_operand" ""))
4292 (set (match_operand:SI 0 "gpc_reg_operand" "")
4293 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4294 "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4296 (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4298 (compare:CC (match_dup 0)
4302 (define_insn "*lshiftrt_internal1le"
4303 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4306 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4307 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4308 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4309 "rlwinm %0,%1,%s2,0xff"
4310 [(set_attr "type" "shift")])
4312 (define_insn "*lshiftrt_internal1be"
4313 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4316 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4317 (match_operand:SI 2 "const_int_operand" "i")) 3)))]
4318 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4319 "rlwinm %0,%1,%s2,0xff"
4320 [(set_attr "type" "shift")])
4322 (define_insn "*lshiftrt_internal2le"
4323 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4327 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4328 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4330 (clobber (match_scratch:SI 3 "=r,r"))]
4331 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4333 rlwinm. %3,%1,%s2,0xff
4335 [(set_attr "type" "shift")
4336 (set_attr "dot" "yes")
4337 (set_attr "length" "4,8")])
4339 (define_insn "*lshiftrt_internal2be"
4340 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4344 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4345 (match_operand:SI 2 "const_int_operand" "i,i")) 3))
4347 (clobber (match_scratch:SI 3 "=r,r"))]
4348 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4350 rlwinm. %3,%1,%s2,0xff
4352 [(set_attr "type" "shift")
4353 (set_attr "dot" "yes")
4354 (set_attr "length" "4,8")])
4357 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4361 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4362 (match_operand:SI 2 "const_int_operand" "")) 0))
4364 (clobber (match_scratch:SI 3 ""))]
4365 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4367 (zero_extend:SI (subreg:QI
4368 (lshiftrt:SI (match_dup 1)
4371 (compare:CC (match_dup 3)
4376 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4380 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4381 (match_operand:SI 2 "const_int_operand" "")) 3))
4383 (clobber (match_scratch:SI 3 ""))]
4384 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4386 (zero_extend:SI (subreg:QI
4387 (lshiftrt:SI (match_dup 1)
4390 (compare:CC (match_dup 3)
4394 (define_insn "*lshiftrt_internal3le"
4395 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4399 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4400 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4402 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4403 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4404 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4406 rlwinm. %0,%1,%s2,0xff
4408 [(set_attr "type" "shift")
4409 (set_attr "dot" "yes")
4410 (set_attr "length" "4,8")])
4412 (define_insn "*lshiftrt_internal3be"
4413 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4417 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4418 (match_operand:SI 2 "const_int_operand" "i,i")) 3))
4420 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4421 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 3)))]
4422 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255))"
4424 rlwinm. %0,%1,%s2,0xff
4426 [(set_attr "type" "shift")
4427 (set_attr "dot" "yes")
4428 (set_attr "length" "4,8")])
4431 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4435 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4436 (match_operand:SI 2 "const_int_operand" "")) 0))
4438 (set (match_operand:SI 0 "gpc_reg_operand" "")
4439 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4440 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4442 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4444 (compare:CC (match_dup 0)
4449 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4453 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4454 (match_operand:SI 2 "const_int_operand" "")) 3))
4456 (set (match_operand:SI 0 "gpc_reg_operand" "")
4457 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 3)))]
4458 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4460 (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 3)))
4462 (compare:CC (match_dup 0)
4466 (define_insn "*lshiftrt_internal4le"
4467 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4470 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4471 (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4472 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4473 "rlwinm %0,%1,%s2,0xffff"
4474 [(set_attr "type" "shift")])
4476 (define_insn "*lshiftrt_internal4be"
4477 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4480 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4481 (match_operand:SI 2 "const_int_operand" "i")) 2)))]
4482 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4483 "rlwinm %0,%1,%s2,0xffff"
4484 [(set_attr "type" "shift")])
4486 (define_insn "*lshiftrt_internal5le"
4487 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4491 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4492 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4494 (clobber (match_scratch:SI 3 "=r,r"))]
4495 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4497 rlwinm. %3,%1,%s2,0xffff
4499 [(set_attr "type" "shift")
4500 (set_attr "dot" "yes")
4501 (set_attr "length" "4,8")])
4503 (define_insn "*lshiftrt_internal5be"
4504 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4508 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4509 (match_operand:SI 2 "const_int_operand" "i,i")) 2))
4511 (clobber (match_scratch:SI 3 "=r,r"))]
4512 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4514 rlwinm. %3,%1,%s2,0xffff
4516 [(set_attr "type" "shift")
4517 (set_attr "dot" "yes")
4518 (set_attr "length" "4,8")])
4521 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4525 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4526 (match_operand:SI 2 "const_int_operand" "")) 0))
4528 (clobber (match_scratch:SI 3 ""))]
4529 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4531 (zero_extend:SI (subreg:HI
4532 (lshiftrt:SI (match_dup 1)
4535 (compare:CC (match_dup 3)
4540 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
4544 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4545 (match_operand:SI 2 "const_int_operand" "")) 2))
4547 (clobber (match_scratch:SI 3 ""))]
4548 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4550 (zero_extend:SI (subreg:HI
4551 (lshiftrt:SI (match_dup 1)
4554 (compare:CC (match_dup 3)
4558 (define_insn "*lshiftrt_internal5le"
4559 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4563 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4564 (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4566 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4567 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4568 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4570 rlwinm. %0,%1,%s2,0xffff
4572 [(set_attr "type" "shift")
4573 (set_attr "dot" "yes")
4574 (set_attr "length" "4,8")])
4576 (define_insn "*lshiftrt_internal5be"
4577 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4581 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4582 (match_operand:SI 2 "const_int_operand" "i,i")) 2))
4584 (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4585 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 2)))]
4586 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535))"
4588 rlwinm. %0,%1,%s2,0xffff
4590 [(set_attr "type" "shift")
4591 (set_attr "dot" "yes")
4592 (set_attr "length" "4,8")])
4595 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4599 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4600 (match_operand:SI 2 "const_int_operand" "")) 0))
4602 (set (match_operand:SI 0 "gpc_reg_operand" "")
4603 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4604 "!BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4606 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4608 (compare:CC (match_dup 0)
4613 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
4617 (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4618 (match_operand:SI 2 "const_int_operand" "")) 2))
4620 (set (match_operand:SI 0 "gpc_reg_operand" "")
4621 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 2)))]
4622 "BYTES_BIG_ENDIAN && includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4624 (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 2)))
4626 (compare:CC (match_dup 0)
4631 (define_expand "ashr<mode>3"
4632 [(parallel [(set (match_operand:GPR 0 "gpc_reg_operand" "")
4633 (ashiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "")
4634 (match_operand:SI 2 "reg_or_cint_operand" "")))
4635 (clobber (reg:GPR CA_REGNO))])]
4638 /* The generic code does not generate optimal code for the low word
4639 (it should be a rlwimi and a rot). Until we have target code to
4640 solve this generically, keep this expander. */
4642 if (<MODE>mode == DImode && !TARGET_POWERPC64)
4644 if (CONST_INT_P (operands[2]))
4646 emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
4654 (define_insn "*ashr<mode>3"
4655 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
4656 (ashiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
4657 (match_operand:SI 2 "reg_or_cint_operand" "rn")))
4658 (clobber (reg:GPR CA_REGNO))]
4660 "sra<wd>%I2 %0,%1,%<hH>2"
4661 [(set_attr "type" "shift")
4662 (set_attr "maybe_var_shift" "yes")])
4664 (define_insn "*ashrsi3_64"
4665 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
4667 (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4668 (match_operand:SI 2 "reg_or_cint_operand" "rn"))))
4669 (clobber (reg:SI CA_REGNO))]
4672 [(set_attr "type" "shift")
4673 (set_attr "maybe_var_shift" "yes")])
4675 (define_insn_and_split "*ashr<mode>3_dot"
4676 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4677 (compare:CC (ashiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4678 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4680 (clobber (match_scratch:GPR 0 "=r,r"))
4681 (clobber (reg:GPR CA_REGNO))]
4682 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4684 sra<wd>%I2. %0,%1,%<hH>2
4686 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4687 [(parallel [(set (match_dup 0)
4688 (ashiftrt:GPR (match_dup 1)
4690 (clobber (reg:GPR CA_REGNO))])
4692 (compare:CC (match_dup 0)
4695 [(set_attr "type" "shift")
4696 (set_attr "maybe_var_shift" "yes")
4697 (set_attr "dot" "yes")
4698 (set_attr "length" "4,8")])
4700 (define_insn_and_split "*ashr<mode>3_dot2"
4701 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4702 (compare:CC (ashiftrt:GPR (match_operand:GPR 1 "gpc_reg_operand" "r,r")
4703 (match_operand:SI 2 "reg_or_cint_operand" "rn,rn"))
4705 (set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
4706 (ashiftrt:GPR (match_dup 1)
4708 (clobber (reg:GPR CA_REGNO))]
4709 "<MODE>mode == Pmode && rs6000_gen_cell_microcode"
4711 sra<wd>%I2. %0,%1,%<hH>2
4713 "&& reload_completed && cc_reg_not_cr0_operand (operands[3], CCmode)"
4714 [(parallel [(set (match_dup 0)
4715 (ashiftrt:GPR (match_dup 1)
4717 (clobber (reg:GPR CA_REGNO))])
4719 (compare:CC (match_dup 0)
4722 [(set_attr "type" "shift")
4723 (set_attr "maybe_var_shift" "yes")
4724 (set_attr "dot" "yes")
4725 (set_attr "length" "4,8")])
4727 ;; Builtins to replace a division to generate FRE reciprocal estimate
4728 ;; instructions and the necessary fixup instructions
4729 (define_expand "recip<mode>3"
4730 [(match_operand:RECIPF 0 "gpc_reg_operand" "")
4731 (match_operand:RECIPF 1 "gpc_reg_operand" "")
4732 (match_operand:RECIPF 2 "gpc_reg_operand" "")]
4733 "RS6000_RECIP_HAVE_RE_P (<MODE>mode)"
4735 rs6000_emit_swdiv (operands[0], operands[1], operands[2], false);
4739 ;; Split to create division from FRE/FRES/etc. and fixup instead of the normal
4740 ;; hardware division. This is only done before register allocation and with
4741 ;; -ffast-math. This must appear before the divsf3/divdf3 insns.
4743 [(set (match_operand:RECIPF 0 "gpc_reg_operand" "")
4744 (div:RECIPF (match_operand 1 "gpc_reg_operand" "")
4745 (match_operand 2 "gpc_reg_operand" "")))]
4746 "RS6000_RECIP_AUTO_RE_P (<MODE>mode)
4747 && can_create_pseudo_p () && optimize_insn_for_speed_p ()
4748 && flag_finite_math_only && !flag_trapping_math && flag_reciprocal_math"
4751 rs6000_emit_swdiv (operands[0], operands[1], operands[2], true);
4755 ;; Builtins to replace 1/sqrt(x) with instructions using RSQRTE and the
4756 ;; appropriate fixup.
4757 (define_expand "rsqrt<mode>2"
4758 [(match_operand:RECIPF 0 "gpc_reg_operand" "")
4759 (match_operand:RECIPF 1 "gpc_reg_operand" "")]
4760 "RS6000_RECIP_HAVE_RSQRTE_P (<MODE>mode)"
4762 rs6000_emit_swrsqrt (operands[0], operands[1]);
4766 ;; Floating-point insns, excluding normal data motion. We combine the SF/DF
4767 ;; modes here, and also add in conditional vsx/power8-vector support to access
4768 ;; values in the traditional Altivec registers if the appropriate
4769 ;; -mupper-regs-{df,sf} option is enabled.
4771 (define_expand "abs<mode>2"
4772 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
4773 (abs:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")))]
4774 "TARGET_<MODE>_INSN"
4777 (define_insn "*abs<mode>2_fpr"
4778 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4779 (abs:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")))]
4784 [(set_attr "type" "fp")
4785 (set_attr "fp_type" "fp_addsub_<Fs>")])
4787 (define_insn "*nabs<mode>2_fpr"
4788 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4791 (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>"))))]
4796 [(set_attr "type" "fp")
4797 (set_attr "fp_type" "fp_addsub_<Fs>")])
4799 (define_expand "neg<mode>2"
4800 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
4801 (neg:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")))]
4802 "TARGET_<MODE>_INSN"
4805 (define_insn "*neg<mode>2_fpr"
4806 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4807 (neg:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")))]
4812 [(set_attr "type" "fp")
4813 (set_attr "fp_type" "fp_addsub_<Fs>")])
4815 (define_expand "add<mode>3"
4816 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
4817 (plus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
4818 (match_operand:SFDF 2 "gpc_reg_operand" "")))]
4819 "TARGET_<MODE>_INSN"
4822 (define_insn "*add<mode>3_fpr"
4823 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4824 (plus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
4825 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
4828 fadd<Ftrad> %0,%1,%2
4829 xsadd<Fvsx> %x0,%x1,%x2"
4830 [(set_attr "type" "fp")
4831 (set_attr "fp_type" "fp_addsub_<Fs>")])
4833 (define_expand "sub<mode>3"
4834 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
4835 (minus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
4836 (match_operand:SFDF 2 "gpc_reg_operand" "")))]
4837 "TARGET_<MODE>_INSN"
4840 (define_insn "*sub<mode>3_fpr"
4841 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4842 (minus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
4843 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
4846 fsub<Ftrad> %0,%1,%2
4847 xssub<Fvsx> %x0,%x1,%x2"
4848 [(set_attr "type" "fp")
4849 (set_attr "fp_type" "fp_addsub_<Fs>")])
4851 (define_expand "mul<mode>3"
4852 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
4853 (mult:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
4854 (match_operand:SFDF 2 "gpc_reg_operand" "")))]
4855 "TARGET_<MODE>_INSN"
4858 (define_insn "*mul<mode>3_fpr"
4859 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4860 (mult:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
4861 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
4864 fmul<Ftrad> %0,%1,%2
4865 xsmul<Fvsx> %x0,%x1,%x2"
4866 [(set_attr "type" "dmul")
4867 (set_attr "fp_type" "fp_mul_<Fs>")])
4869 (define_expand "div<mode>3"
4870 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
4871 (div:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
4872 (match_operand:SFDF 2 "gpc_reg_operand" "")))]
4873 "TARGET_<MODE>_INSN && !TARGET_SIMPLE_FPU"
4876 (define_insn "*div<mode>3_fpr"
4877 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4878 (div:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
4879 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
4880 "TARGET_<MODE>_FPR && !TARGET_SIMPLE_FPU"
4882 fdiv<Ftrad> %0,%1,%2
4883 xsdiv<Fvsx> %x0,%x1,%x2"
4884 [(set_attr "type" "<Fs>div")
4885 (set_attr "fp_type" "fp_div_<Fs>")])
4887 (define_insn "sqrt<mode>2"
4888 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4889 (sqrt:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")))]
4890 "TARGET_<MODE>_FPR && !TARGET_SIMPLE_FPU
4891 && (TARGET_PPC_GPOPT || (<MODE>mode == SFmode && TARGET_XILINX_FPU))"
4894 xssqrt<Fvsx> %x0,%x1"
4895 [(set_attr "type" "<Fs>sqrt")
4896 (set_attr "fp_type" "fp_sqrt_<Fs>")])
4898 ;; Floating point reciprocal approximation
4899 (define_insn "fre<Fs>"
4900 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4901 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
4907 [(set_attr "type" "fp")])
4909 (define_insn "*rsqrt<mode>2"
4910 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
4911 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
4913 "RS6000_RECIP_HAVE_RSQRTE_P (<MODE>mode)"
4915 frsqrte<Ftrad> %0,%1
4916 xsrsqrte<Fvsx> %x0,%x1"
4917 [(set_attr "type" "fp")])
4919 ;; Floating point comparisons
4920 (define_insn "*cmp<mode>_fpr"
4921 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y,y")
4922 (compare:CCFP (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
4923 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
4927 xscmpudp %0,%x1,%x2"
4928 [(set_attr "type" "fpcompare")])
4930 ;; Floating point conversions
4931 (define_expand "extendsfdf2"
4932 [(set (match_operand:DF 0 "gpc_reg_operand" "")
4933 (float_extend:DF (match_operand:SF 1 "reg_or_none500mem_operand" "")))]
4934 "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
4937 (define_insn_and_split "*extendsfdf2_fpr"
4938 [(set (match_operand:DF 0 "gpc_reg_operand" "=d,?d,d,ws,?ws,wv")
4939 (float_extend:DF (match_operand:SF 1 "reg_or_mem_operand" "0,f,m,0,wy,Z")))]
4940 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
4948 "&& reload_completed && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])"
4951 emit_note (NOTE_INSN_DELETED);
4954 [(set_attr "type" "fp,fp,fpload,fp,vecsimple,fpload")])
4956 (define_expand "truncdfsf2"
4957 [(set (match_operand:SF 0 "gpc_reg_operand" "")
4958 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "")))]
4959 "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
4962 (define_insn "*truncdfsf2_fpr"
4963 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4964 (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "d")))]
4965 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
4967 [(set_attr "type" "fp")])
4969 ;; This expander is here to avoid FLOAT_WORDS_BIGENDIAN tests in
4970 ;; builtins.c and optabs.c that are not correct for IBM long double
4971 ;; when little-endian.
4972 (define_expand "signbittf2"
4974 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))
4976 (subreg:DI (match_dup 2) 0))
4979 (set (match_operand:SI 0 "gpc_reg_operand" "")
4982 && TARGET_HARD_FLOAT
4983 && (TARGET_FPRS || TARGET_E500_DOUBLE)
4984 && TARGET_LONG_DOUBLE_128"
4986 operands[2] = gen_reg_rtx (DFmode);
4987 operands[3] = gen_reg_rtx (DImode);
4988 if (TARGET_POWERPC64)
4990 operands[4] = gen_reg_rtx (DImode);
4991 operands[5] = gen_rtx_LSHIFTRT (DImode, operands[3], GEN_INT (63));
4992 operands[6] = gen_rtx_SUBREG (SImode, operands[4],
4993 WORDS_BIG_ENDIAN ? 4 : 0);
4997 operands[4] = gen_reg_rtx (SImode);
4998 operands[5] = gen_rtx_SUBREG (SImode, operands[3],
4999 WORDS_BIG_ENDIAN ? 0 : 4);
5000 operands[6] = gen_rtx_LSHIFTRT (SImode, operands[4], GEN_INT (31));
5004 (define_expand "copysign<mode>3"
5006 (abs:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")))
5008 (neg:SFDF (abs:SFDF (match_dup 1))))
5009 (set (match_operand:SFDF 0 "gpc_reg_operand" "")
5010 (if_then_else:SFDF (ge (match_operand:SFDF 2 "gpc_reg_operand" "")
5014 "TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT>
5015 && ((TARGET_PPC_GFXOPT
5016 && !HONOR_NANS (<MODE>mode)
5017 && !HONOR_SIGNED_ZEROS (<MODE>mode))
5019 || VECTOR_UNIT_VSX_P (<MODE>mode))"
5021 if (TARGET_CMPB || VECTOR_UNIT_VSX_P (<MODE>mode))
5023 emit_insn (gen_copysign<mode>3_fcpsgn (operands[0], operands[1],
5028 operands[3] = gen_reg_rtx (<MODE>mode);
5029 operands[4] = gen_reg_rtx (<MODE>mode);
5030 operands[5] = CONST0_RTX (<MODE>mode);
5033 ;; Use an unspec rather providing an if-then-else in RTL, to prevent the
5034 ;; compiler from optimizing -0.0
5035 (define_insn "copysign<mode>3_fcpsgn"
5036 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5037 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
5038 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")]
5040 "TARGET_<MODE>_FPR && TARGET_CMPB"
5043 xscpsgn<Fvsx> %x0,%x2,%x1"
5044 [(set_attr "type" "fp")])
5046 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
5047 ;; fsel instruction and some auxiliary computations. Then we just have a
5048 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
5050 ;; For MIN, MAX on non-VSX machines, and conditional move all of the time, we
5051 ;; use DEFINE_EXPAND's that involve a fsel instruction and some auxiliary
5052 ;; computations. Then we just have a single DEFINE_INSN for fsel and the
5053 ;; define_splits to make them if made by combine. On VSX machines we have the
5054 ;; min/max instructions.
5056 ;; On VSX, we only check for TARGET_VSX instead of checking for a vsx/p8 vector
5057 ;; to allow either DF/SF to use only traditional registers.
5059 (define_expand "smax<mode>3"
5060 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5061 (if_then_else:SFDF (ge (match_operand:SFDF 1 "gpc_reg_operand" "")
5062 (match_operand:SFDF 2 "gpc_reg_operand" ""))
5065 "TARGET_<MODE>_FPR && TARGET_PPC_GFXOPT && !flag_trapping_math"
5067 rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
5071 (define_insn "*smax<mode>3_vsx"
5072 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5073 (smax:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
5074 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
5075 "TARGET_<MODE>_FPR && TARGET_VSX"
5076 "xsmaxdp %x0,%x1,%x2"
5077 [(set_attr "type" "fp")])
5079 (define_expand "smin<mode>3"
5080 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5081 (if_then_else:SFDF (ge (match_operand:SFDF 1 "gpc_reg_operand" "")
5082 (match_operand:SFDF 2 "gpc_reg_operand" ""))
5085 "TARGET_<MODE>_FPR && TARGET_PPC_GFXOPT && !flag_trapping_math"
5087 rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
5091 (define_insn "*smin<mode>3_vsx"
5092 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5093 (smin:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
5094 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
5095 "TARGET_<MODE>_FPR && TARGET_VSX"
5096 "xsmindp %x0,%x1,%x2"
5097 [(set_attr "type" "fp")])
5100 [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
5101 (match_operator:SFDF 3 "min_max_operator"
5102 [(match_operand:SFDF 1 "gpc_reg_operand" "")
5103 (match_operand:SFDF 2 "gpc_reg_operand" "")]))]
5104 "TARGET_<MODE>_FPR && TARGET_PPC_GFXOPT && !flag_trapping_math
5108 rs6000_emit_minmax (operands[0], GET_CODE (operands[3]), operands[1],
5114 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5115 (match_operator:SF 3 "min_max_operator"
5116 [(match_operand:SF 1 "gpc_reg_operand" "")
5117 (match_operand:SF 2 "gpc_reg_operand" "")]))]
5118 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS
5119 && TARGET_SINGLE_FLOAT && !flag_trapping_math"
5122 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
5123 operands[1], operands[2]);
5127 (define_expand "mov<mode>cc"
5128 [(set (match_operand:GPR 0 "gpc_reg_operand" "")
5129 (if_then_else:GPR (match_operand 1 "comparison_operator" "")
5130 (match_operand:GPR 2 "gpc_reg_operand" "")
5131 (match_operand:GPR 3 "gpc_reg_operand" "")))]
5135 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5141 ;; We use the BASE_REGS for the isel input operands because, if rA is
5142 ;; 0, the value of 0 is placed in rD upon truth. Similarly for rB
5143 ;; because we may switch the operands and rB may end up being rA.
5145 ;; We need 2 patterns: an unsigned and a signed pattern. We could
5146 ;; leave out the mode in operand 4 and use one pattern, but reload can
5147 ;; change the mode underneath our feet and then gets confused trying
5148 ;; to reload the value.
5149 (define_insn "isel_signed_<mode>"
5150 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
5152 (match_operator 1 "scc_comparison_operator"
5153 [(match_operand:CC 4 "cc_reg_operand" "y,y")
5155 (match_operand:GPR 2 "reg_or_cint_operand" "O,b")
5156 (match_operand:GPR 3 "gpc_reg_operand" "r,r")))]
5159 { return output_isel (operands); }"
5160 [(set_attr "type" "isel")
5161 (set_attr "length" "4")])
5163 (define_insn "isel_unsigned_<mode>"
5164 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r,r")
5166 (match_operator 1 "scc_comparison_operator"
5167 [(match_operand:CCUNS 4 "cc_reg_operand" "y,y")
5169 (match_operand:GPR 2 "reg_or_cint_operand" "O,b")
5170 (match_operand:GPR 3 "gpc_reg_operand" "r,r")))]
5173 { return output_isel (operands); }"
5174 [(set_attr "type" "isel")
5175 (set_attr "length" "4")])
5177 ;; These patterns can be useful for combine; they let combine know that
5178 ;; isel can handle reversed comparisons so long as the operands are
5181 (define_insn "*isel_reversed_signed_<mode>"
5182 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
5184 (match_operator 1 "scc_rev_comparison_operator"
5185 [(match_operand:CC 4 "cc_reg_operand" "y")
5187 (match_operand:GPR 2 "gpc_reg_operand" "b")
5188 (match_operand:GPR 3 "gpc_reg_operand" "b")))]
5191 { return output_isel (operands); }"
5192 [(set_attr "type" "isel")
5193 (set_attr "length" "4")])
5195 (define_insn "*isel_reversed_unsigned_<mode>"
5196 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
5198 (match_operator 1 "scc_rev_comparison_operator"
5199 [(match_operand:CCUNS 4 "cc_reg_operand" "y")
5201 (match_operand:GPR 2 "gpc_reg_operand" "b")
5202 (match_operand:GPR 3 "gpc_reg_operand" "b")))]
5205 { return output_isel (operands); }"
5206 [(set_attr "type" "isel")
5207 (set_attr "length" "4")])
5209 (define_expand "movsfcc"
5210 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5211 (if_then_else:SF (match_operand 1 "comparison_operator" "")
5212 (match_operand:SF 2 "gpc_reg_operand" "")
5213 (match_operand:SF 3 "gpc_reg_operand" "")))]
5214 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
5217 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5223 (define_insn "*fselsfsf4"
5224 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5225 (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5226 (match_operand:SF 4 "zero_fp_constant" "F"))
5227 (match_operand:SF 2 "gpc_reg_operand" "f")
5228 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5229 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
5231 [(set_attr "type" "fp")])
5233 (define_insn "*fseldfsf4"
5234 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5235 (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "d")
5236 (match_operand:DF 4 "zero_fp_constant" "F"))
5237 (match_operand:SF 2 "gpc_reg_operand" "f")
5238 (match_operand:SF 3 "gpc_reg_operand" "f")))]
5239 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_SINGLE_FLOAT"
5241 [(set_attr "type" "fp")])
5243 ;; The conditional move instructions allow us to perform max and min
5244 ;; operations even when
5247 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5248 (match_operator:DF 3 "min_max_operator"
5249 [(match_operand:DF 1 "gpc_reg_operand" "")
5250 (match_operand:DF 2 "gpc_reg_operand" "")]))]
5251 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
5252 && !flag_trapping_math"
5255 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
5256 operands[1], operands[2]);
5260 (define_expand "movdfcc"
5261 [(set (match_operand:DF 0 "gpc_reg_operand" "")
5262 (if_then_else:DF (match_operand 1 "comparison_operator" "")
5263 (match_operand:DF 2 "gpc_reg_operand" "")
5264 (match_operand:DF 3 "gpc_reg_operand" "")))]
5265 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5268 if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5274 (define_insn "*fseldfdf4"
5275 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
5276 (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "d")
5277 (match_operand:DF 4 "zero_fp_constant" "F"))
5278 (match_operand:DF 2 "gpc_reg_operand" "d")
5279 (match_operand:DF 3 "gpc_reg_operand" "d")))]
5280 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5282 [(set_attr "type" "fp")])
5284 (define_insn "*fselsfdf4"
5285 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
5286 (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5287 (match_operand:SF 4 "zero_fp_constant" "F"))
5288 (match_operand:DF 2 "gpc_reg_operand" "d")
5289 (match_operand:DF 3 "gpc_reg_operand" "d")))]
5290 "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_SINGLE_FLOAT"
5292 [(set_attr "type" "fp")])
5294 ;; Conversions to and from floating-point.
5296 ; We don't define lfiwax/lfiwzx with the normal definition, because we
5297 ; don't want to support putting SImode in FPR registers.
5298 (define_insn "lfiwax"
5299 [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wj,!wj")
5300 (unspec:DI [(match_operand:SI 1 "reg_or_indexed_operand" "Z,Z,r")]
5302 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWAX"
5307 [(set_attr "type" "fpload,fpload,mffgpr")])
5309 ; This split must be run before register allocation because it allocates the
5310 ; memory slot that is needed to move values to/from the FPR. We don't allocate
5311 ; it earlier to allow for the combiner to merge insns together where it might
5312 ; not be needed and also in case the insns are deleted as dead code.
5314 (define_insn_and_split "floatsi<mode>2_lfiwax"
5315 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d")
5316 (float:SFDF (match_operand:SI 1 "nonimmediate_operand" "r")))
5317 (clobber (match_scratch:DI 2 "=d"))]
5318 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWAX
5319 && <SI_CONVERT_FP> && can_create_pseudo_p ()"
5325 rtx dest = operands[0];
5326 rtx src = operands[1];
5329 if (!MEM_P (src) && TARGET_POWERPC64
5330 && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
5331 tmp = convert_to_mode (DImode, src, false);
5335 if (GET_CODE (tmp) == SCRATCH)
5336 tmp = gen_reg_rtx (DImode);
5339 src = rs6000_address_for_fpconvert (src);
5340 emit_insn (gen_lfiwax (tmp, src));
5344 rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5345 emit_move_insn (stack, src);
5346 emit_insn (gen_lfiwax (tmp, stack));
5349 emit_insn (gen_floatdi<mode>2 (dest, tmp));
5352 [(set_attr "length" "12")
5353 (set_attr "type" "fpload")])
5355 (define_insn_and_split "floatsi<mode>2_lfiwax_mem"
5356 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d,<rreg2>")
5359 (match_operand:SI 1 "indexed_or_indirect_operand" "Z,Z"))))
5360 (clobber (match_scratch:DI 2 "=0,d"))]
5361 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWAX
5368 operands[1] = rs6000_address_for_fpconvert (operands[1]);
5369 if (GET_CODE (operands[2]) == SCRATCH)
5370 operands[2] = gen_reg_rtx (DImode);
5371 emit_insn (gen_lfiwax (operands[2], operands[1]));
5372 emit_insn (gen_floatdi<mode>2 (operands[0], operands[2]));
5375 [(set_attr "length" "8")
5376 (set_attr "type" "fpload")])
5378 (define_insn "lfiwzx"
5379 [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wj,!wj")
5380 (unspec:DI [(match_operand:SI 1 "reg_or_indexed_operand" "Z,Z,r")]
5382 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWZX"
5387 [(set_attr "type" "fpload,fpload,mftgpr")])
5389 (define_insn_and_split "floatunssi<mode>2_lfiwzx"
5390 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d")
5391 (unsigned_float:SFDF (match_operand:SI 1 "nonimmediate_operand" "r")))
5392 (clobber (match_scratch:DI 2 "=d"))]
5393 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWZX
5400 rtx dest = operands[0];
5401 rtx src = operands[1];
5404 if (!MEM_P (src) && TARGET_POWERPC64
5405 && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
5406 tmp = convert_to_mode (DImode, src, true);
5410 if (GET_CODE (tmp) == SCRATCH)
5411 tmp = gen_reg_rtx (DImode);
5414 src = rs6000_address_for_fpconvert (src);
5415 emit_insn (gen_lfiwzx (tmp, src));
5419 rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5420 emit_move_insn (stack, src);
5421 emit_insn (gen_lfiwzx (tmp, stack));
5424 emit_insn (gen_floatdi<mode>2 (dest, tmp));
5427 [(set_attr "length" "12")
5428 (set_attr "type" "fpload")])
5430 (define_insn_and_split "floatunssi<mode>2_lfiwzx_mem"
5431 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d,<rreg2>")
5432 (unsigned_float:SFDF
5434 (match_operand:SI 1 "indexed_or_indirect_operand" "Z,Z"))))
5435 (clobber (match_scratch:DI 2 "=0,d"))]
5436 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWZX
5443 operands[1] = rs6000_address_for_fpconvert (operands[1]);
5444 if (GET_CODE (operands[2]) == SCRATCH)
5445 operands[2] = gen_reg_rtx (DImode);
5446 emit_insn (gen_lfiwzx (operands[2], operands[1]));
5447 emit_insn (gen_floatdi<mode>2 (operands[0], operands[2]));
5450 [(set_attr "length" "8")
5451 (set_attr "type" "fpload")])
5453 ; For each of these conversions, there is a define_expand, a define_insn
5454 ; with a '#' template, and a define_split (with C code). The idea is
5455 ; to allow constant folding with the template of the define_insn,
5456 ; then to have the insns split later (between sched1 and final).
5458 (define_expand "floatsidf2"
5459 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5460 (float:DF (match_operand:SI 1 "nonimmediate_operand" "")))
5463 (clobber (match_dup 4))
5464 (clobber (match_dup 5))
5465 (clobber (match_dup 6))])]
5467 && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
5470 if (TARGET_E500_DOUBLE)
5472 if (!REG_P (operands[1]))
5473 operands[1] = force_reg (SImode, operands[1]);
5474 emit_insn (gen_spe_floatsidf2 (operands[0], operands[1]));
5477 else if (TARGET_LFIWAX && TARGET_FCFID)
5479 emit_insn (gen_floatsidf2_lfiwax (operands[0], operands[1]));
5482 else if (TARGET_FCFID)
5484 rtx dreg = operands[1];
5486 dreg = force_reg (SImode, dreg);
5487 dreg = convert_to_mode (DImode, dreg, false);
5488 emit_insn (gen_floatdidf2 (operands[0], dreg));
5492 if (!REG_P (operands[1]))
5493 operands[1] = force_reg (SImode, operands[1]);
5494 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5495 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503601774854144\", DFmode));
5496 operands[4] = rs6000_allocate_stack_temp (DFmode, true, false);
5497 operands[5] = gen_reg_rtx (DFmode);
5498 operands[6] = gen_reg_rtx (SImode);
5501 (define_insn_and_split "*floatsidf2_internal"
5502 [(set (match_operand:DF 0 "gpc_reg_operand" "=&d")
5503 (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5504 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5505 (use (match_operand:DF 3 "gpc_reg_operand" "d"))
5506 (clobber (match_operand:DF 4 "offsettable_mem_operand" "=o"))
5507 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&d"))
5508 (clobber (match_operand:SI 6 "gpc_reg_operand" "=&r"))]
5509 "! TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5515 rtx lowword, highword;
5516 gcc_assert (MEM_P (operands[4]));
5517 highword = adjust_address (operands[4], SImode, 0);
5518 lowword = adjust_address (operands[4], SImode, 4);
5519 if (! WORDS_BIG_ENDIAN)
5522 tmp = highword; highword = lowword; lowword = tmp;
5525 emit_insn (gen_xorsi3 (operands[6], operands[1],
5526 GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
5527 emit_move_insn (lowword, operands[6]);
5528 emit_move_insn (highword, operands[2]);
5529 emit_move_insn (operands[5], operands[4]);
5530 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5533 [(set_attr "length" "24")
5534 (set_attr "type" "fp")])
5536 ;; If we don't have a direct conversion to single precision, don't enable this
5537 ;; conversion for 32-bit without fast math, because we don't have the insn to
5538 ;; generate the fixup swizzle to avoid double rounding problems.
5539 (define_expand "floatunssisf2"
5540 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5541 (unsigned_float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
5542 "TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT
5545 && ((TARGET_FCFIDUS && TARGET_LFIWZX)
5546 || (TARGET_DOUBLE_FLOAT && TARGET_FCFID
5547 && (TARGET_POWERPC64 || flag_unsafe_math_optimizations)))))"
5552 if (!REG_P (operands[1]))
5553 operands[1] = force_reg (SImode, operands[1]);
5555 else if (TARGET_LFIWZX && TARGET_FCFIDUS)
5557 emit_insn (gen_floatunssisf2_lfiwzx (operands[0], operands[1]));
5562 rtx dreg = operands[1];
5564 dreg = force_reg (SImode, dreg);
5565 dreg = convert_to_mode (DImode, dreg, true);
5566 emit_insn (gen_floatdisf2 (operands[0], dreg));
5571 (define_expand "floatunssidf2"
5572 [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5573 (unsigned_float:DF (match_operand:SI 1 "nonimmediate_operand" "")))
5576 (clobber (match_dup 4))
5577 (clobber (match_dup 5))])]
5579 && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
5582 if (TARGET_E500_DOUBLE)
5584 if (!REG_P (operands[1]))
5585 operands[1] = force_reg (SImode, operands[1]);
5586 emit_insn (gen_spe_floatunssidf2 (operands[0], operands[1]));
5589 else if (TARGET_LFIWZX && TARGET_FCFID)
5591 emit_insn (gen_floatunssidf2_lfiwzx (operands[0], operands[1]));
5594 else if (TARGET_FCFID)
5596 rtx dreg = operands[1];
5598 dreg = force_reg (SImode, dreg);
5599 dreg = convert_to_mode (DImode, dreg, true);
5600 emit_insn (gen_floatdidf2 (operands[0], dreg));
5604 if (!REG_P (operands[1]))
5605 operands[1] = force_reg (SImode, operands[1]);
5606 operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5607 operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503599627370496\", DFmode));
5608 operands[4] = rs6000_allocate_stack_temp (DFmode, true, false);
5609 operands[5] = gen_reg_rtx (DFmode);
5612 (define_insn_and_split "*floatunssidf2_internal"
5613 [(set (match_operand:DF 0 "gpc_reg_operand" "=&d")
5614 (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5615 (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5616 (use (match_operand:DF 3 "gpc_reg_operand" "d"))
5617 (clobber (match_operand:DF 4 "offsettable_mem_operand" "=o"))
5618 (clobber (match_operand:DF 5 "gpc_reg_operand" "=&d"))]
5619 "! TARGET_FCFIDU && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
5620 && !(TARGET_FCFID && TARGET_POWERPC64)"
5626 rtx lowword, highword;
5627 gcc_assert (MEM_P (operands[4]));
5628 highword = adjust_address (operands[4], SImode, 0);
5629 lowword = adjust_address (operands[4], SImode, 4);
5630 if (! WORDS_BIG_ENDIAN)
5633 tmp = highword; highword = lowword; lowword = tmp;
5636 emit_move_insn (lowword, operands[1]);
5637 emit_move_insn (highword, operands[2]);
5638 emit_move_insn (operands[5], operands[4]);
5639 emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5642 [(set_attr "length" "20")
5643 (set_attr "type" "fp")])
5645 (define_expand "fix_trunc<mode>si2"
5646 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5647 (fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "")))]
5648 "TARGET_HARD_FLOAT && ((TARGET_FPRS && <TARGET_FLOAT>) || <E500_CONVERT>)"
5651 if (!<E500_CONVERT>)
5656 emit_insn (gen_fix_trunc<mode>si2_stfiwx (operands[0], operands[1]));
5659 tmp = gen_reg_rtx (DImode);
5660 stack = rs6000_allocate_stack_temp (DImode, true, false);
5661 emit_insn (gen_fix_trunc<mode>si2_internal (operands[0], operands[1],
5668 ; Like the convert to float patterns, this insn must be split before
5669 ; register allocation so that it can allocate the memory slot if it
5671 (define_insn_and_split "fix_trunc<mode>si2_stfiwx"
5672 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5673 (fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d")))
5674 (clobber (match_scratch:DI 2 "=d"))]
5675 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
5676 && (<MODE>mode != SFmode || TARGET_SINGLE_FLOAT)
5677 && TARGET_STFIWX && can_create_pseudo_p ()"
5682 rtx dest = operands[0];
5683 rtx src = operands[1];
5684 rtx tmp = operands[2];
5686 if (GET_CODE (tmp) == SCRATCH)
5687 tmp = gen_reg_rtx (DImode);
5689 emit_insn (gen_fctiwz_<mode> (tmp, src));
5692 dest = rs6000_address_for_fpconvert (dest);
5693 emit_insn (gen_stfiwx (dest, tmp));
5696 else if (TARGET_POWERPC64 && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
5698 dest = gen_lowpart (DImode, dest);
5699 emit_move_insn (dest, tmp);
5704 rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5705 emit_insn (gen_stfiwx (stack, tmp));
5706 emit_move_insn (dest, stack);
5710 [(set_attr "length" "12")
5711 (set_attr "type" "fp")])
5713 (define_insn_and_split "fix_trunc<mode>si2_internal"
5714 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,?r")
5715 (fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d,<rreg>")))
5716 (clobber (match_operand:DI 2 "gpc_reg_operand" "=1,d"))
5717 (clobber (match_operand:DI 3 "offsettable_mem_operand" "=o,o"))]
5718 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5725 gcc_assert (MEM_P (operands[3]));
5726 lowword = adjust_address (operands[3], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
5728 emit_insn (gen_fctiwz_<mode> (operands[2], operands[1]));
5729 emit_move_insn (operands[3], operands[2]);
5730 emit_move_insn (operands[0], lowword);
5733 [(set_attr "length" "16")
5734 (set_attr "type" "fp")])
5736 (define_expand "fix_trunc<mode>di2"
5737 [(set (match_operand:DI 0 "gpc_reg_operand" "")
5738 (fix:DI (match_operand:SFDF 1 "gpc_reg_operand" "")))]
5739 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS
5743 (define_insn "*fix_trunc<mode>di2_fctidz"
5744 [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
5745 (fix:DI (match_operand:SFDF 1 "gpc_reg_operand" "d")))]
5746 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS
5747 && TARGET_FCFID && !VECTOR_UNIT_VSX_P (<MODE>mode)"
5749 [(set_attr "type" "fp")])
5751 (define_expand "fixuns_trunc<mode>si2"
5752 [(set (match_operand:SI 0 "gpc_reg_operand" "")
5753 (unsigned_fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "")))]
5755 && ((TARGET_FPRS && <TARGET_FLOAT> && TARGET_FCTIWUZ && TARGET_STFIWX)
5759 if (!<E500_CONVERT>)
5761 emit_insn (gen_fixuns_trunc<mode>si2_stfiwx (operands[0], operands[1]));
5766 (define_insn_and_split "fixuns_trunc<mode>si2_stfiwx"
5767 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5768 (unsigned_fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d")))
5769 (clobber (match_scratch:DI 2 "=d"))]
5770 "TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT> && TARGET_FCTIWUZ
5771 && TARGET_STFIWX && can_create_pseudo_p ()"
5776 rtx dest = operands[0];
5777 rtx src = operands[1];
5778 rtx tmp = operands[2];
5780 if (GET_CODE (tmp) == SCRATCH)
5781 tmp = gen_reg_rtx (DImode);
5783 emit_insn (gen_fctiwuz_<mode> (tmp, src));
5786 dest = rs6000_address_for_fpconvert (dest);
5787 emit_insn (gen_stfiwx (dest, tmp));
5790 else if (TARGET_POWERPC64 && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
5792 dest = gen_lowpart (DImode, dest);
5793 emit_move_insn (dest, tmp);
5798 rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5799 emit_insn (gen_stfiwx (stack, tmp));
5800 emit_move_insn (dest, stack);
5804 [(set_attr "length" "12")
5805 (set_attr "type" "fp")])
5807 (define_expand "fixuns_trunc<mode>di2"
5808 [(set (match_operand:DI 0 "register_operand" "")
5809 (unsigned_fix:DI (match_operand:SFDF 1 "register_operand" "")))]
5810 "TARGET_HARD_FLOAT && (TARGET_FCTIDUZ || VECTOR_UNIT_VSX_P (<MODE>mode))"
5813 (define_insn "*fixuns_trunc<mode>di2_fctiduz"
5814 [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
5815 (unsigned_fix:DI (match_operand:SFDF 1 "gpc_reg_operand" "d")))]
5816 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS
5817 && TARGET_FCTIDUZ && !VECTOR_UNIT_VSX_P (<MODE>mode)"
5819 [(set_attr "type" "fp")])
5821 ; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] UNSPEC_FCTIWZ))
5822 ; rather than (set (subreg:SI (reg)) (fix:SI ...))
5823 ; because the first makes it clear that operand 0 is not live
5824 ; before the instruction.
5825 (define_insn "fctiwz_<mode>"
5826 [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
5827 (unspec:DI [(fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d"))]
5829 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
5831 [(set_attr "type" "fp")])
5833 (define_insn "fctiwuz_<mode>"
5834 [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
5835 (unspec:DI [(unsigned_fix:SI
5836 (match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>"))]
5838 "TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT> && TARGET_FCTIWUZ"
5840 [(set_attr "type" "fp")])
5842 ;; Only optimize (float (fix x)) -> frz if we are in fast-math mode, since
5843 ;; since the friz instruction does not truncate the value if the floating
5844 ;; point value is < LONG_MIN or > LONG_MAX.
5845 (define_insn "*friz"
5846 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
5847 (float:DF (fix:DI (match_operand:DF 1 "gpc_reg_operand" "d"))))]
5848 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_FPRND
5849 && !VECTOR_UNIT_VSX_P (DFmode) && flag_unsafe_math_optimizations
5850 && !flag_trapping_math && TARGET_FRIZ"
5852 [(set_attr "type" "fp")])
5854 ;; Since FCTIWZ doesn't sign extend the upper bits, we have to do a store and a
5855 ;; load to properly sign extend the value, but at least doing a store, load
5856 ;; into a GPR to sign extend, a store from the GPR and a load back into the FPR
5857 ;; if we have 32-bit memory ops
5858 (define_insn_and_split "*round32<mode>2_fprs"
5859 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d")
5861 (fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d"))))
5862 (clobber (match_scratch:DI 2 "=d"))
5863 (clobber (match_scratch:DI 3 "=d"))]
5864 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
5865 && <SI_CONVERT_FP> && TARGET_LFIWAX && TARGET_STFIWX && TARGET_FCFID
5866 && can_create_pseudo_p ()"
5871 rtx dest = operands[0];
5872 rtx src = operands[1];
5873 rtx tmp1 = operands[2];
5874 rtx tmp2 = operands[3];
5875 rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5877 if (GET_CODE (tmp1) == SCRATCH)
5878 tmp1 = gen_reg_rtx (DImode);
5879 if (GET_CODE (tmp2) == SCRATCH)
5880 tmp2 = gen_reg_rtx (DImode);
5882 emit_insn (gen_fctiwz_<mode> (tmp1, src));
5883 emit_insn (gen_stfiwx (stack, tmp1));
5884 emit_insn (gen_lfiwax (tmp2, stack));
5885 emit_insn (gen_floatdi<mode>2 (dest, tmp2));
5888 [(set_attr "type" "fpload")
5889 (set_attr "length" "16")])
5891 (define_insn_and_split "*roundu32<mode>2_fprs"
5892 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d")
5893 (unsigned_float:SFDF
5894 (unsigned_fix:SI (match_operand:SFDF 1 "gpc_reg_operand" "d"))))
5895 (clobber (match_scratch:DI 2 "=d"))
5896 (clobber (match_scratch:DI 3 "=d"))]
5897 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
5898 && TARGET_LFIWZX && TARGET_STFIWX && TARGET_FCFIDU
5899 && can_create_pseudo_p ()"
5904 rtx dest = operands[0];
5905 rtx src = operands[1];
5906 rtx tmp1 = operands[2];
5907 rtx tmp2 = operands[3];
5908 rtx stack = rs6000_allocate_stack_temp (SImode, false, true);
5910 if (GET_CODE (tmp1) == SCRATCH)
5911 tmp1 = gen_reg_rtx (DImode);
5912 if (GET_CODE (tmp2) == SCRATCH)
5913 tmp2 = gen_reg_rtx (DImode);
5915 emit_insn (gen_fctiwuz_<mode> (tmp1, src));
5916 emit_insn (gen_stfiwx (stack, tmp1));
5917 emit_insn (gen_lfiwzx (tmp2, stack));
5918 emit_insn (gen_floatdi<mode>2 (dest, tmp2));
5921 [(set_attr "type" "fpload")
5922 (set_attr "length" "16")])
5924 ;; No VSX equivalent to fctid
5925 (define_insn "lrint<mode>di2"
5926 [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
5927 (unspec:DI [(match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>")]
5929 "TARGET_<MODE>_FPR && TARGET_FPRND"
5931 [(set_attr "type" "fp")])
5933 (define_insn "btrunc<mode>2"
5934 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5935 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
5937 "TARGET_<MODE>_FPR && TARGET_FPRND"
5941 [(set_attr "type" "fp")
5942 (set_attr "fp_type" "fp_addsub_<Fs>")])
5944 (define_insn "ceil<mode>2"
5945 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5946 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
5948 "TARGET_<MODE>_FPR && TARGET_FPRND"
5952 [(set_attr "type" "fp")
5953 (set_attr "fp_type" "fp_addsub_<Fs>")])
5955 (define_insn "floor<mode>2"
5956 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
5957 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
5959 "TARGET_<MODE>_FPR && TARGET_FPRND"
5963 [(set_attr "type" "fp")
5964 (set_attr "fp_type" "fp_addsub_<Fs>")])
5966 ;; No VSX equivalent to frin
5967 (define_insn "round<mode>2"
5968 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<rreg2>")
5969 (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>")]
5971 "TARGET_<MODE>_FPR && TARGET_FPRND"
5973 [(set_attr "type" "fp")
5974 (set_attr "fp_type" "fp_addsub_<Fs>")])
5976 ; An UNSPEC is used so we don't have to support SImode in FP registers.
5977 (define_insn "stfiwx"
5978 [(set (match_operand:SI 0 "memory_operand" "=Z")
5979 (unspec:SI [(match_operand:DI 1 "gpc_reg_operand" "d")]
5983 [(set_attr "type" "fpstore")])
5985 ;; If we don't have a direct conversion to single precision, don't enable this
5986 ;; conversion for 32-bit without fast math, because we don't have the insn to
5987 ;; generate the fixup swizzle to avoid double rounding problems.
5988 (define_expand "floatsisf2"
5989 [(set (match_operand:SF 0 "gpc_reg_operand" "")
5990 (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
5991 "TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT
5994 && ((TARGET_FCFIDS && TARGET_LFIWAX)
5995 || (TARGET_DOUBLE_FLOAT && TARGET_FCFID
5996 && (TARGET_POWERPC64 || flag_unsafe_math_optimizations)))))"
6001 if (!REG_P (operands[1]))
6002 operands[1] = force_reg (SImode, operands[1]);
6004 else if (TARGET_FCFIDS && TARGET_LFIWAX)
6006 emit_insn (gen_floatsisf2_lfiwax (operands[0], operands[1]));
6009 else if (TARGET_FCFID && TARGET_LFIWAX)
6011 rtx dfreg = gen_reg_rtx (DFmode);
6012 emit_insn (gen_floatsidf2_lfiwax (dfreg, operands[1]));
6013 emit_insn (gen_truncdfsf2 (operands[0], dfreg));
6018 rtx dreg = operands[1];
6020 dreg = force_reg (SImode, dreg);
6021 dreg = convert_to_mode (DImode, dreg, false);
6022 emit_insn (gen_floatdisf2 (operands[0], dreg));
6027 (define_expand "floatdidf2"
6028 [(set (match_operand:DF 0 "gpc_reg_operand" "")
6029 (float:DF (match_operand:DI 1 "gpc_reg_operand" "")))]
6030 "TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS"
6033 (define_insn "*floatdidf2_fpr"
6034 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
6035 (float:DF (match_operand:DI 1 "gpc_reg_operand" "d")))]
6036 "TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS
6037 && !VECTOR_UNIT_VSX_P (DFmode)"
6039 [(set_attr "type" "fp")])
6041 ; Allow the combiner to merge source memory operands to the conversion so that
6042 ; the optimizer/register allocator doesn't try to load the value too early in a
6043 ; GPR and then use store/load to move it to a FPR and suffer from a store-load
6044 ; hit. We will split after reload to avoid the trip through the GPRs
6046 (define_insn_and_split "*floatdidf2_mem"
6047 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
6048 (float:DF (match_operand:DI 1 "memory_operand" "m")))
6049 (clobber (match_scratch:DI 2 "=d"))]
6050 "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT && TARGET_FPRS && TARGET_FCFID"
6052 "&& reload_completed"
6053 [(set (match_dup 2) (match_dup 1))
6054 (set (match_dup 0) (float:DF (match_dup 2)))]
6056 [(set_attr "length" "8")
6057 (set_attr "type" "fpload")])
6059 (define_expand "floatunsdidf2"
6060 [(set (match_operand:DF 0 "gpc_reg_operand" "")
6062 (match_operand:DI 1 "gpc_reg_operand" "")))]
6063 "TARGET_HARD_FLOAT && (TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode))"
6066 (define_insn "*floatunsdidf2_fcfidu"
6067 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
6068 (unsigned_float:DF (match_operand:DI 1 "gpc_reg_operand" "d")))]
6069 "TARGET_HARD_FLOAT && TARGET_FCFIDU && !VECTOR_UNIT_VSX_P (DFmode)"
6071 [(set_attr "type" "fp")
6072 (set_attr "length" "4")])
6074 (define_insn_and_split "*floatunsdidf2_mem"
6075 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
6076 (unsigned_float:DF (match_operand:DI 1 "memory_operand" "m")))
6077 (clobber (match_scratch:DI 2 "=d"))]
6078 "TARGET_HARD_FLOAT && (TARGET_FCFIDU || VECTOR_UNIT_VSX_P (DFmode))"
6080 "&& reload_completed"
6081 [(set (match_dup 2) (match_dup 1))
6082 (set (match_dup 0) (unsigned_float:DF (match_dup 2)))]
6084 [(set_attr "length" "8")
6085 (set_attr "type" "fpload")])
6087 (define_expand "floatdisf2"
6088 [(set (match_operand:SF 0 "gpc_reg_operand" "")
6089 (float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
6090 "TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6091 && (TARGET_FCFIDS || TARGET_POWERPC64 || flag_unsafe_math_optimizations)"
6096 rtx val = operands[1];
6097 if (!flag_unsafe_math_optimizations)
6099 rtx label = gen_label_rtx ();
6100 val = gen_reg_rtx (DImode);
6101 emit_insn (gen_floatdisf2_internal2 (val, operands[1], label));
6104 emit_insn (gen_floatdisf2_internal1 (operands[0], val));
6109 (define_insn "floatdisf2_fcfids"
6110 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6111 (float:SF (match_operand:DI 1 "gpc_reg_operand" "d")))]
6112 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6113 && TARGET_DOUBLE_FLOAT && TARGET_FCFIDS"
6115 [(set_attr "type" "fp")])
6117 (define_insn_and_split "*floatdisf2_mem"
6118 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6119 (float:SF (match_operand:DI 1 "memory_operand" "m")))
6120 (clobber (match_scratch:DI 2 "=f"))]
6121 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6122 && TARGET_DOUBLE_FLOAT && TARGET_FCFIDS"
6124 "&& reload_completed"
6128 emit_move_insn (operands[2], operands[1]);
6129 emit_insn (gen_floatdisf2_fcfids (operands[0], operands[2]));
6132 [(set_attr "length" "8")])
6134 ;; This is not IEEE compliant if rounding mode is "round to nearest".
6135 ;; If the DI->DF conversion is inexact, then it's possible to suffer
6136 ;; from double rounding.
6137 ;; Instead of creating a new cpu type for two FP operations, just use fp
6138 (define_insn_and_split "floatdisf2_internal1"
6139 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6140 (float:SF (match_operand:DI 1 "gpc_reg_operand" "d")))
6141 (clobber (match_scratch:DF 2 "=d"))]
6142 "TARGET_FCFID && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
6144 "&& reload_completed"
6146 (float:DF (match_dup 1)))
6148 (float_truncate:SF (match_dup 2)))]
6150 [(set_attr "length" "8")
6151 (set_attr "type" "fp")])
6153 ;; Twiddles bits to avoid double rounding.
6154 ;; Bits that might be truncated when converting to DFmode are replaced
6155 ;; by a bit that won't be lost at that stage, but is below the SFmode
6156 ;; rounding position.
6157 (define_expand "floatdisf2_internal2"
6158 [(parallel [(set (match_dup 3) (ashiftrt:DI (match_operand:DI 1 "" "")
6160 (clobber (reg:DI CA_REGNO))])
6161 (set (match_operand:DI 0 "" "") (and:DI (match_dup 1)
6163 (set (match_dup 3) (plus:DI (match_dup 3)
6165 (set (match_dup 0) (plus:DI (match_dup 0)
6167 (set (match_dup 4) (compare:CCUNS (match_dup 3)
6169 (set (match_dup 0) (ior:DI (match_dup 0)
6171 (set (match_dup 0) (and:DI (match_dup 0)
6173 (set (pc) (if_then_else (geu (match_dup 4) (const_int 0))
6174 (label_ref (match_operand:DI 2 "" ""))
6176 (set (match_dup 0) (match_dup 1))]
6177 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
6180 operands[3] = gen_reg_rtx (DImode);
6181 operands[4] = gen_reg_rtx (CCUNSmode);
6184 (define_expand "floatunsdisf2"
6185 [(set (match_operand:SF 0 "gpc_reg_operand" "")
6186 (unsigned_float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
6187 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6188 && TARGET_DOUBLE_FLOAT && TARGET_FCFIDUS"
6191 (define_insn "floatunsdisf2_fcfidus"
6192 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6193 (unsigned_float:SF (match_operand:DI 1 "gpc_reg_operand" "d")))]
6194 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6195 && TARGET_DOUBLE_FLOAT && TARGET_FCFIDUS"
6197 [(set_attr "type" "fp")])
6199 (define_insn_and_split "*floatunsdisf2_mem"
6200 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
6201 (unsigned_float:SF (match_operand:DI 1 "memory_operand" "m")))
6202 (clobber (match_scratch:DI 2 "=f"))]
6203 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
6204 && TARGET_DOUBLE_FLOAT && TARGET_FCFIDUS"
6206 "&& reload_completed"
6210 emit_move_insn (operands[2], operands[1]);
6211 emit_insn (gen_floatunsdisf2_fcfidus (operands[0], operands[2]));
6214 [(set_attr "length" "8")
6215 (set_attr "type" "fpload")])
6217 ;; Define the TImode operations that can be done in a small number
6218 ;; of instructions. The & constraints are to prevent the register
6219 ;; allocator from allocating registers that overlap with the inputs
6220 ;; (for example, having an input in 7,8 and an output in 6,7). We
6221 ;; also allow for the output being the same as one of the inputs.
6223 (define_insn "addti3"
6224 [(set (match_operand:TI 0 "gpc_reg_operand" "=&r,&r,r,r")
6225 (plus:TI (match_operand:TI 1 "gpc_reg_operand" "%r,r,0,0")
6226 (match_operand:TI 2 "reg_or_short_operand" "r,I,r,I")))]
6229 if (WORDS_BIG_ENDIAN)
6230 return (GET_CODE (operands[2])) != CONST_INT
6231 ? \"addc %L0,%L1,%L2\;adde %0,%1,%2\"
6232 : \"addic %L0,%L1,%2\;add%G2e %0,%1\";
6234 return (GET_CODE (operands[2])) != CONST_INT
6235 ? \"addc %0,%1,%2\;adde %L0,%L1,%L2\"
6236 : \"addic %0,%1,%2\;add%G2e %L0,%L1\";
6238 [(set_attr "type" "two")
6239 (set_attr "length" "8")])
6241 (define_insn "subti3"
6242 [(set (match_operand:TI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
6243 (minus:TI (match_operand:TI 1 "reg_or_short_operand" "r,I,0,r,I")
6244 (match_operand:TI 2 "gpc_reg_operand" "r,r,r,0,0")))]
6247 if (WORDS_BIG_ENDIAN)
6248 return (GET_CODE (operands[1]) != CONST_INT)
6249 ? \"subfc %L0,%L2,%L1\;subfe %0,%2,%1\"
6250 : \"subfic %L0,%L2,%1\;subf%G1e %0,%2\";
6252 return (GET_CODE (operands[1]) != CONST_INT)
6253 ? \"subfc %0,%2,%1\;subfe %L0,%L2,%L1\"
6254 : \"subfic %0,%2,%1\;subf%G1e %L0,%L2\";
6256 [(set_attr "type" "two")
6257 (set_attr "length" "8")])
6260 ;; Define the DImode operations that can be done in a small number
6261 ;; of instructions. The & constraints are to prevent the register
6262 ;; allocator from allocating registers that overlap with the inputs
6263 ;; (for example, having an input in 7,8 and an output in 6,7). We
6264 ;; also allow for the output being the same as one of the inputs.
6266 (define_insn "*adddi3_noppc64"
6267 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
6268 (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
6269 (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
6270 "! TARGET_POWERPC64"
6273 if (WORDS_BIG_ENDIAN)
6274 return (GET_CODE (operands[2])) != CONST_INT
6275 ? \"addc %L0,%L1,%L2\;adde %0,%1,%2\"
6276 : \"addic %L0,%L1,%2\;add%G2e %0,%1\";
6278 return (GET_CODE (operands[2])) != CONST_INT
6279 ? \"addc %0,%1,%2\;adde %L0,%L1,%L2\"
6280 : \"addic %0,%1,%2\;add%G2e %L0,%L1\";
6282 [(set_attr "type" "two")
6283 (set_attr "length" "8")])
6285 (define_insn "*subdi3_noppc64"
6286 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
6287 (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
6288 (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
6289 "! TARGET_POWERPC64"
6292 if (WORDS_BIG_ENDIAN)
6293 return (GET_CODE (operands[1]) != CONST_INT)
6294 ? \"subfc %L0,%L2,%L1\;subfe %0,%2,%1\"
6295 : \"subfic %L0,%L2,%1\;subf%G1e %0,%2\";
6297 return (GET_CODE (operands[1]) != CONST_INT)
6298 ? \"subfc %0,%2,%1\;subfe %L0,%L2,%L1\"
6299 : \"subfic %0,%2,%1\;subf%G1e %L0,%L2\";
6301 [(set_attr "type" "two")
6302 (set_attr "length" "8")])
6304 (define_insn "*negdi2_noppc64"
6305 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6306 (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
6307 "! TARGET_POWERPC64"
6310 return (WORDS_BIG_ENDIAN)
6311 ? \"subfic %L0,%L1,0\;subfze %0,%1\"
6312 : \"subfic %0,%1,0\;subfze %L0,%L1\";
6314 [(set_attr "type" "two")
6315 (set_attr "length" "8")])
6318 ;; Shift by a variable amount is too complex to be worth open-coding. We
6319 ;; just handle shifts by constants.
6320 (define_insn "ashrdi3_no_power"
6321 [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
6322 (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6323 (match_operand:SI 2 "const_int_operand" "M,i")))
6324 (clobber (reg:SI CA_REGNO))]
6327 switch (which_alternative)
6332 if (WORDS_BIG_ENDIAN)
6333 return \"srawi %0,%1,31\;srawi %L0,%1,%h2\";
6335 return \"srawi %L0,%L1,31\;srawi %0,%L1,%h2\";
6337 if (WORDS_BIG_ENDIAN)
6338 return \"srwi %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;srawi %0,%1,%h2\";
6340 return \"srwi %0,%1,%h2\;insrwi %0,%L1,%h2,0\;srawi %L0,%L1,%h2\";
6343 [(set_attr "type" "two,three")
6344 (set_attr "length" "8,12")])
6346 (define_insn "*ashrdisi3_noppc64be"
6347 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6348 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6349 (const_int 32)) 4))]
6350 "TARGET_32BIT && !TARGET_POWERPC64 && WORDS_BIG_ENDIAN"
6353 if (REGNO (operands[0]) == REGNO (operands[1]))
6356 return \"mr %0,%1\";
6358 [(set_attr "length" "4")])
6361 ;; PowerPC64 DImode operations.
6363 (define_insn "*rotldi3_internal4"
6364 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6365 (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6366 (match_operand:DI 2 "reg_or_cint_operand" "rn"))
6367 (match_operand:DI 3 "mask64_operand" "n")))]
6369 "rld%I2c%B3 %0,%1,%H2,%S3"
6370 [(set_attr "type" "shift")
6371 (set_attr "maybe_var_shift" "yes")])
6373 (define_insn "*rotldi3_internal5"
6374 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6376 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6377 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn"))
6378 (match_operand:DI 3 "mask64_operand" "n,n"))
6380 (clobber (match_scratch:DI 4 "=r,r"))]
6383 rld%I2c%B3. %4,%1,%H2,%S3
6385 [(set_attr "type" "shift")
6386 (set_attr "maybe_var_shift" "yes")
6387 (set_attr "dot" "yes")
6388 (set_attr "length" "4,8")])
6391 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6393 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6394 (match_operand:DI 2 "reg_or_cint_operand" ""))
6395 (match_operand:DI 3 "mask64_operand" ""))
6397 (clobber (match_scratch:DI 4 ""))]
6398 "TARGET_POWERPC64 && reload_completed"
6400 (and:DI (rotate:DI (match_dup 1)
6404 (compare:CC (match_dup 4)
6408 (define_insn "*rotldi3_internal6"
6409 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6411 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6412 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn"))
6413 (match_operand:DI 3 "mask64_operand" "n,n"))
6415 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6416 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6419 rld%I2c%B3. %0,%1,%H2,%S3
6421 [(set_attr "type" "shift")
6422 (set_attr "maybe_var_shift" "yes")
6423 (set_attr "dot" "yes")
6424 (set_attr "length" "4,8")])
6427 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
6429 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6430 (match_operand:DI 2 "reg_or_cint_operand" ""))
6431 (match_operand:DI 3 "mask64_operand" ""))
6433 (set (match_operand:DI 0 "gpc_reg_operand" "")
6434 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6435 "TARGET_POWERPC64 && reload_completed"
6437 (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6439 (compare:CC (match_dup 0)
6443 (define_insn "*rotldi3_internal7le"
6444 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6447 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6448 (match_operand:DI 2 "reg_or_cint_operand" "rn")) 0)))]
6449 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN"
6450 "rld%I2cl %0,%1,%H2,56"
6451 [(set_attr "type" "shift")
6452 (set_attr "maybe_var_shift" "yes")])
6454 (define_insn "*rotldi3_internal7be"
6455 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6458 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6459 (match_operand:DI 2 "reg_or_cint_operand" "rn")) 7)))]
6460 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN"
6461 "rld%I2cl %0,%1,%H2,56"
6462 [(set_attr "type" "shift")
6463 (set_attr "maybe_var_shift" "yes")])
6465 (define_insn "*rotldi3_internal8le"
6466 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6467 (compare:CC (zero_extend:DI
6469 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6470 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6472 (clobber (match_scratch:DI 3 "=r,r"))]
6473 "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6475 rld%I2cl. %3,%1,%H2,56
6477 [(set_attr "type" "shift")
6478 (set_attr "maybe_var_shift" "yes")
6479 (set_attr "dot" "yes")
6480 (set_attr "length" "4,8")])
6482 (define_insn "*rotldi3_internal8be"
6483 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6484 (compare:CC (zero_extend:DI
6486 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6487 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 7))
6489 (clobber (match_scratch:DI 3 "=r,r"))]
6490 "TARGET_64BIT && BYTES_BIG_ENDIAN"
6492 rld%I2cl. %3,%1,%H2,56
6494 [(set_attr "type" "shift")
6495 (set_attr "maybe_var_shift" "yes")
6496 (set_attr "dot" "yes")
6497 (set_attr "length" "4,8")])
6500 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6501 (compare:CC (zero_extend:DI
6503 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6504 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6506 (clobber (match_scratch:DI 3 ""))]
6507 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6509 (zero_extend:DI (subreg:QI
6510 (rotate:DI (match_dup 1)
6513 (compare:CC (match_dup 3)
6518 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6519 (compare:CC (zero_extend:DI
6521 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6522 (match_operand:DI 2 "reg_or_cint_operand" "")) 7))
6524 (clobber (match_scratch:DI 3 ""))]
6525 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6527 (zero_extend:DI (subreg:QI
6528 (rotate:DI (match_dup 1)
6531 (compare:CC (match_dup 3)
6535 (define_insn "*rotldi3_internal9le"
6536 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6537 (compare:CC (zero_extend:DI
6539 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6540 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6542 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6543 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6544 "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6546 rld%I2cl. %0,%1,%H2,56
6548 [(set_attr "type" "shift")
6549 (set_attr "maybe_var_shift" "yes")
6550 (set_attr "dot" "yes")
6551 (set_attr "length" "4,8")])
6553 (define_insn "*rotldi3_internal9be"
6554 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6555 (compare:CC (zero_extend:DI
6557 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6558 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 7))
6560 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6561 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 7)))]
6562 "TARGET_64BIT && BYTES_BIG_ENDIAN"
6564 rld%I2cl. %0,%1,%H2,56
6566 [(set_attr "type" "shift")
6567 (set_attr "maybe_var_shift" "yes")
6568 (set_attr "dot" "yes")
6569 (set_attr "length" "4,8")])
6572 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6573 (compare:CC (zero_extend:DI
6575 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6576 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6578 (set (match_operand:DI 0 "gpc_reg_operand" "")
6579 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6580 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6582 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6584 (compare:CC (match_dup 0)
6589 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6590 (compare:CC (zero_extend:DI
6592 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6593 (match_operand:DI 2 "reg_or_cint_operand" "")) 7))
6595 (set (match_operand:DI 0 "gpc_reg_operand" "")
6596 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 7)))]
6597 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6599 (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 7)))
6601 (compare:CC (match_dup 0)
6605 (define_insn "*rotldi3_internal10le"
6606 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6609 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6610 (match_operand:DI 2 "reg_or_cint_operand" "rn")) 0)))]
6611 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN"
6612 "rld%I2cl %0,%1,%H2,48"
6613 [(set_attr "type" "shift")
6614 (set_attr "maybe_var_shift" "yes")])
6616 (define_insn "*rotldi3_internal10be"
6617 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6620 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6621 (match_operand:DI 2 "reg_or_cint_operand" "rn")) 6)))]
6622 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN"
6623 "rld%I2cl %0,%1,%H2,48"
6624 [(set_attr "type" "shift")
6625 (set_attr "maybe_var_shift" "yes")])
6627 (define_insn "*rotldi3_internal11le"
6628 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6629 (compare:CC (zero_extend:DI
6631 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6632 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6634 (clobber (match_scratch:DI 3 "=r,r"))]
6635 "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6637 rld%I2cl. %3,%1,%H2,48
6639 [(set_attr "type" "shift")
6640 (set_attr "maybe_var_shift" "yes")
6641 (set_attr "dot" "yes")
6642 (set_attr "length" "4,8")])
6644 (define_insn "*rotldi3_internal11be"
6645 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6646 (compare:CC (zero_extend:DI
6648 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6649 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 6))
6651 (clobber (match_scratch:DI 3 "=r,r"))]
6652 "TARGET_64BIT && BYTES_BIG_ENDIAN"
6654 rld%I2cl. %3,%1,%H2,48
6656 [(set_attr "type" "shift")
6657 (set_attr "maybe_var_shift" "yes")
6658 (set_attr "dot" "yes")
6659 (set_attr "length" "4,8")])
6662 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6663 (compare:CC (zero_extend:DI
6665 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6666 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6668 (clobber (match_scratch:DI 3 ""))]
6669 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6671 (zero_extend:DI (subreg:HI
6672 (rotate:DI (match_dup 1)
6675 (compare:CC (match_dup 3)
6680 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6681 (compare:CC (zero_extend:DI
6683 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6684 (match_operand:DI 2 "reg_or_cint_operand" "")) 6))
6686 (clobber (match_scratch:DI 3 ""))]
6687 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6689 (zero_extend:DI (subreg:HI
6690 (rotate:DI (match_dup 1)
6693 (compare:CC (match_dup 3)
6697 (define_insn "*rotldi3_internal12le"
6698 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6699 (compare:CC (zero_extend:DI
6701 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6702 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6704 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6705 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6706 "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6708 rld%I2cl. %0,%1,%H2,48
6710 [(set_attr "type" "shift")
6711 (set_attr "maybe_var_shift" "yes")
6712 (set_attr "dot" "yes")
6713 (set_attr "length" "4,8")])
6715 (define_insn "*rotldi3_internal12be"
6716 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6717 (compare:CC (zero_extend:DI
6719 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6720 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 6))
6722 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6723 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 6)))]
6724 "TARGET_64BIT && BYTES_BIG_ENDIAN"
6726 rld%I2cl. %0,%1,%H2,48
6728 [(set_attr "type" "shift")
6729 (set_attr "maybe_var_shift" "yes")
6730 (set_attr "dot" "yes")
6731 (set_attr "length" "4,8")])
6734 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6735 (compare:CC (zero_extend:DI
6737 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6738 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6740 (set (match_operand:DI 0 "gpc_reg_operand" "")
6741 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6742 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6744 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6746 (compare:CC (match_dup 0)
6751 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6752 (compare:CC (zero_extend:DI
6754 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6755 (match_operand:DI 2 "reg_or_cint_operand" "")) 6))
6757 (set (match_operand:DI 0 "gpc_reg_operand" "")
6758 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 6)))]
6759 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6761 (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 6)))
6763 (compare:CC (match_dup 0)
6767 (define_insn "*rotldi3_internal13le"
6768 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6771 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6772 (match_operand:DI 2 "reg_or_cint_operand" "rn")) 0)))]
6773 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN"
6774 "rld%I2cl %0,%1,%H2,32"
6775 [(set_attr "type" "shift")
6776 (set_attr "maybe_var_shift" "yes")])
6778 (define_insn "*rotldi3_internal13be"
6779 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6782 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6783 (match_operand:DI 2 "reg_or_cint_operand" "rn")) 4)))]
6784 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN"
6785 "rld%I2cl %0,%1,%H2,32"
6786 [(set_attr "type" "shift")
6787 (set_attr "maybe_var_shift" "yes")])
6789 (define_insn "*rotldi3_internal14le"
6790 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6791 (compare:CC (zero_extend:DI
6793 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6794 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6796 (clobber (match_scratch:DI 3 "=r,r"))]
6797 "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6799 rld%I2cl. %3,%1,%H2,32
6801 [(set_attr "type" "shift")
6802 (set_attr "maybe_var_shift" "yes")
6803 (set_attr "dot" "yes")
6804 (set_attr "length" "4,8")])
6806 (define_insn "*rotldi3_internal14be"
6807 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6808 (compare:CC (zero_extend:DI
6810 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6811 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 4))
6813 (clobber (match_scratch:DI 3 "=r,r"))]
6814 "TARGET_64BIT && BYTES_BIG_ENDIAN"
6816 rld%I2cl. %3,%1,%H2,32
6818 [(set_attr "type" "shift")
6819 (set_attr "maybe_var_shift" "yes")
6820 (set_attr "dot" "yes")
6821 (set_attr "length" "4,8")])
6824 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6825 (compare:CC (zero_extend:DI
6827 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6828 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6830 (clobber (match_scratch:DI 3 ""))]
6831 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6833 (zero_extend:DI (subreg:SI
6834 (rotate:DI (match_dup 1)
6837 (compare:CC (match_dup 3)
6842 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6843 (compare:CC (zero_extend:DI
6845 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6846 (match_operand:DI 2 "reg_or_cint_operand" "")) 4))
6848 (clobber (match_scratch:DI 3 ""))]
6849 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6851 (zero_extend:DI (subreg:SI
6852 (rotate:DI (match_dup 1)
6855 (compare:CC (match_dup 3)
6859 (define_insn "*rotldi3_internal15le"
6860 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6861 (compare:CC (zero_extend:DI
6863 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6864 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 0))
6866 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6867 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6868 "TARGET_64BIT && !BYTES_BIG_ENDIAN"
6870 rld%I2cl. %0,%1,%H2,32
6872 [(set_attr "type" "shift")
6873 (set_attr "maybe_var_shift" "yes")
6874 (set_attr "dot" "yes")
6875 (set_attr "length" "4,8")])
6877 (define_insn "*rotldi3_internal15be"
6878 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6879 (compare:CC (zero_extend:DI
6881 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6882 (match_operand:DI 2 "reg_or_cint_operand" "rn,rn")) 4))
6884 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6885 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 4)))]
6886 "TARGET_64BIT && BYTES_BIG_ENDIAN"
6888 rld%I2cl. %0,%1,%H2,32
6890 [(set_attr "type" "shift")
6891 (set_attr "maybe_var_shift" "yes")
6892 (set_attr "dot" "yes")
6893 (set_attr "length" "4,8")])
6896 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6897 (compare:CC (zero_extend:DI
6899 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6900 (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6902 (set (match_operand:DI 0 "gpc_reg_operand" "")
6903 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6904 "TARGET_POWERPC64 && !BYTES_BIG_ENDIAN && reload_completed"
6906 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6908 (compare:CC (match_dup 0)
6913 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
6914 (compare:CC (zero_extend:DI
6916 (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6917 (match_operand:DI 2 "reg_or_cint_operand" "")) 4))
6919 (set (match_operand:DI 0 "gpc_reg_operand" "")
6920 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 4)))]
6921 "TARGET_POWERPC64 && BYTES_BIG_ENDIAN && reload_completed"
6923 (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 4)))
6925 (compare:CC (match_dup 0)
6929 (define_insn "*ashldi3_internal4"
6930 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6931 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6932 (match_operand:SI 2 "const_int_operand" "i"))
6933 (match_operand:DI 3 "const_int_operand" "n")))]
6934 "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6935 "rldic %0,%1,%H2,%W3"
6936 [(set_attr "type" "shift")])
6938 (define_insn "ashldi3_internal5"
6939 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6941 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6942 (match_operand:SI 2 "const_int_operand" "i,i"))
6943 (match_operand:DI 3 "const_int_operand" "n,n"))
6945 (clobber (match_scratch:DI 4 "=r,r"))]
6946 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
6948 rldic. %4,%1,%H2,%W3
6950 [(set_attr "type" "shift")
6951 (set_attr "dot" "yes")
6952 (set_attr "length" "4,8")])
6955 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
6957 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6958 (match_operand:SI 2 "const_int_operand" ""))
6959 (match_operand:DI 3 "const_int_operand" ""))
6961 (clobber (match_scratch:DI 4 ""))]
6962 "TARGET_POWERPC64 && reload_completed
6963 && includes_rldic_lshift_p (operands[2], operands[3])"
6965 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6968 (compare:CC (match_dup 4)
6972 (define_insn "*ashldi3_internal6"
6973 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6975 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6976 (match_operand:SI 2 "const_int_operand" "i,i"))
6977 (match_operand:DI 3 "const_int_operand" "n,n"))
6979 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6980 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6981 "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
6983 rldic. %0,%1,%H2,%W3
6985 [(set_attr "type" "shift")
6986 (set_attr "dot" "yes")
6987 (set_attr "length" "4,8")])
6990 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
6992 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6993 (match_operand:SI 2 "const_int_operand" ""))
6994 (match_operand:DI 3 "const_int_operand" ""))
6996 (set (match_operand:DI 0 "gpc_reg_operand" "")
6997 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6998 "TARGET_POWERPC64 && reload_completed
6999 && includes_rldic_lshift_p (operands[2], operands[3])"
7001 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7004 (compare:CC (match_dup 0)
7008 (define_insn "*ashldi3_internal7"
7009 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7010 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7011 (match_operand:SI 2 "const_int_operand" "i"))
7012 (match_operand:DI 3 "mask64_operand" "n")))]
7013 "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
7014 "rldicr %0,%1,%H2,%S3"
7015 [(set_attr "type" "shift")])
7017 (define_insn "ashldi3_internal8"
7018 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7020 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7021 (match_operand:SI 2 "const_int_operand" "i,i"))
7022 (match_operand:DI 3 "mask64_operand" "n,n"))
7024 (clobber (match_scratch:DI 4 "=r,r"))]
7025 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
7027 rldicr. %4,%1,%H2,%S3
7029 [(set_attr "type" "shift")
7030 (set_attr "dot" "yes")
7031 (set_attr "length" "4,8")])
7034 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
7036 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7037 (match_operand:SI 2 "const_int_operand" ""))
7038 (match_operand:DI 3 "mask64_operand" ""))
7040 (clobber (match_scratch:DI 4 ""))]
7041 "TARGET_POWERPC64 && reload_completed
7042 && includes_rldicr_lshift_p (operands[2], operands[3])"
7044 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7047 (compare:CC (match_dup 4)
7051 (define_insn "*ashldi3_internal9"
7052 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
7054 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7055 (match_operand:SI 2 "const_int_operand" "i,i"))
7056 (match_operand:DI 3 "mask64_operand" "n,n"))
7058 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7059 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7060 "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
7062 rldicr. %0,%1,%H2,%S3
7064 [(set_attr "type" "shift")
7065 (set_attr "dot" "yes")
7066 (set_attr "length" "4,8")])
7069 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
7071 (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7072 (match_operand:SI 2 "const_int_operand" ""))
7073 (match_operand:DI 3 "mask64_operand" ""))
7075 (set (match_operand:DI 0 "gpc_reg_operand" "")
7076 (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7077 "TARGET_POWERPC64 && reload_completed
7078 && includes_rldicr_lshift_p (operands[2], operands[3])"
7080 (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7083 (compare:CC (match_dup 0)
7088 (define_insn_and_split "*anddi3_2rld"
7089 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7090 (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
7091 (match_operand:DI 2 "and_2rld_operand" "n")))]
7096 (and:DI (rotate:DI (match_dup 1)
7100 (and:DI (rotate:DI (match_dup 0)
7104 build_mask64_2_operands (operands[2], &operands[4]);
7106 [(set_attr "length" "8")])
7108 (define_insn_and_split "*anddi3_2rld_dot"
7109 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7110 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
7111 (match_operand:DI 2 "and_2rld_operand" "n,n"))
7113 (clobber (match_scratch:DI 0 "=r,r"))]
7114 "TARGET_64BIT && rs6000_gen_cell_microcode"
7118 "&& reload_completed"
7120 (and:DI (rotate:DI (match_dup 1)
7123 (parallel [(set (match_dup 3)
7124 (compare:CC (and:DI (rotate:DI (match_dup 0)
7128 (clobber (match_dup 0))])]
7130 build_mask64_2_operands (operands[2], &operands[4]);
7132 [(set_attr "type" "compare")
7133 (set_attr "dot" "yes")
7134 (set_attr "length" "8,12")])
7136 (define_insn_and_split "*anddi3_2rld_dot2"
7137 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7138 (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
7139 (match_operand:DI 2 "and_2rld_operand" "n,n"))
7141 (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7142 (and:DI (match_dup 1)
7144 "TARGET_64BIT && rs6000_gen_cell_microcode"
7148 "&& reload_completed"
7150 (and:DI (rotate:DI (match_dup 1)
7153 (parallel [(set (match_dup 3)
7154 (compare:CC (and:DI (rotate:DI (match_dup 0)
7159 (and:DI (rotate:DI (match_dup 0)
7163 build_mask64_2_operands (operands[2], &operands[4]);
7165 [(set_attr "type" "compare")
7166 (set_attr "dot" "yes")
7167 (set_attr "length" "8,12")])
7169 ;; 128-bit logical operations expanders
7171 (define_expand "and<mode>3"
7172 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7173 (and:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
7174 (match_operand:BOOL_128 2 "vlogical_operand" "")))]
7178 (define_expand "ior<mode>3"
7179 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7180 (ior:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
7181 (match_operand:BOOL_128 2 "vlogical_operand" "")))]
7185 (define_expand "xor<mode>3"
7186 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7187 (xor:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
7188 (match_operand:BOOL_128 2 "vlogical_operand" "")))]
7192 (define_expand "one_cmpl<mode>2"
7193 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7194 (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")))]
7198 (define_expand "nor<mode>3"
7199 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7201 (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" ""))
7202 (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))))]
7206 (define_expand "andc<mode>3"
7207 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7209 (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))
7210 (match_operand:BOOL_128 1 "vlogical_operand" "")))]
7214 ;; Power8 vector logical instructions.
7215 (define_expand "eqv<mode>3"
7216 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7218 (xor:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
7219 (match_operand:BOOL_128 2 "vlogical_operand" ""))))]
7220 "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
7223 ;; Rewrite nand into canonical form
7224 (define_expand "nand<mode>3"
7225 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7227 (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" ""))
7228 (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))))]
7229 "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
7232 ;; The canonical form is to have the negated element first, so we need to
7233 ;; reverse arguments.
7234 (define_expand "orc<mode>3"
7235 [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
7237 (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))
7238 (match_operand:BOOL_128 1 "vlogical_operand" "")))]
7239 "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
7242 ;; 128-bit logical operations insns and split operations
7243 (define_insn_and_split "*and<mode>3_internal"
7244 [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7246 (match_operand:BOOL_128 1 "vlogical_operand" "%<BOOL_REGS_OP1>")
7247 (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>")))]
7250 if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7251 return "xxland %x0,%x1,%x2";
7253 if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7254 return "vand %0,%1,%2";
7258 "reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7261 rs6000_split_logical (operands, AND, false, false, false);
7266 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7267 (const_string "vecsimple")
7268 (const_string "integer")))
7269 (set (attr "length")
7271 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7274 (match_test "TARGET_POWERPC64")
7276 (const_string "16"))))])
7279 (define_insn_and_split "*bool<mode>3_internal"
7280 [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7281 (match_operator:BOOL_128 3 "boolean_or_operator"
7282 [(match_operand:BOOL_128 1 "vlogical_operand" "%<BOOL_REGS_OP1>")
7283 (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>")]))]
7286 if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7287 return "xxl%q3 %x0,%x1,%x2";
7289 if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7290 return "v%q3 %0,%1,%2";
7294 "reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7297 rs6000_split_logical (operands, GET_CODE (operands[3]), false, false, false);
7302 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7303 (const_string "vecsimple")
7304 (const_string "integer")))
7305 (set (attr "length")
7307 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7310 (match_test "TARGET_POWERPC64")
7312 (const_string "16"))))])
7315 (define_insn_and_split "*boolc<mode>3_internal1"
7316 [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7317 (match_operator:BOOL_128 3 "boolean_operator"
7319 (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP1>"))
7320 (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_OP2>")]))]
7321 "TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND)"
7323 if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7324 return "xxl%q3 %x0,%x1,%x2";
7326 if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7327 return "v%q3 %0,%1,%2";
7331 "(TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND))
7332 && reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7335 rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, false);
7340 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7341 (const_string "vecsimple")
7342 (const_string "integer")))
7343 (set (attr "length")
7345 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7348 (match_test "TARGET_POWERPC64")
7350 (const_string "16"))))])
7352 (define_insn_and_split "*boolc<mode>3_internal2"
7353 [(set (match_operand:TI2 0 "int_reg_operand" "=&r,r,r")
7354 (match_operator:TI2 3 "boolean_operator"
7356 (match_operand:TI2 1 "int_reg_operand" "r,0,r"))
7357 (match_operand:TI2 2 "int_reg_operand" "r,r,0")]))]
7358 "!TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
7360 "reload_completed && !TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
7363 rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, false);
7366 [(set_attr "type" "integer")
7367 (set (attr "length")
7369 (match_test "TARGET_POWERPC64")
7371 (const_string "16")))])
7374 (define_insn_and_split "*boolcc<mode>3_internal1"
7375 [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7376 (match_operator:BOOL_128 3 "boolean_operator"
7378 (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_OP1>"))
7380 (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>"))]))]
7381 "TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND)"
7383 if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7384 return "xxl%q3 %x0,%x1,%x2";
7386 if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7387 return "v%q3 %0,%1,%2";
7391 "(TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND))
7392 && reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7395 rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, true);
7400 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7401 (const_string "vecsimple")
7402 (const_string "integer")))
7403 (set (attr "length")
7405 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7408 (match_test "TARGET_POWERPC64")
7410 (const_string "16"))))])
7412 (define_insn_and_split "*boolcc<mode>3_internal2"
7413 [(set (match_operand:TI2 0 "int_reg_operand" "=&r,r,r")
7414 (match_operator:TI2 3 "boolean_operator"
7416 (match_operand:TI2 1 "int_reg_operand" "r,0,r"))
7418 (match_operand:TI2 2 "int_reg_operand" "r,r,0"))]))]
7419 "!TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
7421 "reload_completed && !TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
7424 rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, true);
7427 [(set_attr "type" "integer")
7428 (set (attr "length")
7430 (match_test "TARGET_POWERPC64")
7432 (const_string "16")))])
7436 (define_insn_and_split "*eqv<mode>3_internal1"
7437 [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7440 (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_OP1>")
7441 (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>"))))]
7444 if (vsx_register_operand (operands[0], <MODE>mode))
7445 return "xxleqv %x0,%x1,%x2";
7449 "TARGET_P8_VECTOR && reload_completed
7450 && int_reg_operand (operands[0], <MODE>mode)"
7453 rs6000_split_logical (operands, XOR, true, false, false);
7458 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7459 (const_string "vecsimple")
7460 (const_string "integer")))
7461 (set (attr "length")
7463 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7466 (match_test "TARGET_POWERPC64")
7468 (const_string "16"))))])
7470 (define_insn_and_split "*eqv<mode>3_internal2"
7471 [(set (match_operand:TI2 0 "int_reg_operand" "=&r,r,r")
7474 (match_operand:TI2 1 "int_reg_operand" "r,0,r")
7475 (match_operand:TI2 2 "int_reg_operand" "r,r,0"))))]
7478 "reload_completed && !TARGET_P8_VECTOR"
7481 rs6000_split_logical (operands, XOR, true, false, false);
7484 [(set_attr "type" "integer")
7485 (set (attr "length")
7487 (match_test "TARGET_POWERPC64")
7489 (const_string "16")))])
7491 ;; 128-bit one's complement
7492 (define_insn_and_split "*one_cmpl<mode>3_internal"
7493 [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
7495 (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_UNARY>")))]
7498 if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
7499 return "xxlnor %x0,%x1,%x1";
7501 if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
7502 return "vnor %0,%1,%1";
7506 "reload_completed && int_reg_operand (operands[0], <MODE>mode)"
7509 rs6000_split_logical (operands, NOT, false, false, false);
7514 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7515 (const_string "vecsimple")
7516 (const_string "integer")))
7517 (set (attr "length")
7519 (match_test "vsx_register_operand (operands[0], <MODE>mode)")
7522 (match_test "TARGET_POWERPC64")
7524 (const_string "16"))))])
7527 ;; Now define ways of moving data around.
7529 ;; Set up a register with a value from the GOT table
7531 (define_expand "movsi_got"
7532 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7533 (unspec:SI [(match_operand:SI 1 "got_operand" "")
7534 (match_dup 2)] UNSPEC_MOVSI_GOT))]
7535 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7538 if (GET_CODE (operands[1]) == CONST)
7540 rtx offset = const0_rtx;
7541 HOST_WIDE_INT value;
7543 operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
7544 value = INTVAL (offset);
7547 rtx tmp = (!can_create_pseudo_p ()
7549 : gen_reg_rtx (Pmode));
7550 emit_insn (gen_movsi_got (tmp, operands[1]));
7551 emit_insn (gen_addsi3 (operands[0], tmp, offset));
7556 operands[2] = rs6000_got_register (operands[1]);
7559 (define_insn "*movsi_got_internal"
7560 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7561 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7562 (match_operand:SI 2 "gpc_reg_operand" "b")]
7564 "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7565 "lwz %0,%a1@got(%2)"
7566 [(set_attr "type" "load")])
7568 ;; Used by sched, shorten_branches and final when the GOT pseudo reg
7569 ;; didn't get allocated to a hard register.
7571 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7572 (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7573 (match_operand:SI 2 "memory_operand" "")]
7575 "DEFAULT_ABI == ABI_V4
7577 && (reload_in_progress || reload_completed)"
7578 [(set (match_dup 0) (match_dup 2))
7579 (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)]
7583 ;; For SI, we special-case integers that can't be loaded in one insn. We
7584 ;; do the load 16-bits at a time. We could do this by loading from memory,
7585 ;; and this is even supposed to be faster, but it is simpler not to get
7586 ;; integers in the TOC.
7587 (define_insn "movsi_low"
7588 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7589 (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7590 (match_operand 2 "" ""))))]
7591 "TARGET_MACHO && ! TARGET_64BIT"
7592 "lwz %0,lo16(%2)(%1)"
7593 [(set_attr "type" "load")
7594 (set_attr "length" "4")])
7596 (define_insn "*movsi_internal1"
7597 [(set (match_operand:SI 0 "rs6000_nonimmediate_operand" "=r,r,r,m,r,r,r,r,*c*l,*h,*h")
7598 (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,*h,r,r,0"))]
7599 "!TARGET_SINGLE_FPU &&
7600 (gpc_reg_operand (operands[0], SImode) || gpc_reg_operand (operands[1], SImode))"
7613 [(set_attr "type" "*,*,load,store,*,*,*,mfjmpr,mtjmpr,*,*")
7614 (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4")])
7616 (define_insn "*movsi_internal1_single"
7617 [(set (match_operand:SI 0 "rs6000_nonimmediate_operand" "=r,r,r,m,r,r,r,r,*c*l,*h,*h,m,*f")
7618 (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,*h,r,r,0,f,m"))]
7619 "TARGET_SINGLE_FPU &&
7620 (gpc_reg_operand (operands[0], SImode) || gpc_reg_operand (operands[1], SImode))"
7635 [(set_attr "type" "*,*,load,store,*,*,*,mfjmpr,mtjmpr,*,*,fpstore,fpload")
7636 (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
7638 ;; Split a load of a large constant into the appropriate two-insn
7642 [(set (match_operand:SI 0 "gpc_reg_operand" "")
7643 (match_operand:SI 1 "const_int_operand" ""))]
7644 "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
7645 && (INTVAL (operands[1]) & 0xffff) != 0"
7649 (ior:SI (match_dup 0)
7653 if (rs6000_emit_set_const (operands[0], operands[1]))
7659 (define_insn "*mov<mode>_internal2"
7660 [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
7661 (compare:CC (match_operand:P 1 "gpc_reg_operand" "0,r,r")
7663 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
7669 [(set_attr "type" "cmp,logical,cmp")
7670 (set_attr "dot" "yes")
7671 (set_attr "length" "4,4,8")])
7674 [(set (match_operand:CC 2 "cc_reg_not_micro_cr0_operand" "")
7675 (compare:CC (match_operand:P 1 "gpc_reg_operand" "")
7677 (set (match_operand:P 0 "gpc_reg_operand" "") (match_dup 1))]
7679 [(set (match_dup 0) (match_dup 1))
7681 (compare:CC (match_dup 0)
7685 (define_insn "*movhi_internal"
7686 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*c*l,*h")
7687 (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,0"))]
7688 "gpc_reg_operand (operands[0], HImode)
7689 || gpc_reg_operand (operands[1], HImode)"
7698 [(set_attr "type" "*,load,store,*,mfjmpr,mtjmpr,*")])
7700 (define_expand "mov<mode>"
7701 [(set (match_operand:INT 0 "general_operand" "")
7702 (match_operand:INT 1 "any_operand" ""))]
7704 "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
7706 (define_insn "*movqi_internal"
7707 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*c*l,*h")
7708 (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,0"))]
7709 "gpc_reg_operand (operands[0], QImode)
7710 || gpc_reg_operand (operands[1], QImode)"
7719 [(set_attr "type" "*,load,store,*,mfjmpr,mtjmpr,*")])
7721 ;; Here is how to move condition codes around. When we store CC data in
7722 ;; an integer register or memory, we store just the high-order 4 bits.
7723 ;; This lets us not shift in the most common case of CR0.
7724 (define_expand "movcc"
7725 [(set (match_operand:CC 0 "nonimmediate_operand" "")
7726 (match_operand:CC 1 "nonimmediate_operand" ""))]
7730 (define_insn "*movcc_internal1"
7731 [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,?y,y,r,r,r,r,r,cl,r,m")
7732 (match_operand:CC 1 "general_operand" "y,r,r,O,x,y,r,I,h,r,m,r"))]
7733 "register_operand (operands[0], CCmode)
7734 || register_operand (operands[1], CCmode)"
7738 rlwinm %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;rlwinm %1,%1,%f0,0xffffffff
7741 mfcr %0%Q1\;rlwinm %0,%0,%f1,0xf0000000
7749 (cond [(eq_attr "alternative" "0,3")
7750 (const_string "cr_logical")
7751 (eq_attr "alternative" "1,2")
7752 (const_string "mtcr")
7753 (eq_attr "alternative" "6,7")
7754 (const_string "integer")
7755 (eq_attr "alternative" "8")
7756 (const_string "mfjmpr")
7757 (eq_attr "alternative" "9")
7758 (const_string "mtjmpr")
7759 (eq_attr "alternative" "10")
7760 (const_string "load")
7761 (eq_attr "alternative" "11")
7762 (const_string "store")
7763 (match_test "TARGET_MFCRF")
7764 (const_string "mfcrf")
7766 (const_string "mfcr")))
7767 (set_attr "length" "4,4,12,4,4,8,4,4,4,4,4,4")])
7769 ;; For floating-point, we normally deal with the floating-point registers
7770 ;; unless -msoft-float is used. The sole exception is that parameter passing
7771 ;; can produce floating-point values in fixed-point registers. Unless the
7772 ;; value is a simple constant or already in memory, we deal with this by
7773 ;; allocating memory and copying the value explicitly via that memory location.
7775 ;; Move 32-bit binary/decimal floating point
7776 (define_expand "mov<mode>"
7777 [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "")
7778 (match_operand:FMOVE32 1 "any_operand" ""))]
7780 "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
7783 [(set (match_operand:FMOVE32 0 "gpc_reg_operand" "")
7784 (match_operand:FMOVE32 1 "const_double_operand" ""))]
7786 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7787 || (GET_CODE (operands[0]) == SUBREG
7788 && GET_CODE (SUBREG_REG (operands[0])) == REG
7789 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7790 [(set (match_dup 2) (match_dup 3))]
7796 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7797 <real_value_to_target> (rv, l);
7799 if (! TARGET_POWERPC64)
7800 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
7802 operands[2] = gen_lowpart (SImode, operands[0]);
7804 operands[3] = gen_int_mode (l, SImode);
7807 (define_insn "mov<mode>_hardfloat"
7808 [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "=!r,!r,m,f,wa,wa,<f32_lr>,<f32_sm>,wu,Z,?<f32_dm>,?r,*c*l,!r,*h,!r,!r")
7809 (match_operand:FMOVE32 1 "input_operand" "r,m,r,f,wa,j,<f32_lm>,<f32_sr>,Z,wu,r,<f32_dm>,r,h,0,G,Fn"))]
7810 "(gpc_reg_operand (operands[0], <MODE>mode)
7811 || gpc_reg_operand (operands[1], <MODE>mode))
7812 && (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT)"
7831 [(set_attr "type" "*,load,store,fp,vecsimple,vecsimple,fpload,fpstore,fpload,fpstore,mftgpr,mffgpr,mtjmpr,mfjmpr,*,*,*")
7832 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,8")])
7834 (define_insn "*mov<mode>_softfloat"
7835 [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "=r,cl,r,r,m,r,r,r,r,*h")
7836 (match_operand:FMOVE32 1 "input_operand" "r,r,h,m,r,I,L,G,Fn,0"))]
7837 "(gpc_reg_operand (operands[0], <MODE>mode)
7838 || gpc_reg_operand (operands[1], <MODE>mode))
7839 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
7851 [(set_attr "type" "*,mtjmpr,mfjmpr,load,store,*,*,*,*,*")
7852 (set_attr "length" "4,4,4,4,4,4,4,4,8,4")])
7855 ;; Move 64-bit binary/decimal floating point
7856 (define_expand "mov<mode>"
7857 [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "")
7858 (match_operand:FMOVE64 1 "any_operand" ""))]
7860 "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
7863 [(set (match_operand:FMOVE64 0 "gpc_reg_operand" "")
7864 (match_operand:FMOVE64 1 "const_int_operand" ""))]
7865 "! TARGET_POWERPC64 && reload_completed
7866 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7867 || (GET_CODE (operands[0]) == SUBREG
7868 && GET_CODE (SUBREG_REG (operands[0])) == REG
7869 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7870 [(set (match_dup 2) (match_dup 4))
7871 (set (match_dup 3) (match_dup 1))]
7874 int endian = (WORDS_BIG_ENDIAN == 0);
7875 HOST_WIDE_INT value = INTVAL (operands[1]);
7877 operands[2] = operand_subword (operands[0], endian, 0, <MODE>mode);
7878 operands[3] = operand_subword (operands[0], 1 - endian, 0, <MODE>mode);
7879 operands[4] = GEN_INT (value >> 32);
7880 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
7884 [(set (match_operand:FMOVE64 0 "gpc_reg_operand" "")
7885 (match_operand:FMOVE64 1 "const_double_operand" ""))]
7886 "! TARGET_POWERPC64 && reload_completed
7887 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7888 || (GET_CODE (operands[0]) == SUBREG
7889 && GET_CODE (SUBREG_REG (operands[0])) == REG
7890 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7891 [(set (match_dup 2) (match_dup 4))
7892 (set (match_dup 3) (match_dup 5))]
7895 int endian = (WORDS_BIG_ENDIAN == 0);
7899 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7900 <real_value_to_target> (rv, l);
7902 operands[2] = operand_subword (operands[0], endian, 0, <MODE>mode);
7903 operands[3] = operand_subword (operands[0], 1 - endian, 0, <MODE>mode);
7904 operands[4] = gen_int_mode (l[endian], SImode);
7905 operands[5] = gen_int_mode (l[1 - endian], SImode);
7909 [(set (match_operand:FMOVE64 0 "gpc_reg_operand" "")
7910 (match_operand:FMOVE64 1 "const_double_operand" ""))]
7911 "TARGET_POWERPC64 && reload_completed
7912 && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7913 || (GET_CODE (operands[0]) == SUBREG
7914 && GET_CODE (SUBREG_REG (operands[0])) == REG
7915 && REGNO (SUBREG_REG (operands[0])) <= 31))"
7916 [(set (match_dup 2) (match_dup 3))]
7919 int endian = (WORDS_BIG_ENDIAN == 0);
7924 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7925 <real_value_to_target> (rv, l);
7927 operands[2] = gen_lowpart (DImode, operands[0]);
7928 /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN. */
7929 val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32
7930 | ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
7932 operands[3] = gen_int_mode (val, DImode);
7935 ;; Don't have reload use general registers to load a constant. It is
7936 ;; less efficient than loading the constant into an FP register, since
7937 ;; it will probably be used there.
7939 ;; The move constraints are ordered to prefer floating point registers before
7940 ;; general purpose registers to avoid doing a store and a load to get the value
7941 ;; into a floating point register when it is needed for a floating point
7942 ;; operation. Prefer traditional floating point registers over VSX registers,
7943 ;; since the D-form version of the memory instructions does not need a GPR for
7946 (define_insn "*mov<mode>_hardfloat32"
7947 [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=m,d,d,wv,Z,wa,wa,Y,r,!r,!r,!r,!r")
7948 (match_operand:FMOVE64 1 "input_operand" "d,m,d,Z,wv,wa,j,r,Y,r,G,H,F"))]
7949 "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
7950 && (gpc_reg_operand (operands[0], <MODE>mode)
7951 || gpc_reg_operand (operands[1], <MODE>mode))"
7966 [(set_attr "type" "fpstore,fpload,fp,fpload,fpstore,vecsimple,vecsimple,store,load,two,fp,fp,*")
7967 (set_attr "length" "4,4,4,4,4,4,4,8,8,8,8,12,16")])
7969 (define_insn "*mov<mode>_softfloat32"
7970 [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=Y,r,r,r,r,r")
7971 (match_operand:FMOVE64 1 "input_operand" "r,Y,r,G,H,F"))]
7973 && ((TARGET_FPRS && TARGET_SINGLE_FLOAT)
7974 || TARGET_SOFT_FLOAT || TARGET_E500_SINGLE
7975 || (<MODE>mode == DDmode && TARGET_E500_DOUBLE))
7976 && (gpc_reg_operand (operands[0], <MODE>mode)
7977 || gpc_reg_operand (operands[1], <MODE>mode))"
7979 [(set_attr "type" "store,load,two,*,*,*")
7980 (set_attr "length" "8,8,8,8,12,16")])
7982 ; ld/std require word-aligned displacements -> 'Y' constraint.
7983 ; List Y->r and r->Y before r->r for reload.
7984 (define_insn "*mov<mode>_hardfloat64"
7985 [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=m,d,d,wv,Z,wa,wa,Y,r,!r,*c*l,!r,*h,!r,!r,!r,r,wg,r,wk")
7986 (match_operand:FMOVE64 1 "input_operand" "d,m,d,Z,wv,wa,j,r,Y,r,r,h,0,G,H,F,wg,r,wk,r"))]
7987 "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
7988 && (gpc_reg_operand (operands[0], <MODE>mode)
7989 || gpc_reg_operand (operands[1], <MODE>mode))"
8011 [(set_attr "type" "fpstore,fpload,fp,fpload,fpstore,vecsimple,vecsimple,store,load,*,mtjmpr,mfjmpr,*,*,*,*,mftgpr,mffgpr,mftgpr,mffgpr")
8012 (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,4,8,12,16,4,4,4,4")])
8014 (define_insn "*mov<mode>_softfloat64"
8015 [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=Y,r,r,cl,r,r,r,r,*h")
8016 (match_operand:FMOVE64 1 "input_operand" "r,Y,r,r,h,G,H,F,0"))]
8017 "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
8018 && (gpc_reg_operand (operands[0], <MODE>mode)
8019 || gpc_reg_operand (operands[1], <MODE>mode))"
8030 [(set_attr "type" "store,load,*,mtjmpr,mfjmpr,*,*,*,*")
8031 (set_attr "length" "4,4,4,4,4,8,12,16,4")])
8033 (define_expand "mov<mode>"
8034 [(set (match_operand:FMOVE128 0 "general_operand" "")
8035 (match_operand:FMOVE128 1 "any_operand" ""))]
8037 "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
8039 ;; It's important to list Y->r and r->Y before r->r because otherwise
8040 ;; reload, given m->r, will try to pick r->r and reload it, which
8041 ;; doesn't make progress.
8043 ;; We can't split little endian direct moves of TDmode, because the words are
8044 ;; not swapped like they are for TImode or TFmode. Subregs therefore are
8045 ;; problematical. Don't allow direct move for this case.
8047 (define_insn_and_split "*mov<mode>_64bit_dm"
8048 [(set (match_operand:FMOVE128 0 "nonimmediate_operand" "=m,d,d,Y,r,r,r,wm")
8049 (match_operand:FMOVE128 1 "input_operand" "d,m,d,r,YGHF,r,wm,r"))]
8050 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_POWERPC64
8051 && (<MODE>mode != TDmode || WORDS_BIG_ENDIAN)
8052 && (gpc_reg_operand (operands[0], <MODE>mode)
8053 || gpc_reg_operand (operands[1], <MODE>mode))"
8055 "&& reload_completed"
8057 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8058 [(set_attr "length" "8,8,8,12,12,8,8,8")])
8060 (define_insn_and_split "*movtd_64bit_nodm"
8061 [(set (match_operand:TD 0 "nonimmediate_operand" "=m,d,d,Y,r,r")
8062 (match_operand:TD 1 "input_operand" "d,m,d,r,YGHF,r"))]
8063 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_POWERPC64 && !WORDS_BIG_ENDIAN
8064 && (gpc_reg_operand (operands[0], TDmode)
8065 || gpc_reg_operand (operands[1], TDmode))"
8067 "&& reload_completed"
8069 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8070 [(set_attr "length" "8,8,8,12,12,8")])
8072 (define_insn_and_split "*mov<mode>_32bit"
8073 [(set (match_operand:FMOVE128 0 "nonimmediate_operand" "=m,d,d,Y,r,r")
8074 (match_operand:FMOVE128 1 "input_operand" "d,m,d,r,YGHF,r"))]
8075 "TARGET_HARD_FLOAT && TARGET_FPRS && !TARGET_POWERPC64
8076 && (gpc_reg_operand (operands[0], <MODE>mode)
8077 || gpc_reg_operand (operands[1], <MODE>mode))"
8079 "&& reload_completed"
8081 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8082 [(set_attr "length" "8,8,8,20,20,16")])
8084 (define_insn_and_split "*mov<mode>_softfloat"
8085 [(set (match_operand:FMOVE128 0 "rs6000_nonimmediate_operand" "=Y,r,r")
8086 (match_operand:FMOVE128 1 "input_operand" "r,YGHF,r"))]
8087 "(TARGET_SOFT_FLOAT || !TARGET_FPRS)
8088 && (gpc_reg_operand (operands[0], <MODE>mode)
8089 || gpc_reg_operand (operands[1], <MODE>mode))"
8091 "&& reload_completed"
8093 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8094 [(set_attr "length" "20,20,16")])
8096 (define_expand "extenddftf2"
8097 [(set (match_operand:TF 0 "nonimmediate_operand" "")
8098 (float_extend:TF (match_operand:DF 1 "input_operand" "")))]
8100 && TARGET_HARD_FLOAT
8101 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8102 && TARGET_LONG_DOUBLE_128"
8104 if (TARGET_E500_DOUBLE)
8105 emit_insn (gen_spe_extenddftf2 (operands[0], operands[1]));
8107 emit_insn (gen_extenddftf2_fprs (operands[0], operands[1]));
8111 (define_expand "extenddftf2_fprs"
8112 [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
8113 (float_extend:TF (match_operand:DF 1 "input_operand" "")))
8114 (use (match_dup 2))])]
8116 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
8117 && TARGET_LONG_DOUBLE_128"
8119 operands[2] = CONST0_RTX (DFmode);
8120 /* Generate GOT reference early for SVR4 PIC. */
8121 if (DEFAULT_ABI == ABI_V4 && flag_pic)
8122 operands[2] = validize_mem (force_const_mem (DFmode, operands[2]));
8125 (define_insn_and_split "*extenddftf2_internal"
8126 [(set (match_operand:TF 0 "nonimmediate_operand" "=m,Y,d,&d,r")
8127 (float_extend:TF (match_operand:DF 1 "input_operand" "d,r,md,md,rmGHF")))
8128 (use (match_operand:DF 2 "zero_reg_mem_operand" "d,r,m,d,n"))]
8130 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
8131 && TARGET_LONG_DOUBLE_128"
8133 "&& reload_completed"
8136 const int lo_word = LONG_DOUBLE_LARGE_FIRST ? GET_MODE_SIZE (DFmode) : 0;
8137 const int hi_word = LONG_DOUBLE_LARGE_FIRST ? 0 : GET_MODE_SIZE (DFmode);
8138 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word),
8140 emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word),
8145 (define_expand "extendsftf2"
8146 [(set (match_operand:TF 0 "nonimmediate_operand" "")
8147 (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "")))]
8149 && TARGET_HARD_FLOAT
8150 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8151 && TARGET_LONG_DOUBLE_128"
8153 rtx tmp = gen_reg_rtx (DFmode);
8154 emit_insn (gen_extendsfdf2 (tmp, operands[1]));
8155 emit_insn (gen_extenddftf2 (operands[0], tmp));
8159 (define_expand "trunctfdf2"
8160 [(set (match_operand:DF 0 "gpc_reg_operand" "")
8161 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))]
8163 && TARGET_HARD_FLOAT
8164 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8165 && TARGET_LONG_DOUBLE_128"
8168 (define_insn_and_split "trunctfdf2_internal1"
8169 [(set (match_operand:DF 0 "gpc_reg_operand" "=d,?d")
8170 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "0,d")))]
8171 "!TARGET_IEEEQUAD && !TARGET_XL_COMPAT
8172 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8176 "&& reload_completed && REGNO (operands[0]) == REGNO (operands[1])"
8179 emit_note (NOTE_INSN_DELETED);
8182 [(set_attr "type" "fp")])
8184 (define_insn "trunctfdf2_internal2"
8185 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
8186 (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "d")))]
8187 "!TARGET_IEEEQUAD && TARGET_XL_COMPAT
8188 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
8189 && TARGET_LONG_DOUBLE_128"
8191 [(set_attr "type" "fp")
8192 (set_attr "fp_type" "fp_addsub_d")])
8194 (define_expand "trunctfsf2"
8195 [(set (match_operand:SF 0 "gpc_reg_operand" "")
8196 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "")))]
8198 && TARGET_HARD_FLOAT
8199 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8200 && TARGET_LONG_DOUBLE_128"
8202 if (TARGET_E500_DOUBLE)
8203 emit_insn (gen_spe_trunctfsf2 (operands[0], operands[1]));
8205 emit_insn (gen_trunctfsf2_fprs (operands[0], operands[1]));
8209 (define_insn_and_split "trunctfsf2_fprs"
8210 [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
8211 (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "d")))
8212 (clobber (match_scratch:DF 2 "=d"))]
8214 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
8215 && TARGET_LONG_DOUBLE_128"
8217 "&& reload_completed"
8219 (float_truncate:DF (match_dup 1)))
8221 (float_truncate:SF (match_dup 2)))]
8224 (define_expand "floatsitf2"
8225 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8226 (float:TF (match_operand:SI 1 "gpc_reg_operand" "")))]
8228 && TARGET_HARD_FLOAT
8229 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8230 && TARGET_LONG_DOUBLE_128"
8232 rtx tmp = gen_reg_rtx (DFmode);
8233 expand_float (tmp, operands[1], false);
8234 emit_insn (gen_extenddftf2 (operands[0], tmp));
8238 ; fadd, but rounding towards zero.
8239 ; This is probably not the optimal code sequence.
8240 (define_insn "fix_trunc_helper"
8241 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
8242 (unspec:DF [(match_operand:TF 1 "gpc_reg_operand" "d")]
8243 UNSPEC_FIX_TRUNC_TF))
8244 (clobber (match_operand:DF 2 "gpc_reg_operand" "=&d"))]
8245 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
8246 "mffs %2\n\tmtfsb1 31\n\tmtfsb0 30\n\tfadd %0,%1,%L1\n\tmtfsf 1,%2"
8247 [(set_attr "type" "fp")
8248 (set_attr "length" "20")])
8250 (define_expand "fix_trunctfsi2"
8251 [(set (match_operand:SI 0 "gpc_reg_operand" "")
8252 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))]
8253 "!TARGET_IEEEQUAD && TARGET_HARD_FLOAT
8254 && (TARGET_FPRS || TARGET_E500_DOUBLE) && TARGET_LONG_DOUBLE_128"
8256 if (TARGET_E500_DOUBLE)
8257 emit_insn (gen_spe_fix_trunctfsi2 (operands[0], operands[1]));
8259 emit_insn (gen_fix_trunctfsi2_fprs (operands[0], operands[1]));
8263 (define_expand "fix_trunctfsi2_fprs"
8264 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
8265 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))
8266 (clobber (match_dup 2))
8267 (clobber (match_dup 3))
8268 (clobber (match_dup 4))
8269 (clobber (match_dup 5))])]
8271 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8273 operands[2] = gen_reg_rtx (DFmode);
8274 operands[3] = gen_reg_rtx (DFmode);
8275 operands[4] = gen_reg_rtx (DImode);
8276 operands[5] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode));
8279 (define_insn_and_split "*fix_trunctfsi2_internal"
8280 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8281 (fix:SI (match_operand:TF 1 "gpc_reg_operand" "d")))
8282 (clobber (match_operand:DF 2 "gpc_reg_operand" "=d"))
8283 (clobber (match_operand:DF 3 "gpc_reg_operand" "=&d"))
8284 (clobber (match_operand:DI 4 "gpc_reg_operand" "=d"))
8285 (clobber (match_operand:DI 5 "offsettable_mem_operand" "=o"))]
8287 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8293 emit_insn (gen_fix_trunc_helper (operands[2], operands[1], operands[3]));
8295 gcc_assert (MEM_P (operands[5]));
8296 lowword = adjust_address (operands[5], SImode, WORDS_BIG_ENDIAN ? 4 : 0);
8298 emit_insn (gen_fctiwz_df (operands[4], operands[2]));
8299 emit_move_insn (operands[5], operands[4]);
8300 emit_move_insn (operands[0], lowword);
8304 (define_expand "negtf2"
8305 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8306 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "")))]
8308 && TARGET_HARD_FLOAT
8309 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8310 && TARGET_LONG_DOUBLE_128"
8313 (define_insn "negtf2_internal"
8314 [(set (match_operand:TF 0 "gpc_reg_operand" "=d")
8315 (neg:TF (match_operand:TF 1 "gpc_reg_operand" "d")))]
8317 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8320 if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8321 return \"fneg %L0,%L1\;fneg %0,%1\";
8323 return \"fneg %0,%1\;fneg %L0,%L1\";
8325 [(set_attr "type" "fp")
8326 (set_attr "length" "8")])
8328 (define_expand "abstf2"
8329 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8330 (abs:TF (match_operand:TF 1 "gpc_reg_operand" "")))]
8332 && TARGET_HARD_FLOAT
8333 && (TARGET_FPRS || TARGET_E500_DOUBLE)
8334 && TARGET_LONG_DOUBLE_128"
8337 rtx label = gen_label_rtx ();
8338 if (TARGET_E500_DOUBLE)
8340 if (flag_finite_math_only && !flag_trapping_math)
8341 emit_insn (gen_spe_abstf2_tst (operands[0], operands[1], label));
8343 emit_insn (gen_spe_abstf2_cmp (operands[0], operands[1], label));
8346 emit_insn (gen_abstf2_internal (operands[0], operands[1], label));
8351 (define_expand "abstf2_internal"
8352 [(set (match_operand:TF 0 "gpc_reg_operand" "")
8353 (match_operand:TF 1 "gpc_reg_operand" ""))
8354 (set (match_dup 3) (match_dup 5))
8355 (set (match_dup 5) (abs:DF (match_dup 5)))
8356 (set (match_dup 4) (compare:CCFP (match_dup 3) (match_dup 5)))
8357 (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
8358 (label_ref (match_operand 2 "" ""))
8360 (set (match_dup 6) (neg:DF (match_dup 6)))]
8362 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
8363 && TARGET_LONG_DOUBLE_128"
8366 const int hi_word = LONG_DOUBLE_LARGE_FIRST ? 0 : GET_MODE_SIZE (DFmode);
8367 const int lo_word = LONG_DOUBLE_LARGE_FIRST ? GET_MODE_SIZE (DFmode) : 0;
8368 operands[3] = gen_reg_rtx (DFmode);
8369 operands[4] = gen_reg_rtx (CCFPmode);
8370 operands[5] = simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word);
8371 operands[6] = simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word);
8374 ;; Reload helper functions used by rs6000_secondary_reload. The patterns all
8375 ;; must have 3 arguments, and scratch register constraint must be a single
8378 ;; Reload patterns to support gpr load/store with misaligned mem.
8379 ;; and multiple gpr load/store at offset >= 0xfffc
8380 (define_expand "reload_<mode>_store"
8381 [(parallel [(match_operand 0 "memory_operand" "=m")
8382 (match_operand 1 "gpc_reg_operand" "r")
8383 (match_operand:GPR 2 "register_operand" "=&b")])]
8386 rs6000_secondary_reload_gpr (operands[1], operands[0], operands[2], true);
8390 (define_expand "reload_<mode>_load"
8391 [(parallel [(match_operand 0 "gpc_reg_operand" "=r")
8392 (match_operand 1 "memory_operand" "m")
8393 (match_operand:GPR 2 "register_operand" "=b")])]
8396 rs6000_secondary_reload_gpr (operands[0], operands[1], operands[2], false);
8401 ;; Power8 merge instructions to allow direct move to/from floating point
8402 ;; registers in 32-bit mode. We use TF mode to get two registers to move the
8403 ;; individual 32-bit parts across. Subreg doesn't work too well on the TF
8404 ;; value, since it is allocated in reload and not all of the flow information
8405 ;; is setup for it. We have two patterns to do the two moves between gprs and
8406 ;; fprs. There isn't a dependancy between the two, but we could potentially
8407 ;; schedule other instructions between the two instructions. TFmode is
8408 ;; currently limited to traditional FPR registers. If/when this is changed, we
8409 ;; will need to revist %L to make sure it works with VSX registers, or add an
8410 ;; %x version of %L.
8412 (define_insn "p8_fmrgow_<mode>"
8413 [(set (match_operand:FMOVE64X 0 "register_operand" "=d")
8414 (unspec:FMOVE64X [(match_operand:TF 1 "register_operand" "d")]
8415 UNSPEC_P8V_FMRGOW))]
8416 "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8418 [(set_attr "type" "vecperm")])
8420 (define_insn "p8_mtvsrwz_1"
8421 [(set (match_operand:TF 0 "register_operand" "=d")
8422 (unspec:TF [(match_operand:SI 1 "register_operand" "r")]
8423 UNSPEC_P8V_MTVSRWZ))]
8424 "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8426 [(set_attr "type" "mftgpr")])
8428 (define_insn "p8_mtvsrwz_2"
8429 [(set (match_operand:TF 0 "register_operand" "+d")
8430 (unspec:TF [(match_dup 0)
8431 (match_operand:SI 1 "register_operand" "r")]
8432 UNSPEC_P8V_MTVSRWZ))]
8433 "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8435 [(set_attr "type" "mftgpr")])
8437 (define_insn_and_split "reload_fpr_from_gpr<mode>"
8438 [(set (match_operand:FMOVE64X 0 "register_operand" "=ws")
8439 (unspec:FMOVE64X [(match_operand:FMOVE64X 1 "register_operand" "r")]
8440 UNSPEC_P8V_RELOAD_FROM_GPR))
8441 (clobber (match_operand:TF 2 "register_operand" "=d"))]
8442 "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8444 "&& reload_completed"
8447 rtx dest = operands[0];
8448 rtx src = operands[1];
8449 rtx tmp = operands[2];
8450 rtx gpr_hi_reg = gen_highpart (SImode, src);
8451 rtx gpr_lo_reg = gen_lowpart (SImode, src);
8453 emit_insn (gen_p8_mtvsrwz_1 (tmp, gpr_hi_reg));
8454 emit_insn (gen_p8_mtvsrwz_2 (tmp, gpr_lo_reg));
8455 emit_insn (gen_p8_fmrgow_<mode> (dest, tmp));
8458 [(set_attr "length" "12")
8459 (set_attr "type" "three")])
8461 ;; Move 128 bit values from GPRs to VSX registers in 64-bit mode
8462 (define_insn "p8_mtvsrd_1"
8463 [(set (match_operand:TF 0 "register_operand" "=ws")
8464 (unspec:TF [(match_operand:DI 1 "register_operand" "r")]
8465 UNSPEC_P8V_MTVSRD))]
8466 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8468 [(set_attr "type" "mftgpr")])
8470 (define_insn "p8_mtvsrd_2"
8471 [(set (match_operand:TF 0 "register_operand" "+ws")
8472 (unspec:TF [(match_dup 0)
8473 (match_operand:DI 1 "register_operand" "r")]
8474 UNSPEC_P8V_MTVSRD))]
8475 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8477 [(set_attr "type" "mftgpr")])
8479 (define_insn "p8_xxpermdi_<mode>"
8480 [(set (match_operand:FMOVE128_GPR 0 "register_operand" "=wa")
8481 (unspec:FMOVE128_GPR [(match_operand:TF 1 "register_operand" "ws")]
8482 UNSPEC_P8V_XXPERMDI))]
8483 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8484 "xxpermdi %x0,%1,%L1,0"
8485 [(set_attr "type" "vecperm")])
8487 (define_insn_and_split "reload_vsx_from_gpr<mode>"
8488 [(set (match_operand:FMOVE128_GPR 0 "register_operand" "=wa")
8489 (unspec:FMOVE128_GPR
8490 [(match_operand:FMOVE128_GPR 1 "register_operand" "r")]
8491 UNSPEC_P8V_RELOAD_FROM_GPR))
8492 (clobber (match_operand:TF 2 "register_operand" "=ws"))]
8493 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8495 "&& reload_completed"
8498 rtx dest = operands[0];
8499 rtx src = operands[1];
8500 rtx tmp = operands[2];
8501 rtx gpr_hi_reg = gen_highpart (DImode, src);
8502 rtx gpr_lo_reg = gen_lowpart (DImode, src);
8504 emit_insn (gen_p8_mtvsrd_1 (tmp, gpr_hi_reg));
8505 emit_insn (gen_p8_mtvsrd_2 (tmp, gpr_lo_reg));
8506 emit_insn (gen_p8_xxpermdi_<mode> (dest, tmp));
8508 [(set_attr "length" "12")
8509 (set_attr "type" "three")])
8512 [(set (match_operand:FMOVE128_GPR 0 "nonimmediate_operand" "")
8513 (match_operand:FMOVE128_GPR 1 "input_operand" ""))]
8515 && (int_reg_operand (operands[0], <MODE>mode)
8516 || int_reg_operand (operands[1], <MODE>mode))"
8518 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8520 ;; Move SFmode to a VSX from a GPR register. Because scalar floating point
8521 ;; type is stored internally as double precision in the VSX registers, we have
8522 ;; to convert it from the vector format.
8524 (define_insn_and_split "reload_vsx_from_gprsf"
8525 [(set (match_operand:SF 0 "register_operand" "=wa")
8526 (unspec:SF [(match_operand:SF 1 "register_operand" "r")]
8527 UNSPEC_P8V_RELOAD_FROM_GPR))
8528 (clobber (match_operand:DI 2 "register_operand" "=r"))]
8529 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8531 "&& reload_completed"
8534 rtx op0 = operands[0];
8535 rtx op1 = operands[1];
8536 rtx op2 = operands[2];
8537 /* Also use the destination register to hold the unconverted DImode value.
8538 This is conceptually a separate value from OP0, so we use gen_rtx_REG
8539 rather than simplify_gen_subreg. */
8540 rtx op0_di = gen_rtx_REG (DImode, REGNO (op0));
8541 rtx op1_di = simplify_gen_subreg (DImode, op1, SFmode, 0);
8543 /* Move SF value to upper 32-bits for xscvspdpn. */
8544 emit_insn (gen_ashldi3 (op2, op1_di, GEN_INT (32)));
8545 emit_move_insn (op0_di, op2);
8546 emit_insn (gen_vsx_xscvspdpn_directmove (op0, op0_di));
8549 [(set_attr "length" "8")
8550 (set_attr "type" "two")])
8552 ;; Move 128 bit values from VSX registers to GPRs in 64-bit mode by doing a
8553 ;; normal 64-bit move, followed by an xxpermdi to get the bottom 64-bit value,
8554 ;; and then doing a move of that.
8555 (define_insn "p8_mfvsrd_3_<mode>"
8556 [(set (match_operand:DF 0 "register_operand" "=r")
8557 (unspec:DF [(match_operand:FMOVE128_GPR 1 "register_operand" "wa")]
8558 UNSPEC_P8V_RELOAD_FROM_VSX))]
8559 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8561 [(set_attr "type" "mftgpr")])
8563 (define_insn_and_split "reload_gpr_from_vsx<mode>"
8564 [(set (match_operand:FMOVE128_GPR 0 "register_operand" "=r")
8565 (unspec:FMOVE128_GPR
8566 [(match_operand:FMOVE128_GPR 1 "register_operand" "wa")]
8567 UNSPEC_P8V_RELOAD_FROM_VSX))
8568 (clobber (match_operand:FMOVE128_GPR 2 "register_operand" "=wa"))]
8569 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8571 "&& reload_completed"
8574 rtx dest = operands[0];
8575 rtx src = operands[1];
8576 rtx tmp = operands[2];
8577 rtx gpr_hi_reg = gen_highpart (DFmode, dest);
8578 rtx gpr_lo_reg = gen_lowpart (DFmode, dest);
8580 emit_insn (gen_p8_mfvsrd_3_<mode> (gpr_hi_reg, src));
8581 emit_insn (gen_vsx_xxpermdi_<mode> (tmp, src, src, GEN_INT (3)));
8582 emit_insn (gen_p8_mfvsrd_3_<mode> (gpr_lo_reg, tmp));
8584 [(set_attr "length" "12")
8585 (set_attr "type" "three")])
8587 ;; Move SFmode to a GPR from a VSX register. Because scalar floating point
8588 ;; type is stored internally as double precision, we have to convert it to the
8591 (define_insn_and_split "reload_gpr_from_vsxsf"
8592 [(set (match_operand:SF 0 "register_operand" "=r")
8593 (unspec:SF [(match_operand:SF 1 "register_operand" "wa")]
8594 UNSPEC_P8V_RELOAD_FROM_VSX))
8595 (clobber (match_operand:V4SF 2 "register_operand" "=wa"))]
8596 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8598 "&& reload_completed"
8601 rtx op0 = operands[0];
8602 rtx op1 = operands[1];
8603 rtx op2 = operands[2];
8604 rtx diop0 = simplify_gen_subreg (DImode, op0, SFmode, 0);
8606 emit_insn (gen_vsx_xscvdpspn_scalar (op2, op1));
8607 emit_insn (gen_p8_mfvsrd_4_disf (diop0, op2));
8608 emit_insn (gen_lshrdi3 (diop0, diop0, GEN_INT (32)));
8611 [(set_attr "length" "12")
8612 (set_attr "type" "three")])
8614 (define_insn "p8_mfvsrd_4_disf"
8615 [(set (match_operand:DI 0 "register_operand" "=r")
8616 (unspec:DI [(match_operand:V4SF 1 "register_operand" "wa")]
8617 UNSPEC_P8V_RELOAD_FROM_VSX))]
8618 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
8620 [(set_attr "type" "mftgpr")])
8623 ;; Next come the multi-word integer load and store and the load and store
8626 ;; List r->r after r->Y, otherwise reload will try to reload a
8627 ;; non-offsettable address by using r->r which won't make progress.
8628 ;; Use of fprs is disparaged slightly otherwise reload prefers to reload
8629 ;; a gpr into a fpr instead of reloading an invalid 'Y' address
8630 (define_insn "*movdi_internal32"
8631 [(set (match_operand:DI 0 "rs6000_nonimmediate_operand" "=Y,r,r,?m,?*d,?*d,r")
8632 (match_operand:DI 1 "input_operand" "r,Y,r,d,m,d,IJKnGHF"))]
8634 && (gpc_reg_operand (operands[0], DImode)
8635 || gpc_reg_operand (operands[1], DImode))"
8644 [(set_attr "type" "store,load,*,fpstore,fpload,fp,*")])
8647 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8648 (match_operand:DI 1 "const_int_operand" ""))]
8649 "! TARGET_POWERPC64 && reload_completed
8650 && gpr_or_gpr_p (operands[0], operands[1])
8651 && !direct_move_p (operands[0], operands[1])"
8652 [(set (match_dup 2) (match_dup 4))
8653 (set (match_dup 3) (match_dup 1))]
8656 HOST_WIDE_INT value = INTVAL (operands[1]);
8657 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8659 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8661 operands[4] = GEN_INT (value >> 32);
8662 operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8666 [(set (match_operand:DIFD 0 "rs6000_nonimmediate_operand" "")
8667 (match_operand:DIFD 1 "input_operand" ""))]
8668 "reload_completed && !TARGET_POWERPC64
8669 && gpr_or_gpr_p (operands[0], operands[1])
8670 && !direct_move_p (operands[0], operands[1])"
8672 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8674 (define_insn "*movdi_internal64"
8675 [(set (match_operand:DI 0 "nonimmediate_operand" "=Y,r,r,r,r,r,?m,?*d,?*d,r,*h,*h,r,?*wg,r,?*wj,?*wi")
8676 (match_operand:DI 1 "input_operand" "r,Y,r,I,L,nF,d,m,d,*h,r,0,*wg,r,*wj,r,O"))]
8678 && (gpc_reg_operand (operands[0], DImode)
8679 || gpc_reg_operand (operands[1], DImode))"
8698 [(set_attr "type" "store,load,*,*,*,*,fpstore,fpload,fp,mfjmpr,mtjmpr,*,mftgpr,mffgpr,mftgpr,mffgpr,vecsimple")
8699 (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4,4,4,4,4")])
8701 ;; Generate all one-bits and clear left or right.
8702 ;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
8704 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8705 (match_operand:DI 1 "mask64_operand" ""))]
8706 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8707 [(set (match_dup 0) (const_int -1))
8709 (and:DI (rotate:DI (match_dup 0)
8714 ;; Split a load of a large constant into the appropriate five-instruction
8715 ;; sequence. Handle anything in a constant number of insns.
8716 ;; When non-easy constants can go in the TOC, this should use
8717 ;; easy_fp_constant predicate.
8719 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8720 (match_operand:DI 1 "const_int_operand" ""))]
8721 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8722 [(set (match_dup 0) (match_dup 2))
8723 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8726 if (rs6000_emit_set_const (operands[0], operands[1]))
8733 [(set (match_operand:DI 0 "gpc_reg_operand" "")
8734 (match_operand:DI 1 "const_scalar_int_operand" ""))]
8735 "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8736 [(set (match_dup 0) (match_dup 2))
8737 (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8740 if (rs6000_emit_set_const (operands[0], operands[1]))
8746 ;; TImode/PTImode is similar, except that we usually want to compute the
8747 ;; address into a register and use lsi/stsi (the exception is during reload).
8749 (define_insn "*mov<mode>_string"
8750 [(set (match_operand:TI2 0 "reg_or_mem_operand" "=Q,Y,????r,????r,????r,r")
8751 (match_operand:TI2 1 "input_operand" "r,r,Q,Y,r,n"))]
8753 && (<MODE>mode != TImode || VECTOR_MEM_NONE_P (TImode))
8754 && (gpc_reg_operand (operands[0], <MODE>mode)
8755 || gpc_reg_operand (operands[1], <MODE>mode))"
8758 switch (which_alternative)
8764 return \"stswi %1,%P0,16\";
8768 /* If the address is not used in the output, we can use lsi. Otherwise,
8769 fall through to generating four loads. */
8771 && ! reg_overlap_mentioned_p (operands[0], operands[1]))
8772 return \"lswi %0,%P1,16\";
8773 /* ... fall through ... */
8780 [(set_attr "type" "store,store,load,load,*,*")
8781 (set_attr "update" "yes")
8782 (set_attr "indexed" "yes")
8783 (set (attr "cell_micro") (if_then_else (match_test "TARGET_STRING")
8784 (const_string "always")
8785 (const_string "conditional")))])
8787 (define_insn "*mov<mode>_ppc64"
8788 [(set (match_operand:TI2 0 "nonimmediate_operand" "=wQ,Y,r,r,r,r")
8789 (match_operand:TI2 1 "input_operand" "r,r,wQ,Y,r,n"))]
8790 "(TARGET_POWERPC64 && VECTOR_MEM_NONE_P (<MODE>mode)
8791 && (gpc_reg_operand (operands[0], <MODE>mode)
8792 || gpc_reg_operand (operands[1], <MODE>mode)))"
8794 return rs6000_output_move_128bit (operands);
8796 [(set_attr "type" "store,store,load,load,*,*")
8797 (set_attr "length" "8")])
8800 [(set (match_operand:TI2 0 "int_reg_operand" "")
8801 (match_operand:TI2 1 "const_scalar_int_operand" ""))]
8803 && (VECTOR_MEM_NONE_P (<MODE>mode)
8804 || (reload_completed && INT_REGNO_P (REGNO (operands[0]))))"
8805 [(set (match_dup 2) (match_dup 4))
8806 (set (match_dup 3) (match_dup 5))]
8809 operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8811 operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8813 if (CONST_WIDE_INT_P (operands[1]))
8815 operands[4] = GEN_INT (CONST_WIDE_INT_ELT (operands[1], 1));
8816 operands[5] = GEN_INT (CONST_WIDE_INT_ELT (operands[1], 0));
8818 else if (CONST_INT_P (operands[1]))
8820 operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
8821 operands[5] = operands[1];
8828 [(set (match_operand:TI2 0 "nonimmediate_operand" "")
8829 (match_operand:TI2 1 "input_operand" ""))]
8831 && gpr_or_gpr_p (operands[0], operands[1])
8832 && !direct_move_p (operands[0], operands[1])
8833 && !quad_load_store_p (operands[0], operands[1])"
8835 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8837 (define_expand "load_multiple"
8838 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8839 (match_operand:SI 1 "" ""))
8840 (use (match_operand:SI 2 "" ""))])]
8841 "TARGET_STRING && !TARGET_POWERPC64"
8849 /* Support only loading a constant number of fixed-point registers from
8850 memory and only bother with this if more than two; the machine
8851 doesn't support more than eight. */
8852 if (GET_CODE (operands[2]) != CONST_INT
8853 || INTVAL (operands[2]) <= 2
8854 || INTVAL (operands[2]) > 8
8855 || GET_CODE (operands[1]) != MEM
8856 || GET_CODE (operands[0]) != REG
8857 || REGNO (operands[0]) >= 32)
8860 count = INTVAL (operands[2]);
8861 regno = REGNO (operands[0]);
8863 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
8864 op1 = replace_equiv_address (operands[1],
8865 force_reg (SImode, XEXP (operands[1], 0)));
8867 for (i = 0; i < count; i++)
8868 XVECEXP (operands[3], 0, i)
8869 = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
8870 adjust_address_nv (op1, SImode, i * 4));
8873 (define_insn "*ldmsi8"
8874 [(match_parallel 0 "load_multiple_operation"
8875 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8876 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8877 (set (match_operand:SI 3 "gpc_reg_operand" "")
8878 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8879 (set (match_operand:SI 4 "gpc_reg_operand" "")
8880 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8881 (set (match_operand:SI 5 "gpc_reg_operand" "")
8882 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8883 (set (match_operand:SI 6 "gpc_reg_operand" "")
8884 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8885 (set (match_operand:SI 7 "gpc_reg_operand" "")
8886 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8887 (set (match_operand:SI 8 "gpc_reg_operand" "")
8888 (mem:SI (plus:SI (match_dup 1) (const_int 24))))
8889 (set (match_operand:SI 9 "gpc_reg_operand" "")
8890 (mem:SI (plus:SI (match_dup 1) (const_int 28))))])]
8891 "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
8893 { return rs6000_output_load_multiple (operands); }"
8894 [(set_attr "type" "load")
8895 (set_attr "update" "yes")
8896 (set_attr "indexed" "yes")
8897 (set_attr "length" "32")])
8899 (define_insn "*ldmsi7"
8900 [(match_parallel 0 "load_multiple_operation"
8901 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8902 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8903 (set (match_operand:SI 3 "gpc_reg_operand" "")
8904 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8905 (set (match_operand:SI 4 "gpc_reg_operand" "")
8906 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8907 (set (match_operand:SI 5 "gpc_reg_operand" "")
8908 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8909 (set (match_operand:SI 6 "gpc_reg_operand" "")
8910 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8911 (set (match_operand:SI 7 "gpc_reg_operand" "")
8912 (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8913 (set (match_operand:SI 8 "gpc_reg_operand" "")
8914 (mem:SI (plus:SI (match_dup 1) (const_int 24))))])]
8915 "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
8917 { return rs6000_output_load_multiple (operands); }"
8918 [(set_attr "type" "load")
8919 (set_attr "update" "yes")
8920 (set_attr "indexed" "yes")
8921 (set_attr "length" "32")])
8923 (define_insn "*ldmsi6"
8924 [(match_parallel 0 "load_multiple_operation"
8925 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8926 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8927 (set (match_operand:SI 3 "gpc_reg_operand" "")
8928 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8929 (set (match_operand:SI 4 "gpc_reg_operand" "")
8930 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8931 (set (match_operand:SI 5 "gpc_reg_operand" "")
8932 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8933 (set (match_operand:SI 6 "gpc_reg_operand" "")
8934 (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8935 (set (match_operand:SI 7 "gpc_reg_operand" "")
8936 (mem:SI (plus:SI (match_dup 1) (const_int 20))))])]
8937 "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
8939 { return rs6000_output_load_multiple (operands); }"
8940 [(set_attr "type" "load")
8941 (set_attr "update" "yes")
8942 (set_attr "indexed" "yes")
8943 (set_attr "length" "32")])
8945 (define_insn "*ldmsi5"
8946 [(match_parallel 0 "load_multiple_operation"
8947 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8948 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8949 (set (match_operand:SI 3 "gpc_reg_operand" "")
8950 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8951 (set (match_operand:SI 4 "gpc_reg_operand" "")
8952 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8953 (set (match_operand:SI 5 "gpc_reg_operand" "")
8954 (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8955 (set (match_operand:SI 6 "gpc_reg_operand" "")
8956 (mem:SI (plus:SI (match_dup 1) (const_int 16))))])]
8957 "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
8959 { return rs6000_output_load_multiple (operands); }"
8960 [(set_attr "type" "load")
8961 (set_attr "update" "yes")
8962 (set_attr "indexed" "yes")
8963 (set_attr "length" "32")])
8965 (define_insn "*ldmsi4"
8966 [(match_parallel 0 "load_multiple_operation"
8967 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8968 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8969 (set (match_operand:SI 3 "gpc_reg_operand" "")
8970 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8971 (set (match_operand:SI 4 "gpc_reg_operand" "")
8972 (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8973 (set (match_operand:SI 5 "gpc_reg_operand" "")
8974 (mem:SI (plus:SI (match_dup 1) (const_int 12))))])]
8975 "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
8977 { return rs6000_output_load_multiple (operands); }"
8978 [(set_attr "type" "load")
8979 (set_attr "update" "yes")
8980 (set_attr "indexed" "yes")
8981 (set_attr "length" "32")])
8983 (define_insn "*ldmsi3"
8984 [(match_parallel 0 "load_multiple_operation"
8985 [(set (match_operand:SI 2 "gpc_reg_operand" "")
8986 (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8987 (set (match_operand:SI 3 "gpc_reg_operand" "")
8988 (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8989 (set (match_operand:SI 4 "gpc_reg_operand" "")
8990 (mem:SI (plus:SI (match_dup 1) (const_int 8))))])]
8991 "TARGET_STRING && XVECLEN (operands[0], 0) == 3"
8993 { return rs6000_output_load_multiple (operands); }"
8994 [(set_attr "type" "load")
8995 (set_attr "update" "yes")
8996 (set_attr "indexed" "yes")
8997 (set_attr "length" "32")])
8999 (define_expand "store_multiple"
9000 [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
9001 (match_operand:SI 1 "" ""))
9002 (clobber (scratch:SI))
9003 (use (match_operand:SI 2 "" ""))])]
9004 "TARGET_STRING && !TARGET_POWERPC64"
9013 /* Support only storing a constant number of fixed-point registers to
9014 memory and only bother with this if more than two; the machine
9015 doesn't support more than eight. */
9016 if (GET_CODE (operands[2]) != CONST_INT
9017 || INTVAL (operands[2]) <= 2
9018 || INTVAL (operands[2]) > 8
9019 || GET_CODE (operands[0]) != MEM
9020 || GET_CODE (operands[1]) != REG
9021 || REGNO (operands[1]) >= 32)
9024 count = INTVAL (operands[2]);
9025 regno = REGNO (operands[1]);
9027 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
9028 to = force_reg (SImode, XEXP (operands[0], 0));
9029 op0 = replace_equiv_address (operands[0], to);
9031 XVECEXP (operands[3], 0, 0)
9032 = gen_rtx_SET (VOIDmode, adjust_address_nv (op0, SImode, 0), operands[1]);
9033 XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
9034 gen_rtx_SCRATCH (SImode));
9036 for (i = 1; i < count; i++)
9037 XVECEXP (operands[3], 0, i + 1)
9038 = gen_rtx_SET (VOIDmode,
9039 adjust_address_nv (op0, SImode, i * 4),
9040 gen_rtx_REG (SImode, regno + i));
9043 (define_insn "*stmsi8"
9044 [(match_parallel 0 "store_multiple_operation"
9045 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9046 (match_operand:SI 2 "gpc_reg_operand" "r"))
9047 (clobber (match_scratch:SI 3 "=X"))
9048 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9049 (match_operand:SI 4 "gpc_reg_operand" "r"))
9050 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9051 (match_operand:SI 5 "gpc_reg_operand" "r"))
9052 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9053 (match_operand:SI 6 "gpc_reg_operand" "r"))
9054 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9055 (match_operand:SI 7 "gpc_reg_operand" "r"))
9056 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9057 (match_operand:SI 8 "gpc_reg_operand" "r"))
9058 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9059 (match_operand:SI 9 "gpc_reg_operand" "r"))
9060 (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
9061 (match_operand:SI 10 "gpc_reg_operand" "r"))])]
9062 "TARGET_STRING && XVECLEN (operands[0], 0) == 9"
9064 [(set_attr "type" "store")
9065 (set_attr "update" "yes")
9066 (set_attr "indexed" "yes")
9067 (set_attr "cell_micro" "always")])
9069 (define_insn "*stmsi7"
9070 [(match_parallel 0 "store_multiple_operation"
9071 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9072 (match_operand:SI 2 "gpc_reg_operand" "r"))
9073 (clobber (match_scratch:SI 3 "=X"))
9074 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9075 (match_operand:SI 4 "gpc_reg_operand" "r"))
9076 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9077 (match_operand:SI 5 "gpc_reg_operand" "r"))
9078 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9079 (match_operand:SI 6 "gpc_reg_operand" "r"))
9080 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9081 (match_operand:SI 7 "gpc_reg_operand" "r"))
9082 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9083 (match_operand:SI 8 "gpc_reg_operand" "r"))
9084 (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9085 (match_operand:SI 9 "gpc_reg_operand" "r"))])]
9086 "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
9088 [(set_attr "type" "store")
9089 (set_attr "update" "yes")
9090 (set_attr "indexed" "yes")
9091 (set_attr "cell_micro" "always")])
9093 (define_insn "*stmsi6"
9094 [(match_parallel 0 "store_multiple_operation"
9095 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9096 (match_operand:SI 2 "gpc_reg_operand" "r"))
9097 (clobber (match_scratch:SI 3 "=X"))
9098 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9099 (match_operand:SI 4 "gpc_reg_operand" "r"))
9100 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9101 (match_operand:SI 5 "gpc_reg_operand" "r"))
9102 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9103 (match_operand:SI 6 "gpc_reg_operand" "r"))
9104 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9105 (match_operand:SI 7 "gpc_reg_operand" "r"))
9106 (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9107 (match_operand:SI 8 "gpc_reg_operand" "r"))])]
9108 "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
9110 [(set_attr "type" "store")
9111 (set_attr "update" "yes")
9112 (set_attr "indexed" "yes")
9113 (set_attr "cell_micro" "always")])
9115 (define_insn "*stmsi5"
9116 [(match_parallel 0 "store_multiple_operation"
9117 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9118 (match_operand:SI 2 "gpc_reg_operand" "r"))
9119 (clobber (match_scratch:SI 3 "=X"))
9120 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9121 (match_operand:SI 4 "gpc_reg_operand" "r"))
9122 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9123 (match_operand:SI 5 "gpc_reg_operand" "r"))
9124 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9125 (match_operand:SI 6 "gpc_reg_operand" "r"))
9126 (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9127 (match_operand:SI 7 "gpc_reg_operand" "r"))])]
9128 "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
9130 [(set_attr "type" "store")
9131 (set_attr "update" "yes")
9132 (set_attr "indexed" "yes")
9133 (set_attr "cell_micro" "always")])
9135 (define_insn "*stmsi4"
9136 [(match_parallel 0 "store_multiple_operation"
9137 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9138 (match_operand:SI 2 "gpc_reg_operand" "r"))
9139 (clobber (match_scratch:SI 3 "=X"))
9140 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9141 (match_operand:SI 4 "gpc_reg_operand" "r"))
9142 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9143 (match_operand:SI 5 "gpc_reg_operand" "r"))
9144 (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9145 (match_operand:SI 6 "gpc_reg_operand" "r"))])]
9146 "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
9148 [(set_attr "type" "store")
9149 (set_attr "update" "yes")
9150 (set_attr "indexed" "yes")
9151 (set_attr "cell_micro" "always")])
9153 (define_insn "*stmsi3"
9154 [(match_parallel 0 "store_multiple_operation"
9155 [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9156 (match_operand:SI 2 "gpc_reg_operand" "r"))
9157 (clobber (match_scratch:SI 3 "=X"))
9158 (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9159 (match_operand:SI 4 "gpc_reg_operand" "r"))
9160 (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9161 (match_operand:SI 5 "gpc_reg_operand" "r"))])]
9162 "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
9164 [(set_attr "type" "store")
9165 (set_attr "update" "yes")
9166 (set_attr "indexed" "yes")
9167 (set_attr "cell_micro" "always")])
9169 (define_expand "setmemsi"
9170 [(parallel [(set (match_operand:BLK 0 "" "")
9171 (match_operand 2 "const_int_operand" ""))
9172 (use (match_operand:SI 1 "" ""))
9173 (use (match_operand:SI 3 "" ""))])]
9177 /* If value to set is not zero, use the library routine. */
9178 if (operands[2] != const0_rtx)
9181 if (expand_block_clear (operands))
9187 ;; String/block move insn.
9188 ;; Argument 0 is the destination
9189 ;; Argument 1 is the source
9190 ;; Argument 2 is the length
9191 ;; Argument 3 is the alignment
9193 (define_expand "movmemsi"
9194 [(parallel [(set (match_operand:BLK 0 "" "")
9195 (match_operand:BLK 1 "" ""))
9196 (use (match_operand:SI 2 "" ""))
9197 (use (match_operand:SI 3 "" ""))])]
9201 if (expand_block_move (operands))
9207 ;; Move up to 32 bytes at a time. The fixed registers are needed because the
9208 ;; register allocator doesn't have a clue about allocating 8 word registers.
9209 ;; rD/rS = r5 is preferred, efficient form.
9210 (define_expand "movmemsi_8reg"
9211 [(parallel [(set (match_operand 0 "" "")
9212 (match_operand 1 "" ""))
9213 (use (match_operand 2 "" ""))
9214 (use (match_operand 3 "" ""))
9215 (clobber (reg:SI 5))
9216 (clobber (reg:SI 6))
9217 (clobber (reg:SI 7))
9218 (clobber (reg:SI 8))
9219 (clobber (reg:SI 9))
9220 (clobber (reg:SI 10))
9221 (clobber (reg:SI 11))
9222 (clobber (reg:SI 12))
9223 (clobber (match_scratch:SI 4 ""))])]
9228 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9229 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9230 (use (match_operand:SI 2 "immediate_operand" "i"))
9231 (use (match_operand:SI 3 "immediate_operand" "i"))
9232 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9233 (clobber (reg:SI 6))
9234 (clobber (reg:SI 7))
9235 (clobber (reg:SI 8))
9236 (clobber (reg:SI 9))
9237 (clobber (reg:SI 10))
9238 (clobber (reg:SI 11))
9239 (clobber (reg:SI 12))
9240 (clobber (match_scratch:SI 5 "=X"))]
9242 && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9243 || INTVAL (operands[2]) == 0)
9244 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9245 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9246 && REGNO (operands[4]) == 5"
9247 "lswi %4,%1,%2\;stswi %4,%0,%2"
9248 [(set_attr "type" "store")
9249 (set_attr "update" "yes")
9250 (set_attr "indexed" "yes")
9251 (set_attr "cell_micro" "always")
9252 (set_attr "length" "8")])
9254 ;; Move up to 24 bytes at a time. The fixed registers are needed because the
9255 ;; register allocator doesn't have a clue about allocating 6 word registers.
9256 ;; rD/rS = r5 is preferred, efficient form.
9257 (define_expand "movmemsi_6reg"
9258 [(parallel [(set (match_operand 0 "" "")
9259 (match_operand 1 "" ""))
9260 (use (match_operand 2 "" ""))
9261 (use (match_operand 3 "" ""))
9262 (clobber (reg:SI 5))
9263 (clobber (reg:SI 6))
9264 (clobber (reg:SI 7))
9265 (clobber (reg:SI 8))
9266 (clobber (reg:SI 9))
9267 (clobber (reg:SI 10))
9268 (clobber (match_scratch:SI 4 ""))])]
9273 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9274 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9275 (use (match_operand:SI 2 "immediate_operand" "i"))
9276 (use (match_operand:SI 3 "immediate_operand" "i"))
9277 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9278 (clobber (reg:SI 6))
9279 (clobber (reg:SI 7))
9280 (clobber (reg:SI 8))
9281 (clobber (reg:SI 9))
9282 (clobber (reg:SI 10))
9283 (clobber (match_scratch:SI 5 "=X"))]
9285 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9286 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9287 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9288 && REGNO (operands[4]) == 5"
9289 "lswi %4,%1,%2\;stswi %4,%0,%2"
9290 [(set_attr "type" "store")
9291 (set_attr "update" "yes")
9292 (set_attr "indexed" "yes")
9293 (set_attr "cell_micro" "always")
9294 (set_attr "length" "8")])
9296 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
9297 ;; problems with TImode.
9298 ;; rD/rS = r5 is preferred, efficient form.
9299 (define_expand "movmemsi_4reg"
9300 [(parallel [(set (match_operand 0 "" "")
9301 (match_operand 1 "" ""))
9302 (use (match_operand 2 "" ""))
9303 (use (match_operand 3 "" ""))
9304 (clobber (reg:SI 5))
9305 (clobber (reg:SI 6))
9306 (clobber (reg:SI 7))
9307 (clobber (reg:SI 8))
9308 (clobber (match_scratch:SI 4 ""))])]
9313 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9314 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9315 (use (match_operand:SI 2 "immediate_operand" "i"))
9316 (use (match_operand:SI 3 "immediate_operand" "i"))
9317 (clobber (match_operand:SI 4 "gpc_reg_operand" "=&r"))
9318 (clobber (reg:SI 6))
9319 (clobber (reg:SI 7))
9320 (clobber (reg:SI 8))
9321 (clobber (match_scratch:SI 5 "=X"))]
9323 && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9324 && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9325 && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9326 && REGNO (operands[4]) == 5"
9327 "lswi %4,%1,%2\;stswi %4,%0,%2"
9328 [(set_attr "type" "store")
9329 (set_attr "update" "yes")
9330 (set_attr "indexed" "yes")
9331 (set_attr "cell_micro" "always")
9332 (set_attr "length" "8")])
9334 ;; Move up to 8 bytes at a time.
9335 (define_expand "movmemsi_2reg"
9336 [(parallel [(set (match_operand 0 "" "")
9337 (match_operand 1 "" ""))
9338 (use (match_operand 2 "" ""))
9339 (use (match_operand 3 "" ""))
9340 (clobber (match_scratch:DI 4 ""))
9341 (clobber (match_scratch:SI 5 ""))])]
9342 "TARGET_STRING && ! TARGET_POWERPC64"
9346 [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9347 (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9348 (use (match_operand:SI 2 "immediate_operand" "i"))
9349 (use (match_operand:SI 3 "immediate_operand" "i"))
9350 (clobber (match_scratch:DI 4 "=&r"))
9351 (clobber (match_scratch:SI 5 "=X"))]
9352 "TARGET_STRING && ! TARGET_POWERPC64
9353 && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9354 "lswi %4,%1,%2\;stswi %4,%0,%2"
9355 [(set_attr "type" "store")
9356 (set_attr "update" "yes")
9357 (set_attr "indexed" "yes")
9358 (set_attr "cell_micro" "always")
9359 (set_attr "length" "8")])
9361 ;; Move up to 4 bytes at a time.
9362 (define_expand "movmemsi_1reg"
9363 [(parallel [(set (match_operand 0 "" "")
9364 (match_operand 1 "" ""))
9365 (use (match_operand 2 "" ""))
9366 (use (match_operand 3 "" ""))
9367 (clobber (match_scratch:SI 4 ""))
9368 (clobber (match_scratch:SI 5 ""))])]
9373 [(set (mem:BLK (match_operand:P 0 "gpc_reg_operand" "b"))
9374 (mem:BLK (match_operand:P 1 "gpc_reg_operand" "b")))
9375 (use (match_operand:SI 2 "immediate_operand" "i"))
9376 (use (match_operand:SI 3 "immediate_operand" "i"))
9377 (clobber (match_scratch:SI 4 "=&r"))
9378 (clobber (match_scratch:SI 5 "=X"))]
9379 "TARGET_STRING && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9380 "lswi %4,%1,%2\;stswi %4,%0,%2"
9381 [(set_attr "type" "store")
9382 (set_attr "update" "yes")
9383 (set_attr "indexed" "yes")
9384 (set_attr "cell_micro" "always")
9385 (set_attr "length" "8")])
9387 ;; Define insns that do load or store with update. Some of these we can
9388 ;; get by using pre-decrement or pre-increment, but the hardware can also
9389 ;; do cases where the increment is not the size of the object.
9391 ;; In all these cases, we use operands 0 and 1 for the register being
9392 ;; incremented because those are the operands that local-alloc will
9393 ;; tie and these are the pair most likely to be tieable (and the ones
9394 ;; that will benefit the most).
9396 (define_insn "*movdi_update1"
9397 [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
9398 (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9399 (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
9400 (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9401 (plus:DI (match_dup 1) (match_dup 2)))]
9402 "TARGET_POWERPC64 && TARGET_UPDATE
9403 && (!avoiding_indexed_address_p (DImode)
9404 || !gpc_reg_operand (operands[2], DImode))"
9408 [(set_attr "type" "load")
9409 (set_attr "update" "yes")
9410 (set_attr "indexed" "yes,no")])
9412 (define_insn "movdi_<mode>_update"
9413 [(set (mem:DI (plus:P (match_operand:P 1 "gpc_reg_operand" "0,0")
9414 (match_operand:P 2 "reg_or_aligned_short_operand" "r,I")))
9415 (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9416 (set (match_operand:P 0 "gpc_reg_operand" "=b,b")
9417 (plus:P (match_dup 1) (match_dup 2)))]
9418 "TARGET_POWERPC64 && TARGET_UPDATE
9419 && (!avoiding_indexed_address_p (Pmode)
9420 || !gpc_reg_operand (operands[2], Pmode)
9421 || (REG_P (operands[0])
9422 && REGNO (operands[0]) == STACK_POINTER_REGNUM))"
9426 [(set_attr "type" "store")
9427 (set_attr "update" "yes")
9428 (set_attr "indexed" "yes,no")])
9430 ;; This pattern is only conditional on TARGET_POWERPC64, as it is
9431 ;; needed for stack allocation, even if the user passes -mno-update.
9432 (define_insn "movdi_<mode>_update_stack"
9433 [(set (mem:DI (plus:P (match_operand:P 1 "gpc_reg_operand" "0,0")
9434 (match_operand:P 2 "reg_or_aligned_short_operand" "r,I")))
9435 (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9436 (set (match_operand:P 0 "gpc_reg_operand" "=b,b")
9437 (plus:P (match_dup 1) (match_dup 2)))]
9442 [(set_attr "type" "store")
9443 (set_attr "update" "yes")
9444 (set_attr "indexed" "yes,no")])
9446 (define_insn "*movsi_update1"
9447 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9448 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9449 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9450 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9451 (plus:SI (match_dup 1) (match_dup 2)))]
9453 && (!avoiding_indexed_address_p (SImode)
9454 || !gpc_reg_operand (operands[2], SImode))"
9458 [(set_attr "type" "load")
9459 (set_attr "update" "yes")
9460 (set_attr "indexed" "yes,no")])
9462 (define_insn "*movsi_update2"
9463 [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
9465 (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
9466 (match_operand:DI 2 "gpc_reg_operand" "r")))))
9467 (set (match_operand:DI 0 "gpc_reg_operand" "=b")
9468 (plus:DI (match_dup 1) (match_dup 2)))]
9469 "TARGET_POWERPC64 && rs6000_gen_cell_microcode
9470 && !avoiding_indexed_address_p (DImode)"
9472 [(set_attr "type" "load")
9473 (set_attr "sign_extend" "yes")
9474 (set_attr "update" "yes")
9475 (set_attr "indexed" "yes")])
9477 (define_insn "movsi_update"
9478 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9479 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9480 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9481 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9482 (plus:SI (match_dup 1) (match_dup 2)))]
9484 && (!avoiding_indexed_address_p (SImode)
9485 || !gpc_reg_operand (operands[2], SImode)
9486 || (REG_P (operands[0])
9487 && REGNO (operands[0]) == STACK_POINTER_REGNUM))"
9491 [(set_attr "type" "store")
9492 (set_attr "update" "yes")
9493 (set_attr "indexed" "yes,no")])
9495 ;; This is an unconditional pattern; needed for stack allocation, even
9496 ;; if the user passes -mno-update.
9497 (define_insn "movsi_update_stack"
9498 [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9499 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9500 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9501 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9502 (plus:SI (match_dup 1) (match_dup 2)))]
9507 [(set_attr "type" "store")
9508 (set_attr "update" "yes")
9509 (set_attr "indexed" "yes,no")])
9511 (define_insn "*movhi_update1"
9512 [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
9513 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9514 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9515 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9516 (plus:SI (match_dup 1) (match_dup 2)))]
9518 && (!avoiding_indexed_address_p (SImode)
9519 || !gpc_reg_operand (operands[2], SImode))"
9523 [(set_attr "type" "load")
9524 (set_attr "update" "yes")
9525 (set_attr "indexed" "yes,no")])
9527 (define_insn "*movhi_update2"
9528 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9530 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9531 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9532 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9533 (plus:SI (match_dup 1) (match_dup 2)))]
9535 && (!avoiding_indexed_address_p (SImode)
9536 || !gpc_reg_operand (operands[2], SImode))"
9540 [(set_attr "type" "load")
9541 (set_attr "update" "yes")
9542 (set_attr "indexed" "yes,no")])
9544 (define_insn "*movhi_update3"
9545 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9547 (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9548 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9549 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9550 (plus:SI (match_dup 1) (match_dup 2)))]
9551 "TARGET_UPDATE && rs6000_gen_cell_microcode
9552 && (!avoiding_indexed_address_p (SImode)
9553 || !gpc_reg_operand (operands[2], SImode))"
9557 [(set_attr "type" "load")
9558 (set_attr "sign_extend" "yes")
9559 (set_attr "update" "yes")
9560 (set_attr "indexed" "yes,no")])
9562 (define_insn "*movhi_update4"
9563 [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9564 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9565 (match_operand:HI 3 "gpc_reg_operand" "r,r"))
9566 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9567 (plus:SI (match_dup 1) (match_dup 2)))]
9569 && (!avoiding_indexed_address_p (SImode)
9570 || !gpc_reg_operand (operands[2], SImode))"
9574 [(set_attr "type" "store")
9575 (set_attr "update" "yes")
9576 (set_attr "indexed" "yes,no")])
9578 (define_insn "*movqi_update1"
9579 [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
9580 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9581 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9582 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9583 (plus:SI (match_dup 1) (match_dup 2)))]
9585 && (!avoiding_indexed_address_p (SImode)
9586 || !gpc_reg_operand (operands[2], SImode))"
9590 [(set_attr "type" "load")
9591 (set_attr "update" "yes")
9592 (set_attr "indexed" "yes,no")])
9594 (define_insn "*movqi_update2"
9595 [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9597 (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9598 (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9599 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9600 (plus:SI (match_dup 1) (match_dup 2)))]
9602 && (!avoiding_indexed_address_p (SImode)
9603 || !gpc_reg_operand (operands[2], SImode))"
9607 [(set_attr "type" "load")
9608 (set_attr "update" "yes")
9609 (set_attr "indexed" "yes,no")])
9611 (define_insn "*movqi_update3"
9612 [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9613 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9614 (match_operand:QI 3 "gpc_reg_operand" "r,r"))
9615 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9616 (plus:SI (match_dup 1) (match_dup 2)))]
9618 && (!avoiding_indexed_address_p (SImode)
9619 || !gpc_reg_operand (operands[2], SImode))"
9623 [(set_attr "type" "store")
9624 (set_attr "update" "yes")
9625 (set_attr "indexed" "yes,no")])
9627 (define_insn "*movsf_update1"
9628 [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
9629 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9630 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9631 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9632 (plus:SI (match_dup 1) (match_dup 2)))]
9633 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT && TARGET_UPDATE
9634 && (!avoiding_indexed_address_p (SImode)
9635 || !gpc_reg_operand (operands[2], SImode))"
9639 [(set_attr "type" "fpload")
9640 (set_attr "update" "yes")
9641 (set_attr "indexed" "yes,no")])
9643 (define_insn "*movsf_update2"
9644 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9645 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9646 (match_operand:SF 3 "gpc_reg_operand" "f,f"))
9647 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9648 (plus:SI (match_dup 1) (match_dup 2)))]
9649 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT && TARGET_UPDATE
9650 && (!avoiding_indexed_address_p (SImode)
9651 || !gpc_reg_operand (operands[2], SImode))"
9655 [(set_attr "type" "fpstore")
9656 (set_attr "update" "yes")
9657 (set_attr "indexed" "yes,no")])
9659 (define_insn "*movsf_update3"
9660 [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
9661 (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9662 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9663 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9664 (plus:SI (match_dup 1) (match_dup 2)))]
9665 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE
9666 && (!avoiding_indexed_address_p (SImode)
9667 || !gpc_reg_operand (operands[2], SImode))"
9671 [(set_attr "type" "load")
9672 (set_attr "update" "yes")
9673 (set_attr "indexed" "yes,no")])
9675 (define_insn "*movsf_update4"
9676 [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9677 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9678 (match_operand:SF 3 "gpc_reg_operand" "r,r"))
9679 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9680 (plus:SI (match_dup 1) (match_dup 2)))]
9681 "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE
9682 && (!avoiding_indexed_address_p (SImode)
9683 || !gpc_reg_operand (operands[2], SImode))"
9687 [(set_attr "type" "store")
9688 (set_attr "update" "yes")
9689 (set_attr "indexed" "yes,no")])
9691 (define_insn "*movdf_update1"
9692 [(set (match_operand:DF 3 "gpc_reg_operand" "=d,d")
9693 (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9694 (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9695 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9696 (plus:SI (match_dup 1) (match_dup 2)))]
9697 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_UPDATE
9698 && (!avoiding_indexed_address_p (SImode)
9699 || !gpc_reg_operand (operands[2], SImode))"
9703 [(set_attr "type" "fpload")
9704 (set_attr "update" "yes")
9705 (set_attr "indexed" "yes,no")])
9707 (define_insn "*movdf_update2"
9708 [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9709 (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9710 (match_operand:DF 3 "gpc_reg_operand" "d,d"))
9711 (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9712 (plus:SI (match_dup 1) (match_dup 2)))]
9713 "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_UPDATE
9714 && (!avoiding_indexed_address_p (SImode)
9715 || !gpc_reg_operand (operands[2], SImode))"
9719 [(set_attr "type" "fpstore")
9720 (set_attr "update" "yes")
9721 (set_attr "indexed" "yes,no")])
9724 ;; After inserting conditional returns we can sometimes have
9725 ;; unnecessary register moves. Unfortunately we cannot have a
9726 ;; modeless peephole here, because some single SImode sets have early
9727 ;; clobber outputs. Although those sets expand to multi-ppc-insn
9728 ;; sequences, using get_attr_length here will smash the operands
9729 ;; array. Neither is there an early_cobbler_p predicate.
9730 ;; Disallow subregs for E500 so we don't munge frob_di_df_2.
9732 [(set (match_operand:DF 0 "gpc_reg_operand" "")
9733 (match_operand:DF 1 "any_operand" ""))
9734 (set (match_operand:DF 2 "gpc_reg_operand" "")
9736 "!(TARGET_E500_DOUBLE && GET_CODE (operands[2]) == SUBREG)
9737 && peep2_reg_dead_p (2, operands[0])"
9738 [(set (match_dup 2) (match_dup 1))])
9741 [(set (match_operand:SF 0 "gpc_reg_operand" "")
9742 (match_operand:SF 1 "any_operand" ""))
9743 (set (match_operand:SF 2 "gpc_reg_operand" "")
9745 "peep2_reg_dead_p (2, operands[0])"
9746 [(set (match_dup 2) (match_dup 1))])
9751 ;; Mode attributes for different ABIs.
9752 (define_mode_iterator TLSmode [(SI "! TARGET_64BIT") (DI "TARGET_64BIT")])
9753 (define_mode_attr tls_abi_suffix [(SI "32") (DI "64")])
9754 (define_mode_attr tls_sysv_suffix [(SI "si") (DI "di")])
9755 (define_mode_attr tls_insn_suffix [(SI "wz") (DI "d")])
9757 (define_insn_and_split "tls_gd_aix<TLSmode:tls_abi_suffix>"
9758 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9759 (call (mem:TLSmode (match_operand:TLSmode 3 "symbol_ref_operand" "s"))
9760 (match_operand 4 "" "g")))
9761 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
9762 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
9764 (clobber (reg:SI LR_REGNO))]
9765 "HAVE_AS_TLS && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
9767 if (TARGET_CMODEL != CMODEL_SMALL)
9768 return "addis %0,%1,%2@got@tlsgd@ha\;addi %0,%0,%2@got@tlsgd@l\;"
9771 return "addi %0,%1,%2@got@tlsgd\;bl %z3\;nop";
9773 "&& TARGET_TLS_MARKERS"
9775 (unspec:TLSmode [(match_dup 1)
9778 (parallel [(set (match_dup 0)
9779 (call (mem:TLSmode (match_dup 3))
9781 (unspec:TLSmode [(match_dup 2)] UNSPEC_TLSGD)
9782 (clobber (reg:SI LR_REGNO))])]
9784 [(set_attr "type" "two")
9785 (set (attr "length")
9786 (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
9790 (define_insn_and_split "tls_gd_sysv<TLSmode:tls_sysv_suffix>"
9791 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9792 (call (mem:TLSmode (match_operand:TLSmode 3 "symbol_ref_operand" "s"))
9793 (match_operand 4 "" "g")))
9794 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
9795 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
9797 (clobber (reg:SI LR_REGNO))]
9798 "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4"
9802 if (TARGET_SECURE_PLT && flag_pic == 2)
9803 return "addi %0,%1,%2@got@tlsgd\;bl %z3+32768@plt";
9805 return "addi %0,%1,%2@got@tlsgd\;bl %z3@plt";
9808 return "addi %0,%1,%2@got@tlsgd\;bl %z3";
9810 "&& TARGET_TLS_MARKERS"
9812 (unspec:TLSmode [(match_dup 1)
9815 (parallel [(set (match_dup 0)
9816 (call (mem:TLSmode (match_dup 3))
9818 (unspec:TLSmode [(match_dup 2)] UNSPEC_TLSGD)
9819 (clobber (reg:SI LR_REGNO))])]
9821 [(set_attr "type" "two")
9822 (set_attr "length" "8")])
9824 (define_insn_and_split "*tls_gd<TLSmode:tls_abi_suffix>"
9825 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9826 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
9827 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
9829 "HAVE_AS_TLS && TARGET_TLS_MARKERS"
9830 "addi %0,%1,%2@got@tlsgd"
9831 "&& TARGET_CMODEL != CMODEL_SMALL"
9834 (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGD)))
9836 (lo_sum:TLSmode (match_dup 3)
9837 (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGD)))]
9840 operands[3] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
9842 [(set (attr "length")
9843 (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
9847 (define_insn "*tls_gd_high<TLSmode:tls_abi_suffix>"
9848 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9850 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
9851 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
9853 "HAVE_AS_TLS && TARGET_TLS_MARKERS && TARGET_CMODEL != CMODEL_SMALL"
9854 "addis %0,%1,%2@got@tlsgd@ha"
9855 [(set_attr "length" "4")])
9857 (define_insn "*tls_gd_low<TLSmode:tls_abi_suffix>"
9858 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9859 (lo_sum:TLSmode (match_operand:TLSmode 1 "gpc_reg_operand" "b")
9860 (unspec:TLSmode [(match_operand:TLSmode 3 "gpc_reg_operand" "b")
9861 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
9863 "HAVE_AS_TLS && TARGET_TLS_MARKERS && TARGET_CMODEL != CMODEL_SMALL"
9864 "addi %0,%1,%2@got@tlsgd@l"
9865 [(set_attr "length" "4")])
9867 (define_insn "*tls_gd_call_aix<TLSmode:tls_abi_suffix>"
9868 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9869 (call (mem:TLSmode (match_operand:TLSmode 1 "symbol_ref_operand" "s"))
9870 (match_operand 2 "" "g")))
9871 (unspec:TLSmode [(match_operand:TLSmode 3 "rs6000_tls_symbol_ref" "")]
9873 (clobber (reg:SI LR_REGNO))]
9874 "HAVE_AS_TLS && TARGET_TLS_MARKERS
9875 && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
9876 "bl %z1(%3@tlsgd)\;nop"
9877 [(set_attr "type" "branch")
9878 (set_attr "length" "8")])
9880 (define_insn "*tls_gd_call_sysv<TLSmode:tls_abi_suffix>"
9881 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9882 (call (mem:TLSmode (match_operand:TLSmode 1 "symbol_ref_operand" "s"))
9883 (match_operand 2 "" "g")))
9884 (unspec:TLSmode [(match_operand:TLSmode 3 "rs6000_tls_symbol_ref" "")]
9886 (clobber (reg:SI LR_REGNO))]
9887 "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4 && TARGET_TLS_MARKERS"
9891 if (TARGET_SECURE_PLT && flag_pic == 2)
9892 return "bl %z1+32768(%3@tlsgd)@plt";
9893 return "bl %z1(%3@tlsgd)@plt";
9895 return "bl %z1(%3@tlsgd)";
9897 [(set_attr "type" "branch")
9898 (set_attr "length" "4")])
9900 (define_insn_and_split "tls_ld_aix<TLSmode:tls_abi_suffix>"
9901 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9902 (call (mem:TLSmode (match_operand:TLSmode 2 "symbol_ref_operand" "s"))
9903 (match_operand 3 "" "g")))
9904 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
9906 (clobber (reg:SI LR_REGNO))]
9907 "HAVE_AS_TLS && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
9909 if (TARGET_CMODEL != CMODEL_SMALL)
9910 return "addis %0,%1,%&@got@tlsld@ha\;addi %0,%0,%&@got@tlsld@l\;"
9913 return "addi %0,%1,%&@got@tlsld\;bl %z2\;nop";
9915 "&& TARGET_TLS_MARKERS"
9917 (unspec:TLSmode [(match_dup 1)]
9919 (parallel [(set (match_dup 0)
9920 (call (mem:TLSmode (match_dup 2))
9922 (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
9923 (clobber (reg:SI LR_REGNO))])]
9925 [(set_attr "type" "two")
9926 (set (attr "length")
9927 (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
9931 (define_insn_and_split "tls_ld_sysv<TLSmode:tls_sysv_suffix>"
9932 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9933 (call (mem:TLSmode (match_operand:TLSmode 2 "symbol_ref_operand" "s"))
9934 (match_operand 3 "" "g")))
9935 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
9937 (clobber (reg:SI LR_REGNO))]
9938 "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4"
9942 if (TARGET_SECURE_PLT && flag_pic == 2)
9943 return "addi %0,%1,%&@got@tlsld\;bl %z2+32768@plt";
9945 return "addi %0,%1,%&@got@tlsld\;bl %z2@plt";
9948 return "addi %0,%1,%&@got@tlsld\;bl %z2";
9950 "&& TARGET_TLS_MARKERS"
9952 (unspec:TLSmode [(match_dup 1)]
9954 (parallel [(set (match_dup 0)
9955 (call (mem:TLSmode (match_dup 2))
9957 (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
9958 (clobber (reg:SI LR_REGNO))])]
9960 [(set_attr "length" "8")])
9962 (define_insn_and_split "*tls_ld<TLSmode:tls_abi_suffix>"
9963 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9964 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
9966 "HAVE_AS_TLS && TARGET_TLS_MARKERS"
9967 "addi %0,%1,%&@got@tlsld"
9968 "&& TARGET_CMODEL != CMODEL_SMALL"
9971 (unspec:TLSmode [(const_int 0) (match_dup 1)] UNSPEC_TLSLD)))
9973 (lo_sum:TLSmode (match_dup 2)
9974 (unspec:TLSmode [(const_int 0) (match_dup 1)] UNSPEC_TLSLD)))]
9977 operands[2] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
9979 [(set (attr "length")
9980 (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
9984 (define_insn "*tls_ld_high<TLSmode:tls_abi_suffix>"
9985 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9987 (unspec:TLSmode [(const_int 0)
9988 (match_operand:TLSmode 1 "gpc_reg_operand" "b")]
9990 "HAVE_AS_TLS && TARGET_TLS_MARKERS && TARGET_CMODEL != CMODEL_SMALL"
9991 "addis %0,%1,%&@got@tlsld@ha"
9992 [(set_attr "length" "4")])
9994 (define_insn "*tls_ld_low<TLSmode:tls_abi_suffix>"
9995 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
9996 (lo_sum:TLSmode (match_operand:TLSmode 1 "gpc_reg_operand" "b")
9997 (unspec:TLSmode [(const_int 0)
9998 (match_operand:TLSmode 2 "gpc_reg_operand" "b")]
10000 "HAVE_AS_TLS && TARGET_TLS_MARKERS && TARGET_CMODEL != CMODEL_SMALL"
10001 "addi %0,%1,%&@got@tlsld@l"
10002 [(set_attr "length" "4")])
10004 (define_insn "*tls_ld_call_aix<TLSmode:tls_abi_suffix>"
10005 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10006 (call (mem:TLSmode (match_operand:TLSmode 1 "symbol_ref_operand" "s"))
10007 (match_operand 2 "" "g")))
10008 (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
10009 (clobber (reg:SI LR_REGNO))]
10010 "HAVE_AS_TLS && TARGET_TLS_MARKERS
10011 && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
10012 "bl %z1(%&@tlsld)\;nop"
10013 [(set_attr "type" "branch")
10014 (set_attr "length" "8")])
10016 (define_insn "*tls_ld_call_sysv<TLSmode:tls_abi_suffix>"
10017 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10018 (call (mem:TLSmode (match_operand:TLSmode 1 "symbol_ref_operand" "s"))
10019 (match_operand 2 "" "g")))
10020 (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
10021 (clobber (reg:SI LR_REGNO))]
10022 "HAVE_AS_TLS && DEFAULT_ABI == ABI_V4 && TARGET_TLS_MARKERS"
10026 if (TARGET_SECURE_PLT && flag_pic == 2)
10027 return "bl %z1+32768(%&@tlsld)@plt";
10028 return "bl %z1(%&@tlsld)@plt";
10030 return "bl %z1(%&@tlsld)";
10032 [(set_attr "type" "branch")
10033 (set_attr "length" "4")])
10035 (define_insn "tls_dtprel_<TLSmode:tls_abi_suffix>"
10036 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10037 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10038 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10039 UNSPEC_TLSDTPREL))]
10041 "addi %0,%1,%2@dtprel")
10043 (define_insn "tls_dtprel_ha_<TLSmode:tls_abi_suffix>"
10044 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10045 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10046 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10047 UNSPEC_TLSDTPRELHA))]
10049 "addis %0,%1,%2@dtprel@ha")
10051 (define_insn "tls_dtprel_lo_<TLSmode:tls_abi_suffix>"
10052 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10053 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10054 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10055 UNSPEC_TLSDTPRELLO))]
10057 "addi %0,%1,%2@dtprel@l")
10059 (define_insn_and_split "tls_got_dtprel_<TLSmode:tls_abi_suffix>"
10060 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10061 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10062 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10063 UNSPEC_TLSGOTDTPREL))]
10065 "l<TLSmode:tls_insn_suffix> %0,%2@got@dtprel(%1)"
10066 "&& TARGET_CMODEL != CMODEL_SMALL"
10067 [(set (match_dup 3)
10069 (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGOTDTPREL)))
10071 (lo_sum:TLSmode (match_dup 3)
10072 (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGOTDTPREL)))]
10075 operands[3] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
10077 [(set (attr "length")
10078 (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
10082 (define_insn "*tls_got_dtprel_high<TLSmode:tls_abi_suffix>"
10083 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10085 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10086 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10087 UNSPEC_TLSGOTDTPREL)))]
10088 "HAVE_AS_TLS && TARGET_CMODEL != CMODEL_SMALL"
10089 "addis %0,%1,%2@got@dtprel@ha"
10090 [(set_attr "length" "4")])
10092 (define_insn "*tls_got_dtprel_low<TLSmode:tls_abi_suffix>"
10093 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10094 (lo_sum:TLSmode (match_operand:TLSmode 1 "gpc_reg_operand" "b")
10095 (unspec:TLSmode [(match_operand:TLSmode 3 "gpc_reg_operand" "b")
10096 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10097 UNSPEC_TLSGOTDTPREL)))]
10098 "HAVE_AS_TLS && TARGET_CMODEL != CMODEL_SMALL"
10099 "l<TLSmode:tls_insn_suffix> %0,%2@got@dtprel@l(%1)"
10100 [(set_attr "length" "4")])
10102 (define_insn "tls_tprel_<TLSmode:tls_abi_suffix>"
10103 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10104 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10105 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10108 "addi %0,%1,%2@tprel")
10110 (define_insn "tls_tprel_ha_<TLSmode:tls_abi_suffix>"
10111 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10112 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10113 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10114 UNSPEC_TLSTPRELHA))]
10116 "addis %0,%1,%2@tprel@ha")
10118 (define_insn "tls_tprel_lo_<TLSmode:tls_abi_suffix>"
10119 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10120 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10121 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10122 UNSPEC_TLSTPRELLO))]
10124 "addi %0,%1,%2@tprel@l")
10126 ;; "b" output constraint here and on tls_tls input to support linker tls
10127 ;; optimization. The linker may edit the instructions emitted by a
10128 ;; tls_got_tprel/tls_tls pair to addis,addi.
10129 (define_insn_and_split "tls_got_tprel_<TLSmode:tls_abi_suffix>"
10130 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10131 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10132 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10133 UNSPEC_TLSGOTTPREL))]
10135 "l<TLSmode:tls_insn_suffix> %0,%2@got@tprel(%1)"
10136 "&& TARGET_CMODEL != CMODEL_SMALL"
10137 [(set (match_dup 3)
10139 (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGOTTPREL)))
10141 (lo_sum:TLSmode (match_dup 3)
10142 (unspec:TLSmode [(match_dup 1) (match_dup 2)] UNSPEC_TLSGOTTPREL)))]
10145 operands[3] = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
10147 [(set (attr "length")
10148 (if_then_else (ne (symbol_ref "TARGET_CMODEL") (symbol_ref "CMODEL_SMALL"))
10152 (define_insn "*tls_got_tprel_high<TLSmode:tls_abi_suffix>"
10153 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
10155 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10156 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10157 UNSPEC_TLSGOTTPREL)))]
10158 "HAVE_AS_TLS && TARGET_CMODEL != CMODEL_SMALL"
10159 "addis %0,%1,%2@got@tprel@ha"
10160 [(set_attr "length" "4")])
10162 (define_insn "*tls_got_tprel_low<TLSmode:tls_abi_suffix>"
10163 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10164 (lo_sum:TLSmode (match_operand:TLSmode 1 "gpc_reg_operand" "b")
10165 (unspec:TLSmode [(match_operand:TLSmode 3 "gpc_reg_operand" "b")
10166 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10167 UNSPEC_TLSGOTTPREL)))]
10168 "HAVE_AS_TLS && TARGET_CMODEL != CMODEL_SMALL"
10169 "l<TLSmode:tls_insn_suffix> %0,%2@got@tprel@l(%1)"
10170 [(set_attr "length" "4")])
10172 (define_insn "tls_tls_<TLSmode:tls_abi_suffix>"
10173 [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
10174 (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
10175 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
10177 "TARGET_ELF && HAVE_AS_TLS"
10178 "add %0,%1,%2@tls")
10180 (define_expand "tls_get_tpointer"
10181 [(set (match_operand:SI 0 "gpc_reg_operand" "")
10182 (unspec:SI [(const_int 0)] UNSPEC_TLSTLS))]
10183 "TARGET_XCOFF && HAVE_AS_TLS"
10186 emit_insn (gen_tls_get_tpointer_internal ());
10187 emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
10191 (define_insn "tls_get_tpointer_internal"
10193 (unspec:SI [(const_int 0)] UNSPEC_TLSTLS))
10194 (clobber (reg:SI LR_REGNO))]
10195 "TARGET_XCOFF && HAVE_AS_TLS"
10196 "bla __get_tpointer")
10198 (define_expand "tls_get_addr<mode>"
10199 [(set (match_operand:P 0 "gpc_reg_operand" "")
10200 (unspec:P [(match_operand:P 1 "gpc_reg_operand" "")
10201 (match_operand:P 2 "gpc_reg_operand" "")] UNSPEC_TLSTLS))]
10202 "TARGET_XCOFF && HAVE_AS_TLS"
10205 emit_move_insn (gen_rtx_REG (Pmode, 3), operands[1]);
10206 emit_move_insn (gen_rtx_REG (Pmode, 4), operands[2]);
10207 emit_insn (gen_tls_get_addr_internal<mode> ());
10208 emit_move_insn (operands[0], gen_rtx_REG (Pmode, 3));
10212 (define_insn "tls_get_addr_internal<mode>"
10214 (unspec:P [(reg:P 3) (reg:P 4)] UNSPEC_TLSTLS))
10215 (clobber (reg:P 0))
10216 (clobber (reg:P 4))
10217 (clobber (reg:P 5))
10218 (clobber (reg:P 11))
10219 (clobber (reg:CC CR0_REGNO))
10220 (clobber (reg:P LR_REGNO))]
10221 "TARGET_XCOFF && HAVE_AS_TLS"
10222 "bla __tls_get_addr")
10224 ;; Next come insns related to the calling sequence.
10226 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
10227 ;; We move the back-chain and decrement the stack pointer.
10229 (define_expand "allocate_stack"
10230 [(set (match_operand 0 "gpc_reg_operand" "")
10231 (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
10233 (minus (reg 1) (match_dup 1)))]
10236 { rtx chain = gen_reg_rtx (Pmode);
10237 rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
10239 rtx insn, par, set, mem;
10241 emit_move_insn (chain, stack_bot);
10243 /* Check stack bounds if necessary. */
10244 if (crtl->limit_stack)
10247 available = expand_binop (Pmode, sub_optab,
10248 stack_pointer_rtx, stack_limit_rtx,
10249 NULL_RTX, 1, OPTAB_WIDEN);
10250 emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
10253 if (GET_CODE (operands[1]) != CONST_INT
10254 || INTVAL (operands[1]) < -32767
10255 || INTVAL (operands[1]) > 32768)
10257 neg_op0 = gen_reg_rtx (Pmode);
10259 emit_insn (gen_negsi2 (neg_op0, operands[1]));
10261 emit_insn (gen_negdi2 (neg_op0, operands[1]));
10264 neg_op0 = GEN_INT (- INTVAL (operands[1]));
10266 insn = emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update_stack
10267 : gen_movdi_di_update_stack))
10268 (stack_pointer_rtx, stack_pointer_rtx, neg_op0,
10270 /* Since we didn't use gen_frame_mem to generate the MEM, grab
10271 it now and set the alias set/attributes. The above gen_*_update
10272 calls will generate a PARALLEL with the MEM set being the first
10274 par = PATTERN (insn);
10275 gcc_assert (GET_CODE (par) == PARALLEL);
10276 set = XVECEXP (par, 0, 0);
10277 gcc_assert (GET_CODE (set) == SET);
10278 mem = SET_DEST (set);
10279 gcc_assert (MEM_P (mem));
10280 MEM_NOTRAP_P (mem) = 1;
10281 set_mem_alias_set (mem, get_frame_alias_set ());
10283 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
10287 ;; These patterns say how to save and restore the stack pointer. We need not
10288 ;; save the stack pointer at function level since we are careful to
10289 ;; preserve the backchain. At block level, we have to restore the backchain
10290 ;; when we restore the stack pointer.
10292 ;; For nonlocal gotos, we must save both the stack pointer and its
10293 ;; backchain and restore both. Note that in the nonlocal case, the
10294 ;; save area is a memory location.
10296 (define_expand "save_stack_function"
10297 [(match_operand 0 "any_operand" "")
10298 (match_operand 1 "any_operand" "")]
10302 (define_expand "restore_stack_function"
10303 [(match_operand 0 "any_operand" "")
10304 (match_operand 1 "any_operand" "")]
10308 ;; Adjust stack pointer (op0) to a new value (op1).
10309 ;; First copy old stack backchain to new location, and ensure that the
10310 ;; scheduler won't reorder the sp assignment before the backchain write.
10311 (define_expand "restore_stack_block"
10312 [(set (match_dup 2) (match_dup 3))
10313 (set (match_dup 4) (match_dup 2))
10315 (set (match_operand 0 "register_operand" "")
10316 (match_operand 1 "register_operand" ""))]
10322 operands[1] = force_reg (Pmode, operands[1]);
10323 operands[2] = gen_reg_rtx (Pmode);
10324 operands[3] = gen_frame_mem (Pmode, operands[0]);
10325 operands[4] = gen_frame_mem (Pmode, operands[1]);
10326 p = rtvec_alloc (1);
10327 RTVEC_ELT (p, 0) = gen_rtx_SET (VOIDmode,
10328 gen_frame_mem (BLKmode, operands[0]),
10330 operands[5] = gen_rtx_PARALLEL (VOIDmode, p);
10333 (define_expand "save_stack_nonlocal"
10334 [(set (match_dup 3) (match_dup 4))
10335 (set (match_operand 0 "memory_operand" "") (match_dup 3))
10336 (set (match_dup 2) (match_operand 1 "register_operand" ""))]
10340 int units_per_word = (TARGET_32BIT) ? 4 : 8;
10342 /* Copy the backchain to the first word, sp to the second. */
10343 operands[0] = adjust_address_nv (operands[0], Pmode, 0);
10344 operands[2] = adjust_address_nv (operands[0], Pmode, units_per_word);
10345 operands[3] = gen_reg_rtx (Pmode);
10346 operands[4] = gen_frame_mem (Pmode, operands[1]);
10349 (define_expand "restore_stack_nonlocal"
10350 [(set (match_dup 2) (match_operand 1 "memory_operand" ""))
10351 (set (match_dup 3) (match_dup 4))
10352 (set (match_dup 5) (match_dup 2))
10354 (set (match_operand 0 "register_operand" "") (match_dup 3))]
10358 int units_per_word = (TARGET_32BIT) ? 4 : 8;
10361 /* Restore the backchain from the first word, sp from the second. */
10362 operands[2] = gen_reg_rtx (Pmode);
10363 operands[3] = gen_reg_rtx (Pmode);
10364 operands[1] = adjust_address_nv (operands[1], Pmode, 0);
10365 operands[4] = adjust_address_nv (operands[1], Pmode, units_per_word);
10366 operands[5] = gen_frame_mem (Pmode, operands[3]);
10367 p = rtvec_alloc (1);
10368 RTVEC_ELT (p, 0) = gen_rtx_SET (VOIDmode,
10369 gen_frame_mem (BLKmode, operands[0]),
10371 operands[6] = gen_rtx_PARALLEL (VOIDmode, p);
10374 ;; TOC register handling.
10376 ;; Code to initialize the TOC register...
10378 (define_insn "load_toc_aix_si"
10379 [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10380 (unspec:SI [(const_int 0)] UNSPEC_TOC))
10381 (use (reg:SI 2))])]
10382 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) && TARGET_32BIT"
10386 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
10387 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
10388 operands[2] = gen_rtx_REG (Pmode, 2);
10389 return \"lwz %0,%1(%2)\";
10391 [(set_attr "type" "load")
10392 (set_attr "update" "no")
10393 (set_attr "indexed" "no")])
10395 (define_insn "load_toc_aix_di"
10396 [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10397 (unspec:DI [(const_int 0)] UNSPEC_TOC))
10398 (use (reg:DI 2))])]
10399 "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) && TARGET_64BIT"
10403 #ifdef TARGET_RELOCATABLE
10404 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
10405 !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
10407 ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
10410 strcat (buf, \"@toc\");
10411 operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
10412 operands[2] = gen_rtx_REG (Pmode, 2);
10413 return \"ld %0,%1(%2)\";
10415 [(set_attr "type" "load")
10416 (set_attr "update" "no")
10417 (set_attr "indexed" "no")])
10419 (define_insn "load_toc_v4_pic_si"
10420 [(set (reg:SI LR_REGNO)
10421 (unspec:SI [(const_int 0)] UNSPEC_TOC))]
10422 "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
10423 "bl _GLOBAL_OFFSET_TABLE_@local-4"
10424 [(set_attr "type" "branch")
10425 (set_attr "length" "4")])
10427 (define_expand "load_toc_v4_PIC_1"
10428 [(parallel [(set (reg:SI LR_REGNO)
10429 (match_operand:SI 0 "immediate_operand" "s"))
10430 (use (unspec [(match_dup 0)] UNSPEC_TOC))])]
10431 "TARGET_ELF && DEFAULT_ABI == ABI_V4
10432 && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
10435 (define_insn "load_toc_v4_PIC_1_normal"
10436 [(set (reg:SI LR_REGNO)
10437 (match_operand:SI 0 "immediate_operand" "s"))
10438 (use (unspec [(match_dup 0)] UNSPEC_TOC))]
10439 "!TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4
10440 && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
10441 "bcl 20,31,%0\\n%0:"
10442 [(set_attr "type" "branch")
10443 (set_attr "length" "4")])
10445 (define_insn "load_toc_v4_PIC_1_476"
10446 [(set (reg:SI LR_REGNO)
10447 (match_operand:SI 0 "immediate_operand" "s"))
10448 (use (unspec [(match_dup 0)] UNSPEC_TOC))]
10449 "TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4
10450 && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
10454 static char templ[32];
10456 get_ppc476_thunk_name (name);
10457 sprintf (templ, \"bl %s\\n%%0:\", name);
10460 [(set_attr "type" "branch")
10461 (set_attr "length" "4")])
10463 (define_expand "load_toc_v4_PIC_1b"
10464 [(parallel [(set (reg:SI LR_REGNO)
10465 (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
10466 (label_ref (match_operand 1 "" ""))]
10469 "TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
10472 (define_insn "load_toc_v4_PIC_1b_normal"
10473 [(set (reg:SI LR_REGNO)
10474 (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
10475 (label_ref (match_operand 1 "" ""))]
10478 "!TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
10479 "bcl 20,31,$+8\;.long %0-$"
10480 [(set_attr "type" "branch")
10481 (set_attr "length" "8")])
10483 (define_insn "load_toc_v4_PIC_1b_476"
10484 [(set (reg:SI LR_REGNO)
10485 (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
10486 (label_ref (match_operand 1 "" ""))]
10489 "TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
10493 static char templ[32];
10495 get_ppc476_thunk_name (name);
10496 sprintf (templ, \"bl %s\\n\\tb $+8\\n\\t.long %%0-$\", name);
10499 [(set_attr "type" "branch")
10500 (set_attr "length" "16")])
10502 (define_insn "load_toc_v4_PIC_2"
10503 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10504 (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10505 (minus:SI (match_operand:SI 2 "immediate_operand" "s")
10506 (match_operand:SI 3 "immediate_operand" "s")))))]
10507 "TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
10509 [(set_attr "type" "load")])
10511 (define_insn "load_toc_v4_PIC_3b"
10512 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10513 (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10515 (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
10516 (match_operand:SI 3 "symbol_ref_operand" "s")))))]
10517 "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI == ABI_V4 && flag_pic"
10518 "addis %0,%1,%2-%3@ha")
10520 (define_insn "load_toc_v4_PIC_3c"
10521 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10522 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10523 (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
10524 (match_operand:SI 3 "symbol_ref_operand" "s"))))]
10525 "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI == ABI_V4 && flag_pic"
10526 "addi %0,%1,%2-%3@l")
10528 ;; If the TOC is shared over a translation unit, as happens with all
10529 ;; the kinds of PIC that we support, we need to restore the TOC
10530 ;; pointer only when jumping over units of translation.
10531 ;; On Darwin, we need to reload the picbase.
10533 (define_expand "builtin_setjmp_receiver"
10534 [(use (label_ref (match_operand 0 "" "")))]
10535 "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
10536 || (TARGET_TOC && TARGET_MINIMAL_TOC)
10537 || (DEFAULT_ABI == ABI_DARWIN && flag_pic)"
10541 if (DEFAULT_ABI == ABI_DARWIN)
10543 rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, MACHOPIC_FUNCTION_BASE_NAME);
10544 rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
10548 crtl->uses_pic_offset_table = 1;
10549 ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\",
10550 CODE_LABEL_NUMBER (operands[0]));
10551 tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
10553 emit_insn (gen_load_macho_picbase (tmplabrtx));
10554 emit_move_insn (picreg, gen_rtx_REG (Pmode, LR_REGNO));
10555 emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
10559 rs6000_emit_load_toc_table (FALSE);
10563 ;; Largetoc support
10564 (define_insn "*largetoc_high"
10565 [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
10567 (unspec [(match_operand:DI 1 "" "")
10568 (match_operand:DI 2 "gpc_reg_operand" "b")]
10570 "TARGET_ELF && TARGET_CMODEL != CMODEL_SMALL"
10571 "addis %0,%2,%1@toc@ha")
10573 (define_insn "*largetoc_high_aix<mode>"
10574 [(set (match_operand:P 0 "gpc_reg_operand" "=b*r")
10576 (unspec [(match_operand:P 1 "" "")
10577 (match_operand:P 2 "gpc_reg_operand" "b")]
10579 "TARGET_XCOFF && TARGET_CMODEL != CMODEL_SMALL"
10580 "addis %0,%1@u(%2)")
10582 (define_insn "*largetoc_high_plus"
10583 [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
10586 (unspec [(match_operand:DI 1 "" "")
10587 (match_operand:DI 2 "gpc_reg_operand" "b")]
10589 (match_operand:DI 3 "add_cint_operand" "n"))))]
10590 "TARGET_ELF && TARGET_CMODEL != CMODEL_SMALL"
10591 "addis %0,%2,%1+%3@toc@ha")
10593 (define_insn "*largetoc_high_plus_aix<mode>"
10594 [(set (match_operand:P 0 "gpc_reg_operand" "=b*r")
10597 (unspec [(match_operand:P 1 "" "")
10598 (match_operand:P 2 "gpc_reg_operand" "b")]
10600 (match_operand:P 3 "add_cint_operand" "n"))))]
10601 "TARGET_XCOFF && TARGET_CMODEL != CMODEL_SMALL"
10602 "addis %0,%1+%3@u(%2)")
10604 (define_insn "*largetoc_low"
10605 [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
10606 (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,!*r")
10607 (match_operand:DI 2 "" "")))]
10608 "TARGET_ELF && TARGET_CMODEL != CMODEL_SMALL"
10613 (define_insn "*largetoc_low_aix<mode>"
10614 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
10615 (lo_sum:P (match_operand:P 1 "gpc_reg_operand" "b")
10616 (match_operand:P 2 "" "")))]
10617 "TARGET_XCOFF && TARGET_CMODEL != CMODEL_SMALL"
10620 (define_insn_and_split "*tocref<mode>"
10621 [(set (match_operand:P 0 "gpc_reg_operand" "=b*r")
10622 (match_operand:P 1 "small_toc_ref" "R"))]
10625 "&& TARGET_CMODEL != CMODEL_SMALL && reload_completed"
10626 [(set (match_dup 0) (high:P (match_dup 1)))
10627 (set (match_dup 0) (lo_sum:P (match_dup 0) (match_dup 1)))])
10629 ;; Elf specific ways of loading addresses for non-PIC code.
10630 ;; The output of this could be r0, but we make a very strong
10631 ;; preference for a base register because it will usually
10632 ;; be needed there.
10633 (define_insn "elf_high"
10634 [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
10635 (high:SI (match_operand 1 "" "")))]
10636 "TARGET_ELF && ! TARGET_64BIT"
10639 (define_insn "elf_low"
10640 [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
10641 (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
10642 (match_operand 2 "" "")))]
10643 "TARGET_ELF && ! TARGET_64BIT"
10648 ;; Call and call_value insns
10649 (define_expand "call"
10650 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10651 (match_operand 1 "" ""))
10652 (use (match_operand 2 "" ""))
10653 (clobber (reg:SI LR_REGNO))])]
10658 if (MACHOPIC_INDIRECT)
10659 operands[0] = machopic_indirect_call_target (operands[0]);
10662 gcc_assert (GET_CODE (operands[0]) == MEM);
10663 gcc_assert (GET_CODE (operands[1]) == CONST_INT);
10665 operands[0] = XEXP (operands[0], 0);
10667 if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
10669 rs6000_call_aix (NULL_RTX, operands[0], operands[1], operands[2]);
10673 if (GET_CODE (operands[0]) != SYMBOL_REF
10674 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[2]) & CALL_LONG) != 0))
10676 if (INTVAL (operands[2]) & CALL_LONG)
10677 operands[0] = rs6000_longcall_ref (operands[0]);
10679 switch (DEFAULT_ABI)
10683 operands[0] = force_reg (Pmode, operands[0]);
10687 gcc_unreachable ();
10692 (define_expand "call_value"
10693 [(parallel [(set (match_operand 0 "" "")
10694 (call (mem:SI (match_operand 1 "address_operand" ""))
10695 (match_operand 2 "" "")))
10696 (use (match_operand 3 "" ""))
10697 (clobber (reg:SI LR_REGNO))])]
10702 if (MACHOPIC_INDIRECT)
10703 operands[1] = machopic_indirect_call_target (operands[1]);
10706 gcc_assert (GET_CODE (operands[1]) == MEM);
10707 gcc_assert (GET_CODE (operands[2]) == CONST_INT);
10709 operands[1] = XEXP (operands[1], 0);
10711 if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
10713 rs6000_call_aix (operands[0], operands[1], operands[2], operands[3]);
10717 if (GET_CODE (operands[1]) != SYMBOL_REF
10718 || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[3]) & CALL_LONG) != 0))
10720 if (INTVAL (operands[3]) & CALL_LONG)
10721 operands[1] = rs6000_longcall_ref (operands[1]);
10723 switch (DEFAULT_ABI)
10727 operands[1] = force_reg (Pmode, operands[1]);
10731 gcc_unreachable ();
10736 ;; Call to function in current module. No TOC pointer reload needed.
10737 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
10738 ;; either the function was not prototyped, or it was prototyped as a
10739 ;; variable argument function. It is > 0 if FP registers were passed
10740 ;; and < 0 if they were not.
10742 (define_insn "*call_local32"
10743 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10744 (match_operand 1 "" "g,g"))
10745 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10746 (clobber (reg:SI LR_REGNO))]
10747 "(INTVAL (operands[2]) & CALL_LONG) == 0"
10750 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10751 output_asm_insn (\"crxor 6,6,6\", operands);
10753 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10754 output_asm_insn (\"creqv 6,6,6\", operands);
10756 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10758 [(set_attr "type" "branch")
10759 (set_attr "length" "4,8")])
10761 (define_insn "*call_local64"
10762 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10763 (match_operand 1 "" "g,g"))
10764 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10765 (clobber (reg:SI LR_REGNO))]
10766 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10769 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10770 output_asm_insn (\"crxor 6,6,6\", operands);
10772 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10773 output_asm_insn (\"creqv 6,6,6\", operands);
10775 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10777 [(set_attr "type" "branch")
10778 (set_attr "length" "4,8")])
10780 (define_insn "*call_value_local32"
10781 [(set (match_operand 0 "" "")
10782 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10783 (match_operand 2 "" "g,g")))
10784 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10785 (clobber (reg:SI LR_REGNO))]
10786 "(INTVAL (operands[3]) & CALL_LONG) == 0"
10789 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10790 output_asm_insn (\"crxor 6,6,6\", operands);
10792 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10793 output_asm_insn (\"creqv 6,6,6\", operands);
10795 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10797 [(set_attr "type" "branch")
10798 (set_attr "length" "4,8")])
10801 (define_insn "*call_value_local64"
10802 [(set (match_operand 0 "" "")
10803 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10804 (match_operand 2 "" "g,g")))
10805 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10806 (clobber (reg:SI LR_REGNO))]
10807 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10810 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10811 output_asm_insn (\"crxor 6,6,6\", operands);
10813 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10814 output_asm_insn (\"creqv 6,6,6\", operands);
10816 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10818 [(set_attr "type" "branch")
10819 (set_attr "length" "4,8")])
10822 ;; A function pointer under System V is just a normal pointer
10823 ;; operands[0] is the function pointer
10824 ;; operands[1] is the stack size to clean up
10825 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
10826 ;; which indicates how to set cr1
10828 (define_insn "*call_indirect_nonlocal_sysv<mode>"
10829 [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l,c,*l"))
10830 (match_operand 1 "" "g,g,g,g"))
10831 (use (match_operand:SI 2 "immediate_operand" "O,O,n,n"))
10832 (clobber (reg:SI LR_REGNO))]
10833 "DEFAULT_ABI == ABI_V4
10834 || DEFAULT_ABI == ABI_DARWIN"
10836 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10837 output_asm_insn ("crxor 6,6,6", operands);
10839 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10840 output_asm_insn ("creqv 6,6,6", operands);
10844 [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
10845 (set_attr "length" "4,4,8,8")])
10847 (define_insn_and_split "*call_nonlocal_sysv<mode>"
10848 [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s"))
10849 (match_operand 1 "" "g,g"))
10850 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10851 (clobber (reg:SI LR_REGNO))]
10852 "(DEFAULT_ABI == ABI_DARWIN
10853 || (DEFAULT_ABI == ABI_V4
10854 && (INTVAL (operands[2]) & CALL_LONG) == 0))"
10856 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10857 output_asm_insn ("crxor 6,6,6", operands);
10859 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10860 output_asm_insn ("creqv 6,6,6", operands);
10863 return output_call(insn, operands, 0, 2);
10865 if (DEFAULT_ABI == ABI_V4 && flag_pic)
10867 gcc_assert (!TARGET_SECURE_PLT);
10868 return "bl %z0@plt";
10874 "DEFAULT_ABI == ABI_V4
10875 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0])
10876 && (INTVAL (operands[2]) & CALL_LONG) == 0"
10877 [(parallel [(call (mem:SI (match_dup 0))
10879 (use (match_dup 2))
10880 (use (match_dup 3))
10881 (clobber (reg:SI LR_REGNO))])]
10883 operands[3] = pic_offset_table_rtx;
10885 [(set_attr "type" "branch,branch")
10886 (set_attr "length" "4,8")])
10888 (define_insn "*call_nonlocal_sysv_secure<mode>"
10889 [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s,s"))
10890 (match_operand 1 "" "g,g"))
10891 (use (match_operand:SI 2 "immediate_operand" "O,n"))
10892 (use (match_operand:SI 3 "register_operand" "r,r"))
10893 (clobber (reg:SI LR_REGNO))]
10894 "(DEFAULT_ABI == ABI_V4
10895 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[0])
10896 && (INTVAL (operands[2]) & CALL_LONG) == 0)"
10898 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10899 output_asm_insn ("crxor 6,6,6", operands);
10901 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10902 output_asm_insn ("creqv 6,6,6", operands);
10905 /* The magic 32768 offset here and in the other sysv call insns
10906 corresponds to the offset of r30 in .got2, as given by LCTOC1.
10907 See sysv4.h:toc_section. */
10908 return "bl %z0+32768@plt";
10910 return "bl %z0@plt";
10912 [(set_attr "type" "branch,branch")
10913 (set_attr "length" "4,8")])
10915 (define_insn "*call_value_indirect_nonlocal_sysv<mode>"
10916 [(set (match_operand 0 "" "")
10917 (call (mem:SI (match_operand:P 1 "register_operand" "c,*l,c,*l"))
10918 (match_operand 2 "" "g,g,g,g")))
10919 (use (match_operand:SI 3 "immediate_operand" "O,O,n,n"))
10920 (clobber (reg:SI LR_REGNO))]
10921 "DEFAULT_ABI == ABI_V4
10922 || DEFAULT_ABI == ABI_DARWIN"
10924 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10925 output_asm_insn ("crxor 6,6,6", operands);
10927 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10928 output_asm_insn ("creqv 6,6,6", operands);
10932 [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
10933 (set_attr "length" "4,4,8,8")])
10935 (define_insn_and_split "*call_value_nonlocal_sysv<mode>"
10936 [(set (match_operand 0 "" "")
10937 (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s"))
10938 (match_operand 2 "" "g,g")))
10939 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10940 (clobber (reg:SI LR_REGNO))]
10941 "(DEFAULT_ABI == ABI_DARWIN
10942 || (DEFAULT_ABI == ABI_V4
10943 && (INTVAL (operands[3]) & CALL_LONG) == 0))"
10945 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10946 output_asm_insn ("crxor 6,6,6", operands);
10948 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10949 output_asm_insn ("creqv 6,6,6", operands);
10952 return output_call(insn, operands, 1, 3);
10954 if (DEFAULT_ABI == ABI_V4 && flag_pic)
10956 gcc_assert (!TARGET_SECURE_PLT);
10957 return "bl %z1@plt";
10963 "DEFAULT_ABI == ABI_V4
10964 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1])
10965 && (INTVAL (operands[3]) & CALL_LONG) == 0"
10966 [(parallel [(set (match_dup 0)
10967 (call (mem:SI (match_dup 1))
10969 (use (match_dup 3))
10970 (use (match_dup 4))
10971 (clobber (reg:SI LR_REGNO))])]
10973 operands[4] = pic_offset_table_rtx;
10975 [(set_attr "type" "branch,branch")
10976 (set_attr "length" "4,8")])
10978 (define_insn "*call_value_nonlocal_sysv_secure<mode>"
10979 [(set (match_operand 0 "" "")
10980 (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s,s"))
10981 (match_operand 2 "" "g,g")))
10982 (use (match_operand:SI 3 "immediate_operand" "O,n"))
10983 (use (match_operand:SI 4 "register_operand" "r,r"))
10984 (clobber (reg:SI LR_REGNO))]
10985 "(DEFAULT_ABI == ABI_V4
10986 && TARGET_SECURE_PLT && flag_pic && !SYMBOL_REF_LOCAL_P (operands[1])
10987 && (INTVAL (operands[3]) & CALL_LONG) == 0)"
10989 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10990 output_asm_insn ("crxor 6,6,6", operands);
10992 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10993 output_asm_insn ("creqv 6,6,6", operands);
10996 return "bl %z1+32768@plt";
10998 return "bl %z1@plt";
11000 [(set_attr "type" "branch,branch")
11001 (set_attr "length" "4,8")])
11004 ;; Call to AIX abi function in the same module.
11006 (define_insn "*call_local_aix<mode>"
11007 [(call (mem:SI (match_operand:P 0 "current_file_function_operand" "s"))
11008 (match_operand 1 "" "g"))
11009 (clobber (reg:P LR_REGNO))]
11010 "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11012 [(set_attr "type" "branch")
11013 (set_attr "length" "4")])
11015 (define_insn "*call_value_local_aix<mode>"
11016 [(set (match_operand 0 "" "")
11017 (call (mem:SI (match_operand:P 1 "current_file_function_operand" "s"))
11018 (match_operand 2 "" "g")))
11019 (clobber (reg:P LR_REGNO))]
11020 "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11022 [(set_attr "type" "branch")
11023 (set_attr "length" "4")])
11025 ;; Call to AIX abi function which may be in another module.
11026 ;; Restore the TOC pointer (r2) after the call.
11028 (define_insn "*call_nonlocal_aix<mode>"
11029 [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s"))
11030 (match_operand 1 "" "g"))
11031 (clobber (reg:P LR_REGNO))]
11032 "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11034 [(set_attr "type" "branch")
11035 (set_attr "length" "8")])
11037 (define_insn "*call_value_nonlocal_aix<mode>"
11038 [(set (match_operand 0 "" "")
11039 (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s"))
11040 (match_operand 2 "" "g")))
11041 (clobber (reg:P LR_REGNO))]
11042 "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11044 [(set_attr "type" "branch")
11045 (set_attr "length" "8")])
11047 ;; Call to indirect functions with the AIX abi using a 3 word descriptor.
11048 ;; Operand0 is the addresss of the function to call
11049 ;; Operand2 is the location in the function descriptor to load r2 from
11050 ;; Operand3 is the stack location to hold the current TOC pointer
11052 (define_insn "*call_indirect_aix<mode>"
11053 [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l"))
11054 (match_operand 1 "" "g,g"))
11055 (use (match_operand:P 2 "memory_operand" "<ptrm>,<ptrm>"))
11056 (set (reg:P TOC_REGNUM) (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
11057 (clobber (reg:P LR_REGNO))]
11058 "DEFAULT_ABI == ABI_AIX"
11059 "<ptrload> 2,%2\;b%T0l\;<ptrload> 2,%3"
11060 [(set_attr "type" "jmpreg")
11061 (set_attr "length" "12")])
11063 (define_insn "*call_value_indirect_aix<mode>"
11064 [(set (match_operand 0 "" "")
11065 (call (mem:SI (match_operand:P 1 "register_operand" "c,*l"))
11066 (match_operand 2 "" "g,g")))
11067 (use (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
11068 (set (reg:P TOC_REGNUM) (match_operand:P 4 "memory_operand" "<ptrm>,<ptrm>"))
11069 (clobber (reg:P LR_REGNO))]
11070 "DEFAULT_ABI == ABI_AIX"
11071 "<ptrload> 2,%3\;b%T1l\;<ptrload> 2,%4"
11072 [(set_attr "type" "jmpreg")
11073 (set_attr "length" "12")])
11075 ;; Call to indirect functions with the ELFv2 ABI.
11076 ;; Operand0 is the addresss of the function to call
11077 ;; Operand2 is the stack location to hold the current TOC pointer
11079 (define_insn "*call_indirect_elfv2<mode>"
11080 [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l"))
11081 (match_operand 1 "" "g,g"))
11082 (set (reg:P TOC_REGNUM) (match_operand:P 2 "memory_operand" "<ptrm>,<ptrm>"))
11083 (clobber (reg:P LR_REGNO))]
11084 "DEFAULT_ABI == ABI_ELFv2"
11085 "b%T0l\;<ptrload> 2,%2"
11086 [(set_attr "type" "jmpreg")
11087 (set_attr "length" "8")])
11089 (define_insn "*call_value_indirect_elfv2<mode>"
11090 [(set (match_operand 0 "" "")
11091 (call (mem:SI (match_operand:P 1 "register_operand" "c,*l"))
11092 (match_operand 2 "" "g,g")))
11093 (set (reg:P TOC_REGNUM) (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
11094 (clobber (reg:P LR_REGNO))]
11095 "DEFAULT_ABI == ABI_ELFv2"
11096 "b%T1l\;<ptrload> 2,%3"
11097 [(set_attr "type" "jmpreg")
11098 (set_attr "length" "8")])
11101 ;; Call subroutine returning any type.
11102 (define_expand "untyped_call"
11103 [(parallel [(call (match_operand 0 "" "")
11105 (match_operand 1 "" "")
11106 (match_operand 2 "" "")])]
11112 emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
11114 for (i = 0; i < XVECLEN (operands[2], 0); i++)
11116 rtx set = XVECEXP (operands[2], 0, i);
11117 emit_move_insn (SET_DEST (set), SET_SRC (set));
11120 /* The optimizer does not know that the call sets the function value
11121 registers we stored in the result block. We avoid problems by
11122 claiming that all hard registers are used and clobbered at this
11124 emit_insn (gen_blockage ());
11129 ;; sibling call patterns
11130 (define_expand "sibcall"
11131 [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
11132 (match_operand 1 "" ""))
11133 (use (match_operand 2 "" ""))
11134 (use (reg:SI LR_REGNO))
11140 if (MACHOPIC_INDIRECT)
11141 operands[0] = machopic_indirect_call_target (operands[0]);
11144 gcc_assert (GET_CODE (operands[0]) == MEM);
11145 gcc_assert (GET_CODE (operands[1]) == CONST_INT);
11147 operands[0] = XEXP (operands[0], 0);
11149 if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
11151 rs6000_sibcall_aix (NULL_RTX, operands[0], operands[1], operands[2]);
11156 (define_expand "sibcall_value"
11157 [(parallel [(set (match_operand 0 "register_operand" "")
11158 (call (mem:SI (match_operand 1 "address_operand" ""))
11159 (match_operand 2 "" "")))
11160 (use (match_operand 3 "" ""))
11161 (use (reg:SI LR_REGNO))
11167 if (MACHOPIC_INDIRECT)
11168 operands[1] = machopic_indirect_call_target (operands[1]);
11171 gcc_assert (GET_CODE (operands[1]) == MEM);
11172 gcc_assert (GET_CODE (operands[2]) == CONST_INT);
11174 operands[1] = XEXP (operands[1], 0);
11176 if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
11178 rs6000_sibcall_aix (operands[0], operands[1], operands[2], operands[3]);
11183 ;; this and similar patterns must be marked as using LR, otherwise
11184 ;; dataflow will try to delete the store into it. This is true
11185 ;; even when the actual reg to jump to is in CTR, when LR was
11186 ;; saved and restored around the PIC-setting BCL.
11187 (define_insn "*sibcall_local32"
11188 [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
11189 (match_operand 1 "" "g,g"))
11190 (use (match_operand:SI 2 "immediate_operand" "O,n"))
11191 (use (reg:SI LR_REGNO))
11193 "(INTVAL (operands[2]) & CALL_LONG) == 0"
11196 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11197 output_asm_insn (\"crxor 6,6,6\", operands);
11199 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11200 output_asm_insn (\"creqv 6,6,6\", operands);
11202 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
11204 [(set_attr "type" "branch")
11205 (set_attr "length" "4,8")])
11207 (define_insn "*sibcall_local64"
11208 [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
11209 (match_operand 1 "" "g,g"))
11210 (use (match_operand:SI 2 "immediate_operand" "O,n"))
11211 (use (reg:SI LR_REGNO))
11213 "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
11216 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11217 output_asm_insn (\"crxor 6,6,6\", operands);
11219 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11220 output_asm_insn (\"creqv 6,6,6\", operands);
11222 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
11224 [(set_attr "type" "branch")
11225 (set_attr "length" "4,8")])
11227 (define_insn "*sibcall_value_local32"
11228 [(set (match_operand 0 "" "")
11229 (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
11230 (match_operand 2 "" "g,g")))
11231 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11232 (use (reg:SI LR_REGNO))
11234 "(INTVAL (operands[3]) & CALL_LONG) == 0"
11237 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11238 output_asm_insn (\"crxor 6,6,6\", operands);
11240 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11241 output_asm_insn (\"creqv 6,6,6\", operands);
11243 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
11245 [(set_attr "type" "branch")
11246 (set_attr "length" "4,8")])
11248 (define_insn "*sibcall_value_local64"
11249 [(set (match_operand 0 "" "")
11250 (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
11251 (match_operand 2 "" "g,g")))
11252 (use (match_operand:SI 3 "immediate_operand" "O,n"))
11253 (use (reg:SI LR_REGNO))
11255 "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
11258 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11259 output_asm_insn (\"crxor 6,6,6\", operands);
11261 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11262 output_asm_insn (\"creqv 6,6,6\", operands);
11264 return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
11266 [(set_attr "type" "branch")
11267 (set_attr "length" "4,8")])
11269 (define_insn "*sibcall_nonlocal_sysv<mode>"
11270 [(call (mem:SI (match_operand:P 0 "call_operand" "s,s,c,c"))
11271 (match_operand 1 "" ""))
11272 (use (match_operand 2 "immediate_operand" "O,n,O,n"))
11273 (use (reg:SI LR_REGNO))
11275 "(DEFAULT_ABI == ABI_DARWIN
11276 || DEFAULT_ABI == ABI_V4)
11277 && (INTVAL (operands[2]) & CALL_LONG) == 0"
11280 if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11281 output_asm_insn (\"crxor 6,6,6\", operands);
11283 else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11284 output_asm_insn (\"creqv 6,6,6\", operands);
11286 if (which_alternative >= 2)
11288 else if (DEFAULT_ABI == ABI_V4 && flag_pic)
11290 gcc_assert (!TARGET_SECURE_PLT);
11291 return \"b %z0@plt\";
11296 [(set_attr "type" "branch")
11297 (set_attr "length" "4,8,4,8")])
11299 (define_insn "*sibcall_value_nonlocal_sysv<mode>"
11300 [(set (match_operand 0 "" "")
11301 (call (mem:SI (match_operand:P 1 "call_operand" "s,s,c,c"))
11302 (match_operand 2 "" "")))
11303 (use (match_operand:SI 3 "immediate_operand" "O,n,O,n"))
11304 (use (reg:SI LR_REGNO))
11306 "(DEFAULT_ABI == ABI_DARWIN
11307 || DEFAULT_ABI == ABI_V4)
11308 && (INTVAL (operands[3]) & CALL_LONG) == 0"
11311 if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
11312 output_asm_insn (\"crxor 6,6,6\", operands);
11314 else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
11315 output_asm_insn (\"creqv 6,6,6\", operands);
11317 if (which_alternative >= 2)
11319 else if (DEFAULT_ABI == ABI_V4 && flag_pic)
11321 gcc_assert (!TARGET_SECURE_PLT);
11322 return \"b %z1@plt\";
11327 [(set_attr "type" "branch")
11328 (set_attr "length" "4,8,4,8")])
11330 ;; AIX ABI sibling call patterns.
11332 (define_insn "*sibcall_aix<mode>"
11333 [(call (mem:SI (match_operand:P 0 "call_operand" "s,c"))
11334 (match_operand 1 "" "g,g"))
11336 "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11340 [(set_attr "type" "branch")
11341 (set_attr "length" "4")])
11343 (define_insn "*sibcall_value_aix<mode>"
11344 [(set (match_operand 0 "" "")
11345 (call (mem:SI (match_operand:P 1 "call_operand" "s,c"))
11346 (match_operand 2 "" "g,g")))
11348 "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
11352 [(set_attr "type" "branch")
11353 (set_attr "length" "4")])
11355 (define_expand "sibcall_epilogue"
11356 [(use (const_int 0))]
11359 if (!TARGET_SCHED_PROLOG)
11360 emit_insn (gen_blockage ());
11361 rs6000_emit_epilogue (TRUE);
11365 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
11366 ;; all of memory. This blocks insns from being moved across this point.
11368 (define_insn "blockage"
11369 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCK)]
11373 (define_expand "probe_stack"
11374 [(set (match_operand 0 "memory_operand" "=m")
11375 (unspec [(const_int 0)] UNSPEC_PROBE_STACK))]
11379 emit_insn (gen_probe_stack_di (operands[0]));
11381 emit_insn (gen_probe_stack_si (operands[0]));
11385 (define_insn "probe_stack_<mode>"
11386 [(set (match_operand:P 0 "memory_operand" "=m")
11387 (unspec:P [(const_int 0)] UNSPEC_PROBE_STACK))]
11390 operands[1] = gen_rtx_REG (Pmode, 0);
11391 return "st<wd>%U0%X0 %1,%0";
11393 [(set_attr "type" "store")
11394 (set (attr "update")
11395 (if_then_else (match_operand 0 "update_address_mem")
11396 (const_string "yes")
11397 (const_string "no")))
11398 (set (attr "indexed")
11399 (if_then_else (match_operand 0 "indexed_address_mem")
11400 (const_string "yes")
11401 (const_string "no")))
11402 (set_attr "length" "4")])
11404 (define_insn "probe_stack_range<P:mode>"
11405 [(set (match_operand:P 0 "register_operand" "=r")
11406 (unspec_volatile:P [(match_operand:P 1 "register_operand" "0")
11407 (match_operand:P 2 "register_operand" "r")]
11408 UNSPECV_PROBE_STACK_RANGE))]
11410 "* return output_probe_stack_range (operands[0], operands[2]);"
11411 [(set_attr "type" "three")])
11413 ;; Compare insns are next. Note that the RS/6000 has two types of compares,
11414 ;; signed & unsigned, and one type of branch.
11416 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
11417 ;; insns, and branches.
11419 (define_expand "cbranch<mode>4"
11420 [(use (match_operator 0 "rs6000_cbranch_operator"
11421 [(match_operand:GPR 1 "gpc_reg_operand" "")
11422 (match_operand:GPR 2 "reg_or_short_operand" "")]))
11423 (use (match_operand 3 ""))]
11427 /* Take care of the possibility that operands[2] might be negative but
11428 this might be a logical operation. That insn doesn't exist. */
11429 if (GET_CODE (operands[2]) == CONST_INT
11430 && INTVAL (operands[2]) < 0)
11432 operands[2] = force_reg (<MODE>mode, operands[2]);
11433 operands[0] = gen_rtx_fmt_ee (GET_CODE (operands[0]),
11434 GET_MODE (operands[0]),
11435 operands[1], operands[2]);
11438 rs6000_emit_cbranch (<MODE>mode, operands);
11442 (define_expand "cbranch<mode>4"
11443 [(use (match_operator 0 "rs6000_cbranch_operator"
11444 [(match_operand:FP 1 "gpc_reg_operand" "")
11445 (match_operand:FP 2 "gpc_reg_operand" "")]))
11446 (use (match_operand 3 ""))]
11450 rs6000_emit_cbranch (<MODE>mode, operands);
11454 (define_expand "cstore<mode>4"
11455 [(use (match_operator 1 "rs6000_cbranch_operator"
11456 [(match_operand:GPR 2 "gpc_reg_operand" "")
11457 (match_operand:GPR 3 "reg_or_short_operand" "")]))
11458 (clobber (match_operand:SI 0 "register_operand"))]
11462 /* Take care of the possibility that operands[3] might be negative but
11463 this might be a logical operation. That insn doesn't exist. */
11464 if (GET_CODE (operands[3]) == CONST_INT
11465 && INTVAL (operands[3]) < 0)
11467 operands[3] = force_reg (<MODE>mode, operands[3]);
11468 operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]),
11469 GET_MODE (operands[1]),
11470 operands[2], operands[3]);
11473 /* For SNE, we would prefer that the xor/abs sequence be used for integers.
11474 For SEQ, likewise, except that comparisons with zero should be done
11475 with an scc insns. However, due to the order that combine see the
11476 resulting insns, we must, in fact, allow SEQ for integers. Fail in
11477 the cases we don't want to handle or are best handled by portable
11479 if (GET_CODE (operands[1]) == NE)
11481 if ((GET_CODE (operands[1]) == LT || GET_CODE (operands[1]) == LE
11482 || GET_CODE (operands[1]) == GT || GET_CODE (operands[1]) == GE)
11483 && operands[3] == const0_rtx)
11485 rs6000_emit_sCOND (<MODE>mode, operands);
11489 (define_expand "cstore<mode>4"
11490 [(use (match_operator 1 "rs6000_cbranch_operator"
11491 [(match_operand:FP 2 "gpc_reg_operand" "")
11492 (match_operand:FP 3 "gpc_reg_operand" "")]))
11493 (clobber (match_operand:SI 0 "register_operand"))]
11497 rs6000_emit_sCOND (<MODE>mode, operands);
11502 (define_expand "stack_protect_set"
11503 [(match_operand 0 "memory_operand" "")
11504 (match_operand 1 "memory_operand" "")]
11507 #ifdef TARGET_THREAD_SSP_OFFSET
11508 rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
11509 rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
11510 operands[1] = gen_rtx_MEM (Pmode, addr);
11513 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
11515 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
11519 (define_insn "stack_protect_setsi"
11520 [(set (match_operand:SI 0 "memory_operand" "=m")
11521 (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET))
11522 (set (match_scratch:SI 2 "=&r") (const_int 0))]
11524 "lwz%U1%X1 %2,%1\;stw%U0%X0 %2,%0\;li %2,0"
11525 [(set_attr "type" "three")
11526 (set_attr "length" "12")])
11528 (define_insn "stack_protect_setdi"
11529 [(set (match_operand:DI 0 "memory_operand" "=Y")
11530 (unspec:DI [(match_operand:DI 1 "memory_operand" "Y")] UNSPEC_SP_SET))
11531 (set (match_scratch:DI 2 "=&r") (const_int 0))]
11533 "ld%U1%X1 %2,%1\;std%U0%X0 %2,%0\;li %2,0"
11534 [(set_attr "type" "three")
11535 (set_attr "length" "12")])
11537 (define_expand "stack_protect_test"
11538 [(match_operand 0 "memory_operand" "")
11539 (match_operand 1 "memory_operand" "")
11540 (match_operand 2 "" "")]
11543 rtx test, op0, op1;
11544 #ifdef TARGET_THREAD_SSP_OFFSET
11545 rtx tlsreg = gen_rtx_REG (Pmode, TARGET_64BIT ? 13 : 2);
11546 rtx addr = gen_rtx_PLUS (Pmode, tlsreg, GEN_INT (TARGET_THREAD_SSP_OFFSET));
11547 operands[1] = gen_rtx_MEM (Pmode, addr);
11550 op1 = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, operands[1]), UNSPEC_SP_TEST);
11551 test = gen_rtx_EQ (VOIDmode, op0, op1);
11552 emit_jump_insn (gen_cbranchsi4 (test, op0, op1, operands[2]));
11556 (define_insn "stack_protect_testsi"
11557 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
11558 (unspec:CCEQ [(match_operand:SI 1 "memory_operand" "m,m")
11559 (match_operand:SI 2 "memory_operand" "m,m")]
11561 (set (match_scratch:SI 4 "=r,r") (const_int 0))
11562 (clobber (match_scratch:SI 3 "=&r,&r"))]
11565 lwz%U1%X1 %3,%1\;lwz%U2%X2 %4,%2\;xor. %3,%3,%4\;li %4,0
11566 lwz%U1%X1 %3,%1\;lwz%U2%X2 %4,%2\;cmplw %0,%3,%4\;li %3,0\;li %4,0"
11567 [(set_attr "length" "16,20")])
11569 (define_insn "stack_protect_testdi"
11570 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
11571 (unspec:CCEQ [(match_operand:DI 1 "memory_operand" "Y,Y")
11572 (match_operand:DI 2 "memory_operand" "Y,Y")]
11574 (set (match_scratch:DI 4 "=r,r") (const_int 0))
11575 (clobber (match_scratch:DI 3 "=&r,&r"))]
11578 ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;xor. %3,%3,%4\;li %4,0
11579 ld%U1%X1 %3,%1\;ld%U2%X2 %4,%2\;cmpld %0,%3,%4\;li %3,0\;li %4,0"
11580 [(set_attr "length" "16,20")])
11583 ;; Here are the actual compare insns.
11584 (define_insn "*cmp<mode>_internal1"
11585 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
11586 (compare:CC (match_operand:GPR 1 "gpc_reg_operand" "r")
11587 (match_operand:GPR 2 "reg_or_short_operand" "rI")))]
11589 "cmp<wd>%I2 %0,%1,%2"
11590 [(set_attr "type" "cmp")])
11592 ;; If we are comparing a register for equality with a large constant,
11593 ;; we can do this with an XOR followed by a compare. But this is profitable
11594 ;; only if the large constant is only used for the comparison (and in this
11595 ;; case we already have a register to reuse as scratch).
11597 ;; For 64-bit registers, we could only do so if the constant's bit 15 is clear:
11598 ;; otherwise we'd need to XOR with FFFFFFFF????0000 which is not available.
11601 [(set (match_operand:SI 0 "register_operand")
11602 (match_operand:SI 1 "logical_const_operand" ""))
11603 (set (match_dup 0) (match_operator:SI 3 "boolean_or_operator"
11605 (match_operand:SI 2 "logical_const_operand" "")]))
11606 (set (match_operand:CC 4 "cc_reg_operand" "")
11607 (compare:CC (match_operand:SI 5 "gpc_reg_operand" "")
11610 (if_then_else (match_operator 6 "equality_operator"
11611 [(match_dup 4) (const_int 0)])
11612 (match_operand 7 "" "")
11613 (match_operand 8 "" "")))]
11614 "peep2_reg_dead_p (3, operands[0])
11615 && peep2_reg_dead_p (4, operands[4])"
11616 [(set (match_dup 0) (xor:SI (match_dup 5) (match_dup 9)))
11617 (set (match_dup 4) (compare:CC (match_dup 0) (match_dup 10)))
11618 (set (pc) (if_then_else (match_dup 6) (match_dup 7) (match_dup 8)))]
11621 /* Get the constant we are comparing against, and see what it looks like
11622 when sign-extended from 16 to 32 bits. Then see what constant we could
11623 XOR with SEXTC to get the sign-extended value. */
11624 rtx cnst = simplify_const_binary_operation (GET_CODE (operands[3]),
11626 operands[1], operands[2]);
11627 HOST_WIDE_INT c = INTVAL (cnst);
11628 HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
11629 HOST_WIDE_INT xorv = c ^ sextc;
11631 operands[9] = GEN_INT (xorv);
11632 operands[10] = GEN_INT (sextc);
11635 (define_insn "*cmpsi_internal2"
11636 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11637 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11638 (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
11640 "cmplw%I2 %0,%1,%b2"
11641 [(set_attr "type" "cmp")])
11643 (define_insn "*cmpdi_internal2"
11644 [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11645 (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
11646 (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
11648 "cmpld%I2 %0,%1,%b2"
11649 [(set_attr "type" "cmp")])
11651 ;; The following two insns don't exist as single insns, but if we provide
11652 ;; them, we can swap an add and compare, which will enable us to overlap more
11653 ;; of the required delay between a compare and branch. We generate code for
11654 ;; them by splitting.
11657 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
11658 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
11659 (match_operand:SI 2 "short_cint_operand" "i")))
11660 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
11661 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11664 [(set_attr "length" "8")])
11667 [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
11668 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11669 (match_operand:SI 2 "u_short_cint_operand" "i")))
11670 (set (match_operand:SI 0 "gpc_reg_operand" "=r")
11671 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11674 [(set_attr "length" "8")])
11677 [(set (match_operand:CC 3 "cc_reg_operand" "")
11678 (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
11679 (match_operand:SI 2 "short_cint_operand" "")))
11680 (set (match_operand:SI 0 "gpc_reg_operand" "")
11681 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11683 [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
11684 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11687 [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
11688 (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
11689 (match_operand:SI 2 "u_short_cint_operand" "")))
11690 (set (match_operand:SI 0 "gpc_reg_operand" "")
11691 (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11693 [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
11694 (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11696 ;; Only need to compare second words if first words equal
11697 (define_insn "*cmptf_internal1"
11698 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11699 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "d")
11700 (match_operand:TF 2 "gpc_reg_operand" "d")))]
11701 "!TARGET_IEEEQUAD && !TARGET_XL_COMPAT
11702 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LONG_DOUBLE_128"
11703 "fcmpu %0,%1,%2\;bne %0,$+8\;fcmpu %0,%L1,%L2"
11704 [(set_attr "type" "fpcompare")
11705 (set_attr "length" "12")])
11707 (define_insn_and_split "*cmptf_internal2"
11708 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11709 (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "d")
11710 (match_operand:TF 2 "gpc_reg_operand" "d")))
11711 (clobber (match_scratch:DF 3 "=d"))
11712 (clobber (match_scratch:DF 4 "=d"))
11713 (clobber (match_scratch:DF 5 "=d"))
11714 (clobber (match_scratch:DF 6 "=d"))
11715 (clobber (match_scratch:DF 7 "=d"))
11716 (clobber (match_scratch:DF 8 "=d"))
11717 (clobber (match_scratch:DF 9 "=d"))
11718 (clobber (match_scratch:DF 10 "=d"))
11719 (clobber (match_scratch:GPR 11 "=b"))]
11720 "!TARGET_IEEEQUAD && TARGET_XL_COMPAT
11721 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LONG_DOUBLE_128"
11723 "&& reload_completed"
11724 [(set (match_dup 3) (match_dup 14))
11725 (set (match_dup 4) (match_dup 15))
11726 (set (match_dup 9) (abs:DF (match_dup 5)))
11727 (set (match_dup 0) (compare:CCFP (match_dup 9) (match_dup 3)))
11728 (set (pc) (if_then_else (ne (match_dup 0) (const_int 0))
11729 (label_ref (match_dup 12))
11731 (set (match_dup 0) (compare:CCFP (match_dup 5) (match_dup 7)))
11732 (set (pc) (label_ref (match_dup 13)))
11734 (set (match_dup 10) (minus:DF (match_dup 5) (match_dup 7)))
11735 (set (match_dup 9) (minus:DF (match_dup 6) (match_dup 8)))
11736 (set (match_dup 9) (plus:DF (match_dup 10) (match_dup 9)))
11737 (set (match_dup 0) (compare:CCFP (match_dup 9) (match_dup 4)))
11740 REAL_VALUE_TYPE rv;
11741 const int lo_word = LONG_DOUBLE_LARGE_FIRST ? GET_MODE_SIZE (DFmode) : 0;
11742 const int hi_word = LONG_DOUBLE_LARGE_FIRST ? 0 : GET_MODE_SIZE (DFmode);
11744 operands[5] = simplify_gen_subreg (DFmode, operands[1], TFmode, hi_word);
11745 operands[6] = simplify_gen_subreg (DFmode, operands[1], TFmode, lo_word);
11746 operands[7] = simplify_gen_subreg (DFmode, operands[2], TFmode, hi_word);
11747 operands[8] = simplify_gen_subreg (DFmode, operands[2], TFmode, lo_word);
11748 operands[12] = gen_label_rtx ();
11749 operands[13] = gen_label_rtx ();
11751 operands[14] = force_const_mem (DFmode,
11752 CONST_DOUBLE_FROM_REAL_VALUE (rv, DFmode));
11753 operands[15] = force_const_mem (DFmode,
11754 CONST_DOUBLE_FROM_REAL_VALUE (dconst0,
11759 tocref = create_TOC_reference (XEXP (operands[14], 0), operands[11]);
11760 operands[14] = gen_const_mem (DFmode, tocref);
11761 tocref = create_TOC_reference (XEXP (operands[15], 0), operands[11]);
11762 operands[15] = gen_const_mem (DFmode, tocref);
11763 set_mem_alias_set (operands[14], get_TOC_alias_set ());
11764 set_mem_alias_set (operands[15], get_TOC_alias_set ());
11768 ;; Now we have the scc insns. We can do some combinations because of the
11769 ;; way the machine works.
11771 ;; Note that this is probably faster if we can put an insn between the
11772 ;; mfcr and rlinm, but this is tricky. Let's leave it for now. In most
11773 ;; cases the insns below which don't use an intermediate CR field will
11774 ;; be used instead.
11776 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11777 (match_operator:SI 1 "scc_comparison_operator"
11778 [(match_operand 2 "cc_reg_operand" "y")
11781 "mfcr %0%Q2\;rlwinm %0,%0,%J1,1"
11782 [(set (attr "type")
11783 (cond [(match_test "TARGET_MFCRF")
11784 (const_string "mfcrf")
11786 (const_string "mfcr")))
11787 (set_attr "length" "8")])
11789 ;; Same as above, but get the GT bit.
11790 (define_insn "move_from_CR_gt_bit"
11791 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11792 (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_GT))]
11793 "TARGET_HARD_FLOAT && !TARGET_FPRS"
11794 "mfcr %0\;rlwinm %0,%0,%D1,31,31"
11795 [(set_attr "type" "mfcr")
11796 (set_attr "length" "8")])
11798 ;; Same as above, but get the OV/ORDERED bit.
11799 (define_insn "move_from_CR_ov_bit"
11800 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11801 (unspec:SI [(match_operand:CC 1 "cc_reg_operand" "y")]
11804 "mfcr %0\;rlwinm %0,%0,%t1,1"
11805 [(set_attr "type" "mfcr")
11806 (set_attr "length" "8")])
11809 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11810 (match_operator:DI 1 "scc_comparison_operator"
11811 [(match_operand 2 "cc_reg_operand" "y")
11814 "mfcr %0%Q2\;rlwinm %0,%0,%J1,1"
11815 [(set (attr "type")
11816 (cond [(match_test "TARGET_MFCRF")
11817 (const_string "mfcrf")
11819 (const_string "mfcr")))
11820 (set_attr "length" "8")])
11823 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11824 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11825 [(match_operand 2 "cc_reg_operand" "y,y")
11828 (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
11829 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11832 mfcr %3%Q2\;rlwinm. %3,%3,%J1,1
11834 [(set_attr "type" "shift")
11835 (set_attr "dot" "yes")
11836 (set_attr "length" "8,16")])
11839 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11840 (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11841 [(match_operand 2 "cc_reg_operand" "")
11844 (set (match_operand:SI 3 "gpc_reg_operand" "")
11845 (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11846 "TARGET_32BIT && reload_completed"
11847 [(set (match_dup 3)
11848 (match_op_dup 1 [(match_dup 2) (const_int 0)]))
11850 (compare:CC (match_dup 3)
11855 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11856 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11857 [(match_operand 2 "cc_reg_operand" "y")
11859 (match_operand:SI 3 "const_int_operand" "n")))]
11863 int is_bit = ccr_bit (operands[1], 1);
11864 int put_bit = 31 - (INTVAL (operands[3]) & 31);
11867 if (is_bit >= put_bit)
11868 count = is_bit - put_bit;
11870 count = 32 - (put_bit - is_bit);
11872 operands[4] = GEN_INT (count);
11873 operands[5] = GEN_INT (put_bit);
11875 return \"mfcr %0%Q2\;rlwinm %0,%0,%4,%5,%5\";
11877 [(set (attr "type")
11878 (cond [(match_test "TARGET_MFCRF")
11879 (const_string "mfcrf")
11881 (const_string "mfcr")))
11882 (set_attr "length" "8")])
11885 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11887 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11888 [(match_operand 2 "cc_reg_operand" "y,y")
11890 (match_operand:SI 3 "const_int_operand" "n,n"))
11892 (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
11893 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11898 int is_bit = ccr_bit (operands[1], 1);
11899 int put_bit = 31 - (INTVAL (operands[3]) & 31);
11902 /* Force split for non-cc0 compare. */
11903 if (which_alternative == 1)
11906 if (is_bit >= put_bit)
11907 count = is_bit - put_bit;
11909 count = 32 - (put_bit - is_bit);
11911 operands[5] = GEN_INT (count);
11912 operands[6] = GEN_INT (put_bit);
11914 return \"mfcr %4%Q2\;rlwinm. %4,%4,%5,%6,%6\";
11916 [(set_attr "type" "shift")
11917 (set_attr "dot" "yes")
11918 (set_attr "length" "8,16")])
11921 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
11923 (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11924 [(match_operand 2 "cc_reg_operand" "")
11926 (match_operand:SI 3 "const_int_operand" ""))
11928 (set (match_operand:SI 4 "gpc_reg_operand" "")
11929 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11932 [(set (match_dup 4)
11933 (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11936 (compare:CC (match_dup 4)
11940 ;; There is a 3 cycle delay between consecutive mfcr instructions
11941 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
11944 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11945 (match_operator:SI 1 "scc_comparison_operator"
11946 [(match_operand 2 "cc_reg_operand" "y")
11948 (set (match_operand:SI 3 "gpc_reg_operand" "=r")
11949 (match_operator:SI 4 "scc_comparison_operator"
11950 [(match_operand 5 "cc_reg_operand" "y")
11952 "REGNO (operands[2]) != REGNO (operands[5])"
11953 "mfcr %3\;rlwinm %0,%3,%J1,1\;rlwinm %3,%3,%J4,1"
11954 [(set_attr "type" "mfcr")
11955 (set_attr "length" "12")])
11958 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11959 (match_operator:DI 1 "scc_comparison_operator"
11960 [(match_operand 2 "cc_reg_operand" "y")
11962 (set (match_operand:DI 3 "gpc_reg_operand" "=r")
11963 (match_operator:DI 4 "scc_comparison_operator"
11964 [(match_operand 5 "cc_reg_operand" "y")
11966 "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
11967 "mfcr %3\;rlwinm %0,%3,%J1,1\;rlwinm %3,%3,%J4,1"
11968 [(set_attr "type" "mfcr")
11969 (set_attr "length" "12")])
11971 ;; There are some scc insns that can be done directly, without a compare.
11972 ;; These are faster because they don't involve the communications between
11973 ;; the FXU and branch units. In fact, we will be replacing all of the
11974 ;; integer scc insns here or in the portable methods in emit_store_flag.
11976 ;; Also support (neg (scc ..)) since that construct is used to replace
11977 ;; branches, (plus (scc ..) ..) since that construct is common and
11978 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
11979 ;; cases where it is no more expensive than (neg (scc ..)).
11981 ;; Have reload force a constant into a register for the simple insns that
11982 ;; otherwise won't accept constants. We do this because it is faster than
11983 ;; the cmp/mfcr sequence we would otherwise generate.
11985 (define_mode_attr scc_eq_op2 [(SI "rKLI")
11988 (define_insn_and_split "*eq<mode>"
11989 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
11990 (eq:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
11991 (match_operand:GPR 2 "scc_eq_operand" "<scc_eq_op2>")))]
11995 [(set (match_dup 0)
11996 (clz:GPR (match_dup 3)))
11998 (lshiftrt:GPR (match_dup 0) (match_dup 4)))]
12000 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
12002 /* Use output operand as intermediate. */
12003 operands[3] = operands[0];
12005 if (logical_operand (operands[2], <MODE>mode))
12006 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12007 gen_rtx_XOR (<MODE>mode,
12008 operands[1], operands[2])));
12010 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12011 gen_rtx_PLUS (<MODE>mode, operands[1],
12012 negate_rtx (<MODE>mode,
12016 operands[3] = operands[1];
12018 operands[4] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
12021 (define_insn_and_split "*eq<mode>_compare"
12022 [(set (match_operand:CC 3 "cc_reg_operand" "=y")
12024 (eq:P (match_operand:P 1 "gpc_reg_operand" "=r")
12025 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))
12027 (set (match_operand:P 0 "gpc_reg_operand" "=r")
12028 (eq:P (match_dup 1) (match_dup 2)))]
12032 [(set (match_dup 0)
12033 (clz:P (match_dup 4)))
12034 (parallel [(set (match_dup 3)
12035 (compare:CC (lshiftrt:P (match_dup 0) (match_dup 5))
12038 (lshiftrt:P (match_dup 0) (match_dup 5)))])]
12040 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
12042 /* Use output operand as intermediate. */
12043 operands[4] = operands[0];
12045 if (logical_operand (operands[2], <MODE>mode))
12046 emit_insn (gen_rtx_SET (VOIDmode, operands[4],
12047 gen_rtx_XOR (<MODE>mode,
12048 operands[1], operands[2])));
12050 emit_insn (gen_rtx_SET (VOIDmode, operands[4],
12051 gen_rtx_PLUS (<MODE>mode, operands[1],
12052 negate_rtx (<MODE>mode,
12056 operands[4] = operands[1];
12058 operands[5] = GEN_INT (exact_log2 (GET_MODE_BITSIZE (<MODE>mode)));
12061 ;; We have insns of the form shown by the first define_insn below. If
12062 ;; there is something inside the comparison operation, we must split it.
12064 [(set (match_operand:SI 0 "gpc_reg_operand" "")
12065 (plus:SI (match_operator 1 "comparison_operator"
12066 [(match_operand:SI 2 "" "")
12067 (match_operand:SI 3
12068 "reg_or_cint_operand" "")])
12069 (match_operand:SI 4 "gpc_reg_operand" "")))
12070 (clobber (match_operand:SI 5 "register_operand" ""))]
12071 "! gpc_reg_operand (operands[2], SImode)"
12072 [(set (match_dup 5) (match_dup 2))
12073 (set (match_dup 0) (plus:SI (match_op_dup 1 [(match_dup 5) (match_dup 3)])
12076 (define_insn "*plus_eqsi"
12077 [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
12078 (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
12079 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I"))
12080 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
12083 xor %0,%1,%2\;subfic %0,%0,0\;addze %0,%3
12084 subfic %0,%1,0\;addze %0,%3
12085 xori %0,%1,%b2\;subfic %0,%0,0\;addze %0,%3
12086 xoris %0,%1,%u2\;subfic %0,%0,0\;addze %0,%3
12087 subfic %0,%1,%2\;subfic %0,%0,0\;addze %0,%3"
12088 [(set_attr "type" "three,two,three,three,three")
12089 (set_attr "length" "12,8,12,12,12")])
12091 (define_insn "*compare_plus_eqsi"
12092 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
12095 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
12096 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
12097 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
12099 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
12100 "TARGET_32BIT && optimize_size"
12102 xor %4,%1,%2\;subfic %4,%4,0\;addze. %4,%3
12103 subfic %4,%1,0\;addze. %4,%3
12104 xori %4,%1,%b2\;subfic %4,%4,0\;addze. %4,%3
12105 xoris %4,%1,%u2\;subfic %4,%4,0\;addze. %4,%3
12106 subfic %4,%1,%2\;subfic %4,%4,0\;addze. %4,%3
12112 [(set_attr "type" "compare")
12113 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
12116 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12119 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
12120 (match_operand:SI 2 "scc_eq_operand" ""))
12121 (match_operand:SI 3 "gpc_reg_operand" ""))
12123 (clobber (match_scratch:SI 4 ""))]
12124 "TARGET_32BIT && optimize_size && reload_completed"
12125 [(set (match_dup 4)
12126 (plus:SI (eq:SI (match_dup 1)
12130 (compare:CC (match_dup 4)
12134 (define_insn "*plus_eqsi_compare"
12135 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
12138 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
12139 (match_operand:SI 2 "scc_eq_operand" "r,O,K,L,I,r,O,K,L,I"))
12140 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
12142 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
12143 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12144 "TARGET_32BIT && optimize_size"
12146 xor %0,%1,%2\;subfic %0,%0,0\;addze. %0,%3
12147 subfic %0,%1,0\;addze. %0,%3
12148 xori %0,%1,%b2\;subfic %0,%0,0\;addze. %0,%3
12149 xoris %0,%1,%u2\;subfic %0,%0,0\;addze. %0,%3
12150 subfic %0,%1,%2\;subfic %0,%0,0\;addze. %0,%3
12156 [(set_attr "type" "compare")
12157 (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
12160 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12163 (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
12164 (match_operand:SI 2 "scc_eq_operand" ""))
12165 (match_operand:SI 3 "gpc_reg_operand" ""))
12167 (set (match_operand:SI 0 "gpc_reg_operand" "")
12168 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12169 "TARGET_32BIT && optimize_size && reload_completed"
12170 [(set (match_dup 0)
12171 (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12173 (compare:CC (match_dup 0)
12177 (define_insn "*neg_eq0<mode>"
12178 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12179 (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "r")
12182 "addic %0,%1,-1\;subfe %0,%0,%0"
12183 [(set_attr "type" "two")
12184 (set_attr "length" "8")])
12186 (define_insn_and_split "*neg_eq<mode>"
12187 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12188 (neg:P (eq:P (match_operand:P 1 "gpc_reg_operand" "%r")
12189 (match_operand:P 2 "scc_eq_operand" "<scc_eq_op2>"))))]
12193 [(set (match_dup 0) (neg:P (eq:P (match_dup 3) (const_int 0))))]
12195 if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) != 0)
12197 /* Use output operand as intermediate. */
12198 operands[3] = operands[0];
12200 if (logical_operand (operands[2], <MODE>mode))
12201 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12202 gen_rtx_XOR (<MODE>mode,
12203 operands[1], operands[2])));
12205 emit_insn (gen_rtx_SET (VOIDmode, operands[3],
12206 gen_rtx_PLUS (<MODE>mode, operands[1],
12207 negate_rtx (<MODE>mode,
12211 operands[3] = operands[1];
12214 (define_insn "*ne0_<mode>"
12215 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12216 (ne:P (match_operand:P 1 "gpc_reg_operand" "r")
12218 (clobber (match_scratch:P 2 "=&r"))]
12219 "!(TARGET_32BIT && TARGET_ISEL)"
12220 "addic %2,%1,-1\;subfe %0,%2,%1"
12221 [(set_attr "type" "two")
12222 (set_attr "length" "8")])
12224 (define_insn "*plus_ne0_<mode>"
12225 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12226 (plus:P (ne:P (match_operand:P 1 "gpc_reg_operand" "r")
12228 (match_operand:P 2 "gpc_reg_operand" "r")))
12229 (clobber (match_scratch:P 3 "=&r"))]
12231 "addic %3,%1,-1\;addze %0,%2"
12232 [(set_attr "type" "two")
12233 (set_attr "length" "8")])
12235 (define_insn "*compare_plus_ne0_<mode>"
12236 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12237 (compare:CC (plus:P (ne:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12239 (match_operand:P 2 "gpc_reg_operand" "r,r"))
12241 (clobber (match_scratch:P 3 "=&r,&r"))
12242 (clobber (match_scratch:P 4 "=X,&r"))]
12245 addic %3,%1,-1\;addze. %3,%2
12247 [(set_attr "type" "compare")
12248 (set_attr "length" "8,12")])
12251 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
12252 (compare:CC (ne:P (match_operand:SI 1 "gpc_reg_operand" "")
12254 (neg:P (match_operand:P 2 "gpc_reg_operand" ""))))
12255 (clobber (match_scratch:P 3 ""))
12256 (clobber (match_scratch:P 4 ""))]
12258 [(parallel [(set (match_dup 3)
12259 (plus:P (ne:P (match_dup 1)
12262 (clobber (match_dup 4))])
12264 (compare:CC (match_dup 3)
12269 (define_insn "*compare_plus_ne0_<mode>_1"
12270 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=x,?y")
12271 (compare:CCEQ (ne:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12273 (neg:P (match_operand:P 2 "gpc_reg_operand" "r,r"))))
12274 (clobber (match_scratch:P 3 "=&r,&r"))
12275 (clobber (match_scratch:P 4 "=X,&r"))]
12278 addic %3,%1,-1\;addze. %3,%2
12280 [(set_attr "type" "compare")
12281 (set_attr "length" "8,12")])
12284 [(set (match_operand:CCEQ 0 "cc_reg_not_micro_cr0_operand" "")
12285 (compare:CCEQ (ne:P (match_operand:SI 1 "gpc_reg_operand" "")
12287 (neg:P (match_operand:P 2 "gpc_reg_operand" ""))))
12288 (clobber (match_scratch:P 3 ""))
12289 (clobber (match_scratch:P 4 ""))]
12291 [(parallel [(set (match_dup 3)
12292 (plus:P (ne:P (match_dup 1)
12295 (clobber (match_dup 4))])
12297 (compare:CC (match_dup 3)
12301 (define_insn "*plus_ne0_<mode>_compare"
12302 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12304 (plus:P (ne:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12306 (match_operand:P 2 "gpc_reg_operand" "r,r"))
12308 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12309 (plus:P (ne:P (match_dup 1)
12312 (clobber (match_scratch:P 3 "=&r,&r"))]
12315 addic %3,%1,-1\;addze. %0,%2
12317 [(set_attr "type" "compare")
12318 (set_attr "length" "8,12")])
12321 [(set (match_operand:CC 4 "cc_reg_not_micro_cr0_operand" "")
12323 (plus:P (ne:P (match_operand:P 1 "gpc_reg_operand" "")
12325 (match_operand:P 2 "gpc_reg_operand" ""))
12327 (set (match_operand:P 0 "gpc_reg_operand" "")
12328 (plus:P (ne:P (match_dup 1)
12331 (clobber (match_scratch:P 3 ""))]
12333 [(parallel [(set (match_dup 0)
12334 (plus:P (ne:P (match_dup 1)
12337 (clobber (match_dup 3))])
12339 (compare:CC (match_dup 0)
12343 (define_insn "*leu<mode>"
12344 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12345 (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12346 (match_operand:P 2 "reg_or_short_operand" "rI")))]
12348 "subf%I2c %0,%1,%2\;li %0,0\;adde %0,%0,%0"
12349 [(set_attr "type" "three")
12350 (set_attr "length" "12")])
12352 (define_insn "*leu<mode>_compare"
12353 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12355 (leu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12356 (match_operand:P 2 "reg_or_short_operand" "rI,rI"))
12358 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12359 (leu:P (match_dup 1) (match_dup 2)))]
12362 subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
12364 [(set_attr "type" "compare")
12365 (set_attr "length" "12,16")])
12368 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12370 (leu:P (match_operand:P 1 "gpc_reg_operand" "")
12371 (match_operand:P 2 "reg_or_short_operand" ""))
12373 (set (match_operand:P 0 "gpc_reg_operand" "")
12374 (leu:P (match_dup 1) (match_dup 2)))]
12376 [(set (match_dup 0)
12377 (leu:P (match_dup 1) (match_dup 2)))
12379 (compare:CC (match_dup 0)
12383 (define_insn "*plus_leu<mode>"
12384 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12385 (plus:P (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12386 (match_operand:P 2 "reg_or_short_operand" "rI"))
12387 (match_operand:P 3 "gpc_reg_operand" "r")))]
12389 "subf%I2c %0,%1,%2\;addze %0,%3"
12390 [(set_attr "type" "two")
12391 (set_attr "length" "8")])
12394 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12396 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12397 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12398 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12400 (clobber (match_scratch:SI 4 "=&r,&r"))]
12403 subf%I2c %4,%1,%2\;addze. %4,%3
12405 [(set_attr "type" "compare")
12406 (set_attr "length" "8,12")])
12409 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12411 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12412 (match_operand:SI 2 "reg_or_short_operand" ""))
12413 (match_operand:SI 3 "gpc_reg_operand" ""))
12415 (clobber (match_scratch:SI 4 ""))]
12416 "TARGET_32BIT && reload_completed"
12417 [(set (match_dup 4)
12418 (plus:SI (leu:SI (match_dup 1) (match_dup 2))
12421 (compare:CC (match_dup 4)
12426 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12428 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12429 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12430 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12432 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12433 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12436 subf%I2c %0,%1,%2\;addze. %0,%3
12438 [(set_attr "type" "compare")
12439 (set_attr "length" "8,12")])
12442 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12444 (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12445 (match_operand:SI 2 "reg_or_short_operand" ""))
12446 (match_operand:SI 3 "gpc_reg_operand" ""))
12448 (set (match_operand:SI 0 "gpc_reg_operand" "")
12449 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12450 "TARGET_32BIT && reload_completed"
12451 [(set (match_dup 0)
12452 (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12454 (compare:CC (match_dup 0)
12458 (define_insn "*neg_leu<mode>"
12459 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12460 (neg:P (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12461 (match_operand:P 2 "reg_or_short_operand" "rI"))))]
12463 "subf%I2c %0,%1,%2\;subfe %0,%0,%0\;nand %0,%0,%0"
12464 [(set_attr "type" "three")
12465 (set_attr "length" "12")])
12467 (define_insn "*and_neg_leu<mode>"
12468 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12470 (leu:P (match_operand:P 1 "gpc_reg_operand" "r")
12471 (match_operand:P 2 "reg_or_short_operand" "rI")))
12472 (match_operand:P 3 "gpc_reg_operand" "r")))]
12474 "subf%I2c %0,%1,%2\;subfe %0,%0,%0\;andc %0,%3,%0"
12475 [(set_attr "type" "three")
12476 (set_attr "length" "12")])
12479 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12482 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12483 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12484 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12486 (clobber (match_scratch:SI 4 "=&r,&r"))]
12489 subf%I2c %4,%1,%2\;subfe %4,%4,%4\;andc. %4,%3,%4
12491 [(set_attr "type" "compare")
12492 (set_attr "length" "12,16")])
12495 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12498 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12499 (match_operand:SI 2 "reg_or_short_operand" "")))
12500 (match_operand:SI 3 "gpc_reg_operand" ""))
12502 (clobber (match_scratch:SI 4 ""))]
12503 "TARGET_32BIT && reload_completed"
12504 [(set (match_dup 4)
12505 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12508 (compare:CC (match_dup 4)
12513 [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12516 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12517 (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12518 (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12520 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12521 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12524 subf%I2c %0,%1,%2\;subfe %0,%0,%0\;andc. %0,%3,%0
12526 [(set_attr "type" "compare")
12527 (set_attr "length" "12,16")])
12530 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12533 (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12534 (match_operand:SI 2 "reg_or_short_operand" "")))
12535 (match_operand:SI 3 "gpc_reg_operand" ""))
12537 (set (match_operand:SI 0 "gpc_reg_operand" "")
12538 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12539 "TARGET_32BIT && reload_completed"
12540 [(set (match_dup 0)
12541 (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12544 (compare:CC (match_dup 0)
12548 (define_insn_and_split "*ltu<mode>"
12549 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12550 (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12551 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))]
12555 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12556 (set (match_dup 0) (neg:P (match_dup 0)))]
12559 (define_insn_and_split "*ltu<mode>_compare"
12560 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12562 (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12563 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
12565 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
12566 (ltu:P (match_dup 1) (match_dup 2)))]
12570 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12571 (parallel [(set (match_dup 3)
12572 (compare:CC (neg:P (match_dup 0)) (const_int 0)))
12573 (set (match_dup 0) (neg:P (match_dup 0)))])]
12576 (define_insn_and_split "*plus_ltu<mode>"
12577 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,r")
12578 (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12579 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
12580 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
12583 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12584 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12585 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))]
12588 (define_insn_and_split "*plus_ltu<mode>_1"
12589 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,r")
12590 (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12591 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
12592 (match_operand:P 3 "short_cint_operand" "I,I")))]
12595 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12596 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12597 (parallel [(set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))
12598 (clobber (reg:P CA_REGNO))])]
12601 (define_insn_and_split "*plus_ltu<mode>_compare"
12602 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12604 (plus:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12605 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
12606 (match_operand:P 3 "gpc_reg_operand" "r,r,r,r"))
12608 (set (match_operand:P 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12609 (plus:P (ltu:P (match_dup 1) (match_dup 2)) (match_dup 3)))]
12612 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12613 [(set (match_dup 0) (neg:P (ltu:P (match_dup 1) (match_dup 2))))
12614 (parallel [(set (match_dup 4)
12615 (compare:CC (minus:P (match_dup 3) (match_dup 0))
12617 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))])]
12620 (define_insn "*neg_ltu<mode>"
12621 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12622 (neg:P (ltu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12623 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))))]
12626 subfc %0,%2,%1\;subfe %0,%0,%0
12627 addic %0,%1,%n2\;subfe %0,%0,%0"
12628 [(set_attr "type" "two")
12629 (set_attr "length" "8")])
12631 (define_insn "*geu<mode>"
12632 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12633 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12634 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))]
12637 subfc %0,%2,%1\;li %0,0\;adde %0,%0,%0
12638 addic %0,%1,%n2\;li %0,0\;adde %0,%0,%0"
12639 [(set_attr "type" "three")
12640 (set_attr "length" "12")])
12642 (define_insn "*geu<mode>_compare"
12643 [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12645 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
12646 (match_operand:P 2 "reg_or_neg_short_operand" "r,P,r,P"))
12648 (set (match_operand:P 0 "gpc_reg_operand" "=r,r,r,r")
12649 (geu:P (match_dup 1) (match_dup 2)))]
12652 subfc %0,%2,%1\;li %0,0\;adde. %0,%0,%0
12653 addic %0,%1,%n2\;li %0,0\;adde. %0,%0,%0
12656 [(set_attr "type" "compare")
12657 (set_attr "length" "12,12,16,16")])
12660 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
12662 (geu:P (match_operand:P 1 "gpc_reg_operand" "")
12663 (match_operand:P 2 "reg_or_neg_short_operand" ""))
12665 (set (match_operand:P 0 "gpc_reg_operand" "")
12666 (geu:P (match_dup 1) (match_dup 2)))]
12668 [(set (match_dup 0)
12669 (geu:P (match_dup 1) (match_dup 2)))
12671 (compare:CC (match_dup 0)
12675 (define_insn "*plus_geu<mode>"
12676 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,&r")
12677 (plus:P (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12678 (match_operand:P 2 "reg_or_neg_short_operand" "r,P"))
12679 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
12682 subfc %0,%2,%1\;addze %0,%3
12683 addic %0,%1,%n2\;addze %0,%3"
12684 [(set_attr "type" "two")
12685 (set_attr "length" "8")])
12688 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12690 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12691 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12692 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12694 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12697 subfc %4,%2,%1\;addze. %4,%3
12698 addic %4,%1,%n2\;addze. %4,%3
12701 [(set_attr "type" "compare")
12702 (set_attr "length" "8,8,12,12")])
12705 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12707 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12708 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12709 (match_operand:SI 3 "gpc_reg_operand" ""))
12711 (clobber (match_scratch:SI 4 ""))]
12712 "TARGET_32BIT && reload_completed"
12713 [(set (match_dup 4)
12714 (plus:SI (geu:SI (match_dup 1) (match_dup 2))
12717 (compare:CC (match_dup 4)
12722 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12724 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12725 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12726 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12728 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12729 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12732 subfc %0,%2,%1\;addze. %0,%3
12733 addic %0,%1,%n2\;addze. %0,%3
12736 [(set_attr "type" "compare")
12737 (set_attr "length" "8,8,12,12")])
12740 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12742 (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12743 (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12744 (match_operand:SI 3 "gpc_reg_operand" ""))
12746 (set (match_operand:SI 0 "gpc_reg_operand" "")
12747 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12748 "TARGET_32BIT && reload_completed"
12749 [(set (match_dup 0)
12750 (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12752 (compare:CC (match_dup 0)
12756 (define_insn "*neg_geu<mode>"
12757 [(set (match_operand:P 0 "gpc_reg_operand" "=r,r")
12758 (neg:P (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12759 (match_operand:P 2 "reg_or_short_operand" "r,I"))))]
12762 subfc %0,%2,%1\;subfe %0,%0,%0\;nand %0,%0,%0
12763 subfic %0,%1,-1\;add%I2c %0,%0,%2\;subfe %0,%0,%0"
12764 [(set_attr "type" "three")
12765 (set_attr "length" "12")])
12767 (define_insn "*and_neg_geu<mode>"
12768 [(set (match_operand:P 0 "gpc_reg_operand" "=&r,&r")
12770 (geu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
12771 (match_operand:P 2 "reg_or_neg_short_operand" "r,P")))
12772 (match_operand:P 3 "gpc_reg_operand" "r,r")))]
12775 subfc %0,%2,%1\;subfe %0,%0,%0\;andc %0,%3,%0
12776 addic %0,%1,%n2\;subfe %0,%0,%0\;andc %0,%3,%0"
12777 [(set_attr "type" "three")
12778 (set_attr "length" "12")])
12781 [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12784 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12785 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12786 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12788 (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12791 subfc %4,%2,%1\;subfe %4,%4,%4\;andc. %4,%3,%4
12792 addic %4,%1,%n2\;subfe %4,%4,%4\;andc. %4,%3,%4
12795 [(set_attr "type" "compare")
12796 (set_attr "length" "12,12,16,16")])
12799 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12802 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12803 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12804 (match_operand:SI 3 "gpc_reg_operand" ""))
12806 (clobber (match_scratch:SI 4 ""))]
12807 "TARGET_32BIT && reload_completed"
12808 [(set (match_dup 4)
12809 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2)))
12812 (compare:CC (match_dup 4)
12817 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12820 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12821 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12822 (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12824 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12825 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12828 subfc %0,%2,%1\;subfe %0,%0,%0\;andc. %0,%3,%0
12829 addic %0,%1,%n2\;subfe %0,%0,%0\;andc. %0,%3,%0
12832 [(set_attr "type" "compare")
12833 (set_attr "length" "12,12,16,16")])
12836 [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12839 (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12840 (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12841 (match_operand:SI 3 "gpc_reg_operand" ""))
12843 (set (match_operand:SI 0 "gpc_reg_operand" "")
12844 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12845 "TARGET_32BIT && reload_completed"
12846 [(set (match_dup 0)
12847 (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
12849 (compare:CC (match_dup 0)
12853 (define_insn "*plus_gt0<mode>"
12854 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
12855 (plus:P (gt:P (match_operand:P 1 "gpc_reg_operand" "r")
12857 (match_operand:P 2 "gpc_reg_operand" "r")))]
12859 "addc %0,%1,%1\;subfe %0,%1,%0\;addze %0,%2"
12860 [(set_attr "type" "three")
12861 (set_attr "length" "12")])
12864 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12866 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12868 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12870 (clobber (match_scratch:SI 3 "=&r,&r"))]
12873 addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
12875 [(set_attr "type" "compare")
12876 (set_attr "length" "12,16")])
12879 [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12881 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12883 (match_operand:SI 2 "gpc_reg_operand" ""))
12885 (clobber (match_scratch:SI 3 ""))]
12886 "TARGET_32BIT && reload_completed"
12887 [(set (match_dup 3)
12888 (plus:SI (gt:SI (match_dup 1) (const_int 0))
12891 (compare:CC (match_dup 3)
12896 [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12898 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12900 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12902 (clobber (match_scratch:DI 3 "=&r,&r"))]
12905 addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
12907 [(set_attr "type" "compare")
12908 (set_attr "length" "12,16")])
12911 [(set (match_operand:CC 0 "cc_reg_not_micro_cr0_operand" "")
12913 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12915 (match_operand:DI 2 "gpc_reg_operand" ""))
12917 (clobber (match_scratch:DI 3 ""))]
12918 "TARGET_64BIT && reload_completed"
12919 [(set (match_dup 3)
12920 (plus:DI (gt:DI (match_dup 1) (const_int 0))
12923 (compare:CC (match_dup 3)
12928 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12930 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12932 (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12934 (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12935 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
12938 addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
12940 [(set_attr "type" "compare")
12941 (set_attr "length" "12,16")])
12944 [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12946 (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12948 (match_operand:SI 2 "gpc_reg_operand" ""))
12950 (set (match_operand:SI 0 "gpc_reg_operand" "")
12951 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
12952 "TARGET_32BIT && reload_completed"
12953 [(set (match_dup 0)
12954 (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
12956 (compare:CC (match_dup 0)
12961 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12963 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12965 (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12967 (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
12968 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
12971 addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
12973 [(set_attr "type" "compare")
12974 (set_attr "length" "12,16")])
12977 [(set (match_operand:CC 3 "cc_reg_not_micro_cr0_operand" "")
12979 (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12981 (match_operand:DI 2 "gpc_reg_operand" ""))
12983 (set (match_operand:DI 0 "gpc_reg_operand" "")
12984 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
12985 "TARGET_64BIT && reload_completed"
12986 [(set (match_dup 0)
12987 (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
12989 (compare:CC (match_dup 0)
12993 (define_insn_and_split "*gtu<mode>"
12994 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
12995 (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
12996 (match_operand:P 2 "reg_or_short_operand" "rI")))]
13000 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13001 (set (match_dup 0) (neg:P (match_dup 0)))]
13004 (define_insn_and_split "*gtu<mode>_compare"
13005 [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13007 (gtu:P (match_operand:P 1 "gpc_reg_operand" "r,r")
13008 (match_operand:P 2 "reg_or_short_operand" "rI,rI"))
13010 (set (match_operand:P 0 "gpc_reg_operand" "=r,r")
13011 (gtu:P (match_dup 1) (match_dup 2)))]
13015 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13016 (parallel [(set (match_dup 3)
13017 (compare:CC (neg:P (match_dup 0)) (const_int 0)))
13018 (set (match_dup 0) (neg:P (match_dup 0)))])]
13021 (define_insn_and_split "*plus_gtu<mode>"
13022 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
13023 (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
13024 (match_operand:P 2 "reg_or_short_operand" "rI"))
13025 (match_operand:P 3 "gpc_reg_operand" "r")))]
13028 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13029 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13030 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))]
13033 (define_insn_and_split "*plus_gtu<mode>_1"
13034 [(set (match_operand:P 0 "gpc_reg_operand" "=&r")
13035 (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
13036 (match_operand:P 2 "reg_or_short_operand" "rI"))
13037 (match_operand:P 3 "short_cint_operand" "I")))]
13040 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13041 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13042 (parallel [(set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))
13043 (clobber (reg:P CA_REGNO))])]
13046 (define_insn_and_split "*plus_gtu<mode>_compare"
13047 [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13049 (plus:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r,r,r,r")
13050 (match_operand:P 2 "reg_or_short_operand" "I,r,I,r"))
13051 (match_operand:P 3 "gpc_reg_operand" "r,r,r,r"))
13053 (set (match_operand:P 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13054 (plus:P (gtu:P (match_dup 1) (match_dup 2)) (match_dup 3)))]
13057 "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13058 [(set (match_dup 0) (neg:P (gtu:P (match_dup 1) (match_dup 2))))
13059 (parallel [(set (match_dup 4)
13060 (compare:CC (minus:P (match_dup 3) (match_dup 0))
13062 (set (match_dup 0) (minus:P (match_dup 3) (match_dup 0)))])]
13065 (define_insn "*neg_gtu<mode>"
13066 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
13067 (neg:P (gtu:P (match_operand:P 1 "gpc_reg_operand" "r")
13068 (match_operand:P 2 "reg_or_short_operand" "rI"))))]
13070 "subf%I2c %0,%1,%2\;subfe %0,%0,%0"
13071 [(set_attr "type" "two")
13072 (set_attr "length" "8")])
13075 ;; Define both directions of branch and return. If we need a reload
13076 ;; register, we'd rather use CR0 since it is much easier to copy a
13077 ;; register CC value to there.
13081 (if_then_else (match_operator 1 "branch_comparison_operator"
13083 "cc_reg_operand" "y")
13085 (label_ref (match_operand 0 "" ""))
13090 return output_cbranch (operands[1], \"%l0\", 0, insn);
13092 [(set_attr "type" "branch")])
13096 (if_then_else (match_operator 0 "branch_comparison_operator"
13098 "cc_reg_operand" "y")
13105 return output_cbranch (operands[0], NULL, 0, insn);
13107 [(set_attr "type" "jmpreg")
13108 (set_attr "length" "4")])
13112 (if_then_else (match_operator 1 "branch_comparison_operator"
13114 "cc_reg_operand" "y")
13117 (label_ref (match_operand 0 "" ""))))]
13121 return output_cbranch (operands[1], \"%l0\", 1, insn);
13123 [(set_attr "type" "branch")])
13127 (if_then_else (match_operator 0 "branch_comparison_operator"
13129 "cc_reg_operand" "y")
13136 return output_cbranch (operands[0], NULL, 1, insn);
13138 [(set_attr "type" "jmpreg")
13139 (set_attr "length" "4")])
13141 ;; Logic on condition register values.
13143 ; This pattern matches things like
13144 ; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
13145 ; (eq:SI (reg:CCFP 68) (const_int 0)))
13147 ; which are generated by the branch logic.
13148 ; Prefer destructive operations where BT = BB (for crXX BT,BA,BB)
13150 (define_insn "*cceq_ior_compare"
13151 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13152 (compare:CCEQ (match_operator:SI 1 "boolean_operator"
13153 [(match_operator:SI 2
13154 "branch_positive_comparison_operator"
13156 "cc_reg_operand" "y,y")
13158 (match_operator:SI 4
13159 "branch_positive_comparison_operator"
13161 "cc_reg_operand" "0,y")
13165 "cr%q1 %E0,%j2,%j4"
13166 [(set_attr "type" "cr_logical,delayed_cr")])
13168 ; Why is the constant -1 here, but 1 in the previous pattern?
13169 ; Because ~1 has all but the low bit set.
13171 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13172 (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
13173 [(not:SI (match_operator:SI 2
13174 "branch_positive_comparison_operator"
13176 "cc_reg_operand" "y,y")
13178 (match_operator:SI 4
13179 "branch_positive_comparison_operator"
13181 "cc_reg_operand" "0,y")
13185 "cr%q1 %E0,%j2,%j4"
13186 [(set_attr "type" "cr_logical,delayed_cr")])
13188 (define_insn "*cceq_rev_compare"
13189 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13190 (compare:CCEQ (match_operator:SI 1
13191 "branch_positive_comparison_operator"
13193 "cc_reg_operand" "0,y")
13198 [(set_attr "type" "cr_logical,delayed_cr")])
13200 ;; If we are comparing the result of two comparisons, this can be done
13201 ;; using creqv or crxor.
13203 (define_insn_and_split ""
13204 [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13205 (compare:CCEQ (match_operator 1 "branch_comparison_operator"
13206 [(match_operand 2 "cc_reg_operand" "y")
13208 (match_operator 3 "branch_comparison_operator"
13209 [(match_operand 4 "cc_reg_operand" "y")
13214 [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
13218 int positive_1, positive_2;
13220 positive_1 = branch_positive_comparison_operator (operands[1],
13221 GET_MODE (operands[1]));
13222 positive_2 = branch_positive_comparison_operator (operands[3],
13223 GET_MODE (operands[3]));
13226 operands[1] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[2]),
13227 GET_CODE (operands[1])),
13229 operands[2], const0_rtx);
13230 else if (GET_MODE (operands[1]) != SImode)
13231 operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode,
13232 operands[2], const0_rtx);
13235 operands[3] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[4]),
13236 GET_CODE (operands[3])),
13238 operands[4], const0_rtx);
13239 else if (GET_MODE (operands[3]) != SImode)
13240 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
13241 operands[4], const0_rtx);
13243 if (positive_1 == positive_2)
13245 operands[1] = gen_rtx_NOT (SImode, operands[1]);
13246 operands[5] = constm1_rtx;
13250 operands[5] = const1_rtx;
13254 ;; Unconditional branch and return.
13256 (define_insn "jump"
13258 (label_ref (match_operand 0 "" "")))]
13261 [(set_attr "type" "branch")])
13263 (define_insn "<return_str>return"
13267 [(set_attr "type" "jmpreg")])
13269 (define_expand "indirect_jump"
13270 [(set (pc) (match_operand 0 "register_operand" ""))])
13272 (define_insn "*indirect_jump<mode>"
13273 [(set (pc) (match_operand:P 0 "register_operand" "c,*l"))]
13278 [(set_attr "type" "jmpreg")])
13280 ;; Table jump for switch statements:
13281 (define_expand "tablejump"
13282 [(use (match_operand 0 "" ""))
13283 (use (label_ref (match_operand 1 "" "")))]
13288 emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
13290 emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
13294 (define_expand "tablejumpsi"
13295 [(set (match_dup 3)
13296 (plus:SI (match_operand:SI 0 "" "")
13298 (parallel [(set (pc) (match_dup 3))
13299 (use (label_ref (match_operand 1 "" "")))])]
13302 { operands[0] = force_reg (SImode, operands[0]);
13303 operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
13304 operands[3] = gen_reg_rtx (SImode);
13307 (define_expand "tablejumpdi"
13308 [(set (match_dup 4)
13309 (sign_extend:DI (match_operand:SI 0 "lwa_operand" "")))
13311 (plus:DI (match_dup 4)
13313 (parallel [(set (pc) (match_dup 3))
13314 (use (label_ref (match_operand 1 "" "")))])]
13317 { operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
13318 operands[3] = gen_reg_rtx (DImode);
13319 operands[4] = gen_reg_rtx (DImode);
13322 (define_insn "*tablejump<mode>_internal1"
13324 (match_operand:P 0 "register_operand" "c,*l"))
13325 (use (label_ref (match_operand 1 "" "")))]
13330 [(set_attr "type" "jmpreg")])
13337 (define_insn "group_ending_nop"
13338 [(unspec [(const_int 0)] UNSPEC_GRP_END_NOP)]
13342 if (rs6000_cpu_attr == CPU_POWER6)
13343 return \"ori 1,1,0\";
13344 return \"ori 2,2,0\";
13347 ;; Define the subtract-one-and-jump insns, starting with the template
13348 ;; so loop.c knows what to generate.
13350 (define_expand "doloop_end"
13351 [(use (match_operand 0 "" "")) ; loop pseudo
13352 (use (match_operand 1 "" ""))] ; label
13358 if (GET_MODE (operands[0]) != DImode)
13360 emit_jump_insn (gen_ctrdi (operands[0], operands[1]));
13364 if (GET_MODE (operands[0]) != SImode)
13366 emit_jump_insn (gen_ctrsi (operands[0], operands[1]));
13371 (define_expand "ctr<mode>"
13372 [(parallel [(set (pc)
13373 (if_then_else (ne (match_operand:P 0 "register_operand" "")
13375 (label_ref (match_operand 1 "" ""))
13378 (plus:P (match_dup 0)
13380 (clobber (match_scratch:CC 2 ""))
13381 (clobber (match_scratch:P 3 ""))])]
13385 ;; We need to be able to do this for any operand, including MEM, or we
13386 ;; will cause reload to blow up since we don't allow output reloads on
13388 ;; For the length attribute to be calculated correctly, the
13389 ;; label MUST be operand 0.
13391 (define_insn "*ctr<mode>_internal1"
13393 (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13395 (label_ref (match_operand 0 "" ""))
13397 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*c*l")
13398 (plus:P (match_dup 1)
13400 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13401 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13405 if (which_alternative != 0)
13407 else if (get_attr_length (insn) == 4)
13408 return \"bdnz %l0\";
13410 return \"bdz $+8\;b %l0\";
13412 [(set_attr "type" "branch")
13413 (set_attr "length" "*,12,16,16")])
13415 (define_insn "*ctr<mode>_internal2"
13417 (if_then_else (ne (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13420 (label_ref (match_operand 0 "" ""))))
13421 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*c*l")
13422 (plus:P (match_dup 1)
13424 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13425 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13429 if (which_alternative != 0)
13431 else if (get_attr_length (insn) == 4)
13432 return \"bdz %l0\";
13434 return \"bdnz $+8\;b %l0\";
13436 [(set_attr "type" "branch")
13437 (set_attr "length" "*,12,16,16")])
13439 ;; Similar but use EQ
13441 (define_insn "*ctr<mode>_internal5"
13443 (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13445 (label_ref (match_operand 0 "" ""))
13447 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*c*l")
13448 (plus:P (match_dup 1)
13450 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13451 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13455 if (which_alternative != 0)
13457 else if (get_attr_length (insn) == 4)
13458 return \"bdz %l0\";
13460 return \"bdnz $+8\;b %l0\";
13462 [(set_attr "type" "branch")
13463 (set_attr "length" "*,12,16,16")])
13465 (define_insn "*ctr<mode>_internal6"
13467 (if_then_else (eq (match_operand:P 1 "register_operand" "c,*r,*r,*r")
13470 (label_ref (match_operand 0 "" ""))))
13471 (set (match_operand:P 2 "nonimmediate_operand" "=1,*r,m,*c*l")
13472 (plus:P (match_dup 1)
13474 (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13475 (clobber (match_scratch:P 4 "=X,X,&r,r"))]
13479 if (which_alternative != 0)
13481 else if (get_attr_length (insn) == 4)
13482 return \"bdnz %l0\";
13484 return \"bdz $+8\;b %l0\";
13486 [(set_attr "type" "branch")
13487 (set_attr "length" "*,12,16,16")])
13489 ;; Now the splitters if we could not allocate the CTR register
13493 (if_then_else (match_operator 2 "comparison_operator"
13494 [(match_operand:P 1 "gpc_reg_operand" "")
13496 (match_operand 5 "" "")
13497 (match_operand 6 "" "")))
13498 (set (match_operand:P 0 "gpc_reg_operand" "")
13499 (plus:P (match_dup 1) (const_int -1)))
13500 (clobber (match_scratch:CC 3 ""))
13501 (clobber (match_scratch:P 4 ""))]
13503 [(parallel [(set (match_dup 3)
13504 (compare:CC (plus:P (match_dup 1)
13508 (plus:P (match_dup 1)
13510 (set (pc) (if_then_else (match_dup 7)
13514 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
13515 operands[3], const0_rtx); }")
13519 (if_then_else (match_operator 2 "comparison_operator"
13520 [(match_operand:P 1 "gpc_reg_operand" "")
13522 (match_operand 5 "" "")
13523 (match_operand 6 "" "")))
13524 (set (match_operand:P 0 "nonimmediate_operand" "")
13525 (plus:P (match_dup 1) (const_int -1)))
13526 (clobber (match_scratch:CC 3 ""))
13527 (clobber (match_scratch:P 4 ""))]
13528 "reload_completed && ! gpc_reg_operand (operands[0], SImode)"
13529 [(parallel [(set (match_dup 3)
13530 (compare:CC (plus:P (match_dup 1)
13534 (plus:P (match_dup 1)
13538 (set (pc) (if_then_else (match_dup 7)
13542 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
13543 operands[3], const0_rtx); }")
13545 (define_insn "trap"
13546 [(trap_if (const_int 1) (const_int 0))]
13549 [(set_attr "type" "trap")])
13551 (define_expand "ctrap<mode>4"
13552 [(trap_if (match_operator 0 "ordered_comparison_operator"
13553 [(match_operand:GPR 1 "register_operand")
13554 (match_operand:GPR 2 "reg_or_short_operand")])
13555 (match_operand 3 "zero_constant" ""))]
13560 [(trap_if (match_operator 0 "ordered_comparison_operator"
13561 [(match_operand:GPR 1 "register_operand" "r")
13562 (match_operand:GPR 2 "reg_or_short_operand" "rI")])
13565 "t<wd>%V0%I2 %1,%2"
13566 [(set_attr "type" "trap")])
13568 ;; Insns related to generating the function prologue and epilogue.
13570 (define_expand "prologue"
13571 [(use (const_int 0))]
13574 rs6000_emit_prologue ();
13575 if (!TARGET_SCHED_PROLOG)
13576 emit_insn (gen_blockage ());
13580 (define_insn "*movesi_from_cr_one"
13581 [(match_parallel 0 "mfcr_operation"
13582 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
13583 (unspec:SI [(match_operand:CC 2 "cc_reg_operand" "y")
13584 (match_operand 3 "immediate_operand" "n")]
13585 UNSPEC_MOVESI_FROM_CR))])]
13591 for (i = 0; i < XVECLEN (operands[0], 0); i++)
13593 mask = INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
13594 operands[4] = GEN_INT (mask);
13595 output_asm_insn (\"mfcr %1,%4\", operands);
13599 [(set_attr "type" "mfcrf")])
13601 (define_insn "movesi_from_cr"
13602 [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13603 (unspec:SI [(reg:CC CR0_REGNO) (reg:CC CR1_REGNO)
13604 (reg:CC CR2_REGNO) (reg:CC CR3_REGNO)
13605 (reg:CC CR4_REGNO) (reg:CC CR5_REGNO)
13606 (reg:CC CR6_REGNO) (reg:CC CR7_REGNO)]
13607 UNSPEC_MOVESI_FROM_CR))]
13610 [(set_attr "type" "mfcr")])
13612 (define_insn "*crsave"
13613 [(match_parallel 0 "crsave_operation"
13614 [(set (match_operand:SI 1 "memory_operand" "=m")
13615 (match_operand:SI 2 "gpc_reg_operand" "r"))])]
13618 [(set_attr "type" "store")])
13620 (define_insn "*stmw"
13621 [(match_parallel 0 "stmw_operation"
13622 [(set (match_operand:SI 1 "memory_operand" "=m")
13623 (match_operand:SI 2 "gpc_reg_operand" "r"))])]
13626 [(set_attr "type" "store")
13627 (set_attr "update" "yes")
13628 (set_attr "indexed" "yes")])
13630 ; The following comment applies to:
13634 ; return_and_restore_gpregs*
13635 ; return_and_restore_fpregs*
13636 ; return_and_restore_fpregs_aix*
13638 ; The out-of-line save / restore functions expects one input argument.
13639 ; Since those are not standard call_insn's, we must avoid using
13640 ; MATCH_OPERAND for that argument. That way the register rename
13641 ; optimization will not try to rename this register.
13642 ; Each pattern is repeated for each possible register number used in
13643 ; various ABIs (r11, r1, and for some functions r12)
13645 (define_insn "*save_gpregs_<mode>_r11"
13646 [(match_parallel 0 "any_parallel_operand"
13647 [(clobber (reg:P 65))
13648 (use (match_operand:P 1 "symbol_ref_operand" "s"))
13650 (set (match_operand:P 2 "memory_operand" "=m")
13651 (match_operand:P 3 "gpc_reg_operand" "r"))])]
13654 [(set_attr "type" "branch")
13655 (set_attr "length" "4")])
13657 (define_insn "*save_gpregs_<mode>_r12"
13658 [(match_parallel 0 "any_parallel_operand"
13659 [(clobber (reg:P 65))
13660 (use (match_operand:P 1 "symbol_ref_operand" "s"))
13662 (set (match_operand:P 2 "memory_operand" "=m")
13663 (match_operand:P 3 "gpc_reg_operand" "r"))])]
13666 [(set_attr "type" "branch")
13667 (set_attr "length" "4")])
13669 (define_insn "*save_gpregs_<mode>_r1"
13670 [(match_parallel 0 "any_parallel_operand"
13671 [(clobber (reg:P 65))
13672 (use (match_operand:P 1 "symbol_ref_operand" "s"))
13674 (set (match_operand:P 2 "memory_operand" "=m")
13675 (match_operand:P 3 "gpc_reg_operand" "r"))])]
13678 [(set_attr "type" "branch")
13679 (set_attr "length" "4")])
13681 (define_insn "*save_fpregs_<mode>_r11"
13682 [(match_parallel 0 "any_parallel_operand"
13683 [(clobber (reg:P 65))
13684 (use (match_operand:P 1 "symbol_ref_operand" "s"))
13686 (set (match_operand:DF 2 "memory_operand" "=m")
13687 (match_operand:DF 3 "gpc_reg_operand" "d"))])]
13690 [(set_attr "type" "branch")
13691 (set_attr "length" "4")])
13693 (define_insn "*save_fpregs_<mode>_r12"
13694 [(match_parallel 0 "any_parallel_operand"
13695 [(clobber (reg:P 65))
13696 (use (match_operand:P 1 "symbol_ref_operand" "s"))
13698 (set (match_operand:DF 2 "memory_operand" "=m")
13699 (match_operand:DF 3 "gpc_reg_operand" "d"))])]
13702 [(set_attr "type" "branch")
13703 (set_attr "length" "4")])
13705 (define_insn "*save_fpregs_<mode>_r1"
13706 [(match_parallel 0 "any_parallel_operand"
13707 [(clobber (reg:P 65))
13708 (use (match_operand:P 1 "symbol_ref_operand" "s"))
13710 (set (match_operand:DF 2 "memory_operand" "=m")
13711 (match_operand:DF 3 "gpc_reg_operand" "d"))])]
13714 [(set_attr "type" "branch")
13715 (set_attr "length" "4")])
13717 ; This is to explain that changes to the stack pointer should
13718 ; not be moved over loads from or stores to stack memory.
13719 (define_insn "stack_tie"
13720 [(match_parallel 0 "tie_operand"
13721 [(set (mem:BLK (reg 1)) (const_int 0))])]
13724 [(set_attr "length" "0")])
13726 (define_expand "epilogue"
13727 [(use (const_int 0))]
13730 if (!TARGET_SCHED_PROLOG)
13731 emit_insn (gen_blockage ());
13732 rs6000_emit_epilogue (FALSE);
13736 ; On some processors, doing the mtcrf one CC register at a time is
13737 ; faster (like on the 604e). On others, doing them all at once is
13738 ; faster; for instance, on the 601 and 750.
13740 (define_expand "movsi_to_cr_one"
13741 [(set (match_operand:CC 0 "cc_reg_operand" "")
13742 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "")
13743 (match_dup 2)] UNSPEC_MOVESI_TO_CR))]
13745 "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
13747 (define_insn "*movsi_to_cr"
13748 [(match_parallel 0 "mtcrf_operation"
13749 [(set (match_operand:CC 1 "cc_reg_operand" "=y")
13750 (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
13751 (match_operand 3 "immediate_operand" "n")]
13752 UNSPEC_MOVESI_TO_CR))])]
13758 for (i = 0; i < XVECLEN (operands[0], 0); i++)
13759 mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
13760 operands[4] = GEN_INT (mask);
13761 return \"mtcrf %4,%2\";
13763 [(set_attr "type" "mtcr")])
13765 (define_insn "*mtcrfsi"
13766 [(set (match_operand:CC 0 "cc_reg_operand" "=y")
13767 (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
13768 (match_operand 2 "immediate_operand" "n")]
13769 UNSPEC_MOVESI_TO_CR))]
13770 "GET_CODE (operands[0]) == REG
13771 && CR_REGNO_P (REGNO (operands[0]))
13772 && GET_CODE (operands[2]) == CONST_INT
13773 && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
13775 [(set_attr "type" "mtcr")])
13777 ; The load-multiple instructions have similar properties.
13778 ; Note that "load_multiple" is a name known to the machine-independent
13779 ; code that actually corresponds to the PowerPC load-string.
13781 (define_insn "*lmw"
13782 [(match_parallel 0 "lmw_operation"
13783 [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
13784 (match_operand:SI 2 "memory_operand" "m"))])]
13787 [(set_attr "type" "load")
13788 (set_attr "update" "yes")
13789 (set_attr "indexed" "yes")
13790 (set_attr "cell_micro" "always")])
13792 (define_insn "*return_internal_<mode>"
13794 (use (match_operand:P 0 "register_operand" "lc"))]
13797 [(set_attr "type" "jmpreg")])
13799 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
13800 ; stuff was in GCC. Oh, and "any_parallel_operand" is a bit flexible...
13802 ; The following comment applies to:
13806 ; return_and_restore_gpregs*
13807 ; return_and_restore_fpregs*
13808 ; return_and_restore_fpregs_aix*
13810 ; The out-of-line save / restore functions expects one input argument.
13811 ; Since those are not standard call_insn's, we must avoid using
13812 ; MATCH_OPERAND for that argument. That way the register rename
13813 ; optimization will not try to rename this register.
13814 ; Each pattern is repeated for each possible register number used in
13815 ; various ABIs (r11, r1, and for some functions r12)
13817 (define_insn "*restore_gpregs_<mode>_r11"
13818 [(match_parallel 0 "any_parallel_operand"
13819 [(clobber (match_operand:P 1 "register_operand" "=l"))
13820 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13822 (set (match_operand:P 3 "gpc_reg_operand" "=r")
13823 (match_operand:P 4 "memory_operand" "m"))])]
13826 [(set_attr "type" "branch")
13827 (set_attr "length" "4")])
13829 (define_insn "*restore_gpregs_<mode>_r12"
13830 [(match_parallel 0 "any_parallel_operand"
13831 [(clobber (match_operand:P 1 "register_operand" "=l"))
13832 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13834 (set (match_operand:P 3 "gpc_reg_operand" "=r")
13835 (match_operand:P 4 "memory_operand" "m"))])]
13838 [(set_attr "type" "branch")
13839 (set_attr "length" "4")])
13841 (define_insn "*restore_gpregs_<mode>_r1"
13842 [(match_parallel 0 "any_parallel_operand"
13843 [(clobber (match_operand:P 1 "register_operand" "=l"))
13844 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13846 (set (match_operand:P 3 "gpc_reg_operand" "=r")
13847 (match_operand:P 4 "memory_operand" "m"))])]
13850 [(set_attr "type" "branch")
13851 (set_attr "length" "4")])
13853 (define_insn "*return_and_restore_gpregs_<mode>_r11"
13854 [(match_parallel 0 "any_parallel_operand"
13856 (clobber (match_operand:P 1 "register_operand" "=l"))
13857 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13859 (set (match_operand:P 3 "gpc_reg_operand" "=r")
13860 (match_operand:P 4 "memory_operand" "m"))])]
13863 [(set_attr "type" "branch")
13864 (set_attr "length" "4")])
13866 (define_insn "*return_and_restore_gpregs_<mode>_r12"
13867 [(match_parallel 0 "any_parallel_operand"
13869 (clobber (match_operand:P 1 "register_operand" "=l"))
13870 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13872 (set (match_operand:P 3 "gpc_reg_operand" "=r")
13873 (match_operand:P 4 "memory_operand" "m"))])]
13876 [(set_attr "type" "branch")
13877 (set_attr "length" "4")])
13879 (define_insn "*return_and_restore_gpregs_<mode>_r1"
13880 [(match_parallel 0 "any_parallel_operand"
13882 (clobber (match_operand:P 1 "register_operand" "=l"))
13883 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13885 (set (match_operand:P 3 "gpc_reg_operand" "=r")
13886 (match_operand:P 4 "memory_operand" "m"))])]
13889 [(set_attr "type" "branch")
13890 (set_attr "length" "4")])
13892 (define_insn "*return_and_restore_fpregs_<mode>_r11"
13893 [(match_parallel 0 "any_parallel_operand"
13895 (clobber (match_operand:P 1 "register_operand" "=l"))
13896 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13898 (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13899 (match_operand:DF 4 "memory_operand" "m"))])]
13902 [(set_attr "type" "branch")
13903 (set_attr "length" "4")])
13905 (define_insn "*return_and_restore_fpregs_<mode>_r12"
13906 [(match_parallel 0 "any_parallel_operand"
13908 (clobber (match_operand:P 1 "register_operand" "=l"))
13909 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13911 (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13912 (match_operand:DF 4 "memory_operand" "m"))])]
13915 [(set_attr "type" "branch")
13916 (set_attr "length" "4")])
13918 (define_insn "*return_and_restore_fpregs_<mode>_r1"
13919 [(match_parallel 0 "any_parallel_operand"
13921 (clobber (match_operand:P 1 "register_operand" "=l"))
13922 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13924 (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13925 (match_operand:DF 4 "memory_operand" "m"))])]
13928 [(set_attr "type" "branch")
13929 (set_attr "length" "4")])
13931 (define_insn "*return_and_restore_fpregs_aix_<mode>_r11"
13932 [(match_parallel 0 "any_parallel_operand"
13934 (use (match_operand:P 1 "register_operand" "l"))
13935 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13937 (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13938 (match_operand:DF 4 "memory_operand" "m"))])]
13941 [(set_attr "type" "branch")
13942 (set_attr "length" "4")])
13944 (define_insn "*return_and_restore_fpregs_aix_<mode>_r1"
13945 [(match_parallel 0 "any_parallel_operand"
13947 (use (match_operand:P 1 "register_operand" "l"))
13948 (use (match_operand:P 2 "symbol_ref_operand" "s"))
13950 (set (match_operand:DF 3 "gpc_reg_operand" "=d")
13951 (match_operand:DF 4 "memory_operand" "m"))])]
13954 [(set_attr "type" "branch")
13955 (set_attr "length" "4")])
13957 ; This is used in compiling the unwind routines.
13958 (define_expand "eh_return"
13959 [(use (match_operand 0 "general_operand" ""))]
13964 emit_insn (gen_eh_set_lr_si (operands[0]));
13966 emit_insn (gen_eh_set_lr_di (operands[0]));
13970 ; We can't expand this before we know where the link register is stored.
13971 (define_insn "eh_set_lr_<mode>"
13972 [(unspec_volatile [(match_operand:P 0 "register_operand" "r")]
13974 (clobber (match_scratch:P 1 "=&b"))]
13979 [(unspec_volatile [(match_operand 0 "register_operand" "")] UNSPECV_EH_RR)
13980 (clobber (match_scratch 1 ""))]
13985 rs6000_emit_eh_reg_restore (operands[0], operands[1]);
13989 (define_insn "prefetch"
13990 [(prefetch (match_operand 0 "indexed_or_indirect_address" "a")
13991 (match_operand:SI 1 "const_int_operand" "n")
13992 (match_operand:SI 2 "const_int_operand" "n"))]
13996 if (GET_CODE (operands[0]) == REG)
13997 return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
13998 return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
14000 [(set_attr "type" "load")])
14002 (define_insn "bpermd_<mode>"
14003 [(set (match_operand:P 0 "gpc_reg_operand" "=r")
14004 (unspec:P [(match_operand:P 1 "gpc_reg_operand" "r")
14005 (match_operand:P 2 "gpc_reg_operand" "r")] UNSPEC_BPERM))]
14008 [(set_attr "type" "popcnt")])
14011 ;; Builtin fma support. Handle
14012 ;; Note that the conditions for expansion are in the FMA_F iterator.
14014 (define_expand "fma<mode>4"
14015 [(set (match_operand:FMA_F 0 "register_operand" "")
14017 (match_operand:FMA_F 1 "register_operand" "")
14018 (match_operand:FMA_F 2 "register_operand" "")
14019 (match_operand:FMA_F 3 "register_operand" "")))]
14023 (define_insn "*fma<mode>4_fpr"
14024 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
14026 (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>,<Fv>")
14027 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
14028 (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>")))]
14029 "TARGET_<MODE>_FPR"
14031 fmadd<Ftrad> %0,%1,%2,%3
14032 xsmadda<Fvsx> %x0,%x1,%x2
14033 xsmaddm<Fvsx> %x0,%x1,%x3"
14034 [(set_attr "type" "fp")
14035 (set_attr "fp_type" "fp_maddsub_<Fs>")])
14037 ; Altivec only has fma and nfms.
14038 (define_expand "fms<mode>4"
14039 [(set (match_operand:FMA_F 0 "register_operand" "")
14041 (match_operand:FMA_F 1 "register_operand" "")
14042 (match_operand:FMA_F 2 "register_operand" "")
14043 (neg:FMA_F (match_operand:FMA_F 3 "register_operand" ""))))]
14044 "!VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
14047 (define_insn "*fms<mode>4_fpr"
14048 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
14050 (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>,<Fv>")
14051 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
14052 (neg:SFDF (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>"))))]
14053 "TARGET_<MODE>_FPR"
14055 fmsub<Ftrad> %0,%1,%2,%3
14056 xsmsuba<Fvsx> %x0,%x1,%x2
14057 xsmsubm<Fvsx> %x0,%x1,%x3"
14058 [(set_attr "type" "fp")
14059 (set_attr "fp_type" "fp_maddsub_<Fs>")])
14061 ;; If signed zeros are ignored, -(a * b - c) = -a * b + c.
14062 (define_expand "fnma<mode>4"
14063 [(set (match_operand:FMA_F 0 "register_operand" "")
14066 (match_operand:FMA_F 1 "register_operand" "")
14067 (match_operand:FMA_F 2 "register_operand" "")
14068 (neg:FMA_F (match_operand:FMA_F 3 "register_operand" "")))))]
14069 "!HONOR_SIGNED_ZEROS (<MODE>mode)"
14072 ;; If signed zeros are ignored, -(a * b + c) = -a * b - c.
14073 (define_expand "fnms<mode>4"
14074 [(set (match_operand:FMA_F 0 "register_operand" "")
14077 (match_operand:FMA_F 1 "register_operand" "")
14078 (match_operand:FMA_F 2 "register_operand" "")
14079 (match_operand:FMA_F 3 "register_operand" ""))))]
14080 "!HONOR_SIGNED_ZEROS (<MODE>mode) && !VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
14083 ; Not an official optab name, but used from builtins.
14084 (define_expand "nfma<mode>4"
14085 [(set (match_operand:FMA_F 0 "register_operand" "")
14088 (match_operand:FMA_F 1 "register_operand" "")
14089 (match_operand:FMA_F 2 "register_operand" "")
14090 (match_operand:FMA_F 3 "register_operand" ""))))]
14091 "!VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
14094 (define_insn "*nfma<mode>4_fpr"
14095 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
14098 (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>,<Fv>")
14099 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
14100 (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>"))))]
14101 "TARGET_<MODE>_FPR"
14103 fnmadd<Ftrad> %0,%1,%2,%3
14104 xsnmadda<Fvsx> %x0,%x1,%x2
14105 xsnmaddm<Fvsx> %x0,%x1,%x3"
14106 [(set_attr "type" "fp")
14107 (set_attr "fp_type" "fp_maddsub_<Fs>")])
14109 ; Not an official optab name, but used from builtins.
14110 (define_expand "nfms<mode>4"
14111 [(set (match_operand:FMA_F 0 "register_operand" "")
14114 (match_operand:FMA_F 1 "register_operand" "")
14115 (match_operand:FMA_F 2 "register_operand" "")
14116 (neg:FMA_F (match_operand:FMA_F 3 "register_operand" "")))))]
14120 (define_insn "*nfmssf4_fpr"
14121 [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
14124 (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>,<Fv>")
14125 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
14127 (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>")))))]
14128 "TARGET_<MODE>_FPR"
14130 fnmsub<Ftrad> %0,%1,%2,%3
14131 xsnmsuba<Fvsx> %x0,%x1,%x2
14132 xsnmsubm<Fvsx> %x0,%x1,%x3"
14133 [(set_attr "type" "fp")
14134 (set_attr "fp_type" "fp_maddsub_<Fs>")])
14137 (define_expand "rs6000_get_timebase"
14138 [(use (match_operand:DI 0 "gpc_reg_operand" ""))]
14141 if (TARGET_POWERPC64)
14142 emit_insn (gen_rs6000_mftb_di (operands[0]));
14144 emit_insn (gen_rs6000_get_timebase_ppc32 (operands[0]));
14148 (define_insn "rs6000_get_timebase_ppc32"
14149 [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
14150 (unspec_volatile:DI [(const_int 0)] UNSPECV_MFTB))
14151 (clobber (match_scratch:SI 1 "=r"))
14152 (clobber (match_scratch:CC 2 "=y"))]
14153 "!TARGET_POWERPC64"
14155 if (WORDS_BIG_ENDIAN)
14158 return "mfspr %0,269\;"
14166 return "mftbu %0\;"
14175 return "mfspr %L0,269\;"
14183 return "mftbu %L0\;"
14190 [(set_attr "length" "20")])
14192 (define_insn "rs6000_mftb_<mode>"
14193 [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
14194 (unspec_volatile:GPR [(const_int 0)] UNSPECV_MFTB))]
14198 return "mfspr %0,268";
14204 (define_insn "rs6000_mffs"
14205 [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
14206 (unspec_volatile:DF [(const_int 0)] UNSPECV_MFFS))]
14207 "TARGET_HARD_FLOAT && TARGET_FPRS"
14210 (define_insn "rs6000_mtfsf"
14211 [(unspec_volatile [(match_operand:SI 0 "const_int_operand" "i")
14212 (match_operand:DF 1 "gpc_reg_operand" "d")]
14214 "TARGET_HARD_FLOAT && TARGET_FPRS"
14218 ;; Power8 fusion support for fusing an addis instruction with a D-form load of
14219 ;; a GPR. The addis instruction must be adjacent to the load, and use the same
14220 ;; register that is being loaded. The fused ops must be physically adjacent.
14222 ;; Find cases where the addis that feeds into a load instruction is either used
14223 ;; once or is the same as the target register, and replace it with the fusion
14227 [(set (match_operand:P 0 "base_reg_operand" "")
14228 (match_operand:P 1 "fusion_gpr_addis" ""))
14229 (set (match_operand:INT1 2 "base_reg_operand" "")
14230 (match_operand:INT1 3 "fusion_gpr_mem_load" ""))]
14232 && fusion_gpr_load_p (operands[0], operands[1], operands[2],
14236 expand_fusion_gpr_load (operands);
14240 ;; Fusion insn, created by the define_peephole2 above (and eventually by
14243 (define_insn "fusion_gpr_load_<mode>"
14244 [(set (match_operand:INT1 0 "base_reg_operand" "=&b")
14245 (unspec:INT1 [(match_operand:INT1 1 "fusion_gpr_mem_combo" "")]
14246 UNSPEC_FUSION_GPR))]
14249 return emit_fusion_gpr_load (operands[0], operands[1]);
14251 [(set_attr "type" "load")
14252 (set_attr "length" "8")])
14255 ;; Miscellaneous ISA 2.06 (power7) instructions
14256 (define_insn "addg6s"
14257 [(set (match_operand:SI 0 "register_operand" "=r")
14258 (unspec:SI [(match_operand:SI 1 "register_operand" "r")
14259 (match_operand:SI 2 "register_operand" "r")]
14263 [(set_attr "type" "integer")
14264 (set_attr "length" "4")])
14266 (define_insn "cdtbcd"
14267 [(set (match_operand:SI 0 "register_operand" "=r")
14268 (unspec:SI [(match_operand:SI 1 "register_operand" "r")]
14272 [(set_attr "type" "integer")
14273 (set_attr "length" "4")])
14275 (define_insn "cbcdtd"
14276 [(set (match_operand:SI 0 "register_operand" "=r")
14277 (unspec:SI [(match_operand:SI 1 "register_operand" "r")]
14281 [(set_attr "type" "integer")
14282 (set_attr "length" "4")])
14284 (define_int_iterator UNSPEC_DIV_EXTEND [UNSPEC_DIVE
14289 (define_int_attr div_extend [(UNSPEC_DIVE "e")
14290 (UNSPEC_DIVEO "eo")
14291 (UNSPEC_DIVEU "eu")
14292 (UNSPEC_DIVEUO "euo")])
14294 (define_insn "div<div_extend>_<mode>"
14295 [(set (match_operand:GPR 0 "register_operand" "=r")
14296 (unspec:GPR [(match_operand:GPR 1 "register_operand" "r")
14297 (match_operand:GPR 2 "register_operand" "r")]
14298 UNSPEC_DIV_EXTEND))]
14300 "div<wd><div_extend> %0,%1,%2"
14301 [(set_attr "type" "div")
14302 (set_attr "size" "<bits>")])
14305 ;; Pack/unpack 128-bit floating point types that take 2 scalar registers
14307 ; Type of the 64-bit part when packing/unpacking 128-bit floating point types
14308 (define_mode_attr FP128_64 [(TF "DF") (TD "DI")])
14310 (define_expand "unpack<mode>"
14311 [(set (match_operand:<FP128_64> 0 "nonimmediate_operand" "")
14313 [(match_operand:FMOVE128 1 "register_operand" "")
14314 (match_operand:QI 2 "const_0_to_1_operand" "")]
14315 UNSPEC_UNPACK_128BIT))]
14319 (define_insn_and_split "unpack<mode>_dm"
14320 [(set (match_operand:<FP128_64> 0 "nonimmediate_operand" "=d,m,d,r,m")
14322 [(match_operand:FMOVE128 1 "register_operand" "d,d,r,d,r")
14323 (match_operand:QI 2 "const_0_to_1_operand" "i,i,i,i,i")]
14324 UNSPEC_UNPACK_128BIT))]
14325 "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
14327 "&& reload_completed"
14328 [(set (match_dup 0) (match_dup 3))]
14330 unsigned fp_regno = REGNO (operands[1]) + UINTVAL (operands[2]);
14332 if (REG_P (operands[0]) && REGNO (operands[0]) == fp_regno)
14334 emit_note (NOTE_INSN_DELETED);
14338 operands[3] = gen_rtx_REG (<FP128_64>mode, fp_regno);
14340 [(set_attr "type" "fp,fpstore,mffgpr,mftgpr,store")
14341 (set_attr "length" "4")])
14343 (define_insn_and_split "unpack<mode>_nodm"
14344 [(set (match_operand:<FP128_64> 0 "nonimmediate_operand" "=d,m")
14346 [(match_operand:FMOVE128 1 "register_operand" "d,d")
14347 (match_operand:QI 2 "const_0_to_1_operand" "i,i")]
14348 UNSPEC_UNPACK_128BIT))]
14349 "!TARGET_POWERPC64 || !TARGET_DIRECT_MOVE"
14351 "&& reload_completed"
14352 [(set (match_dup 0) (match_dup 3))]
14354 unsigned fp_regno = REGNO (operands[1]) + UINTVAL (operands[2]);
14356 if (REG_P (operands[0]) && REGNO (operands[0]) == fp_regno)
14358 emit_note (NOTE_INSN_DELETED);
14362 operands[3] = gen_rtx_REG (<FP128_64>mode, fp_regno);
14364 [(set_attr "type" "fp,fpstore")
14365 (set_attr "length" "4")])
14367 (define_insn_and_split "pack<mode>"
14368 [(set (match_operand:FMOVE128 0 "register_operand" "=d,&d")
14370 [(match_operand:<FP128_64> 1 "register_operand" "0,d")
14371 (match_operand:<FP128_64> 2 "register_operand" "d,d")]
14372 UNSPEC_PACK_128BIT))]
14377 "&& reload_completed && REGNO (operands[0]) != REGNO (operands[1])"
14378 [(set (match_dup 3) (match_dup 1))
14379 (set (match_dup 4) (match_dup 2))]
14381 unsigned dest_hi = REGNO (operands[0]);
14382 unsigned dest_lo = dest_hi + 1;
14384 gcc_assert (!IN_RANGE (REGNO (operands[1]), dest_hi, dest_lo));
14385 gcc_assert (!IN_RANGE (REGNO (operands[2]), dest_hi, dest_lo));
14387 operands[3] = gen_rtx_REG (<FP128_64>mode, dest_hi);
14388 operands[4] = gen_rtx_REG (<FP128_64>mode, dest_lo);
14390 [(set_attr "type" "fp,fp")
14391 (set_attr "length" "4,8")])
14393 (define_insn "unpackv1ti"
14394 [(set (match_operand:DI 0 "register_operand" "=d,d")
14395 (unspec:DI [(match_operand:V1TI 1 "register_operand" "0,wa")
14396 (match_operand:QI 2 "const_0_to_1_operand" "O,i")]
14397 UNSPEC_UNPACK_128BIT))]
14400 if (REGNO (operands[0]) == REGNO (operands[1]) && INTVAL (operands[2]) == 0)
14401 return ASM_COMMENT_START " xxpermdi to same register";
14403 operands[3] = GEN_INT (INTVAL (operands[2]) == 0 ? 0 : 3);
14404 return "xxpermdi %x0,%x1,%x1,%3";
14406 [(set_attr "type" "vecperm")
14407 (set_attr "length" "4")])
14409 (define_insn "packv1ti"
14410 [(set (match_operand:V1TI 0 "register_operand" "=wa")
14412 [(match_operand:DI 1 "register_operand" "d")
14413 (match_operand:DI 2 "register_operand" "d")]
14414 UNSPEC_PACK_128BIT))]
14416 "xxpermdi %x0,%x1,%x2,0"
14417 [(set_attr "type" "vecperm")
14418 (set_attr "length" "4")])
14422 (include "sync.md")
14423 (include "vector.md")
14425 (include "altivec.md")
14428 (include "paired.md")
14429 (include "crypto.md")