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 ;; p -- print raw symbol name.
57 ;; X -- don't print any sort of PIC '@' suffix for a symbol.
58 ;; & -- print some in-use local-dynamic symbol name.
59 ;; H -- print a memory address offset by 8; used for sse high-parts
60 ;; Y -- print condition for XOP pcom* instruction.
61 ;; + -- print a branch hint as 'cs' or 'ds' prefix
62 ;; ; -- print a semicolon (after prefixes due to bug in older gas).
63 ;; @ -- print a segment register of thread base pointer load
67 (define_c_enum "unspec" [
68 ;; Relocation specifiers
79 UNSPEC_MACHOPIC_OFFSET
89 UNSPEC_MEMORY_BLOCKAGE
99 ;; Other random patterns
108 UNSPEC_LD_MPIC ; load_macho_picbase
110 UNSPEC_DIV_ALREADY_SPLIT
111 UNSPEC_CALL_NEEDS_VZEROUPPER
114 ;; For SSE/MMX support:
132 UNSPEC_MS_TO_SYSV_CALL
134 ;; Generic math support
136 UNSPEC_IEEE_MIN ; not commutative
137 UNSPEC_IEEE_MAX ; not commutative
139 ;; x87 Floating point
155 UNSPEC_FRNDINT_MASK_PM
159 ;; x87 Double output FP
191 ;; For SSE4.1 support
201 ;; For SSE4.2 support
208 UNSPEC_XOP_UNSIGNED_CMP
219 UNSPEC_AESKEYGENASSIST
221 ;; For PCLMUL support
245 ;; For RDRAND support
253 (define_c_enum "unspecv" [
256 UNSPECV_PROBE_STACK_RANGE
276 UNSPECV_LLWP_INTRINSIC
277 UNSPECV_SLWP_INTRINSIC
278 UNSPECV_LWPVAL_INTRINSIC
279 UNSPECV_LWPINS_INTRINSIC
284 UNSPECV_SPLIT_STACK_RETURN
287 ;; Constants to represent rounding modes in the ROUND instruction
296 ;; Constants to represent pcomtrue/pcomfalse variants
306 ;; Constants used in the XOP pperm instruction
308 [(PPERM_SRC 0x00) /* copy source */
309 (PPERM_INVERT 0x20) /* invert source */
310 (PPERM_REVERSE 0x40) /* bit reverse source */
311 (PPERM_REV_INV 0x60) /* bit reverse & invert src */
312 (PPERM_ZERO 0x80) /* all 0's */
313 (PPERM_ONES 0xa0) /* all 1's */
314 (PPERM_SIGN 0xc0) /* propagate sign bit */
315 (PPERM_INV_SIGN 0xe0) /* invert & propagate sign */
316 (PPERM_SRC1 0x00) /* use first source byte */
317 (PPERM_SRC2 0x10) /* use second source byte */
320 ;; Registers by name.
373 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
376 ;; In C guard expressions, put expressions which may be compile-time
377 ;; constants first. This allows for better optimization. For
378 ;; example, write "TARGET_64BIT && reload_completed", not
379 ;; "reload_completed && TARGET_64BIT".
383 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,corei7,
384 atom,generic64,amdfam10,bdver1,bdver2,btver1"
385 (const (symbol_ref "ix86_schedule")))
387 ;; A basic instruction type. Refinements due to arguments to be
388 ;; provided in other attributes.
391 alu,alu1,negnot,imov,imovx,lea,
392 incdec,ishift,ishiftx,ishift1,rotate,rotatex,rotate1,imul,imulx,idiv,
393 icmp,test,ibr,setcc,icmov,
394 push,pop,call,callv,leave,
396 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
397 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
398 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
399 ssemuladd,sse4arg,lwp,
400 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
401 (const_string "other"))
403 ;; Main data type used by the insn
405 "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
406 (const_string "unknown"))
408 ;; The CPU unit operations uses.
409 (define_attr "unit" "integer,i387,sse,mmx,unknown"
410 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
411 (const_string "i387")
412 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
413 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
414 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
416 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
418 (eq_attr "type" "other")
419 (const_string "unknown")]
420 (const_string "integer")))
422 ;; The (bounding maximum) length of an instruction immediate.
423 (define_attr "length_immediate" ""
424 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
427 (eq_attr "unit" "i387,sse,mmx")
429 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,ishiftx,ishift1,
430 rotate,rotatex,rotate1,imul,icmp,push,pop")
431 (symbol_ref "ix86_attr_length_immediate_default (insn, true)")
432 (eq_attr "type" "imov,test")
433 (symbol_ref "ix86_attr_length_immediate_default (insn, false)")
434 (eq_attr "type" "call")
435 (if_then_else (match_operand 0 "constant_call_address_operand" "")
438 (eq_attr "type" "callv")
439 (if_then_else (match_operand 1 "constant_call_address_operand" "")
442 ;; We don't know the size before shorten_branches. Expect
443 ;; the instruction to fit for better scheduling.
444 (eq_attr "type" "ibr")
447 (symbol_ref "/* Update immediate_length and other attributes! */
448 gcc_unreachable (),1")))
450 ;; The (bounding maximum) length of an instruction address.
451 (define_attr "length_address" ""
452 (cond [(eq_attr "type" "str,other,multi,fxch")
454 (and (eq_attr "type" "call")
455 (match_operand 0 "constant_call_address_operand" ""))
457 (and (eq_attr "type" "callv")
458 (match_operand 1 "constant_call_address_operand" ""))
461 (symbol_ref "ix86_attr_length_address_default (insn)")))
463 ;; Set when length prefix is used.
464 (define_attr "prefix_data16" ""
465 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
467 (eq_attr "mode" "HI")
469 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
474 ;; Set when string REP prefix is used.
475 (define_attr "prefix_rep" ""
476 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
478 (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
483 ;; Set when 0f opcode prefix is used.
484 (define_attr "prefix_0f" ""
486 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
487 (eq_attr "unit" "sse,mmx"))
491 ;; Set when REX opcode prefix is used.
492 (define_attr "prefix_rex" ""
493 (cond [(not (match_test "TARGET_64BIT"))
495 (and (eq_attr "mode" "DI")
496 (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
497 (eq_attr "unit" "!mmx")))
499 (and (eq_attr "mode" "QI")
500 (match_test "x86_extended_QIreg_mentioned_p (insn)"))
502 (match_test "x86_extended_reg_mentioned_p (insn)")
504 (and (eq_attr "type" "imovx")
505 (match_operand:QI 1 "ext_QIreg_operand" ""))
510 ;; There are also additional prefixes in 3DNOW, SSSE3.
511 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
512 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
513 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
514 (define_attr "prefix_extra" ""
515 (cond [(eq_attr "type" "ssemuladd,sse4arg")
517 (eq_attr "type" "sseiadd1,ssecvt1")
522 ;; Prefix used: original, VEX or maybe VEX.
523 (define_attr "prefix" "orig,vex,maybe_vex"
524 (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
526 (const_string "orig")))
528 ;; VEX W bit is used.
529 (define_attr "prefix_vex_w" "" (const_int 0))
531 ;; The length of VEX prefix
532 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
533 ;; 0f38/0f3a prefixes can't. In i386.md 0f3[8a] is
534 ;; still prefix_0f 1, with prefix_extra 1.
535 (define_attr "length_vex" ""
536 (if_then_else (and (eq_attr "prefix_0f" "1")
537 (eq_attr "prefix_extra" "0"))
538 (if_then_else (eq_attr "prefix_vex_w" "1")
539 (symbol_ref "ix86_attr_length_vex_default (insn, true, true)")
540 (symbol_ref "ix86_attr_length_vex_default (insn, true, false)"))
541 (if_then_else (eq_attr "prefix_vex_w" "1")
542 (symbol_ref "ix86_attr_length_vex_default (insn, false, true)")
543 (symbol_ref "ix86_attr_length_vex_default (insn, false, false)"))))
545 ;; Set when modrm byte is used.
546 (define_attr "modrm" ""
547 (cond [(eq_attr "type" "str,leave")
549 (eq_attr "unit" "i387")
551 (and (eq_attr "type" "incdec")
552 (and (not (match_test "TARGET_64BIT"))
553 (ior (match_operand:SI 1 "register_operand" "")
554 (match_operand:HI 1 "register_operand" ""))))
556 (and (eq_attr "type" "push")
557 (not (match_operand 1 "memory_operand" "")))
559 (and (eq_attr "type" "pop")
560 (not (match_operand 0 "memory_operand" "")))
562 (and (eq_attr "type" "imov")
563 (and (not (eq_attr "mode" "DI"))
564 (ior (and (match_operand 0 "register_operand" "")
565 (match_operand 1 "immediate_operand" ""))
566 (ior (and (match_operand 0 "ax_reg_operand" "")
567 (match_operand 1 "memory_displacement_only_operand" ""))
568 (and (match_operand 0 "memory_displacement_only_operand" "")
569 (match_operand 1 "ax_reg_operand" ""))))))
571 (and (eq_attr "type" "call")
572 (match_operand 0 "constant_call_address_operand" ""))
574 (and (eq_attr "type" "callv")
575 (match_operand 1 "constant_call_address_operand" ""))
577 (and (eq_attr "type" "alu,alu1,icmp,test")
578 (match_operand 0 "ax_reg_operand" ""))
579 (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
583 ;; The (bounding maximum) length of an instruction in bytes.
584 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
585 ;; Later we may want to split them and compute proper length as for
587 (define_attr "length" ""
588 (cond [(eq_attr "type" "other,multi,fistp,frndint")
590 (eq_attr "type" "fcmp")
592 (eq_attr "unit" "i387")
594 (plus (attr "prefix_data16")
595 (attr "length_address")))
596 (ior (eq_attr "prefix" "vex")
597 (and (eq_attr "prefix" "maybe_vex")
598 (match_test "TARGET_AVX")))
599 (plus (attr "length_vex")
600 (plus (attr "length_immediate")
602 (attr "length_address"))))]
603 (plus (plus (attr "modrm")
604 (plus (attr "prefix_0f")
605 (plus (attr "prefix_rex")
606 (plus (attr "prefix_extra")
608 (plus (attr "prefix_rep")
609 (plus (attr "prefix_data16")
610 (plus (attr "length_immediate")
611 (attr "length_address")))))))
613 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
614 ;; `store' if there is a simple memory reference therein, or `unknown'
615 ;; if the instruction is complex.
617 (define_attr "memory" "none,load,store,both,unknown"
618 (cond [(eq_attr "type" "other,multi,str,lwp")
619 (const_string "unknown")
620 (eq_attr "type" "lea,fcmov,fpspc")
621 (const_string "none")
622 (eq_attr "type" "fistp,leave")
623 (const_string "both")
624 (eq_attr "type" "frndint")
625 (const_string "load")
626 (eq_attr "type" "push")
627 (if_then_else (match_operand 1 "memory_operand" "")
628 (const_string "both")
629 (const_string "store"))
630 (eq_attr "type" "pop")
631 (if_then_else (match_operand 0 "memory_operand" "")
632 (const_string "both")
633 (const_string "load"))
634 (eq_attr "type" "setcc")
635 (if_then_else (match_operand 0 "memory_operand" "")
636 (const_string "store")
637 (const_string "none"))
638 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
639 (if_then_else (ior (match_operand 0 "memory_operand" "")
640 (match_operand 1 "memory_operand" ""))
641 (const_string "load")
642 (const_string "none"))
643 (eq_attr "type" "ibr")
644 (if_then_else (match_operand 0 "memory_operand" "")
645 (const_string "load")
646 (const_string "none"))
647 (eq_attr "type" "call")
648 (if_then_else (match_operand 0 "constant_call_address_operand" "")
649 (const_string "none")
650 (const_string "load"))
651 (eq_attr "type" "callv")
652 (if_then_else (match_operand 1 "constant_call_address_operand" "")
653 (const_string "none")
654 (const_string "load"))
655 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
656 (match_operand 1 "memory_operand" ""))
657 (const_string "both")
658 (and (match_operand 0 "memory_operand" "")
659 (match_operand 1 "memory_operand" ""))
660 (const_string "both")
661 (match_operand 0 "memory_operand" "")
662 (const_string "store")
663 (match_operand 1 "memory_operand" "")
664 (const_string "load")
666 "!alu1,negnot,ishift1,
667 imov,imovx,icmp,test,bitmanip,
669 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
670 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
671 (match_operand 2 "memory_operand" ""))
672 (const_string "load")
673 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
674 (match_operand 3 "memory_operand" ""))
675 (const_string "load")
677 (const_string "none")))
679 ;; Indicates if an instruction has both an immediate and a displacement.
681 (define_attr "imm_disp" "false,true,unknown"
682 (cond [(eq_attr "type" "other,multi")
683 (const_string "unknown")
684 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
685 (and (match_operand 0 "memory_displacement_operand" "")
686 (match_operand 1 "immediate_operand" "")))
687 (const_string "true")
688 (and (eq_attr "type" "alu,ishift,ishiftx,rotate,rotatex,imul,idiv")
689 (and (match_operand 0 "memory_displacement_operand" "")
690 (match_operand 2 "immediate_operand" "")))
691 (const_string "true")
693 (const_string "false")))
695 ;; Indicates if an FP operation has an integer source.
697 (define_attr "fp_int_src" "false,true"
698 (const_string "false"))
700 ;; Defines rounding mode of an FP operation.
702 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
703 (const_string "any"))
705 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
706 (define_attr "use_carry" "0,1" (const_string "0"))
708 ;; Define attribute to indicate unaligned ssemov insns
709 (define_attr "movu" "0,1" (const_string "0"))
711 ;; Used to control the "enabled" attribute on a per-instruction basis.
712 (define_attr "isa" "base,sse2,sse2_noavx,sse3,sse4,sse4_noavx,noavx,avx,bmi2"
713 (const_string "base"))
715 (define_attr "enabled" ""
716 (cond [(eq_attr "isa" "sse2") (symbol_ref "TARGET_SSE2")
717 (eq_attr "isa" "sse2_noavx")
718 (symbol_ref "TARGET_SSE2 && !TARGET_AVX")
719 (eq_attr "isa" "sse3") (symbol_ref "TARGET_SSE3")
720 (eq_attr "isa" "sse4") (symbol_ref "TARGET_SSE4_1")
721 (eq_attr "isa" "sse4_noavx")
722 (symbol_ref "TARGET_SSE4_1 && !TARGET_AVX")
723 (eq_attr "isa" "avx") (symbol_ref "TARGET_AVX")
724 (eq_attr "isa" "noavx") (symbol_ref "!TARGET_AVX")
725 (eq_attr "isa" "bmi2") (symbol_ref "TARGET_BMI2")
729 ;; Describe a user's asm statement.
730 (define_asm_attributes
731 [(set_attr "length" "128")
732 (set_attr "type" "multi")])
734 (define_code_iterator plusminus [plus minus])
736 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
738 ;; Base name for define_insn
739 (define_code_attr plusminus_insn
740 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
741 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
743 ;; Base name for insn mnemonic.
744 (define_code_attr plusminus_mnemonic
745 [(plus "add") (ss_plus "adds") (us_plus "addus")
746 (minus "sub") (ss_minus "subs") (us_minus "subus")])
747 (define_code_attr plusminus_carry_mnemonic
748 [(plus "adc") (minus "sbb")])
750 ;; Mark commutative operators as such in constraints.
751 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
752 (minus "") (ss_minus "") (us_minus "")])
754 ;; Mapping of max and min
755 (define_code_iterator maxmin [smax smin umax umin])
757 ;; Mapping of signed max and min
758 (define_code_iterator smaxmin [smax smin])
760 ;; Mapping of unsigned max and min
761 (define_code_iterator umaxmin [umax umin])
763 ;; Base name for integer and FP insn mnemonic
764 (define_code_attr maxmin_int [(smax "maxs") (smin "mins")
765 (umax "maxu") (umin "minu")])
766 (define_code_attr maxmin_float [(smax "max") (smin "min")])
768 ;; Mapping of logic operators
769 (define_code_iterator any_logic [and ior xor])
770 (define_code_iterator any_or [ior xor])
772 ;; Base name for insn mnemonic.
773 (define_code_attr logic [(and "and") (ior "or") (xor "xor")])
775 ;; Mapping of shift-right operators
776 (define_code_iterator any_shiftrt [lshiftrt ashiftrt])
778 ;; Base name for define_insn
779 (define_code_attr shift_insn
780 [(ashift "ashl") (lshiftrt "lshr") (ashiftrt "ashr")])
782 ;; Base name for insn mnemonic.
783 (define_code_attr shift [(ashift "sll") (lshiftrt "shr") (ashiftrt "sar")])
785 ;; Mapping of rotate operators
786 (define_code_iterator any_rotate [rotate rotatert])
788 ;; Base name for define_insn
789 (define_code_attr rotate_insn [(rotate "rotl") (rotatert "rotr")])
791 ;; Base name for insn mnemonic.
792 (define_code_attr rotate [(rotate "rol") (rotatert "ror")])
794 ;; Mapping of abs neg operators
795 (define_code_iterator absneg [abs neg])
797 ;; Base name for x87 insn mnemonic.
798 (define_code_attr absneg_mnemonic [(abs "abs") (neg "chs")])
800 ;; Used in signed and unsigned widening multiplications.
801 (define_code_iterator any_extend [sign_extend zero_extend])
803 ;; Prefix for insn menmonic.
804 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")])
806 ;; Prefix for define_insn
807 (define_code_attr u [(sign_extend "") (zero_extend "u")])
808 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
810 ;; All integer modes.
811 (define_mode_iterator SWI1248x [QI HI SI DI])
813 ;; All integer modes without QImode.
814 (define_mode_iterator SWI248x [HI SI DI])
816 ;; All integer modes without QImode and HImode.
817 (define_mode_iterator SWI48x [SI DI])
819 ;; All integer modes without SImode and DImode.
820 (define_mode_iterator SWI12 [QI HI])
822 ;; All integer modes without DImode.
823 (define_mode_iterator SWI124 [QI HI SI])
825 ;; All integer modes without QImode and DImode.
826 (define_mode_iterator SWI24 [HI SI])
828 ;; Single word integer modes.
829 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
831 ;; Single word integer modes without QImode.
832 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
834 ;; Single word integer modes without QImode and HImode.
835 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
837 ;; All math-dependant single and double word integer modes.
838 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
839 (HI "TARGET_HIMODE_MATH")
840 SI DI (TI "TARGET_64BIT")])
842 ;; Math-dependant single word integer modes.
843 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
844 (HI "TARGET_HIMODE_MATH")
845 SI (DI "TARGET_64BIT")])
847 ;; Math-dependant integer modes without DImode.
848 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
849 (HI "TARGET_HIMODE_MATH")
852 ;; Math-dependant single word integer modes without QImode.
853 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
854 SI (DI "TARGET_64BIT")])
856 ;; Double word integer modes.
857 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
858 (TI "TARGET_64BIT")])
860 ;; Double word integer modes as mode attribute.
861 (define_mode_attr DWI [(SI "DI") (DI "TI")])
862 (define_mode_attr dwi [(SI "di") (DI "ti")])
864 ;; Half mode for double word integer modes.
865 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
866 (DI "TARGET_64BIT")])
868 ;; Instruction suffix for integer modes.
869 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
871 ;; Pointer size prefix for integer modes (Intel asm dialect)
872 (define_mode_attr iptrsize [(QI "BYTE")
877 ;; Register class for integer modes.
878 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
880 ;; Immediate operand constraint for integer modes.
881 (define_mode_attr i [(QI "n") (HI "n") (SI "e") (DI "e")])
883 ;; General operand constraint for word modes.
884 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "rme") (DI "rme")])
886 ;; Immediate operand constraint for double integer modes.
887 (define_mode_attr di [(SI "nF") (DI "e")])
889 ;; Immediate operand constraint for shifts.
890 (define_mode_attr S [(QI "I") (HI "I") (SI "I") (DI "J") (TI "O")])
892 ;; General operand predicate for integer modes.
893 (define_mode_attr general_operand
894 [(QI "general_operand")
895 (HI "general_operand")
896 (SI "x86_64_general_operand")
897 (DI "x86_64_general_operand")
898 (TI "x86_64_general_operand")])
900 ;; General sign/zero extend operand predicate for integer modes.
901 (define_mode_attr general_szext_operand
902 [(QI "general_operand")
903 (HI "general_operand")
904 (SI "x86_64_szext_general_operand")
905 (DI "x86_64_szext_general_operand")])
907 ;; Immediate operand predicate for integer modes.
908 (define_mode_attr immediate_operand
909 [(QI "immediate_operand")
910 (HI "immediate_operand")
911 (SI "x86_64_immediate_operand")
912 (DI "x86_64_immediate_operand")])
914 ;; Nonmemory operand predicate for integer modes.
915 (define_mode_attr nonmemory_operand
916 [(QI "nonmemory_operand")
917 (HI "nonmemory_operand")
918 (SI "x86_64_nonmemory_operand")
919 (DI "x86_64_nonmemory_operand")])
921 ;; Operand predicate for shifts.
922 (define_mode_attr shift_operand
923 [(QI "nonimmediate_operand")
924 (HI "nonimmediate_operand")
925 (SI "nonimmediate_operand")
926 (DI "shiftdi_operand")
927 (TI "register_operand")])
929 ;; Operand predicate for shift argument.
930 (define_mode_attr shift_immediate_operand
931 [(QI "const_1_to_31_operand")
932 (HI "const_1_to_31_operand")
933 (SI "const_1_to_31_operand")
934 (DI "const_1_to_63_operand")])
936 ;; Input operand predicate for arithmetic left shifts.
937 (define_mode_attr ashl_input_operand
938 [(QI "nonimmediate_operand")
939 (HI "nonimmediate_operand")
940 (SI "nonimmediate_operand")
941 (DI "ashldi_input_operand")
942 (TI "reg_or_pm1_operand")])
944 ;; SSE and x87 SFmode and DFmode floating point modes
945 (define_mode_iterator MODEF [SF DF])
947 ;; All x87 floating point modes
948 (define_mode_iterator X87MODEF [SF DF XF])
950 ;; SSE instruction suffix for various modes
951 (define_mode_attr ssemodesuffix
953 (V8SF "ps") (V4DF "pd")
954 (V4SF "ps") (V2DF "pd")
955 (V16QI "b") (V8HI "w") (V4SI "d") (V2DI "q")
956 (V32QI "b") (V16HI "w") (V8SI "d") (V4DI "q")])
958 ;; SSE vector suffix for floating point modes
959 (define_mode_attr ssevecmodesuffix [(SF "ps") (DF "pd")])
961 ;; SSE vector mode corresponding to a scalar mode
962 (define_mode_attr ssevecmode
963 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
965 ;; Instruction suffix for REX 64bit operators.
966 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
968 ;; This mode iterator allows :P to be used for patterns that operate on
969 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
970 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
972 ;; This mode iterator allows :PTR to be used for patterns that operate on
973 ;; ptr_mode sized quantities.
974 (define_mode_iterator PTR
975 [(SI "ptr_mode == SImode") (DI "ptr_mode == DImode")])
977 ;; Scheduling descriptions
979 (include "pentium.md")
982 (include "athlon.md")
983 (include "bdver1.md")
989 ;; Operand and operator predicates and constraints
991 (include "predicates.md")
992 (include "constraints.md")
995 ;; Compare and branch/compare and store instructions.
997 (define_expand "cbranch<mode>4"
998 [(set (reg:CC FLAGS_REG)
999 (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
1000 (match_operand:SDWIM 2 "<general_operand>" "")))
1001 (set (pc) (if_then_else
1002 (match_operator 0 "ordered_comparison_operator"
1003 [(reg:CC FLAGS_REG) (const_int 0)])
1004 (label_ref (match_operand 3 "" ""))
1008 if (MEM_P (operands[1]) && MEM_P (operands[2]))
1009 operands[1] = force_reg (<MODE>mode, operands[1]);
1010 ix86_expand_branch (GET_CODE (operands[0]),
1011 operands[1], operands[2], operands[3]);
1015 (define_expand "cstore<mode>4"
1016 [(set (reg:CC FLAGS_REG)
1017 (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
1018 (match_operand:SWIM 3 "<general_operand>" "")))
1019 (set (match_operand:QI 0 "register_operand" "")
1020 (match_operator 1 "ordered_comparison_operator"
1021 [(reg:CC FLAGS_REG) (const_int 0)]))]
1024 if (MEM_P (operands[2]) && MEM_P (operands[3]))
1025 operands[2] = force_reg (<MODE>mode, operands[2]);
1026 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1027 operands[2], operands[3]);
1031 (define_expand "cmp<mode>_1"
1032 [(set (reg:CC FLAGS_REG)
1033 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
1034 (match_operand:SWI48 1 "<general_operand>" "")))])
1036 (define_insn "*cmp<mode>_ccno_1"
1037 [(set (reg FLAGS_REG)
1038 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
1039 (match_operand:SWI 1 "const0_operand" "")))]
1040 "ix86_match_ccmode (insn, CCNOmode)"
1042 test{<imodesuffix>}\t%0, %0
1043 cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1044 [(set_attr "type" "test,icmp")
1045 (set_attr "length_immediate" "0,1")
1046 (set_attr "mode" "<MODE>")])
1048 (define_insn "*cmp<mode>_1"
1049 [(set (reg FLAGS_REG)
1050 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1051 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
1052 "ix86_match_ccmode (insn, CCmode)"
1053 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1054 [(set_attr "type" "icmp")
1055 (set_attr "mode" "<MODE>")])
1057 (define_insn "*cmp<mode>_minus_1"
1058 [(set (reg FLAGS_REG)
1060 (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1061 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
1063 "ix86_match_ccmode (insn, CCGOCmode)"
1064 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1065 [(set_attr "type" "icmp")
1066 (set_attr "mode" "<MODE>")])
1068 (define_insn "*cmpqi_ext_1"
1069 [(set (reg FLAGS_REG)
1071 (match_operand:QI 0 "general_operand" "Qm")
1074 (match_operand 1 "ext_register_operand" "Q")
1076 (const_int 8)) 0)))]
1077 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1078 "cmp{b}\t{%h1, %0|%0, %h1}"
1079 [(set_attr "type" "icmp")
1080 (set_attr "mode" "QI")])
1082 (define_insn "*cmpqi_ext_1_rex64"
1083 [(set (reg FLAGS_REG)
1085 (match_operand:QI 0 "register_operand" "Q")
1088 (match_operand 1 "ext_register_operand" "Q")
1090 (const_int 8)) 0)))]
1091 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1092 "cmp{b}\t{%h1, %0|%0, %h1}"
1093 [(set_attr "type" "icmp")
1094 (set_attr "mode" "QI")])
1096 (define_insn "*cmpqi_ext_2"
1097 [(set (reg FLAGS_REG)
1101 (match_operand 0 "ext_register_operand" "Q")
1104 (match_operand:QI 1 "const0_operand" "")))]
1105 "ix86_match_ccmode (insn, CCNOmode)"
1107 [(set_attr "type" "test")
1108 (set_attr "length_immediate" "0")
1109 (set_attr "mode" "QI")])
1111 (define_expand "cmpqi_ext_3"
1112 [(set (reg:CC FLAGS_REG)
1116 (match_operand 0 "ext_register_operand" "")
1119 (match_operand:QI 1 "immediate_operand" "")))])
1121 (define_insn "*cmpqi_ext_3_insn"
1122 [(set (reg FLAGS_REG)
1126 (match_operand 0 "ext_register_operand" "Q")
1129 (match_operand:QI 1 "general_operand" "Qmn")))]
1130 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1131 "cmp{b}\t{%1, %h0|%h0, %1}"
1132 [(set_attr "type" "icmp")
1133 (set_attr "modrm" "1")
1134 (set_attr "mode" "QI")])
1136 (define_insn "*cmpqi_ext_3_insn_rex64"
1137 [(set (reg FLAGS_REG)
1141 (match_operand 0 "ext_register_operand" "Q")
1144 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1145 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1146 "cmp{b}\t{%1, %h0|%h0, %1}"
1147 [(set_attr "type" "icmp")
1148 (set_attr "modrm" "1")
1149 (set_attr "mode" "QI")])
1151 (define_insn "*cmpqi_ext_4"
1152 [(set (reg FLAGS_REG)
1156 (match_operand 0 "ext_register_operand" "Q")
1161 (match_operand 1 "ext_register_operand" "Q")
1163 (const_int 8)) 0)))]
1164 "ix86_match_ccmode (insn, CCmode)"
1165 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1166 [(set_attr "type" "icmp")
1167 (set_attr "mode" "QI")])
1169 ;; These implement float point compares.
1170 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1171 ;; which would allow mix and match FP modes on the compares. Which is what
1172 ;; the old patterns did, but with many more of them.
1174 (define_expand "cbranchxf4"
1175 [(set (reg:CC FLAGS_REG)
1176 (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1177 (match_operand:XF 2 "nonmemory_operand" "")))
1178 (set (pc) (if_then_else
1179 (match_operator 0 "ix86_fp_comparison_operator"
1182 (label_ref (match_operand 3 "" ""))
1186 ix86_expand_branch (GET_CODE (operands[0]),
1187 operands[1], operands[2], operands[3]);
1191 (define_expand "cstorexf4"
1192 [(set (reg:CC FLAGS_REG)
1193 (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1194 (match_operand:XF 3 "nonmemory_operand" "")))
1195 (set (match_operand:QI 0 "register_operand" "")
1196 (match_operator 1 "ix86_fp_comparison_operator"
1201 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1202 operands[2], operands[3]);
1206 (define_expand "cbranch<mode>4"
1207 [(set (reg:CC FLAGS_REG)
1208 (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1209 (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1210 (set (pc) (if_then_else
1211 (match_operator 0 "ix86_fp_comparison_operator"
1214 (label_ref (match_operand 3 "" ""))
1216 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1218 ix86_expand_branch (GET_CODE (operands[0]),
1219 operands[1], operands[2], operands[3]);
1223 (define_expand "cstore<mode>4"
1224 [(set (reg:CC FLAGS_REG)
1225 (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1226 (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1227 (set (match_operand:QI 0 "register_operand" "")
1228 (match_operator 1 "ix86_fp_comparison_operator"
1231 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1233 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1234 operands[2], operands[3]);
1238 (define_expand "cbranchcc4"
1239 [(set (pc) (if_then_else
1240 (match_operator 0 "comparison_operator"
1241 [(match_operand 1 "flags_reg_operand" "")
1242 (match_operand 2 "const0_operand" "")])
1243 (label_ref (match_operand 3 "" ""))
1247 ix86_expand_branch (GET_CODE (operands[0]),
1248 operands[1], operands[2], operands[3]);
1252 (define_expand "cstorecc4"
1253 [(set (match_operand:QI 0 "register_operand" "")
1254 (match_operator 1 "comparison_operator"
1255 [(match_operand 2 "flags_reg_operand" "")
1256 (match_operand 3 "const0_operand" "")]))]
1259 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1260 operands[2], operands[3]);
1265 ;; FP compares, step 1:
1266 ;; Set the FP condition codes.
1268 ;; CCFPmode compare with exceptions
1269 ;; CCFPUmode compare with no exceptions
1271 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1272 ;; used to manage the reg stack popping would not be preserved.
1274 (define_insn "*cmpfp_0"
1275 [(set (match_operand:HI 0 "register_operand" "=a")
1278 (match_operand 1 "register_operand" "f")
1279 (match_operand 2 "const0_operand" ""))]
1281 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1282 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1283 "* return output_fp_compare (insn, operands, false, false);"
1284 [(set_attr "type" "multi")
1285 (set_attr "unit" "i387")
1287 (cond [(match_operand:SF 1 "" "")
1289 (match_operand:DF 1 "" "")
1292 (const_string "XF")))])
1294 (define_insn_and_split "*cmpfp_0_cc"
1295 [(set (reg:CCFP FLAGS_REG)
1297 (match_operand 1 "register_operand" "f")
1298 (match_operand 2 "const0_operand" "")))
1299 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1300 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1301 && TARGET_SAHF && !TARGET_CMOVE
1302 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1304 "&& reload_completed"
1307 [(compare:CCFP (match_dup 1)(match_dup 2))]
1309 (set (reg:CC FLAGS_REG)
1310 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1312 [(set_attr "type" "multi")
1313 (set_attr "unit" "i387")
1315 (cond [(match_operand:SF 1 "" "")
1317 (match_operand:DF 1 "" "")
1320 (const_string "XF")))])
1322 (define_insn "*cmpfp_xf"
1323 [(set (match_operand:HI 0 "register_operand" "=a")
1326 (match_operand:XF 1 "register_operand" "f")
1327 (match_operand:XF 2 "register_operand" "f"))]
1330 "* return output_fp_compare (insn, operands, false, false);"
1331 [(set_attr "type" "multi")
1332 (set_attr "unit" "i387")
1333 (set_attr "mode" "XF")])
1335 (define_insn_and_split "*cmpfp_xf_cc"
1336 [(set (reg:CCFP FLAGS_REG)
1338 (match_operand:XF 1 "register_operand" "f")
1339 (match_operand:XF 2 "register_operand" "f")))
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" "XF")])
1356 (define_insn "*cmpfp_<mode>"
1357 [(set (match_operand:HI 0 "register_operand" "=a")
1360 (match_operand:MODEF 1 "register_operand" "f")
1361 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1364 "* return output_fp_compare (insn, operands, false, false);"
1365 [(set_attr "type" "multi")
1366 (set_attr "unit" "i387")
1367 (set_attr "mode" "<MODE>")])
1369 (define_insn_and_split "*cmpfp_<mode>_cc"
1370 [(set (reg:CCFP FLAGS_REG)
1372 (match_operand:MODEF 1 "register_operand" "f")
1373 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1374 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1376 && TARGET_SAHF && !TARGET_CMOVE"
1378 "&& reload_completed"
1381 [(compare:CCFP (match_dup 1)(match_dup 2))]
1383 (set (reg:CC FLAGS_REG)
1384 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1386 [(set_attr "type" "multi")
1387 (set_attr "unit" "i387")
1388 (set_attr "mode" "<MODE>")])
1390 (define_insn "*cmpfp_u"
1391 [(set (match_operand:HI 0 "register_operand" "=a")
1394 (match_operand 1 "register_operand" "f")
1395 (match_operand 2 "register_operand" "f"))]
1397 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1398 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1399 "* return output_fp_compare (insn, operands, false, true);"
1400 [(set_attr "type" "multi")
1401 (set_attr "unit" "i387")
1403 (cond [(match_operand:SF 1 "" "")
1405 (match_operand:DF 1 "" "")
1408 (const_string "XF")))])
1410 (define_insn_and_split "*cmpfp_u_cc"
1411 [(set (reg:CCFPU FLAGS_REG)
1413 (match_operand 1 "register_operand" "f")
1414 (match_operand 2 "register_operand" "f")))
1415 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1416 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1417 && TARGET_SAHF && !TARGET_CMOVE
1418 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1420 "&& reload_completed"
1423 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1425 (set (reg:CC FLAGS_REG)
1426 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1428 [(set_attr "type" "multi")
1429 (set_attr "unit" "i387")
1431 (cond [(match_operand:SF 1 "" "")
1433 (match_operand:DF 1 "" "")
1436 (const_string "XF")))])
1438 (define_insn "*cmpfp_<mode>"
1439 [(set (match_operand:HI 0 "register_operand" "=a")
1442 (match_operand 1 "register_operand" "f")
1443 (match_operator 3 "float_operator"
1444 [(match_operand:SWI24 2 "memory_operand" "m")]))]
1446 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1447 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1448 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1449 "* return output_fp_compare (insn, operands, false, false);"
1450 [(set_attr "type" "multi")
1451 (set_attr "unit" "i387")
1452 (set_attr "fp_int_src" "true")
1453 (set_attr "mode" "<MODE>")])
1455 (define_insn_and_split "*cmpfp_<mode>_cc"
1456 [(set (reg:CCFP FLAGS_REG)
1458 (match_operand 1 "register_operand" "f")
1459 (match_operator 3 "float_operator"
1460 [(match_operand:SWI24 2 "memory_operand" "m")])))
1461 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1462 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1463 && TARGET_SAHF && !TARGET_CMOVE
1464 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1465 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1467 "&& reload_completed"
1472 (match_op_dup 3 [(match_dup 2)]))]
1474 (set (reg:CC FLAGS_REG)
1475 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1477 [(set_attr "type" "multi")
1478 (set_attr "unit" "i387")
1479 (set_attr "fp_int_src" "true")
1480 (set_attr "mode" "<MODE>")])
1482 ;; FP compares, step 2
1483 ;; Move the fpsw to ax.
1485 (define_insn "x86_fnstsw_1"
1486 [(set (match_operand:HI 0 "register_operand" "=a")
1487 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1490 [(set (attr "length")
1491 (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1492 (set_attr "mode" "SI")
1493 (set_attr "unit" "i387")])
1495 ;; FP compares, step 3
1496 ;; Get ax into flags, general case.
1498 (define_insn "x86_sahf_1"
1499 [(set (reg:CC FLAGS_REG)
1500 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1504 #ifndef HAVE_AS_IX86_SAHF
1506 return ASM_BYTE "0x9e";
1511 [(set_attr "length" "1")
1512 (set_attr "athlon_decode" "vector")
1513 (set_attr "amdfam10_decode" "direct")
1514 (set_attr "bdver1_decode" "direct")
1515 (set_attr "mode" "SI")])
1517 ;; Pentium Pro can do steps 1 through 3 in one go.
1518 ;; comi*, ucomi*, fcomi*, ficomi*, fucomi*
1519 ;; (these i387 instructions set flags directly)
1520 (define_insn "*cmpfp_i_mixed"
1521 [(set (reg:CCFP FLAGS_REG)
1522 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1523 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1524 "TARGET_MIX_SSE_I387
1525 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1526 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1527 "* return output_fp_compare (insn, operands, true, false);"
1528 [(set_attr "type" "fcmp,ssecomi")
1529 (set_attr "prefix" "orig,maybe_vex")
1531 (if_then_else (match_operand:SF 1 "" "")
1533 (const_string "DF")))
1534 (set (attr "prefix_rep")
1535 (if_then_else (eq_attr "type" "ssecomi")
1537 (const_string "*")))
1538 (set (attr "prefix_data16")
1539 (cond [(eq_attr "type" "fcmp")
1541 (eq_attr "mode" "DF")
1544 (const_string "0")))
1545 (set_attr "athlon_decode" "vector")
1546 (set_attr "amdfam10_decode" "direct")
1547 (set_attr "bdver1_decode" "double")])
1549 (define_insn "*cmpfp_i_sse"
1550 [(set (reg:CCFP FLAGS_REG)
1551 (compare:CCFP (match_operand 0 "register_operand" "x")
1552 (match_operand 1 "nonimmediate_operand" "xm")))]
1554 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1555 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1556 "* return output_fp_compare (insn, operands, true, false);"
1557 [(set_attr "type" "ssecomi")
1558 (set_attr "prefix" "maybe_vex")
1560 (if_then_else (match_operand:SF 1 "" "")
1562 (const_string "DF")))
1563 (set_attr "prefix_rep" "0")
1564 (set (attr "prefix_data16")
1565 (if_then_else (eq_attr "mode" "DF")
1567 (const_string "0")))
1568 (set_attr "athlon_decode" "vector")
1569 (set_attr "amdfam10_decode" "direct")
1570 (set_attr "bdver1_decode" "double")])
1572 (define_insn "*cmpfp_i_i387"
1573 [(set (reg:CCFP FLAGS_REG)
1574 (compare:CCFP (match_operand 0 "register_operand" "f")
1575 (match_operand 1 "register_operand" "f")))]
1576 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1578 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1579 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1580 "* return output_fp_compare (insn, operands, true, false);"
1581 [(set_attr "type" "fcmp")
1583 (cond [(match_operand:SF 1 "" "")
1585 (match_operand:DF 1 "" "")
1588 (const_string "XF")))
1589 (set_attr "athlon_decode" "vector")
1590 (set_attr "amdfam10_decode" "direct")
1591 (set_attr "bdver1_decode" "double")])
1593 (define_insn "*cmpfp_iu_mixed"
1594 [(set (reg:CCFPU FLAGS_REG)
1595 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1596 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1597 "TARGET_MIX_SSE_I387
1598 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1599 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1600 "* return output_fp_compare (insn, operands, true, true);"
1601 [(set_attr "type" "fcmp,ssecomi")
1602 (set_attr "prefix" "orig,maybe_vex")
1604 (if_then_else (match_operand:SF 1 "" "")
1606 (const_string "DF")))
1607 (set (attr "prefix_rep")
1608 (if_then_else (eq_attr "type" "ssecomi")
1610 (const_string "*")))
1611 (set (attr "prefix_data16")
1612 (cond [(eq_attr "type" "fcmp")
1614 (eq_attr "mode" "DF")
1617 (const_string "0")))
1618 (set_attr "athlon_decode" "vector")
1619 (set_attr "amdfam10_decode" "direct")
1620 (set_attr "bdver1_decode" "double")])
1622 (define_insn "*cmpfp_iu_sse"
1623 [(set (reg:CCFPU FLAGS_REG)
1624 (compare:CCFPU (match_operand 0 "register_operand" "x")
1625 (match_operand 1 "nonimmediate_operand" "xm")))]
1627 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1628 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1629 "* return output_fp_compare (insn, operands, true, true);"
1630 [(set_attr "type" "ssecomi")
1631 (set_attr "prefix" "maybe_vex")
1633 (if_then_else (match_operand:SF 1 "" "")
1635 (const_string "DF")))
1636 (set_attr "prefix_rep" "0")
1637 (set (attr "prefix_data16")
1638 (if_then_else (eq_attr "mode" "DF")
1640 (const_string "0")))
1641 (set_attr "athlon_decode" "vector")
1642 (set_attr "amdfam10_decode" "direct")
1643 (set_attr "bdver1_decode" "double")])
1645 (define_insn "*cmpfp_iu_387"
1646 [(set (reg:CCFPU FLAGS_REG)
1647 (compare:CCFPU (match_operand 0 "register_operand" "f")
1648 (match_operand 1 "register_operand" "f")))]
1649 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1651 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1652 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1653 "* return output_fp_compare (insn, operands, true, true);"
1654 [(set_attr "type" "fcmp")
1656 (cond [(match_operand:SF 1 "" "")
1658 (match_operand:DF 1 "" "")
1661 (const_string "XF")))
1662 (set_attr "athlon_decode" "vector")
1663 (set_attr "amdfam10_decode" "direct")
1664 (set_attr "bdver1_decode" "direct")])
1666 ;; Push/pop instructions.
1668 (define_insn "*push<mode>2"
1669 [(set (match_operand:DWI 0 "push_operand" "=<")
1670 (match_operand:DWI 1 "general_no_elim_operand" "riF*o"))]
1673 [(set_attr "type" "multi")
1674 (set_attr "mode" "<MODE>")])
1677 [(set (match_operand:TI 0 "push_operand" "")
1678 (match_operand:TI 1 "general_operand" ""))]
1679 "TARGET_64BIT && reload_completed
1680 && !SSE_REG_P (operands[1])"
1682 "ix86_split_long_move (operands); DONE;")
1684 (define_insn "*pushdi2_rex64"
1685 [(set (match_operand:DI 0 "push_operand" "=<,!<")
1686 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
1691 [(set_attr "type" "push,multi")
1692 (set_attr "mode" "DI")])
1694 ;; Convert impossible pushes of immediate to existing instructions.
1695 ;; First try to get scratch register and go through it. In case this
1696 ;; fails, push sign extended lower part first and then overwrite
1697 ;; upper part by 32bit move.
1699 [(match_scratch:DI 2 "r")
1700 (set (match_operand:DI 0 "push_operand" "")
1701 (match_operand:DI 1 "immediate_operand" ""))]
1702 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1703 && !x86_64_immediate_operand (operands[1], DImode)"
1704 [(set (match_dup 2) (match_dup 1))
1705 (set (match_dup 0) (match_dup 2))])
1707 ;; We need to define this as both peepholer and splitter for case
1708 ;; peephole2 pass is not run.
1709 ;; "&& 1" is needed to keep it from matching the previous pattern.
1711 [(set (match_operand:DI 0 "push_operand" "")
1712 (match_operand:DI 1 "immediate_operand" ""))]
1713 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1714 && !x86_64_immediate_operand (operands[1], DImode) && 1"
1715 [(set (match_dup 0) (match_dup 1))
1716 (set (match_dup 2) (match_dup 3))]
1718 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1720 operands[1] = gen_lowpart (DImode, operands[2]);
1721 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1726 [(set (match_operand:DI 0 "push_operand" "")
1727 (match_operand:DI 1 "immediate_operand" ""))]
1728 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
1729 ? epilogue_completed : reload_completed)
1730 && !symbolic_operand (operands[1], DImode)
1731 && !x86_64_immediate_operand (operands[1], DImode)"
1732 [(set (match_dup 0) (match_dup 1))
1733 (set (match_dup 2) (match_dup 3))]
1735 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1737 operands[1] = gen_lowpart (DImode, operands[2]);
1738 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1743 [(set (match_operand:DI 0 "push_operand" "")
1744 (match_operand:DI 1 "general_operand" ""))]
1745 "!TARGET_64BIT && reload_completed
1746 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
1748 "ix86_split_long_move (operands); DONE;")
1750 (define_insn "*pushsi2"
1751 [(set (match_operand:SI 0 "push_operand" "=<")
1752 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1755 [(set_attr "type" "push")
1756 (set_attr "mode" "SI")])
1758 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1759 ;; "push a byte/word". But actually we use pushl, which has the effect
1760 ;; of rounding the amount pushed up to a word.
1762 ;; For TARGET_64BIT we always round up to 8 bytes.
1763 (define_insn "*push<mode>2_rex64"
1764 [(set (match_operand:SWI124 0 "push_operand" "=X")
1765 (match_operand:SWI124 1 "nonmemory_no_elim_operand" "r<i>"))]
1768 [(set_attr "type" "push")
1769 (set_attr "mode" "DI")])
1771 (define_insn "*push<mode>2"
1772 [(set (match_operand:SWI12 0 "push_operand" "=X")
1773 (match_operand:SWI12 1 "nonmemory_no_elim_operand" "rn"))]
1776 [(set_attr "type" "push")
1777 (set_attr "mode" "SI")])
1779 (define_insn "*push<mode>2_prologue"
1780 [(set (match_operand:P 0 "push_operand" "=<")
1781 (match_operand:P 1 "general_no_elim_operand" "r<i>*m"))
1782 (clobber (mem:BLK (scratch)))]
1784 "push{<imodesuffix>}\t%1"
1785 [(set_attr "type" "push")
1786 (set_attr "mode" "<MODE>")])
1788 (define_insn "*pop<mode>1"
1789 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1790 (match_operand:P 1 "pop_operand" ">"))]
1792 "pop{<imodesuffix>}\t%0"
1793 [(set_attr "type" "pop")
1794 (set_attr "mode" "<MODE>")])
1796 (define_insn "*pop<mode>1_epilogue"
1797 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1798 (match_operand:P 1 "pop_operand" ">"))
1799 (clobber (mem:BLK (scratch)))]
1801 "pop{<imodesuffix>}\t%0"
1802 [(set_attr "type" "pop")
1803 (set_attr "mode" "<MODE>")])
1805 ;; Move instructions.
1807 (define_expand "movoi"
1808 [(set (match_operand:OI 0 "nonimmediate_operand" "")
1809 (match_operand:OI 1 "general_operand" ""))]
1811 "ix86_expand_move (OImode, operands); DONE;")
1813 (define_expand "movti"
1814 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1815 (match_operand:TI 1 "nonimmediate_operand" ""))]
1816 "TARGET_64BIT || TARGET_SSE"
1819 ix86_expand_move (TImode, operands);
1820 else if (push_operand (operands[0], TImode))
1821 ix86_expand_push (TImode, operands[1]);
1823 ix86_expand_vector_move (TImode, operands);
1827 ;; This expands to what emit_move_complex would generate if we didn't
1828 ;; have a movti pattern. Having this avoids problems with reload on
1829 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
1830 ;; to have around all the time.
1831 (define_expand "movcdi"
1832 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
1833 (match_operand:CDI 1 "general_operand" ""))]
1836 if (push_operand (operands[0], CDImode))
1837 emit_move_complex_push (CDImode, operands[0], operands[1]);
1839 emit_move_complex_parts (operands[0], operands[1]);
1843 (define_expand "mov<mode>"
1844 [(set (match_operand:SWI1248x 0 "nonimmediate_operand" "")
1845 (match_operand:SWI1248x 1 "general_operand" ""))]
1847 "ix86_expand_move (<MODE>mode, operands); DONE;")
1849 (define_insn "*mov<mode>_xor"
1850 [(set (match_operand:SWI48 0 "register_operand" "=r")
1851 (match_operand:SWI48 1 "const0_operand" ""))
1852 (clobber (reg:CC FLAGS_REG))]
1855 [(set_attr "type" "alu1")
1856 (set_attr "mode" "SI")
1857 (set_attr "length_immediate" "0")])
1859 (define_insn "*mov<mode>_or"
1860 [(set (match_operand:SWI48 0 "register_operand" "=r")
1861 (match_operand:SWI48 1 "const_int_operand" ""))
1862 (clobber (reg:CC FLAGS_REG))]
1864 && operands[1] == constm1_rtx"
1865 "or{<imodesuffix>}\t{%1, %0|%0, %1}"
1866 [(set_attr "type" "alu1")
1867 (set_attr "mode" "<MODE>")
1868 (set_attr "length_immediate" "1")])
1870 (define_insn "*movoi_internal_avx"
1871 [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
1872 (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
1873 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1875 switch (which_alternative)
1878 return standard_sse_constant_opcode (insn, operands[1]);
1881 if (misaligned_operand (operands[0], OImode)
1882 || misaligned_operand (operands[1], OImode))
1883 return "vmovdqu\t{%1, %0|%0, %1}";
1885 return "vmovdqa\t{%1, %0|%0, %1}";
1890 [(set_attr "type" "sselog1,ssemov,ssemov")
1891 (set_attr "prefix" "vex")
1892 (set_attr "mode" "OI")])
1894 (define_insn "*movti_internal_rex64"
1895 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
1896 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
1897 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1899 switch (which_alternative)
1905 return standard_sse_constant_opcode (insn, operands[1]);
1908 /* TDmode values are passed as TImode on the stack. Moving them
1909 to stack may result in unaligned memory access. */
1910 if (misaligned_operand (operands[0], TImode)
1911 || misaligned_operand (operands[1], TImode))
1913 if (get_attr_mode (insn) == MODE_V4SF)
1914 return "%vmovups\t{%1, %0|%0, %1}";
1916 return "%vmovdqu\t{%1, %0|%0, %1}";
1920 if (get_attr_mode (insn) == MODE_V4SF)
1921 return "%vmovaps\t{%1, %0|%0, %1}";
1923 return "%vmovdqa\t{%1, %0|%0, %1}";
1929 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
1930 (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
1932 (cond [(eq_attr "alternative" "2,3")
1934 (match_test "optimize_function_for_size_p (cfun)")
1935 (const_string "V4SF")
1936 (const_string "TI"))
1937 (eq_attr "alternative" "4")
1939 (ior (match_test "TARGET_SSE_TYPELESS_STORES")
1940 (match_test "optimize_function_for_size_p (cfun)"))
1941 (const_string "V4SF")
1942 (const_string "TI"))]
1943 (const_string "DI")))])
1946 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1947 (match_operand:TI 1 "general_operand" ""))]
1949 && !SSE_REG_P (operands[0]) && !SSE_REG_P (operands[1])"
1951 "ix86_split_long_move (operands); DONE;")
1953 (define_insn "*movti_internal_sse"
1954 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
1955 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
1956 "TARGET_SSE && !TARGET_64BIT
1957 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1959 switch (which_alternative)
1962 return standard_sse_constant_opcode (insn, operands[1]);
1965 /* TDmode values are passed as TImode on the stack. Moving them
1966 to stack may result in unaligned memory access. */
1967 if (misaligned_operand (operands[0], TImode)
1968 || misaligned_operand (operands[1], TImode))
1970 if (get_attr_mode (insn) == MODE_V4SF)
1971 return "%vmovups\t{%1, %0|%0, %1}";
1973 return "%vmovdqu\t{%1, %0|%0, %1}";
1977 if (get_attr_mode (insn) == MODE_V4SF)
1978 return "%vmovaps\t{%1, %0|%0, %1}";
1980 return "%vmovdqa\t{%1, %0|%0, %1}";
1986 [(set_attr "type" "sselog1,ssemov,ssemov")
1987 (set_attr "prefix" "maybe_vex")
1989 (cond [(ior (not (match_test "TARGET_SSE2"))
1990 (match_test "optimize_function_for_size_p (cfun)"))
1991 (const_string "V4SF")
1992 (and (eq_attr "alternative" "2")
1993 (match_test "TARGET_SSE_TYPELESS_STORES"))
1994 (const_string "V4SF")]
1995 (const_string "TI")))])
1997 (define_insn "*movdi_internal_rex64"
1998 [(set (match_operand:DI 0 "nonimmediate_operand"
1999 "=r,r ,r,m ,!o,*y,m*y,?*y,?r ,?*Ym,*x,m ,*x,*x,?r ,?*Yi,?*x,?*Ym")
2000 (match_operand:DI 1 "general_operand"
2001 "Z ,rem,i,re,n ,C ,*y ,m ,*Ym,r ,C ,*x,*x,m ,*Yi,r ,*Ym,*x"))]
2002 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2004 switch (get_attr_type (insn))
2007 if (SSE_REG_P (operands[0]))
2008 return "movq2dq\t{%1, %0|%0, %1}";
2010 return "movdq2q\t{%1, %0|%0, %1}";
2013 if (get_attr_mode (insn) == MODE_TI)
2014 return "%vmovdqa\t{%1, %0|%0, %1}";
2015 /* Handle broken assemblers that require movd instead of movq. */
2016 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2017 return "%vmovd\t{%1, %0|%0, %1}";
2019 return "%vmovq\t{%1, %0|%0, %1}";
2022 /* Handle broken assemblers that require movd instead of movq. */
2023 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2024 return "movd\t{%1, %0|%0, %1}";
2026 return "movq\t{%1, %0|%0, %1}";
2029 return standard_sse_constant_opcode (insn, operands[1]);
2032 return "pxor\t%0, %0";
2038 return "lea{q}\t{%a1, %0|%0, %a1}";
2041 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2042 if (get_attr_mode (insn) == MODE_SI)
2043 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2044 else if (which_alternative == 2)
2045 return "movabs{q}\t{%1, %0|%0, %1}";
2047 return "mov{q}\t{%1, %0|%0, %1}";
2051 (cond [(eq_attr "alternative" "4")
2052 (const_string "multi")
2053 (eq_attr "alternative" "5")
2054 (const_string "mmx")
2055 (eq_attr "alternative" "6,7,8,9")
2056 (const_string "mmxmov")
2057 (eq_attr "alternative" "10")
2058 (const_string "sselog1")
2059 (eq_attr "alternative" "11,12,13,14,15")
2060 (const_string "ssemov")
2061 (eq_attr "alternative" "16,17")
2062 (const_string "ssecvt")
2063 (match_operand 1 "pic_32bit_operand" "")
2064 (const_string "lea")
2066 (const_string "imov")))
2069 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2071 (const_string "*")))
2072 (set (attr "length_immediate")
2074 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2076 (const_string "*")))
2077 (set (attr "prefix_rex")
2078 (if_then_else (eq_attr "alternative" "8,9")
2080 (const_string "*")))
2081 (set (attr "prefix_data16")
2082 (if_then_else (eq_attr "alternative" "11")
2084 (const_string "*")))
2085 (set (attr "prefix")
2086 (if_then_else (eq_attr "alternative" "10,11,12,13,14,15")
2087 (const_string "maybe_vex")
2088 (const_string "orig")))
2089 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,TI,DI,TI,DI,DI,DI,DI,DI")])
2091 ;; Reload patterns to support multi-word load/store
2092 ;; with non-offsetable address.
2093 (define_expand "reload_noff_store"
2094 [(parallel [(match_operand 0 "memory_operand" "=m")
2095 (match_operand 1 "register_operand" "r")
2096 (match_operand:DI 2 "register_operand" "=&r")])]
2099 rtx mem = operands[0];
2100 rtx addr = XEXP (mem, 0);
2102 emit_move_insn (operands[2], addr);
2103 mem = replace_equiv_address_nv (mem, operands[2]);
2105 emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
2109 (define_expand "reload_noff_load"
2110 [(parallel [(match_operand 0 "register_operand" "=r")
2111 (match_operand 1 "memory_operand" "m")
2112 (match_operand:DI 2 "register_operand" "=r")])]
2115 rtx mem = operands[1];
2116 rtx addr = XEXP (mem, 0);
2118 emit_move_insn (operands[2], addr);
2119 mem = replace_equiv_address_nv (mem, operands[2]);
2121 emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
2125 ;; Convert impossible stores of immediate to existing instructions.
2126 ;; First try to get scratch register and go through it. In case this
2127 ;; fails, move by 32bit parts.
2129 [(match_scratch:DI 2 "r")
2130 (set (match_operand:DI 0 "memory_operand" "")
2131 (match_operand:DI 1 "immediate_operand" ""))]
2132 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2133 && !x86_64_immediate_operand (operands[1], DImode)"
2134 [(set (match_dup 2) (match_dup 1))
2135 (set (match_dup 0) (match_dup 2))])
2137 ;; We need to define this as both peepholer and splitter for case
2138 ;; peephole2 pass is not run.
2139 ;; "&& 1" is needed to keep it from matching the previous pattern.
2141 [(set (match_operand:DI 0 "memory_operand" "")
2142 (match_operand:DI 1 "immediate_operand" ""))]
2143 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2144 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2145 [(set (match_dup 2) (match_dup 3))
2146 (set (match_dup 4) (match_dup 5))]
2147 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2150 [(set (match_operand:DI 0 "memory_operand" "")
2151 (match_operand:DI 1 "immediate_operand" ""))]
2152 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2153 ? epilogue_completed : reload_completed)
2154 && !symbolic_operand (operands[1], DImode)
2155 && !x86_64_immediate_operand (operands[1], DImode)"
2156 [(set (match_dup 2) (match_dup 3))
2157 (set (match_dup 4) (match_dup 5))]
2158 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2160 (define_insn "*movdi_internal"
2161 [(set (match_operand:DI 0 "nonimmediate_operand"
2162 "=r ,o ,*y,m*y,*y,*x,m ,*x,*x,*x,m ,*x,*x,?*x,?*Ym")
2163 (match_operand:DI 1 "general_operand"
2164 "riFo,riF,C ,*y ,m ,C ,*x,*x,m ,C ,*x,*x,m ,*Ym,*x"))]
2165 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2167 switch (get_attr_type (insn))
2170 if (SSE_REG_P (operands[0]))
2171 return "movq2dq\t{%1, %0|%0, %1}";
2173 return "movdq2q\t{%1, %0|%0, %1}";
2176 switch (get_attr_mode (insn))
2179 return "%vmovdqa\t{%1, %0|%0, %1}";
2181 return "%vmovq\t{%1, %0|%0, %1}";
2183 return "movaps\t{%1, %0|%0, %1}";
2185 return "movlps\t{%1, %0|%0, %1}";
2191 return "movq\t{%1, %0|%0, %1}";
2194 return standard_sse_constant_opcode (insn, operands[1]);
2197 return "pxor\t%0, %0";
2207 (cond [(eq_attr "alternative" "5,6,7,8,13,14")
2208 (const_string "sse2")
2209 (eq_attr "alternative" "9,10,11,12")
2210 (const_string "noavx")
2212 (const_string "*")))
2214 (cond [(eq_attr "alternative" "0,1")
2215 (const_string "multi")
2216 (eq_attr "alternative" "2")
2217 (const_string "mmx")
2218 (eq_attr "alternative" "3,4")
2219 (const_string "mmxmov")
2220 (eq_attr "alternative" "5,9")
2221 (const_string "sselog1")
2222 (eq_attr "alternative" "13,14")
2223 (const_string "ssecvt")
2225 (const_string "ssemov")))
2226 (set (attr "prefix")
2227 (if_then_else (eq_attr "alternative" "5,6,7,8")
2228 (const_string "maybe_vex")
2229 (const_string "orig")))
2230 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF,DI,DI")])
2233 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2234 (match_operand:DI 1 "general_operand" ""))]
2235 "!TARGET_64BIT && reload_completed
2236 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))
2237 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
2239 "ix86_split_long_move (operands); DONE;")
2241 (define_insn "*movsi_internal"
2242 [(set (match_operand:SI 0 "nonimmediate_operand"
2243 "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
2244 (match_operand:SI 1 "general_operand"
2245 "g ,re,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
2246 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2248 switch (get_attr_type (insn))
2251 return standard_sse_constant_opcode (insn, operands[1]);
2254 switch (get_attr_mode (insn))
2257 return "%vmovdqa\t{%1, %0|%0, %1}";
2259 return "%vmovaps\t{%1, %0|%0, %1}";
2261 return "%vmovd\t{%1, %0|%0, %1}";
2263 return "%vmovss\t{%1, %0|%0, %1}";
2269 return "pxor\t%0, %0";
2272 if (get_attr_mode (insn) == MODE_DI)
2273 return "movq\t{%1, %0|%0, %1}";
2274 return "movd\t{%1, %0|%0, %1}";
2277 return "lea{l}\t{%a1, %0|%0, %a1}";
2280 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2281 return "mov{l}\t{%1, %0|%0, %1}";
2285 (cond [(eq_attr "alternative" "2")
2286 (const_string "mmx")
2287 (eq_attr "alternative" "3,4,5")
2288 (const_string "mmxmov")
2289 (eq_attr "alternative" "6")
2290 (const_string "sselog1")
2291 (eq_attr "alternative" "7,8,9,10,11")
2292 (const_string "ssemov")
2293 (match_operand 1 "pic_32bit_operand" "")
2294 (const_string "lea")
2296 (const_string "imov")))
2297 (set (attr "prefix")
2298 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
2299 (const_string "orig")
2300 (const_string "maybe_vex")))
2301 (set (attr "prefix_data16")
2302 (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
2304 (const_string "*")))
2306 (cond [(eq_attr "alternative" "2,3")
2308 (eq_attr "alternative" "6,7")
2310 (not (match_test "TARGET_SSE2"))
2311 (const_string "V4SF")
2312 (const_string "TI"))
2313 (and (eq_attr "alternative" "8,9,10,11")
2314 (not (match_test "TARGET_SSE2")))
2317 (const_string "SI")))])
2319 (define_insn "*movhi_internal"
2320 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
2321 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
2322 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2324 switch (get_attr_type (insn))
2327 /* movzwl is faster than movw on p2 due to partial word stalls,
2328 though not as fast as an aligned movl. */
2329 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
2331 if (get_attr_mode (insn) == MODE_SI)
2332 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2334 return "mov{w}\t{%1, %0|%0, %1}";
2338 (cond [(match_test "optimize_function_for_size_p (cfun)")
2339 (const_string "imov")
2340 (and (eq_attr "alternative" "0")
2341 (ior (not (match_test "TARGET_PARTIAL_REG_STALL"))
2342 (not (match_test "TARGET_HIMODE_MATH"))))
2343 (const_string "imov")
2344 (and (eq_attr "alternative" "1,2")
2345 (match_operand:HI 1 "aligned_operand" ""))
2346 (const_string "imov")
2347 (and (match_test "TARGET_MOVX")
2348 (eq_attr "alternative" "0,2"))
2349 (const_string "imovx")
2351 (const_string "imov")))
2353 (cond [(eq_attr "type" "imovx")
2355 (and (eq_attr "alternative" "1,2")
2356 (match_operand:HI 1 "aligned_operand" ""))
2358 (and (eq_attr "alternative" "0")
2359 (ior (not (match_test "TARGET_PARTIAL_REG_STALL"))
2360 (not (match_test "TARGET_HIMODE_MATH"))))
2363 (const_string "HI")))])
2365 ;; Situation is quite tricky about when to choose full sized (SImode) move
2366 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
2367 ;; partial register dependency machines (such as AMD Athlon), where QImode
2368 ;; moves issue extra dependency and for partial register stalls machines
2369 ;; that don't use QImode patterns (and QImode move cause stall on the next
2372 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2373 ;; register stall machines with, where we use QImode instructions, since
2374 ;; partial register stall can be caused there. Then we use movzx.
2375 (define_insn "*movqi_internal"
2376 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2377 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
2378 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2380 switch (get_attr_type (insn))
2383 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2384 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2386 if (get_attr_mode (insn) == MODE_SI)
2387 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2389 return "mov{b}\t{%1, %0|%0, %1}";
2393 (cond [(and (eq_attr "alternative" "5")
2394 (not (match_operand:QI 1 "aligned_operand" "")))
2395 (const_string "imovx")
2396 (match_test "optimize_function_for_size_p (cfun)")
2397 (const_string "imov")
2398 (and (eq_attr "alternative" "3")
2399 (ior (not (match_test "TARGET_PARTIAL_REG_STALL"))
2400 (not (match_test "TARGET_QIMODE_MATH"))))
2401 (const_string "imov")
2402 (eq_attr "alternative" "3,5")
2403 (const_string "imovx")
2404 (and (match_test "TARGET_MOVX")
2405 (eq_attr "alternative" "2"))
2406 (const_string "imovx")
2408 (const_string "imov")))
2410 (cond [(eq_attr "alternative" "3,4,5")
2412 (eq_attr "alternative" "6")
2414 (eq_attr "type" "imovx")
2416 (and (eq_attr "type" "imov")
2417 (and (eq_attr "alternative" "0,1")
2418 (and (match_test "TARGET_PARTIAL_REG_DEPENDENCY")
2419 (and (not (match_test "optimize_function_for_size_p (cfun)"))
2420 (not (match_test "TARGET_PARTIAL_REG_STALL"))))))
2422 ;; Avoid partial register stalls when not using QImode arithmetic
2423 (and (eq_attr "type" "imov")
2424 (and (eq_attr "alternative" "0,1")
2425 (and (match_test "TARGET_PARTIAL_REG_STALL")
2426 (not (match_test "TARGET_QIMODE_MATH")))))
2429 (const_string "QI")))])
2431 ;; Stores and loads of ax to arbitrary constant address.
2432 ;; We fake an second form of instruction to force reload to load address
2433 ;; into register when rax is not available
2434 (define_insn "*movabs<mode>_1"
2435 [(set (mem:SWI1248x (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2436 (match_operand:SWI1248x 1 "nonmemory_operand" "a,er"))]
2437 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2439 movabs{<imodesuffix>}\t{%1, %P0|%P0, %1}
2440 mov{<imodesuffix>}\t{%1, %a0|%a0, %1}"
2441 [(set_attr "type" "imov")
2442 (set_attr "modrm" "0,*")
2443 (set_attr "length_address" "8,0")
2444 (set_attr "length_immediate" "0,*")
2445 (set_attr "memory" "store")
2446 (set_attr "mode" "<MODE>")])
2448 (define_insn "*movabs<mode>_2"
2449 [(set (match_operand:SWI1248x 0 "register_operand" "=a,r")
2450 (mem:SWI1248x (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2451 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2453 movabs{<imodesuffix>}\t{%P1, %0|%0, %P1}
2454 mov{<imodesuffix>}\t{%a1, %0|%0, %a1}"
2455 [(set_attr "type" "imov")
2456 (set_attr "modrm" "0,*")
2457 (set_attr "length_address" "8,0")
2458 (set_attr "length_immediate" "0")
2459 (set_attr "memory" "load")
2460 (set_attr "mode" "<MODE>")])
2462 (define_insn "*swap<mode>"
2463 [(set (match_operand:SWI48 0 "register_operand" "+r")
2464 (match_operand:SWI48 1 "register_operand" "+r"))
2468 "xchg{<imodesuffix>}\t%1, %0"
2469 [(set_attr "type" "imov")
2470 (set_attr "mode" "<MODE>")
2471 (set_attr "pent_pair" "np")
2472 (set_attr "athlon_decode" "vector")
2473 (set_attr "amdfam10_decode" "double")
2474 (set_attr "bdver1_decode" "double")])
2476 (define_insn "*swap<mode>_1"
2477 [(set (match_operand:SWI12 0 "register_operand" "+r")
2478 (match_operand:SWI12 1 "register_operand" "+r"))
2481 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2483 [(set_attr "type" "imov")
2484 (set_attr "mode" "SI")
2485 (set_attr "pent_pair" "np")
2486 (set_attr "athlon_decode" "vector")
2487 (set_attr "amdfam10_decode" "double")
2488 (set_attr "bdver1_decode" "double")])
2490 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL
2491 ;; is disabled for AMDFAM10
2492 (define_insn "*swap<mode>_2"
2493 [(set (match_operand:SWI12 0 "register_operand" "+<r>")
2494 (match_operand:SWI12 1 "register_operand" "+<r>"))
2497 "TARGET_PARTIAL_REG_STALL"
2498 "xchg{<imodesuffix>}\t%1, %0"
2499 [(set_attr "type" "imov")
2500 (set_attr "mode" "<MODE>")
2501 (set_attr "pent_pair" "np")
2502 (set_attr "athlon_decode" "vector")])
2504 (define_expand "movstrict<mode>"
2505 [(set (strict_low_part (match_operand:SWI12 0 "nonimmediate_operand" ""))
2506 (match_operand:SWI12 1 "general_operand" ""))]
2509 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2511 if (GET_CODE (operands[0]) == SUBREG
2512 && GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[0]))) != MODE_INT)
2514 /* Don't generate memory->memory moves, go through a register */
2515 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2516 operands[1] = force_reg (<MODE>mode, operands[1]);
2519 (define_insn "*movstrict<mode>_1"
2520 [(set (strict_low_part
2521 (match_operand:SWI12 0 "nonimmediate_operand" "+<r>m,<r>"))
2522 (match_operand:SWI12 1 "general_operand" "<r>n,m"))]
2523 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2524 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2525 "mov{<imodesuffix>}\t{%1, %0|%0, %1}"
2526 [(set_attr "type" "imov")
2527 (set_attr "mode" "<MODE>")])
2529 (define_insn "*movstrict<mode>_xor"
2530 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
2531 (match_operand:SWI12 1 "const0_operand" ""))
2532 (clobber (reg:CC FLAGS_REG))]
2534 "xor{<imodesuffix>}\t%0, %0"
2535 [(set_attr "type" "alu1")
2536 (set_attr "mode" "<MODE>")
2537 (set_attr "length_immediate" "0")])
2539 (define_insn "*mov<mode>_extv_1"
2540 [(set (match_operand:SWI24 0 "register_operand" "=R")
2541 (sign_extract:SWI24 (match_operand 1 "ext_register_operand" "Q")
2545 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2546 [(set_attr "type" "imovx")
2547 (set_attr "mode" "SI")])
2549 (define_insn "*movqi_extv_1_rex64"
2550 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2551 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2556 switch (get_attr_type (insn))
2559 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2561 return "mov{b}\t{%h1, %0|%0, %h1}";
2565 (if_then_else (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2566 (match_test "TARGET_MOVX"))
2567 (const_string "imovx")
2568 (const_string "imov")))
2570 (if_then_else (eq_attr "type" "imovx")
2572 (const_string "QI")))])
2574 (define_insn "*movqi_extv_1"
2575 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2576 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2581 switch (get_attr_type (insn))
2584 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2586 return "mov{b}\t{%h1, %0|%0, %h1}";
2590 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2591 (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2592 (match_test "TARGET_MOVX")))
2593 (const_string "imovx")
2594 (const_string "imov")))
2596 (if_then_else (eq_attr "type" "imovx")
2598 (const_string "QI")))])
2600 (define_insn "*mov<mode>_extzv_1"
2601 [(set (match_operand:SWI48 0 "register_operand" "=R")
2602 (zero_extract:SWI48 (match_operand 1 "ext_register_operand" "Q")
2606 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2607 [(set_attr "type" "imovx")
2608 (set_attr "mode" "SI")])
2610 (define_insn "*movqi_extzv_2_rex64"
2611 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2613 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2618 switch (get_attr_type (insn))
2621 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2623 return "mov{b}\t{%h1, %0|%0, %h1}";
2627 (if_then_else (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2628 (match_test "TARGET_MOVX"))
2629 (const_string "imovx")
2630 (const_string "imov")))
2632 (if_then_else (eq_attr "type" "imovx")
2634 (const_string "QI")))])
2636 (define_insn "*movqi_extzv_2"
2637 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2639 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2644 switch (get_attr_type (insn))
2647 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2649 return "mov{b}\t{%h1, %0|%0, %h1}";
2653 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2654 (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2655 (match_test "TARGET_MOVX")))
2656 (const_string "imovx")
2657 (const_string "imov")))
2659 (if_then_else (eq_attr "type" "imovx")
2661 (const_string "QI")))])
2663 (define_expand "mov<mode>_insv_1"
2664 [(set (zero_extract:SWI48 (match_operand 0 "ext_register_operand" "")
2667 (match_operand:SWI48 1 "nonmemory_operand" ""))])
2669 (define_insn "*mov<mode>_insv_1_rex64"
2670 [(set (zero_extract:SWI48x (match_operand 0 "ext_register_operand" "+Q")
2673 (match_operand:SWI48x 1 "nonmemory_operand" "Qn"))]
2675 "mov{b}\t{%b1, %h0|%h0, %b1}"
2676 [(set_attr "type" "imov")
2677 (set_attr "mode" "QI")])
2679 (define_insn "*movsi_insv_1"
2680 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2683 (match_operand:SI 1 "general_operand" "Qmn"))]
2685 "mov{b}\t{%b1, %h0|%h0, %b1}"
2686 [(set_attr "type" "imov")
2687 (set_attr "mode" "QI")])
2689 (define_insn "*movqi_insv_2"
2690 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2693 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2696 "mov{b}\t{%h1, %h0|%h0, %h1}"
2697 [(set_attr "type" "imov")
2698 (set_attr "mode" "QI")])
2700 ;; Floating point push instructions.
2702 (define_insn "*pushtf"
2703 [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2704 (match_operand:TF 1 "general_no_elim_operand" "x,Fo,*r"))]
2707 /* This insn should be already split before reg-stack. */
2710 [(set_attr "type" "multi")
2711 (set_attr "unit" "sse,*,*")
2712 (set_attr "mode" "TF,SI,SI")])
2714 ;; %%% Kill this when call knows how to work this out.
2716 [(set (match_operand:TF 0 "push_operand" "")
2717 (match_operand:TF 1 "sse_reg_operand" ""))]
2718 "TARGET_SSE2 && reload_completed"
2719 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
2720 (set (mem:TF (reg:P SP_REG)) (match_dup 1))])
2722 (define_insn "*pushxf"
2723 [(set (match_operand:XF 0 "push_operand" "=<,<")
2724 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
2725 "optimize_function_for_speed_p (cfun)"
2727 /* This insn should be already split before reg-stack. */
2730 [(set_attr "type" "multi")
2731 (set_attr "unit" "i387,*")
2732 (set_attr "mode" "XF,SI")])
2734 ;; Size of pushxf is 3 (for sub) + 2 (for fstp) + memory operand size.
2735 ;; Size of pushxf using integer instructions is 3+3*memory operand size
2736 ;; Pushing using integer instructions is longer except for constants
2737 ;; and direct memory references (assuming that any given constant is pushed
2738 ;; only once, but this ought to be handled elsewhere).
2740 (define_insn "*pushxf_nointeger"
2741 [(set (match_operand:XF 0 "push_operand" "=<,<")
2742 (match_operand:XF 1 "general_no_elim_operand" "f,*rFo"))]
2743 "optimize_function_for_size_p (cfun)"
2745 /* This insn should be already split before reg-stack. */
2748 [(set_attr "type" "multi")
2749 (set_attr "unit" "i387,*")
2750 (set_attr "mode" "XF,SI")])
2752 ;; %%% Kill this when call knows how to work this out.
2754 [(set (match_operand:XF 0 "push_operand" "")
2755 (match_operand:XF 1 "fp_register_operand" ""))]
2757 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2758 (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
2759 "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
2761 (define_insn "*pushdf_rex64"
2762 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2763 (match_operand:DF 1 "general_no_elim_operand" "f,Yd*rFm,x"))]
2766 /* This insn should be already split before reg-stack. */
2769 [(set_attr "type" "multi")
2770 (set_attr "unit" "i387,*,*")
2771 (set_attr "mode" "DF,DI,DF")])
2773 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2774 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2775 ;; On the average, pushdf using integers can be still shorter.
2777 (define_insn "*pushdf"
2778 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2779 (match_operand:DF 1 "general_no_elim_operand" "f,Yd*rFo,x"))]
2782 /* This insn should be already split before reg-stack. */
2785 [(set_attr "isa" "*,*,sse2")
2786 (set_attr "type" "multi")
2787 (set_attr "unit" "i387,*,*")
2788 (set_attr "mode" "DF,DI,DF")])
2790 ;; %%% Kill this when call knows how to work this out.
2792 [(set (match_operand:DF 0 "push_operand" "")
2793 (match_operand:DF 1 "any_fp_register_operand" ""))]
2795 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
2796 (set (mem:DF (reg:P SP_REG)) (match_dup 1))])
2798 (define_insn "*pushsf_rex64"
2799 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2800 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2803 /* Anything else should be already split before reg-stack. */
2804 gcc_assert (which_alternative == 1);
2805 return "push{q}\t%q1";
2807 [(set_attr "type" "multi,push,multi")
2808 (set_attr "unit" "i387,*,*")
2809 (set_attr "mode" "SF,DI,SF")])
2811 (define_insn "*pushsf"
2812 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2813 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2816 /* Anything else should be already split before reg-stack. */
2817 gcc_assert (which_alternative == 1);
2818 return "push{l}\t%1";
2820 [(set_attr "type" "multi,push,multi")
2821 (set_attr "unit" "i387,*,*")
2822 (set_attr "mode" "SF,SI,SF")])
2824 ;; %%% Kill this when call knows how to work this out.
2826 [(set (match_operand:SF 0 "push_operand" "")
2827 (match_operand:SF 1 "any_fp_register_operand" ""))]
2829 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2830 (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
2831 "operands[2] = GEN_INT (-GET_MODE_SIZE (<P:MODE>mode));")
2834 [(set (match_operand:SF 0 "push_operand" "")
2835 (match_operand:SF 1 "memory_operand" ""))]
2837 && (operands[2] = find_constant_src (insn))"
2838 [(set (match_dup 0) (match_dup 2))])
2841 [(set (match_operand 0 "push_operand" "")
2842 (match_operand 1 "general_operand" ""))]
2844 && (GET_MODE (operands[0]) == TFmode
2845 || GET_MODE (operands[0]) == XFmode
2846 || GET_MODE (operands[0]) == DFmode)
2847 && !ANY_FP_REG_P (operands[1])"
2849 "ix86_split_long_move (operands); DONE;")
2851 ;; Floating point move instructions.
2853 (define_expand "movtf"
2854 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2855 (match_operand:TF 1 "nonimmediate_operand" ""))]
2858 ix86_expand_move (TFmode, operands);
2862 (define_expand "mov<mode>"
2863 [(set (match_operand:X87MODEF 0 "nonimmediate_operand" "")
2864 (match_operand:X87MODEF 1 "general_operand" ""))]
2866 "ix86_expand_move (<MODE>mode, operands); DONE;")
2868 (define_insn "*movtf_internal"
2869 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?*r ,!o")
2870 (match_operand:TF 1 "general_operand" "xm,x,C,*roF,F*r"))]
2872 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2873 && (!can_create_pseudo_p ()
2874 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2875 || GET_CODE (operands[1]) != CONST_DOUBLE
2876 || (optimize_function_for_size_p (cfun)
2877 && standard_sse_constant_p (operands[1])
2878 && !memory_operand (operands[0], TFmode))
2879 || (!TARGET_MEMORY_MISMATCH_STALL
2880 && memory_operand (operands[0], TFmode)))"
2882 switch (which_alternative)
2886 /* Handle misaligned load/store since we
2887 don't have movmisaligntf pattern. */
2888 if (misaligned_operand (operands[0], TFmode)
2889 || misaligned_operand (operands[1], TFmode))
2891 if (get_attr_mode (insn) == MODE_V4SF)
2892 return "%vmovups\t{%1, %0|%0, %1}";
2894 return "%vmovdqu\t{%1, %0|%0, %1}";
2898 if (get_attr_mode (insn) == MODE_V4SF)
2899 return "%vmovaps\t{%1, %0|%0, %1}";
2901 return "%vmovdqa\t{%1, %0|%0, %1}";
2905 return standard_sse_constant_opcode (insn, operands[1]);
2915 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
2916 (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,*,*")
2918 (cond [(eq_attr "alternative" "0,2")
2920 (match_test "optimize_function_for_size_p (cfun)")
2921 (const_string "V4SF")
2922 (const_string "TI"))
2923 (eq_attr "alternative" "1")
2925 (ior (match_test "TARGET_SSE_TYPELESS_STORES")
2926 (match_test "optimize_function_for_size_p (cfun)"))
2927 (const_string "V4SF")
2928 (const_string "TI"))]
2929 (const_string "DI")))])
2931 ;; Possible store forwarding (partial memory) stall in alternative 4.
2932 (define_insn "*movxf_internal"
2933 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,?Yx*r ,!o")
2934 (match_operand:XF 1 "general_operand" "fm,f,G,Yx*roF,FYx*r"))]
2935 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2936 && (!can_create_pseudo_p ()
2937 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2938 || GET_CODE (operands[1]) != CONST_DOUBLE
2939 || (optimize_function_for_size_p (cfun)
2940 && standard_80387_constant_p (operands[1]) > 0
2941 && !memory_operand (operands[0], XFmode))
2942 || (!TARGET_MEMORY_MISMATCH_STALL
2943 && memory_operand (operands[0], XFmode)))"
2945 switch (which_alternative)
2949 return output_387_reg_move (insn, operands);
2952 return standard_80387_constant_opcode (operands[1]);
2962 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2963 (set_attr "mode" "XF,XF,XF,SI,SI")])
2965 (define_insn "*movdf_internal_rex64"
2966 [(set (match_operand:DF 0 "nonimmediate_operand"
2967 "=f,m,f,?r,?m,?r,!o,x,x,x,m,Yi,r ")
2968 (match_operand:DF 1 "general_operand"
2969 "fm,f,G,rm,r ,F ,F ,C,x,m,x,r ,Yi"))]
2970 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2971 && (!can_create_pseudo_p ()
2972 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2973 || GET_CODE (operands[1]) != CONST_DOUBLE
2974 || (optimize_function_for_size_p (cfun)
2975 && ((!(TARGET_SSE2 && TARGET_SSE_MATH)
2976 && standard_80387_constant_p (operands[1]) > 0)
2977 || (TARGET_SSE2 && TARGET_SSE_MATH
2978 && standard_sse_constant_p (operands[1]))))
2979 || memory_operand (operands[0], DFmode))"
2981 switch (which_alternative)
2985 return output_387_reg_move (insn, operands);
2988 return standard_80387_constant_opcode (operands[1]);
2992 return "mov{q}\t{%1, %0|%0, %1}";
2995 return "movabs{q}\t{%1, %0|%0, %1}";
3001 return standard_sse_constant_opcode (insn, operands[1]);
3006 switch (get_attr_mode (insn))
3009 if (!TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3010 return "%vmovapd\t{%1, %0|%0, %1}";
3012 return "%vmovaps\t{%1, %0|%0, %1}";
3015 return "%vmovq\t{%1, %0|%0, %1}";
3017 if (TARGET_AVX && REG_P (operands[0]) && REG_P (operands[1]))
3018 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3019 return "%vmovsd\t{%1, %0|%0, %1}";
3021 return "%vmovlpd\t{%1, %d0|%d0, %1}";
3023 return "%vmovlps\t{%1, %d0|%d0, %1}";
3030 /* Handle broken assemblers that require movd instead of movq. */
3031 return "%vmovd\t{%1, %0|%0, %1}";
3038 (cond [(eq_attr "alternative" "0,1,2")
3039 (const_string "fmov")
3040 (eq_attr "alternative" "3,4,5")
3041 (const_string "imov")
3042 (eq_attr "alternative" "6")
3043 (const_string "multi")
3044 (eq_attr "alternative" "7")
3045 (const_string "sselog1")
3047 (const_string "ssemov")))
3050 (and (eq_attr "alternative" "5") (eq_attr "type" "imov"))
3052 (const_string "*")))
3053 (set (attr "length_immediate")
3055 (and (eq_attr "alternative" "5") (eq_attr "type" "imov"))
3057 (const_string "*")))
3058 (set (attr "prefix")
3059 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5,6")
3060 (const_string "orig")
3061 (const_string "maybe_vex")))
3062 (set (attr "prefix_data16")
3063 (if_then_else (eq_attr "mode" "V1DF")
3065 (const_string "*")))
3067 (cond [(eq_attr "alternative" "0,1,2")
3069 (eq_attr "alternative" "3,4,5,6,11,12")
3072 /* xorps is one byte shorter. */
3073 (eq_attr "alternative" "7")
3074 (cond [(match_test "optimize_function_for_size_p (cfun)")
3075 (const_string "V4SF")
3076 (match_test "TARGET_SSE_LOAD0_BY_PXOR")
3079 (const_string "V2DF"))
3081 /* For architectures resolving dependencies on
3082 whole SSE registers use APD move to break dependency
3083 chains, otherwise use short move to avoid extra work.
3085 movaps encodes one byte shorter. */
3086 (eq_attr "alternative" "8")
3088 [(match_test "optimize_function_for_size_p (cfun)")
3089 (const_string "V4SF")
3090 (match_test "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3091 (const_string "V2DF")
3093 (const_string "DF"))
3094 /* For architectures resolving dependencies on register
3095 parts we may avoid extra work to zero out upper part
3097 (eq_attr "alternative" "9")
3099 (match_test "TARGET_SSE_SPLIT_REGS")
3100 (const_string "V1DF")
3101 (const_string "DF"))
3103 (const_string "DF")))])
3105 ;; Possible store forwarding (partial memory) stall in alternative 4.
3106 (define_insn "*movdf_internal"
3107 [(set (match_operand:DF 0 "nonimmediate_operand"
3108 "=f,m,f,?Yd*r ,!o ,x,x,x,m,*x,*x,*x,m")
3109 (match_operand:DF 1 "general_operand"
3110 "fm,f,G,Yd*roF,FYd*r,C,x,m,x,C ,*x,m ,*x"))]
3111 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3112 && (!can_create_pseudo_p ()
3113 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3114 || GET_CODE (operands[1]) != CONST_DOUBLE
3115 || (optimize_function_for_size_p (cfun)
3116 && ((!(TARGET_SSE2 && TARGET_SSE_MATH)
3117 && standard_80387_constant_p (operands[1]) > 0)
3118 || (TARGET_SSE2 && TARGET_SSE_MATH
3119 && standard_sse_constant_p (operands[1])))
3120 && !memory_operand (operands[0], DFmode))
3121 || (!TARGET_MEMORY_MISMATCH_STALL
3122 && memory_operand (operands[0], DFmode)))"
3124 switch (which_alternative)
3128 return output_387_reg_move (insn, operands);
3131 return standard_80387_constant_opcode (operands[1]);
3139 return standard_sse_constant_opcode (insn, operands[1]);
3147 switch (get_attr_mode (insn))
3150 if (!TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3151 return "%vmovapd\t{%1, %0|%0, %1}";
3153 return "%vmovaps\t{%1, %0|%0, %1}";
3156 return "%vmovq\t{%1, %0|%0, %1}";
3158 if (TARGET_AVX && REG_P (operands[0]) && REG_P (operands[1]))
3159 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3160 return "%vmovsd\t{%1, %0|%0, %1}";
3162 return "%vmovlpd\t{%1, %d0|%d0, %1}";
3164 return "%vmovlps\t{%1, %d0|%d0, %1}";
3174 (if_then_else (eq_attr "alternative" "5,6,7,8")
3175 (const_string "sse2")
3176 (const_string "*")))
3178 (cond [(eq_attr "alternative" "0,1,2")
3179 (const_string "fmov")
3180 (eq_attr "alternative" "3,4")
3181 (const_string "multi")
3182 (eq_attr "alternative" "5,9")
3183 (const_string "sselog1")
3185 (const_string "ssemov")))
3186 (set (attr "prefix")
3187 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3188 (const_string "orig")
3189 (const_string "maybe_vex")))
3190 (set (attr "prefix_data16")
3191 (if_then_else (eq_attr "mode" "V1DF")
3193 (const_string "*")))
3195 (cond [(eq_attr "alternative" "0,1,2")
3197 (eq_attr "alternative" "3,4")
3200 /* For SSE1, we have many fewer alternatives. */
3201 (not (match_test "TARGET_SSE2"))
3203 (eq_attr "alternative" "5,6,9,10")
3204 (const_string "V4SF")
3205 (const_string "V2SF"))
3207 /* xorps is one byte shorter. */
3208 (eq_attr "alternative" "5,9")
3209 (cond [(match_test "optimize_function_for_size_p (cfun)")
3210 (const_string "V4SF")
3211 (match_test "TARGET_SSE_LOAD0_BY_PXOR")
3214 (const_string "V2DF"))
3216 /* For architectures resolving dependencies on
3217 whole SSE registers use APD move to break dependency
3218 chains, otherwise use short move to avoid extra work.
3220 movaps encodes one byte shorter. */
3221 (eq_attr "alternative" "6,10")
3223 [(match_test "optimize_function_for_size_p (cfun)")
3224 (const_string "V4SF")
3225 (match_test "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3226 (const_string "V2DF")
3228 (const_string "DF"))
3229 /* For architectures resolving dependencies on register
3230 parts we may avoid extra work to zero out upper part
3232 (eq_attr "alternative" "7,11")
3234 (match_test "TARGET_SSE_SPLIT_REGS")
3235 (const_string "V1DF")
3236 (const_string "DF"))
3238 (const_string "DF")))])
3240 (define_insn "*movsf_internal"
3241 [(set (match_operand:SF 0 "nonimmediate_operand"
3242 "=f,m,f,?r ,?m,x,x,x,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
3243 (match_operand:SF 1 "general_operand"
3244 "fm,f,G,rmF,Fr,C,x,m,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
3245 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3246 && (!can_create_pseudo_p ()
3247 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3248 || GET_CODE (operands[1]) != CONST_DOUBLE
3249 || (optimize_function_for_size_p (cfun)
3250 && ((!TARGET_SSE_MATH
3251 && standard_80387_constant_p (operands[1]) > 0)
3253 && standard_sse_constant_p (operands[1]))))
3254 || memory_operand (operands[0], SFmode))"
3256 switch (which_alternative)
3260 return output_387_reg_move (insn, operands);
3263 return standard_80387_constant_opcode (operands[1]);
3267 return "mov{l}\t{%1, %0|%0, %1}";
3270 return standard_sse_constant_opcode (insn, operands[1]);
3273 if (get_attr_mode (insn) == MODE_V4SF)
3274 return "%vmovaps\t{%1, %0|%0, %1}";
3276 return "vmovss\t{%1, %0, %0|%0, %0, %1}";
3280 return "%vmovss\t{%1, %0|%0, %1}";
3286 return "movd\t{%1, %0|%0, %1}";
3289 return "movq\t{%1, %0|%0, %1}";
3293 return "%vmovd\t{%1, %0|%0, %1}";
3300 (cond [(eq_attr "alternative" "0,1,2")
3301 (const_string "fmov")
3302 (eq_attr "alternative" "3,4")
3303 (const_string "multi")
3304 (eq_attr "alternative" "5")
3305 (const_string "sselog1")
3306 (eq_attr "alternative" "9,10,11,14,15")
3307 (const_string "mmxmov")
3309 (const_string "ssemov")))
3310 (set (attr "prefix")
3311 (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
3312 (const_string "maybe_vex")
3313 (const_string "orig")))
3315 (cond [(eq_attr "alternative" "3,4,9,10")
3317 (eq_attr "alternative" "5")
3319 (and (and (match_test "TARGET_SSE_LOAD0_BY_PXOR")
3320 (match_test "TARGET_SSE2"))
3321 (not (match_test "optimize_function_for_size_p (cfun)")))
3323 (const_string "V4SF"))
3324 /* For architectures resolving dependencies on
3325 whole SSE registers use APS move to break dependency
3326 chains, otherwise use short move to avoid extra work.
3328 Do the same for architectures resolving dependencies on
3329 the parts. While in DF mode it is better to always handle
3330 just register parts, the SF mode is different due to lack
3331 of instructions to load just part of the register. It is
3332 better to maintain the whole registers in single format
3333 to avoid problems on using packed logical operations. */
3334 (eq_attr "alternative" "6")
3336 (ior (match_test "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3337 (match_test "TARGET_SSE_SPLIT_REGS"))
3338 (const_string "V4SF")
3339 (const_string "SF"))
3340 (eq_attr "alternative" "11")
3341 (const_string "DI")]
3342 (const_string "SF")))])
3345 [(set (match_operand 0 "any_fp_register_operand" "")
3346 (match_operand 1 "memory_operand" ""))]
3348 && (GET_MODE (operands[0]) == TFmode
3349 || GET_MODE (operands[0]) == XFmode
3350 || GET_MODE (operands[0]) == DFmode
3351 || GET_MODE (operands[0]) == SFmode)
3352 && (operands[2] = find_constant_src (insn))"
3353 [(set (match_dup 0) (match_dup 2))]
3355 rtx c = operands[2];
3356 int r = REGNO (operands[0]);
3358 if ((SSE_REGNO_P (r) && !standard_sse_constant_p (c))
3359 || (FP_REGNO_P (r) && standard_80387_constant_p (c) < 1))
3364 [(set (match_operand 0 "any_fp_register_operand" "")
3365 (float_extend (match_operand 1 "memory_operand" "")))]
3367 && (GET_MODE (operands[0]) == TFmode
3368 || GET_MODE (operands[0]) == XFmode
3369 || GET_MODE (operands[0]) == DFmode)
3370 && (operands[2] = find_constant_src (insn))"
3371 [(set (match_dup 0) (match_dup 2))]
3373 rtx c = operands[2];
3374 int r = REGNO (operands[0]);
3376 if ((SSE_REGNO_P (r) && !standard_sse_constant_p (c))
3377 || (FP_REGNO_P (r) && standard_80387_constant_p (c) < 1))
3381 ;; Split the load of -0.0 or -1.0 into fldz;fchs or fld1;fchs sequence
3383 [(set (match_operand:X87MODEF 0 "fp_register_operand" "")
3384 (match_operand:X87MODEF 1 "immediate_operand" ""))]
3386 && (standard_80387_constant_p (operands[1]) == 8
3387 || standard_80387_constant_p (operands[1]) == 9)"
3388 [(set (match_dup 0)(match_dup 1))
3390 (neg:X87MODEF (match_dup 0)))]
3394 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
3395 if (real_isnegzero (&r))
3396 operands[1] = CONST0_RTX (<MODE>mode);
3398 operands[1] = CONST1_RTX (<MODE>mode);
3402 [(set (match_operand 0 "nonimmediate_operand" "")
3403 (match_operand 1 "general_operand" ""))]
3405 && (GET_MODE (operands[0]) == TFmode
3406 || GET_MODE (operands[0]) == XFmode
3407 || GET_MODE (operands[0]) == DFmode)
3408 && !(ANY_FP_REG_P (operands[0]) || ANY_FP_REG_P (operands[1]))"
3410 "ix86_split_long_move (operands); DONE;")
3412 (define_insn "swapxf"
3413 [(set (match_operand:XF 0 "register_operand" "+f")
3414 (match_operand:XF 1 "register_operand" "+f"))
3419 if (STACK_TOP_P (operands[0]))
3424 [(set_attr "type" "fxch")
3425 (set_attr "mode" "XF")])
3427 (define_insn "*swap<mode>"
3428 [(set (match_operand:MODEF 0 "fp_register_operand" "+f")
3429 (match_operand:MODEF 1 "fp_register_operand" "+f"))
3432 "TARGET_80387 || reload_completed"
3434 if (STACK_TOP_P (operands[0]))
3439 [(set_attr "type" "fxch")
3440 (set_attr "mode" "<MODE>")])
3442 ;; Zero extension instructions
3444 (define_expand "zero_extendsidi2"
3445 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3446 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3451 emit_insn (gen_zero_extendsidi2_1 (operands[0], operands[1]));
3456 (define_insn "*zero_extendsidi2_rex64"
3457 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,?*Ym,?*y,?*Yi,*x")
3459 (match_operand:SI 1 "nonimmediate_operand" "rm,0,r ,m ,r ,m")))]
3462 mov\t{%k1, %k0|%k0, %k1}
3464 movd\t{%1, %0|%0, %1}
3465 movd\t{%1, %0|%0, %1}
3466 %vmovd\t{%1, %0|%0, %1}
3467 %vmovd\t{%1, %0|%0, %1}"
3468 [(set_attr "type" "imovx,imov,mmxmov,mmxmov,ssemov,ssemov")
3469 (set_attr "prefix" "orig,*,orig,orig,maybe_vex,maybe_vex")
3470 (set_attr "prefix_0f" "0,*,*,*,*,*")
3471 (set_attr "mode" "SI,DI,DI,DI,TI,TI")])
3474 [(set (match_operand:DI 0 "memory_operand" "")
3475 (zero_extend:DI (match_dup 0)))]
3477 [(set (match_dup 4) (const_int 0))]
3478 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3480 ;; %%% Kill me once multi-word ops are sane.
3481 (define_insn "zero_extendsidi2_1"
3482 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?o,?*Ym,?*y,?*Yi,*x")
3484 (match_operand:SI 1 "nonimmediate_operand" "0,rm,r ,r ,m ,r ,m")))
3485 (clobber (reg:CC FLAGS_REG))]
3491 movd\t{%1, %0|%0, %1}
3492 movd\t{%1, %0|%0, %1}
3493 %vmovd\t{%1, %0|%0, %1}
3494 %vmovd\t{%1, %0|%0, %1}"
3495 [(set_attr "isa" "*,*,*,*,*,*,sse2")
3496 (set_attr "type" "multi,multi,multi,mmxmov,mmxmov,ssemov,ssemov")
3497 (set_attr "prefix" "*,*,*,orig,orig,maybe_vex,maybe_vex")
3498 (set_attr "mode" "SI,SI,SI,DI,DI,TI,TI")])
3501 [(set (match_operand:DI 0 "register_operand" "")
3502 (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3503 (clobber (reg:CC FLAGS_REG))]
3504 "!TARGET_64BIT && reload_completed
3505 && true_regnum (operands[0]) == true_regnum (operands[1])"
3506 [(set (match_dup 4) (const_int 0))]
3507 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3510 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3511 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3512 (clobber (reg:CC FLAGS_REG))]
3513 "!TARGET_64BIT && reload_completed
3514 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))"
3515 [(set (match_dup 3) (match_dup 1))
3516 (set (match_dup 4) (const_int 0))]
3517 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3519 (define_insn "zero_extend<mode>di2"
3520 [(set (match_operand:DI 0 "register_operand" "=r")
3522 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3524 "movz{<imodesuffix>l|x}\t{%1, %k0|%k0, %1}"
3525 [(set_attr "type" "imovx")
3526 (set_attr "mode" "SI")])
3528 (define_expand "zero_extendhisi2"
3529 [(set (match_operand:SI 0 "register_operand" "")
3530 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3533 if (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3535 operands[1] = force_reg (HImode, operands[1]);
3536 emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3541 (define_insn_and_split "zero_extendhisi2_and"
3542 [(set (match_operand:SI 0 "register_operand" "=r")
3543 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3544 (clobber (reg:CC FLAGS_REG))]
3545 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3547 "&& reload_completed"
3548 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3549 (clobber (reg:CC FLAGS_REG))])]
3551 [(set_attr "type" "alu1")
3552 (set_attr "mode" "SI")])
3554 (define_insn "*zero_extendhisi2_movzwl"
3555 [(set (match_operand:SI 0 "register_operand" "=r")
3556 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3557 "!TARGET_ZERO_EXTEND_WITH_AND
3558 || optimize_function_for_size_p (cfun)"
3559 "movz{wl|x}\t{%1, %0|%0, %1}"
3560 [(set_attr "type" "imovx")
3561 (set_attr "mode" "SI")])
3563 (define_expand "zero_extendqi<mode>2"
3565 [(set (match_operand:SWI24 0 "register_operand" "")
3566 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3567 (clobber (reg:CC FLAGS_REG))])])
3569 (define_insn "*zero_extendqi<mode>2_and"
3570 [(set (match_operand:SWI24 0 "register_operand" "=r,?&q")
3571 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3572 (clobber (reg:CC FLAGS_REG))]
3573 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3575 [(set_attr "type" "alu1")
3576 (set_attr "mode" "<MODE>")])
3578 ;; When source and destination does not overlap, clear destination
3579 ;; first and then do the movb
3581 [(set (match_operand:SWI24 0 "register_operand" "")
3582 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3583 (clobber (reg:CC FLAGS_REG))]
3585 && (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3586 && ANY_QI_REG_P (operands[0])
3587 && (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]))
3588 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3589 [(set (strict_low_part (match_dup 2)) (match_dup 1))]
3591 operands[2] = gen_lowpart (QImode, operands[0]);
3592 ix86_expand_clear (operands[0]);
3595 (define_insn "*zero_extendqi<mode>2_movzbl_and"
3596 [(set (match_operand:SWI24 0 "register_operand" "=r,r")
3597 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3598 (clobber (reg:CC FLAGS_REG))]
3599 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun)"
3601 [(set_attr "type" "imovx,alu1")
3602 (set_attr "mode" "<MODE>")])
3604 ;; For the movzbl case strip only the clobber
3606 [(set (match_operand:SWI24 0 "register_operand" "")
3607 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3608 (clobber (reg:CC FLAGS_REG))]
3610 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))
3611 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3613 (zero_extend:SWI24 (match_dup 1)))])
3615 ; zero extend to SImode to avoid partial register stalls
3616 (define_insn "*zero_extendqi<mode>2_movzbl"
3617 [(set (match_operand:SWI24 0 "register_operand" "=r")
3618 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3620 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))"
3621 "movz{bl|x}\t{%1, %k0|%k0, %1}"
3622 [(set_attr "type" "imovx")
3623 (set_attr "mode" "SI")])
3625 ;; Rest is handled by single and.
3627 [(set (match_operand:SWI24 0 "register_operand" "")
3628 (zero_extend:SWI24 (match_operand:QI 1 "register_operand" "")))
3629 (clobber (reg:CC FLAGS_REG))]
3631 && true_regnum (operands[0]) == true_regnum (operands[1])"
3632 [(parallel [(set (match_dup 0) (and:SWI24 (match_dup 0) (const_int 255)))
3633 (clobber (reg:CC FLAGS_REG))])])
3635 ;; Sign extension instructions
3637 (define_expand "extendsidi2"
3638 [(set (match_operand:DI 0 "register_operand" "")
3639 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))]
3644 emit_insn (gen_extendsidi2_1 (operands[0], operands[1]));
3649 (define_insn "*extendsidi2_rex64"
3650 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3651 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3655 movs{lq|x}\t{%1, %0|%0, %1}"
3656 [(set_attr "type" "imovx")
3657 (set_attr "mode" "DI")
3658 (set_attr "prefix_0f" "0")
3659 (set_attr "modrm" "0,1")])
3661 (define_insn "extendsidi2_1"
3662 [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3663 (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3664 (clobber (reg:CC FLAGS_REG))
3665 (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3669 ;; Extend to memory case when source register does die.
3671 [(set (match_operand:DI 0 "memory_operand" "")
3672 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3673 (clobber (reg:CC FLAGS_REG))
3674 (clobber (match_operand:SI 2 "register_operand" ""))]
3676 && dead_or_set_p (insn, operands[1])
3677 && !reg_mentioned_p (operands[1], operands[0]))"
3678 [(set (match_dup 3) (match_dup 1))
3679 (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3680 (clobber (reg:CC FLAGS_REG))])
3681 (set (match_dup 4) (match_dup 1))]
3682 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3684 ;; Extend to memory case when source register does not die.
3686 [(set (match_operand:DI 0 "memory_operand" "")
3687 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3688 (clobber (reg:CC FLAGS_REG))
3689 (clobber (match_operand:SI 2 "register_operand" ""))]
3693 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3695 emit_move_insn (operands[3], operands[1]);
3697 /* Generate a cltd if possible and doing so it profitable. */
3698 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3699 && true_regnum (operands[1]) == AX_REG
3700 && true_regnum (operands[2]) == DX_REG)
3702 emit_insn (gen_ashrsi3_cvt (operands[2], operands[1], GEN_INT (31)));
3706 emit_move_insn (operands[2], operands[1]);
3707 emit_insn (gen_ashrsi3_cvt (operands[2], operands[2], GEN_INT (31)));
3709 emit_move_insn (operands[4], operands[2]);
3713 ;; Extend to register case. Optimize case where source and destination
3714 ;; registers match and cases where we can use cltd.
3716 [(set (match_operand:DI 0 "register_operand" "")
3717 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3718 (clobber (reg:CC FLAGS_REG))
3719 (clobber (match_scratch:SI 2 ""))]
3723 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3725 if (true_regnum (operands[3]) != true_regnum (operands[1]))
3726 emit_move_insn (operands[3], operands[1]);
3728 /* Generate a cltd if possible and doing so it profitable. */
3729 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3730 && true_regnum (operands[3]) == AX_REG
3731 && true_regnum (operands[4]) == DX_REG)
3733 emit_insn (gen_ashrsi3_cvt (operands[4], operands[3], GEN_INT (31)));
3737 if (true_regnum (operands[4]) != true_regnum (operands[1]))
3738 emit_move_insn (operands[4], operands[1]);
3740 emit_insn (gen_ashrsi3_cvt (operands[4], operands[4], GEN_INT (31)));
3744 (define_insn "extend<mode>di2"
3745 [(set (match_operand:DI 0 "register_operand" "=r")
3747 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3749 "movs{<imodesuffix>q|x}\t{%1, %0|%0, %1}"
3750 [(set_attr "type" "imovx")
3751 (set_attr "mode" "DI")])
3753 (define_insn "extendhisi2"
3754 [(set (match_operand:SI 0 "register_operand" "=*a,r")
3755 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3758 switch (get_attr_prefix_0f (insn))
3761 return "{cwtl|cwde}";
3763 return "movs{wl|x}\t{%1, %0|%0, %1}";
3766 [(set_attr "type" "imovx")
3767 (set_attr "mode" "SI")
3768 (set (attr "prefix_0f")
3769 ;; movsx is short decodable while cwtl is vector decoded.
3770 (if_then_else (and (eq_attr "cpu" "!k6")
3771 (eq_attr "alternative" "0"))
3773 (const_string "1")))
3775 (if_then_else (eq_attr "prefix_0f" "0")
3777 (const_string "1")))])
3779 (define_insn "*extendhisi2_zext"
3780 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3783 (match_operand:HI 1 "nonimmediate_operand" "*0,rm"))))]
3786 switch (get_attr_prefix_0f (insn))
3789 return "{cwtl|cwde}";
3791 return "movs{wl|x}\t{%1, %k0|%k0, %1}";
3794 [(set_attr "type" "imovx")
3795 (set_attr "mode" "SI")
3796 (set (attr "prefix_0f")
3797 ;; movsx is short decodable while cwtl is vector decoded.
3798 (if_then_else (and (eq_attr "cpu" "!k6")
3799 (eq_attr "alternative" "0"))
3801 (const_string "1")))
3803 (if_then_else (eq_attr "prefix_0f" "0")
3805 (const_string "1")))])
3807 (define_insn "extendqisi2"
3808 [(set (match_operand:SI 0 "register_operand" "=r")
3809 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3811 "movs{bl|x}\t{%1, %0|%0, %1}"
3812 [(set_attr "type" "imovx")
3813 (set_attr "mode" "SI")])
3815 (define_insn "*extendqisi2_zext"
3816 [(set (match_operand:DI 0 "register_operand" "=r")
3818 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm"))))]
3820 "movs{bl|x}\t{%1, %k0|%k0, %1}"
3821 [(set_attr "type" "imovx")
3822 (set_attr "mode" "SI")])
3824 (define_insn "extendqihi2"
3825 [(set (match_operand:HI 0 "register_operand" "=*a,r")
3826 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "*0,qm")))]
3829 switch (get_attr_prefix_0f (insn))
3832 return "{cbtw|cbw}";
3834 return "movs{bw|x}\t{%1, %0|%0, %1}";
3837 [(set_attr "type" "imovx")
3838 (set_attr "mode" "HI")
3839 (set (attr "prefix_0f")
3840 ;; movsx is short decodable while cwtl is vector decoded.
3841 (if_then_else (and (eq_attr "cpu" "!k6")
3842 (eq_attr "alternative" "0"))
3844 (const_string "1")))
3846 (if_then_else (eq_attr "prefix_0f" "0")
3848 (const_string "1")))])
3850 ;; Conversions between float and double.
3852 ;; These are all no-ops in the model used for the 80387.
3853 ;; So just emit moves.
3855 ;; %%% Kill these when call knows how to work out a DFmode push earlier.
3857 [(set (match_operand:DF 0 "push_operand" "")
3858 (float_extend:DF (match_operand:SF 1 "fp_register_operand" "")))]
3860 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
3861 (set (mem:DF (reg:P SP_REG)) (float_extend:DF (match_dup 1)))])
3864 [(set (match_operand:XF 0 "push_operand" "")
3865 (float_extend:XF (match_operand:MODEF 1 "fp_register_operand" "")))]
3867 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
3868 (set (mem:XF (reg:P SP_REG)) (float_extend:XF (match_dup 1)))]
3869 "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
3871 (define_expand "extendsfdf2"
3872 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3873 (float_extend:DF (match_operand:SF 1 "general_operand" "")))]
3874 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
3876 /* ??? Needed for compress_float_constant since all fp constants
3877 are TARGET_LEGITIMATE_CONSTANT_P. */
3878 if (GET_CODE (operands[1]) == CONST_DOUBLE)
3880 if ((!TARGET_SSE2 || TARGET_MIX_SSE_I387)
3881 && standard_80387_constant_p (operands[1]) > 0)
3883 operands[1] = simplify_const_unary_operation
3884 (FLOAT_EXTEND, DFmode, operands[1], SFmode);
3885 emit_move_insn_1 (operands[0], operands[1]);
3888 operands[1] = validize_mem (force_const_mem (SFmode, operands[1]));
3892 /* For converting SF(xmm2) to DF(xmm1), use the following code instead of
3894 unpcklps xmm2,xmm2 ; packed conversion might crash on signaling NaNs
3896 We do the conversion post reload to avoid producing of 128bit spills
3897 that might lead to ICE on 32bit target. The sequence unlikely combine
3900 [(set (match_operand:DF 0 "register_operand" "")
3902 (match_operand:SF 1 "nonimmediate_operand" "")))]
3903 "TARGET_USE_VECTOR_FP_CONVERTS
3904 && optimize_insn_for_speed_p ()
3905 && reload_completed && SSE_REG_P (operands[0])"
3910 (parallel [(const_int 0) (const_int 1)]))))]
3912 operands[2] = simplify_gen_subreg (V2DFmode, operands[0], DFmode, 0);
3913 operands[3] = simplify_gen_subreg (V4SFmode, operands[0], DFmode, 0);
3914 /* Use movss for loading from memory, unpcklps reg, reg for registers.
3915 Try to avoid move when unpacking can be done in source. */
3916 if (REG_P (operands[1]))
3918 /* If it is unsafe to overwrite upper half of source, we need
3919 to move to destination and unpack there. */
3920 if ((ORIGINAL_REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3921 || PSEUDO_REGNO_BYTES (ORIGINAL_REGNO (operands[1])) > 4)
3922 && true_regnum (operands[0]) != true_regnum (operands[1]))
3924 rtx tmp = gen_rtx_REG (SFmode, true_regnum (operands[0]));
3925 emit_move_insn (tmp, operands[1]);
3928 operands[3] = simplify_gen_subreg (V4SFmode, operands[1], SFmode, 0);
3929 emit_insn (gen_vec_interleave_lowv4sf (operands[3], operands[3],
3933 emit_insn (gen_vec_setv4sf_0 (operands[3],
3934 CONST0_RTX (V4SFmode), operands[1]));
3937 (define_insn "*extendsfdf2_mixed"
3938 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,m,x")
3940 (match_operand:SF 1 "nonimmediate_operand" "fm,f,xm")))]
3941 "TARGET_SSE2 && TARGET_MIX_SSE_I387"
3943 switch (which_alternative)
3947 return output_387_reg_move (insn, operands);
3950 return "%vcvtss2sd\t{%1, %d0|%d0, %1}";
3956 [(set_attr "type" "fmov,fmov,ssecvt")
3957 (set_attr "prefix" "orig,orig,maybe_vex")
3958 (set_attr "mode" "SF,XF,DF")])
3960 (define_insn "*extendsfdf2_sse"