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, 2011
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).
62 ;; @ -- print a segment register of thread base pointer load
66 (define_c_enum "unspec" [
67 ;; Relocation specifiers
78 UNSPEC_MACHOPIC_OFFSET
88 UNSPEC_MEMORY_BLOCKAGE
98 ;; Other random patterns
107 UNSPEC_LD_MPIC ; load_macho_picbase
109 UNSPEC_DIV_ALREADY_SPLIT
110 UNSPEC_CALL_NEEDS_VZEROUPPER
112 ;; For SSE/MMX support:
130 UNSPEC_MS_TO_SYSV_CALL
132 ;; Generic math support
134 UNSPEC_IEEE_MIN ; not commutative
135 UNSPEC_IEEE_MAX ; not commutative
137 ;; x87 Floating point
153 UNSPEC_FRNDINT_MASK_PM
157 ;; x87 Double output FP
189 ;; For SSE4.1 support
199 ;; For SSE4.2 support
206 UNSPEC_XOP_UNSIGNED_CMP
217 UNSPEC_AESKEYGENASSIST
219 ;; For PCLMUL support
237 ;; For RDRAND support
241 (define_c_enum "unspecv" [
244 UNSPECV_PROBE_STACK_RANGE
264 UNSPECV_LLWP_INTRINSIC
265 UNSPECV_SLWP_INTRINSIC
266 UNSPECV_LWPVAL_INTRINSIC
267 UNSPECV_LWPINS_INTRINSIC
272 UNSPECV_SPLIT_STACK_RETURN
275 ;; Constants to represent rounding modes in the ROUND instruction
284 ;; Constants to represent pcomtrue/pcomfalse variants
294 ;; Constants used in the XOP pperm instruction
296 [(PPERM_SRC 0x00) /* copy source */
297 (PPERM_INVERT 0x20) /* invert source */
298 (PPERM_REVERSE 0x40) /* bit reverse source */
299 (PPERM_REV_INV 0x60) /* bit reverse & invert src */
300 (PPERM_ZERO 0x80) /* all 0's */
301 (PPERM_ONES 0xa0) /* all 1's */
302 (PPERM_SIGN 0xc0) /* propagate sign bit */
303 (PPERM_INV_SIGN 0xe0) /* invert & propagate sign */
304 (PPERM_SRC1 0x00) /* use first source byte */
305 (PPERM_SRC2 0x10) /* use second source byte */
308 ;; Registers by name.
361 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
364 ;; In C guard expressions, put expressions which may be compile-time
365 ;; constants first. This allows for better optimization. For
366 ;; example, write "TARGET_64BIT && reload_completed", not
367 ;; "reload_completed && TARGET_64BIT".
371 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,corei7,
372 atom,generic64,amdfam10,bdver1,btver1"
373 (const (symbol_ref "ix86_schedule")))
375 ;; A basic instruction type. Refinements due to arguments to be
376 ;; provided in other attributes.
379 alu,alu1,negnot,imov,imovx,lea,
380 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
381 icmp,test,ibr,setcc,icmov,
382 push,pop,call,callv,leave,
384 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
385 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
386 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
387 ssemuladd,sse4arg,lwp,
388 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
389 (const_string "other"))
391 ;; Main data type used by the insn
393 "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
394 (const_string "unknown"))
396 ;; The CPU unit operations uses.
397 (define_attr "unit" "integer,i387,sse,mmx,unknown"
398 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
399 (const_string "i387")
400 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
401 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
402 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
404 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
406 (eq_attr "type" "other")
407 (const_string "unknown")]
408 (const_string "integer")))
410 ;; The (bounding maximum) length of an instruction immediate.
411 (define_attr "length_immediate" ""
412 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
415 (eq_attr "unit" "i387,sse,mmx")
417 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
419 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
420 (eq_attr "type" "imov,test")
421 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
422 (eq_attr "type" "call")
423 (if_then_else (match_operand 0 "constant_call_address_operand" "")
426 (eq_attr "type" "callv")
427 (if_then_else (match_operand 1 "constant_call_address_operand" "")
430 ;; We don't know the size before shorten_branches. Expect
431 ;; the instruction to fit for better scheduling.
432 (eq_attr "type" "ibr")
435 (symbol_ref "/* Update immediate_length and other attributes! */
436 gcc_unreachable (),1")))
438 ;; The (bounding maximum) length of an instruction address.
439 (define_attr "length_address" ""
440 (cond [(eq_attr "type" "str,other,multi,fxch")
442 (and (eq_attr "type" "call")
443 (match_operand 0 "constant_call_address_operand" ""))
445 (and (eq_attr "type" "callv")
446 (match_operand 1 "constant_call_address_operand" ""))
449 (symbol_ref "ix86_attr_length_address_default (insn)")))
451 ;; Set when length prefix is used.
452 (define_attr "prefix_data16" ""
453 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
455 (eq_attr "mode" "HI")
457 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
462 ;; Set when string REP prefix is used.
463 (define_attr "prefix_rep" ""
464 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
466 (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
471 ;; Set when 0f opcode prefix is used.
472 (define_attr "prefix_0f" ""
474 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
475 (eq_attr "unit" "sse,mmx"))
479 ;; Set when REX opcode prefix is used.
480 (define_attr "prefix_rex" ""
481 (cond [(eq (symbol_ref "TARGET_64BIT") (const_int 0))
483 (and (eq_attr "mode" "DI")
484 (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
485 (eq_attr "unit" "!mmx")))
487 (and (eq_attr "mode" "QI")
488 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
491 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
494 (and (eq_attr "type" "imovx")
495 (match_operand:QI 1 "ext_QIreg_operand" ""))
500 ;; There are also additional prefixes in 3DNOW, SSSE3.
501 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
502 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
503 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
504 (define_attr "prefix_extra" ""
505 (cond [(eq_attr "type" "ssemuladd,sse4arg")
507 (eq_attr "type" "sseiadd1,ssecvt1")
512 ;; Prefix used: original, VEX or maybe VEX.
513 (define_attr "prefix" "orig,vex,maybe_vex"
514 (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
516 (const_string "orig")))
518 ;; VEX W bit is used.
519 (define_attr "prefix_vex_w" "" (const_int 0))
521 ;; The length of VEX prefix
522 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
523 ;; 0f38/0f3a prefixes can't. In i386.md 0f3[8a] is
524 ;; still prefix_0f 1, with prefix_extra 1.
525 (define_attr "length_vex" ""
526 (if_then_else (and (eq_attr "prefix_0f" "1")
527 (eq_attr "prefix_extra" "0"))
528 (if_then_else (eq_attr "prefix_vex_w" "1")
529 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 1)")
530 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 0)"))
531 (if_then_else (eq_attr "prefix_vex_w" "1")
532 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 1)")
533 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 0)"))))
535 ;; Set when modrm byte is used.
536 (define_attr "modrm" ""
537 (cond [(eq_attr "type" "str,leave")
539 (eq_attr "unit" "i387")
541 (and (eq_attr "type" "incdec")
542 (and (eq (symbol_ref "TARGET_64BIT") (const_int 0))
543 (ior (match_operand:SI 1 "register_operand" "")
544 (match_operand:HI 1 "register_operand" ""))))
546 (and (eq_attr "type" "push")
547 (not (match_operand 1 "memory_operand" "")))
549 (and (eq_attr "type" "pop")
550 (not (match_operand 0 "memory_operand" "")))
552 (and (eq_attr "type" "imov")
553 (and (not (eq_attr "mode" "DI"))
554 (ior (and (match_operand 0 "register_operand" "")
555 (match_operand 1 "immediate_operand" ""))
556 (ior (and (match_operand 0 "ax_reg_operand" "")
557 (match_operand 1 "memory_displacement_only_operand" ""))
558 (and (match_operand 0 "memory_displacement_only_operand" "")
559 (match_operand 1 "ax_reg_operand" ""))))))
561 (and (eq_attr "type" "call")
562 (match_operand 0 "constant_call_address_operand" ""))
564 (and (eq_attr "type" "callv")
565 (match_operand 1 "constant_call_address_operand" ""))
567 (and (eq_attr "type" "alu,alu1,icmp,test")
568 (match_operand 0 "ax_reg_operand" ""))
569 (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
573 ;; The (bounding maximum) length of an instruction in bytes.
574 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
575 ;; Later we may want to split them and compute proper length as for
577 (define_attr "length" ""
578 (cond [(eq_attr "type" "other,multi,fistp,frndint")
580 (eq_attr "type" "fcmp")
582 (eq_attr "unit" "i387")
584 (plus (attr "prefix_data16")
585 (attr "length_address")))
586 (ior (eq_attr "prefix" "vex")
587 (and (eq_attr "prefix" "maybe_vex")
588 (ne (symbol_ref "TARGET_AVX") (const_int 0))))
589 (plus (attr "length_vex")
590 (plus (attr "length_immediate")
592 (attr "length_address"))))]
593 (plus (plus (attr "modrm")
594 (plus (attr "prefix_0f")
595 (plus (attr "prefix_rex")
596 (plus (attr "prefix_extra")
598 (plus (attr "prefix_rep")
599 (plus (attr "prefix_data16")
600 (plus (attr "length_immediate")
601 (attr "length_address")))))))
603 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
604 ;; `store' if there is a simple memory reference therein, or `unknown'
605 ;; if the instruction is complex.
607 (define_attr "memory" "none,load,store,both,unknown"
608 (cond [(eq_attr "type" "other,multi,str,lwp")
609 (const_string "unknown")
610 (eq_attr "type" "lea,fcmov,fpspc")
611 (const_string "none")
612 (eq_attr "type" "fistp,leave")
613 (const_string "both")
614 (eq_attr "type" "frndint")
615 (const_string "load")
616 (eq_attr "type" "push")
617 (if_then_else (match_operand 1 "memory_operand" "")
618 (const_string "both")
619 (const_string "store"))
620 (eq_attr "type" "pop")
621 (if_then_else (match_operand 0 "memory_operand" "")
622 (const_string "both")
623 (const_string "load"))
624 (eq_attr "type" "setcc")
625 (if_then_else (match_operand 0 "memory_operand" "")
626 (const_string "store")
627 (const_string "none"))
628 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
629 (if_then_else (ior (match_operand 0 "memory_operand" "")
630 (match_operand 1 "memory_operand" ""))
631 (const_string "load")
632 (const_string "none"))
633 (eq_attr "type" "ibr")
634 (if_then_else (match_operand 0 "memory_operand" "")
635 (const_string "load")
636 (const_string "none"))
637 (eq_attr "type" "call")
638 (if_then_else (match_operand 0 "constant_call_address_operand" "")
639 (const_string "none")
640 (const_string "load"))
641 (eq_attr "type" "callv")
642 (if_then_else (match_operand 1 "constant_call_address_operand" "")
643 (const_string "none")
644 (const_string "load"))
645 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
646 (match_operand 1 "memory_operand" ""))
647 (const_string "both")
648 (and (match_operand 0 "memory_operand" "")
649 (match_operand 1 "memory_operand" ""))
650 (const_string "both")
651 (match_operand 0 "memory_operand" "")
652 (const_string "store")
653 (match_operand 1 "memory_operand" "")
654 (const_string "load")
656 "!alu1,negnot,ishift1,
657 imov,imovx,icmp,test,bitmanip,
659 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
660 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
661 (match_operand 2 "memory_operand" ""))
662 (const_string "load")
663 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
664 (match_operand 3 "memory_operand" ""))
665 (const_string "load")
667 (const_string "none")))
669 ;; Indicates if an instruction has both an immediate and a displacement.
671 (define_attr "imm_disp" "false,true,unknown"
672 (cond [(eq_attr "type" "other,multi")
673 (const_string "unknown")
674 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
675 (and (match_operand 0 "memory_displacement_operand" "")
676 (match_operand 1 "immediate_operand" "")))
677 (const_string "true")
678 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
679 (and (match_operand 0 "memory_displacement_operand" "")
680 (match_operand 2 "immediate_operand" "")))
681 (const_string "true")
683 (const_string "false")))
685 ;; Indicates if an FP operation has an integer source.
687 (define_attr "fp_int_src" "false,true"
688 (const_string "false"))
690 ;; Defines rounding mode of an FP operation.
692 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
693 (const_string "any"))
695 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
696 (define_attr "use_carry" "0,1" (const_string "0"))
698 ;; Define attribute to indicate unaligned ssemov insns
699 (define_attr "movu" "0,1" (const_string "0"))
701 ;; Describe a user's asm statement.
702 (define_asm_attributes
703 [(set_attr "length" "128")
704 (set_attr "type" "multi")])
706 (define_code_iterator plusminus [plus minus])
708 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
710 ;; Base name for define_insn
711 (define_code_attr plusminus_insn
712 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
713 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
715 ;; Base name for insn mnemonic.
716 (define_code_attr plusminus_mnemonic
717 [(plus "add") (ss_plus "adds") (us_plus "addus")
718 (minus "sub") (ss_minus "subs") (us_minus "subus")])
719 (define_code_attr plusminus_carry_mnemonic
720 [(plus "adc") (minus "sbb")])
722 ;; Mark commutative operators as such in constraints.
723 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
724 (minus "") (ss_minus "") (us_minus "")])
726 ;; Mapping of signed max and min
727 (define_code_iterator smaxmin [smax smin])
729 ;; Mapping of unsigned max and min
730 (define_code_iterator umaxmin [umax umin])
732 ;; Base name for integer and FP insn mnemonic
733 (define_code_attr maxmin_int [(smax "maxs") (smin "mins")
734 (umax "maxu") (umin "minu")])
735 (define_code_attr maxmin_float [(smax "max") (smin "min")])
737 ;; Mapping of logic operators
738 (define_code_iterator any_logic [and ior xor])
739 (define_code_iterator any_or [ior xor])
741 ;; Base name for insn mnemonic.
742 (define_code_attr logic [(and "and") (ior "or") (xor "xor")])
744 ;; Mapping of shift-right operators
745 (define_code_iterator any_shiftrt [lshiftrt ashiftrt])
747 ;; Base name for define_insn
748 (define_code_attr shiftrt_insn [(lshiftrt "lshr") (ashiftrt "ashr")])
750 ;; Base name for insn mnemonic.
751 (define_code_attr shiftrt [(lshiftrt "shr") (ashiftrt "sar")])
753 ;; Mapping of rotate operators
754 (define_code_iterator any_rotate [rotate rotatert])
756 ;; Base name for define_insn
757 (define_code_attr rotate_insn [(rotate "rotl") (rotatert "rotr")])
759 ;; Base name for insn mnemonic.
760 (define_code_attr rotate [(rotate "rol") (rotatert "ror")])
762 ;; Mapping of abs neg operators
763 (define_code_iterator absneg [abs neg])
765 ;; Base name for x87 insn mnemonic.
766 (define_code_attr absneg_mnemonic [(abs "abs") (neg "chs")])
768 ;; Used in signed and unsigned widening multiplications.
769 (define_code_iterator any_extend [sign_extend zero_extend])
771 ;; Various insn prefixes for signed and unsigned operations.
772 (define_code_attr u [(sign_extend "") (zero_extend "u")
773 (div "") (udiv "u")])
774 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
776 ;; Used in signed and unsigned divisions.
777 (define_code_iterator any_div [div udiv])
779 ;; Instruction prefix for signed and unsigned operations.
780 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")
781 (div "i") (udiv "")])
783 ;; 64bit single word integer modes.
784 (define_mode_iterator SWI1248x [QI HI SI DI])
786 ;; 64bit single word integer modes without QImode and HImode.
787 (define_mode_iterator SWI48x [SI DI])
789 ;; Single word integer modes.
790 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
792 ;; Single word integer modes without SImode and DImode.
793 (define_mode_iterator SWI12 [QI HI])
795 ;; Single word integer modes without DImode.
796 (define_mode_iterator SWI124 [QI HI SI])
798 ;; Single word integer modes without QImode and DImode.
799 (define_mode_iterator SWI24 [HI SI])
801 ;; Single word integer modes without QImode.
802 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
804 ;; Single word integer modes without QImode and HImode.
805 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
807 ;; All math-dependant single and double word integer modes.
808 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
809 (HI "TARGET_HIMODE_MATH")
810 SI DI (TI "TARGET_64BIT")])
812 ;; Math-dependant single word integer modes.
813 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
814 (HI "TARGET_HIMODE_MATH")
815 SI (DI "TARGET_64BIT")])
817 ;; Math-dependant single word integer modes without DImode.
818 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
819 (HI "TARGET_HIMODE_MATH")
822 ;; Math-dependant single word integer modes without QImode.
823 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
824 SI (DI "TARGET_64BIT")])
826 ;; Double word integer modes.
827 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
828 (TI "TARGET_64BIT")])
830 ;; Double word integer modes as mode attribute.
831 (define_mode_attr DWI [(SI "DI") (DI "TI")])
832 (define_mode_attr dwi [(SI "di") (DI "ti")])
834 ;; Half mode for double word integer modes.
835 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
836 (DI "TARGET_64BIT")])
838 ;; Instruction suffix for integer modes.
839 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
841 ;; Pointer size prefix for integer modes (Intel asm dialect)
842 (define_mode_attr iptrsize [(QI "BYTE")
847 ;; Register class for integer modes.
848 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
850 ;; Immediate operand constraint for integer modes.
851 (define_mode_attr i [(QI "n") (HI "n") (SI "i") (DI "e")])
853 ;; General operand constraint for word modes.
854 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "g") (DI "rme")])
856 ;; Immediate operand constraint for double integer modes.
857 (define_mode_attr di [(SI "iF") (DI "e")])
859 ;; Immediate operand constraint for shifts.
860 (define_mode_attr S [(QI "I") (HI "I") (SI "I") (DI "J") (TI "O")])
862 ;; General operand predicate for integer modes.
863 (define_mode_attr general_operand
864 [(QI "general_operand")
865 (HI "general_operand")
866 (SI "general_operand")
867 (DI "x86_64_general_operand")
868 (TI "x86_64_general_operand")])
870 ;; General sign/zero extend operand predicate for integer modes.
871 (define_mode_attr general_szext_operand
872 [(QI "general_operand")
873 (HI "general_operand")
874 (SI "general_operand")
875 (DI "x86_64_szext_general_operand")])
877 ;; Immediate operand predicate for integer modes.
878 (define_mode_attr immediate_operand
879 [(QI "immediate_operand")
880 (HI "immediate_operand")
881 (SI "immediate_operand")
882 (DI "x86_64_immediate_operand")])
884 ;; Nonmemory operand predicate for integer modes.
885 (define_mode_attr nonmemory_operand
886 [(QI "nonmemory_operand")
887 (HI "nonmemory_operand")
888 (SI "nonmemory_operand")
889 (DI "x86_64_nonmemory_operand")])
891 ;; Operand predicate for shifts.
892 (define_mode_attr shift_operand
893 [(QI "nonimmediate_operand")
894 (HI "nonimmediate_operand")
895 (SI "nonimmediate_operand")
896 (DI "shiftdi_operand")
897 (TI "register_operand")])
899 ;; Operand predicate for shift argument.
900 (define_mode_attr shift_immediate_operand
901 [(QI "const_1_to_31_operand")
902 (HI "const_1_to_31_operand")
903 (SI "const_1_to_31_operand")
904 (DI "const_1_to_63_operand")])
906 ;; Input operand predicate for arithmetic left shifts.
907 (define_mode_attr ashl_input_operand
908 [(QI "nonimmediate_operand")
909 (HI "nonimmediate_operand")
910 (SI "nonimmediate_operand")
911 (DI "ashldi_input_operand")
912 (TI "reg_or_pm1_operand")])
914 ;; SSE and x87 SFmode and DFmode floating point modes
915 (define_mode_iterator MODEF [SF DF])
917 ;; All x87 floating point modes
918 (define_mode_iterator X87MODEF [SF DF XF])
920 ;; All integer modes handled by x87 fisttp operator.
921 (define_mode_iterator X87MODEI [HI SI DI])
923 ;; All integer modes handled by integer x87 operators.
924 (define_mode_iterator X87MODEI12 [HI SI])
926 ;; All integer modes handled by SSE cvtts?2si* operators.
927 (define_mode_iterator SSEMODEI24 [SI DI])
929 ;; SSE asm suffix for floating point modes
930 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
932 ;; SSE vector mode corresponding to a scalar mode
933 (define_mode_attr ssevecmode
934 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
936 ;; Instruction suffix for REX 64bit operators.
937 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
939 ;; This mode iterator allows :P to be used for patterns that operate on
940 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
941 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
943 ;; Scheduling descriptions
945 (include "pentium.md")
948 (include "athlon.md")
949 (include "bdver1.md")
955 ;; Operand and operator predicates and constraints
957 (include "predicates.md")
958 (include "constraints.md")
961 ;; Compare and branch/compare and store instructions.
963 (define_expand "cbranch<mode>4"
964 [(set (reg:CC FLAGS_REG)
965 (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
966 (match_operand:SDWIM 2 "<general_operand>" "")))
967 (set (pc) (if_then_else
968 (match_operator 0 "ordered_comparison_operator"
969 [(reg:CC FLAGS_REG) (const_int 0)])
970 (label_ref (match_operand 3 "" ""))
974 if (MEM_P (operands[1]) && MEM_P (operands[2]))
975 operands[1] = force_reg (<MODE>mode, operands[1]);
976 ix86_expand_branch (GET_CODE (operands[0]),
977 operands[1], operands[2], operands[3]);
981 (define_expand "cstore<mode>4"
982 [(set (reg:CC FLAGS_REG)
983 (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
984 (match_operand:SWIM 3 "<general_operand>" "")))
985 (set (match_operand:QI 0 "register_operand" "")
986 (match_operator 1 "ordered_comparison_operator"
987 [(reg:CC FLAGS_REG) (const_int 0)]))]
990 if (MEM_P (operands[2]) && MEM_P (operands[3]))
991 operands[2] = force_reg (<MODE>mode, operands[2]);
992 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
993 operands[2], operands[3]);
997 (define_expand "cmp<mode>_1"
998 [(set (reg:CC FLAGS_REG)
999 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
1000 (match_operand:SWI48 1 "<general_operand>" "")))])
1002 (define_insn "*cmp<mode>_ccno_1"
1003 [(set (reg FLAGS_REG)
1004 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
1005 (match_operand:SWI 1 "const0_operand" "")))]
1006 "ix86_match_ccmode (insn, CCNOmode)"
1008 test{<imodesuffix>}\t%0, %0
1009 cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1010 [(set_attr "type" "test,icmp")
1011 (set_attr "length_immediate" "0,1")
1012 (set_attr "mode" "<MODE>")])
1014 (define_insn "*cmp<mode>_1"
1015 [(set (reg FLAGS_REG)
1016 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1017 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
1018 "ix86_match_ccmode (insn, CCmode)"
1019 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1020 [(set_attr "type" "icmp")
1021 (set_attr "mode" "<MODE>")])
1023 (define_insn "*cmp<mode>_minus_1"
1024 [(set (reg FLAGS_REG)
1026 (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1027 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
1029 "ix86_match_ccmode (insn, CCGOCmode)"
1030 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1031 [(set_attr "type" "icmp")
1032 (set_attr "mode" "<MODE>")])
1034 (define_insn "*cmpqi_ext_1"
1035 [(set (reg FLAGS_REG)
1037 (match_operand:QI 0 "general_operand" "Qm")
1040 (match_operand 1 "ext_register_operand" "Q")
1042 (const_int 8)) 0)))]
1043 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1044 "cmp{b}\t{%h1, %0|%0, %h1}"
1045 [(set_attr "type" "icmp")
1046 (set_attr "mode" "QI")])
1048 (define_insn "*cmpqi_ext_1_rex64"
1049 [(set (reg FLAGS_REG)
1051 (match_operand:QI 0 "register_operand" "Q")
1054 (match_operand 1 "ext_register_operand" "Q")
1056 (const_int 8)) 0)))]
1057 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1058 "cmp{b}\t{%h1, %0|%0, %h1}"
1059 [(set_attr "type" "icmp")
1060 (set_attr "mode" "QI")])
1062 (define_insn "*cmpqi_ext_2"
1063 [(set (reg FLAGS_REG)
1067 (match_operand 0 "ext_register_operand" "Q")
1070 (match_operand:QI 1 "const0_operand" "")))]
1071 "ix86_match_ccmode (insn, CCNOmode)"
1073 [(set_attr "type" "test")
1074 (set_attr "length_immediate" "0")
1075 (set_attr "mode" "QI")])
1077 (define_expand "cmpqi_ext_3"
1078 [(set (reg:CC FLAGS_REG)
1082 (match_operand 0 "ext_register_operand" "")
1085 (match_operand:QI 1 "immediate_operand" "")))])
1087 (define_insn "*cmpqi_ext_3_insn"
1088 [(set (reg FLAGS_REG)
1092 (match_operand 0 "ext_register_operand" "Q")
1095 (match_operand:QI 1 "general_operand" "Qmn")))]
1096 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1097 "cmp{b}\t{%1, %h0|%h0, %1}"
1098 [(set_attr "type" "icmp")
1099 (set_attr "modrm" "1")
1100 (set_attr "mode" "QI")])
1102 (define_insn "*cmpqi_ext_3_insn_rex64"
1103 [(set (reg FLAGS_REG)
1107 (match_operand 0 "ext_register_operand" "Q")
1110 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1111 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1112 "cmp{b}\t{%1, %h0|%h0, %1}"
1113 [(set_attr "type" "icmp")
1114 (set_attr "modrm" "1")
1115 (set_attr "mode" "QI")])
1117 (define_insn "*cmpqi_ext_4"
1118 [(set (reg FLAGS_REG)
1122 (match_operand 0 "ext_register_operand" "Q")
1127 (match_operand 1 "ext_register_operand" "Q")
1129 (const_int 8)) 0)))]
1130 "ix86_match_ccmode (insn, CCmode)"
1131 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1132 [(set_attr "type" "icmp")
1133 (set_attr "mode" "QI")])
1135 ;; These implement float point compares.
1136 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1137 ;; which would allow mix and match FP modes on the compares. Which is what
1138 ;; the old patterns did, but with many more of them.
1140 (define_expand "cbranchxf4"
1141 [(set (reg:CC FLAGS_REG)
1142 (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1143 (match_operand:XF 2 "nonmemory_operand" "")))
1144 (set (pc) (if_then_else
1145 (match_operator 0 "ix86_fp_comparison_operator"
1148 (label_ref (match_operand 3 "" ""))
1152 ix86_expand_branch (GET_CODE (operands[0]),
1153 operands[1], operands[2], operands[3]);
1157 (define_expand "cstorexf4"
1158 [(set (reg:CC FLAGS_REG)
1159 (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1160 (match_operand:XF 3 "nonmemory_operand" "")))
1161 (set (match_operand:QI 0 "register_operand" "")
1162 (match_operator 1 "ix86_fp_comparison_operator"
1167 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1168 operands[2], operands[3]);
1172 (define_expand "cbranch<mode>4"
1173 [(set (reg:CC FLAGS_REG)
1174 (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1175 (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1176 (set (pc) (if_then_else
1177 (match_operator 0 "ix86_fp_comparison_operator"
1180 (label_ref (match_operand 3 "" ""))
1182 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1184 ix86_expand_branch (GET_CODE (operands[0]),
1185 operands[1], operands[2], operands[3]);
1189 (define_expand "cstore<mode>4"
1190 [(set (reg:CC FLAGS_REG)
1191 (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1192 (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1193 (set (match_operand:QI 0 "register_operand" "")
1194 (match_operator 1 "ix86_fp_comparison_operator"
1197 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1199 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1200 operands[2], operands[3]);
1204 (define_expand "cbranchcc4"
1205 [(set (pc) (if_then_else
1206 (match_operator 0 "comparison_operator"
1207 [(match_operand 1 "flags_reg_operand" "")
1208 (match_operand 2 "const0_operand" "")])
1209 (label_ref (match_operand 3 "" ""))
1213 ix86_expand_branch (GET_CODE (operands[0]),
1214 operands[1], operands[2], operands[3]);
1218 (define_expand "cstorecc4"
1219 [(set (match_operand:QI 0 "register_operand" "")
1220 (match_operator 1 "comparison_operator"
1221 [(match_operand 2 "flags_reg_operand" "")
1222 (match_operand 3 "const0_operand" "")]))]
1225 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1226 operands[2], operands[3]);
1231 ;; FP compares, step 1:
1232 ;; Set the FP condition codes.
1234 ;; CCFPmode compare with exceptions
1235 ;; CCFPUmode compare with no exceptions
1237 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1238 ;; used to manage the reg stack popping would not be preserved.
1240 (define_insn "*cmpfp_0"
1241 [(set (match_operand:HI 0 "register_operand" "=a")
1244 (match_operand 1 "register_operand" "f")
1245 (match_operand 2 "const0_operand" ""))]
1247 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1248 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1249 "* return output_fp_compare (insn, operands, 0, 0);"
1250 [(set_attr "type" "multi")
1251 (set_attr "unit" "i387")
1253 (cond [(match_operand:SF 1 "" "")
1255 (match_operand:DF 1 "" "")
1258 (const_string "XF")))])
1260 (define_insn_and_split "*cmpfp_0_cc"
1261 [(set (reg:CCFP FLAGS_REG)
1263 (match_operand 1 "register_operand" "f")
1264 (match_operand 2 "const0_operand" "")))
1265 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1266 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1267 && TARGET_SAHF && !TARGET_CMOVE
1268 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1270 "&& reload_completed"
1273 [(compare:CCFP (match_dup 1)(match_dup 2))]
1275 (set (reg:CC FLAGS_REG)
1276 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1278 [(set_attr "type" "multi")
1279 (set_attr "unit" "i387")
1281 (cond [(match_operand:SF 1 "" "")
1283 (match_operand:DF 1 "" "")
1286 (const_string "XF")))])
1288 (define_insn "*cmpfp_xf"
1289 [(set (match_operand:HI 0 "register_operand" "=a")
1292 (match_operand:XF 1 "register_operand" "f")
1293 (match_operand:XF 2 "register_operand" "f"))]
1296 "* return output_fp_compare (insn, operands, 0, 0);"
1297 [(set_attr "type" "multi")
1298 (set_attr "unit" "i387")
1299 (set_attr "mode" "XF")])
1301 (define_insn_and_split "*cmpfp_xf_cc"
1302 [(set (reg:CCFP FLAGS_REG)
1304 (match_operand:XF 1 "register_operand" "f")
1305 (match_operand:XF 2 "register_operand" "f")))
1306 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1308 && TARGET_SAHF && !TARGET_CMOVE"
1310 "&& reload_completed"
1313 [(compare:CCFP (match_dup 1)(match_dup 2))]
1315 (set (reg:CC FLAGS_REG)
1316 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1318 [(set_attr "type" "multi")
1319 (set_attr "unit" "i387")
1320 (set_attr "mode" "XF")])
1322 (define_insn "*cmpfp_<mode>"
1323 [(set (match_operand:HI 0 "register_operand" "=a")
1326 (match_operand:MODEF 1 "register_operand" "f")
1327 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1330 "* return output_fp_compare (insn, operands, 0, 0);"
1331 [(set_attr "type" "multi")
1332 (set_attr "unit" "i387")
1333 (set_attr "mode" "<MODE>")])
1335 (define_insn_and_split "*cmpfp_<mode>_cc"
1336 [(set (reg:CCFP FLAGS_REG)
1338 (match_operand:MODEF 1 "register_operand" "f")
1339 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1340 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1342 && TARGET_SAHF && !TARGET_CMOVE"
1344 "&& reload_completed"
1347 [(compare:CCFP (match_dup 1)(match_dup 2))]
1349 (set (reg:CC FLAGS_REG)
1350 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1352 [(set_attr "type" "multi")
1353 (set_attr "unit" "i387")
1354 (set_attr "mode" "<MODE>")])
1356 (define_insn "*cmpfp_u"
1357 [(set (match_operand:HI 0 "register_operand" "=a")
1360 (match_operand 1 "register_operand" "f")
1361 (match_operand 2 "register_operand" "f"))]
1363 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1364 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1365 "* return output_fp_compare (insn, operands, 0, 1);"
1366 [(set_attr "type" "multi")
1367 (set_attr "unit" "i387")
1369 (cond [(match_operand:SF 1 "" "")
1371 (match_operand:DF 1 "" "")
1374 (const_string "XF")))])
1376 (define_insn_and_split "*cmpfp_u_cc"
1377 [(set (reg:CCFPU FLAGS_REG)
1379 (match_operand 1 "register_operand" "f")
1380 (match_operand 2 "register_operand" "f")))
1381 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1382 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1383 && TARGET_SAHF && !TARGET_CMOVE
1384 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1386 "&& reload_completed"
1389 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1391 (set (reg:CC FLAGS_REG)
1392 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1394 [(set_attr "type" "multi")
1395 (set_attr "unit" "i387")
1397 (cond [(match_operand:SF 1 "" "")
1399 (match_operand:DF 1 "" "")
1402 (const_string "XF")))])
1404 (define_insn "*cmpfp_<mode>"
1405 [(set (match_operand:HI 0 "register_operand" "=a")
1408 (match_operand 1 "register_operand" "f")
1409 (match_operator 3 "float_operator"
1410 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1412 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1413 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1414 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1415 "* return output_fp_compare (insn, operands, 0, 0);"
1416 [(set_attr "type" "multi")
1417 (set_attr "unit" "i387")
1418 (set_attr "fp_int_src" "true")
1419 (set_attr "mode" "<MODE>")])
1421 (define_insn_and_split "*cmpfp_<mode>_cc"
1422 [(set (reg:CCFP FLAGS_REG)
1424 (match_operand 1 "register_operand" "f")
1425 (match_operator 3 "float_operator"
1426 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1427 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1428 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1429 && TARGET_SAHF && !TARGET_CMOVE
1430 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1431 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1433 "&& reload_completed"
1438 (match_op_dup 3 [(match_dup 2)]))]
1440 (set (reg:CC FLAGS_REG)
1441 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1443 [(set_attr "type" "multi")
1444 (set_attr "unit" "i387")
1445 (set_attr "fp_int_src" "true")
1446 (set_attr "mode" "<MODE>")])
1448 ;; FP compares, step 2
1449 ;; Move the fpsw to ax.
1451 (define_insn "x86_fnstsw_1"
1452 [(set (match_operand:HI 0 "register_operand" "=a")
1453 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1456 [(set (attr "length") (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1457 (set_attr "mode" "SI")
1458 (set_attr "unit" "i387")])
1460 ;; FP compares, step 3
1461 ;; Get ax into flags, general case.
1463 (define_insn "x86_sahf_1"
1464 [(set (reg:CC FLAGS_REG)
1465 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1469 #ifndef HAVE_AS_IX86_SAHF
1471 return ASM_BYTE "0x9e";
1476 [(set_attr "length" "1")
1477 (set_attr "athlon_decode" "vector")
1478 (set_attr "amdfam10_decode" "direct")
1479 (set_attr "bdver1_decode" "direct")
1480 (set_attr "mode" "SI")])
1482 ;; Pentium Pro can do steps 1 through 3 in one go.
1483 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1484 (define_insn "*cmpfp_i_mixed"
1485 [(set (reg:CCFP FLAGS_REG)
1486 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1487 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1488 "TARGET_MIX_SSE_I387
1489 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1490 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1491 "* return output_fp_compare (insn, operands, 1, 0);"
1492 [(set_attr "type" "fcmp,ssecomi")
1493 (set_attr "prefix" "orig,maybe_vex")
1495 (if_then_else (match_operand:SF 1 "" "")
1497 (const_string "DF")))
1498 (set (attr "prefix_rep")
1499 (if_then_else (eq_attr "type" "ssecomi")
1501 (const_string "*")))
1502 (set (attr "prefix_data16")
1503 (cond [(eq_attr "type" "fcmp")
1505 (eq_attr "mode" "DF")
1508 (const_string "0")))
1509 (set_attr "athlon_decode" "vector")
1510 (set_attr "amdfam10_decode" "direct")
1511 (set_attr "bdver1_decode" "double")])
1513 (define_insn "*cmpfp_i_sse"
1514 [(set (reg:CCFP FLAGS_REG)
1515 (compare:CCFP (match_operand 0 "register_operand" "x")
1516 (match_operand 1 "nonimmediate_operand" "xm")))]
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, 0);"
1521 [(set_attr "type" "ssecomi")
1522 (set_attr "prefix" "maybe_vex")
1524 (if_then_else (match_operand:SF 1 "" "")
1526 (const_string "DF")))
1527 (set_attr "prefix_rep" "0")
1528 (set (attr "prefix_data16")
1529 (if_then_else (eq_attr "mode" "DF")
1531 (const_string "0")))
1532 (set_attr "athlon_decode" "vector")
1533 (set_attr "amdfam10_decode" "direct")
1534 (set_attr "bdver1_decode" "double")])
1536 (define_insn "*cmpfp_i_i387"
1537 [(set (reg:CCFP FLAGS_REG)
1538 (compare:CCFP (match_operand 0 "register_operand" "f")
1539 (match_operand 1 "register_operand" "f")))]
1540 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1542 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1543 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1544 "* return output_fp_compare (insn, operands, 1, 0);"
1545 [(set_attr "type" "fcmp")
1547 (cond [(match_operand:SF 1 "" "")
1549 (match_operand:DF 1 "" "")
1552 (const_string "XF")))
1553 (set_attr "athlon_decode" "vector")
1554 (set_attr "amdfam10_decode" "direct")
1555 (set_attr "bdver1_decode" "double")])
1557 (define_insn "*cmpfp_iu_mixed"
1558 [(set (reg:CCFPU FLAGS_REG)
1559 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1560 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1561 "TARGET_MIX_SSE_I387
1562 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1563 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1564 "* return output_fp_compare (insn, operands, 1, 1);"
1565 [(set_attr "type" "fcmp,ssecomi")
1566 (set_attr "prefix" "orig,maybe_vex")
1568 (if_then_else (match_operand:SF 1 "" "")
1570 (const_string "DF")))
1571 (set (attr "prefix_rep")
1572 (if_then_else (eq_attr "type" "ssecomi")
1574 (const_string "*")))
1575 (set (attr "prefix_data16")
1576 (cond [(eq_attr "type" "fcmp")
1578 (eq_attr "mode" "DF")
1581 (const_string "0")))
1582 (set_attr "athlon_decode" "vector")
1583 (set_attr "amdfam10_decode" "direct")
1584 (set_attr "bdver1_decode" "double")])
1586 (define_insn "*cmpfp_iu_sse"
1587 [(set (reg:CCFPU FLAGS_REG)
1588 (compare:CCFPU (match_operand 0 "register_operand" "x")
1589 (match_operand 1 "nonimmediate_operand" "xm")))]
1591 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1592 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1593 "* return output_fp_compare (insn, operands, 1, 1);"
1594 [(set_attr "type" "ssecomi")
1595 (set_attr "prefix" "maybe_vex")
1597 (if_then_else (match_operand:SF 1 "" "")
1599 (const_string "DF")))
1600 (set_attr "prefix_rep" "0")
1601 (set (attr "prefix_data16")
1602 (if_then_else (eq_attr "mode" "DF")
1604 (const_string "0")))
1605 (set_attr "athlon_decode" "vector")
1606 (set_attr "amdfam10_decode" "direct")
1607 (set_attr "bdver1_decode" "double")])
1609 (define_insn "*cmpfp_iu_387"
1610 [(set (reg:CCFPU FLAGS_REG)
1611 (compare:CCFPU (match_operand 0 "register_operand" "f")
1612 (match_operand 1 "register_operand" "f")))]
1613 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1615 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1616 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1617 "* return output_fp_compare (insn, operands, 1, 1);"
1618 [(set_attr "type" "fcmp")
1620 (cond [(match_operand:SF 1 "" "")
1622 (match_operand:DF 1 "" "")
1625 (const_string "XF")))
1626 (set_attr "athlon_decode" "vector")
1627 (set_attr "amdfam10_decode" "direct")
1628 (set_attr "bdver1_decode" "direct")])
1630 ;; Push/pop instructions.
1632 (define_insn "*push<mode>2"
1633 [(set (match_operand:DWI 0 "push_operand" "=<")
1634 (match_operand:DWI 1 "general_no_elim_operand" "riF*m"))]
1639 [(set (match_operand:TI 0 "push_operand" "")
1640 (match_operand:TI 1 "general_operand" ""))]
1641 "TARGET_64BIT && reload_completed
1642 && !SSE_REG_P (operands[1])"
1644 "ix86_split_long_move (operands); DONE;")
1646 (define_insn "*pushdi2_rex64"
1647 [(set (match_operand:DI 0 "push_operand" "=<,!<")
1648 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
1653 [(set_attr "type" "push,multi")
1654 (set_attr "mode" "DI")])
1656 ;; Convert impossible pushes of immediate to existing instructions.
1657 ;; First try to get scratch register and go through it. In case this
1658 ;; fails, push sign extended lower part first and then overwrite
1659 ;; upper part by 32bit move.
1661 [(match_scratch:DI 2 "r")
1662 (set (match_operand:DI 0 "push_operand" "")
1663 (match_operand:DI 1 "immediate_operand" ""))]
1664 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1665 && !x86_64_immediate_operand (operands[1], DImode)"
1666 [(set (match_dup 2) (match_dup 1))
1667 (set (match_dup 0) (match_dup 2))])
1669 ;; We need to define this as both peepholer and splitter for case
1670 ;; peephole2 pass is not run.
1671 ;; "&& 1" is needed to keep it from matching the previous pattern.
1673 [(set (match_operand:DI 0 "push_operand" "")
1674 (match_operand:DI 1 "immediate_operand" ""))]
1675 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1676 && !x86_64_immediate_operand (operands[1], DImode) && 1"
1677 [(set (match_dup 0) (match_dup 1))
1678 (set (match_dup 2) (match_dup 3))]
1680 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1682 operands[1] = gen_lowpart (DImode, operands[2]);
1683 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1688 [(set (match_operand:DI 0 "push_operand" "")
1689 (match_operand:DI 1 "immediate_operand" ""))]
1690 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
1691 ? epilogue_completed : reload_completed)
1692 && !symbolic_operand (operands[1], DImode)
1693 && !x86_64_immediate_operand (operands[1], DImode)"
1694 [(set (match_dup 0) (match_dup 1))
1695 (set (match_dup 2) (match_dup 3))]
1697 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1699 operands[1] = gen_lowpart (DImode, operands[2]);
1700 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1705 [(set (match_operand:DI 0 "push_operand" "")
1706 (match_operand:DI 1 "general_operand" ""))]
1707 "!TARGET_64BIT && reload_completed
1708 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
1710 "ix86_split_long_move (operands); DONE;")
1712 (define_insn "*pushsi2"
1713 [(set (match_operand:SI 0 "push_operand" "=<")
1714 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1717 [(set_attr "type" "push")
1718 (set_attr "mode" "SI")])
1720 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1721 ;; "push a byte/word". But actually we use pushl, which has the effect
1722 ;; of rounding the amount pushed up to a word.
1724 ;; For TARGET_64BIT we always round up to 8 bytes.
1725 (define_insn "*push<mode>2_rex64"
1726 [(set (match_operand:SWI124 0 "push_operand" "=X")
1727 (match_operand:SWI124 1 "nonmemory_no_elim_operand" "r<i>"))]
1730 [(set_attr "type" "push")
1731 (set_attr "mode" "DI")])
1733 (define_insn "*push<mode>2"
1734 [(set (match_operand:SWI12 0 "push_operand" "=X")
1735 (match_operand:SWI12 1 "nonmemory_no_elim_operand" "rn"))]
1738 [(set_attr "type" "push")
1739 (set_attr "mode" "SI")])
1741 (define_insn "*push<mode>2_prologue"
1742 [(set (match_operand:P 0 "push_operand" "=<")
1743 (match_operand:P 1 "general_no_elim_operand" "r<i>*m"))
1744 (clobber (mem:BLK (scratch)))]
1746 "push{<imodesuffix>}\t%1"
1747 [(set_attr "type" "push")
1748 (set_attr "mode" "<MODE>")])
1750 (define_insn "*pop<mode>1"
1751 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1752 (match_operand:P 1 "pop_operand" ">"))]
1754 "pop{<imodesuffix>}\t%0"
1755 [(set_attr "type" "pop")
1756 (set_attr "mode" "<MODE>")])
1758 (define_insn "*pop<mode>1_epilogue"
1759 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1760 (match_operand:P 1 "pop_operand" ">"))
1761 (clobber (mem:BLK (scratch)))]
1763 "pop{<imodesuffix>}\t%0"
1764 [(set_attr "type" "pop")
1765 (set_attr "mode" "<MODE>")])
1767 ;; Move instructions.
1769 (define_expand "movoi"
1770 [(set (match_operand:OI 0 "nonimmediate_operand" "")
1771 (match_operand:OI 1 "general_operand" ""))]
1773 "ix86_expand_move (OImode, operands); DONE;")
1775 (define_expand "movti"
1776 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1777 (match_operand:TI 1 "nonimmediate_operand" ""))]
1778 "TARGET_64BIT || TARGET_SSE"
1781 ix86_expand_move (TImode, operands);
1782 else if (push_operand (operands[0], TImode))
1783 ix86_expand_push (TImode, operands[1]);
1785 ix86_expand_vector_move (TImode, operands);
1789 ;; This expands to what emit_move_complex would generate if we didn't
1790 ;; have a movti pattern. Having this avoids problems with reload on
1791 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
1792 ;; to have around all the time.
1793 (define_expand "movcdi"
1794 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
1795 (match_operand:CDI 1 "general_operand" ""))]
1798 if (push_operand (operands[0], CDImode))
1799 emit_move_complex_push (CDImode, operands[0], operands[1]);
1801 emit_move_complex_parts (operands[0], operands[1]);
1805 (define_expand "mov<mode>"
1806 [(set (match_operand:SWI1248x 0 "nonimmediate_operand" "")
1807 (match_operand:SWI1248x 1 "general_operand" ""))]
1809 "ix86_expand_move (<MODE>mode, operands); DONE;")
1811 (define_insn "*mov<mode>_xor"
1812 [(set (match_operand:SWI48 0 "register_operand" "=r")
1813 (match_operand:SWI48 1 "const0_operand" ""))
1814 (clobber (reg:CC FLAGS_REG))]
1817 [(set_attr "type" "alu1")
1818 (set_attr "mode" "SI")
1819 (set_attr "length_immediate" "0")])
1821 (define_insn "*mov<mode>_or"
1822 [(set (match_operand:SWI48 0 "register_operand" "=r")
1823 (match_operand:SWI48 1 "const_int_operand" ""))
1824 (clobber (reg:CC FLAGS_REG))]
1826 && operands[1] == constm1_rtx"
1827 "or{<imodesuffix>}\t{%1, %0|%0, %1}"
1828 [(set_attr "type" "alu1")
1829 (set_attr "mode" "<MODE>")
1830 (set_attr "length_immediate" "1")])
1832 (define_insn "*movoi_internal_avx"
1833 [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
1834 (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
1835 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1837 switch (which_alternative)
1840 return "vxorps\t%0, %0, %0";
1843 if (misaligned_operand (operands[0], OImode)
1844 || misaligned_operand (operands[1], OImode))
1845 return "vmovdqu\t{%1, %0|%0, %1}";
1847 return "vmovdqa\t{%1, %0|%0, %1}";
1852 [(set_attr "type" "sselog1,ssemov,ssemov")
1853 (set_attr "prefix" "vex")
1854 (set_attr "mode" "OI")])
1856 (define_insn "*movti_internal_rex64"
1857 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
1858 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
1859 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1861 switch (which_alternative)
1867 if (get_attr_mode (insn) == MODE_V4SF)
1868 return "%vxorps\t%0, %d0";
1870 return "%vpxor\t%0, %d0";
1873 /* TDmode values are passed as TImode on the stack. Moving them
1874 to stack may result in unaligned memory access. */
1875 if (misaligned_operand (operands[0], TImode)
1876 || misaligned_operand (operands[1], TImode))
1878 if (get_attr_mode (insn) == MODE_V4SF)
1879 return "%vmovups\t{%1, %0|%0, %1}";
1881 return "%vmovdqu\t{%1, %0|%0, %1}";
1885 if (get_attr_mode (insn) == MODE_V4SF)
1886 return "%vmovaps\t{%1, %0|%0, %1}";
1888 return "%vmovdqa\t{%1, %0|%0, %1}";
1894 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
1895 (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
1897 (cond [(eq_attr "alternative" "2,3")
1899 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1901 (const_string "V4SF")
1902 (const_string "TI"))
1903 (eq_attr "alternative" "4")
1905 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1907 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1909 (const_string "V4SF")
1910 (const_string "TI"))]
1911 (const_string "DI")))])
1914 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1915 (match_operand:TI 1 "general_operand" ""))]
1917 && !SSE_REG_P (operands[0]) && !SSE_REG_P (operands[1])"
1919 "ix86_split_long_move (operands); DONE;")
1921 (define_insn "*movti_internal_sse"
1922 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
1923 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
1924 "TARGET_SSE && !TARGET_64BIT
1925 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1927 switch (which_alternative)
1930 if (get_attr_mode (insn) == MODE_V4SF)
1931 return "%vxorps\t%0, %d0";
1933 return "%vpxor\t%0, %d0";
1936 /* TDmode values are passed as TImode on the stack. Moving them
1937 to stack may result in unaligned memory access. */
1938 if (misaligned_operand (operands[0], TImode)
1939 || misaligned_operand (operands[1], TImode))
1941 if (get_attr_mode (insn) == MODE_V4SF)
1942 return "%vmovups\t{%1, %0|%0, %1}";
1944 return "%vmovdqu\t{%1, %0|%0, %1}";
1948 if (get_attr_mode (insn) == MODE_V4SF)
1949 return "%vmovaps\t{%1, %0|%0, %1}";
1951 return "%vmovdqa\t{%1, %0|%0, %1}";
1957 [(set_attr "type" "sselog1,ssemov,ssemov")
1958 (set_attr "prefix" "maybe_vex")
1960 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1961 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1963 (const_string "V4SF")
1964 (and (eq_attr "alternative" "2")
1965 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1967 (const_string "V4SF")]
1968 (const_string "TI")))])
1970 (define_insn "*movdi_internal_rex64"
1971 [(set (match_operand:DI 0 "nonimmediate_operand"
1972 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
1973 (match_operand:DI 1 "general_operand"
1974 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
1975 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1977 switch (get_attr_type (insn))
1980 if (SSE_REG_P (operands[0]))
1981 return "movq2dq\t{%1, %0|%0, %1}";
1983 return "movdq2q\t{%1, %0|%0, %1}";
1988 if (get_attr_mode (insn) == MODE_TI)
1989 return "vmovdqa\t{%1, %0|%0, %1}";
1991 return "vmovq\t{%1, %0|%0, %1}";
1994 if (get_attr_mode (insn) == MODE_TI)
1995 return "movdqa\t{%1, %0|%0, %1}";
1999 /* Moves from and into integer register is done using movd
2000 opcode with REX prefix. */
2001 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2002 return "movd\t{%1, %0|%0, %1}";
2003 return "movq\t{%1, %0|%0, %1}";
2006 return "%vpxor\t%0, %d0";
2009 return "pxor\t%0, %0";
2015 return "lea{q}\t{%a1, %0|%0, %a1}";
2018 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2019 if (get_attr_mode (insn) == MODE_SI)
2020 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2021 else if (which_alternative == 2)
2022 return "movabs{q}\t{%1, %0|%0, %1}";
2024 return "mov{q}\t{%1, %0|%0, %1}";
2028 (cond [(eq_attr "alternative" "5")
2029 (const_string "mmx")
2030 (eq_attr "alternative" "6,7,8,9,10")
2031 (const_string "mmxmov")
2032 (eq_attr "alternative" "11")
2033 (const_string "sselog1")
2034 (eq_attr "alternative" "12,13,14,15,16")
2035 (const_string "ssemov")
2036 (eq_attr "alternative" "17,18")
2037 (const_string "ssecvt")
2038 (eq_attr "alternative" "4")
2039 (const_string "multi")
2040 (match_operand:DI 1 "pic_32bit_operand" "")
2041 (const_string "lea")
2043 (const_string "imov")))
2046 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2048 (const_string "*")))
2049 (set (attr "length_immediate")
2051 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2053 (const_string "*")))
2054 (set_attr "prefix_rex" "*,*,*,*,*,*,*,1,*,1,*,*,*,*,*,*,*,*,*")
2055 (set_attr "prefix_data16" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,1,*,*,*")
2056 (set (attr "prefix")
2057 (if_then_else (eq_attr "alternative" "11,12,13,14,15,16")
2058 (const_string "maybe_vex")
2059 (const_string "orig")))
2060 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2062 ;; Convert impossible stores of immediate to existing instructions.
2063 ;; First try to get scratch register and go through it. In case this
2064 ;; fails, move by 32bit parts.
2066 [(match_scratch:DI 2 "r")
2067 (set (match_operand:DI 0 "memory_operand" "")
2068 (match_operand:DI 1 "immediate_operand" ""))]
2069 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2070 && !x86_64_immediate_operand (operands[1], DImode)"
2071 [(set (match_dup 2) (match_dup 1))
2072 (set (match_dup 0) (match_dup 2))])
2074 ;; We need to define this as both peepholer and splitter for case
2075 ;; peephole2 pass is not run.
2076 ;; "&& 1" is needed to keep it from matching the previous pattern.
2078 [(set (match_operand:DI 0 "memory_operand" "")
2079 (match_operand:DI 1 "immediate_operand" ""))]
2080 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2081 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2082 [(set (match_dup 2) (match_dup 3))
2083 (set (match_dup 4) (match_dup 5))]
2084 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2087 [(set (match_operand:DI 0 "memory_operand" "")
2088 (match_operand:DI 1 "immediate_operand" ""))]
2089 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2090 ? epilogue_completed : reload_completed)
2091 && !symbolic_operand (operands[1], DImode)
2092 && !x86_64_immediate_operand (operands[1], DImode)"
2093 [(set (match_dup 2) (match_dup 3))
2094 (set (match_dup 4) (match_dup 5))]
2095 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2097 (define_insn "*movdi_internal"
2098 [(set (match_operand:DI 0 "nonimmediate_operand"
2099 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2100 (match_operand:DI 1 "general_operand"
2101 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2102 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2107 movq\t{%1, %0|%0, %1}
2108 movq\t{%1, %0|%0, %1}
2110 %vmovq\t{%1, %0|%0, %1}
2111 %vmovdqa\t{%1, %0|%0, %1}
2112 %vmovq\t{%1, %0|%0, %1}
2114 movlps\t{%1, %0|%0, %1}
2115 movaps\t{%1, %0|%0, %1}
2116 movlps\t{%1, %0|%0, %1}"
2117 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2118 (set (attr "prefix")
2119 (if_then_else (eq_attr "alternative" "5,6,7,8")
2120 (const_string "vex")
2121 (const_string "orig")))
2122 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2125 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2126 (match_operand:DI 1 "general_operand" ""))]
2127 "!TARGET_64BIT && reload_completed
2128 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))
2129 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
2131 "ix86_split_long_move (operands); DONE;")
2133 (define_insn "*movsi_internal"
2134 [(set (match_operand:SI 0 "nonimmediate_operand"
2135 "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
2136 (match_operand:SI 1 "general_operand"
2137 "g ,ri,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
2138 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2140 switch (get_attr_type (insn))
2143 if (get_attr_mode (insn) == MODE_TI)
2144 return "%vpxor\t%0, %d0";
2145 return "%vxorps\t%0, %d0";
2148 switch (get_attr_mode (insn))
2151 return "%vmovdqa\t{%1, %0|%0, %1}";
2153 return "%vmovaps\t{%1, %0|%0, %1}";
2155 return "%vmovd\t{%1, %0|%0, %1}";
2157 return "%vmovss\t{%1, %0|%0, %1}";
2163 return "pxor\t%0, %0";
2166 if (get_attr_mode (insn) == MODE_DI)
2167 return "movq\t{%1, %0|%0, %1}";
2168 return "movd\t{%1, %0|%0, %1}";
2171 return "lea{l}\t{%a1, %0|%0, %a1}";
2174 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2175 return "mov{l}\t{%1, %0|%0, %1}";
2179 (cond [(eq_attr "alternative" "2")
2180 (const_string "mmx")
2181 (eq_attr "alternative" "3,4,5")
2182 (const_string "mmxmov")
2183 (eq_attr "alternative" "6")
2184 (const_string "sselog1")
2185 (eq_attr "alternative" "7,8,9,10,11")
2186 (const_string "ssemov")
2187 (match_operand:DI 1 "pic_32bit_operand" "")
2188 (const_string "lea")
2190 (const_string "imov")))
2191 (set (attr "prefix")
2192 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
2193 (const_string "orig")
2194 (const_string "maybe_vex")))
2195 (set (attr "prefix_data16")
2196 (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
2198 (const_string "*")))
2200 (cond [(eq_attr "alternative" "2,3")
2202 (eq_attr "alternative" "6,7")
2204 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2205 (const_string "V4SF")
2206 (const_string "TI"))
2207 (and (eq_attr "alternative" "8,9,10,11")
2208 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
2211 (const_string "SI")))])
2213 (define_insn "*movhi_internal"
2214 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
2215 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
2216 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2218 switch (get_attr_type (insn))
2221 /* movzwl is faster than movw on p2 due to partial word stalls,
2222 though not as fast as an aligned movl. */
2223 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
2225 if (get_attr_mode (insn) == MODE_SI)
2226 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2228 return "mov{w}\t{%1, %0|%0, %1}";
2232 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
2234 (const_string "imov")
2235 (and (eq_attr "alternative" "0")
2236 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2238 (eq (symbol_ref "TARGET_HIMODE_MATH")
2240 (const_string "imov")
2241 (and (eq_attr "alternative" "1,2")
2242 (match_operand:HI 1 "aligned_operand" ""))
2243 (const_string "imov")
2244 (and (ne (symbol_ref "TARGET_MOVX")
2246 (eq_attr "alternative" "0,2"))
2247 (const_string "imovx")
2249 (const_string "imov")))
2251 (cond [(eq_attr "type" "imovx")
2253 (and (eq_attr "alternative" "1,2")
2254 (match_operand:HI 1 "aligned_operand" ""))
2256 (and (eq_attr "alternative" "0")
2257 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2259 (eq (symbol_ref "TARGET_HIMODE_MATH")
2263 (const_string "HI")))])
2265 ;; Situation is quite tricky about when to choose full sized (SImode) move
2266 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
2267 ;; partial register dependency machines (such as AMD Athlon), where QImode
2268 ;; moves issue extra dependency and for partial register stalls machines
2269 ;; that don't use QImode patterns (and QImode move cause stall on the next
2272 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2273 ;; register stall machines with, where we use QImode instructions, since
2274 ;; partial register stall can be caused there. Then we use movzx.
2275 (define_insn "*movqi_internal"
2276 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2277 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
2278 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2280 switch (get_attr_type (insn))
2283 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2284 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2286 if (get_attr_mode (insn) == MODE_SI)
2287 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2289 return "mov{b}\t{%1, %0|%0, %1}";
2293 (cond [(and (eq_attr "alternative" "5")
2294 (not (match_operand:QI 1 "aligned_operand" "")))
2295 (const_string "imovx")
2296 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2298 (const_string "imov")
2299 (and (eq_attr "alternative" "3")
2300 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2302 (eq (symbol_ref "TARGET_QIMODE_MATH")
2304 (const_string "imov")
2305 (eq_attr "alternative" "3,5")
2306 (const_string "imovx")
2307 (and (ne (symbol_ref "TARGET_MOVX")
2309 (eq_attr "alternative" "2"))
2310 (const_string "imovx")
2312 (const_string "imov")))
2314 (cond [(eq_attr "alternative" "3,4,5")
2316 (eq_attr "alternative" "6")
2318 (eq_attr "type" "imovx")
2320 (and (eq_attr "type" "imov")
2321 (and (eq_attr "alternative" "0,1")
2322 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2324 (and (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2326 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2329 ;; Avoid partial register stalls when not using QImode arithmetic
2330 (and (eq_attr "type" "imov")
2331 (and (eq_attr "alternative" "0,1")
2332 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2334 (eq (symbol_ref "TARGET_QIMODE_MATH")
2338 (const_string "QI")))])
2340 ;; Stores and loads of ax to arbitrary constant address.
2341 ;; We fake an second form of instruction to force reload to load address
2342 ;; into register when rax is not available
2343 (define_insn "*movabs<mode>_1"
2344 [(set (mem:SWI1248x (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2345 (match_operand:SWI1248x 1 "nonmemory_operand" "a,er"))]
2346 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2348 movabs{<imodesuffix>}\t{%1, %P0|%P0, %1}
2349 mov{<imodesuffix>}\t{%1, %a0|%a0, %1}"
2350 [(set_attr "type" "imov")
2351 (set_attr "modrm" "0,*")
2352 (set_attr "length_address" "8,0")
2353 (set_attr "length_immediate" "0,*")
2354 (set_attr "memory" "store")
2355 (set_attr "mode" "<MODE>")])
2357 (define_insn "*movabs<mode>_2"
2358 [(set (match_operand:SWI1248x 0 "register_operand" "=a,r")
2359 (mem:SWI1248x (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2360 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2362 movabs{<imodesuffix>}\t{%P1, %0|%0, %P1}
2363 mov{<imodesuffix>}\t{%a1, %0|%0, %a1}"
2364 [(set_attr "type" "imov")
2365 (set_attr "modrm" "0,*")
2366 (set_attr "length_address" "8,0")
2367 (set_attr "length_immediate" "0")
2368 (set_attr "memory" "load")
2369 (set_attr "mode" "<MODE>")])
2371 (define_insn "*swap<mode>"
2372 [(set (match_operand:SWI48 0 "register_operand" "+r")
2373 (match_operand:SWI48 1 "register_operand" "+r"))
2377 "xchg{<imodesuffix>}\t%1, %0"
2378 [(set_attr "type" "imov")
2379 (set_attr "mode" "<MODE>")
2380 (set_attr "pent_pair" "np")
2381 (set_attr "athlon_decode" "vector")
2382 (set_attr "amdfam10_decode" "double")
2383 (set_attr "bdver1_decode" "double")])
2385 (define_insn "*swap<mode>_1"
2386 [(set (match_operand:SWI12 0 "register_operand" "+r")
2387 (match_operand:SWI12 1 "register_operand" "+r"))
2390 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2392 [(set_attr "type" "imov")
2393 (set_attr "mode" "SI")
2394 (set_attr "pent_pair" "np")
2395 (set_attr "athlon_decode" "vector")
2396 (set_attr "amdfam10_decode" "double")
2397 (set_attr "bdver1_decode" "double")])
2399 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL
2400 ;; is disabled for AMDFAM10
2401 (define_insn "*swap<mode>_2"
2402 [(set (match_operand:SWI12 0 "register_operand" "+<r>")
2403 (match_operand:SWI12 1 "register_operand" "+<r>"))
2406 "TARGET_PARTIAL_REG_STALL"
2407 "xchg{<imodesuffix>}\t%1, %0"
2408 [(set_attr "type" "imov")
2409 (set_attr "mode" "<MODE>")
2410 (set_attr "pent_pair" "np")
2411 (set_attr "athlon_decode" "vector")])
2413 (define_expand "movstrict<mode>"
2414 [(set (strict_low_part (match_operand:SWI12 0 "nonimmediate_operand" ""))
2415 (match_operand:SWI12 1 "general_operand" ""))]
2418 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2420 /* Don't generate memory->memory moves, go through a register */
2421 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2422 operands[1] = force_reg (<MODE>mode, operands[1]);
2425 (define_insn "*movstrict<mode>_1"
2426 [(set (strict_low_part
2427 (match_operand:SWI12 0 "nonimmediate_operand" "+<r>m,<r>"))
2428 (match_operand:SWI12 1 "general_operand" "<r>n,m"))]
2429 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2430 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2431 "mov{<imodesuffix>}\t{%1, %0|%0, %1}"
2432 [(set_attr "type" "imov")
2433 (set_attr "mode" "<MODE>")])
2435 (define_insn "*movstrict<mode>_xor"
2436 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
2437 (match_operand:SWI12 1 "const0_operand" ""))
2438 (clobber (reg:CC FLAGS_REG))]
2440 "xor{<imodesuffix>}\t%0, %0"
2441 [(set_attr "type" "alu1")
2442 (set_attr "mode" "<MODE>")
2443 (set_attr "length_immediate" "0")])
2445 (define_insn "*mov<mode>_extv_1"
2446 [(set (match_operand:SWI24 0 "register_operand" "=R")
2447 (sign_extract:SWI24 (match_operand 1 "ext_register_operand" "Q")
2451 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2452 [(set_attr "type" "imovx")
2453 (set_attr "mode" "SI")])
2455 (define_insn "*movqi_extv_1_rex64"
2456 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2457 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2462 switch (get_attr_type (insn))
2465 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2467 return "mov{b}\t{%h1, %0|%0, %h1}";
2471 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2472 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2473 (ne (symbol_ref "TARGET_MOVX")
2475 (const_string "imovx")
2476 (const_string "imov")))
2478 (if_then_else (eq_attr "type" "imovx")
2480 (const_string "QI")))])
2482 (define_insn "*movqi_extv_1"
2483 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2484 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2489 switch (get_attr_type (insn))
2492 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2494 return "mov{b}\t{%h1, %0|%0, %h1}";
2498 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2499 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2500 (ne (symbol_ref "TARGET_MOVX")
2502 (const_string "imovx")
2503 (const_string "imov")))
2505 (if_then_else (eq_attr "type" "imovx")
2507 (const_string "QI")))])
2509 (define_insn "*mov<mode>_extzv_1"
2510 [(set (match_operand:SWI48 0 "register_operand" "=R")
2511 (zero_extract:SWI48 (match_operand 1 "ext_register_operand" "Q")
2515 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2516 [(set_attr "type" "imovx")
2517 (set_attr "mode" "SI")])
2519 (define_insn "*movqi_extzv_2_rex64"
2520 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2522 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2527 switch (get_attr_type (insn))
2530 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2532 return "mov{b}\t{%h1, %0|%0, %h1}";
2536 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2537 (ne (symbol_ref "TARGET_MOVX")
2539 (const_string "imovx")
2540 (const_string "imov")))
2542 (if_then_else (eq_attr "type" "imovx")
2544 (const_string "QI")))])
2546 (define_insn "*movqi_extzv_2"
2547 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2549 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2554 switch (get_attr_type (insn))
2557 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2559 return "mov{b}\t{%h1, %0|%0, %h1}";
2563 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2564 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2565 (ne (symbol_ref "TARGET_MOVX")
2567 (const_string "imovx")
2568 (const_string "imov")))
2570 (if_then_else (eq_attr "type" "imovx")
2572 (const_string "QI")))])
2574 (define_expand "mov<mode>_insv_1"
2575 [(set (zero_extract:SWI48 (match_operand 0 "ext_register_operand" "")
2578 (match_operand:SWI48 1 "nonmemory_operand" ""))])
2580 (define_insn "*mov<mode>_insv_1_rex64"
2581 [(set (zero_extract:SWI48x (match_operand 0 "ext_register_operand" "+Q")
2584 (match_operand:SWI48x 1 "nonmemory_operand" "Qn"))]
2586 "mov{b}\t{%b1, %h0|%h0, %b1}"
2587 [(set_attr "type" "imov")
2588 (set_attr "mode" "QI")])
2590 (define_insn "*movsi_insv_1"
2591 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2594 (match_operand:SI 1 "general_operand" "Qmn"))]
2596 "mov{b}\t{%b1, %h0|%h0, %b1}"
2597 [(set_attr "type" "imov")
2598 (set_attr "mode" "QI")])
2600 (define_insn "*movqi_insv_2"
2601 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2604 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2607 "mov{b}\t{%h1, %h0|%h0, %h1}"
2608 [(set_attr "type" "imov")
2609 (set_attr "mode" "QI")])
2611 ;; Floating point push instructions.
2613 (define_insn "*pushtf"
2614 [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2615 (match_operand:TF 1 "general_no_elim_operand" "x,Fo,*r"))]
2618 /* This insn should be already split before reg-stack. */
2621 [(set_attr "type" "multi")
2622 (set_attr "unit" "sse,*,*")
2623 (set_attr "mode" "TF,SI,SI")])
2626 [(set (match_operand:TF 0 "push_operand" "")
2627 (match_operand:TF 1 "sse_reg_operand" ""))]
2628 "TARGET_SSE2 && reload_completed"
2629 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
2630 (set (mem:TF (reg:P SP_REG)) (match_dup 1))])
2633 [(set (match_operand:TF 0 "push_operand" "")
2634 (match_operand:TF 1 "general_operand" ""))]
2635 "TARGET_SSE2 && reload_completed
2636 && !SSE_REG_P (operands[1])"
2638 "ix86_split_long_move (operands); DONE;")
2640 (define_insn "*pushxf"
2641 [(set (match_operand:XF 0 "push_operand" "=<,<")
2642 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
2643 "optimize_function_for_speed_p (cfun)"
2645 /* This insn should be already split before reg-stack. */
2648 [(set_attr "type" "multi")
2649 (set_attr "unit" "i387,*")
2650 (set_attr "mode" "XF,SI")])
2652 ;; Size of pushxf is 3 (for sub) + 2 (for fstp) + memory operand size.
2653 ;; Size of pushxf using integer instructions is 3+3*memory operand size
2654 ;; Pushing using integer instructions is longer except for constants
2655 ;; and direct memory references (assuming that any given constant is pushed
2656 ;; only once, but this ought to be handled elsewhere).
2658 (define_insn "*pushxf_nointeger"
2659 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
2660 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
2661 "optimize_function_for_size_p (cfun)"
2663 /* This insn should be already split before reg-stack. */
2666 [(set_attr "type" "multi")
2667 (set_attr "unit" "i387,*,*")
2668 (set_attr "mode" "XF,SI,SI")])
2671 [(set (match_operand:XF 0 "push_operand" "")
2672 (match_operand:XF 1 "fp_register_operand" ""))]
2674 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2675 (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
2676 "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
2679 [(set (match_operand:XF 0 "push_operand" "")
2680 (match_operand:XF 1 "general_operand" ""))]
2682 && !FP_REG_P (operands[1])"
2684 "ix86_split_long_move (operands); DONE;")
2686 (define_insn "*pushdf"
2687 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2688 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
2689 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2691 /* This insn should be already split before reg-stack. */
2694 [(set_attr "type" "multi")
2695 (set_attr "unit" "i387,*,*")
2696 (set_attr "mode" "DF,SI,DF")])
2698 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2699 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2700 ;; On the average, pushdf using integers can be still shorter. Allow this
2701 ;; pattern for optimize_size too.
2703 (define_insn "*pushdf_nointeger"
2704 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2705 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
2706 "!(TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES)"
2708 /* This insn should be already split before reg-stack. */
2711 [(set_attr "type" "multi")
2712 (set_attr "unit" "i387,*,*,*")
2713 (set_attr "mode" "DF,SI,SI,DF")])
2715 ;; %%% Kill this when call knows how to work this out.
2717 [(set (match_operand:DF 0 "push_operand" "")
2718 (match_operand:DF 1 "any_fp_register_operand" ""))]
2720 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
2721 (set (mem:DF (reg:P SP_REG)) (match_dup 1))])
2724 [(set (match_operand:DF 0 "push_operand" "")
2725 (match_operand:DF 1 "general_operand" ""))]
2727 && !ANY_FP_REG_P (operands[1])"
2729 "ix86_split_long_move (operands); DONE;")
2731 (define_insn "*pushsf_rex64"
2732 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2733 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2736 /* Anything else should be already split before reg-stack. */
2737 gcc_assert (which_alternative == 1);
2738 return "push{q}\t%q1";
2740 [(set_attr "type" "multi,push,multi")
2741 (set_attr "unit" "i387,*,*")
2742 (set_attr "mode" "SF,DI,SF")])
2744 (define_insn "*pushsf"
2745 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2746 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2749 /* Anything else should be already split before reg-stack. */
2750 gcc_assert (which_alternative == 1);
2751 return "push{l}\t%1";
2753 [(set_attr "type" "multi,push,multi")
2754 (set_attr "unit" "i387,*,*")
2755 (set_attr "mode" "SF,SI,SF")])
2758 [(set (match_operand:SF 0 "push_operand" "")
2759 (match_operand:SF 1 "memory_operand" ""))]
2761 && MEM_P (operands[1])
2762 && (operands[2] = find_constant_src (insn))"
2766 ;; %%% Kill this when call knows how to work this out.
2768 [(set (match_operand:SF 0 "push_operand" "")
2769 (match_operand:SF 1 "any_fp_register_operand" ""))]
2771 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2772 (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
2773 "operands[2] = GEN_INT (-GET_MODE_SIZE (<MODE>mode));")
2775 ;; Floating point move instructions.
2777 (define_expand "movtf"
2778 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2779 (match_operand:TF 1 "nonimmediate_operand" ""))]
2782 ix86_expand_move (TFmode, operands);
2786 (define_expand "mov<mode>"
2787 [(set (match_operand:X87MODEF 0 "nonimmediate_operand" "")
2788 (match_operand:X87MODEF 1 "general_operand" ""))]
2790 "ix86_expand_move (<MODE>mode, operands); DONE;")
2792 (define_insn "*movtf_internal"
2793 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?r,?o")
2794 (match_operand:TF 1 "general_operand" "xm,x,C,roF,Fr"))]
2796 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2798 switch (which_alternative)
2802 if (get_attr_mode (insn) == MODE_V4SF)
2803 return "%vmovaps\t{%1, %0|%0, %1}";
2805 return "%vmovdqa\t{%1, %0|%0, %1}";
2807 if (get_attr_mode (insn) == MODE_V4SF)
2808 return "%vxorps\t%0, %d0";
2810 return "%vpxor\t%0, %d0";
2818 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
2819 (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,*,*")
2821 (cond [(eq_attr "alternative" "0,2")
2823 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2825 (const_string "V4SF")
2826 (const_string "TI"))
2827 (eq_attr "alternative" "1")
2829 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2831 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2833 (const_string "V4SF")
2834 (const_string "TI"))]
2835 (const_string "DI")))])
2838 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2839 (match_operand:TF 1 "general_operand" ""))]
2841 && !(SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]))"
2843 "ix86_split_long_move (operands); DONE;")
2845 (define_insn "*movxf_internal"
2846 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,r,o")
2847 (match_operand:XF 1 "general_operand" "fm,f,G,roF,Fr"))]
2848 "optimize_function_for_speed_p (cfun)
2849 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2850 && (reload_in_progress || reload_completed
2851 || GET_CODE (operands[1]) != CONST_DOUBLE
2852 || memory_operand (operands[0], XFmode))"
2854 switch (which_alternative)
2858 return output_387_reg_move (insn, operands);
2861 return standard_80387_constant_opcode (operands[1]);
2870 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2871 (set_attr "mode" "XF,XF,XF,SI,SI")])
2873 ;; Do not use integer registers when optimizing for size
2874 (define_insn "*movxf_internal_nointeger"
2875 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2876 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2877 "optimize_function_for_size_p (cfun)
2878 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2879 && (reload_in_progress || reload_completed
2880 || standard_80387_constant_p (operands[1])
2881 || GET_CODE (operands[1]) != CONST_DOUBLE
2882 || memory_operand (operands[0], XFmode))"
2884 switch (which_alternative)
2888 return output_387_reg_move (insn, operands);
2891 return standard_80387_constant_opcode (operands[1]);
2899 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2900 (set_attr "mode" "XF,XF,XF,SI,SI")])
2903 [(set (match_operand:XF 0 "nonimmediate_operand" "")
2904 (match_operand:XF 1 "general_operand" ""))]
2906 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2907 && ! (FP_REG_P (operands[0]) ||
2908 (GET_CODE (operands[0]) == SUBREG
2909 && FP_REG_P (SUBREG_REG (operands[0]))))
2910 && ! (FP_REG_P (operands[1]) ||
2911 (GET_CODE (operands[1]) == SUBREG
2912 && FP_REG_P (SUBREG_REG (operands[1]))))"
2914 "ix86_split_long_move (operands); DONE;")
2916 (define_insn "*movdf_internal_rex64"
2917 [(set (match_operand:DF 0 "nonimmediate_operand"
2918 "=f,m,f,r ,m ,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
2919 (match_operand:DF 1 "general_operand"
2920 "fm,f,G,rmF,Fr,C ,Y2*x,m ,Y2*x,r ,Yi"))]
2921 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2922 && (reload_in_progress || reload_completed
2923 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2924 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
2925 && optimize_function_for_size_p (cfun)
2926 && standard_80387_constant_p (operands[1]))
2927 || GET_CODE (operands[1]) != CONST_DOUBLE
2928 || memory_operand (operands[0], DFmode))"
2930 switch (which_alternative)
2934 return output_387_reg_move (insn, operands);
2937 return standard_80387_constant_opcode (operands[1]);
2944 switch (get_attr_mode (insn))
2947 return "%vxorps\t%0, %d0";
2949 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2950 return "%vxorps\t%0, %d0";
2952 return "%vxorpd\t%0, %d0";
2954 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2955 return "%vxorps\t%0, %d0";
2957 return "%vpxor\t%0, %d0";
2964 switch (get_attr_mode (insn))
2967 return "%vmovaps\t{%1, %0|%0, %1}";
2969 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2970 return "%vmovaps\t{%1, %0|%0, %1}";
2972 return "%vmovapd\t{%1, %0|%0, %1}";
2974 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2975 return "%vmovaps\t{%1, %0|%0, %1}";
2977 return "%vmovdqa\t{%1, %0|%0, %1}";
2979 return "%vmovq\t{%1, %0|%0, %1}";
2983 if (REG_P (operands[0]) && REG_P (operands[1]))
2984 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
2986 return "vmovsd\t{%1, %0|%0, %1}";
2989 return "movsd\t{%1, %0|%0, %1}";
2991 return "%vmovlpd\t{%1, %d0|%d0, %1}";
2993 return "%vmovlps\t{%1, %d0|%d0, %1}";
3000 return "%vmovd\t{%1, %0|%0, %1}";
3006 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
3007 (set (attr "prefix")
3008 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3009 (const_string "orig")
3010 (const_string "maybe_vex")))
3011 (set (attr "prefix_data16")
3012 (if_then_else (eq_attr "mode" "V1DF")
3014 (const_string "*")))
3016 (cond [(eq_attr "alternative" "0,1,2")
3018 (eq_attr "alternative" "3,4,9,10")
3021 /* For SSE1, we have many fewer alternatives. */
3022 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3023 (cond [(eq_attr "alternative" "5,6")
3024 (const_string "V4SF")
3026 (const_string "V2SF"))
3028 /* xorps is one byte shorter. */
3029 (eq_attr "alternative" "5")
3030 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3032 (const_string "V4SF")
3033 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3037 (const_string "V2DF"))
3039 /* For architectures resolving dependencies on
3040 whole SSE registers use APD move to break dependency
3041 chains, otherwise use short move to avoid extra work.
3043 movaps encodes one byte shorter. */
3044 (eq_attr "alternative" "6")
3046 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3048 (const_string "V4SF")
3049 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3051 (const_string "V2DF")
3053 (const_string "DF"))
3054 /* For architectures resolving dependencies on register
3055 parts we may avoid extra work to zero out upper part
3057 (eq_attr "alternative" "7")
3059 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3061 (const_string "V1DF")
3062 (const_string "DF"))
3064 (const_string "DF")))])
3066 (define_insn "*movdf_internal"
3067 [(set (match_operand:DF 0 "nonimmediate_operand"
3068 "=f,m,f,r ,o ,Y2*x,Y2*x,Y2*x,m ")
3069 (match_operand:DF 1 "general_operand"
3070 "fm,f,G,roF,Fr,C ,Y2*x,m ,Y2*x"))]
3071 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3072 && optimize_function_for_speed_p (cfun)
3073 && TARGET_INTEGER_DFMODE_MOVES
3074 && (reload_in_progress || reload_completed
3075 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3076 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3077 && optimize_function_for_size_p (cfun)
3078 && standard_80387_constant_p (operands[1]))
3079 || GET_CODE (operands[1]) != CONST_DOUBLE
3080 || memory_operand (operands[0], DFmode))"
3082 switch (which_alternative)
3086 return output_387_reg_move (insn, operands);
3089 return standard_80387_constant_opcode (operands[1]);
3096 switch (get_attr_mode (insn))
3099 return "xorps\t%0, %0";
3101 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3102 return "xorps\t%0, %0";
3104 return "xorpd\t%0, %0";
3106 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3107 return "xorps\t%0, %0";
3109 return "pxor\t%0, %0";
3116 switch (get_attr_mode (insn))
3119 return "movaps\t{%1, %0|%0, %1}";
3121 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3122 return "movaps\t{%1, %0|%0, %1}";
3124 return "movapd\t{%1, %0|%0, %1}";
3126 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3127 return "movaps\t{%1, %0|%0, %1}";
3129 return "movdqa\t{%1, %0|%0, %1}";
3131 return "movq\t{%1, %0|%0, %1}";
3133 return "movsd\t{%1, %0|%0, %1}";
3135 return "movlpd\t{%1, %0|%0, %1}";
3137 return "movlps\t{%1, %0|%0, %1}";
3146 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3147 (set (attr "prefix_data16")
3148 (if_then_else (eq_attr "mode" "V1DF")
3150 (const_string "*")))
3152 (cond [(eq_attr "alternative" "0,1,2")
3154 (eq_attr "alternative" "3,4")
3157 /* For SSE1, we have many fewer alternatives. */
3158 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3159 (cond [(eq_attr "alternative" "5,6")
3160 (const_string "V4SF")
3162 (const_string "V2SF"))
3164 /* xorps is one byte shorter. */
3165 (eq_attr "alternative" "5")
3166 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3168 (const_string "V4SF")
3169 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3173 (const_string "V2DF"))
3175 /* For architectures resolving dependencies on
3176 whole SSE registers use APD move to break dependency
3177 chains, otherwise use short move to avoid extra work.
3179 movaps encodes one byte shorter. */
3180 (eq_attr "alternative" "6")
3182 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3184 (const_string "V4SF")
3185 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3187 (const_string "V2DF")
3189 (const_string "DF"))
3190 /* For architectures resolving dependencies on register
3191 parts we may avoid extra work to zero out upper part
3193 (eq_attr "alternative" "7")
3195 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3197 (const_string "V1DF")
3198 (const_string "DF"))
3200 (const_string "DF")))])
3202 ;; Moving is usually shorter when only FP registers are used. This separate
3203 ;; movdf pattern avoids the use of integer registers for FP operations
3204 ;; when optimizing for size.
3206 (define_insn "*movdf_internal_nointeger"
3207 [(set (match_operand:DF 0 "nonimmediate_operand"
3208 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
3209 (match_operand:DF 1 "general_operand"
3210 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
3211 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3212 && ((optimize_function_for_size_p (cfun)
3213 || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
3214 && (reload_in_progress || reload_completed
3215 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3216 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3217 && optimize_function_for_size_p (cfun)
3218 && !memory_operand (operands[0], DFmode)
3219 && standard_80387_constant_p (operands[1]))
3220 || GET_CODE (operands[1]) != CONST_DOUBLE
3221 || ((optimize_function_for_size_p (cfun)
3222 || !TARGET_MEMORY_MISMATCH_STALL
3223 || reload_in_progress || reload_completed)
3224 && memory_operand (operands[0], DFmode)))"
3226 switch (which_alternative)
3230 return output_387_reg_move (insn, operands);
3233 return standard_80387_constant_opcode (operands[1]);
3240 switch (get_attr_mode (insn))
3243 return "%vxorps\t%0, %d0";
3245 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3246 return "%vxorps\t%0, %d0";
3248 return "%vxorpd\t%0, %d0";
3250 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3251 return "%vxorps\t%0, %d0";
3253 return "%vpxor\t%0, %d0";
3260 switch (get_attr_mode (insn))
3263 return "%vmovaps\t{%1, %0|%0, %1}";
3265 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3266 return "%vmovaps\t{%1, %0|%0, %1}";
3268 return "%vmovapd\t{%1, %0|%0, %1}";
3270 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3271 return "%vmovaps\t{%1, %0|%0, %1}";
3273 return "%vmovdqa\t{%1, %0|%0, %1}";
3275 return "%vmovq\t{%1, %0|%0, %1}";
3279 if (REG_P (operands[0]) && REG_P (operands[1]))
3280 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3282 return "vmovsd\t{%1, %0|%0, %1}";
3285 return "movsd\t{%1, %0|%0, %1}";
3289 if (REG_P (operands[0]))
3290 return "vmovlpd\t{%1, %0, %0|%0, %0, %1}";
3292 return "vmovlpd\t{%1, %0|%0, %1}";
3295 return "movlpd\t{%1, %0|%0, %1}";
3299 if (REG_P (operands[0]))
3300 return "vmovlps\t{%1, %0, %0|%0, %0, %1}";
3302 return "vmovlps\t{%1, %0|%0, %1}";
3305 return "movlps\t{%1, %0|%0, %1}";
3314 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3315 (set (attr "prefix")
3316 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3317 (const_string "orig")
3318 (const_string "maybe_vex")))
3319 (set (attr "prefix_data16")
3320 (if_then_else (eq_attr "mode" "V1DF")
3322 (const_string "*")))
3324 (cond [(eq_attr "alternative" "0,1,2")
3326 (eq_attr "alternative" "3,4")
3329 /* For SSE1, we have many fewer alternatives. */
3330 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3331 (cond [(eq_attr "alternative" "5,6")
3332 (const_string "V4SF")
3334 (const_string "V2SF"))
3336 /* xorps is one byte shorter. */
3337 (eq_attr "alternative" "5")
3338 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3340 (const_string "V4SF")
3341 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3345 (const_string "V2DF"))
3347 /* For architectures resolving dependencies on
3348 whole SSE registers use APD move to break dependency
3349 chains, otherwise use short move to avoid extra work.
3351 movaps encodes one byte shorter. */
3352 (eq_attr "alternative" "6")
3354 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3356 (const_string "V4SF")
3357 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3359 (const_string "V2DF")
3361 (const_string "DF"))
3362 /* For architectures resolving dependencies on register
3363 parts we may avoid extra work to zero out upper part
3365 (eq_attr "alternative" "7")
3367 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3369 (const_string "V1DF")
3370 (const_string "DF"))
3372 (const_string "DF")))])
3375 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3376 (match_operand:DF 1 "general_operand" ""))]
3378 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3379 && ! (ANY_FP_REG_P (operands[0]) ||
3380 (GET_CODE (operands[0]) == SUBREG
3381 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3382 && ! (ANY_FP_REG_P (operands[1]) ||
3383 (GET_CODE (operands[1]) == SUBREG
3384 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3386 "ix86_split_long_move (operands); DONE;")
3388 (define_insn "*movsf_internal"
3389 [(set (match_operand:SF 0 "nonimmediate_operand"
3390 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
3391 (match_operand:SF 1 "general_operand"
3392 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
3393 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3394 && (reload_in_progress || reload_completed
3395 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3396 || (!TARGET_SSE_MATH && optimize_function_for_size_p (cfun)
3397 && standard_80387_constant_p (operands[1]))
3398 || GET_CODE (operands[1]) != CONST_DOUBLE
3399 || memory_operand (operands[0], SFmode))"
3401 switch (which_alternative)
3405 return output_387_reg_move (insn, operands);
3408 return standard_80387_constant_opcode (operands[1]);
3412 return "mov{l}\t{%1, %0|%0, %1}";
3414 if (get_attr_mode (insn) == MODE_TI)
3415 return "%vpxor\t%0, %d0";
3417 return "%vxorps\t%0, %d0";
3419 if (get_attr_mode (insn) == MODE_V4SF)
3420 return "%vmovaps\t{%1, %0|%0, %1}";
3422 return "%vmovss\t{%1, %d0|%d0, %1}";
3425 return REG_P (operands[1]) ? "vmovss\t{%1, %0, %0|%0, %0, %1}"
3426 : "vmovss\t{%1, %0|%0, %1}";
3428 return "movss\t{%1, %0|%0, %1}";
3430 return "%vmovss\t{%1, %0|%0, %1}";
3432 case 9: case 10: case 14: case 15:
3433 return "movd\t{%1, %0|%0, %1}";
3435 return "%vmovd\t{%1, %0|%0, %1}";
3438 return "movq\t{%1, %0|%0, %1}";
3444 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
3445 (set (attr "prefix")
3446 (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
3447 (const_string "maybe_vex")
3448 (const_string "orig")))
3450 (cond [(eq_attr "alternative" "3,4,9,10")
3452 (eq_attr "alternative" "5")
3454 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3456 (ne (symbol_ref "TARGET_SSE2")
3458 (eq (symbol_ref "optimize_function_for_size_p (cfun)")
3461 (const_string "V4SF"))
3462 /* For architectures resolving dependencies on
3463 whole SSE registers use APS move to break dependency
3464 chains, otherwise use short move to avoid extra work.
3466 Do the same for architectures resolving dependencies on
3467 the parts. While in DF mode it is better to always handle
3468 just register parts, the SF mode is different due to lack
3469 of instructions to load just part of the register. It is
3470 better to maintain the whole registers in single format
3471 to avoid problems on using packed logical operations. */
3472 (eq_attr "alternative" "6")
3474 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3476 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3478 (const_string "V4SF")
3479 (const_string "SF"))
3480 (eq_attr "alternative" "11")
3481 (const_string "DI")]
3482 (const_string "SF")))])
3485 [(set (match_operand 0 "register_operand" "")
3486 (match_operand 1 "memory_operand" ""))]
3488 && MEM_P (operands[1])
3489 && (GET_MODE (operands[0]) == TFmode
3490 || GET_MODE (operands[0]) == XFmode
3491 || GET_MODE (operands[0]) == DFmode
3492 || GET_MODE (operands[0]) == SFmode)
3493 && (operands[2] = find_constant_src (insn))"
3494 [(set (match_dup 0) (match_dup 2))]
3496 rtx c = operands[2];
3497 rtx r = operands[0];
3499 if (GET_CODE (r) == SUBREG)
3504 if (!standard_sse_constant_p (c))
3507 else if (FP_REG_P (r))
3509 if (!standard_80387_constant_p (c))
3512 else if (MMX_REG_P (r))
3517 [(set (match_operand 0 "register_operand" "")
3518 (float_extend (match_operand 1 "memory_operand" "")))]
3520 && MEM_P (operands[1])
3521 && (GET_MODE (operands[0]) == TFmode
3522 || GET_MODE (operands[0]) == XFmode
3523 || GET_MODE (operands[0]) == DFmode
3524 || GET_MODE (operands[0]) == SFmode)
3525 && (operands[2] = find_constant_src (insn))"
3526 [(set (match_dup 0) (match_dup 2))]
3528 rtx c = operands[2];
3529 rtx r = operands[0];
3531 if (GET_CODE (r) == SUBREG)
3536 if (!standard_sse_constant_p (c))
3539 else if (FP_REG_P (r))
3541 if (!standard_80387_constant_p (c))
3544 else if (MMX_REG_P (r))
3548 ;; Split the load of -0.0 or -1.0 into fldz;fchs or fld1;fchs sequence
3550 [(set (match_operand:X87MODEF 0 "register_operand" "")
3551 (match_operand:X87MODEF 1 "immediate_operand" ""))]
3552 "reload_completed && FP_REGNO_P (REGNO (operands[0]))
3553 && (standard_80387_constant_p (operands[1]) == 8
3554 || standard_80387_constant_p (operands[1]) == 9)"
3555 [(set (match_dup 0)(match_dup 1))
3557 (neg:X87MODEF (match_dup 0)))]
3561 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
3562 if (real_isnegzero (&r))
3563 operands[1] = CONST0_RTX (<MODE>mode);
3565 operands[1] = CONST1_RTX (<MODE>mode);
3568 (define_insn "swapxf"
3569 [(set (match_operand:XF 0 "register_operand" "+f")
3570 (match_operand:XF 1 "register_operand" "+f"))
3575 if (STACK_TOP_P (operands[0]))
3580 [(set_attr "type" "fxch")
3581 (set_attr "mode" "XF")])
3583 (define_insn "*swap<mode>"
3584 [(set (match_operand:MODEF 0 "fp_register_operand" "+f")
3585 (match_operand:MODEF 1 "fp_register_operand" "+f"))
3588 "TARGET_80387 || reload_completed"
3590 if (STACK_TOP_P (operands[0]))
3595 [(set_attr "type" "fxch")
3596 (set_attr "mode" "<MODE>")])
3598 ;; Zero extension instructions
3600 (define_expand "zero_extendsidi2"
3601 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3602 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3607 emit_insn (gen_zero_extendsidi2_1 (operands[0], operands[1]));
3612 (define_insn "*zero_extendsidi2_rex64"
3613 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,?*Ym,?*y,?*Yi,*Y2")
3615 (match_operand:SI 1 "nonimmediate_operand" "rm,0,r ,m ,r ,m")))]
3618 mov\t{%k1, %k0|%k0, %k1}
3620 movd\t{%1, %0|%0, %1}
3621 movd\t{%1, %0|%0, %1}
3622 %vmovd\t{%1, %0|%0, %1}
3623 %vmovd\t{%1, %0|%0, %1}"
3624 [(set_attr "type" "imovx,imov,mmxmov,mmxmov,ssemov,ssemov")
3625 (set_attr "prefix" "orig,*,orig,orig,maybe_vex,maybe_vex")
3626 (set_attr "prefix_0f" "0,*,*,*,*,*")
3627 (set_attr "mode" "SI,DI,DI,DI,TI,TI")])
3630 [(set (match_operand:DI 0 "memory_operand" "")
3631 (zero_extend:DI (match_dup 0)))]
3633 [(set (match_dup 4) (const_int 0))]
3634 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3636 ;; %%% Kill me once multi-word ops are sane.
3637 (define_insn "zero_extendsidi2_1"
3638 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?o,?*Ym,?*y,?*Yi,*Y2")
3640 (match_operand:SI 1 "nonimmediate_operand" "0,rm,r ,r ,m ,r ,m")))
3641 (clobber (reg:CC FLAGS_REG))]
3647 movd\t{%1, %0|%0, %1}
3648 movd\t{%1, %0|%0, %1}
3649 %vmovd\t{%1, %0|%0, %1}
3650 %vmovd\t{%1, %0|%0, %1}"
3651 [(set_attr "type" "multi,multi,multi,mmxmov,mmxmov,ssemov,ssemov")
3652 (set_attr "prefix" "*,*,*,orig,orig,maybe_vex,maybe_vex")
3653 (set_attr "mode" "SI,SI,SI,DI,DI,TI,TI")])
3656 [(set (match_operand:DI 0 "register_operand" "")
3657 (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3658 (clobber (reg:CC FLAGS_REG))]
3659 "!TARGET_64BIT && reload_completed
3660 && true_regnum (operands[0]) == true_regnum (operands[1])"
3661 [(set (match_dup 4) (const_int 0))]
3662 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3665 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3666 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3667 (clobber (reg:CC FLAGS_REG))]
3668 "!TARGET_64BIT && reload_completed
3669 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))"
3670 [(set (match_dup 3) (match_dup 1))
3671 (set (match_dup 4) (const_int 0))]
3672 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3674 (define_insn "zero_extend<mode>di2"
3675 [(set (match_operand:DI 0 "register_operand" "=r")
3677 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3679 "movz{<imodesuffix>l|x}\t{%1, %k0|%k0, %1}"
3680 [(set_attr "type" "imovx")
3681 (set_attr "mode" "SI")])
3683 (define_expand "zero_extendhisi2"
3684 [(set (match_operand:SI 0 "register_operand" "")
3685 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3688 if (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3690 operands[1] = force_reg (HImode, operands[1]);
3691 emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3696 (define_insn_and_split "zero_extendhisi2_and"
3697 [(set (match_operand:SI 0 "register_operand" "=r")
3698 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3699 (clobber (reg:CC FLAGS_REG))]
3700 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3702 "&& reload_completed"
3703 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3704 (clobber (reg:CC FLAGS_REG))])]
3706 [(set_attr "type" "alu1")
3707 (set_attr "mode" "SI")])
3709 (define_insn "*zero_extendhisi2_movzwl"
3710 [(set (match_operand:SI 0 "register_operand" "=r")
3711 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3712 "!TARGET_ZERO_EXTEND_WITH_AND
3713 || optimize_function_for_size_p (cfun)"
3714 "movz{wl|x}\t{%1, %0|%0, %1}"
3715 [(set_attr "type" "imovx")
3716 (set_attr "mode" "SI")])
3718 (define_expand "zero_extendqi<mode>2"
3720 [(set (match_operand:SWI24 0 "register_operand" "")
3721 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3722 (clobber (reg:CC FLAGS_REG))])])
3724 (define_insn "*zero_extendqi<mode>2_and"
3725 [(set (match_operand:SWI24 0 "register_operand" "=r,?&q")
3726 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3727 (clobber (reg:CC FLAGS_REG))]
3728 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3730 [(set_attr "type" "alu1")
3731 (set_attr "mode" "<MODE>")])
3733 ;; When source and destination does not overlap, clear destination
3734 ;; first and then do the movb
3736 [(set (match_operand:SWI24 0 "register_operand" "")
3737 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3738 (clobber (reg:CC FLAGS_REG))]
3740 && (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3741 && ANY_QI_REG_P (operands[0])
3742 && (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]))
3743 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3744 [(set (strict_low_part (match_dup 2)) (match_dup 1))]
3746 operands[2] = gen_lowpart (QImode, operands[0]);
3747 ix86_expand_clear (operands[0]);
3750 (define_insn "*zero_extendqi<mode>2_movzbl_and"
3751 [(set (match_operand:SWI24 0 "register_operand" "=r,r")
3752 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3753 (clobber (reg:CC FLAGS_REG))]
3754 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun)"
3756 [(set_attr "type" "imovx,alu1")
3757 (set_attr "mode" "<MODE>")])
3759 ;; For the movzbl case strip only the clobber
3761 [(set (match_operand:SWI24 0 "register_operand" "")
3762 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3763 (clobber (reg:CC FLAGS_REG))]
3765 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))
3766 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3768 (zero_extend:SWI24 (match_dup 1)))])
3770 ; zero extend to SImode to avoid partial register stalls
3771 (define_insn "*zero_extendqi<mode>2_movzbl"
3772 [(set (match_operand:SWI24 0 "register_operand" "=r")
3773 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3775 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))"
3776 "movz{bl|x}\t{%1, %k0|%k0, %1}"
3777 [(set_attr "type" "imovx")
3778 (set_attr "mode" "SI")])
3780 ;; Rest is handled by single and.
3782 [(set (match_operand:SWI24 0 "register_operand" "")
3783 (zero_extend:SWI24 (match_operand:QI 1 "register_operand" "")))
3784 (clobber (reg:CC FLAGS_REG))]
3786 && true_regnum (operands[0]) == true_regnum (operands[1])"
3787 [(parallel [(set (match_dup 0) (and:SWI24 (match_dup 0) (const_int 255)))
3788 (clobber (reg:CC FLAGS_REG))])])
3790 ;; Sign extension instructions
3792 (define_expand "extendsidi2"
3793 [(set (match_operand:DI 0 "register_operand" "")
3794 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))]
3799 emit_insn (gen_extendsidi2_1 (operands[0], operands[1]));
3804 (define_insn "*extendsidi2_rex64"
3805 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3806 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3810 movs{lq|x}\t{%1, %0|%0, %1}"
3811 [(set_attr "type" "imovx")
3812 (set_attr "mode" "DI")
3813 (set_attr "prefix_0f" "0")
3814 (set_attr "modrm" "0,1")])
3816 (define_insn "extendsidi2_1"
3817 [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3818 (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3819 (clobber (reg:CC FLAGS_REG))
3820 (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3824 ;; Extend to memory case when source register does die.
3826 [(set (match_operand:DI 0 "memory_operand" "")
3827 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3828 (clobber (reg:CC FLAGS_REG))
3829 (clobber (match_operand:SI 2 "register_operand" ""))]
3831 && dead_or_set_p (insn, operands[1])
3832 && !reg_mentioned_p (operands[1], operands[0]))"
3833 [(set (match_dup 3) (match_dup 1))
3834 (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3835 (clobber (reg:CC FLAGS_REG))])
3836 (set (match_dup 4) (match_dup 1))]
3837 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3839 ;; Extend to memory case when source register does not die.
3841 [(set (match_operand:DI 0 "memory_operand" "")
3842 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3843 (clobber (reg:CC FLAGS_REG))
3844 (clobber (match_operand:SI 2 "register_operand" ""))]
3848 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3850 emit_move_insn (operands[3], operands[1]);
3852 /* Generate a cltd if possible and doing so it profitable. */
3853 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3854 && true_regnum (operands[1]) == AX_REG
3855 && true_regnum (operands[2]) == DX_REG)
3857 emit_insn (gen_ashrsi3_cvt (operands[2], operands[1], GEN_INT (31)));
3861 emit_move_insn (operands[2], operands[1]);
3862 emit_insn (gen_ashrsi3_cvt (operands[2], operands[2], GEN_INT (31)));
3864 emit_move_insn (operands[4], operands[2]);
3868 ;; Extend to register case. Optimize case where source and destination
3869 ;; registers match and cases where we can use cltd.
3871 [(set (match_operand:DI 0 "register_operand" "")
3872 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3873 (clobber (reg:CC FLAGS_REG))
3874 (clobber (match_scratch:SI 2 ""))]
3878 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3880 if (true_regnum (operands[3]) != true_regnum (operands[1]))
3881 emit_move_insn (operands[3], operands[1]);
3883 /* Generate a cltd if possible and doing so it profitable. */
3884 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3885 && true_regnum (operands[3]) == AX_REG
3886 && true_regnum (operands[4]) == DX_REG)
3888 emit_insn (gen_ashrsi3_cvt (operands[4], operands[3], GEN_INT (31)));
3892 if (true_regnum (operands[4]) != true_regnum (operands[1]))
3893 emit_move_insn (operands[4], operands[1]);
3895 emit_insn (gen_ashrsi3_cvt (operands[4], operands[4], GEN_INT (31)));
3899 (define_insn "extend<mode>di2"
3900 [(set (match_operand:DI 0 "register_operand" "=r")
3902 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3904 "movs{<imodesuffix>q|x}\t{%1, %0|%0, %1}"
3905 [(set_attr "type" "imovx")
3906 (set_attr "mode" "DI")])