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
237 ;; For RDRAND support
241 (define_c_enum "unspecv" [
244 UNSPECV_PROBE_STACK_RANGE
264 UNSPECV_LLWP_INTRINSIC
265 UNSPECV_SLWP_INTRINSIC
266 UNSPECV_LWPVAL_INTRINSIC
267 UNSPECV_LWPINS_INTRINSIC
272 UNSPECV_SPLIT_STACK_RETURN
275 ;; Constants to represent rounding modes in the ROUND instruction
284 ;; Constants to represent pcomtrue/pcomfalse variants
294 ;; Constants used in the XOP pperm instruction
296 [(PPERM_SRC 0x00) /* copy source */
297 (PPERM_INVERT 0x20) /* invert source */
298 (PPERM_REVERSE 0x40) /* bit reverse source */
299 (PPERM_REV_INV 0x60) /* bit reverse & invert src */
300 (PPERM_ZERO 0x80) /* all 0's */
301 (PPERM_ONES 0xa0) /* all 1's */
302 (PPERM_SIGN 0xc0) /* propagate sign bit */
303 (PPERM_INV_SIGN 0xe0) /* invert & propagate sign */
304 (PPERM_SRC1 0x00) /* use first source byte */
305 (PPERM_SRC2 0x10) /* use second source byte */
308 ;; Registers by name.
361 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
364 ;; In C guard expressions, put expressions which may be compile-time
365 ;; constants first. This allows for better optimization. For
366 ;; example, write "TARGET_64BIT && reload_completed", not
367 ;; "reload_completed && TARGET_64BIT".
371 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,corei7,
372 atom,generic64,amdfam10,bdver1,btver1"
373 (const (symbol_ref "ix86_schedule")))
375 ;; A basic instruction type. Refinements due to arguments to be
376 ;; provided in other attributes.
379 alu,alu1,negnot,imov,imovx,lea,
380 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
381 icmp,test,ibr,setcc,icmov,
382 push,pop,call,callv,leave,
384 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
385 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
386 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
387 ssemuladd,sse4arg,lwp,
388 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
389 (const_string "other"))
391 ;; Main data type used by the insn
393 "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
394 (const_string "unknown"))
396 ;; The CPU unit operations uses.
397 (define_attr "unit" "integer,i387,sse,mmx,unknown"
398 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
399 (const_string "i387")
400 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
401 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
402 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
404 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
406 (eq_attr "type" "other")
407 (const_string "unknown")]
408 (const_string "integer")))
410 ;; The (bounding maximum) length of an instruction immediate.
411 (define_attr "length_immediate" ""
412 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
415 (eq_attr "unit" "i387,sse,mmx")
417 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
419 (symbol_ref "ix86_attr_length_immediate_default (insn, true)")
420 (eq_attr "type" "imov,test")
421 (symbol_ref "ix86_attr_length_immediate_default (insn, false)")
422 (eq_attr "type" "call")
423 (if_then_else (match_operand 0 "constant_call_address_operand" "")
426 (eq_attr "type" "callv")
427 (if_then_else (match_operand 1 "constant_call_address_operand" "")
430 ;; We don't know the size before shorten_branches. Expect
431 ;; the instruction to fit for better scheduling.
432 (eq_attr "type" "ibr")
435 (symbol_ref "/* Update immediate_length and other attributes! */
436 gcc_unreachable (),1")))
438 ;; The (bounding maximum) length of an instruction address.
439 (define_attr "length_address" ""
440 (cond [(eq_attr "type" "str,other,multi,fxch")
442 (and (eq_attr "type" "call")
443 (match_operand 0 "constant_call_address_operand" ""))
445 (and (eq_attr "type" "callv")
446 (match_operand 1 "constant_call_address_operand" ""))
449 (symbol_ref "ix86_attr_length_address_default (insn)")))
451 ;; Set when length prefix is used.
452 (define_attr "prefix_data16" ""
453 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
455 (eq_attr "mode" "HI")
457 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
462 ;; Set when string REP prefix is used.
463 (define_attr "prefix_rep" ""
464 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
466 (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
471 ;; Set when 0f opcode prefix is used.
472 (define_attr "prefix_0f" ""
474 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
475 (eq_attr "unit" "sse,mmx"))
479 ;; Set when REX opcode prefix is used.
480 (define_attr "prefix_rex" ""
481 (cond [(eq (symbol_ref "TARGET_64BIT") (const_int 0))
483 (and (eq_attr "mode" "DI")
484 (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
485 (eq_attr "unit" "!mmx")))
487 (and (eq_attr "mode" "QI")
488 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
491 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
494 (and (eq_attr "type" "imovx")
495 (match_operand:QI 1 "ext_QIreg_operand" ""))
500 ;; There are also additional prefixes in 3DNOW, SSSE3.
501 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
502 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
503 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
504 (define_attr "prefix_extra" ""
505 (cond [(eq_attr "type" "ssemuladd,sse4arg")
507 (eq_attr "type" "sseiadd1,ssecvt1")
512 ;; Prefix used: original, VEX or maybe VEX.
513 (define_attr "prefix" "orig,vex,maybe_vex"
514 (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
516 (const_string "orig")))
518 ;; VEX W bit is used.
519 (define_attr "prefix_vex_w" "" (const_int 0))
521 ;; The length of VEX prefix
522 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
523 ;; 0f38/0f3a prefixes can't. In i386.md 0f3[8a] is
524 ;; still prefix_0f 1, with prefix_extra 1.
525 (define_attr "length_vex" ""
526 (if_then_else (and (eq_attr "prefix_0f" "1")
527 (eq_attr "prefix_extra" "0"))
528 (if_then_else (eq_attr "prefix_vex_w" "1")
529 (symbol_ref "ix86_attr_length_vex_default (insn, true, true)")
530 (symbol_ref "ix86_attr_length_vex_default (insn, true, false)"))
531 (if_then_else (eq_attr "prefix_vex_w" "1")
532 (symbol_ref "ix86_attr_length_vex_default (insn, false, true)")
533 (symbol_ref "ix86_attr_length_vex_default (insn, false, false)"))))
535 ;; Set when modrm byte is used.
536 (define_attr "modrm" ""
537 (cond [(eq_attr "type" "str,leave")
539 (eq_attr "unit" "i387")
541 (and (eq_attr "type" "incdec")
542 (and (eq (symbol_ref "TARGET_64BIT") (const_int 0))
543 (ior (match_operand:SI 1 "register_operand" "")
544 (match_operand:HI 1 "register_operand" ""))))
546 (and (eq_attr "type" "push")
547 (not (match_operand 1 "memory_operand" "")))
549 (and (eq_attr "type" "pop")
550 (not (match_operand 0 "memory_operand" "")))
552 (and (eq_attr "type" "imov")
553 (and (not (eq_attr "mode" "DI"))
554 (ior (and (match_operand 0 "register_operand" "")
555 (match_operand 1 "immediate_operand" ""))
556 (ior (and (match_operand 0 "ax_reg_operand" "")
557 (match_operand 1 "memory_displacement_only_operand" ""))
558 (and (match_operand 0 "memory_displacement_only_operand" "")
559 (match_operand 1 "ax_reg_operand" ""))))))
561 (and (eq_attr "type" "call")
562 (match_operand 0 "constant_call_address_operand" ""))
564 (and (eq_attr "type" "callv")
565 (match_operand 1 "constant_call_address_operand" ""))
567 (and (eq_attr "type" "alu,alu1,icmp,test")
568 (match_operand 0 "ax_reg_operand" ""))
569 (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
573 ;; The (bounding maximum) length of an instruction in bytes.
574 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
575 ;; Later we may want to split them and compute proper length as for
577 (define_attr "length" ""
578 (cond [(eq_attr "type" "other,multi,fistp,frndint")
580 (eq_attr "type" "fcmp")
582 (eq_attr "unit" "i387")
584 (plus (attr "prefix_data16")
585 (attr "length_address")))
586 (ior (eq_attr "prefix" "vex")
587 (and (eq_attr "prefix" "maybe_vex")
588 (ne (symbol_ref "TARGET_AVX") (const_int 0))))
589 (plus (attr "length_vex")
590 (plus (attr "length_immediate")
592 (attr "length_address"))))]
593 (plus (plus (attr "modrm")
594 (plus (attr "prefix_0f")
595 (plus (attr "prefix_rex")
596 (plus (attr "prefix_extra")
598 (plus (attr "prefix_rep")
599 (plus (attr "prefix_data16")
600 (plus (attr "length_immediate")
601 (attr "length_address")))))))
603 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
604 ;; `store' if there is a simple memory reference therein, or `unknown'
605 ;; if the instruction is complex.
607 (define_attr "memory" "none,load,store,both,unknown"
608 (cond [(eq_attr "type" "other,multi,str,lwp")
609 (const_string "unknown")
610 (eq_attr "type" "lea,fcmov,fpspc")
611 (const_string "none")
612 (eq_attr "type" "fistp,leave")
613 (const_string "both")
614 (eq_attr "type" "frndint")
615 (const_string "load")
616 (eq_attr "type" "push")
617 (if_then_else (match_operand 1 "memory_operand" "")
618 (const_string "both")
619 (const_string "store"))
620 (eq_attr "type" "pop")
621 (if_then_else (match_operand 0 "memory_operand" "")
622 (const_string "both")
623 (const_string "load"))
624 (eq_attr "type" "setcc")
625 (if_then_else (match_operand 0 "memory_operand" "")
626 (const_string "store")
627 (const_string "none"))
628 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
629 (if_then_else (ior (match_operand 0 "memory_operand" "")
630 (match_operand 1 "memory_operand" ""))
631 (const_string "load")
632 (const_string "none"))
633 (eq_attr "type" "ibr")
634 (if_then_else (match_operand 0 "memory_operand" "")
635 (const_string "load")
636 (const_string "none"))
637 (eq_attr "type" "call")
638 (if_then_else (match_operand 0 "constant_call_address_operand" "")
639 (const_string "none")
640 (const_string "load"))
641 (eq_attr "type" "callv")
642 (if_then_else (match_operand 1 "constant_call_address_operand" "")
643 (const_string "none")
644 (const_string "load"))
645 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
646 (match_operand 1 "memory_operand" ""))
647 (const_string "both")
648 (and (match_operand 0 "memory_operand" "")
649 (match_operand 1 "memory_operand" ""))
650 (const_string "both")
651 (match_operand 0 "memory_operand" "")
652 (const_string "store")
653 (match_operand 1 "memory_operand" "")
654 (const_string "load")
656 "!alu1,negnot,ishift1,
657 imov,imovx,icmp,test,bitmanip,
659 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
660 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
661 (match_operand 2 "memory_operand" ""))
662 (const_string "load")
663 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
664 (match_operand 3 "memory_operand" ""))
665 (const_string "load")
667 (const_string "none")))
669 ;; Indicates if an instruction has both an immediate and a displacement.
671 (define_attr "imm_disp" "false,true,unknown"
672 (cond [(eq_attr "type" "other,multi")
673 (const_string "unknown")
674 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
675 (and (match_operand 0 "memory_displacement_operand" "")
676 (match_operand 1 "immediate_operand" "")))
677 (const_string "true")
678 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
679 (and (match_operand 0 "memory_displacement_operand" "")
680 (match_operand 2 "immediate_operand" "")))
681 (const_string "true")
683 (const_string "false")))
685 ;; Indicates if an FP operation has an integer source.
687 (define_attr "fp_int_src" "false,true"
688 (const_string "false"))
690 ;; Defines rounding mode of an FP operation.
692 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
693 (const_string "any"))
695 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
696 (define_attr "use_carry" "0,1" (const_string "0"))
698 ;; Define attribute to indicate unaligned ssemov insns
699 (define_attr "movu" "0,1" (const_string "0"))
701 ;; Used to control the "enabled" attribute on a per-instruction basis.
702 (define_attr "isa" "base,noavx,avx"
703 (const_string "base"))
705 (define_attr "enabled" ""
706 (cond [(eq_attr "isa" "noavx") (symbol_ref "!TARGET_AVX")
707 (eq_attr "isa" "avx") (symbol_ref "TARGET_AVX")
711 ;; Describe a user's asm statement.
712 (define_asm_attributes
713 [(set_attr "length" "128")
714 (set_attr "type" "multi")])
716 (define_code_iterator plusminus [plus minus])
718 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
720 ;; Base name for define_insn
721 (define_code_attr plusminus_insn
722 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
723 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
725 ;; Base name for insn mnemonic.
726 (define_code_attr plusminus_mnemonic
727 [(plus "add") (ss_plus "adds") (us_plus "addus")
728 (minus "sub") (ss_minus "subs") (us_minus "subus")])
729 (define_code_attr plusminus_carry_mnemonic
730 [(plus "adc") (minus "sbb")])
732 ;; Mark commutative operators as such in constraints.
733 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
734 (minus "") (ss_minus "") (us_minus "")])
736 ;; Mapping of signed max and min
737 (define_code_iterator smaxmin [smax smin])
739 ;; Mapping of unsigned max and min
740 (define_code_iterator umaxmin [umax umin])
742 ;; Base name for integer and FP insn mnemonic
743 (define_code_attr maxmin_int [(smax "maxs") (smin "mins")
744 (umax "maxu") (umin "minu")])
745 (define_code_attr maxmin_float [(smax "max") (smin "min")])
747 ;; Mapping of logic operators
748 (define_code_iterator any_logic [and ior xor])
749 (define_code_iterator any_or [ior xor])
751 ;; Base name for insn mnemonic.
752 (define_code_attr logic [(and "and") (ior "or") (xor "xor")])
754 ;; Mapping of shift-right operators
755 (define_code_iterator any_shiftrt [lshiftrt ashiftrt])
757 ;; Base name for define_insn
758 (define_code_attr shiftrt_insn [(lshiftrt "lshr") (ashiftrt "ashr")])
760 ;; Base name for insn mnemonic.
761 (define_code_attr shiftrt [(lshiftrt "shr") (ashiftrt "sar")])
763 ;; Mapping of rotate operators
764 (define_code_iterator any_rotate [rotate rotatert])
766 ;; Base name for define_insn
767 (define_code_attr rotate_insn [(rotate "rotl") (rotatert "rotr")])
769 ;; Base name for insn mnemonic.
770 (define_code_attr rotate [(rotate "rol") (rotatert "ror")])
772 ;; Mapping of abs neg operators
773 (define_code_iterator absneg [abs neg])
775 ;; Base name for x87 insn mnemonic.
776 (define_code_attr absneg_mnemonic [(abs "abs") (neg "chs")])
778 ;; Used in signed and unsigned widening multiplications.
779 (define_code_iterator any_extend [sign_extend zero_extend])
781 ;; Various insn prefixes for signed and unsigned operations.
782 (define_code_attr u [(sign_extend "") (zero_extend "u")
783 (div "") (udiv "u")])
784 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
786 ;; Used in signed and unsigned divisions.
787 (define_code_iterator any_div [div udiv])
789 ;; Instruction prefix for signed and unsigned operations.
790 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")
791 (div "i") (udiv "")])
793 ;; 64bit single word integer modes.
794 (define_mode_iterator SWI1248x [QI HI SI DI])
796 ;; 64bit single word integer modes without QImode and HImode.
797 (define_mode_iterator SWI48x [SI DI])
799 ;; Single word integer modes.
800 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
802 ;; Single word integer modes without SImode and DImode.
803 (define_mode_iterator SWI12 [QI HI])
805 ;; Single word integer modes without DImode.
806 (define_mode_iterator SWI124 [QI HI SI])
808 ;; Single word integer modes without QImode and DImode.
809 (define_mode_iterator SWI24 [HI SI])
811 ;; Single word integer modes without QImode.
812 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
814 ;; Single word integer modes without QImode and HImode.
815 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
817 ;; All math-dependant single and double word integer modes.
818 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
819 (HI "TARGET_HIMODE_MATH")
820 SI DI (TI "TARGET_64BIT")])
822 ;; Math-dependant single word integer modes.
823 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
824 (HI "TARGET_HIMODE_MATH")
825 SI (DI "TARGET_64BIT")])
827 ;; Math-dependant single word integer modes without DImode.
828 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
829 (HI "TARGET_HIMODE_MATH")
832 ;; Math-dependant single word integer modes without QImode.
833 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
834 SI (DI "TARGET_64BIT")])
836 ;; Double word integer modes.
837 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
838 (TI "TARGET_64BIT")])
840 ;; Double word integer modes as mode attribute.
841 (define_mode_attr DWI [(SI "DI") (DI "TI")])
842 (define_mode_attr dwi [(SI "di") (DI "ti")])
844 ;; Half mode for double word integer modes.
845 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
846 (DI "TARGET_64BIT")])
848 ;; Instruction suffix for integer modes.
849 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
851 ;; Pointer size prefix for integer modes (Intel asm dialect)
852 (define_mode_attr iptrsize [(QI "BYTE")
857 ;; Register class for integer modes.
858 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
860 ;; Immediate operand constraint for integer modes.
861 (define_mode_attr i [(QI "n") (HI "n") (SI "i") (DI "e")])
863 ;; General operand constraint for word modes.
864 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "g") (DI "rme")])
866 ;; Immediate operand constraint for double integer modes.
867 (define_mode_attr di [(SI "iF") (DI "e")])
869 ;; Immediate operand constraint for shifts.
870 (define_mode_attr S [(QI "I") (HI "I") (SI "I") (DI "J") (TI "O")])
872 ;; General operand predicate for integer modes.
873 (define_mode_attr general_operand
874 [(QI "general_operand")
875 (HI "general_operand")
876 (SI "general_operand")
877 (DI "x86_64_general_operand")
878 (TI "x86_64_general_operand")])
880 ;; General sign/zero extend operand predicate for integer modes.
881 (define_mode_attr general_szext_operand
882 [(QI "general_operand")
883 (HI "general_operand")
884 (SI "general_operand")
885 (DI "x86_64_szext_general_operand")])
887 ;; Immediate operand predicate for integer modes.
888 (define_mode_attr immediate_operand
889 [(QI "immediate_operand")
890 (HI "immediate_operand")
891 (SI "immediate_operand")
892 (DI "x86_64_immediate_operand")])
894 ;; Nonmemory operand predicate for integer modes.
895 (define_mode_attr nonmemory_operand
896 [(QI "nonmemory_operand")
897 (HI "nonmemory_operand")
898 (SI "nonmemory_operand")
899 (DI "x86_64_nonmemory_operand")])
901 ;; Operand predicate for shifts.
902 (define_mode_attr shift_operand
903 [(QI "nonimmediate_operand")
904 (HI "nonimmediate_operand")
905 (SI "nonimmediate_operand")
906 (DI "shiftdi_operand")
907 (TI "register_operand")])
909 ;; Operand predicate for shift argument.
910 (define_mode_attr shift_immediate_operand
911 [(QI "const_1_to_31_operand")
912 (HI "const_1_to_31_operand")
913 (SI "const_1_to_31_operand")
914 (DI "const_1_to_63_operand")])
916 ;; Input operand predicate for arithmetic left shifts.
917 (define_mode_attr ashl_input_operand
918 [(QI "nonimmediate_operand")
919 (HI "nonimmediate_operand")
920 (SI "nonimmediate_operand")
921 (DI "ashldi_input_operand")
922 (TI "reg_or_pm1_operand")])
924 ;; SSE and x87 SFmode and DFmode floating point modes
925 (define_mode_iterator MODEF [SF DF])
927 ;; All x87 floating point modes
928 (define_mode_iterator X87MODEF [SF DF XF])
930 ;; All integer modes handled by x87 fisttp operator.
931 (define_mode_iterator X87MODEI [HI SI DI])
933 ;; All integer modes handled by integer x87 operators.
934 (define_mode_iterator X87MODEI12 [HI SI])
936 ;; All integer modes handled by SSE cvtts?2si* operators.
937 (define_mode_iterator SSEMODEI24 [SI DI])
939 ;; SSE instruction suffix for various modes
940 (define_mode_attr ssemodesuffix
942 (V8SF "ps") (V4DF "pd")
943 (V4SF "ps") (V2DF "pd")
944 (V16QI "b") (V8HI "w") (V4SI "d") (V2DI "q")
947 ;; SSE vector suffix for floating point modes
948 (define_mode_attr ssevecmodesuffix [(SF "ps") (DF "pd")])
950 ;; SSE vector mode corresponding to a scalar mode
951 (define_mode_attr ssevecmode
952 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
954 ;; Instruction suffix for REX 64bit operators.
955 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
957 ;; This mode iterator allows :P to be used for patterns that operate on
958 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
959 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
961 ;; Scheduling descriptions
963 (include "pentium.md")
966 (include "athlon.md")
967 (include "bdver1.md")
973 ;; Operand and operator predicates and constraints
975 (include "predicates.md")
976 (include "constraints.md")
979 ;; Compare and branch/compare and store instructions.
981 (define_expand "cbranch<mode>4"
982 [(set (reg:CC FLAGS_REG)
983 (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
984 (match_operand:SDWIM 2 "<general_operand>" "")))
985 (set (pc) (if_then_else
986 (match_operator 0 "ordered_comparison_operator"
987 [(reg:CC FLAGS_REG) (const_int 0)])
988 (label_ref (match_operand 3 "" ""))
992 if (MEM_P (operands[1]) && MEM_P (operands[2]))
993 operands[1] = force_reg (<MODE>mode, operands[1]);
994 ix86_expand_branch (GET_CODE (operands[0]),
995 operands[1], operands[2], operands[3]);
999 (define_expand "cstore<mode>4"
1000 [(set (reg:CC FLAGS_REG)
1001 (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
1002 (match_operand:SWIM 3 "<general_operand>" "")))
1003 (set (match_operand:QI 0 "register_operand" "")
1004 (match_operator 1 "ordered_comparison_operator"
1005 [(reg:CC FLAGS_REG) (const_int 0)]))]
1008 if (MEM_P (operands[2]) && MEM_P (operands[3]))
1009 operands[2] = force_reg (<MODE>mode, operands[2]);
1010 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1011 operands[2], operands[3]);
1015 (define_expand "cmp<mode>_1"
1016 [(set (reg:CC FLAGS_REG)
1017 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
1018 (match_operand:SWI48 1 "<general_operand>" "")))])
1020 (define_insn "*cmp<mode>_ccno_1"
1021 [(set (reg FLAGS_REG)
1022 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
1023 (match_operand:SWI 1 "const0_operand" "")))]
1024 "ix86_match_ccmode (insn, CCNOmode)"
1026 test{<imodesuffix>}\t%0, %0
1027 cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1028 [(set_attr "type" "test,icmp")
1029 (set_attr "length_immediate" "0,1")
1030 (set_attr "mode" "<MODE>")])
1032 (define_insn "*cmp<mode>_1"
1033 [(set (reg FLAGS_REG)
1034 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1035 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
1036 "ix86_match_ccmode (insn, CCmode)"
1037 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1038 [(set_attr "type" "icmp")
1039 (set_attr "mode" "<MODE>")])
1041 (define_insn "*cmp<mode>_minus_1"
1042 [(set (reg FLAGS_REG)
1044 (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1045 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
1047 "ix86_match_ccmode (insn, CCGOCmode)"
1048 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1049 [(set_attr "type" "icmp")
1050 (set_attr "mode" "<MODE>")])
1052 (define_insn "*cmpqi_ext_1"
1053 [(set (reg FLAGS_REG)
1055 (match_operand:QI 0 "general_operand" "Qm")
1058 (match_operand 1 "ext_register_operand" "Q")
1060 (const_int 8)) 0)))]
1061 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1062 "cmp{b}\t{%h1, %0|%0, %h1}"
1063 [(set_attr "type" "icmp")
1064 (set_attr "mode" "QI")])
1066 (define_insn "*cmpqi_ext_1_rex64"
1067 [(set (reg FLAGS_REG)
1069 (match_operand:QI 0 "register_operand" "Q")
1072 (match_operand 1 "ext_register_operand" "Q")
1074 (const_int 8)) 0)))]
1075 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1076 "cmp{b}\t{%h1, %0|%0, %h1}"
1077 [(set_attr "type" "icmp")
1078 (set_attr "mode" "QI")])
1080 (define_insn "*cmpqi_ext_2"
1081 [(set (reg FLAGS_REG)
1085 (match_operand 0 "ext_register_operand" "Q")
1088 (match_operand:QI 1 "const0_operand" "")))]
1089 "ix86_match_ccmode (insn, CCNOmode)"
1091 [(set_attr "type" "test")
1092 (set_attr "length_immediate" "0")
1093 (set_attr "mode" "QI")])
1095 (define_expand "cmpqi_ext_3"
1096 [(set (reg:CC FLAGS_REG)
1100 (match_operand 0 "ext_register_operand" "")
1103 (match_operand:QI 1 "immediate_operand" "")))])
1105 (define_insn "*cmpqi_ext_3_insn"
1106 [(set (reg FLAGS_REG)
1110 (match_operand 0 "ext_register_operand" "Q")
1113 (match_operand:QI 1 "general_operand" "Qmn")))]
1114 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1115 "cmp{b}\t{%1, %h0|%h0, %1}"
1116 [(set_attr "type" "icmp")
1117 (set_attr "modrm" "1")
1118 (set_attr "mode" "QI")])
1120 (define_insn "*cmpqi_ext_3_insn_rex64"
1121 [(set (reg FLAGS_REG)
1125 (match_operand 0 "ext_register_operand" "Q")
1128 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1129 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1130 "cmp{b}\t{%1, %h0|%h0, %1}"
1131 [(set_attr "type" "icmp")
1132 (set_attr "modrm" "1")
1133 (set_attr "mode" "QI")])
1135 (define_insn "*cmpqi_ext_4"
1136 [(set (reg FLAGS_REG)
1140 (match_operand 0 "ext_register_operand" "Q")
1145 (match_operand 1 "ext_register_operand" "Q")
1147 (const_int 8)) 0)))]
1148 "ix86_match_ccmode (insn, CCmode)"
1149 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1150 [(set_attr "type" "icmp")
1151 (set_attr "mode" "QI")])
1153 ;; These implement float point compares.
1154 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1155 ;; which would allow mix and match FP modes on the compares. Which is what
1156 ;; the old patterns did, but with many more of them.
1158 (define_expand "cbranchxf4"
1159 [(set (reg:CC FLAGS_REG)
1160 (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1161 (match_operand:XF 2 "nonmemory_operand" "")))
1162 (set (pc) (if_then_else
1163 (match_operator 0 "ix86_fp_comparison_operator"
1166 (label_ref (match_operand 3 "" ""))
1170 ix86_expand_branch (GET_CODE (operands[0]),
1171 operands[1], operands[2], operands[3]);
1175 (define_expand "cstorexf4"
1176 [(set (reg:CC FLAGS_REG)
1177 (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1178 (match_operand:XF 3 "nonmemory_operand" "")))
1179 (set (match_operand:QI 0 "register_operand" "")
1180 (match_operator 1 "ix86_fp_comparison_operator"
1185 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1186 operands[2], operands[3]);
1190 (define_expand "cbranch<mode>4"
1191 [(set (reg:CC FLAGS_REG)
1192 (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1193 (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1194 (set (pc) (if_then_else
1195 (match_operator 0 "ix86_fp_comparison_operator"
1198 (label_ref (match_operand 3 "" ""))
1200 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1202 ix86_expand_branch (GET_CODE (operands[0]),
1203 operands[1], operands[2], operands[3]);
1207 (define_expand "cstore<mode>4"
1208 [(set (reg:CC FLAGS_REG)
1209 (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1210 (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1211 (set (match_operand:QI 0 "register_operand" "")
1212 (match_operator 1 "ix86_fp_comparison_operator"
1215 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1217 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1218 operands[2], operands[3]);
1222 (define_expand "cbranchcc4"
1223 [(set (pc) (if_then_else
1224 (match_operator 0 "comparison_operator"
1225 [(match_operand 1 "flags_reg_operand" "")
1226 (match_operand 2 "const0_operand" "")])
1227 (label_ref (match_operand 3 "" ""))
1231 ix86_expand_branch (GET_CODE (operands[0]),
1232 operands[1], operands[2], operands[3]);
1236 (define_expand "cstorecc4"
1237 [(set (match_operand:QI 0 "register_operand" "")
1238 (match_operator 1 "comparison_operator"
1239 [(match_operand 2 "flags_reg_operand" "")
1240 (match_operand 3 "const0_operand" "")]))]
1243 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1244 operands[2], operands[3]);
1249 ;; FP compares, step 1:
1250 ;; Set the FP condition codes.
1252 ;; CCFPmode compare with exceptions
1253 ;; CCFPUmode compare with no exceptions
1255 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1256 ;; used to manage the reg stack popping would not be preserved.
1258 (define_insn "*cmpfp_0"
1259 [(set (match_operand:HI 0 "register_operand" "=a")
1262 (match_operand 1 "register_operand" "f")
1263 (match_operand 2 "const0_operand" ""))]
1265 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1266 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1267 "* return output_fp_compare (insn, operands, false, false);"
1268 [(set_attr "type" "multi")
1269 (set_attr "unit" "i387")
1271 (cond [(match_operand:SF 1 "" "")
1273 (match_operand:DF 1 "" "")
1276 (const_string "XF")))])
1278 (define_insn_and_split "*cmpfp_0_cc"
1279 [(set (reg:CCFP FLAGS_REG)
1281 (match_operand 1 "register_operand" "f")
1282 (match_operand 2 "const0_operand" "")))
1283 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1284 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1285 && TARGET_SAHF && !TARGET_CMOVE
1286 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1288 "&& reload_completed"
1291 [(compare:CCFP (match_dup 1)(match_dup 2))]
1293 (set (reg:CC FLAGS_REG)
1294 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1296 [(set_attr "type" "multi")
1297 (set_attr "unit" "i387")
1299 (cond [(match_operand:SF 1 "" "")
1301 (match_operand:DF 1 "" "")
1304 (const_string "XF")))])
1306 (define_insn "*cmpfp_xf"
1307 [(set (match_operand:HI 0 "register_operand" "=a")
1310 (match_operand:XF 1 "register_operand" "f")
1311 (match_operand:XF 2 "register_operand" "f"))]
1314 "* return output_fp_compare (insn, operands, false, false);"
1315 [(set_attr "type" "multi")
1316 (set_attr "unit" "i387")
1317 (set_attr "mode" "XF")])
1319 (define_insn_and_split "*cmpfp_xf_cc"
1320 [(set (reg:CCFP FLAGS_REG)
1322 (match_operand:XF 1 "register_operand" "f")
1323 (match_operand:XF 2 "register_operand" "f")))
1324 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1326 && TARGET_SAHF && !TARGET_CMOVE"
1328 "&& reload_completed"
1331 [(compare:CCFP (match_dup 1)(match_dup 2))]
1333 (set (reg:CC FLAGS_REG)
1334 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1336 [(set_attr "type" "multi")
1337 (set_attr "unit" "i387")
1338 (set_attr "mode" "XF")])
1340 (define_insn "*cmpfp_<mode>"
1341 [(set (match_operand:HI 0 "register_operand" "=a")
1344 (match_operand:MODEF 1 "register_operand" "f")
1345 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1348 "* return output_fp_compare (insn, operands, false, false);"
1349 [(set_attr "type" "multi")
1350 (set_attr "unit" "i387")
1351 (set_attr "mode" "<MODE>")])
1353 (define_insn_and_split "*cmpfp_<mode>_cc"
1354 [(set (reg:CCFP FLAGS_REG)
1356 (match_operand:MODEF 1 "register_operand" "f")
1357 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1358 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1360 && TARGET_SAHF && !TARGET_CMOVE"
1362 "&& reload_completed"
1365 [(compare:CCFP (match_dup 1)(match_dup 2))]
1367 (set (reg:CC FLAGS_REG)
1368 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1370 [(set_attr "type" "multi")
1371 (set_attr "unit" "i387")
1372 (set_attr "mode" "<MODE>")])
1374 (define_insn "*cmpfp_u"
1375 [(set (match_operand:HI 0 "register_operand" "=a")
1378 (match_operand 1 "register_operand" "f")
1379 (match_operand 2 "register_operand" "f"))]
1381 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1382 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1383 "* return output_fp_compare (insn, operands, false, true);"
1384 [(set_attr "type" "multi")
1385 (set_attr "unit" "i387")
1387 (cond [(match_operand:SF 1 "" "")
1389 (match_operand:DF 1 "" "")
1392 (const_string "XF")))])
1394 (define_insn_and_split "*cmpfp_u_cc"
1395 [(set (reg:CCFPU FLAGS_REG)
1397 (match_operand 1 "register_operand" "f")
1398 (match_operand 2 "register_operand" "f")))
1399 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1400 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1401 && TARGET_SAHF && !TARGET_CMOVE
1402 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1404 "&& reload_completed"
1407 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1409 (set (reg:CC FLAGS_REG)
1410 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1412 [(set_attr "type" "multi")
1413 (set_attr "unit" "i387")
1415 (cond [(match_operand:SF 1 "" "")
1417 (match_operand:DF 1 "" "")
1420 (const_string "XF")))])
1422 (define_insn "*cmpfp_<mode>"
1423 [(set (match_operand:HI 0 "register_operand" "=a")
1426 (match_operand 1 "register_operand" "f")
1427 (match_operator 3 "float_operator"
1428 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1430 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1431 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1432 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1433 "* return output_fp_compare (insn, operands, false, false);"
1434 [(set_attr "type" "multi")
1435 (set_attr "unit" "i387")
1436 (set_attr "fp_int_src" "true")
1437 (set_attr "mode" "<MODE>")])
1439 (define_insn_and_split "*cmpfp_<mode>_cc"
1440 [(set (reg:CCFP FLAGS_REG)
1442 (match_operand 1 "register_operand" "f")
1443 (match_operator 3 "float_operator"
1444 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1445 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1446 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1447 && TARGET_SAHF && !TARGET_CMOVE
1448 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1449 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1451 "&& reload_completed"
1456 (match_op_dup 3 [(match_dup 2)]))]
1458 (set (reg:CC FLAGS_REG)
1459 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1461 [(set_attr "type" "multi")
1462 (set_attr "unit" "i387")
1463 (set_attr "fp_int_src" "true")
1464 (set_attr "mode" "<MODE>")])
1466 ;; FP compares, step 2
1467 ;; Move the fpsw to ax.
1469 (define_insn "x86_fnstsw_1"
1470 [(set (match_operand:HI 0 "register_operand" "=a")
1471 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1474 [(set (attr "length") (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1475 (set_attr "mode" "SI")
1476 (set_attr "unit" "i387")])
1478 ;; FP compares, step 3
1479 ;; Get ax into flags, general case.
1481 (define_insn "x86_sahf_1"
1482 [(set (reg:CC FLAGS_REG)
1483 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1487 #ifndef HAVE_AS_IX86_SAHF
1489 return ASM_BYTE "0x9e";
1494 [(set_attr "length" "1")
1495 (set_attr "athlon_decode" "vector")
1496 (set_attr "amdfam10_decode" "direct")
1497 (set_attr "bdver1_decode" "direct")
1498 (set_attr "mode" "SI")])
1500 ;; Pentium Pro can do steps 1 through 3 in one go.
1501 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1502 (define_insn "*cmpfp_i_mixed"
1503 [(set (reg:CCFP FLAGS_REG)
1504 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1505 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1506 "TARGET_MIX_SSE_I387
1507 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1508 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1509 "* return output_fp_compare (insn, operands, true, false);"
1510 [(set_attr "type" "fcmp,ssecomi")
1511 (set_attr "prefix" "orig,maybe_vex")
1513 (if_then_else (match_operand:SF 1 "" "")
1515 (const_string "DF")))
1516 (set (attr "prefix_rep")
1517 (if_then_else (eq_attr "type" "ssecomi")
1519 (const_string "*")))
1520 (set (attr "prefix_data16")
1521 (cond [(eq_attr "type" "fcmp")
1523 (eq_attr "mode" "DF")
1526 (const_string "0")))
1527 (set_attr "athlon_decode" "vector")
1528 (set_attr "amdfam10_decode" "direct")
1529 (set_attr "bdver1_decode" "double")])
1531 (define_insn "*cmpfp_i_sse"
1532 [(set (reg:CCFP FLAGS_REG)
1533 (compare:CCFP (match_operand 0 "register_operand" "x")
1534 (match_operand 1 "nonimmediate_operand" "xm")))]
1536 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1537 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1538 "* return output_fp_compare (insn, operands, true, false);"
1539 [(set_attr "type" "ssecomi")
1540 (set_attr "prefix" "maybe_vex")
1542 (if_then_else (match_operand:SF 1 "" "")
1544 (const_string "DF")))
1545 (set_attr "prefix_rep" "0")
1546 (set (attr "prefix_data16")
1547 (if_then_else (eq_attr "mode" "DF")
1549 (const_string "0")))
1550 (set_attr "athlon_decode" "vector")
1551 (set_attr "amdfam10_decode" "direct")
1552 (set_attr "bdver1_decode" "double")])
1554 (define_insn "*cmpfp_i_i387"
1555 [(set (reg:CCFP FLAGS_REG)
1556 (compare:CCFP (match_operand 0 "register_operand" "f")
1557 (match_operand 1 "register_operand" "f")))]
1558 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1560 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1561 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1562 "* return output_fp_compare (insn, operands, true, false);"
1563 [(set_attr "type" "fcmp")
1565 (cond [(match_operand:SF 1 "" "")
1567 (match_operand:DF 1 "" "")
1570 (const_string "XF")))
1571 (set_attr "athlon_decode" "vector")
1572 (set_attr "amdfam10_decode" "direct")
1573 (set_attr "bdver1_decode" "double")])
1575 (define_insn "*cmpfp_iu_mixed"
1576 [(set (reg:CCFPU FLAGS_REG)
1577 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1578 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1579 "TARGET_MIX_SSE_I387
1580 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1581 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1582 "* return output_fp_compare (insn, operands, true, true);"
1583 [(set_attr "type" "fcmp,ssecomi")
1584 (set_attr "prefix" "orig,maybe_vex")
1586 (if_then_else (match_operand:SF 1 "" "")
1588 (const_string "DF")))
1589 (set (attr "prefix_rep")
1590 (if_then_else (eq_attr "type" "ssecomi")
1592 (const_string "*")))
1593 (set (attr "prefix_data16")
1594 (cond [(eq_attr "type" "fcmp")
1596 (eq_attr "mode" "DF")
1599 (const_string "0")))
1600 (set_attr "athlon_decode" "vector")
1601 (set_attr "amdfam10_decode" "direct")
1602 (set_attr "bdver1_decode" "double")])
1604 (define_insn "*cmpfp_iu_sse"
1605 [(set (reg:CCFPU FLAGS_REG)
1606 (compare:CCFPU (match_operand 0 "register_operand" "x")
1607 (match_operand 1 "nonimmediate_operand" "xm")))]
1609 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1610 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1611 "* return output_fp_compare (insn, operands, true, true);"
1612 [(set_attr "type" "ssecomi")
1613 (set_attr "prefix" "maybe_vex")
1615 (if_then_else (match_operand:SF 1 "" "")
1617 (const_string "DF")))
1618 (set_attr "prefix_rep" "0")
1619 (set (attr "prefix_data16")
1620 (if_then_else (eq_attr "mode" "DF")
1622 (const_string "0")))
1623 (set_attr "athlon_decode" "vector")
1624 (set_attr "amdfam10_decode" "direct")
1625 (set_attr "bdver1_decode" "double")])
1627 (define_insn "*cmpfp_iu_387"
1628 [(set (reg:CCFPU FLAGS_REG)
1629 (compare:CCFPU (match_operand 0 "register_operand" "f")
1630 (match_operand 1 "register_operand" "f")))]
1631 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1633 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1634 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1635 "* return output_fp_compare (insn, operands, true, true);"
1636 [(set_attr "type" "fcmp")
1638 (cond [(match_operand:SF 1 "" "")
1640 (match_operand:DF 1 "" "")
1643 (const_string "XF")))
1644 (set_attr "athlon_decode" "vector")
1645 (set_attr "amdfam10_decode" "direct")
1646 (set_attr "bdver1_decode" "direct")])
1648 ;; Push/pop instructions.
1650 (define_insn "*push<mode>2"
1651 [(set (match_operand:DWI 0 "push_operand" "=<")
1652 (match_operand:DWI 1 "general_no_elim_operand" "riF*m"))]
1657 [(set (match_operand:TI 0 "push_operand" "")
1658 (match_operand:TI 1 "general_operand" ""))]
1659 "TARGET_64BIT && reload_completed
1660 && !SSE_REG_P (operands[1])"
1662 "ix86_split_long_move (operands); DONE;")
1664 (define_insn "*pushdi2_rex64"
1665 [(set (match_operand:DI 0 "push_operand" "=<,!<")
1666 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
1671 [(set_attr "type" "push,multi")
1672 (set_attr "mode" "DI")])
1674 ;; Convert impossible pushes of immediate to existing instructions.
1675 ;; First try to get scratch register and go through it. In case this
1676 ;; fails, push sign extended lower part first and then overwrite
1677 ;; upper part by 32bit move.
1679 [(match_scratch:DI 2 "r")
1680 (set (match_operand:DI 0 "push_operand" "")
1681 (match_operand:DI 1 "immediate_operand" ""))]
1682 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1683 && !x86_64_immediate_operand (operands[1], DImode)"
1684 [(set (match_dup 2) (match_dup 1))
1685 (set (match_dup 0) (match_dup 2))])
1687 ;; We need to define this as both peepholer and splitter for case
1688 ;; peephole2 pass is not run.
1689 ;; "&& 1" is needed to keep it from matching the previous pattern.
1691 [(set (match_operand:DI 0 "push_operand" "")
1692 (match_operand:DI 1 "immediate_operand" ""))]
1693 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1694 && !x86_64_immediate_operand (operands[1], DImode) && 1"
1695 [(set (match_dup 0) (match_dup 1))
1696 (set (match_dup 2) (match_dup 3))]
1698 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1700 operands[1] = gen_lowpart (DImode, operands[2]);
1701 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1706 [(set (match_operand:DI 0 "push_operand" "")
1707 (match_operand:DI 1 "immediate_operand" ""))]
1708 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
1709 ? epilogue_completed : reload_completed)
1710 && !symbolic_operand (operands[1], DImode)
1711 && !x86_64_immediate_operand (operands[1], DImode)"
1712 [(set (match_dup 0) (match_dup 1))
1713 (set (match_dup 2) (match_dup 3))]
1715 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1717 operands[1] = gen_lowpart (DImode, operands[2]);
1718 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1723 [(set (match_operand:DI 0 "push_operand" "")
1724 (match_operand:DI 1 "general_operand" ""))]
1725 "!TARGET_64BIT && reload_completed
1726 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
1728 "ix86_split_long_move (operands); DONE;")
1730 (define_insn "*pushsi2"
1731 [(set (match_operand:SI 0 "push_operand" "=<")
1732 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1735 [(set_attr "type" "push")
1736 (set_attr "mode" "SI")])
1738 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1739 ;; "push a byte/word". But actually we use pushl, which has the effect
1740 ;; of rounding the amount pushed up to a word.
1742 ;; For TARGET_64BIT we always round up to 8 bytes.
1743 (define_insn "*push<mode>2_rex64"
1744 [(set (match_operand:SWI124 0 "push_operand" "=X")
1745 (match_operand:SWI124 1 "nonmemory_no_elim_operand" "r<i>"))]
1748 [(set_attr "type" "push")
1749 (set_attr "mode" "DI")])
1751 (define_insn "*push<mode>2"
1752 [(set (match_operand:SWI12 0 "push_operand" "=X")
1753 (match_operand:SWI12 1 "nonmemory_no_elim_operand" "rn"))]
1756 [(set_attr "type" "push")
1757 (set_attr "mode" "SI")])
1759 (define_insn "*push<mode>2_prologue"
1760 [(set (match_operand:P 0 "push_operand" "=<")
1761 (match_operand:P 1 "general_no_elim_operand" "r<i>*m"))
1762 (clobber (mem:BLK (scratch)))]
1764 "push{<imodesuffix>}\t%1"
1765 [(set_attr "type" "push")
1766 (set_attr "mode" "<MODE>")])
1768 (define_insn "*pop<mode>1"
1769 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1770 (match_operand:P 1 "pop_operand" ">"))]
1772 "pop{<imodesuffix>}\t%0"
1773 [(set_attr "type" "pop")
1774 (set_attr "mode" "<MODE>")])
1776 (define_insn "*pop<mode>1_epilogue"
1777 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1778 (match_operand:P 1 "pop_operand" ">"))
1779 (clobber (mem:BLK (scratch)))]
1781 "pop{<imodesuffix>}\t%0"
1782 [(set_attr "type" "pop")
1783 (set_attr "mode" "<MODE>")])
1785 ;; Move instructions.
1787 (define_expand "movoi"
1788 [(set (match_operand:OI 0 "nonimmediate_operand" "")
1789 (match_operand:OI 1 "general_operand" ""))]
1791 "ix86_expand_move (OImode, operands); DONE;")
1793 (define_expand "movti"
1794 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1795 (match_operand:TI 1 "nonimmediate_operand" ""))]
1796 "TARGET_64BIT || TARGET_SSE"
1799 ix86_expand_move (TImode, operands);
1800 else if (push_operand (operands[0], TImode))
1801 ix86_expand_push (TImode, operands[1]);
1803 ix86_expand_vector_move (TImode, operands);
1807 ;; This expands to what emit_move_complex would generate if we didn't
1808 ;; have a movti pattern. Having this avoids problems with reload on
1809 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
1810 ;; to have around all the time.
1811 (define_expand "movcdi"
1812 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
1813 (match_operand:CDI 1 "general_operand" ""))]
1816 if (push_operand (operands[0], CDImode))
1817 emit_move_complex_push (CDImode, operands[0], operands[1]);
1819 emit_move_complex_parts (operands[0], operands[1]);
1823 (define_expand "mov<mode>"
1824 [(set (match_operand:SWI1248x 0 "nonimmediate_operand" "")
1825 (match_operand:SWI1248x 1 "general_operand" ""))]
1827 "ix86_expand_move (<MODE>mode, operands); DONE;")
1829 (define_insn "*mov<mode>_xor"
1830 [(set (match_operand:SWI48 0 "register_operand" "=r")
1831 (match_operand:SWI48 1 "const0_operand" ""))
1832 (clobber (reg:CC FLAGS_REG))]
1835 [(set_attr "type" "alu1")
1836 (set_attr "mode" "SI")
1837 (set_attr "length_immediate" "0")])
1839 (define_insn "*mov<mode>_or"
1840 [(set (match_operand:SWI48 0 "register_operand" "=r")
1841 (match_operand:SWI48 1 "const_int_operand" ""))
1842 (clobber (reg:CC FLAGS_REG))]
1844 && operands[1] == constm1_rtx"
1845 "or{<imodesuffix>}\t{%1, %0|%0, %1}"
1846 [(set_attr "type" "alu1")
1847 (set_attr "mode" "<MODE>")
1848 (set_attr "length_immediate" "1")])
1850 (define_insn "*movoi_internal_avx"
1851 [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
1852 (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
1853 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1855 switch (which_alternative)
1858 return "vxorps\t%0, %0, %0";
1861 if (misaligned_operand (operands[0], OImode)
1862 || misaligned_operand (operands[1], OImode))
1863 return "vmovdqu\t{%1, %0|%0, %1}";
1865 return "vmovdqa\t{%1, %0|%0, %1}";
1870 [(set_attr "type" "sselog1,ssemov,ssemov")
1871 (set_attr "prefix" "vex")
1872 (set_attr "mode" "OI")])
1874 (define_insn "*movti_internal_rex64"
1875 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
1876 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
1877 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1879 switch (which_alternative)
1885 if (get_attr_mode (insn) == MODE_V4SF)
1886 return "%vxorps\t%0, %d0";
1888 return "%vpxor\t%0, %d0";
1891 /* TDmode values are passed as TImode on the stack. Moving them
1892 to stack may result in unaligned memory access. */
1893 if (misaligned_operand (operands[0], TImode)
1894 || misaligned_operand (operands[1], TImode))
1896 if (get_attr_mode (insn) == MODE_V4SF)
1897 return "%vmovups\t{%1, %0|%0, %1}";
1899 return "%vmovdqu\t{%1, %0|%0, %1}";
1903 if (get_attr_mode (insn) == MODE_V4SF)
1904 return "%vmovaps\t{%1, %0|%0, %1}";
1906 return "%vmovdqa\t{%1, %0|%0, %1}";
1912 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
1913 (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
1915 (cond [(eq_attr "alternative" "2,3")
1917 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1919 (const_string "V4SF")
1920 (const_string "TI"))
1921 (eq_attr "alternative" "4")
1923 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1925 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1927 (const_string "V4SF")
1928 (const_string "TI"))]
1929 (const_string "DI")))])
1932 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1933 (match_operand:TI 1 "general_operand" ""))]
1935 && !SSE_REG_P (operands[0]) && !SSE_REG_P (operands[1])"
1937 "ix86_split_long_move (operands); DONE;")
1939 (define_insn "*movti_internal_sse"
1940 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
1941 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
1942 "TARGET_SSE && !TARGET_64BIT
1943 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1945 switch (which_alternative)
1948 if (get_attr_mode (insn) == MODE_V4SF)
1949 return "%vxorps\t%0, %d0";
1951 return "%vpxor\t%0, %d0";
1954 /* TDmode values are passed as TImode on the stack. Moving them
1955 to stack may result in unaligned memory access. */
1956 if (misaligned_operand (operands[0], TImode)
1957 || misaligned_operand (operands[1], TImode))
1959 if (get_attr_mode (insn) == MODE_V4SF)
1960 return "%vmovups\t{%1, %0|%0, %1}";
1962 return "%vmovdqu\t{%1, %0|%0, %1}";
1966 if (get_attr_mode (insn) == MODE_V4SF)
1967 return "%vmovaps\t{%1, %0|%0, %1}";
1969 return "%vmovdqa\t{%1, %0|%0, %1}";
1975 [(set_attr "type" "sselog1,ssemov,ssemov")
1976 (set_attr "prefix" "maybe_vex")
1978 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1979 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1981 (const_string "V4SF")
1982 (and (eq_attr "alternative" "2")
1983 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1985 (const_string "V4SF")]
1986 (const_string "TI")))])
1988 (define_insn "*movdi_internal_rex64"
1989 [(set (match_operand:DI 0 "nonimmediate_operand"
1990 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
1991 (match_operand:DI 1 "general_operand"
1992 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
1993 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1995 switch (get_attr_type (insn))
1998 if (SSE_REG_P (operands[0]))
1999 return "movq2dq\t{%1, %0|%0, %1}";
2001 return "movdq2q\t{%1, %0|%0, %1}";
2004 if (get_attr_mode (insn) == MODE_TI)
2005 return "%vmovdqa\t{%1, %0|%0, %1}";
2006 /* Handle broken assemblers that require movd instead of movq. */
2007 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2008 return "%vmovd\t{%1, %0|%0, %1}";
2010 return "%vmovq\t{%1, %0|%0, %1}";
2013 /* Handle broken assemblers that require movd instead of movq. */
2014 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2015 return "movd\t{%1, %0|%0, %1}";
2017 return "movq\t{%1, %0|%0, %1}";
2020 return "%vpxor\t%0, %d0";
2023 return "pxor\t%0, %0";
2029 return "lea{q}\t{%a1, %0|%0, %a1}";
2032 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2033 if (get_attr_mode (insn) == MODE_SI)
2034 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2035 else if (which_alternative == 2)
2036 return "movabs{q}\t{%1, %0|%0, %1}";
2038 return "mov{q}\t{%1, %0|%0, %1}";
2042 (cond [(eq_attr "alternative" "5")
2043 (const_string "mmx")
2044 (eq_attr "alternative" "6,7,8,9,10")
2045 (const_string "mmxmov")
2046 (eq_attr "alternative" "11")
2047 (const_string "sselog1")
2048 (eq_attr "alternative" "12,13,14,15,16")
2049 (const_string "ssemov")
2050 (eq_attr "alternative" "17,18")
2051 (const_string "ssecvt")
2052 (eq_attr "alternative" "4")
2053 (const_string "multi")
2054 (match_operand:DI 1 "pic_32bit_operand" "")
2055 (const_string "lea")
2057 (const_string "imov")))
2060 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2062 (const_string "*")))
2063 (set (attr "length_immediate")
2065 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2067 (const_string "*")))
2068 (set_attr "prefix_rex" "*,*,*,*,*,*,*,1,*,1,*,*,*,*,*,*,*,*,*")
2069 (set_attr "prefix_data16" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,1,*,*,*")
2070 (set (attr "prefix")
2071 (if_then_else (eq_attr "alternative" "11,12,13,14,15,16")
2072 (const_string "maybe_vex")
2073 (const_string "orig")))
2074 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2076 ;; Convert impossible stores of immediate to existing instructions.
2077 ;; First try to get scratch register and go through it. In case this
2078 ;; fails, move by 32bit parts.
2080 [(match_scratch:DI 2 "r")
2081 (set (match_operand:DI 0 "memory_operand" "")
2082 (match_operand:DI 1 "immediate_operand" ""))]
2083 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2084 && !x86_64_immediate_operand (operands[1], DImode)"
2085 [(set (match_dup 2) (match_dup 1))
2086 (set (match_dup 0) (match_dup 2))])
2088 ;; We need to define this as both peepholer and splitter for case
2089 ;; peephole2 pass is not run.
2090 ;; "&& 1" is needed to keep it from matching the previous pattern.
2092 [(set (match_operand:DI 0 "memory_operand" "")
2093 (match_operand:DI 1 "immediate_operand" ""))]
2094 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2095 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2096 [(set (match_dup 2) (match_dup 3))
2097 (set (match_dup 4) (match_dup 5))]
2098 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2101 [(set (match_operand:DI 0 "memory_operand" "")
2102 (match_operand:DI 1 "immediate_operand" ""))]
2103 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2104 ? epilogue_completed : reload_completed)
2105 && !symbolic_operand (operands[1], DImode)
2106 && !x86_64_immediate_operand (operands[1], DImode)"
2107 [(set (match_dup 2) (match_dup 3))
2108 (set (match_dup 4) (match_dup 5))]
2109 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2111 (define_insn "*movdi_internal"
2112 [(set (match_operand:DI 0 "nonimmediate_operand"
2113 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2114 (match_operand:DI 1 "general_operand"
2115 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2116 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2121 movq\t{%1, %0|%0, %1}
2122 movq\t{%1, %0|%0, %1}
2124 %vmovq\t{%1, %0|%0, %1}
2125 %vmovdqa\t{%1, %0|%0, %1}
2126 %vmovq\t{%1, %0|%0, %1}
2128 movlps\t{%1, %0|%0, %1}
2129 movaps\t{%1, %0|%0, %1}
2130 movlps\t{%1, %0|%0, %1}"
2132 (if_then_else (eq_attr "alternative" "9,10,11,12")
2133 (const_string "noavx")
2134 (const_string "base")))
2135 (set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2136 (set (attr "prefix")
2137 (if_then_else (eq_attr "alternative" "5,6,7,8")
2138 (const_string "maybe_vex")
2139 (const_string "orig")))
2140 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2143 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2144 (match_operand:DI 1 "general_operand" ""))]
2145 "!TARGET_64BIT && reload_completed
2146 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))
2147 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
2149 "ix86_split_long_move (operands); DONE;")
2151 (define_insn "*movsi_internal"
2152 [(set (match_operand:SI 0 "nonimmediate_operand"
2153 "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
2154 (match_operand:SI 1 "general_operand"
2155 "g ,ri,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
2156 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2158 switch (get_attr_type (insn))
2161 if (get_attr_mode (insn) == MODE_TI)
2162 return "%vpxor\t%0, %d0";
2163 return "%vxorps\t%0, %d0";
2166 switch (get_attr_mode (insn))
2169 return "%vmovdqa\t{%1, %0|%0, %1}";
2171 return "%vmovaps\t{%1, %0|%0, %1}";
2173 return "%vmovd\t{%1, %0|%0, %1}";
2175 return "%vmovss\t{%1, %0|%0, %1}";
2181 return "pxor\t%0, %0";
2184 if (get_attr_mode (insn) == MODE_DI)
2185 return "movq\t{%1, %0|%0, %1}";
2186 return "movd\t{%1, %0|%0, %1}";
2189 return "lea{l}\t{%a1, %0|%0, %a1}";
2192 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2193 return "mov{l}\t{%1, %0|%0, %1}";
2197 (cond [(eq_attr "alternative" "2")
2198 (const_string "mmx")
2199 (eq_attr "alternative" "3,4,5")
2200 (const_string "mmxmov")
2201 (eq_attr "alternative" "6")
2202 (const_string "sselog1")
2203 (eq_attr "alternative" "7,8,9,10,11")
2204 (const_string "ssemov")
2205 (match_operand:DI 1 "pic_32bit_operand" "")
2206 (const_string "lea")
2208 (const_string "imov")))
2209 (set (attr "prefix")
2210 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
2211 (const_string "orig")
2212 (const_string "maybe_vex")))
2213 (set (attr "prefix_data16")
2214 (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
2216 (const_string "*")))
2218 (cond [(eq_attr "alternative" "2,3")
2220 (eq_attr "alternative" "6,7")
2222 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2223 (const_string "V4SF")
2224 (const_string "TI"))
2225 (and (eq_attr "alternative" "8,9,10,11")
2226 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
2229 (const_string "SI")))])
2231 (define_insn "*movhi_internal"
2232 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
2233 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
2234 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2236 switch (get_attr_type (insn))
2239 /* movzwl is faster than movw on p2 due to partial word stalls,
2240 though not as fast as an aligned movl. */
2241 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
2243 if (get_attr_mode (insn) == MODE_SI)
2244 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2246 return "mov{w}\t{%1, %0|%0, %1}";
2250 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
2252 (const_string "imov")
2253 (and (eq_attr "alternative" "0")
2254 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2256 (eq (symbol_ref "TARGET_HIMODE_MATH")
2258 (const_string "imov")
2259 (and (eq_attr "alternative" "1,2")
2260 (match_operand:HI 1 "aligned_operand" ""))
2261 (const_string "imov")
2262 (and (ne (symbol_ref "TARGET_MOVX")
2264 (eq_attr "alternative" "0,2"))
2265 (const_string "imovx")
2267 (const_string "imov")))
2269 (cond [(eq_attr "type" "imovx")
2271 (and (eq_attr "alternative" "1,2")
2272 (match_operand:HI 1 "aligned_operand" ""))
2274 (and (eq_attr "alternative" "0")
2275 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2277 (eq (symbol_ref "TARGET_HIMODE_MATH")
2281 (const_string "HI")))])
2283 ;; Situation is quite tricky about when to choose full sized (SImode) move
2284 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
2285 ;; partial register dependency machines (such as AMD Athlon), where QImode
2286 ;; moves issue extra dependency and for partial register stalls machines
2287 ;; that don't use QImode patterns (and QImode move cause stall on the next
2290 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2291 ;; register stall machines with, where we use QImode instructions, since
2292 ;; partial register stall can be caused there. Then we use movzx.
2293 (define_insn "*movqi_internal"
2294 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2295 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
2296 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2298 switch (get_attr_type (insn))
2301 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2302 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2304 if (get_attr_mode (insn) == MODE_SI)
2305 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2307 return "mov{b}\t{%1, %0|%0, %1}";
2311 (cond [(and (eq_attr "alternative" "5")
2312 (not (match_operand:QI 1 "aligned_operand" "")))
2313 (const_string "imovx")
2314 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2316 (const_string "imov")
2317 (and (eq_attr "alternative" "3")
2318 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2320 (eq (symbol_ref "TARGET_QIMODE_MATH")
2322 (const_string "imov")
2323 (eq_attr "alternative" "3,5")
2324 (const_string "imovx")
2325 (and (ne (symbol_ref "TARGET_MOVX")
2327 (eq_attr "alternative" "2"))
2328 (const_string "imovx")
2330 (const_string "imov")))
2332 (cond [(eq_attr "alternative" "3,4,5")
2334 (eq_attr "alternative" "6")
2336 (eq_attr "type" "imovx")
2338 (and (eq_attr "type" "imov")
2339 (and (eq_attr "alternative" "0,1")
2340 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2342 (and (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2344 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2347 ;; Avoid partial register stalls when not using QImode arithmetic
2348 (and (eq_attr "type" "imov")
2349 (and (eq_attr "alternative" "0,1")
2350 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2352 (eq (symbol_ref "TARGET_QIMODE_MATH")
2356 (const_string "QI")))])
2358 ;; Stores and loads of ax to arbitrary constant address.
2359 ;; We fake an second form of instruction to force reload to load address
2360 ;; into register when rax is not available
2361 (define_insn "*movabs<mode>_1"
2362 [(set (mem:SWI1248x (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2363 (match_operand:SWI1248x 1 "nonmemory_operand" "a,er"))]
2364 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2366 movabs{<imodesuffix>}\t{%1, %P0|%P0, %1}
2367 mov{<imodesuffix>}\t{%1, %a0|%a0, %1}"
2368 [(set_attr "type" "imov")
2369 (set_attr "modrm" "0,*")
2370 (set_attr "length_address" "8,0")
2371 (set_attr "length_immediate" "0,*")
2372 (set_attr "memory" "store")
2373 (set_attr "mode" "<MODE>")])
2375 (define_insn "*movabs<mode>_2"
2376 [(set (match_operand:SWI1248x 0 "register_operand" "=a,r")
2377 (mem:SWI1248x (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2378 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2380 movabs{<imodesuffix>}\t{%P1, %0|%0, %P1}
2381 mov{<imodesuffix>}\t{%a1, %0|%0, %a1}"
2382 [(set_attr "type" "imov")
2383 (set_attr "modrm" "0,*")
2384 (set_attr "length_address" "8,0")
2385 (set_attr "length_immediate" "0")
2386 (set_attr "memory" "load")
2387 (set_attr "mode" "<MODE>")])
2389 (define_insn "*swap<mode>"
2390 [(set (match_operand:SWI48 0 "register_operand" "+r")
2391 (match_operand:SWI48 1 "register_operand" "+r"))
2395 "xchg{<imodesuffix>}\t%1, %0"
2396 [(set_attr "type" "imov")
2397 (set_attr "mode" "<MODE>")
2398 (set_attr "pent_pair" "np")
2399 (set_attr "athlon_decode" "vector")
2400 (set_attr "amdfam10_decode" "double")
2401 (set_attr "bdver1_decode" "double")])
2403 (define_insn "*swap<mode>_1"
2404 [(set (match_operand:SWI12 0 "register_operand" "+r")
2405 (match_operand:SWI12 1 "register_operand" "+r"))
2408 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2410 [(set_attr "type" "imov")
2411 (set_attr "mode" "SI")
2412 (set_attr "pent_pair" "np")
2413 (set_attr "athlon_decode" "vector")
2414 (set_attr "amdfam10_decode" "double")
2415 (set_attr "bdver1_decode" "double")])
2417 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL
2418 ;; is disabled for AMDFAM10
2419 (define_insn "*swap<mode>_2"
2420 [(set (match_operand:SWI12 0 "register_operand" "+<r>")
2421 (match_operand:SWI12 1 "register_operand" "+<r>"))
2424 "TARGET_PARTIAL_REG_STALL"
2425 "xchg{<imodesuffix>}\t%1, %0"
2426 [(set_attr "type" "imov")
2427 (set_attr "mode" "<MODE>")
2428 (set_attr "pent_pair" "np")
2429 (set_attr "athlon_decode" "vector")])
2431 (define_expand "movstrict<mode>"
2432 [(set (strict_low_part (match_operand:SWI12 0 "nonimmediate_operand" ""))
2433 (match_operand:SWI12 1 "general_operand" ""))]
2436 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2438 if (GET_CODE (operands[0]) == SUBREG
2439 && GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[0]))) != MODE_INT)
2441 /* Don't generate memory->memory moves, go through a register */
2442 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2443 operands[1] = force_reg (<MODE>mode, operands[1]);
2446 (define_insn "*movstrict<mode>_1"
2447 [(set (strict_low_part
2448 (match_operand:SWI12 0 "nonimmediate_operand" "+<r>m,<r>"))
2449 (match_operand:SWI12 1 "general_operand" "<r>n,m"))]
2450 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2451 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2452 "mov{<imodesuffix>}\t{%1, %0|%0, %1}"
2453 [(set_attr "type" "imov")
2454 (set_attr "mode" "<MODE>")])
2456 (define_insn "*movstrict<mode>_xor"
2457 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
2458 (match_operand:SWI12 1 "const0_operand" ""))
2459 (clobber (reg:CC FLAGS_REG))]
2461 "xor{<imodesuffix>}\t%0, %0"
2462 [(set_attr "type" "alu1")
2463 (set_attr "mode" "<MODE>")
2464 (set_attr "length_immediate" "0")])
2466 (define_insn "*mov<mode>_extv_1"
2467 [(set (match_operand:SWI24 0 "register_operand" "=R")
2468 (sign_extract:SWI24 (match_operand 1 "ext_register_operand" "Q")
2472 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2473 [(set_attr "type" "imovx")
2474 (set_attr "mode" "SI")])
2476 (define_insn "*movqi_extv_1_rex64"
2477 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2478 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2483 switch (get_attr_type (insn))
2486 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2488 return "mov{b}\t{%h1, %0|%0, %h1}";
2492 (if_then_else (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2493 (ne (symbol_ref "TARGET_MOVX")
2495 (const_string "imovx")
2496 (const_string "imov")))
2498 (if_then_else (eq_attr "type" "imovx")
2500 (const_string "QI")))])
2502 (define_insn "*movqi_extv_1"
2503 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2504 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2509 switch (get_attr_type (insn))
2512 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2514 return "mov{b}\t{%h1, %0|%0, %h1}";
2518 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2519 (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2520 (ne (symbol_ref "TARGET_MOVX")
2522 (const_string "imovx")
2523 (const_string "imov")))
2525 (if_then_else (eq_attr "type" "imovx")
2527 (const_string "QI")))])
2529 (define_insn "*mov<mode>_extzv_1"
2530 [(set (match_operand:SWI48 0 "register_operand" "=R")
2531 (zero_extract:SWI48 (match_operand 1 "ext_register_operand" "Q")
2535 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2536 [(set_attr "type" "imovx")
2537 (set_attr "mode" "SI")])
2539 (define_insn "*movqi_extzv_2_rex64"
2540 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2542 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2547 switch (get_attr_type (insn))
2550 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2552 return "mov{b}\t{%h1, %0|%0, %h1}";
2556 (if_then_else (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2557 (ne (symbol_ref "TARGET_MOVX")
2559 (const_string "imovx")
2560 (const_string "imov")))
2562 (if_then_else (eq_attr "type" "imovx")
2564 (const_string "QI")))])
2566 (define_insn "*movqi_extzv_2"
2567 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2569 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2574 switch (get_attr_type (insn))
2577 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2579 return "mov{b}\t{%h1, %0|%0, %h1}";
2583 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2584 (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2585 (ne (symbol_ref "TARGET_MOVX")
2587 (const_string "imovx")
2588 (const_string "imov")))
2590 (if_then_else (eq_attr "type" "imovx")
2592 (const_string "QI")))])
2594 (define_expand "mov<mode>_insv_1"
2595 [(set (zero_extract:SWI48 (match_operand 0 "ext_register_operand" "")
2598 (match_operand:SWI48 1 "nonmemory_operand" ""))])
2600 (define_insn "*mov<mode>_insv_1_rex64"
2601 [(set (zero_extract:SWI48x (match_operand 0 "ext_register_operand" "+Q")
2604 (match_operand:SWI48x 1 "nonmemory_operand" "Qn"))]
2606 "mov{b}\t{%b1, %h0|%h0, %b1}"
2607 [(set_attr "type" "imov")
2608 (set_attr "mode" "QI")])
2610 (define_insn "*movsi_insv_1"
2611 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2614 (match_operand:SI 1 "general_operand" "Qmn"))]
2616 "mov{b}\t{%b1, %h0|%h0, %b1}"
2617 [(set_attr "type" "imov")
2618 (set_attr "mode" "QI")])
2620 (define_insn "*movqi_insv_2"
2621 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2624 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2627 "mov{b}\t{%h1, %h0|%h0, %h1}"
2628 [(set_attr "type" "imov")
2629 (set_attr "mode" "QI")])
2631 ;; Floating point push instructions.
2633 (define_insn "*pushtf"
2634 [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2635 (match_operand:TF 1 "general_no_elim_operand" "x,Fo,*r"))]
2638 /* This insn should be already split before reg-stack. */
2641 [(set_attr "type" "multi")
2642 (set_attr "unit" "sse,*,*")
2643 (set_attr "mode" "TF,SI,SI")])
2646 [(set (match_operand:TF 0 "push_operand" "")
2647 (match_operand:TF 1 "sse_reg_operand" ""))]
2648 "TARGET_SSE2 && reload_completed"
2649 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
2650 (set (mem:TF (reg:P SP_REG)) (match_dup 1))])
2653 [(set (match_operand:TF 0 "push_operand" "")
2654 (match_operand:TF 1 "general_operand" ""))]
2655 "TARGET_SSE2 && reload_completed
2656 && !SSE_REG_P (operands[1])"
2658 "ix86_split_long_move (operands); DONE;")
2660 (define_insn "*pushxf"
2661 [(set (match_operand:XF 0 "push_operand" "=<,<")
2662 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
2663 "optimize_function_for_speed_p (cfun)"
2665 /* This insn should be already split before reg-stack. */
2668 [(set_attr "type" "multi")
2669 (set_attr "unit" "i387,*")
2670 (set_attr "mode" "XF,SI")])
2672 ;; Size of pushxf is 3 (for sub) + 2 (for fstp) + memory operand size.
2673 ;; Size of pushxf using integer instructions is 3+3*memory operand size
2674 ;; Pushing using integer instructions is longer except for constants
2675 ;; and direct memory references (assuming that any given constant is pushed
2676 ;; only once, but this ought to be handled elsewhere).
2678 (define_insn "*pushxf_nointeger"
2679 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
2680 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
2681 "optimize_function_for_size_p (cfun)"
2683 /* This insn should be already split before reg-stack. */
2686 [(set_attr "type" "multi")
2687 (set_attr "unit" "i387,*,*")
2688 (set_attr "mode" "XF,SI,SI")])
2691 [(set (match_operand:XF 0 "push_operand" "")
2692 (match_operand:XF 1 "fp_register_operand" ""))]
2694 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2695 (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
2696 "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
2699 [(set (match_operand:XF 0 "push_operand" "")
2700 (match_operand:XF 1 "general_operand" ""))]
2702 && !FP_REG_P (operands[1])"
2704 "ix86_split_long_move (operands); DONE;")
2706 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2707 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2708 ;; On the average, pushdf using integers can be still shorter.
2710 (define_insn "*pushdf"
2711 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2712 (match_operand:DF 1 "general_no_elim_operand" "f,Yd*rFo,Y2"))]
2715 /* This insn should be already split before reg-stack. */
2718 [(set_attr "type" "multi")
2719 (set_attr "unit" "i387,*,*")
2720 (set_attr "mode" "DF,SI,DF")])
2722 ;; %%% Kill this when call knows how to work this out.
2724 [(set (match_operand:DF 0 "push_operand" "")
2725 (match_operand:DF 1 "any_fp_register_operand" ""))]
2727 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
2728 (set (mem:DF (reg:P SP_REG)) (match_dup 1))])
2731 [(set (match_operand:DF 0 "push_operand" "")
2732 (match_operand:DF 1 "general_operand" ""))]
2734 && !ANY_FP_REG_P (operands[1])"
2736 "ix86_split_long_move (operands); DONE;")
2738 (define_insn "*pushsf_rex64"
2739 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2740 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2743 /* Anything else should be already split before reg-stack. */
2744 gcc_assert (which_alternative == 1);
2745 return "push{q}\t%q1";
2747 [(set_attr "type" "multi,push,multi")
2748 (set_attr "unit" "i387,*,*")
2749 (set_attr "mode" "SF,DI,SF")])
2751 (define_insn "*pushsf"
2752 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2753 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2756 /* Anything else should be already split before reg-stack. */
2757 gcc_assert (which_alternative == 1);
2758 return "push{l}\t%1";
2760 [(set_attr "type" "multi,push,multi")
2761 (set_attr "unit" "i387,*,*")
2762 (set_attr "mode" "SF,SI,SF")])
2765 [(set (match_operand:SF 0 "push_operand" "")
2766 (match_operand:SF 1 "memory_operand" ""))]
2768 && MEM_P (operands[1])
2769 && (operands[2] = find_constant_src (insn))"
2773 ;; %%% Kill this when call knows how to work this out.
2775 [(set (match_operand:SF 0 "push_operand" "")
2776 (match_operand:SF 1 "any_fp_register_operand" ""))]
2778 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2779 (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
2780 "operands[2] = GEN_INT (-GET_MODE_SIZE (<MODE>mode));")
2782 ;; Floating point move instructions.
2784 (define_expand "movtf"
2785 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2786 (match_operand:TF 1 "nonimmediate_operand" ""))]
2789 ix86_expand_move (TFmode, operands);
2793 (define_expand "mov<mode>"
2794 [(set (match_operand:X87MODEF 0 "nonimmediate_operand" "")
2795 (match_operand:X87MODEF 1 "general_operand" ""))]
2797 "ix86_expand_move (<MODE>mode, operands); DONE;")
2799 (define_insn "*movtf_internal"
2800 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?r,?o")
2801 (match_operand:TF 1 "general_operand" "xm,x,C,roF,Fr"))]
2803 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2805 switch (which_alternative)
2809 if (get_attr_mode (insn) == MODE_V4SF)
2810 return "%vmovaps\t{%1, %0|%0, %1}";
2812 return "%vmovdqa\t{%1, %0|%0, %1}";
2815 return standard_sse_constant_opcode (insn, operands[1]);
2825 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
2826 (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,*,*")
2828 (cond [(eq_attr "alternative" "0,2")
2830 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2832 (const_string "V4SF")
2833 (const_string "TI"))
2834 (eq_attr "alternative" "1")
2836 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2838 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2840 (const_string "V4SF")
2841 (const_string "TI"))]
2842 (const_string "DI")))])
2845 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2846 (match_operand:TF 1 "general_operand" ""))]
2848 && !(SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]))"
2850 "ix86_split_long_move (operands); DONE;")
2852 (define_insn "*movxf_internal"
2853 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,Yx*r ,o")
2854 (match_operand:XF 1 "general_operand" "fm,f,G,Yx*roF,FYx*r"))]
2855 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2856 && (!can_create_pseudo_p ()
2857 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2858 || GET_CODE (operands[1]) != CONST_DOUBLE
2859 || (optimize_function_for_size_p (cfun)
2860 && standard_80387_constant_p (operands[1]) > 0)
2861 || memory_operand (operands[0], XFmode))"
2863 switch (which_alternative)
2867 return output_387_reg_move (insn, operands);
2870 return standard_80387_constant_opcode (operands[1]);
2878 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2879 (set_attr "mode" "XF,XF,XF,SI,SI")])
2882 [(set (match_operand:XF 0 "nonimmediate_operand" "")
2883 (match_operand:XF 1 "general_operand" ""))]
2885 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2886 && ! (FP_REG_P (operands[0]) ||
2887 (GET_CODE (operands[0]) == SUBREG
2888 && FP_REG_P (SUBREG_REG (operands[0]))))
2889 && ! (FP_REG_P (operands[1]) ||
2890 (GET_CODE (operands[1]) == SUBREG
2891 && FP_REG_P (SUBREG_REG (operands[1]))))"
2893 "ix86_split_long_move (operands); DONE;")
2895 (define_insn "*movdf_internal_rex64"
2896 [(set (match_operand:DF 0 "nonimmediate_operand"
2897 "=f,m,f,r ,m,!r,!m,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
2898 (match_operand:DF 1 "general_operand"
2899 "fm,f,G,rm,r,F ,F ,C ,Y2*x,m ,Y2*x,r ,Yi"))]
2900 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2901 && (!can_create_pseudo_p ()
2902 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2903 || GET_CODE (operands[1]) != CONST_DOUBLE
2904 || (optimize_function_for_size_p (cfun)
2905 && ((!(TARGET_SSE2 && TARGET_SSE_MATH)
2906 && standard_80387_constant_p (operands[1]) > 0)
2907 || (TARGET_SSE2 && TARGET_SSE_MATH
2908 && standard_sse_constant_p (operands[1]))))
2909 || memory_operand (operands[0], DFmode))"
2911 switch (which_alternative)
2915 return output_387_reg_move (insn, operands);
2918 return standard_80387_constant_opcode (operands[1]);
2922 return "mov{q}\t{%1, %0|%0, %1}";
2925 return "movabs{q}\t{%1, %0|%0, %1}";
2931 return standard_sse_constant_opcode (insn, operands[1]);
2936 switch (get_attr_mode (insn))
2939 return "%vmovaps\t{%1, %0|%0, %1}";
2941 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2942 return "%vmovaps\t{%1, %0|%0, %1}";
2944 return "%vmovapd\t{%1, %0|%0, %1}";
2946 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2947 return "%vmovaps\t{%1, %0|%0, %1}";
2949 return "%vmovdqa\t{%1, %0|%0, %1}";
2951 return "%vmovq\t{%1, %0|%0, %1}";
2953 if (TARGET_AVX && REG_P (operands[0]) && REG_P (operands[1]))
2954 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
2956 return "%vmovsd\t{%1, %0|%0, %1}";
2958 return "%vmovlpd\t{%1, %d0|%d0, %1}";
2960 return "%vmovlps\t{%1, %d0|%d0, %1}";
2967 /* Handle broken assemblers that require movd instead of movq. */
2968 return "%vmovd\t{%1, %0|%0, %1}";
2974 [(set_attr "type" "fmov,fmov,fmov,imov,imov,imov,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
2977 (and (eq_attr "alternative" "5") (eq_attr "type" "imov"))
2979 (const_string "*")))
2980 (set (attr "length_immediate")
2982 (and (eq_attr "alternative" "5") (eq_attr "type" "imov"))
2984 (const_string "*")))
2985 (set (attr "prefix")
2986 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5,6")
2987 (const_string "orig")
2988 (const_string "maybe_vex")))
2989 (set (attr "prefix_data16")
2990 (if_then_else (eq_attr "mode" "V1DF")
2992 (const_string "*")))
2994 (cond [(eq_attr "alternative" "0,1,2")
2996 (eq_attr "alternative" "3,4,5,6,11,12")
2999 /* For SSE1, we have many fewer alternatives. */
3000 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3001 (cond [(eq_attr "alternative" "7,8")
3002 (const_string "V4SF")
3004 (const_string "V2SF"))
3006 /* xorps is one byte shorter. */
3007 (eq_attr "alternative" "7")
3008 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3010 (const_string "V4SF")
3011 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3015 (const_string "V2DF"))
3017 /* For architectures resolving dependencies on
3018 whole SSE registers use APD move to break dependency
3019 chains, otherwise use short move to avoid extra work.
3021 movaps encodes one byte shorter. */
3022 (eq_attr "alternative" "8")
3024 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3026 (const_string "V4SF")
3027 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3029 (const_string "V2DF")
3031 (const_string "DF"))
3032 /* For architectures resolving dependencies on register
3033 parts we may avoid extra work to zero out upper part
3035 (eq_attr "alternative" "9")
3037 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3039 (const_string "V1DF")
3040 (const_string "DF"))
3042 (const_string "DF")))])
3044 ;; Possible store forwarding (partial memory) stall in alternative 4.
3045 (define_insn "*movdf_internal"
3046 [(set (match_operand:DF 0 "nonimmediate_operand"
3047 "=f,m,f,Yd*r ,o ,Y2*x,Y2*x,Y2*x,m ")
3048 (match_operand:DF 1 "general_operand"
3049 "fm,f,G,Yd*roF,FYd*r,C ,Y2*x,m ,Y2*x"))]
3050 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3051 && (!can_create_pseudo_p ()
3052 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3053 || GET_CODE (operands[1]) != CONST_DOUBLE
3054 || (!TARGET_INTEGER_DFMODE_MOVES
3055 && ((!(TARGET_SSE2 && TARGET_SSE_MATH)
3056 && standard_80387_constant_p (operands[1]) > 0)
3057 || (TARGET_SSE2 && TARGET_SSE_MATH
3058 && standard_sse_constant_p (operands[1])))
3059 && !memory_operand (operands[0], DFmode))
3060 || ((TARGET_INTEGER_DFMODE_MOVES
3061 || !TARGET_MEMORY_MISMATCH_STALL)
3062 && memory_operand (operands[0], DFmode)))"
3064 switch (which_alternative)
3068 return output_387_reg_move (insn, operands);
3071 return standard_80387_constant_opcode (operands[1]);
3078 return standard_sse_constant_opcode (insn, operands[1]);
3083 switch (get_attr_mode (insn))
3086 return "%vmovaps\t{%1, %0|%0, %1}";
3088 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3089 return "%vmovaps\t{%1, %0|%0, %1}";
3091 return "%vmovapd\t{%1, %0|%0, %1}";
3093 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3094 return "%vmovaps\t{%1, %0|%0, %1}";
3096 return "%vmovdqa\t{%1, %0|%0, %1}";
3098 return "%vmovq\t{%1, %0|%0, %1}";
3100 if (TARGET_AVX && REG_P (operands[0]) && REG_P (operands[1]))
3101 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3103 return "%vmovsd\t{%1, %0|%0, %1}";
3105 if (TARGET_AVX && REG_P (operands[0]))
3106 return "vmovlpd\t{%1, %0, %0|%0, %0, %1}";
3108 return "%vmovlpd\t{%1, %0|%0, %1}";
3110 if (TARGET_AVX && REG_P (operands[0]))
3111 return "vmovlps\t{%1, %0, %0|%0, %0, %1}";
3113 return "%vmovlps\t{%1, %0|%0, %1}";
3122 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3123 (set (attr "prefix")
3124 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3125 (const_string "orig")
3126 (const_string "maybe_vex")))
3127 (set (attr "prefix_data16")
3128 (if_then_else (eq_attr "mode" "V1DF")
3130 (const_string "*")))
3132 (cond [(eq_attr "alternative" "0,1,2")
3134 (eq_attr "alternative" "3,4")
3137 /* For SSE1, we have many fewer alternatives. */
3138 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3139 (cond [(eq_attr "alternative" "5,6")
3140 (const_string "V4SF")
3142 (const_string "V2SF"))
3144 /* xorps is one byte shorter. */
3145 (eq_attr "alternative" "5")
3146 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3148 (const_string "V4SF")
3149 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3153 (const_string "V2DF"))
3155 /* For architectures resolving dependencies on
3156 whole SSE registers use APD move to break dependency
3157 chains, otherwise use short move to avoid extra work.
3159 movaps encodes one byte shorter. */
3160 (eq_attr "alternative" "6")
3162 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3164 (const_string "V4SF")
3165 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3167 (const_string "V2DF")
3169 (const_string "DF"))
3170 /* For architectures resolving dependencies on register
3171 parts we may avoid extra work to zero out upper part
3173 (eq_attr "alternative" "7")
3175 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3177 (const_string "V1DF")
3178 (const_string "DF"))
3180 (const_string "DF")))])
3183 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3184 (match_operand:DF 1 "general_operand" ""))]
3186 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3187 && ! (ANY_FP_REG_P (operands[0]) ||
3188 (GET_CODE (operands[0]) == SUBREG
3189 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3190 && ! (ANY_FP_REG_P (operands[1]) ||
3191 (GET_CODE (operands[1]) == SUBREG
3192 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3194 "ix86_split_long_move (operands); DONE;")
3196 (define_insn "*movsf_internal"
3197 [(set (match_operand:SF 0 "nonimmediate_operand"
3198 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
3199 (match_operand:SF 1 "general_operand"
3200 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
3201 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3202 && (!can_create_pseudo_p ()
3203 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3204 || GET_CODE (operands[1]) != CONST_DOUBLE
3205 || (optimize_function_for_size_p (cfun)
3206 && ((!TARGET_SSE_MATH
3207 && standard_80387_constant_p (operands[1]) > 0)
3209 && standard_sse_constant_p (operands[1]))))
3210 || memory_operand (operands[0], SFmode))"
3212 switch (which_alternative)
3216 return output_387_reg_move (insn, operands);
3219 return standard_80387_constant_opcode (operands[1]);
3223 return "mov{l}\t{%1, %0|%0, %1}";
3226 return standard_sse_constant_opcode (insn, operands[1]);
3229 if (get_attr_mode (insn) == MODE_V4SF)
3230 return "%vmovaps\t{%1, %0|%0, %1}";
3232 return "%vmovss\t{%1, %d0|%d0, %1}";
3234 if (TARGET_AVX && REG_P (operands[1]))
3235 return "vmovss\t{%1, %0, %0|%0, %0, %1}";
3237 return "%vmovss\t{%1, %0|%0, %1}";
3239 return "%vmovss\t{%1, %0|%0, %1}";
3241 case 9: case 10: case 14: case 15:
3242 return "movd\t{%1, %0|%0, %1}";
3245 return "movq\t{%1, %0|%0, %1}";
3248 return "%vmovd\t{%1, %0|%0, %1}";
3254 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
3255 (set (attr "prefix")
3256 (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
3257 (const_string "maybe_vex")
3258 (const_string "orig")))
3260 (cond [(eq_attr "alternative" "3,4,9,10")
3262 (eq_attr "alternative" "5")
3264 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3266 (ne (symbol_ref "TARGET_SSE2")
3268 (eq (symbol_ref "optimize_function_for_size_p (cfun)")
3271 (const_string "V4SF"))
3272 /* For architectures resolving dependencies on
3273 whole SSE registers use APS move to break dependency
3274 chains, otherwise use short move to avoid extra work.
3276 Do the same for architectures resolving dependencies on
3277 the parts. While in DF mode it is better to always handle
3278 just register parts, the SF mode is different due to lack
3279 of instructions to load just part of the register. It is
3280 better to maintain the whole registers in single format
3281 to avoid problems on using packed logical operations. */
3282 (eq_attr "alternative" "6")
3284 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3286 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3288 (const_string "V4SF")
3289 (const_string "SF"))
3290 (eq_attr "alternative" "11")
3291 (const_string "DI")]
3292 (const_string "SF")))])
3295 [(set (match_operand 0 "register_operand" "")
3296 (match_operand 1 "memory_operand" ""))]
3298 && MEM_P (operands[1])
3299 && (GET_MODE (operands[0]) == TFmode
3300 || GET_MODE (operands[0]) == XFmode
3301 || GET_MODE (operands[0]) == DFmode
3302 || GET_MODE (operands[0]) == SFmode)
3303 && (operands[2] = find_constant_src (insn))"
3304 [(set (match_dup 0) (match_dup 2))]
3306 rtx c = operands[2];
3307 rtx r = operands[0];
3309 if (GET_CODE (r) == SUBREG)
3314 if (!standard_sse_constant_p (c))
3317 else if (FP_REG_P (r))
3319 if (standard_80387_constant_p (c) < 1)
3322 else if (MMX_REG_P (r))
3327 [(set (match_operand 0 "register_operand" "")
3328 (float_extend (match_operand 1 "memory_operand" "")))]
3330 && MEM_P (operands[1])
3331 && (GET_MODE (operands[0]) == TFmode
3332 || GET_MODE (operands[0]) == XFmode
3333 || GET_MODE (operands[0]) == DFmode
3334 || GET_MODE (operands[0]) == SFmode)
3335 && (operands[2] = find_constant_src (insn))"
3336 [(set (match_dup 0) (match_dup 2))]
3338 rtx c = operands[2];
3339 rtx r = operands[0];
3341 if (GET_CODE (r) == SUBREG)
3346 if (!standard_sse_constant_p (c))
3349 else if (FP_REG_P (r))
3351 if (standard_80387_constant_p (c) < 1)
3354 else if (MMX_REG_P (r))
3358 ;; Split the load of -0.0 or -1.0 into fldz;fchs or fld1;fchs sequence
3360 [(set (match_operand:X87MODEF 0 "register_operand" "")
3361 (match_operand:X87MODEF 1 "immediate_operand" ""))]
3362 "reload_completed && FP_REGNO_P (REGNO (operands[0]))
3363 && (standard_80387_constant_p (operands[1]) == 8
3364 || standard_80387_constant_p (operands[1]) == 9)"
3365 [(set (match_dup 0)(match_dup 1))
3367 (neg:X87MODEF (match_dup 0)))]
3371 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
3372 if (real_isnegzero (&r))
3373 operands[1] = CONST0_RTX (<MODE>mode);
3375 operands[1] = CONST1_RTX (<MODE>mode);
3378 (define_insn "swapxf"
3379 [(set (match_operand:XF 0 "register_operand" "+f")
3380 (match_operand:XF 1 "register_operand" "+f"))
3385 if (STACK_TOP_P (operands[0]))
3390 [(set_attr "type" "fxch")
3391 (set_attr "mode" "XF")])
3393 (define_insn "*swap<mode>"
3394 [(set (match_operand:MODEF 0 "fp_register_operand" "+f")
3395 (match_operand:MODEF 1 "fp_register_operand" "+f"))
3398 "TARGET_80387 || reload_completed"
3400 if (STACK_TOP_P (operands[0]))
3405 [(set_attr "type" "fxch")
3406 (set_attr "mode" "<MODE>")])
3408 ;; Zero extension instructions
3410 (define_expand "zero_extendsidi2"
3411 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3412 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3417 emit_insn (gen_zero_extendsidi2_1 (operands[0], operands[1]));
3422 (define_insn "*zero_extendsidi2_rex64"
3423 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,?*Ym,?*y,?*Yi,*Y2")
3425 (match_operand:SI 1 "nonimmediate_operand" "rm,0,r ,m ,r ,m")))]
3428 mov\t{%k1, %k0|%k0, %k1}
3430 movd\t{%1, %0|%0, %1}
3431 movd\t{%1, %0|%0, %1}
3432 %vmovd\t{%1, %0|%0, %1}
3433 %vmovd\t{%1, %0|%0, %1}"
3434 [(set_attr "type" "imovx,imov,mmxmov,mmxmov,ssemov,ssemov")
3435 (set_attr "prefix" "orig,*,orig,orig,maybe_vex,maybe_vex")
3436 (set_attr "prefix_0f" "0,*,*,*,*,*")
3437 (set_attr "mode" "SI,DI,DI,DI,TI,TI")])
3440 [(set (match_operand:DI 0 "memory_operand" "")
3441 (zero_extend:DI (match_dup 0)))]
3443 [(set (match_dup 4) (const_int 0))]
3444 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3446 ;; %%% Kill me once multi-word ops are sane.
3447 (define_insn "zero_extendsidi2_1"
3448 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?o,?*Ym,?*y,?*Yi,*Y2")
3450 (match_operand:SI 1 "nonimmediate_operand" "0,rm,r ,r ,m ,r ,m")))
3451 (clobber (reg:CC FLAGS_REG))]
3457 movd\t{%1, %0|%0, %1}
3458 movd\t{%1, %0|%0, %1}
3459 %vmovd\t{%1, %0|%0, %1}
3460 %vmovd\t{%1, %0|%0, %1}"
3461 [(set_attr "type" "multi,multi,multi,mmxmov,mmxmov,ssemov,ssemov")
3462 (set_attr "prefix" "*,*,*,orig,orig,maybe_vex,maybe_vex")
3463 (set_attr "mode" "SI,SI,SI,DI,DI,TI,TI")])
3466 [(set (match_operand:DI 0 "register_operand" "")
3467 (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3468 (clobber (reg:CC FLAGS_REG))]
3469 "!TARGET_64BIT && reload_completed
3470 && true_regnum (operands[0]) == true_regnum (operands[1])"
3471 [(set (match_dup 4) (const_int 0))]
3472 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3475 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3476 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3477 (clobber (reg:CC FLAGS_REG))]
3478 "!TARGET_64BIT && reload_completed
3479 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))"
3480 [(set (match_dup 3) (match_dup 1))
3481 (set (match_dup 4) (const_int 0))]
3482 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3484 (define_insn "zero_extend<mode>di2"
3485 [(set (match_operand:DI 0 "register_operand" "=r")
3487 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3489 "movz{<imodesuffix>l|x}\t{%1, %k0|%k0, %1}"
3490 [(set_attr "type" "imovx")
3491 (set_attr "mode" "SI")])
3493 (define_expand "zero_extendhisi2"
3494 [(set (match_operand:SI 0 "register_operand" "")
3495 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3498 if (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3500 operands[1] = force_reg (HImode, operands[1]);
3501 emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3506 (define_insn_and_split "zero_extendhisi2_and"
3507 [(set (match_operand:SI 0 "register_operand" "=r")
3508 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3509 (clobber (reg:CC FLAGS_REG))]
3510 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3512 "&& reload_completed"
3513 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3514 (clobber (reg:CC FLAGS_REG))])]
3516 [(set_attr "type" "alu1")
3517 (set_attr "mode" "SI")])
3519 (define_insn "*zero_extendhisi2_movzwl"
3520 [(set (match_operand:SI 0 "register_operand" "=r")
3521 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3522 "!TARGET_ZERO_EXTEND_WITH_AND
3523 || optimize_function_for_size_p (cfun)"
3524 "movz{wl|x}\t{%1, %0|%0, %1}"
3525 [(set_attr "type" "imovx")
3526 (set_attr "mode" "SI")])
3528 (define_expand "zero_extendqi<mode>2"
3530 [(set (match_operand:SWI24 0 "register_operand" "")
3531 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3532 (clobber (reg:CC FLAGS_REG))])])
3534 (define_insn "*zero_extendqi<mode>2_and"
3535 [(set (match_operand:SWI24 0 "register_operand" "=r,?&q")
3536 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3537 (clobber (reg:CC FLAGS_REG))]
3538 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3540 [(set_attr "type" "alu1")
3541 (set_attr "mode" "<MODE>")])
3543 ;; When source and destination does not overlap, clear destination
3544 ;; first and then do the movb
3546 [(set (match_operand:SWI24 0 "register_operand" "")
3547 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3548 (clobber (reg:CC FLAGS_REG))]
3550 && (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3551 && ANY_QI_REG_P (operands[0])
3552 && (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]))
3553 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3554 [(set (strict_low_part (match_dup 2)) (match_dup 1))]
3556 operands[2] = gen_lowpart (QImode, operands[0]);
3557 ix86_expand_clear (operands[0]);
3560 (define_insn "*zero_extendqi<mode>2_movzbl_and"
3561 [(set (match_operand:SWI24 0 "register_operand" "=r,r")
3562 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3563 (clobber (reg:CC FLAGS_REG))]
3564 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun)"
3566 [(set_attr "type" "imovx,alu1")
3567 (set_attr "mode" "<MODE>")])
3569 ;; For the movzbl case strip only the clobber
3571 [(set (match_operand:SWI24 0 "register_operand" "")
3572 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3573 (clobber (reg:CC FLAGS_REG))]
3575 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))
3576 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3578 (zero_extend:SWI24 (match_dup 1)))])
3580 ; zero extend to SImode to avoid partial register stalls
3581 (define_insn "*zero_extendqi<mode>2_movzbl"
3582 [(set (match_operand:SWI24 0 "register_operand" "=r")
3583 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3585 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))"
3586 "movz{bl|x}\t{%1, %k0|%k0, %1}"
3587 [(set_attr "type" "imovx")
3588 (set_attr "mode" "SI")])
3590 ;; Rest is handled by single and.
3592 [(set (match_operand:SWI24 0 "register_operand" "")
3593 (zero_extend:SWI24 (match_operand:QI 1 "register_operand" "")))
3594 (clobber (reg:CC FLAGS_REG))]
3596 && true_regnum (operands[0]) == true_regnum (operands[1])"
3597 [(parallel [(set (match_dup 0) (and:SWI24 (match_dup 0) (const_int 255)))
3598 (clobber (reg:CC FLAGS_REG))])])
3600 ;; Sign extension instructions
3602 (define_expand "extendsidi2"
3603 [(set (match_operand:DI 0 "register_operand" "")
3604 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))]
3609 emit_insn (gen_extendsidi2_1 (operands[0], operands[1]));
3614 (define_insn "*extendsidi2_rex64"
3615 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3616 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3620 movs{lq|x}\t{%1, %0|%0, %1}"
3621 [(set_attr "type" "imovx")
3622 (set_attr "mode" "DI")
3623 (set_attr "prefix_0f" "0")
3624 (set_attr "modrm" "0,1")])
3626 (define_insn "extendsidi2_1"
3627 [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3628 (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3629 (clobber (reg:CC FLAGS_REG))
3630 (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3634 ;; Extend to memory case when source register does die.
3636 [(set (match_operand:DI 0 "memory_operand" "")
3637 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3638 (clobber (reg:CC FLAGS_REG))
3639 (clobber (match_operand:SI 2 "register_operand" ""))]
3641 && dead_or_set_p (insn, operands[1])
3642 && !reg_mentioned_p (operands[1], operands[0]))"
3643 [(set (match_dup 3) (match_dup 1))
3644 (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3645 (clobber (reg:CC FLAGS_REG))])
3646 (set (match_dup 4) (match_dup 1))]
3647 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3649 ;; Extend to memory case when source register does not die.
3651 [(set (match_operand:DI 0 "memory_operand" "")
3652 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3653 (clobber (reg:CC FLAGS_REG))
3654 (clobber (match_operand:SI 2 "register_operand" ""))]
3658 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3660 emit_move_insn (operands[3], operands[1]);
3662 /* Generate a cltd if possible and doing so it profitable. */
3663 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3664 && true_regnum (operands[1]) == AX_REG
3665 && true_regnum (operands[2]) == DX_REG)
3667 emit_insn (gen_ashrsi3_cvt (operands[2], operands[1], GEN_INT (31)));
3671 emit_move_insn (operands[2], operands[1]);
3672 emit_insn (gen_ashrsi3_cvt (operands[2], operands[2], GEN_INT (31)));
3674 emit_move_insn (operands[4], operands[2]);
3678 ;; Extend to register case. Optimize case where source and destination
3679 ;; registers match and cases where we can use cltd.
3681 [(set (match_operand:DI 0 "register_operand" "")
3682 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3683 (clobber (reg:CC FLAGS_REG))
3684 (clobber (match_scratch:SI 2 ""))]
3688 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3690 if (true_regnum (operands[3]) != true_regnum (operands[1]))
3691 emit_move_insn (operands[3], operands[1]);
3693 /* Generate a cltd if possible and doing so it profitable. */
3694 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3695 && true_regnum (operands[3]) == AX_REG
3696 && true_regnum (operands[4]) == DX_REG)
3698 emit_insn (gen_ashrsi3_cvt (operands[4], operands[3], GEN_INT (31)));
3702 if (true_regnum (operands[4]) != true_regnum (operands[1]))
3703 emit_move_insn (operands[4], operands[1]);
3705 emit_insn (gen_ashrsi3_cvt (operands[4], operands[4], GEN_INT (31)));
3709 (define_insn "extend<mode>di2"
3710 [(set (match_operand:DI 0 "register_operand" "=r")
3712 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3714 "movs{<imodesuffix>q|x}\t{%1, %0|%0, %1}"
3715 [(set_attr "type" "imovx")
3716 (set_attr "mode" "DI")])
3718 (define_insn "extendhisi2"
3719 [(set (match_operand:SI 0 "register_operand" "=*a,r")
3720 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3723 switch (get_attr_prefix_0f (insn))
3726 return "{cwtl|cwde}";
3728 return "movs{wl|x}\t{%1, %0|%0, %1}";
3731 [(set_attr "type" "imovx")
3732 (set_attr "mode" "SI")
3733 (set (attr "prefix_0f")
3734 ;; movsx is short decodable while cwtl is vector decoded.
3735 (if_then_else (and (eq_attr "cpu" "!k6")
3736 (eq_attr "alternative" "0"))
3738 (const_string "1")))
3740 (if_then_else (eq_attr "prefix_0f" "0")
3742 (const_string "1")))])
3744 (define_insn "*extendhisi2_zext"
3745 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3748 (match_operand:HI 1 "nonimmediate_operand" "*0,rm"))))]
3751 switch (get_attr_prefix_0f (insn))
3754 return "{cwtl|cwde}";
3756 return "movs{wl|x}\t{%1, %k0|%k0, %1}";
3759 [(set_attr "type" "imovx")
3760 (set_attr "mode" "SI")
3761 (set (attr "prefix_0f")
3762 ;; movsx is short decodable while cwtl is vector decoded.
3763 (if_then_else (and (eq_attr "cpu" "!k6")
3764 (eq_attr "alternative" "0"))
3766 (const_string "1")))
3768 (if_then_else (eq_attr "prefix_0f" "0")
3770 (const_string "1")))])
3772 (define_insn "extendqisi2"
3773 [(set (match_operand:SI 0 "register_operand" "=r")
3774 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3776 "movs{bl|x}\t{%1, %0|%0, %1}"
3777 [(set_attr "type" "imovx")
3778 (set_attr "mode" "SI")])
3780 (define_insn "*extendqisi2_zext"
3781 [(set (match_operand:DI 0 "register_operand" "=r")
3783 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm"))))]
3785 "movs{bl|x}\t{%1, %k0|%k0, %1}"
3786 [(set_attr "type" "imovx")
3787 (set_attr "mode" "SI")])
3789 (define_insn "extendqihi2"
3790 [(set (match_operand:HI 0 "register_operand" "=*a,r")
3791 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "*0,qm")))]
3794 switch (get_attr_prefix_0f (insn))
3797 return "{cbtw|cbw}";
3799 return "movs{bw|x}\t{%1, %0|%0, %1}";
3802 [(set_attr "type" "imovx")
3803 (set_attr "mode" "HI")
3804 (set (attr "prefix_0f")
3805 ;; movsx is short decodable while cwtl is vector decoded.
3806 (if_then_else (and (eq_attr "cpu" "!k6")
3807 (eq_attr "alternative" "0"))
3809 (const_string "1")))
3811 (if_then_else (eq_attr "prefix_0f" "0")
3813 (const_string "1")))])
3815 ;; Conversions between float and double.
3817 ;; These are all no-ops in the model used for the 80387.
3818 ;; So just emit moves.
3820 ;; %%% Kill these when call knows how to work out a DFmode push earlier.
3822 [(set (match_operand:DF 0 "push_operand" "")
3823 (float_extend:DF (match_operand:SF 1 "fp_register_operand" "")))]
3825 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
3826 (set (mem:DF (reg:P SP_REG)) (float_extend:DF (match_dup 1)))])
3829 [(set (match_operand:XF 0 "push_operand" "")
3830 (float_extend:XF (match_operand:MODEF 1 "fp_register_operand" "")))]
3832 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
3833 (set (mem:XF (reg:P SP_REG)) (float_extend:XF (match_dup 1)))]
3834 "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
3836 (define_expand "extendsfdf2"
3837 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3838 (float_extend:DF (match_operand:SF 1 "general_operand" "")))]
3839 "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
3841 /* ??? Needed for compress_float_constant since all fp constants
3842 are TARGET_LEGITIMATE_CONSTANT_P. */
3843 if (GET_CODE (operands[1]) == CONST_DOUBLE)
3845 if ((!TARGET_SSE2 || TARGET_MIX_SSE_I387)
3846 && standard_80387_constant_p (operands[1]) > 0)
3848 operands[1] = simplify_const_unary_operation
3849 (FLOAT_EXTEND, DFmode, operands[1], SFmode);
3850 emit_move_insn_1 (operands[0], operands[1]);
3853 operands[1] = validize_mem (force_const_mem (SFmode, operands[1]));
3857 /* For converting SF(xmm2) to DF(xmm1), use the following code instead of
3859 unpcklps xmm2,xmm2 ; packed conversion might crash on signaling NaNs
3861 We do the conversion post reload to avoid producing of 128bit spills
3862 that might lead to ICE on 32bit target. The sequence unlikely combine
3865 [(set (match_operand:DF 0 "register_operand" "")
3867 (match_operand:SF 1 "nonimmediate_operand" "")))]
3868 "TARGET_USE_VECTOR_FP_CONVERTS
3869 && optimize_insn_for_speed_p ()
3870 && reload_completed && SSE_REG_P (operands[0])"
3875 (parallel [(const_int 0) (const_int 1)]))))]
3877 operands[2] = simplify_gen_subreg (V2DFmode, operands[0], DFmode, 0);
3878 operands[3] = simplify_gen_subreg (V4SFmode, operands[0], DFmode, 0);
3879 /* Use movss for loading from memory, unpcklps reg, reg for registers.
3880 Try to avoid move when unpacking can be done in source. */
3881 if (REG_P (operands[1]))
3883 /* If it is unsafe to overwrite upper half of source, we need
3884 to move to destination and unpack there. */
3885 if ((ORIGINAL_REGNO (operands[1]) < FIRST_PSEUDO_REGISTER
3886 || PSEUDO_REGNO_BYTES (ORIGINAL_REGNO (operands[1])) > 4)
3887 && true_regnum (operands[0]) != true_regnum (operands[1]))
3889 rtx tmp = gen_rtx_REG (SFmode, true_regnum (operands[0]));
3890 emit_move_insn (tmp, operands[1]);
3893 operands[3] = simplify_gen_subreg (V4SFmode, operands[1], SFmode, 0);
3894 emit_insn (gen_vec_interleave_lowv4sf (operands[3], operands[3],
3898 emit_insn (gen_vec_setv4sf_0 (operands[3],
3899 CONST0_RTX (V4SFmode), operands[1]));
3902 (define_insn "*extendsfdf2_mixed"
3903 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,m,x")
3905 (match_operand:SF 1 "nonimmediate_operand" "fm,f,xm")))]
3906 "TARGET_SSE2 && TARGET_MIX_SSE_I387"
3908 switch (which_alternative)
3912 return output_387_reg_move (insn, operands);
3915 return "%vcvtss2sd\t{%1, %d0|%d0, %1}";
3921 [(set_attr "type" "fmov,fmov,ssecvt")