1 ;; GCC machine description for IA-32 and x86-64.
2 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 ;; Free Software Foundation, Inc.
5 ;; Mostly by William Schelter.
6 ;; x86_64 support added by Jan Hubicka
8 ;; This file is part of GCC.
10 ;; GCC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; GCC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING3. If not see
22 ;; <http://www.gnu.org/licenses/>. */
24 ;; The original PO technology requires these to be ordered by speed,
25 ;; so that assigner will pick the fastest.
27 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
29 ;; The special asm out single letter directives following a '%' are:
30 ;; L,W,B,Q,S,T -- print the opcode suffix for specified size of operand.
31 ;; C -- print opcode suffix for set/cmov insn.
32 ;; c -- like C, but print reversed condition
33 ;; F,f -- likewise, but for floating-point.
34 ;; O -- if HAVE_AS_IX86_CMOV_SUN_SYNTAX, expand to "w.", "l." or "q.",
36 ;; R -- print the prefix for register names.
37 ;; z -- print the opcode suffix for the size of the current operand.
38 ;; Z -- likewise, with special suffixes for x87 instructions.
39 ;; * -- print a star (in certain assembler syntax)
40 ;; A -- print an absolute memory reference.
41 ;; w -- print the operand as if it's a "word" (HImode) even if it isn't.
42 ;; s -- print a shift double count, followed by the assemblers argument
44 ;; b -- print the QImode name of the register for the indicated operand.
45 ;; %b0 would print %al if operands[0] is reg 0.
46 ;; w -- likewise, print the HImode name of the register.
47 ;; k -- likewise, print the SImode name of the register.
48 ;; q -- likewise, print the DImode name of the register.
49 ;; x -- likewise, print the V4SFmode name of the register.
50 ;; t -- likewise, print the V8SFmode name of the register.
51 ;; h -- print the QImode name for a "high" register, either ah, bh, ch or dh.
52 ;; y -- print "st(0)" instead of "st" as a register.
53 ;; d -- print duplicated register operand for AVX instruction.
54 ;; D -- print condition for SSE cmp instruction.
55 ;; P -- if PIC, print an @PLT suffix.
56 ;; X -- don't print any sort of PIC '@' suffix for a symbol.
57 ;; & -- print some in-use local-dynamic symbol name.
58 ;; H -- print a memory address offset by 8; used for sse high-parts
59 ;; Y -- print condition for XOP pcom* instruction.
60 ;; + -- print a branch hint as 'cs' or 'ds' prefix
61 ;; ; -- print a semicolon (after prefixes due to bug in older gas).
66 [; Relocation specifiers
77 (UNSPEC_MACHOPIC_OFFSET 10)
80 (UNSPEC_STACK_ALLOC 11)
82 (UNSPEC_SSE_PROLOGUE_SAVE 13)
86 (UNSPEC_SET_GOT_OFFSET 17)
87 (UNSPEC_MEMORY_BLOCKAGE 18)
92 (UNSPEC_TLS_LD_BASE 22)
95 ; Other random patterns
100 (UNSPEC_ADD_CARRY 34)
103 (UNSPEC_LD_MPIC 38) ; load_macho_picbase
104 (UNSPEC_TRUNC_NOOP 39)
106 ; For SSE/MMX support:
107 (UNSPEC_FIX_NOTRUNC 40)
124 (UNSPEC_MS_TO_SYSV_CALL 48)
126 ; Generic math support
128 (UNSPEC_IEEE_MIN 51) ; not commutative
129 (UNSPEC_IEEE_MAX 52) ; not commutative
144 (UNSPEC_FRNDINT_FLOOR 70)
145 (UNSPEC_FRNDINT_CEIL 71)
146 (UNSPEC_FRNDINT_TRUNC 72)
147 (UNSPEC_FRNDINT_MASK_PM 73)
148 (UNSPEC_FIST_FLOOR 74)
149 (UNSPEC_FIST_CEIL 75)
151 ; x87 Double output FP
152 (UNSPEC_SINCOS_COS 80)
153 (UNSPEC_SINCOS_SIN 81)
154 (UNSPEC_XTRACT_FRACT 84)
155 (UNSPEC_XTRACT_EXP 85)
156 (UNSPEC_FSCALE_FRACT 86)
157 (UNSPEC_FSCALE_EXP 87)
169 (UNSPEC_SP_TLS_SET 102)
170 (UNSPEC_SP_TLS_TEST 103)
180 (UNSPEC_INSERTQI 132)
185 (UNSPEC_INSERTPS 135)
187 (UNSPEC_MOVNTDQA 137)
189 (UNSPEC_PHMINPOSUW 139)
195 (UNSPEC_PCMPESTR 144)
196 (UNSPEC_PCMPISTR 145)
199 (UNSPEC_FMA4_INTRINSIC 150)
200 (UNSPEC_FMA4_FMADDSUB 151)
201 (UNSPEC_FMA4_FMSUBADD 152)
202 (UNSPEC_XOP_UNSIGNED_CMP 151)
203 (UNSPEC_XOP_TRUEFALSE 152)
204 (UNSPEC_XOP_PERMUTE 153)
209 (UNSPEC_AESENCLAST 160)
211 (UNSPEC_AESDECLAST 162)
213 (UNSPEC_AESKEYGENASSIST 164)
221 (UNSPEC_VPERMIL2 168)
222 (UNSPEC_VPERMIL2F128 169)
223 (UNSPEC_MASKLOAD 170)
224 (UNSPEC_MASKSTORE 171)
230 [(UNSPECV_BLOCKAGE 0)
231 (UNSPECV_STACK_PROBE 1)
243 (UNSPECV_PROLOGUE_USE 14)
245 (UNSPECV_VZEROALL 16)
246 (UNSPECV_VZEROUPPER 17)
250 (UNSPECV_VSWAPMOV 21)
251 (UNSPECV_LLWP_INTRINSIC 22)
252 (UNSPECV_SLWP_INTRINSIC 23)
253 (UNSPECV_LWPVAL_INTRINSIC 24)
254 (UNSPECV_LWPINS_INTRINSIC 25)
257 ;; Constants to represent pcomtrue/pcomfalse variants
267 ;; Constants used in the XOP pperm instruction
269 [(PPERM_SRC 0x00) /* copy source */
270 (PPERM_INVERT 0x20) /* invert source */
271 (PPERM_REVERSE 0x40) /* bit reverse source */
272 (PPERM_REV_INV 0x60) /* bit reverse & invert src */
273 (PPERM_ZERO 0x80) /* all 0's */
274 (PPERM_ONES 0xa0) /* all 1's */
275 (PPERM_SIGN 0xc0) /* propagate sign bit */
276 (PPERM_INV_SIGN 0xe0) /* invert & propagate sign */
277 (PPERM_SRC1 0x00) /* use first source byte */
278 (PPERM_SRC2 0x10) /* use second source byte */
281 ;; Registers by name.
334 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
337 ;; In C guard expressions, put expressions which may be compile-time
338 ;; constants first. This allows for better optimization. For
339 ;; example, write "TARGET_64BIT && reload_completed", not
340 ;; "reload_completed && TARGET_64BIT".
344 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,atom,
346 (const (symbol_ref "ix86_schedule")))
348 ;; A basic instruction type. Refinements due to arguments to be
349 ;; provided in other attributes.
352 alu,alu1,negnot,imov,imovx,lea,
353 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
354 icmp,test,ibr,setcc,icmov,
355 push,pop,call,callv,leave,
357 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
358 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
359 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
360 ssemuladd,sse4arg,lwp,
361 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
362 (const_string "other"))
364 ;; Main data type used by the insn
366 "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
367 (const_string "unknown"))
369 ;; The CPU unit operations uses.
370 (define_attr "unit" "integer,i387,sse,mmx,unknown"
371 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
372 (const_string "i387")
373 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
374 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
375 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
377 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
379 (eq_attr "type" "other")
380 (const_string "unknown")]
381 (const_string "integer")))
383 ;; The (bounding maximum) length of an instruction immediate.
384 (define_attr "length_immediate" ""
385 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
388 (eq_attr "unit" "i387,sse,mmx")
390 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
392 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
393 (eq_attr "type" "imov,test")
394 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
395 (eq_attr "type" "call")
396 (if_then_else (match_operand 0 "constant_call_address_operand" "")
399 (eq_attr "type" "callv")
400 (if_then_else (match_operand 1 "constant_call_address_operand" "")
403 ;; We don't know the size before shorten_branches. Expect
404 ;; the instruction to fit for better scheduling.
405 (eq_attr "type" "ibr")
408 (symbol_ref "/* Update immediate_length and other attributes! */
409 gcc_unreachable (),1")))
411 ;; The (bounding maximum) length of an instruction address.
412 (define_attr "length_address" ""
413 (cond [(eq_attr "type" "str,other,multi,fxch")
415 (and (eq_attr "type" "call")
416 (match_operand 0 "constant_call_address_operand" ""))
418 (and (eq_attr "type" "callv")
419 (match_operand 1 "constant_call_address_operand" ""))
422 (symbol_ref "ix86_attr_length_address_default (insn)")))
424 ;; Set when length prefix is used.
425 (define_attr "prefix_data16" ""
426 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
428 (eq_attr "mode" "HI")
430 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
435 ;; Set when string REP prefix is used.
436 (define_attr "prefix_rep" ""
437 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
439 (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
444 ;; Set when 0f opcode prefix is used.
445 (define_attr "prefix_0f" ""
447 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
448 (eq_attr "unit" "sse,mmx"))
452 ;; Set when REX opcode prefix is used.
453 (define_attr "prefix_rex" ""
454 (cond [(ne (symbol_ref "!TARGET_64BIT") (const_int 0))
456 (and (eq_attr "mode" "DI")
457 (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
458 (eq_attr "unit" "!mmx")))
460 (and (eq_attr "mode" "QI")
461 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
464 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
467 (and (eq_attr "type" "imovx")
468 (match_operand:QI 1 "ext_QIreg_operand" ""))
473 ;; There are also additional prefixes in 3DNOW, SSSE3.
474 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
475 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
476 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
477 (define_attr "prefix_extra" ""
478 (cond [(eq_attr "type" "ssemuladd,sse4arg")
480 (eq_attr "type" "sseiadd1,ssecvt1")
485 ;; Prefix used: original, VEX or maybe VEX.
486 (define_attr "prefix" "orig,vex,maybe_vex"
487 (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
489 (const_string "orig")))
491 ;; VEX W bit is used.
492 (define_attr "prefix_vex_w" "" (const_int 0))
494 ;; The length of VEX prefix
495 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
496 ;; 0f38/0f3a prefixes can't. In i386.md 0f3[8a] is
497 ;; still prefix_0f 1, with prefix_extra 1.
498 (define_attr "length_vex" ""
499 (if_then_else (and (eq_attr "prefix_0f" "1")
500 (eq_attr "prefix_extra" "0"))
501 (if_then_else (eq_attr "prefix_vex_w" "1")
502 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 1)")
503 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 0)"))
504 (if_then_else (eq_attr "prefix_vex_w" "1")
505 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 1)")
506 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 0)"))))
508 ;; Set when modrm byte is used.
509 (define_attr "modrm" ""
510 (cond [(eq_attr "type" "str,leave")
512 (eq_attr "unit" "i387")
514 (and (eq_attr "type" "incdec")
515 (and (eq (symbol_ref "TARGET_64BIT") (const_int 0))
516 (ior (match_operand:SI 1 "register_operand" "")
517 (match_operand:HI 1 "register_operand" ""))))
519 (and (eq_attr "type" "push")
520 (not (match_operand 1 "memory_operand" "")))
522 (and (eq_attr "type" "pop")
523 (not (match_operand 0 "memory_operand" "")))
525 (and (eq_attr "type" "imov")
526 (and (not (eq_attr "mode" "DI"))
527 (ior (and (match_operand 0 "register_operand" "")
528 (match_operand 1 "immediate_operand" ""))
529 (ior (and (match_operand 0 "ax_reg_operand" "")
530 (match_operand 1 "memory_displacement_only_operand" ""))
531 (and (match_operand 0 "memory_displacement_only_operand" "")
532 (match_operand 1 "ax_reg_operand" ""))))))
534 (and (eq_attr "type" "call")
535 (match_operand 0 "constant_call_address_operand" ""))
537 (and (eq_attr "type" "callv")
538 (match_operand 1 "constant_call_address_operand" ""))
540 (and (eq_attr "type" "alu,alu1,icmp,test")
541 (match_operand 0 "ax_reg_operand" ""))
542 (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
546 ;; The (bounding maximum) length of an instruction in bytes.
547 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
548 ;; Later we may want to split them and compute proper length as for
550 (define_attr "length" ""
551 (cond [(eq_attr "type" "other,multi,fistp,frndint")
553 (eq_attr "type" "fcmp")
555 (eq_attr "unit" "i387")
557 (plus (attr "prefix_data16")
558 (attr "length_address")))
559 (ior (eq_attr "prefix" "vex")
560 (and (eq_attr "prefix" "maybe_vex")
561 (ne (symbol_ref "TARGET_AVX") (const_int 0))))
562 (plus (attr "length_vex")
563 (plus (attr "length_immediate")
565 (attr "length_address"))))]
566 (plus (plus (attr "modrm")
567 (plus (attr "prefix_0f")
568 (plus (attr "prefix_rex")
569 (plus (attr "prefix_extra")
571 (plus (attr "prefix_rep")
572 (plus (attr "prefix_data16")
573 (plus (attr "length_immediate")
574 (attr "length_address")))))))
576 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
577 ;; `store' if there is a simple memory reference therein, or `unknown'
578 ;; if the instruction is complex.
580 (define_attr "memory" "none,load,store,both,unknown"
581 (cond [(eq_attr "type" "other,multi,str,lwp")
582 (const_string "unknown")
583 (eq_attr "type" "lea,fcmov,fpspc")
584 (const_string "none")
585 (eq_attr "type" "fistp,leave")
586 (const_string "both")
587 (eq_attr "type" "frndint")
588 (const_string "load")
589 (eq_attr "type" "push")
590 (if_then_else (match_operand 1 "memory_operand" "")
591 (const_string "both")
592 (const_string "store"))
593 (eq_attr "type" "pop")
594 (if_then_else (match_operand 0 "memory_operand" "")
595 (const_string "both")
596 (const_string "load"))
597 (eq_attr "type" "setcc")
598 (if_then_else (match_operand 0 "memory_operand" "")
599 (const_string "store")
600 (const_string "none"))
601 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
602 (if_then_else (ior (match_operand 0 "memory_operand" "")
603 (match_operand 1 "memory_operand" ""))
604 (const_string "load")
605 (const_string "none"))
606 (eq_attr "type" "ibr")
607 (if_then_else (match_operand 0 "memory_operand" "")
608 (const_string "load")
609 (const_string "none"))
610 (eq_attr "type" "call")
611 (if_then_else (match_operand 0 "constant_call_address_operand" "")
612 (const_string "none")
613 (const_string "load"))
614 (eq_attr "type" "callv")
615 (if_then_else (match_operand 1 "constant_call_address_operand" "")
616 (const_string "none")
617 (const_string "load"))
618 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
619 (match_operand 1 "memory_operand" ""))
620 (const_string "both")
621 (and (match_operand 0 "memory_operand" "")
622 (match_operand 1 "memory_operand" ""))
623 (const_string "both")
624 (match_operand 0 "memory_operand" "")
625 (const_string "store")
626 (match_operand 1 "memory_operand" "")
627 (const_string "load")
629 "!alu1,negnot,ishift1,
630 imov,imovx,icmp,test,bitmanip,
632 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
633 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
634 (match_operand 2 "memory_operand" ""))
635 (const_string "load")
636 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
637 (match_operand 3 "memory_operand" ""))
638 (const_string "load")
640 (const_string "none")))
642 ;; Indicates if an instruction has both an immediate and a displacement.
644 (define_attr "imm_disp" "false,true,unknown"
645 (cond [(eq_attr "type" "other,multi")
646 (const_string "unknown")
647 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
648 (and (match_operand 0 "memory_displacement_operand" "")
649 (match_operand 1 "immediate_operand" "")))
650 (const_string "true")
651 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
652 (and (match_operand 0 "memory_displacement_operand" "")
653 (match_operand 2 "immediate_operand" "")))
654 (const_string "true")
656 (const_string "false")))
658 ;; Indicates if an FP operation has an integer source.
660 (define_attr "fp_int_src" "false,true"
661 (const_string "false"))
663 ;; Defines rounding mode of an FP operation.
665 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
666 (const_string "any"))
668 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
669 (define_attr "use_carry" "0,1" (const_string "0"))
671 ;; Define attribute to indicate unaligned ssemov insns
672 (define_attr "movu" "0,1" (const_string "0"))
674 ;; Describe a user's asm statement.
675 (define_asm_attributes
676 [(set_attr "length" "128")
677 (set_attr "type" "multi")])
679 ;; All integer comparison codes.
680 (define_code_iterator int_cond [ne eq ge gt le lt geu gtu leu ltu])
682 ;; All floating-point comparison codes.
683 (define_code_iterator fp_cond [unordered ordered
684 uneq unge ungt unle unlt ltgt])
686 (define_code_iterator plusminus [plus minus])
688 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
690 ;; Base name for define_insn
691 (define_code_attr plusminus_insn
692 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
693 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
695 ;; Base name for insn mnemonic.
696 (define_code_attr plusminus_mnemonic
697 [(plus "add") (ss_plus "adds") (us_plus "addus")
698 (minus "sub") (ss_minus "subs") (us_minus "subus")])
699 (define_code_attr plusminus_carry_mnemonic
700 [(plus "adc") (minus "sbb")])
702 ;; Mark commutative operators as such in constraints.
703 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
704 (minus "") (ss_minus "") (us_minus "")])
706 ;; Mapping of signed max and min
707 (define_code_iterator smaxmin [smax smin])
709 ;; Mapping of unsigned max and min
710 (define_code_iterator umaxmin [umax umin])
712 ;; Mapping of signed/unsigned max and min
713 (define_code_iterator maxmin [smax smin umax umin])
715 ;; Base name for integer and FP insn mnemonic
716 (define_code_attr maxmin_int [(smax "maxs") (smin "mins")
717 (umax "maxu") (umin "minu")])
718 (define_code_attr maxmin_float [(smax "max") (smin "min")])
720 ;; Mapping of logic operators
721 (define_code_iterator any_logic [and ior xor])
722 (define_code_iterator any_or [ior xor])
724 ;; Base name for insn mnemonic.
725 (define_code_attr logic [(and "and") (ior "or") (xor "xor")])
727 ;; Mapping of shift-right operators
728 (define_code_iterator any_shiftrt [lshiftrt ashiftrt])
730 ;; Base name for define_insn
731 (define_code_attr shiftrt_insn [(lshiftrt "lshr") (ashiftrt "ashr")])
733 ;; Base name for insn mnemonic.
734 (define_code_attr shiftrt [(lshiftrt "shr") (ashiftrt "sar")])
736 ;; Mapping of rotate operators
737 (define_code_iterator any_rotate [rotate rotatert])
739 ;; Base name for define_insn
740 (define_code_attr rotate_insn [(rotate "rotl") (rotatert "rotr")])
742 ;; Base name for insn mnemonic.
743 (define_code_attr rotate [(rotate "rol") (rotatert "ror")])
745 ;; Mapping of abs neg operators
746 (define_code_iterator absneg [abs neg])
748 ;; Base name for x87 insn mnemonic.
749 (define_code_attr absneg_mnemonic [(abs "abs") (neg "chs")])
751 ;; Used in signed and unsigned widening multiplications.
752 (define_code_iterator any_extend [sign_extend zero_extend])
754 ;; Various insn prefixes for signed and unsigned operations.
755 (define_code_attr u [(sign_extend "") (zero_extend "u")
756 (div "") (udiv "u")])
757 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
759 ;; Used in signed and unsigned divisions.
760 (define_code_iterator any_div [div udiv])
762 ;; Instruction prefix for signed and unsigned operations.
763 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")
764 (div "i") (udiv "")])
766 ;; All single word integer modes.
767 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
769 ;; Single word integer modes without DImode.
770 (define_mode_iterator SWI124 [QI HI SI])
772 ;; Single word integer modes without QImode.
773 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
775 ;; Single word integer modes without QImode and HImode.
776 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
778 ;; All math-dependant single and double word integer modes.
779 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
780 (HI "TARGET_HIMODE_MATH")
781 SI DI (TI "TARGET_64BIT")])
783 ;; Math-dependant single word integer modes.
784 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
785 (HI "TARGET_HIMODE_MATH")
786 SI (DI "TARGET_64BIT")])
788 ;; Math-dependant single word integer modes without DImode.
789 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
790 (HI "TARGET_HIMODE_MATH")
793 ;; Math-dependant single word integer modes without QImode.
794 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
795 SI (DI "TARGET_64BIT")])
797 ;; Double word integer modes.
798 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
799 (TI "TARGET_64BIT")])
801 ;; Double word integer modes as mode attribute.
802 (define_mode_attr DWI [(SI "DI") (DI "TI")])
803 (define_mode_attr dwi [(SI "di") (DI "ti")])
805 ;; Half mode for double word integer modes.
806 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
807 (DI "TARGET_64BIT")])
809 ;; Instruction suffix for integer modes.
810 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
812 ;; Register class for integer modes.
813 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
815 ;; Immediate operand constraint for integer modes.
816 (define_mode_attr i [(QI "n") (HI "n") (SI "i") (DI "e")])
818 ;; General operand constraint for word modes.
819 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "g") (DI "rme")])
821 ;; Immediate operand constraint for double integer modes.
822 (define_mode_attr di [(SI "iF") (DI "e")])
824 ;; Immediate operand constraint for shifts.
825 (define_mode_attr S [(QI "I") (HI "I") (SI "I") (DI "J") (TI "O")])
827 ;; General operand predicate for integer modes.
828 (define_mode_attr general_operand
829 [(QI "general_operand")
830 (HI "general_operand")
831 (SI "general_operand")
832 (DI "x86_64_general_operand")
833 (TI "x86_64_general_operand")])
835 ;; General sign/zero extend operand predicate for integer modes.
836 (define_mode_attr general_szext_operand
837 [(QI "general_operand")
838 (HI "general_operand")
839 (SI "general_operand")
840 (DI "x86_64_szext_general_operand")])
842 ;; Operand predicate for shifts.
843 (define_mode_attr shift_operand
844 [(QI "nonimmediate_operand")
845 (HI "nonimmediate_operand")
846 (SI "nonimmediate_operand")
847 (DI "shiftdi_operand")
848 (TI "register_operand")])
850 ;; Operand predicate for shift argument.
851 (define_mode_attr shift_immediate_operand
852 [(QI "const_1_to_31_operand")
853 (HI "const_1_to_31_operand")
854 (SI "const_1_to_31_operand")
855 (DI "const_1_to_63_operand")])
857 ;; Input operand predicate for arithmetic left shifts.
858 (define_mode_attr ashl_input_operand
859 [(QI "nonimmediate_operand")
860 (HI "nonimmediate_operand")
861 (SI "nonimmediate_operand")
862 (DI "ashldi_input_operand")
863 (TI "reg_or_pm1_operand")])
865 ;; SSE and x87 SFmode and DFmode floating point modes
866 (define_mode_iterator MODEF [SF DF])
868 ;; All x87 floating point modes
869 (define_mode_iterator X87MODEF [SF DF XF])
871 ;; All integer modes handled by x87 fisttp operator.
872 (define_mode_iterator X87MODEI [HI SI DI])
874 ;; All integer modes handled by integer x87 operators.
875 (define_mode_iterator X87MODEI12 [HI SI])
877 ;; All integer modes handled by SSE cvtts?2si* operators.
878 (define_mode_iterator SSEMODEI24 [SI DI])
880 ;; SSE asm suffix for floating point modes
881 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
883 ;; SSE vector mode corresponding to a scalar mode
884 (define_mode_attr ssevecmode
885 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
887 ;; Instruction suffix for REX 64bit operators.
888 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
890 ;; This mode iterator allows :P to be used for patterns that operate on
891 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
892 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
894 ;; Scheduling descriptions
896 (include "pentium.md")
899 (include "athlon.md")
904 ;; Operand and operator predicates and constraints
906 (include "predicates.md")
907 (include "constraints.md")
910 ;; Compare and branch/compare and store instructions.
912 (define_expand "cbranch<mode>4"
913 [(set (reg:CC FLAGS_REG)
914 (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
915 (match_operand:SDWIM 2 "<general_operand>" "")))
916 (set (pc) (if_then_else
917 (match_operator 0 "comparison_operator"
918 [(reg:CC FLAGS_REG) (const_int 0)])
919 (label_ref (match_operand 3 "" ""))
923 if (MEM_P (operands[1]) && MEM_P (operands[2]))
924 operands[1] = force_reg (<MODE>mode, operands[1]);
925 ix86_compare_op0 = operands[1];
926 ix86_compare_op1 = operands[2];
927 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
931 (define_expand "cstore<mode>4"
932 [(set (reg:CC FLAGS_REG)
933 (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
934 (match_operand:SWIM 3 "<general_operand>" "")))
935 (set (match_operand:QI 0 "register_operand" "")
936 (match_operator 1 "comparison_operator"
937 [(reg:CC FLAGS_REG) (const_int 0)]))]
940 if (MEM_P (operands[2]) && MEM_P (operands[3]))
941 operands[2] = force_reg (<MODE>mode, operands[2]);
942 ix86_compare_op0 = operands[2];
943 ix86_compare_op1 = operands[3];
944 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
948 (define_expand "cmp<mode>_1"
949 [(set (reg:CC FLAGS_REG)
950 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
951 (match_operand:SWI48 1 "<general_operand>" "")))]
955 (define_insn "*cmp<mode>_ccno_1"
956 [(set (reg FLAGS_REG)
957 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
958 (match_operand:SWI 1 "const0_operand" "")))]
959 "ix86_match_ccmode (insn, CCNOmode)"
961 test{<imodesuffix>}\t%0, %0
962 cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
963 [(set_attr "type" "test,icmp")
964 (set_attr "length_immediate" "0,1")
965 (set_attr "mode" "<MODE>")])
967 (define_insn "*cmp<mode>_1"
968 [(set (reg FLAGS_REG)
969 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
970 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
971 "ix86_match_ccmode (insn, CCmode)"
972 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
973 [(set_attr "type" "icmp")
974 (set_attr "mode" "<MODE>")])
976 (define_insn "*cmp<mode>_minus_1"
977 [(set (reg FLAGS_REG)
979 (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
980 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
982 "ix86_match_ccmode (insn, CCGOCmode)"
983 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
984 [(set_attr "type" "icmp")
985 (set_attr "mode" "<MODE>")])
987 (define_insn "*cmpqi_ext_1"
988 [(set (reg FLAGS_REG)
990 (match_operand:QI 0 "general_operand" "Qm")
993 (match_operand 1 "ext_register_operand" "Q")
996 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
997 "cmp{b}\t{%h1, %0|%0, %h1}"
998 [(set_attr "type" "icmp")
999 (set_attr "mode" "QI")])
1001 (define_insn "*cmpqi_ext_1_rex64"
1002 [(set (reg FLAGS_REG)
1004 (match_operand:QI 0 "register_operand" "Q")
1007 (match_operand 1 "ext_register_operand" "Q")
1009 (const_int 8)) 0)))]
1010 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1011 "cmp{b}\t{%h1, %0|%0, %h1}"
1012 [(set_attr "type" "icmp")
1013 (set_attr "mode" "QI")])
1015 (define_insn "*cmpqi_ext_2"
1016 [(set (reg FLAGS_REG)
1020 (match_operand 0 "ext_register_operand" "Q")
1023 (match_operand:QI 1 "const0_operand" "")))]
1024 "ix86_match_ccmode (insn, CCNOmode)"
1026 [(set_attr "type" "test")
1027 (set_attr "length_immediate" "0")
1028 (set_attr "mode" "QI")])
1030 (define_expand "cmpqi_ext_3"
1031 [(set (reg:CC FLAGS_REG)
1035 (match_operand 0 "ext_register_operand" "")
1038 (match_operand:QI 1 "immediate_operand" "")))]
1042 (define_insn "*cmpqi_ext_3_insn"
1043 [(set (reg FLAGS_REG)
1047 (match_operand 0 "ext_register_operand" "Q")
1050 (match_operand:QI 1 "general_operand" "Qmn")))]
1051 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1052 "cmp{b}\t{%1, %h0|%h0, %1}"
1053 [(set_attr "type" "icmp")
1054 (set_attr "modrm" "1")
1055 (set_attr "mode" "QI")])
1057 (define_insn "*cmpqi_ext_3_insn_rex64"
1058 [(set (reg FLAGS_REG)
1062 (match_operand 0 "ext_register_operand" "Q")
1065 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1066 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1067 "cmp{b}\t{%1, %h0|%h0, %1}"
1068 [(set_attr "type" "icmp")
1069 (set_attr "modrm" "1")
1070 (set_attr "mode" "QI")])
1072 (define_insn "*cmpqi_ext_4"
1073 [(set (reg FLAGS_REG)
1077 (match_operand 0 "ext_register_operand" "Q")
1082 (match_operand 1 "ext_register_operand" "Q")
1084 (const_int 8)) 0)))]
1085 "ix86_match_ccmode (insn, CCmode)"
1086 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1087 [(set_attr "type" "icmp")
1088 (set_attr "mode" "QI")])
1090 ;; These implement float point compares.
1091 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1092 ;; which would allow mix and match FP modes on the compares. Which is what
1093 ;; the old patterns did, but with many more of them.
1095 (define_expand "cbranchxf4"
1096 [(set (reg:CC FLAGS_REG)
1097 (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1098 (match_operand:XF 2 "nonmemory_operand" "")))
1099 (set (pc) (if_then_else
1100 (match_operator 0 "ix86_fp_comparison_operator"
1103 (label_ref (match_operand 3 "" ""))
1107 ix86_compare_op0 = operands[1];
1108 ix86_compare_op1 = operands[2];
1109 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
1113 (define_expand "cstorexf4"
1114 [(set (reg:CC FLAGS_REG)
1115 (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1116 (match_operand:XF 3 "nonmemory_operand" "")))
1117 (set (match_operand:QI 0 "register_operand" "")
1118 (match_operator 1 "ix86_fp_comparison_operator"
1123 ix86_compare_op0 = operands[2];
1124 ix86_compare_op1 = operands[3];
1125 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
1129 (define_expand "cbranch<mode>4"
1130 [(set (reg:CC FLAGS_REG)
1131 (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1132 (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1133 (set (pc) (if_then_else
1134 (match_operator 0 "ix86_fp_comparison_operator"
1137 (label_ref (match_operand 3 "" ""))
1139 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1141 ix86_compare_op0 = operands[1];
1142 ix86_compare_op1 = operands[2];
1143 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
1147 (define_expand "cstore<mode>4"
1148 [(set (reg:CC FLAGS_REG)
1149 (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1150 (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1151 (set (match_operand:QI 0 "register_operand" "")
1152 (match_operator 1 "ix86_fp_comparison_operator"
1155 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1157 ix86_compare_op0 = operands[2];
1158 ix86_compare_op1 = operands[3];
1159 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
1163 (define_expand "cbranchcc4"
1164 [(set (pc) (if_then_else
1165 (match_operator 0 "comparison_operator"
1166 [(match_operand 1 "flags_reg_operand" "")
1167 (match_operand 2 "const0_operand" "")])
1168 (label_ref (match_operand 3 "" ""))
1172 ix86_compare_op0 = operands[1];
1173 ix86_compare_op1 = operands[2];
1174 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
1178 (define_expand "cstorecc4"
1179 [(set (match_operand:QI 0 "register_operand" "")
1180 (match_operator 1 "comparison_operator"
1181 [(match_operand 2 "flags_reg_operand" "")
1182 (match_operand 3 "const0_operand" "")]))]
1185 ix86_compare_op0 = operands[2];
1186 ix86_compare_op1 = operands[3];
1187 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
1192 ;; FP compares, step 1:
1193 ;; Set the FP condition codes.
1195 ;; CCFPmode compare with exceptions
1196 ;; CCFPUmode compare with no exceptions
1198 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1199 ;; used to manage the reg stack popping would not be preserved.
1201 (define_insn "*cmpfp_0"
1202 [(set (match_operand:HI 0 "register_operand" "=a")
1205 (match_operand 1 "register_operand" "f")
1206 (match_operand 2 "const0_operand" ""))]
1208 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1209 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1210 "* return output_fp_compare (insn, operands, 0, 0);"
1211 [(set_attr "type" "multi")
1212 (set_attr "unit" "i387")
1214 (cond [(match_operand:SF 1 "" "")
1216 (match_operand:DF 1 "" "")
1219 (const_string "XF")))])
1221 (define_insn_and_split "*cmpfp_0_cc"
1222 [(set (reg:CCFP FLAGS_REG)
1224 (match_operand 1 "register_operand" "f")
1225 (match_operand 2 "const0_operand" "")))
1226 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1227 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1228 && TARGET_SAHF && !TARGET_CMOVE
1229 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1231 "&& reload_completed"
1234 [(compare:CCFP (match_dup 1)(match_dup 2))]
1236 (set (reg:CC FLAGS_REG)
1237 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1239 [(set_attr "type" "multi")
1240 (set_attr "unit" "i387")
1242 (cond [(match_operand:SF 1 "" "")
1244 (match_operand:DF 1 "" "")
1247 (const_string "XF")))])
1249 (define_insn "*cmpfp_xf"
1250 [(set (match_operand:HI 0 "register_operand" "=a")
1253 (match_operand:XF 1 "register_operand" "f")
1254 (match_operand:XF 2 "register_operand" "f"))]
1257 "* return output_fp_compare (insn, operands, 0, 0);"
1258 [(set_attr "type" "multi")
1259 (set_attr "unit" "i387")
1260 (set_attr "mode" "XF")])
1262 (define_insn_and_split "*cmpfp_xf_cc"
1263 [(set (reg:CCFP FLAGS_REG)
1265 (match_operand:XF 1 "register_operand" "f")
1266 (match_operand:XF 2 "register_operand" "f")))
1267 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1269 && TARGET_SAHF && !TARGET_CMOVE"
1271 "&& reload_completed"
1274 [(compare:CCFP (match_dup 1)(match_dup 2))]
1276 (set (reg:CC FLAGS_REG)
1277 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1279 [(set_attr "type" "multi")
1280 (set_attr "unit" "i387")
1281 (set_attr "mode" "XF")])
1283 (define_insn "*cmpfp_<mode>"
1284 [(set (match_operand:HI 0 "register_operand" "=a")
1287 (match_operand:MODEF 1 "register_operand" "f")
1288 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1291 "* return output_fp_compare (insn, operands, 0, 0);"
1292 [(set_attr "type" "multi")
1293 (set_attr "unit" "i387")
1294 (set_attr "mode" "<MODE>")])
1296 (define_insn_and_split "*cmpfp_<mode>_cc"
1297 [(set (reg:CCFP FLAGS_REG)
1299 (match_operand:MODEF 1 "register_operand" "f")
1300 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1301 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1303 && TARGET_SAHF && !TARGET_CMOVE"
1305 "&& reload_completed"
1308 [(compare:CCFP (match_dup 1)(match_dup 2))]
1310 (set (reg:CC FLAGS_REG)
1311 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1313 [(set_attr "type" "multi")
1314 (set_attr "unit" "i387")
1315 (set_attr "mode" "<MODE>")])
1317 (define_insn "*cmpfp_u"
1318 [(set (match_operand:HI 0 "register_operand" "=a")
1321 (match_operand 1 "register_operand" "f")
1322 (match_operand 2 "register_operand" "f"))]
1324 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1325 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1326 "* return output_fp_compare (insn, operands, 0, 1);"
1327 [(set_attr "type" "multi")
1328 (set_attr "unit" "i387")
1330 (cond [(match_operand:SF 1 "" "")
1332 (match_operand:DF 1 "" "")
1335 (const_string "XF")))])
1337 (define_insn_and_split "*cmpfp_u_cc"
1338 [(set (reg:CCFPU FLAGS_REG)
1340 (match_operand 1 "register_operand" "f")
1341 (match_operand 2 "register_operand" "f")))
1342 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1343 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1344 && TARGET_SAHF && !TARGET_CMOVE
1345 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1347 "&& reload_completed"
1350 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1352 (set (reg:CC FLAGS_REG)
1353 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1355 [(set_attr "type" "multi")
1356 (set_attr "unit" "i387")
1358 (cond [(match_operand:SF 1 "" "")
1360 (match_operand:DF 1 "" "")
1363 (const_string "XF")))])
1365 (define_insn "*cmpfp_<mode>"
1366 [(set (match_operand:HI 0 "register_operand" "=a")
1369 (match_operand 1 "register_operand" "f")
1370 (match_operator 3 "float_operator"
1371 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1373 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1374 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1375 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1376 "* return output_fp_compare (insn, operands, 0, 0);"
1377 [(set_attr "type" "multi")
1378 (set_attr "unit" "i387")
1379 (set_attr "fp_int_src" "true")
1380 (set_attr "mode" "<MODE>")])
1382 (define_insn_and_split "*cmpfp_<mode>_cc"
1383 [(set (reg:CCFP FLAGS_REG)
1385 (match_operand 1 "register_operand" "f")
1386 (match_operator 3 "float_operator"
1387 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1388 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1389 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1390 && TARGET_SAHF && !TARGET_CMOVE
1391 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1392 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1394 "&& reload_completed"
1399 (match_op_dup 3 [(match_dup 2)]))]
1401 (set (reg:CC FLAGS_REG)
1402 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1404 [(set_attr "type" "multi")
1405 (set_attr "unit" "i387")
1406 (set_attr "fp_int_src" "true")
1407 (set_attr "mode" "<MODE>")])
1409 ;; FP compares, step 2
1410 ;; Move the fpsw to ax.
1412 (define_insn "x86_fnstsw_1"
1413 [(set (match_operand:HI 0 "register_operand" "=a")
1414 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1417 [(set (attr "length") (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1418 (set_attr "mode" "SI")
1419 (set_attr "unit" "i387")])
1421 ;; FP compares, step 3
1422 ;; Get ax into flags, general case.
1424 (define_insn "x86_sahf_1"
1425 [(set (reg:CC FLAGS_REG)
1426 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1430 #ifdef HAVE_AS_IX86_SAHF
1433 return ASM_BYTE "0x9e";
1436 [(set_attr "length" "1")
1437 (set_attr "athlon_decode" "vector")
1438 (set_attr "amdfam10_decode" "direct")
1439 (set_attr "mode" "SI")])
1441 ;; Pentium Pro can do steps 1 through 3 in one go.
1442 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1443 (define_insn "*cmpfp_i_mixed"
1444 [(set (reg:CCFP FLAGS_REG)
1445 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1446 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1447 "TARGET_MIX_SSE_I387
1448 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1449 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1450 "* return output_fp_compare (insn, operands, 1, 0);"
1451 [(set_attr "type" "fcmp,ssecomi")
1452 (set_attr "prefix" "orig,maybe_vex")
1454 (if_then_else (match_operand:SF 1 "" "")
1456 (const_string "DF")))
1457 (set (attr "prefix_rep")
1458 (if_then_else (eq_attr "type" "ssecomi")
1460 (const_string "*")))
1461 (set (attr "prefix_data16")
1462 (cond [(eq_attr "type" "fcmp")
1464 (eq_attr "mode" "DF")
1467 (const_string "0")))
1468 (set_attr "athlon_decode" "vector")
1469 (set_attr "amdfam10_decode" "direct")])
1471 (define_insn "*cmpfp_i_sse"
1472 [(set (reg:CCFP FLAGS_REG)
1473 (compare:CCFP (match_operand 0 "register_operand" "x")
1474 (match_operand 1 "nonimmediate_operand" "xm")))]
1476 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1477 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1478 "* return output_fp_compare (insn, operands, 1, 0);"
1479 [(set_attr "type" "ssecomi")
1480 (set_attr "prefix" "maybe_vex")
1482 (if_then_else (match_operand:SF 1 "" "")
1484 (const_string "DF")))
1485 (set_attr "prefix_rep" "0")
1486 (set (attr "prefix_data16")
1487 (if_then_else (eq_attr "mode" "DF")
1489 (const_string "0")))
1490 (set_attr "athlon_decode" "vector")
1491 (set_attr "amdfam10_decode" "direct")])
1493 (define_insn "*cmpfp_i_i387"
1494 [(set (reg:CCFP FLAGS_REG)
1495 (compare:CCFP (match_operand 0 "register_operand" "f")
1496 (match_operand 1 "register_operand" "f")))]
1497 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1499 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1500 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1501 "* return output_fp_compare (insn, operands, 1, 0);"
1502 [(set_attr "type" "fcmp")
1504 (cond [(match_operand:SF 1 "" "")
1506 (match_operand:DF 1 "" "")
1509 (const_string "XF")))
1510 (set_attr "athlon_decode" "vector")
1511 (set_attr "amdfam10_decode" "direct")])
1513 (define_insn "*cmpfp_iu_mixed"
1514 [(set (reg:CCFPU FLAGS_REG)
1515 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1516 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1517 "TARGET_MIX_SSE_I387
1518 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1519 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1520 "* return output_fp_compare (insn, operands, 1, 1);"
1521 [(set_attr "type" "fcmp,ssecomi")
1522 (set_attr "prefix" "orig,maybe_vex")
1524 (if_then_else (match_operand:SF 1 "" "")
1526 (const_string "DF")))
1527 (set (attr "prefix_rep")
1528 (if_then_else (eq_attr "type" "ssecomi")
1530 (const_string "*")))
1531 (set (attr "prefix_data16")
1532 (cond [(eq_attr "type" "fcmp")
1534 (eq_attr "mode" "DF")
1537 (const_string "0")))
1538 (set_attr "athlon_decode" "vector")
1539 (set_attr "amdfam10_decode" "direct")])
1541 (define_insn "*cmpfp_iu_sse"
1542 [(set (reg:CCFPU FLAGS_REG)
1543 (compare:CCFPU (match_operand 0 "register_operand" "x")
1544 (match_operand 1 "nonimmediate_operand" "xm")))]
1546 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1547 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1548 "* return output_fp_compare (insn, operands, 1, 1);"
1549 [(set_attr "type" "ssecomi")
1550 (set_attr "prefix" "maybe_vex")
1552 (if_then_else (match_operand:SF 1 "" "")
1554 (const_string "DF")))
1555 (set_attr "prefix_rep" "0")
1556 (set (attr "prefix_data16")
1557 (if_then_else (eq_attr "mode" "DF")
1559 (const_string "0")))
1560 (set_attr "athlon_decode" "vector")
1561 (set_attr "amdfam10_decode" "direct")])
1563 (define_insn "*cmpfp_iu_387"
1564 [(set (reg:CCFPU FLAGS_REG)
1565 (compare:CCFPU (match_operand 0 "register_operand" "f")
1566 (match_operand 1 "register_operand" "f")))]
1567 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1569 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1570 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1571 "* return output_fp_compare (insn, operands, 1, 1);"
1572 [(set_attr "type" "fcmp")
1574 (cond [(match_operand:SF 1 "" "")
1576 (match_operand:DF 1 "" "")
1579 (const_string "XF")))
1580 (set_attr "athlon_decode" "vector")
1581 (set_attr "amdfam10_decode" "direct")])
1583 ;; Move instructions.
1585 ;; General case of fullword move.
1587 (define_expand "movsi"
1588 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1589 (match_operand:SI 1 "general_operand" ""))]
1591 "ix86_expand_move (SImode, operands); DONE;")
1593 ;; Push/pop instructions. They are separate since autoinc/dec is not a
1596 ;; %%% We don't use a post-inc memory reference because x86 is not a
1597 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1598 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1599 ;; targets without our curiosities, and it is just as easy to represent
1600 ;; this differently.
1602 (define_insn "*pushsi2"
1603 [(set (match_operand:SI 0 "push_operand" "=<")
1604 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1607 [(set_attr "type" "push")
1608 (set_attr "mode" "SI")])
1610 ;; For 64BIT abi we always round up to 8 bytes.
1611 (define_insn "*pushsi2_rex64"
1612 [(set (match_operand:SI 0 "push_operand" "=X")
1613 (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1616 [(set_attr "type" "push")
1617 (set_attr "mode" "SI")])
1619 (define_insn "*pushsi2_prologue"
1620 [(set (match_operand:SI 0 "push_operand" "=<")
1621 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1622 (clobber (mem:BLK (scratch)))]
1625 [(set_attr "type" "push")
1626 (set_attr "mode" "SI")])
1628 (define_insn "*popsi1_epilogue"
1629 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1630 (mem:SI (reg:SI SP_REG)))
1631 (set (reg:SI SP_REG)
1632 (plus:SI (reg:SI SP_REG) (const_int 4)))
1633 (clobber (mem:BLK (scratch)))]
1636 [(set_attr "type" "pop")
1637 (set_attr "mode" "SI")])
1639 (define_insn "popsi1"
1640 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1641 (mem:SI (reg:SI SP_REG)))
1642 (set (reg:SI SP_REG)
1643 (plus:SI (reg:SI SP_REG) (const_int 4)))]
1646 [(set_attr "type" "pop")
1647 (set_attr "mode" "SI")])
1649 (define_insn "*movsi_xor"
1650 [(set (match_operand:SI 0 "register_operand" "=r")
1651 (match_operand:SI 1 "const0_operand" ""))
1652 (clobber (reg:CC FLAGS_REG))]
1655 [(set_attr "type" "alu1")
1656 (set_attr "mode" "SI")
1657 (set_attr "length_immediate" "0")])
1659 (define_insn "*movsi_or"
1660 [(set (match_operand:SI 0 "register_operand" "=r")
1661 (match_operand:SI 1 "immediate_operand" "i"))
1662 (clobber (reg:CC FLAGS_REG))]
1664 && operands[1] == constm1_rtx"
1666 operands[1] = constm1_rtx;
1667 return "or{l}\t{%1, %0|%0, %1}";
1669 [(set_attr "type" "alu1")
1670 (set_attr "mode" "SI")
1671 (set_attr "length_immediate" "1")])
1673 (define_insn "*movsi_1"
1674 [(set (match_operand:SI 0 "nonimmediate_operand"
1675 "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
1676 (match_operand:SI 1 "general_operand"
1677 "g ,ri,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
1678 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1680 switch (get_attr_type (insn))
1683 if (get_attr_mode (insn) == MODE_TI)
1684 return "%vpxor\t%0, %d0";
1685 return "%vxorps\t%0, %d0";
1688 switch (get_attr_mode (insn))
1691 return "%vmovdqa\t{%1, %0|%0, %1}";
1693 return "%vmovaps\t{%1, %0|%0, %1}";
1695 return "%vmovd\t{%1, %0|%0, %1}";
1697 return "%vmovss\t{%1, %0|%0, %1}";
1703 return "pxor\t%0, %0";
1706 if (get_attr_mode (insn) == MODE_DI)
1707 return "movq\t{%1, %0|%0, %1}";
1708 return "movd\t{%1, %0|%0, %1}";
1711 return "lea{l}\t{%1, %0|%0, %1}";
1714 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
1715 return "mov{l}\t{%1, %0|%0, %1}";
1719 (cond [(eq_attr "alternative" "2")
1720 (const_string "mmx")
1721 (eq_attr "alternative" "3,4,5")
1722 (const_string "mmxmov")
1723 (eq_attr "alternative" "6")
1724 (const_string "sselog1")
1725 (eq_attr "alternative" "7,8,9,10,11")
1726 (const_string "ssemov")
1727 (match_operand:DI 1 "pic_32bit_operand" "")
1728 (const_string "lea")
1730 (const_string "imov")))
1731 (set (attr "prefix")
1732 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
1733 (const_string "orig")
1734 (const_string "maybe_vex")))
1735 (set (attr "prefix_data16")
1736 (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
1738 (const_string "*")))
1740 (cond [(eq_attr "alternative" "2,3")
1742 (eq_attr "alternative" "6,7")
1744 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1745 (const_string "V4SF")
1746 (const_string "TI"))
1747 (and (eq_attr "alternative" "8,9,10,11")
1748 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
1751 (const_string "SI")))])
1753 ;; Stores and loads of ax to arbitrary constant address.
1754 ;; We fake an second form of instruction to force reload to load address
1755 ;; into register when rax is not available
1756 (define_insn "*movabssi_1_rex64"
1757 [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1758 (match_operand:SI 1 "nonmemory_operand" "a,er"))]
1759 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1761 movabs{l}\t{%1, %P0|%P0, %1}
1762 mov{l}\t{%1, %a0|%a0, %1}"
1763 [(set_attr "type" "imov")
1764 (set_attr "modrm" "0,*")
1765 (set_attr "length_address" "8,0")
1766 (set_attr "length_immediate" "0,*")
1767 (set_attr "memory" "store")
1768 (set_attr "mode" "SI")])
1770 (define_insn "*movabssi_2_rex64"
1771 [(set (match_operand:SI 0 "register_operand" "=a,r")
1772 (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1773 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1775 movabs{l}\t{%P1, %0|%0, %P1}
1776 mov{l}\t{%a1, %0|%0, %a1}"
1777 [(set_attr "type" "imov")
1778 (set_attr "modrm" "0,*")
1779 (set_attr "length_address" "8,0")
1780 (set_attr "length_immediate" "0")
1781 (set_attr "memory" "load")
1782 (set_attr "mode" "SI")])
1784 (define_insn "*swapsi"
1785 [(set (match_operand:SI 0 "register_operand" "+r")
1786 (match_operand:SI 1 "register_operand" "+r"))
1791 [(set_attr "type" "imov")
1792 (set_attr "mode" "SI")
1793 (set_attr "pent_pair" "np")
1794 (set_attr "athlon_decode" "vector")
1795 (set_attr "amdfam10_decode" "double")])
1797 (define_expand "movhi"
1798 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1799 (match_operand:HI 1 "general_operand" ""))]
1801 "ix86_expand_move (HImode, operands); DONE;")
1803 (define_insn "*pushhi2"
1804 [(set (match_operand:HI 0 "push_operand" "=X")
1805 (match_operand:HI 1 "nonmemory_no_elim_operand" "rn"))]
1808 [(set_attr "type" "push")
1809 (set_attr "mode" "SI")])
1811 ;; For 64BIT abi we always round up to 8 bytes.
1812 (define_insn "*pushhi2_rex64"
1813 [(set (match_operand:HI 0 "push_operand" "=X")
1814 (match_operand:HI 1 "nonmemory_no_elim_operand" "rn"))]
1817 [(set_attr "type" "push")
1818 (set_attr "mode" "DI")])
1820 (define_insn "*movhi_1"
1821 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
1822 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
1823 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1825 switch (get_attr_type (insn))
1828 /* movzwl is faster than movw on p2 due to partial word stalls,
1829 though not as fast as an aligned movl. */
1830 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1832 if (get_attr_mode (insn) == MODE_SI)
1833 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1835 return "mov{w}\t{%1, %0|%0, %1}";
1839 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)") (const_int 0))
1840 (const_string "imov")
1841 (and (eq_attr "alternative" "0")
1842 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1844 (eq (symbol_ref "TARGET_HIMODE_MATH")
1846 (const_string "imov")
1847 (and (eq_attr "alternative" "1,2")
1848 (match_operand:HI 1 "aligned_operand" ""))
1849 (const_string "imov")
1850 (and (ne (symbol_ref "TARGET_MOVX")
1852 (eq_attr "alternative" "0,2"))
1853 (const_string "imovx")
1855 (const_string "imov")))
1857 (cond [(eq_attr "type" "imovx")
1859 (and (eq_attr "alternative" "1,2")
1860 (match_operand:HI 1 "aligned_operand" ""))
1862 (and (eq_attr "alternative" "0")
1863 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1865 (eq (symbol_ref "TARGET_HIMODE_MATH")
1869 (const_string "HI")))])
1871 ;; Stores and loads of ax to arbitrary constant address.
1872 ;; We fake an second form of instruction to force reload to load address
1873 ;; into register when rax is not available
1874 (define_insn "*movabshi_1_rex64"
1875 [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1876 (match_operand:HI 1 "nonmemory_operand" "a,er"))]
1877 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1879 movabs{w}\t{%1, %P0|%P0, %1}
1880 mov{w}\t{%1, %a0|%a0, %1}"
1881 [(set_attr "type" "imov")
1882 (set_attr "modrm" "0,*")
1883 (set_attr "length_address" "8,0")
1884 (set_attr "length_immediate" "0,*")
1885 (set_attr "memory" "store")
1886 (set_attr "mode" "HI")])
1888 (define_insn "*movabshi_2_rex64"
1889 [(set (match_operand:HI 0 "register_operand" "=a,r")
1890 (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1891 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1893 movabs{w}\t{%P1, %0|%0, %P1}
1894 mov{w}\t{%a1, %0|%0, %a1}"
1895 [(set_attr "type" "imov")
1896 (set_attr "modrm" "0,*")
1897 (set_attr "length_address" "8,0")
1898 (set_attr "length_immediate" "0")
1899 (set_attr "memory" "load")
1900 (set_attr "mode" "HI")])
1902 (define_insn "*swaphi_1"
1903 [(set (match_operand:HI 0 "register_operand" "+r")
1904 (match_operand:HI 1 "register_operand" "+r"))
1907 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
1909 [(set_attr "type" "imov")
1910 (set_attr "mode" "SI")
1911 (set_attr "pent_pair" "np")
1912 (set_attr "athlon_decode" "vector")
1913 (set_attr "amdfam10_decode" "double")])
1915 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
1916 (define_insn "*swaphi_2"
1917 [(set (match_operand:HI 0 "register_operand" "+r")
1918 (match_operand:HI 1 "register_operand" "+r"))
1921 "TARGET_PARTIAL_REG_STALL"
1923 [(set_attr "type" "imov")
1924 (set_attr "mode" "HI")
1925 (set_attr "pent_pair" "np")
1926 (set_attr "athlon_decode" "vector")])
1928 (define_expand "movstricthi"
1929 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1930 (match_operand:HI 1 "general_operand" ""))]
1933 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
1935 /* Don't generate memory->memory moves, go through a register */
1936 if (MEM_P (operands[0]) && MEM_P (operands[1]))
1937 operands[1] = force_reg (HImode, operands[1]);
1940 (define_insn "*movstricthi_1"
1941 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1942 (match_operand:HI 1 "general_operand" "rn,m"))]
1943 "(! TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
1944 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1945 "mov{w}\t{%1, %0|%0, %1}"
1946 [(set_attr "type" "imov")
1947 (set_attr "mode" "HI")])
1949 (define_insn "*movstricthi_xor"
1950 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1951 (match_operand:HI 1 "const0_operand" ""))
1952 (clobber (reg:CC FLAGS_REG))]
1955 [(set_attr "type" "alu1")
1956 (set_attr "mode" "HI")
1957 (set_attr "length_immediate" "0")])
1959 (define_expand "movqi"
1960 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1961 (match_operand:QI 1 "general_operand" ""))]
1963 "ix86_expand_move (QImode, operands); DONE;")
1965 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1966 ;; "push a byte". But actually we use pushl, which has the effect
1967 ;; of rounding the amount pushed up to a word.
1969 (define_insn "*pushqi2"
1970 [(set (match_operand:QI 0 "push_operand" "=X")
1971 (match_operand:QI 1 "nonmemory_no_elim_operand" "rn"))]
1974 [(set_attr "type" "push")
1975 (set_attr "mode" "SI")])
1977 ;; For 64BIT abi we always round up to 8 bytes.
1978 (define_insn "*pushqi2_rex64"
1979 [(set (match_operand:QI 0 "push_operand" "=X")
1980 (match_operand:QI 1 "nonmemory_no_elim_operand" "qn"))]
1983 [(set_attr "type" "push")
1984 (set_attr "mode" "DI")])
1986 ;; Situation is quite tricky about when to choose full sized (SImode) move
1987 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
1988 ;; partial register dependency machines (such as AMD Athlon), where QImode
1989 ;; moves issue extra dependency and for partial register stalls machines
1990 ;; that don't use QImode patterns (and QImode move cause stall on the next
1993 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
1994 ;; register stall machines with, where we use QImode instructions, since
1995 ;; partial register stall can be caused there. Then we use movzx.
1996 (define_insn "*movqi_1"
1997 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
1998 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
1999 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2001 switch (get_attr_type (insn))
2004 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2005 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2007 if (get_attr_mode (insn) == MODE_SI)
2008 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2010 return "mov{b}\t{%1, %0|%0, %1}";
2014 (cond [(and (eq_attr "alternative" "5")
2015 (not (match_operand:QI 1 "aligned_operand" "")))
2016 (const_string "imovx")
2017 (ne (symbol_ref "optimize_function_for_size_p (cfun)") (const_int 0))
2018 (const_string "imov")
2019 (and (eq_attr "alternative" "3")
2020 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2022 (eq (symbol_ref "TARGET_QIMODE_MATH")
2024 (const_string "imov")
2025 (eq_attr "alternative" "3,5")
2026 (const_string "imovx")
2027 (and (ne (symbol_ref "TARGET_MOVX")
2029 (eq_attr "alternative" "2"))
2030 (const_string "imovx")
2032 (const_string "imov")))
2034 (cond [(eq_attr "alternative" "3,4,5")
2036 (eq_attr "alternative" "6")
2038 (eq_attr "type" "imovx")
2040 (and (eq_attr "type" "imov")
2041 (and (eq_attr "alternative" "0,1")
2042 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2044 (and (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2046 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2049 ;; Avoid partial register stalls when not using QImode arithmetic
2050 (and (eq_attr "type" "imov")
2051 (and (eq_attr "alternative" "0,1")
2052 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2054 (eq (symbol_ref "TARGET_QIMODE_MATH")
2058 (const_string "QI")))])
2060 (define_insn "*swapqi_1"
2061 [(set (match_operand:QI 0 "register_operand" "+r")
2062 (match_operand:QI 1 "register_operand" "+r"))
2065 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2067 [(set_attr "type" "imov")
2068 (set_attr "mode" "SI")
2069 (set_attr "pent_pair" "np")
2070 (set_attr "athlon_decode" "vector")
2071 (set_attr "amdfam10_decode" "vector")])
2073 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
2074 (define_insn "*swapqi_2"
2075 [(set (match_operand:QI 0 "register_operand" "+q")
2076 (match_operand:QI 1 "register_operand" "+q"))
2079 "TARGET_PARTIAL_REG_STALL"
2081 [(set_attr "type" "imov")
2082 (set_attr "mode" "QI")
2083 (set_attr "pent_pair" "np")
2084 (set_attr "athlon_decode" "vector")])
2086 (define_expand "movstrictqi"
2087 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
2088 (match_operand:QI 1 "general_operand" ""))]
2091 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2093 /* Don't generate memory->memory moves, go through a register. */
2094 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2095 operands[1] = force_reg (QImode, operands[1]);
2098 (define_insn "*movstrictqi_1"
2099 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
2100 (match_operand:QI 1 "general_operand" "*qn,m"))]
2101 "(! TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2102 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2103 "mov{b}\t{%1, %0|%0, %1}"
2104 [(set_attr "type" "imov")
2105 (set_attr "mode" "QI")])
2107 (define_insn "*movstrictqi_xor"
2108 [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
2109 (match_operand:QI 1 "const0_operand" ""))
2110 (clobber (reg:CC FLAGS_REG))]
2113 [(set_attr "type" "alu1")
2114 (set_attr "mode" "QI")
2115 (set_attr "length_immediate" "0")])
2117 (define_insn "*movsi_extv_1"
2118 [(set (match_operand:SI 0 "register_operand" "=R")
2119 (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
2123 "movs{bl|x}\t{%h1, %0|%0, %h1}"
2124 [(set_attr "type" "imovx")
2125 (set_attr "mode" "SI")])
2127 (define_insn "*movhi_extv_1"
2128 [(set (match_operand:HI 0 "register_operand" "=R")
2129 (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
2133 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2134 [(set_attr "type" "imovx")
2135 (set_attr "mode" "SI")])
2137 (define_insn "*movqi_extv_1"
2138 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2139 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2144 switch (get_attr_type (insn))
2147 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2149 return "mov{b}\t{%h1, %0|%0, %h1}";
2153 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2154 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2155 (ne (symbol_ref "TARGET_MOVX")
2157 (const_string "imovx")
2158 (const_string "imov")))
2160 (if_then_else (eq_attr "type" "imovx")
2162 (const_string "QI")))])
2164 (define_insn "*movqi_extv_1_rex64"
2165 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2166 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2171 switch (get_attr_type (insn))
2174 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2176 return "mov{b}\t{%h1, %0|%0, %h1}";
2180 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2181 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2182 (ne (symbol_ref "TARGET_MOVX")
2184 (const_string "imovx")
2185 (const_string "imov")))
2187 (if_then_else (eq_attr "type" "imovx")
2189 (const_string "QI")))])
2191 ;; Stores and loads of ax to arbitrary constant address.
2192 ;; We fake an second form of instruction to force reload to load address
2193 ;; into register when rax is not available
2194 (define_insn "*movabsqi_1_rex64"
2195 [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2196 (match_operand:QI 1 "nonmemory_operand" "a,er"))]
2197 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2199 movabs{b}\t{%1, %P0|%P0, %1}
2200 mov{b}\t{%1, %a0|%a0, %1}"
2201 [(set_attr "type" "imov")
2202 (set_attr "modrm" "0,*")
2203 (set_attr "length_address" "8,0")
2204 (set_attr "length_immediate" "0,*")
2205 (set_attr "memory" "store")
2206 (set_attr "mode" "QI")])
2208 (define_insn "*movabsqi_2_rex64"
2209 [(set (match_operand:QI 0 "register_operand" "=a,r")
2210 (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2211 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2213 movabs{b}\t{%P1, %0|%0, %P1}
2214 mov{b}\t{%a1, %0|%0, %a1}"
2215 [(set_attr "type" "imov")
2216 (set_attr "modrm" "0,*")
2217 (set_attr "length_address" "8,0")
2218 (set_attr "length_immediate" "0")
2219 (set_attr "memory" "load")
2220 (set_attr "mode" "QI")])
2222 (define_insn "*movdi_extzv_1"
2223 [(set (match_operand:DI 0 "register_operand" "=R")
2224 (zero_extract:DI (match_operand 1 "ext_register_operand" "Q")
2228 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2229 [(set_attr "type" "imovx")
2230 (set_attr "mode" "SI")])
2232 (define_insn "*movsi_extzv_1"
2233 [(set (match_operand:SI 0 "register_operand" "=R")
2234 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
2238 "movz{bl|x}\t{%h1, %0|%0, %h1}"
2239 [(set_attr "type" "imovx")
2240 (set_attr "mode" "SI")])
2242 (define_insn "*movqi_extzv_2"
2243 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2244 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2249 switch (get_attr_type (insn))
2252 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2254 return "mov{b}\t{%h1, %0|%0, %h1}";
2258 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2259 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2260 (ne (symbol_ref "TARGET_MOVX")
2262 (const_string "imovx")
2263 (const_string "imov")))
2265 (if_then_else (eq_attr "type" "imovx")
2267 (const_string "QI")))])
2269 (define_insn "*movqi_extzv_2_rex64"
2270 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2271 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2276 switch (get_attr_type (insn))
2279 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2281 return "mov{b}\t{%h1, %0|%0, %h1}";
2285 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2286 (ne (symbol_ref "TARGET_MOVX")
2288 (const_string "imovx")
2289 (const_string "imov")))
2291 (if_then_else (eq_attr "type" "imovx")
2293 (const_string "QI")))])
2295 (define_insn "movsi_insv_1"
2296 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2299 (match_operand:SI 1 "general_operand" "Qmn"))]
2301 "mov{b}\t{%b1, %h0|%h0, %b1}"
2302 [(set_attr "type" "imov")
2303 (set_attr "mode" "QI")])
2305 (define_insn "*movsi_insv_1_rex64"
2306 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2309 (match_operand:SI 1 "nonmemory_operand" "Qn"))]
2311 "mov{b}\t{%b1, %h0|%h0, %b1}"
2312 [(set_attr "type" "imov")
2313 (set_attr "mode" "QI")])
2315 (define_insn "movdi_insv_1_rex64"
2316 [(set (zero_extract:DI (match_operand 0 "ext_register_operand" "+Q")
2319 (match_operand:DI 1 "nonmemory_operand" "Qn"))]
2321 "mov{b}\t{%b1, %h0|%h0, %b1}"
2322 [(set_attr "type" "imov")
2323 (set_attr "mode" "QI")])
2325 (define_insn "*movqi_insv_2"
2326 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2329 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2332 "mov{b}\t{%h1, %h0|%h0, %h1}"
2333 [(set_attr "type" "imov")
2334 (set_attr "mode" "QI")])
2336 (define_expand "movdi"
2337 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2338 (match_operand:DI 1 "general_operand" ""))]
2340 "ix86_expand_move (DImode, operands); DONE;")
2342 (define_insn "*pushdi"
2343 [(set (match_operand:DI 0 "push_operand" "=<")
2344 (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
2348 (define_insn "*pushdi2_rex64"
2349 [(set (match_operand:DI 0 "push_operand" "=<,!<")
2350 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
2355 [(set_attr "type" "push,multi")
2356 (set_attr "mode" "DI")])
2358 ;; Convert impossible pushes of immediate to existing instructions.
2359 ;; First try to get scratch register and go through it. In case this
2360 ;; fails, push sign extended lower part first and then overwrite
2361 ;; upper part by 32bit move.
2363 [(match_scratch:DI 2 "r")
2364 (set (match_operand:DI 0 "push_operand" "")
2365 (match_operand:DI 1 "immediate_operand" ""))]
2366 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2367 && !x86_64_immediate_operand (operands[1], DImode)"
2368 [(set (match_dup 2) (match_dup 1))
2369 (set (match_dup 0) (match_dup 2))]
2372 ;; We need to define this as both peepholer and splitter for case
2373 ;; peephole2 pass is not run.
2374 ;; "&& 1" is needed to keep it from matching the previous pattern.
2376 [(set (match_operand:DI 0 "push_operand" "")
2377 (match_operand:DI 1 "immediate_operand" ""))]
2378 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2379 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2380 [(set (match_dup 0) (match_dup 1))
2381 (set (match_dup 2) (match_dup 3))]
2382 "split_di (&operands[1], 1, &operands[2], &operands[3]);
2383 operands[1] = gen_lowpart (DImode, operands[2]);
2384 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2389 [(set (match_operand:DI 0 "push_operand" "")
2390 (match_operand:DI 1 "immediate_operand" ""))]
2391 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2392 ? epilogue_completed : reload_completed)
2393 && !symbolic_operand (operands[1], DImode)
2394 && !x86_64_immediate_operand (operands[1], DImode)"
2395 [(set (match_dup 0) (match_dup 1))
2396 (set (match_dup 2) (match_dup 3))]
2397 "split_di (&operands[1], 1, &operands[2], &operands[3]);
2398 operands[1] = gen_lowpart (DImode, operands[2]);
2399 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2403 (define_insn "*pushdi2_prologue_rex64"
2404 [(set (match_operand:DI 0 "push_operand" "=<")
2405 (match_operand:DI 1 "general_no_elim_operand" "re*m"))
2406 (clobber (mem:BLK (scratch)))]
2409 [(set_attr "type" "push")
2410 (set_attr "mode" "DI")])
2412 (define_insn "*popdi1_epilogue_rex64"
2413 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2414 (mem:DI (reg:DI SP_REG)))
2415 (set (reg:DI SP_REG)
2416 (plus:DI (reg:DI SP_REG) (const_int 8)))
2417 (clobber (mem:BLK (scratch)))]
2420 [(set_attr "type" "pop")
2421 (set_attr "mode" "DI")])
2423 (define_insn "popdi1"
2424 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2425 (mem:DI (reg:DI SP_REG)))
2426 (set (reg:DI SP_REG)
2427 (plus:DI (reg:DI SP_REG) (const_int 8)))]
2430 [(set_attr "type" "pop")
2431 (set_attr "mode" "DI")])
2433 (define_insn "*movdi_xor_rex64"
2434 [(set (match_operand:DI 0 "register_operand" "=r")
2435 (match_operand:DI 1 "const0_operand" ""))
2436 (clobber (reg:CC FLAGS_REG))]
2438 && reload_completed"
2440 [(set_attr "type" "alu1")
2441 (set_attr "mode" "SI")
2442 (set_attr "length_immediate" "0")])
2444 (define_insn "*movdi_or_rex64"
2445 [(set (match_operand:DI 0 "register_operand" "=r")
2446 (match_operand:DI 1 "const_int_operand" "i"))
2447 (clobber (reg:CC FLAGS_REG))]
2450 && operands[1] == constm1_rtx"
2452 operands[1] = constm1_rtx;
2453 return "or{q}\t{%1, %0|%0, %1}";
2455 [(set_attr "type" "alu1")
2456 (set_attr "mode" "DI")
2457 (set_attr "length_immediate" "1")])
2459 (define_insn "*movdi_2"
2460 [(set (match_operand:DI 0 "nonimmediate_operand"
2461 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2462 (match_operand:DI 1 "general_operand"
2463 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2464 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2469 movq\t{%1, %0|%0, %1}
2470 movq\t{%1, %0|%0, %1}
2472 %vmovq\t{%1, %0|%0, %1}
2473 %vmovdqa\t{%1, %0|%0, %1}
2474 %vmovq\t{%1, %0|%0, %1}
2476 movlps\t{%1, %0|%0, %1}
2477 movaps\t{%1, %0|%0, %1}
2478 movlps\t{%1, %0|%0, %1}"
2479 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2480 (set (attr "prefix")
2481 (if_then_else (eq_attr "alternative" "5,6,7,8")
2482 (const_string "vex")
2483 (const_string "orig")))
2484 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2487 [(set (match_operand:DI 0 "push_operand" "")
2488 (match_operand:DI 1 "general_operand" ""))]
2489 "!TARGET_64BIT && reload_completed
2490 && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2492 "ix86_split_long_move (operands); DONE;")
2494 ;; %%% This multiword shite has got to go.
2496 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2497 (match_operand:DI 1 "general_operand" ""))]
2498 "!TARGET_64BIT && reload_completed
2499 && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
2500 && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2502 "ix86_split_long_move (operands); DONE;")
2504 (define_insn "*movdi_1_rex64"
2505 [(set (match_operand:DI 0 "nonimmediate_operand"
2506 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
2507 (match_operand:DI 1 "general_operand"
2508 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
2509 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2511 switch (get_attr_type (insn))
2514 if (SSE_REG_P (operands[0]))
2515 return "movq2dq\t{%1, %0|%0, %1}";
2517 return "movdq2q\t{%1, %0|%0, %1}";
2522 if (get_attr_mode (insn) == MODE_TI)
2523 return "vmovdqa\t{%1, %0|%0, %1}";
2525 return "vmovq\t{%1, %0|%0, %1}";
2528 if (get_attr_mode (insn) == MODE_TI)
2529 return "movdqa\t{%1, %0|%0, %1}";
2533 /* Moves from and into integer register is done using movd
2534 opcode with REX prefix. */
2535 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2536 return "movd\t{%1, %0|%0, %1}";
2537 return "movq\t{%1, %0|%0, %1}";
2540 return "%vpxor\t%0, %d0";
2543 return "pxor\t%0, %0";
2549 return "lea{q}\t{%a1, %0|%0, %a1}";
2552 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2553 if (get_attr_mode (insn) == MODE_SI)
2554 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2555 else if (which_alternative == 2)
2556 return "movabs{q}\t{%1, %0|%0, %1}";
2558 return "mov{q}\t{%1, %0|%0, %1}";
2562 (cond [(eq_attr "alternative" "5")
2563 (const_string "mmx")
2564 (eq_attr "alternative" "6,7,8,9,10")
2565 (const_string "mmxmov")
2566 (eq_attr "alternative" "11")
2567 (const_string "sselog1")
2568 (eq_attr "alternative" "12,13,14,15,16")
2569 (const_string "ssemov")
2570 (eq_attr "alternative" "17,18")
2571 (const_string "ssecvt")
2572 (eq_attr "alternative" "4")
2573 (const_string "multi")
2574 (match_operand:DI 1 "pic_32bit_operand" "")
2575 (const_string "lea")
2577 (const_string "imov")))
2580 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2582 (const_string "*")))
2583 (set (attr "length_immediate")
2585 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2587 (const_string "*")))
2588 (set_attr "prefix_rex" "*,*,*,*,*,*,*,1,*,1,*,*,*,*,*,*,*,*,*")
2589 (set_attr "prefix_data16" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,1,*,*,*")
2590 (set (attr "prefix")
2591 (if_then_else (eq_attr "alternative" "11,12,13,14,15,16")
2592 (const_string "maybe_vex")
2593 (const_string "orig")))
2594 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2596 ;; Stores and loads of ax to arbitrary constant address.
2597 ;; We fake an second form of instruction to force reload to load address
2598 ;; into register when rax is not available
2599 (define_insn "*movabsdi_1_rex64"
2600 [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2601 (match_operand:DI 1 "nonmemory_operand" "a,er"))]
2602 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2604 movabs{q}\t{%1, %P0|%P0, %1}
2605 mov{q}\t{%1, %a0|%a0, %1}"
2606 [(set_attr "type" "imov")
2607 (set_attr "modrm" "0,*")
2608 (set_attr "length_address" "8,0")
2609 (set_attr "length_immediate" "0,*")
2610 (set_attr "memory" "store")
2611 (set_attr "mode" "DI")])
2613 (define_insn "*movabsdi_2_rex64"
2614 [(set (match_operand:DI 0 "register_operand" "=a,r")
2615 (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2616 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2618 movabs{q}\t{%P1, %0|%0, %P1}
2619 mov{q}\t{%a1, %0|%0, %a1}"
2620 [(set_attr "type" "imov")
2621 (set_attr "modrm" "0,*")
2622 (set_attr "length_address" "8,0")
2623 (set_attr "length_immediate" "0")
2624 (set_attr "memory" "load")
2625 (set_attr "mode" "DI")])
2627 ;; Convert impossible stores of immediate to existing instructions.
2628 ;; First try to get scratch register and go through it. In case this
2629 ;; fails, move by 32bit parts.
2631 [(match_scratch:DI 2 "r")
2632 (set (match_operand:DI 0 "memory_operand" "")
2633 (match_operand:DI 1 "immediate_operand" ""))]
2634 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2635 && !x86_64_immediate_operand (operands[1], DImode)"
2636 [(set (match_dup 2) (match_dup 1))
2637 (set (match_dup 0) (match_dup 2))]
2640 ;; We need to define this as both peepholer and splitter for case
2641 ;; peephole2 pass is not run.
2642 ;; "&& 1" is needed to keep it from matching the previous pattern.
2644 [(set (match_operand:DI 0 "memory_operand" "")
2645 (match_operand:DI 1 "immediate_operand" ""))]
2646 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2647 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2648 [(set (match_dup 2) (match_dup 3))
2649 (set (match_dup 4) (match_dup 5))]
2650 "split_di (&operands[0], 2, &operands[2], &operands[4]);")
2653 [(set (match_operand:DI 0 "memory_operand" "")
2654 (match_operand:DI 1 "immediate_operand" ""))]
2655 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2656 ? epilogue_completed : reload_completed)
2657 && !symbolic_operand (operands[1], DImode)
2658 && !x86_64_immediate_operand (operands[1], DImode)"
2659 [(set (match_dup 2) (match_dup 3))
2660 (set (match_dup 4) (match_dup 5))]
2661 "split_di (&operands[0], 2, &operands[2], &operands[4]);")
2663 (define_insn "*swapdi_rex64"
2664 [(set (match_operand:DI 0 "register_operand" "+r")
2665 (match_operand:DI 1 "register_operand" "+r"))
2670 [(set_attr "type" "imov")
2671 (set_attr "mode" "DI")
2672 (set_attr "pent_pair" "np")
2673 (set_attr "athlon_decode" "vector")
2674 (set_attr "amdfam10_decode" "double")])
2676 (define_expand "movoi"
2677 [(set (match_operand:OI 0 "nonimmediate_operand" "")
2678 (match_operand:OI 1 "general_operand" ""))]
2680 "ix86_expand_move (OImode, operands); DONE;")
2682 (define_insn "*movoi_internal"
2683 [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
2684 (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
2686 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2688 switch (which_alternative)
2691 return "vxorps\t%0, %0, %0";
2694 if (misaligned_operand (operands[0], OImode)
2695 || misaligned_operand (operands[1], OImode))
2696 return "vmovdqu\t{%1, %0|%0, %1}";
2698 return "vmovdqa\t{%1, %0|%0, %1}";
2703 [(set_attr "type" "sselog1,ssemov,ssemov")
2704 (set_attr "prefix" "vex")
2705 (set_attr "mode" "OI")])
2707 (define_expand "movti"
2708 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2709 (match_operand:TI 1 "nonimmediate_operand" ""))]
2710 "TARGET_SSE || TARGET_64BIT"
2713 ix86_expand_move (TImode, operands);
2714 else if (push_operand (operands[0], TImode))
2715 ix86_expand_push (TImode, operands[1]);
2717 ix86_expand_vector_move (TImode, operands);
2721 (define_insn "*movti_internal"
2722 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
2723 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
2724 "TARGET_SSE && !TARGET_64BIT
2725 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2727 switch (which_alternative)
2730 if (get_attr_mode (insn) == MODE_V4SF)
2731 return "%vxorps\t%0, %d0";
2733 return "%vpxor\t%0, %d0";
2736 /* TDmode values are passed as TImode on the stack. Moving them
2737 to stack may result in unaligned memory access. */
2738 if (misaligned_operand (operands[0], TImode)
2739 || misaligned_operand (operands[1], TImode))
2741 if (get_attr_mode (insn) == MODE_V4SF)
2742 return "%vmovups\t{%1, %0|%0, %1}";
2744 return "%vmovdqu\t{%1, %0|%0, %1}";
2748 if (get_attr_mode (insn) == MODE_V4SF)
2749 return "%vmovaps\t{%1, %0|%0, %1}";
2751 return "%vmovdqa\t{%1, %0|%0, %1}";
2757 [(set_attr "type" "sselog1,ssemov,ssemov")
2758 (set_attr "prefix" "maybe_vex")
2760 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2761 (ne (symbol_ref "optimize_function_for_size_p (cfun)") (const_int 0)))
2762 (const_string "V4SF")
2763 (and (eq_attr "alternative" "2")
2764 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2766 (const_string "V4SF")]
2767 (const_string "TI")))])
2769 (define_insn "*movti_rex64"
2770 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
2771 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
2773 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2775 switch (which_alternative)
2781 if (get_attr_mode (insn) == MODE_V4SF)
2782 return "%vxorps\t%0, %d0";
2784 return "%vpxor\t%0, %d0";
2787 /* TDmode values are passed as TImode on the stack. Moving them
2788 to stack may result in unaligned memory access. */
2789 if (misaligned_operand (operands[0], TImode)
2790 || misaligned_operand (operands[1], TImode))
2792 if (get_attr_mode (insn) == MODE_V4SF)
2793 return "%vmovups\t{%1, %0|%0, %1}";
2795 return "%vmovdqu\t{%1, %0|%0, %1}";
2799 if (get_attr_mode (insn) == MODE_V4SF)
2800 return "%vmovaps\t{%1, %0|%0, %1}";
2802 return "%vmovdqa\t{%1, %0|%0, %1}";
2808 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
2809 (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
2811 (cond [(eq_attr "alternative" "2,3")
2813 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2815 (const_string "V4SF")
2816 (const_string "TI"))
2817 (eq_attr "alternative" "4")
2819 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2821 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2823 (const_string "V4SF")
2824 (const_string "TI"))]
2825 (const_string "DI")))])
2828 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2829 (match_operand:TI 1 "general_operand" ""))]
2830 "reload_completed && !SSE_REG_P (operands[0])
2831 && !SSE_REG_P (operands[1])"
2833 "ix86_split_long_move (operands); DONE;")
2835 ;; This expands to what emit_move_complex would generate if we didn't
2836 ;; have a movti pattern. Having this avoids problems with reload on
2837 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
2838 ;; to have around all the time.
2839 (define_expand "movcdi"
2840 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
2841 (match_operand:CDI 1 "general_operand" ""))]
2844 if (push_operand (operands[0], CDImode))
2845 emit_move_complex_push (CDImode, operands[0], operands[1]);
2847 emit_move_complex_parts (operands[0], operands[1]);
2851 (define_expand "movsf"
2852 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2853 (match_operand:SF 1 "general_operand" ""))]
2855 "ix86_expand_move (SFmode, operands); DONE;")
2857 (define_insn "*pushsf"
2858 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2859 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2862 /* Anything else should be already split before reg-stack. */
2863 gcc_assert (which_alternative == 1);
2864 return "push{l}\t%1";
2866 [(set_attr "type" "multi,push,multi")
2867 (set_attr "unit" "i387,*,*")
2868 (set_attr "mode" "SF,SI,SF")])
2870 (define_insn "*pushsf_rex64"
2871 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2872 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2875 /* Anything else should be already split before reg-stack. */
2876 gcc_assert (which_alternative == 1);
2877 return "push{q}\t%q1";
2879 [(set_attr "type" "multi,push,multi")
2880 (set_attr "unit" "i387,*,*")
2881 (set_attr "mode" "SF,DI,SF")])
2884 [(set (match_operand:SF 0 "push_operand" "")
2885 (match_operand:SF 1 "memory_operand" ""))]
2887 && MEM_P (operands[1])
2888 && (operands[2] = find_constant_src (insn))"
2892 ;; %%% Kill this when call knows how to work this out.
2894 [(set (match_operand:SF 0 "push_operand" "")
2895 (match_operand:SF 1 "any_fp_register_operand" ""))]
2897 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
2898 (set (mem:SF (reg:SI SP_REG)) (match_dup 1))])
2901 [(set (match_operand:SF 0 "push_operand" "")
2902 (match_operand:SF 1 "any_fp_register_operand" ""))]
2904 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (const_int -8)))
2905 (set (mem:SF (reg:DI SP_REG)) (match_dup 1))])
2907 (define_insn "*movsf_1"
2908 [(set (match_operand:SF 0 "nonimmediate_operand"
2909 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
2910 (match_operand:SF 1 "general_operand"
2911 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
2912 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2913 && (reload_in_progress || reload_completed
2914 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2915 || (!TARGET_SSE_MATH && optimize_function_for_size_p (cfun)
2916 && standard_80387_constant_p (operands[1]))
2917 || GET_CODE (operands[1]) != CONST_DOUBLE
2918 || memory_operand (operands[0], SFmode))"
2920 switch (which_alternative)
2924 return output_387_reg_move (insn, operands);
2927 return standard_80387_constant_opcode (operands[1]);
2931 return "mov{l}\t{%1, %0|%0, %1}";
2933 if (get_attr_mode (insn) == MODE_TI)
2934 return "%vpxor\t%0, %d0";
2936 return "%vxorps\t%0, %d0";
2938 if (get_attr_mode (insn) == MODE_V4SF)
2939 return "%vmovaps\t{%1, %0|%0, %1}";
2941 return "%vmovss\t{%1, %d0|%d0, %1}";
2944 return REG_P (operands[1]) ? "vmovss\t{%1, %0, %0|%0, %0, %1}"
2945 : "vmovss\t{%1, %0|%0, %1}";
2947 return "movss\t{%1, %0|%0, %1}";
2949 return "%vmovss\t{%1, %0|%0, %1}";
2951 case 9: case 10: case 14: case 15:
2952 return "movd\t{%1, %0|%0, %1}";
2954 return "%vmovd\t{%1, %0|%0, %1}";
2957 return "movq\t{%1, %0|%0, %1}";
2963 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
2964 (set (attr "prefix")
2965 (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
2966 (const_string "maybe_vex")
2967 (const_string "orig")))
2969 (cond [(eq_attr "alternative" "3,4,9,10")
2971 (eq_attr "alternative" "5")
2973 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2975 (ne (symbol_ref "TARGET_SSE2")
2977 (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2980 (const_string "V4SF"))
2981 /* For architectures resolving dependencies on
2982 whole SSE registers use APS move to break dependency
2983 chains, otherwise use short move to avoid extra work.
2985 Do the same for architectures resolving dependencies on
2986 the parts. While in DF mode it is better to always handle
2987 just register parts, the SF mode is different due to lack
2988 of instructions to load just part of the register. It is
2989 better to maintain the whole registers in single format
2990 to avoid problems on using packed logical operations. */
2991 (eq_attr "alternative" "6")
2993 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2995 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2997 (const_string "V4SF")
2998 (const_string "SF"))
2999 (eq_attr "alternative" "11")
3000 (const_string "DI")]
3001 (const_string "SF")))])
3003 (define_insn "*swapsf"
3004 [(set (match_operand:SF 0 "fp_register_operand" "+f")
3005 (match_operand:SF 1 "fp_register_operand" "+f"))
3008 "reload_completed || TARGET_80387"
3010 if (STACK_TOP_P (operands[0]))
3015 [(set_attr "type" "fxch")
3016 (set_attr "mode" "SF")])
3018 (define_expand "movdf"
3019 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3020 (match_operand:DF 1 "general_operand" ""))]
3022 "ix86_expand_move (DFmode, operands); DONE;")
3024 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
3025 ;; Size of pushdf using integer instructions is 2+2*memory operand size
3026 ;; On the average, pushdf using integers can be still shorter. Allow this
3027 ;; pattern for optimize_size too.
3029 (define_insn "*pushdf_nointeger"
3030 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
3031 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
3032 "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
3034 /* This insn should be already split before reg-stack. */
3037 [(set_attr "type" "multi")
3038 (set_attr "unit" "i387,*,*,*")
3039 (set_attr "mode" "DF,SI,SI,DF")])
3041 (define_insn "*pushdf_integer"
3042 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
3043 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
3044 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
3046 /* This insn should be already split before reg-stack. */
3049 [(set_attr "type" "multi")
3050 (set_attr "unit" "i387,*,*")
3051 (set_attr "mode" "DF,SI,DF")])
3053 ;; %%% Kill this when call knows how to work this out.
3055 [(set (match_operand:DF 0 "push_operand" "")
3056 (match_operand:DF 1 "any_fp_register_operand" ""))]
3058 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
3059 (set (mem:DF (reg:P SP_REG)) (match_dup 1))]
3063 [(set (match_operand:DF 0 "push_operand" "")
3064 (match_operand:DF 1 "general_operand" ""))]
3067 "ix86_split_long_move (operands); DONE;")
3069 ;; Moving is usually shorter when only FP registers are used. This separate
3070 ;; movdf pattern avoids the use of integer registers for FP operations
3071 ;; when optimizing for size.
3073 (define_insn "*movdf_nointeger"
3074 [(set (match_operand:DF 0 "nonimmediate_operand"
3075 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
3076 (match_operand:DF 1 "general_operand"
3077 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
3078 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3079 && ((optimize_function_for_size_p (cfun)
3080 || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
3081 && (reload_in_progress || reload_completed
3082 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3083 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3084 && optimize_function_for_size_p (cfun)
3085 && !memory_operand (operands[0], DFmode)
3086 && standard_80387_constant_p (operands[1]))
3087 || GET_CODE (operands[1]) != CONST_DOUBLE
3088 || ((optimize_function_for_size_p (cfun)
3089 || !TARGET_MEMORY_MISMATCH_STALL
3090 || reload_in_progress || reload_completed)
3091 && memory_operand (operands[0], DFmode)))"
3093 switch (which_alternative)
3097 return output_387_reg_move (insn, operands);
3100 return standard_80387_constant_opcode (operands[1]);
3106 switch (get_attr_mode (insn))
3109 return "%vxorps\t%0, %d0";
3111 return "%vxorpd\t%0, %d0";
3113 return "%vpxor\t%0, %d0";
3120 switch (get_attr_mode (insn))
3123 return "%vmovaps\t{%1, %0|%0, %1}";
3125 return "%vmovapd\t{%1, %0|%0, %1}";
3127 return "%vmovdqa\t{%1, %0|%0, %1}";
3129 return "%vmovq\t{%1, %0|%0, %1}";
3133 if (REG_P (operands[0]) && REG_P (operands[1]))
3134 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3136 return "vmovsd\t{%1, %0|%0, %1}";
3139 return "movsd\t{%1, %0|%0, %1}";
3143 if (REG_P (operands[0]))
3144 return "vmovlpd\t{%1, %0, %0|%0, %0, %1}";
3146 return "vmovlpd\t{%1, %0|%0, %1}";
3149 return "movlpd\t{%1, %0|%0, %1}";
3153 if (REG_P (operands[0]))
3154 return "vmovlps\t{%1, %0, %0|%0, %0, %1}";
3156 return "vmovlps\t{%1, %0|%0, %1}";
3159 return "movlps\t{%1, %0|%0, %1}";
3168 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3169 (set (attr "prefix")
3170 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3171 (const_string "orig")
3172 (const_string "maybe_vex")))
3173 (set (attr "prefix_data16")
3174 (if_then_else (eq_attr "mode" "V1DF")
3176 (const_string "*")))
3178 (cond [(eq_attr "alternative" "0,1,2")
3180 (eq_attr "alternative" "3,4")
3183 /* For SSE1, we have many fewer alternatives. */
3184 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3185 (cond [(eq_attr "alternative" "5,6")
3186 (const_string "V4SF")
3188 (const_string "V2SF"))
3190 /* xorps is one byte shorter. */
3191 (eq_attr "alternative" "5")
3192 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3194 (const_string "V4SF")
3195 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3199 (const_string "V2DF"))
3201 /* For architectures resolving dependencies on
3202 whole SSE registers use APD move to break dependency
3203 chains, otherwise use short move to avoid extra work.
3205 movaps encodes one byte shorter. */
3206 (eq_attr "alternative" "6")
3208 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3210 (const_string "V4SF")
3211 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3213 (const_string "V2DF")
3215 (const_string "DF"))
3216 /* For architectures resolving dependencies on register
3217 parts we may avoid extra work to zero out upper part
3219 (eq_attr "alternative" "7")
3221 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3223 (const_string "V1DF")
3224 (const_string "DF"))
3226 (const_string "DF")))])
3228 (define_insn "*movdf_integer_rex64"
3229 [(set (match_operand:DF 0 "nonimmediate_operand"
3230 "=f,m,f,r ,m ,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
3231 (match_operand:DF 1 "general_operand"
3232 "fm,f,G,rmF,Fr,C ,Y2*x,m ,Y2*x,r ,Yi"))]
3233 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3234 && (reload_in_progress || reload_completed
3235 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3236 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3237 && optimize_function_for_size_p (cfun)
3238 && standard_80387_constant_p (operands[1]))
3239 || GET_CODE (operands[1]) != CONST_DOUBLE
3240 || memory_operand (operands[0], DFmode))"
3242 switch (which_alternative)
3246 return output_387_reg_move (insn, operands);
3249 return standard_80387_constant_opcode (operands[1]);
3256 switch (get_attr_mode (insn))
3259 return "%vxorps\t%0, %d0";
3261 return "%vxorpd\t%0, %d0";
3263 return "%vpxor\t%0, %d0";
3270 switch (get_attr_mode (insn))
3273 return "%vmovaps\t{%1, %0|%0, %1}";
3275 return "%vmovapd\t{%1, %0|%0, %1}";
3277 return "%vmovdqa\t{%1, %0|%0, %1}";
3279 return "%vmovq\t{%1, %0|%0, %1}";
3283 if (REG_P (operands[0]) && REG_P (operands[1]))
3284 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3286 return "vmovsd\t{%1, %0|%0, %1}";
3289 return "movsd\t{%1, %0|%0, %1}";
3291 return "%vmovlpd\t{%1, %d0|%d0, %1}";
3293 return "%vmovlps\t{%1, %d0|%d0, %1}";
3300 return "%vmovd\t{%1, %0|%0, %1}";
3306 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
3307 (set (attr "prefix")
3308 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3309 (const_string "orig")
3310 (const_string "maybe_vex")))
3311 (set (attr "prefix_data16")
3312 (if_then_else (eq_attr "mode" "V1DF")
3314 (const_string "*")))
3316 (cond [(eq_attr "alternative" "0,1,2")
3318 (eq_attr "alternative" "3,4,9,10")
3321 /* For SSE1, we have many fewer alternatives. */
3322 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3323 (cond [(eq_attr "alternative" "5,6")
3324 (const_string "V4SF")
3326 (const_string "V2SF"))
3328 /* xorps is one byte shorter. */
3329 (eq_attr "alternative" "5")
3330 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3332 (const_string "V4SF")
3333 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3337 (const_string "V2DF"))
3339 /* For architectures resolving dependencies on
3340 whole SSE registers use APD move to break dependency
3341 chains, otherwise use short move to avoid extra work.
3343 movaps encodes one byte shorter. */
3344 (eq_attr "alternative" "6")
3346 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3348 (const_string "V4SF")
3349 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3351 (const_string "V2DF")
3353 (const_string "DF"))
3354 /* For architectures resolving dependencies on register
3355 parts we may avoid extra work to zero out upper part
3357 (eq_attr "alternative" "7")
3359 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3361 (const_string "V1DF")
3362 (const_string "DF"))
3364 (const_string "DF")))])
3366 (define_insn "*movdf_integer"
3367 [(set (match_operand:DF 0 "nonimmediate_operand"
3368 "=f,m,f,r ,o ,Y2*x,Y2*x,Y2*x,m ")
3369 (match_operand:DF 1 "general_operand"
3370 "fm,f,G,roF,Fr,C ,Y2*x,m ,Y2*x"))]
3371 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3372 && optimize_function_for_speed_p (cfun)
3373 && TARGET_INTEGER_DFMODE_MOVES
3374 && (reload_in_progress || reload_completed
3375 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3376 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3377 && optimize_function_for_size_p (cfun)
3378 && standard_80387_constant_p (operands[1]))
3379 || GET_CODE (operands[1]) != CONST_DOUBLE
3380 || memory_operand (operands[0], DFmode))"
3382 switch (which_alternative)
3386 return output_387_reg_move (insn, operands);
3389 return standard_80387_constant_opcode (operands[1]);
3396 switch (get_attr_mode (insn))
3399 return "xorps\t%0, %0";
3401 return "xorpd\t%0, %0";
3403 return "pxor\t%0, %0";
3410 switch (get_attr_mode (insn))
3413 return "movaps\t{%1, %0|%0, %1}";
3415 return "movapd\t{%1, %0|%0, %1}";
3417 return "movdqa\t{%1, %0|%0, %1}";
3419 return "movq\t{%1, %0|%0, %1}";
3421 return "movsd\t{%1, %0|%0, %1}";
3423 return "movlpd\t{%1, %0|%0, %1}";
3425 return "movlps\t{%1, %0|%0, %1}";
3434 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3435 (set (attr "prefix_data16")
3436 (if_then_else (eq_attr "mode" "V1DF")
3438 (const_string "*")))
3440 (cond [(eq_attr "alternative" "0,1,2")
3442 (eq_attr "alternative" "3,4")
3445 /* For SSE1, we have many fewer alternatives. */
3446 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3447 (cond [(eq_attr "alternative" "5,6")
3448 (const_string "V4SF")
3450 (const_string "V2SF"))
3452 /* xorps is one byte shorter. */
3453 (eq_attr "alternative" "5")
3454 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3456 (const_string "V4SF")
3457 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3461 (const_string "V2DF"))
3463 /* For architectures resolving dependencies on
3464 whole SSE registers use APD move to break dependency
3465 chains, otherwise use short move to avoid extra work.
3467 movaps encodes one byte shorter. */
3468 (eq_attr "alternative" "6")
3470 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3472 (const_string "V4SF")
3473 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3475 (const_string "V2DF")
3477 (const_string "DF"))
3478 /* For architectures resolving dependencies on register
3479 parts we may avoid extra work to zero out upper part
3481 (eq_attr "alternative" "7")
3483 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3485 (const_string "V1DF")
3486 (const_string "DF"))
3488 (const_string "DF")))])
3491 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3492 (match_operand:DF 1 "general_operand" ""))]
3494 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3495 && ! (ANY_FP_REG_P (operands[0]) ||
3496 (GET_CODE (operands[0]) == SUBREG
3497 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3498 && ! (ANY_FP_REG_P (operands[1]) ||
3499 (GET_CODE (operands[1]) == SUBREG
3500 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3502 "ix86_split_long_move (operands); DONE;")
3504 (define_insn "*swapdf"
3505 [(set (match_operand:DF 0 "fp_register_operand" "+f")
3506 (match_operand:DF 1 "fp_register_operand" "+f"))
3509 "reload_completed || TARGET_80387"
3511 if (STACK_TOP_P (operands[0]))
3516 [(set_attr "type" "fxch")
3517 (set_attr "mode" "DF")])
3519 (define_expand "movxf"
3520 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3521 (match_operand:XF 1 "general_operand" ""))]
3523 "ix86_expand_move (XFmode, operands); DONE;")
3525 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
3526 ;; Size of pushdf using integer instructions is 3+3*memory operand size
3527 ;; Pushing using integer instructions is longer except for constants
3528 ;; and direct memory references.
3529 ;; (assuming that any given constant is pushed only once, but this ought to be
3530 ;; handled elsewhere).
3532 (define_insn "*pushxf_nointeger"
3533 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
3534 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
3535 "optimize_function_for_size_p (cfun)"
3537 /* This insn should be already split before reg-stack. */
3540 [(set_attr "type" "multi")
3541 (set_attr "unit" "i387,*,*")
3542 (set_attr "mode" "XF,SI,SI")])
3544 (define_insn "*pushxf_integer"
3545 [(set (match_operand:XF 0 "push_operand" "=<,<")
3546 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
3547 "optimize_function_for_speed_p (cfun)"
3549 /* This insn should be already split before reg-stack. */
3552 [(set_attr "type" "multi")
3553 (set_attr "unit" "i387,*")
3554 (set_attr "mode" "XF,SI")])
3557 [(set (match_operand 0 "push_operand" "")
3558 (match_operand 1 "general_operand" ""))]
3560 && (GET_MODE (operands[0]) == XFmode
3561 || GET_MODE (operands[0]) == DFmode)
3562 && !ANY_FP_REG_P (operands[1])"
3564 "ix86_split_long_move (operands); DONE;")
3567 [(set (match_operand:XF 0 "push_operand" "")
3568 (match_operand:XF 1 "any_fp_register_operand" ""))]
3570 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
3571 (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
3572 "operands[2] = GEN_INT (TARGET_128BIT_LONG_DOUBLE ? -16 : -12);")
3574 ;; Do not use integer registers when optimizing for size
3575 (define_insn "*movxf_nointeger"
3576 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
3577 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
3578 "optimize_function_for_size_p (cfun)
3579 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3580 && (reload_in_progress || reload_completed
3581 || standard_80387_constant_p (operands[1])
3582 || GET_CODE (operands[1]) != CONST_DOUBLE
3583 || memory_operand (operands[0], XFmode))"
3585 switch (which_alternative)
3589 return output_387_reg_move (insn, operands);
3592 return standard_80387_constant_opcode (operands[1]);
3600 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3601 (set_attr "mode" "XF,XF,XF,SI,SI")])
3603 (define_insn "*movxf_integer"
3604 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,r,o")
3605 (match_operand:XF 1 "general_operand" "fm,f,G,roF,Fr"))]
3606 "optimize_function_for_speed_p (cfun)
3607 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3608 && (reload_in_progress || reload_completed
3609 || GET_CODE (operands[1]) != CONST_DOUBLE
3610 || memory_operand (operands[0], XFmode))"
3612 switch (which_alternative)
3616 return output_387_reg_move (insn, operands);
3619 return standard_80387_constant_opcode (operands[1]);
3628 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3629 (set_attr "mode" "XF,XF,XF,SI,SI")])
3631 (define_expand "movtf"
3632 [(set (match_operand:TF 0 "nonimmediate_operand" "")
3633 (match_operand:TF 1 "nonimmediate_operand" ""))]
3636 ix86_expand_move (TFmode, operands);
3640 (define_insn "*movtf_internal"
3641 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?r,?o")
3642 (match_operand:TF 1 "general_operand" "xm,x,C,roF,Fr"))]
3644 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
3646 switch (which_alternative)
3650 if (get_attr_mode (insn) == MODE_V4SF)
3651 return "%vmovaps\t{%1, %0|%0, %1}";
3653 return "%vmovdqa\t{%1, %0|%0, %1}";
3655 if (get_attr_mode (insn) == MODE_V4SF)
3656 return "%vxorps\t%0, %d0";
3658 return "%vpxor\t%0, %d0";
3666 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
3667 (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,*,*")
3669 (cond [(eq_attr "alternative" "0,2")
3671 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
3673 (const_string "V4SF")
3674 (const_string "TI"))
3675 (eq_attr "alternative" "1")
3677 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
3679 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
3681 (const_string "V4SF")
3682 (const_string "TI"))]
3683 (const_string "DI")))])
3685 (define_insn "*pushtf_sse"
3686 [(set (match_operand:TF 0 "push_operand" "=<,<,<")
3687 (match_operand:TF 1 "general_no_elim_operand" "x,Fo,*r"))]
3690 /* This insn should be already split before reg-stack. */
3693 [(set_attr "type" "multi")
3694 (set_attr "unit" "sse,*,*")
3695 (set_attr "mode" "TF,SI,SI")])
3698 [(set (match_operand:TF 0 "push_operand" "")
3699 (match_operand:TF 1 "general_operand" ""))]
3700 "TARGET_SSE2 && reload_completed
3701 && !SSE_REG_P (operands[1])"
3703 "ix86_split_long_move (operands); DONE;")
3706 [(set (match_operand:TF 0 "push_operand" "")
3707 (match_operand:TF 1 "any_fp_register_operand" ""))]
3709 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
3710 (set (mem:TF (reg:P SP_REG)) (match_dup 1))]
3714 [(set (match_operand 0 "nonimmediate_operand" "")
3715 (match_operand 1 "general_operand" ""))]
3717 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3718 && GET_MODE (operands[0]) == XFmode
3719 && ! (ANY_FP_REG_P (operands[0]) ||
3720 (GET_CODE (operands[0]) == SUBREG
3721 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3722 && ! (ANY_FP_REG_P (operands[1]) ||
3723 (GET_CODE (operands[1]) == SUBREG
3724 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3726 "ix86_split_long_move (operands); DONE;")
3729 [(set (match_operand 0 "register_operand" "")
3730 (match_operand 1 "memory_operand" ""))]
3732 && MEM_P (operands[1])
3733 && (GET_MODE (operands[0]) == TFmode
3734 || GET_MODE (operands[0]) == XFmode
3735 || GET_MODE (operands[0]) == SFmode
3736 || GET_MODE (operands[0]) == DFmode)
3737 && (operands[2] = find_constant_src (insn))"
3738 [(set (match_dup 0) (match_dup 2))]
3740 rtx c = operands[2];
3741 rtx r = operands[0];
3743 if (GET_CODE (r) == SUBREG)
3748 if (!standard_sse_constant_p (c))
3751 else if (FP_REG_P (r))
3753 if (!standard_80387_constant_p (c))
3756 else if (MMX_REG_P (r))
3761 [(set (match_operand 0 "register_operand" "")
3762 (float_extend (match_operand 1 "memory_operand" "")))]
3764 && MEM_P (operands[1])
3765 && (GET_MODE (operands[0]) == TFmode
3766 || GET_MODE (operands[0]) == XFmode
3767 || GET_MODE (operands[0]) == SFmode
3768 || GET_MODE (operands[0]) == DFmode)
3769 && (operands[2] = find_constant_src (insn))"
3770 [(set (match_dup 0) (match_dup 2))]
3772 rtx c = operands[2];
3773 rtx r = operands[0];
3775 if (GET_CODE (r) == SUBREG)
3780 if (!standard_sse_constant_p (c))
3783 else if (FP_REG_P (r))
3785 if (!standard_80387_constant_p (c))
3788 else if (MMX_REG_P (r))
3792 (define_insn "swapxf"
3793 [(set (match_operand:XF 0 "register_operand" "+f")
3794 (match_operand:XF 1 "register_operand" "+f"))
3799 if (STACK_TOP_P (operands[0]))
3804 [(set_attr "type" "fxch")
3805 (set_attr "mode" "XF")])
3807 ;; Split the load of -0.0 or -1.0 into fldz;fchs or fld1;fchs sequence
3809 [(set (match_operand:X87MODEF 0 "register_operand" "")
3810 (match_operand:X87MODEF 1 "immediate_operand" ""))]
3811 "reload_completed && FP_REGNO_P (REGNO (operands[0]))
3812 && (standard_80387_constant_p (operands[1]) == 8
3813 || standard_80387_constant_p (operands[1]) == 9)"
3814 [(set (match_dup 0)(match_dup 1))
3816 (neg:X87MODEF (match_dup 0)))]
3820 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
3821 if (real_isnegzero (&r))
3822 operands[1] = CONST0_RTX (<MODE>mode);
3824 operands[1] = CONST1_RTX (<MODE>mode);
3828 [(set (match_operand:TF 0 "nonimmediate_operand" "")
3829 (match_operand:TF 1 "general_operand" ""))]
3831 && !(SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]))"
3833 "ix86_split_long_move (operands); DONE;")
3835 ;; Zero extension instructions
3837 (define_expand "zero_extendhisi2"
3838 [(set (match_operand:SI 0 "register_operand" "")
3839 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3842 if (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3844 operands[1] = force_reg (HImode, operands[1]);
3845 emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3850 (define_insn "zero_extendhisi2_and"
3851 [(set (match_operand:SI 0 "register_operand" "=r")
3852 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3853 (clobber (reg:CC FLAGS_REG))]
3854 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3856 [(set_attr "type" "alu1")
3857 (set_attr "mode" "SI")])
3860 [(set (match_operand:SI 0 "register_operand" "")
3861 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))
3862 (clobber (reg:CC FLAGS_REG))]
3863 "reload_completed && TARGET_ZERO_EXTEND_WITH_AND
3864 && optimize_function_for_speed_p (cfun)"
3865 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3866 (clobber (reg:CC FLAGS_REG))])]
3869 (define_insn "*zero_extendhisi2_movzwl"
3870 [(set (match_operand:SI 0 "register_operand" "=r")
3871 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3872 "!TARGET_ZERO_EXTEND_WITH_AND
3873 || optimize_function_for_size_p (cfun)"
3874 "movz{wl|x}\t{%1, %0|%0, %1}"
3875 [(set_attr "type" "imovx")
3876 (set_attr "mode" "SI")])
3878 (define_expand "zero_extendqihi2"
3880 [(set (match_operand:HI 0 "register_operand" "")
3881 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3882 (clobber (reg:CC FLAGS_REG))])]
3886 (define_insn "*zero_extendqihi2_and"