1 ;; GCC machine description for IA-32 and x86-64.
2 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 ;; Free Software Foundation, Inc.
5 ;; Mostly by William Schelter.
6 ;; x86_64 support added by Jan Hubicka
8 ;; This file is part of GCC.
10 ;; GCC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; GCC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING3. If not see
22 ;; <http://www.gnu.org/licenses/>. */
24 ;; The original PO technology requires these to be ordered by speed,
25 ;; so that assigner will pick the fastest.
27 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
29 ;; The special asm out single letter directives following a '%' are:
30 ;; L,W,B,Q,S,T -- print the opcode suffix for specified size of operand.
31 ;; C -- print opcode suffix for set/cmov insn.
32 ;; c -- like C, but print reversed condition
33 ;; F,f -- likewise, but for floating-point.
34 ;; O -- if HAVE_AS_IX86_CMOV_SUN_SYNTAX, expand to "w.", "l." or "q.",
36 ;; R -- print the prefix for register names.
37 ;; z -- print the opcode suffix for the size of the current operand.
38 ;; Z -- likewise, with special suffixes for x87 instructions.
39 ;; * -- print a star (in certain assembler syntax)
40 ;; A -- print an absolute memory reference.
41 ;; w -- print the operand as if it's a "word" (HImode) even if it isn't.
42 ;; s -- print a shift double count, followed by the assemblers argument
44 ;; b -- print the QImode name of the register for the indicated operand.
45 ;; %b0 would print %al if operands[0] is reg 0.
46 ;; w -- likewise, print the HImode name of the register.
47 ;; k -- likewise, print the SImode name of the register.
48 ;; q -- likewise, print the DImode name of the register.
49 ;; x -- likewise, print the V4SFmode name of the register.
50 ;; t -- likewise, print the V8SFmode name of the register.
51 ;; h -- print the QImode name for a "high" register, either ah, bh, ch or dh.
52 ;; y -- print "st(0)" instead of "st" as a register.
53 ;; d -- print duplicated register operand for AVX instruction.
54 ;; D -- print condition for SSE cmp instruction.
55 ;; P -- if PIC, print an @PLT suffix.
56 ;; X -- don't print any sort of PIC '@' suffix for a symbol.
57 ;; & -- print some in-use local-dynamic symbol name.
58 ;; H -- print a memory address offset by 8; used for sse high-parts
59 ;; Y -- print condition for XOP pcom* instruction.
60 ;; + -- print a branch hint as 'cs' or 'ds' prefix
61 ;; ; -- print a semicolon (after prefixes due to bug in older gas).
62 ;; @ -- print a segment register of thread base pointer load
66 (define_c_enum "unspec" [
67 ;; Relocation specifiers
78 UNSPEC_MACHOPIC_OFFSET
87 UNSPEC_MEMORY_BLOCKAGE
96 ;; Other random patterns
105 UNSPEC_LD_MPIC ; load_macho_picbase
107 UNSPEC_DIV_ALREADY_SPLIT
108 UNSPEC_CALL_NEEDS_VZEROUPPER
110 ;; For SSE/MMX support:
128 UNSPEC_MS_TO_SYSV_CALL
130 ;; Generic math support
132 UNSPEC_IEEE_MIN ; not commutative
133 UNSPEC_IEEE_MAX ; not commutative
135 ;; x87 Floating point
151 UNSPEC_FRNDINT_MASK_PM
155 ;; x87 Double output FP
187 ;; For SSE4.1 support
197 ;; For SSE4.2 support
204 UNSPEC_XOP_UNSIGNED_CMP
215 UNSPEC_AESKEYGENASSIST
217 ;; For PCLMUL support
233 (define_c_enum "unspecv" [
236 UNSPECV_PROBE_STACK_RANGE
256 UNSPECV_LLWP_INTRINSIC
257 UNSPECV_SLWP_INTRINSIC
258 UNSPECV_LWPVAL_INTRINSIC
259 UNSPECV_LWPINS_INTRINSIC
265 UNSPECV_SPLIT_STACK_RETURN
268 ;; Constants to represent pcomtrue/pcomfalse variants
278 ;; Constants used in the XOP pperm instruction
280 [(PPERM_SRC 0x00) /* copy source */
281 (PPERM_INVERT 0x20) /* invert source */
282 (PPERM_REVERSE 0x40) /* bit reverse source */
283 (PPERM_REV_INV 0x60) /* bit reverse & invert src */
284 (PPERM_ZERO 0x80) /* all 0's */
285 (PPERM_ONES 0xa0) /* all 1's */
286 (PPERM_SIGN 0xc0) /* propagate sign bit */
287 (PPERM_INV_SIGN 0xe0) /* invert & propagate sign */
288 (PPERM_SRC1 0x00) /* use first source byte */
289 (PPERM_SRC2 0x10) /* use second source byte */
292 ;; Registers by name.
345 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
348 ;; In C guard expressions, put expressions which may be compile-time
349 ;; constants first. This allows for better optimization. For
350 ;; example, write "TARGET_64BIT && reload_completed", not
351 ;; "reload_completed && TARGET_64BIT".
355 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,atom,
356 generic64,amdfam10,bdver1"
357 (const (symbol_ref "ix86_schedule")))
359 ;; A basic instruction type. Refinements due to arguments to be
360 ;; provided in other attributes.
363 alu,alu1,negnot,imov,imovx,lea,
364 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
365 icmp,test,ibr,setcc,icmov,
366 push,pop,call,callv,leave,
368 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
369 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
370 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
371 ssemuladd,sse4arg,lwp,
372 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
373 (const_string "other"))
375 ;; Main data type used by the insn
377 "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
378 (const_string "unknown"))
380 ;; The CPU unit operations uses.
381 (define_attr "unit" "integer,i387,sse,mmx,unknown"
382 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
383 (const_string "i387")
384 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
385 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
386 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
388 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
390 (eq_attr "type" "other")
391 (const_string "unknown")]
392 (const_string "integer")))
394 ;; The (bounding maximum) length of an instruction immediate.
395 (define_attr "length_immediate" ""
396 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
399 (eq_attr "unit" "i387,sse,mmx")
401 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
403 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
404 (eq_attr "type" "imov,test")
405 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
406 (eq_attr "type" "call")
407 (if_then_else (match_operand 0 "constant_call_address_operand" "")
410 (eq_attr "type" "callv")
411 (if_then_else (match_operand 1 "constant_call_address_operand" "")
414 ;; We don't know the size before shorten_branches. Expect
415 ;; the instruction to fit for better scheduling.
416 (eq_attr "type" "ibr")
419 (symbol_ref "/* Update immediate_length and other attributes! */
420 gcc_unreachable (),1")))
422 ;; The (bounding maximum) length of an instruction address.
423 (define_attr "length_address" ""
424 (cond [(eq_attr "type" "str,other,multi,fxch")
426 (and (eq_attr "type" "call")
427 (match_operand 0 "constant_call_address_operand" ""))
429 (and (eq_attr "type" "callv")
430 (match_operand 1 "constant_call_address_operand" ""))
433 (symbol_ref "ix86_attr_length_address_default (insn)")))
435 ;; Set when length prefix is used.
436 (define_attr "prefix_data16" ""
437 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
439 (eq_attr "mode" "HI")
441 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
446 ;; Set when string REP prefix is used.
447 (define_attr "prefix_rep" ""
448 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
450 (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
455 ;; Set when 0f opcode prefix is used.
456 (define_attr "prefix_0f" ""
458 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
459 (eq_attr "unit" "sse,mmx"))
463 ;; Set when REX opcode prefix is used.
464 (define_attr "prefix_rex" ""
465 (cond [(eq (symbol_ref "TARGET_64BIT") (const_int 0))
467 (and (eq_attr "mode" "DI")
468 (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
469 (eq_attr "unit" "!mmx")))
471 (and (eq_attr "mode" "QI")
472 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
475 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
478 (and (eq_attr "type" "imovx")
479 (match_operand:QI 1 "ext_QIreg_operand" ""))
484 ;; There are also additional prefixes in 3DNOW, SSSE3.
485 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
486 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
487 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
488 (define_attr "prefix_extra" ""
489 (cond [(eq_attr "type" "ssemuladd,sse4arg")
491 (eq_attr "type" "sseiadd1,ssecvt1")
496 ;; Prefix used: original, VEX or maybe VEX.
497 (define_attr "prefix" "orig,vex,maybe_vex"
498 (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
500 (const_string "orig")))
502 ;; VEX W bit is used.
503 (define_attr "prefix_vex_w" "" (const_int 0))
505 ;; The length of VEX prefix
506 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
507 ;; 0f38/0f3a prefixes can't. In i386.md 0f3[8a] is
508 ;; still prefix_0f 1, with prefix_extra 1.
509 (define_attr "length_vex" ""
510 (if_then_else (and (eq_attr "prefix_0f" "1")
511 (eq_attr "prefix_extra" "0"))
512 (if_then_else (eq_attr "prefix_vex_w" "1")
513 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 1)")
514 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 0)"))
515 (if_then_else (eq_attr "prefix_vex_w" "1")
516 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 1)")
517 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 0)"))))
519 ;; Set when modrm byte is used.
520 (define_attr "modrm" ""
521 (cond [(eq_attr "type" "str,leave")
523 (eq_attr "unit" "i387")
525 (and (eq_attr "type" "incdec")
526 (and (eq (symbol_ref "TARGET_64BIT") (const_int 0))
527 (ior (match_operand:SI 1 "register_operand" "")
528 (match_operand:HI 1 "register_operand" ""))))
530 (and (eq_attr "type" "push")
531 (not (match_operand 1 "memory_operand" "")))
533 (and (eq_attr "type" "pop")
534 (not (match_operand 0 "memory_operand" "")))
536 (and (eq_attr "type" "imov")
537 (and (not (eq_attr "mode" "DI"))
538 (ior (and (match_operand 0 "register_operand" "")
539 (match_operand 1 "immediate_operand" ""))
540 (ior (and (match_operand 0 "ax_reg_operand" "")
541 (match_operand 1 "memory_displacement_only_operand" ""))
542 (and (match_operand 0 "memory_displacement_only_operand" "")
543 (match_operand 1 "ax_reg_operand" ""))))))
545 (and (eq_attr "type" "call")
546 (match_operand 0 "constant_call_address_operand" ""))
548 (and (eq_attr "type" "callv")
549 (match_operand 1 "constant_call_address_operand" ""))
551 (and (eq_attr "type" "alu,alu1,icmp,test")
552 (match_operand 0 "ax_reg_operand" ""))
553 (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
557 ;; The (bounding maximum) length of an instruction in bytes.
558 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
559 ;; Later we may want to split them and compute proper length as for
561 (define_attr "length" ""
562 (cond [(eq_attr "type" "other,multi,fistp,frndint")
564 (eq_attr "type" "fcmp")
566 (eq_attr "unit" "i387")
568 (plus (attr "prefix_data16")
569 (attr "length_address")))
570 (ior (eq_attr "prefix" "vex")
571 (and (eq_attr "prefix" "maybe_vex")
572 (ne (symbol_ref "TARGET_AVX") (const_int 0))))
573 (plus (attr "length_vex")
574 (plus (attr "length_immediate")
576 (attr "length_address"))))]
577 (plus (plus (attr "modrm")
578 (plus (attr "prefix_0f")
579 (plus (attr "prefix_rex")
580 (plus (attr "prefix_extra")
582 (plus (attr "prefix_rep")
583 (plus (attr "prefix_data16")
584 (plus (attr "length_immediate")
585 (attr "length_address")))))))
587 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
588 ;; `store' if there is a simple memory reference therein, or `unknown'
589 ;; if the instruction is complex.
591 (define_attr "memory" "none,load,store,both,unknown"
592 (cond [(eq_attr "type" "other,multi,str,lwp")
593 (const_string "unknown")
594 (eq_attr "type" "lea,fcmov,fpspc")
595 (const_string "none")
596 (eq_attr "type" "fistp,leave")
597 (const_string "both")
598 (eq_attr "type" "frndint")
599 (const_string "load")
600 (eq_attr "type" "push")
601 (if_then_else (match_operand 1 "memory_operand" "")
602 (const_string "both")
603 (const_string "store"))
604 (eq_attr "type" "pop")
605 (if_then_else (match_operand 0 "memory_operand" "")
606 (const_string "both")
607 (const_string "load"))
608 (eq_attr "type" "setcc")
609 (if_then_else (match_operand 0 "memory_operand" "")
610 (const_string "store")
611 (const_string "none"))
612 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
613 (if_then_else (ior (match_operand 0 "memory_operand" "")
614 (match_operand 1 "memory_operand" ""))
615 (const_string "load")
616 (const_string "none"))
617 (eq_attr "type" "ibr")
618 (if_then_else (match_operand 0 "memory_operand" "")
619 (const_string "load")
620 (const_string "none"))
621 (eq_attr "type" "call")
622 (if_then_else (match_operand 0 "constant_call_address_operand" "")
623 (const_string "none")
624 (const_string "load"))
625 (eq_attr "type" "callv")
626 (if_then_else (match_operand 1 "constant_call_address_operand" "")
627 (const_string "none")
628 (const_string "load"))
629 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
630 (match_operand 1 "memory_operand" ""))
631 (const_string "both")
632 (and (match_operand 0 "memory_operand" "")
633 (match_operand 1 "memory_operand" ""))
634 (const_string "both")
635 (match_operand 0 "memory_operand" "")
636 (const_string "store")
637 (match_operand 1 "memory_operand" "")
638 (const_string "load")
640 "!alu1,negnot,ishift1,
641 imov,imovx,icmp,test,bitmanip,
643 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
644 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
645 (match_operand 2 "memory_operand" ""))
646 (const_string "load")
647 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
648 (match_operand 3 "memory_operand" ""))
649 (const_string "load")
651 (const_string "none")))
653 ;; Indicates if an instruction has both an immediate and a displacement.
655 (define_attr "imm_disp" "false,true,unknown"
656 (cond [(eq_attr "type" "other,multi")
657 (const_string "unknown")
658 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
659 (and (match_operand 0 "memory_displacement_operand" "")
660 (match_operand 1 "immediate_operand" "")))
661 (const_string "true")
662 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
663 (and (match_operand 0 "memory_displacement_operand" "")
664 (match_operand 2 "immediate_operand" "")))
665 (const_string "true")
667 (const_string "false")))
669 ;; Indicates if an FP operation has an integer source.
671 (define_attr "fp_int_src" "false,true"
672 (const_string "false"))
674 ;; Defines rounding mode of an FP operation.
676 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
677 (const_string "any"))
679 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
680 (define_attr "use_carry" "0,1" (const_string "0"))
682 ;; Define attribute to indicate unaligned ssemov insns
683 (define_attr "movu" "0,1" (const_string "0"))
685 ;; Describe a user's asm statement.
686 (define_asm_attributes
687 [(set_attr "length" "128")
688 (set_attr "type" "multi")])
690 (define_code_iterator plusminus [plus minus])
692 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
694 ;; Base name for define_insn
695 (define_code_attr plusminus_insn
696 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
697 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
699 ;; Base name for insn mnemonic.
700 (define_code_attr plusminus_mnemonic
701 [(plus "add") (ss_plus "adds") (us_plus "addus")
702 (minus "sub") (ss_minus "subs") (us_minus "subus")])
703 (define_code_attr plusminus_carry_mnemonic
704 [(plus "adc") (minus "sbb")])
706 ;; Mark commutative operators as such in constraints.
707 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
708 (minus "") (ss_minus "") (us_minus "")])
710 ;; Mapping of signed max and min
711 (define_code_iterator smaxmin [smax smin])
713 ;; Mapping of unsigned max and min
714 (define_code_iterator umaxmin [umax umin])
716 ;; Base name for integer and FP insn mnemonic
717 (define_code_attr maxmin_int [(smax "maxs") (smin "mins")
718 (umax "maxu") (umin "minu")])
719 (define_code_attr maxmin_float [(smax "max") (smin "min")])
721 ;; Mapping of logic operators
722 (define_code_iterator any_logic [and ior xor])
723 (define_code_iterator any_or [ior xor])
725 ;; Base name for insn mnemonic.
726 (define_code_attr logic [(and "and") (ior "or") (xor "xor")])
728 ;; Mapping of shift-right operators
729 (define_code_iterator any_shiftrt [lshiftrt ashiftrt])
731 ;; Base name for define_insn
732 (define_code_attr shiftrt_insn [(lshiftrt "lshr") (ashiftrt "ashr")])
734 ;; Base name for insn mnemonic.
735 (define_code_attr shiftrt [(lshiftrt "shr") (ashiftrt "sar")])
737 ;; Mapping of rotate operators
738 (define_code_iterator any_rotate [rotate rotatert])
740 ;; Base name for define_insn
741 (define_code_attr rotate_insn [(rotate "rotl") (rotatert "rotr")])
743 ;; Base name for insn mnemonic.
744 (define_code_attr rotate [(rotate "rol") (rotatert "ror")])
746 ;; Mapping of abs neg operators
747 (define_code_iterator absneg [abs neg])
749 ;; Base name for x87 insn mnemonic.
750 (define_code_attr absneg_mnemonic [(abs "abs") (neg "chs")])
752 ;; Used in signed and unsigned widening multiplications.
753 (define_code_iterator any_extend [sign_extend zero_extend])
755 ;; Various insn prefixes for signed and unsigned operations.
756 (define_code_attr u [(sign_extend "") (zero_extend "u")
757 (div "") (udiv "u")])
758 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
760 ;; Used in signed and unsigned divisions.
761 (define_code_iterator any_div [div udiv])
763 ;; Instruction prefix for signed and unsigned operations.
764 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")
765 (div "i") (udiv "")])
767 ;; 64bit single word integer modes.
768 (define_mode_iterator SWI1248x [QI HI SI DI])
770 ;; 64bit single word integer modes without QImode and HImode.
771 (define_mode_iterator SWI48x [SI DI])
773 ;; Single word integer modes.
774 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
776 ;; Single word integer modes without SImode and DImode.
777 (define_mode_iterator SWI12 [QI HI])
779 ;; Single word integer modes without DImode.
780 (define_mode_iterator SWI124 [QI HI SI])
782 ;; Single word integer modes without QImode and DImode.
783 (define_mode_iterator SWI24 [HI SI])
785 ;; Single word integer modes without QImode.
786 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
788 ;; Single word integer modes without QImode and HImode.
789 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
791 ;; All math-dependant single and double word integer modes.
792 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
793 (HI "TARGET_HIMODE_MATH")
794 SI DI (TI "TARGET_64BIT")])
796 ;; Math-dependant single word integer modes.
797 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
798 (HI "TARGET_HIMODE_MATH")
799 SI (DI "TARGET_64BIT")])
801 ;; Math-dependant single word integer modes without DImode.
802 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
803 (HI "TARGET_HIMODE_MATH")
806 ;; Math-dependant single word integer modes without QImode.
807 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
808 SI (DI "TARGET_64BIT")])
810 ;; Double word integer modes.
811 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
812 (TI "TARGET_64BIT")])
814 ;; Double word integer modes as mode attribute.
815 (define_mode_attr DWI [(SI "DI") (DI "TI")])
816 (define_mode_attr dwi [(SI "di") (DI "ti")])
818 ;; Half mode for double word integer modes.
819 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
820 (DI "TARGET_64BIT")])
822 ;; Instruction suffix for integer modes.
823 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
825 ;; Pointer size prefix for integer modes (Intel asm dialect)
826 (define_mode_attr iptrsize [(QI "BYTE")
831 ;; Register class for integer modes.
832 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
834 ;; Immediate operand constraint for integer modes.
835 (define_mode_attr i [(QI "n") (HI "n") (SI "i") (DI "e")])
837 ;; General operand constraint for word modes.
838 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "g") (DI "rme")])
840 ;; Immediate operand constraint for double integer modes.
841 (define_mode_attr di [(SI "iF") (DI "e")])
843 ;; Immediate operand constraint for shifts.
844 (define_mode_attr S [(QI "I") (HI "I") (SI "I") (DI "J") (TI "O")])
846 ;; General operand predicate for integer modes.
847 (define_mode_attr general_operand
848 [(QI "general_operand")
849 (HI "general_operand")
850 (SI "general_operand")
851 (DI "x86_64_general_operand")
852 (TI "x86_64_general_operand")])
854 ;; General sign/zero extend operand predicate for integer modes.
855 (define_mode_attr general_szext_operand
856 [(QI "general_operand")
857 (HI "general_operand")
858 (SI "general_operand")
859 (DI "x86_64_szext_general_operand")])
861 ;; Immediate operand predicate for integer modes.
862 (define_mode_attr immediate_operand
863 [(QI "immediate_operand")
864 (HI "immediate_operand")
865 (SI "immediate_operand")
866 (DI "x86_64_immediate_operand")])
868 ;; Nonmemory operand predicate for integer modes.
869 (define_mode_attr nonmemory_operand
870 [(QI "nonmemory_operand")
871 (HI "nonmemory_operand")
872 (SI "nonmemory_operand")
873 (DI "x86_64_nonmemory_operand")])
875 ;; Operand predicate for shifts.
876 (define_mode_attr shift_operand
877 [(QI "nonimmediate_operand")
878 (HI "nonimmediate_operand")
879 (SI "nonimmediate_operand")
880 (DI "shiftdi_operand")
881 (TI "register_operand")])
883 ;; Operand predicate for shift argument.
884 (define_mode_attr shift_immediate_operand
885 [(QI "const_1_to_31_operand")
886 (HI "const_1_to_31_operand")
887 (SI "const_1_to_31_operand")
888 (DI "const_1_to_63_operand")])
890 ;; Input operand predicate for arithmetic left shifts.
891 (define_mode_attr ashl_input_operand
892 [(QI "nonimmediate_operand")
893 (HI "nonimmediate_operand")
894 (SI "nonimmediate_operand")
895 (DI "ashldi_input_operand")
896 (TI "reg_or_pm1_operand")])
898 ;; SSE and x87 SFmode and DFmode floating point modes
899 (define_mode_iterator MODEF [SF DF])
901 ;; All x87 floating point modes
902 (define_mode_iterator X87MODEF [SF DF XF])
904 ;; All integer modes handled by x87 fisttp operator.
905 (define_mode_iterator X87MODEI [HI SI DI])
907 ;; All integer modes handled by integer x87 operators.
908 (define_mode_iterator X87MODEI12 [HI SI])
910 ;; All integer modes handled by SSE cvtts?2si* operators.
911 (define_mode_iterator SSEMODEI24 [SI DI])
913 ;; SSE asm suffix for floating point modes
914 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
916 ;; SSE vector mode corresponding to a scalar mode
917 (define_mode_attr ssevecmode
918 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
920 ;; Instruction suffix for REX 64bit operators.
921 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
923 ;; This mode iterator allows :P to be used for patterns that operate on
924 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
925 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
927 ;; Scheduling descriptions
929 (include "pentium.md")
932 (include "athlon.md")
933 (include "bdver1.md")
938 ;; Operand and operator predicates and constraints
940 (include "predicates.md")
941 (include "constraints.md")
944 ;; Compare and branch/compare and store instructions.
946 (define_expand "cbranch<mode>4"
947 [(set (reg:CC FLAGS_REG)
948 (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
949 (match_operand:SDWIM 2 "<general_operand>" "")))
950 (set (pc) (if_then_else
951 (match_operator 0 "ordered_comparison_operator"
952 [(reg:CC FLAGS_REG) (const_int 0)])
953 (label_ref (match_operand 3 "" ""))
957 if (MEM_P (operands[1]) && MEM_P (operands[2]))
958 operands[1] = force_reg (<MODE>mode, operands[1]);
959 ix86_expand_branch (GET_CODE (operands[0]),
960 operands[1], operands[2], operands[3]);
964 (define_expand "cstore<mode>4"
965 [(set (reg:CC FLAGS_REG)
966 (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
967 (match_operand:SWIM 3 "<general_operand>" "")))
968 (set (match_operand:QI 0 "register_operand" "")
969 (match_operator 1 "ordered_comparison_operator"
970 [(reg:CC FLAGS_REG) (const_int 0)]))]
973 if (MEM_P (operands[2]) && MEM_P (operands[3]))
974 operands[2] = force_reg (<MODE>mode, operands[2]);
975 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
976 operands[2], operands[3]);
980 (define_expand "cmp<mode>_1"
981 [(set (reg:CC FLAGS_REG)
982 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
983 (match_operand:SWI48 1 "<general_operand>" "")))])
985 (define_insn "*cmp<mode>_ccno_1"
986 [(set (reg FLAGS_REG)
987 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
988 (match_operand:SWI 1 "const0_operand" "")))]
989 "ix86_match_ccmode (insn, CCNOmode)"
991 test{<imodesuffix>}\t%0, %0
992 cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
993 [(set_attr "type" "test,icmp")
994 (set_attr "length_immediate" "0,1")
995 (set_attr "mode" "<MODE>")])
997 (define_insn "*cmp<mode>_1"
998 [(set (reg FLAGS_REG)
999 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1000 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
1001 "ix86_match_ccmode (insn, CCmode)"
1002 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1003 [(set_attr "type" "icmp")
1004 (set_attr "mode" "<MODE>")])
1006 (define_insn "*cmp<mode>_minus_1"
1007 [(set (reg FLAGS_REG)
1009 (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1010 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
1012 "ix86_match_ccmode (insn, CCGOCmode)"
1013 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1014 [(set_attr "type" "icmp")
1015 (set_attr "mode" "<MODE>")])
1017 (define_insn "*cmpqi_ext_1"
1018 [(set (reg FLAGS_REG)
1020 (match_operand:QI 0 "general_operand" "Qm")
1023 (match_operand 1 "ext_register_operand" "Q")
1025 (const_int 8)) 0)))]
1026 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1027 "cmp{b}\t{%h1, %0|%0, %h1}"
1028 [(set_attr "type" "icmp")
1029 (set_attr "mode" "QI")])
1031 (define_insn "*cmpqi_ext_1_rex64"
1032 [(set (reg FLAGS_REG)
1034 (match_operand:QI 0 "register_operand" "Q")
1037 (match_operand 1 "ext_register_operand" "Q")
1039 (const_int 8)) 0)))]
1040 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1041 "cmp{b}\t{%h1, %0|%0, %h1}"
1042 [(set_attr "type" "icmp")
1043 (set_attr "mode" "QI")])
1045 (define_insn "*cmpqi_ext_2"
1046 [(set (reg FLAGS_REG)
1050 (match_operand 0 "ext_register_operand" "Q")
1053 (match_operand:QI 1 "const0_operand" "")))]
1054 "ix86_match_ccmode (insn, CCNOmode)"
1056 [(set_attr "type" "test")
1057 (set_attr "length_immediate" "0")
1058 (set_attr "mode" "QI")])
1060 (define_expand "cmpqi_ext_3"
1061 [(set (reg:CC FLAGS_REG)
1065 (match_operand 0 "ext_register_operand" "")
1068 (match_operand:QI 1 "immediate_operand" "")))])
1070 (define_insn "*cmpqi_ext_3_insn"
1071 [(set (reg FLAGS_REG)
1075 (match_operand 0 "ext_register_operand" "Q")
1078 (match_operand:QI 1 "general_operand" "Qmn")))]
1079 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1080 "cmp{b}\t{%1, %h0|%h0, %1}"
1081 [(set_attr "type" "icmp")
1082 (set_attr "modrm" "1")
1083 (set_attr "mode" "QI")])
1085 (define_insn "*cmpqi_ext_3_insn_rex64"
1086 [(set (reg FLAGS_REG)
1090 (match_operand 0 "ext_register_operand" "Q")
1093 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1094 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1095 "cmp{b}\t{%1, %h0|%h0, %1}"
1096 [(set_attr "type" "icmp")
1097 (set_attr "modrm" "1")
1098 (set_attr "mode" "QI")])
1100 (define_insn "*cmpqi_ext_4"
1101 [(set (reg FLAGS_REG)
1105 (match_operand 0 "ext_register_operand" "Q")
1110 (match_operand 1 "ext_register_operand" "Q")
1112 (const_int 8)) 0)))]
1113 "ix86_match_ccmode (insn, CCmode)"
1114 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1115 [(set_attr "type" "icmp")
1116 (set_attr "mode" "QI")])
1118 ;; These implement float point compares.
1119 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1120 ;; which would allow mix and match FP modes on the compares. Which is what
1121 ;; the old patterns did, but with many more of them.
1123 (define_expand "cbranchxf4"
1124 [(set (reg:CC FLAGS_REG)
1125 (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1126 (match_operand:XF 2 "nonmemory_operand" "")))
1127 (set (pc) (if_then_else
1128 (match_operator 0 "ix86_fp_comparison_operator"
1131 (label_ref (match_operand 3 "" ""))
1135 ix86_expand_branch (GET_CODE (operands[0]),
1136 operands[1], operands[2], operands[3]);
1140 (define_expand "cstorexf4"
1141 [(set (reg:CC FLAGS_REG)
1142 (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1143 (match_operand:XF 3 "nonmemory_operand" "")))
1144 (set (match_operand:QI 0 "register_operand" "")
1145 (match_operator 1 "ix86_fp_comparison_operator"
1150 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1151 operands[2], operands[3]);
1155 (define_expand "cbranch<mode>4"
1156 [(set (reg:CC FLAGS_REG)
1157 (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1158 (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1159 (set (pc) (if_then_else
1160 (match_operator 0 "ix86_fp_comparison_operator"
1163 (label_ref (match_operand 3 "" ""))
1165 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1167 ix86_expand_branch (GET_CODE (operands[0]),
1168 operands[1], operands[2], operands[3]);
1172 (define_expand "cstore<mode>4"
1173 [(set (reg:CC FLAGS_REG)
1174 (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1175 (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1176 (set (match_operand:QI 0 "register_operand" "")
1177 (match_operator 1 "ix86_fp_comparison_operator"
1180 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1182 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1183 operands[2], operands[3]);
1187 (define_expand "cbranchcc4"
1188 [(set (pc) (if_then_else
1189 (match_operator 0 "comparison_operator"
1190 [(match_operand 1 "flags_reg_operand" "")
1191 (match_operand 2 "const0_operand" "")])
1192 (label_ref (match_operand 3 "" ""))
1196 ix86_expand_branch (GET_CODE (operands[0]),
1197 operands[1], operands[2], operands[3]);
1201 (define_expand "cstorecc4"
1202 [(set (match_operand:QI 0 "register_operand" "")
1203 (match_operator 1 "comparison_operator"
1204 [(match_operand 2 "flags_reg_operand" "")
1205 (match_operand 3 "const0_operand" "")]))]
1208 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1209 operands[2], operands[3]);
1214 ;; FP compares, step 1:
1215 ;; Set the FP condition codes.
1217 ;; CCFPmode compare with exceptions
1218 ;; CCFPUmode compare with no exceptions
1220 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1221 ;; used to manage the reg stack popping would not be preserved.
1223 (define_insn "*cmpfp_0"
1224 [(set (match_operand:HI 0 "register_operand" "=a")
1227 (match_operand 1 "register_operand" "f")
1228 (match_operand 2 "const0_operand" ""))]
1230 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1231 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1232 "* return output_fp_compare (insn, operands, 0, 0);"
1233 [(set_attr "type" "multi")
1234 (set_attr "unit" "i387")
1236 (cond [(match_operand:SF 1 "" "")
1238 (match_operand:DF 1 "" "")
1241 (const_string "XF")))])
1243 (define_insn_and_split "*cmpfp_0_cc"
1244 [(set (reg:CCFP FLAGS_REG)
1246 (match_operand 1 "register_operand" "f")
1247 (match_operand 2 "const0_operand" "")))
1248 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1249 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1250 && TARGET_SAHF && !TARGET_CMOVE
1251 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1253 "&& reload_completed"
1256 [(compare:CCFP (match_dup 1)(match_dup 2))]
1258 (set (reg:CC FLAGS_REG)
1259 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1261 [(set_attr "type" "multi")
1262 (set_attr "unit" "i387")
1264 (cond [(match_operand:SF 1 "" "")
1266 (match_operand:DF 1 "" "")
1269 (const_string "XF")))])
1271 (define_insn "*cmpfp_xf"
1272 [(set (match_operand:HI 0 "register_operand" "=a")
1275 (match_operand:XF 1 "register_operand" "f")
1276 (match_operand:XF 2 "register_operand" "f"))]
1279 "* return output_fp_compare (insn, operands, 0, 0);"
1280 [(set_attr "type" "multi")
1281 (set_attr "unit" "i387")
1282 (set_attr "mode" "XF")])
1284 (define_insn_and_split "*cmpfp_xf_cc"
1285 [(set (reg:CCFP FLAGS_REG)
1287 (match_operand:XF 1 "register_operand" "f")
1288 (match_operand:XF 2 "register_operand" "f")))
1289 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1291 && TARGET_SAHF && !TARGET_CMOVE"
1293 "&& reload_completed"
1296 [(compare:CCFP (match_dup 1)(match_dup 2))]
1298 (set (reg:CC FLAGS_REG)
1299 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1301 [(set_attr "type" "multi")
1302 (set_attr "unit" "i387")
1303 (set_attr "mode" "XF")])
1305 (define_insn "*cmpfp_<mode>"
1306 [(set (match_operand:HI 0 "register_operand" "=a")
1309 (match_operand:MODEF 1 "register_operand" "f")
1310 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1313 "* return output_fp_compare (insn, operands, 0, 0);"
1314 [(set_attr "type" "multi")
1315 (set_attr "unit" "i387")
1316 (set_attr "mode" "<MODE>")])
1318 (define_insn_and_split "*cmpfp_<mode>_cc"
1319 [(set (reg:CCFP FLAGS_REG)
1321 (match_operand:MODEF 1 "register_operand" "f")
1322 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1323 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1325 && TARGET_SAHF && !TARGET_CMOVE"
1327 "&& reload_completed"
1330 [(compare:CCFP (match_dup 1)(match_dup 2))]
1332 (set (reg:CC FLAGS_REG)
1333 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1335 [(set_attr "type" "multi")
1336 (set_attr "unit" "i387")
1337 (set_attr "mode" "<MODE>")])
1339 (define_insn "*cmpfp_u"
1340 [(set (match_operand:HI 0 "register_operand" "=a")
1343 (match_operand 1 "register_operand" "f")
1344 (match_operand 2 "register_operand" "f"))]
1346 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1347 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1348 "* return output_fp_compare (insn, operands, 0, 1);"
1349 [(set_attr "type" "multi")
1350 (set_attr "unit" "i387")
1352 (cond [(match_operand:SF 1 "" "")
1354 (match_operand:DF 1 "" "")
1357 (const_string "XF")))])
1359 (define_insn_and_split "*cmpfp_u_cc"
1360 [(set (reg:CCFPU FLAGS_REG)
1362 (match_operand 1 "register_operand" "f")
1363 (match_operand 2 "register_operand" "f")))
1364 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1365 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1366 && TARGET_SAHF && !TARGET_CMOVE
1367 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1369 "&& reload_completed"
1372 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1374 (set (reg:CC FLAGS_REG)
1375 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1377 [(set_attr "type" "multi")
1378 (set_attr "unit" "i387")
1380 (cond [(match_operand:SF 1 "" "")
1382 (match_operand:DF 1 "" "")
1385 (const_string "XF")))])
1387 (define_insn "*cmpfp_<mode>"
1388 [(set (match_operand:HI 0 "register_operand" "=a")
1391 (match_operand 1 "register_operand" "f")
1392 (match_operator 3 "float_operator"
1393 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1395 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1396 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1397 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1398 "* return output_fp_compare (insn, operands, 0, 0);"
1399 [(set_attr "type" "multi")
1400 (set_attr "unit" "i387")
1401 (set_attr "fp_int_src" "true")
1402 (set_attr "mode" "<MODE>")])
1404 (define_insn_and_split "*cmpfp_<mode>_cc"
1405 [(set (reg:CCFP FLAGS_REG)
1407 (match_operand 1 "register_operand" "f")
1408 (match_operator 3 "float_operator"
1409 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1410 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1411 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1412 && TARGET_SAHF && !TARGET_CMOVE
1413 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1414 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1416 "&& reload_completed"
1421 (match_op_dup 3 [(match_dup 2)]))]
1423 (set (reg:CC FLAGS_REG)
1424 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1426 [(set_attr "type" "multi")
1427 (set_attr "unit" "i387")
1428 (set_attr "fp_int_src" "true")
1429 (set_attr "mode" "<MODE>")])
1431 ;; FP compares, step 2
1432 ;; Move the fpsw to ax.
1434 (define_insn "x86_fnstsw_1"
1435 [(set (match_operand:HI 0 "register_operand" "=a")
1436 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1439 [(set (attr "length") (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1440 (set_attr "mode" "SI")
1441 (set_attr "unit" "i387")])
1443 ;; FP compares, step 3
1444 ;; Get ax into flags, general case.
1446 (define_insn "x86_sahf_1"
1447 [(set (reg:CC FLAGS_REG)
1448 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1452 #ifndef HAVE_AS_IX86_SAHF
1454 return ASM_BYTE "0x9e";
1459 [(set_attr "length" "1")
1460 (set_attr "athlon_decode" "vector")
1461 (set_attr "amdfam10_decode" "direct")
1462 (set_attr "bdver1_decode" "direct")
1463 (set_attr "mode" "SI")])
1465 ;; Pentium Pro can do steps 1 through 3 in one go.
1466 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1467 (define_insn "*cmpfp_i_mixed"
1468 [(set (reg:CCFP FLAGS_REG)
1469 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1470 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1471 "TARGET_MIX_SSE_I387
1472 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1473 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1474 "* return output_fp_compare (insn, operands, 1, 0);"
1475 [(set_attr "type" "fcmp,ssecomi")
1476 (set_attr "prefix" "orig,maybe_vex")
1478 (if_then_else (match_operand:SF 1 "" "")
1480 (const_string "DF")))
1481 (set (attr "prefix_rep")
1482 (if_then_else (eq_attr "type" "ssecomi")
1484 (const_string "*")))
1485 (set (attr "prefix_data16")
1486 (cond [(eq_attr "type" "fcmp")
1488 (eq_attr "mode" "DF")
1491 (const_string "0")))
1492 (set_attr "athlon_decode" "vector")
1493 (set_attr "amdfam10_decode" "direct")
1494 (set_attr "bdver1_decode" "double")])
1496 (define_insn "*cmpfp_i_sse"
1497 [(set (reg:CCFP FLAGS_REG)
1498 (compare:CCFP (match_operand 0 "register_operand" "x")
1499 (match_operand 1 "nonimmediate_operand" "xm")))]
1501 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1502 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1503 "* return output_fp_compare (insn, operands, 1, 0);"
1504 [(set_attr "type" "ssecomi")
1505 (set_attr "prefix" "maybe_vex")
1507 (if_then_else (match_operand:SF 1 "" "")
1509 (const_string "DF")))
1510 (set_attr "prefix_rep" "0")
1511 (set (attr "prefix_data16")
1512 (if_then_else (eq_attr "mode" "DF")
1514 (const_string "0")))
1515 (set_attr "athlon_decode" "vector")
1516 (set_attr "amdfam10_decode" "direct")
1517 (set_attr "bdver1_decode" "double")])
1519 (define_insn "*cmpfp_i_i387"
1520 [(set (reg:CCFP FLAGS_REG)
1521 (compare:CCFP (match_operand 0 "register_operand" "f")
1522 (match_operand 1 "register_operand" "f")))]
1523 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1525 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1526 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1527 "* return output_fp_compare (insn, operands, 1, 0);"
1528 [(set_attr "type" "fcmp")
1530 (cond [(match_operand:SF 1 "" "")
1532 (match_operand:DF 1 "" "")
1535 (const_string "XF")))
1536 (set_attr "athlon_decode" "vector")
1537 (set_attr "amdfam10_decode" "direct")
1538 (set_attr "bdver1_decode" "double")])
1540 (define_insn "*cmpfp_iu_mixed"
1541 [(set (reg:CCFPU FLAGS_REG)
1542 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1543 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1544 "TARGET_MIX_SSE_I387
1545 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1546 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1547 "* return output_fp_compare (insn, operands, 1, 1);"
1548 [(set_attr "type" "fcmp,ssecomi")
1549 (set_attr "prefix" "orig,maybe_vex")
1551 (if_then_else (match_operand:SF 1 "" "")
1553 (const_string "DF")))
1554 (set (attr "prefix_rep")
1555 (if_then_else (eq_attr "type" "ssecomi")
1557 (const_string "*")))
1558 (set (attr "prefix_data16")
1559 (cond [(eq_attr "type" "fcmp")
1561 (eq_attr "mode" "DF")
1564 (const_string "0")))
1565 (set_attr "athlon_decode" "vector")
1566 (set_attr "amdfam10_decode" "direct")
1567 (set_attr "bdver1_decode" "double")])
1569 (define_insn "*cmpfp_iu_sse"
1570 [(set (reg:CCFPU FLAGS_REG)
1571 (compare:CCFPU (match_operand 0 "register_operand" "x")
1572 (match_operand 1 "nonimmediate_operand" "xm")))]
1574 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1575 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1576 "* return output_fp_compare (insn, operands, 1, 1);"
1577 [(set_attr "type" "ssecomi")
1578 (set_attr "prefix" "maybe_vex")
1580 (if_then_else (match_operand:SF 1 "" "")
1582 (const_string "DF")))
1583 (set_attr "prefix_rep" "0")
1584 (set (attr "prefix_data16")
1585 (if_then_else (eq_attr "mode" "DF")
1587 (const_string "0")))
1588 (set_attr "athlon_decode" "vector")
1589 (set_attr "amdfam10_decode" "direct")
1590 (set_attr "bdver1_decode" "double")])
1592 (define_insn "*cmpfp_iu_387"
1593 [(set (reg:CCFPU FLAGS_REG)
1594 (compare:CCFPU (match_operand 0 "register_operand" "f")
1595 (match_operand 1 "register_operand" "f")))]
1596 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1598 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1599 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1600 "* return output_fp_compare (insn, operands, 1, 1);"
1601 [(set_attr "type" "fcmp")
1603 (cond [(match_operand:SF 1 "" "")
1605 (match_operand:DF 1 "" "")
1608 (const_string "XF")))
1609 (set_attr "athlon_decode" "vector")
1610 (set_attr "amdfam10_decode" "direct")
1611 (set_attr "bdver1_decode" "direct")])
1613 ;; Push/pop instructions.
1615 (define_insn "*push<mode>2"
1616 [(set (match_operand:DWI 0 "push_operand" "=<")
1617 (match_operand:DWI 1 "general_no_elim_operand" "riF*m"))]
1622 [(set (match_operand:TI 0 "push_operand" "")
1623 (match_operand:TI 1 "general_operand" ""))]
1624 "TARGET_64BIT && reload_completed
1625 && !SSE_REG_P (operands[1])"
1627 "ix86_split_long_move (operands); DONE;")
1629 (define_insn "*pushdi2_rex64"
1630 [(set (match_operand:DI 0 "push_operand" "=<,!<")
1631 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
1636 [(set_attr "type" "push,multi")
1637 (set_attr "mode" "DI")])
1639 ;; Convert impossible pushes of immediate to existing instructions.
1640 ;; First try to get scratch register and go through it. In case this
1641 ;; fails, push sign extended lower part first and then overwrite
1642 ;; upper part by 32bit move.
1644 [(match_scratch:DI 2 "r")
1645 (set (match_operand:DI 0 "push_operand" "")
1646 (match_operand:DI 1 "immediate_operand" ""))]
1647 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1648 && !x86_64_immediate_operand (operands[1], DImode)"
1649 [(set (match_dup 2) (match_dup 1))
1650 (set (match_dup 0) (match_dup 2))])
1652 ;; We need to define this as both peepholer and splitter for case
1653 ;; peephole2 pass is not run.
1654 ;; "&& 1" is needed to keep it from matching the previous pattern.
1656 [(set (match_operand:DI 0 "push_operand" "")
1657 (match_operand:DI 1 "immediate_operand" ""))]
1658 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1659 && !x86_64_immediate_operand (operands[1], DImode) && 1"
1660 [(set (match_dup 0) (match_dup 1))
1661 (set (match_dup 2) (match_dup 3))]
1663 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1665 operands[1] = gen_lowpart (DImode, operands[2]);
1666 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1671 [(set (match_operand:DI 0 "push_operand" "")
1672 (match_operand:DI 1 "immediate_operand" ""))]
1673 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
1674 ? epilogue_completed : reload_completed)
1675 && !symbolic_operand (operands[1], DImode)
1676 && !x86_64_immediate_operand (operands[1], DImode)"
1677 [(set (match_dup 0) (match_dup 1))
1678 (set (match_dup 2) (match_dup 3))]
1680 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1682 operands[1] = gen_lowpart (DImode, operands[2]);
1683 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1688 [(set (match_operand:DI 0 "push_operand" "")
1689 (match_operand:DI 1 "general_operand" ""))]
1690 "!TARGET_64BIT && reload_completed
1691 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
1693 "ix86_split_long_move (operands); DONE;")
1695 (define_insn "*pushsi2"
1696 [(set (match_operand:SI 0 "push_operand" "=<")
1697 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1700 [(set_attr "type" "push")
1701 (set_attr "mode" "SI")])
1703 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1704 ;; "push a byte/word". But actually we use pushl, which has the effect
1705 ;; of rounding the amount pushed up to a word.
1707 ;; For TARGET_64BIT we always round up to 8 bytes.
1708 (define_insn "*push<mode>2_rex64"
1709 [(set (match_operand:SWI124 0 "push_operand" "=X")
1710 (match_operand:SWI124 1 "nonmemory_no_elim_operand" "r<i>"))]
1713 [(set_attr "type" "push")
1714 (set_attr "mode" "DI")])
1716 (define_insn "*push<mode>2"
1717 [(set (match_operand:SWI12 0 "push_operand" "=X")
1718 (match_operand:SWI12 1 "nonmemory_no_elim_operand" "rn"))]
1721 [(set_attr "type" "push")
1722 (set_attr "mode" "SI")])
1724 (define_insn "*push<mode>2_prologue"
1725 [(set (match_operand:P 0 "push_operand" "=<")
1726 (match_operand:P 1 "general_no_elim_operand" "r<i>*m"))
1727 (clobber (mem:BLK (scratch)))]
1729 "push{<imodesuffix>}\t%1"
1730 [(set_attr "type" "push")
1731 (set_attr "mode" "<MODE>")])
1733 (define_insn "*pop<mode>1"
1734 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1735 (match_operand:P 1 "pop_operand" ">"))]
1737 "pop{<imodesuffix>}\t%0"
1738 [(set_attr "type" "pop")
1739 (set_attr "mode" "<MODE>")])
1741 (define_insn "*pop<mode>1_epilogue"
1742 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1743 (match_operand:P 1 "pop_operand" ">"))
1744 (clobber (mem:BLK (scratch)))]
1746 "pop{<imodesuffix>}\t%0"
1747 [(set_attr "type" "pop")
1748 (set_attr "mode" "<MODE>")])
1750 ;; Move instructions.
1752 (define_expand "movoi"
1753 [(set (match_operand:OI 0 "nonimmediate_operand" "")
1754 (match_operand:OI 1 "general_operand" ""))]
1756 "ix86_expand_move (OImode, operands); DONE;")
1758 (define_expand "movti"
1759 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1760 (match_operand:TI 1 "nonimmediate_operand" ""))]
1761 "TARGET_64BIT || TARGET_SSE"
1764 ix86_expand_move (TImode, operands);
1765 else if (push_operand (operands[0], TImode))
1766 ix86_expand_push (TImode, operands[1]);
1768 ix86_expand_vector_move (TImode, operands);
1772 ;; This expands to what emit_move_complex would generate if we didn't
1773 ;; have a movti pattern. Having this avoids problems with reload on
1774 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
1775 ;; to have around all the time.
1776 (define_expand "movcdi"
1777 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
1778 (match_operand:CDI 1 "general_operand" ""))]
1781 if (push_operand (operands[0], CDImode))
1782 emit_move_complex_push (CDImode, operands[0], operands[1]);
1784 emit_move_complex_parts (operands[0], operands[1]);
1788 (define_expand "mov<mode>"
1789 [(set (match_operand:SWI1248x 0 "nonimmediate_operand" "")
1790 (match_operand:SWI1248x 1 "general_operand" ""))]
1792 "ix86_expand_move (<MODE>mode, operands); DONE;")
1794 (define_insn "*mov<mode>_xor"
1795 [(set (match_operand:SWI48 0 "register_operand" "=r")
1796 (match_operand:SWI48 1 "const0_operand" ""))
1797 (clobber (reg:CC FLAGS_REG))]
1800 [(set_attr "type" "alu1")
1801 (set_attr "mode" "SI")
1802 (set_attr "length_immediate" "0")])
1804 (define_insn "*mov<mode>_or"
1805 [(set (match_operand:SWI48 0 "register_operand" "=r")
1806 (match_operand:SWI48 1 "const_int_operand" ""))
1807 (clobber (reg:CC FLAGS_REG))]
1809 && operands[1] == constm1_rtx"
1810 "or{<imodesuffix>}\t{%1, %0|%0, %1}"
1811 [(set_attr "type" "alu1")
1812 (set_attr "mode" "<MODE>")
1813 (set_attr "length_immediate" "1")])
1815 (define_insn "*movoi_internal_avx"
1816 [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
1817 (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
1818 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1820 switch (which_alternative)
1823 return "vxorps\t%0, %0, %0";
1826 if (misaligned_operand (operands[0], OImode)
1827 || misaligned_operand (operands[1], OImode))
1828 return "vmovdqu\t{%1, %0|%0, %1}";
1830 return "vmovdqa\t{%1, %0|%0, %1}";
1835 [(set_attr "type" "sselog1,ssemov,ssemov")
1836 (set_attr "prefix" "vex")
1837 (set_attr "mode" "OI")])
1839 (define_insn "*movti_internal_rex64"
1840 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
1841 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
1842 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1844 switch (which_alternative)
1850 if (get_attr_mode (insn) == MODE_V4SF)
1851 return "%vxorps\t%0, %d0";
1853 return "%vpxor\t%0, %d0";
1856 /* TDmode values are passed as TImode on the stack. Moving them
1857 to stack may result in unaligned memory access. */
1858 if (misaligned_operand (operands[0], TImode)
1859 || misaligned_operand (operands[1], TImode))
1861 if (get_attr_mode (insn) == MODE_V4SF)
1862 return "%vmovups\t{%1, %0|%0, %1}";
1864 return "%vmovdqu\t{%1, %0|%0, %1}";
1868 if (get_attr_mode (insn) == MODE_V4SF)
1869 return "%vmovaps\t{%1, %0|%0, %1}";
1871 return "%vmovdqa\t{%1, %0|%0, %1}";
1877 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
1878 (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
1880 (cond [(eq_attr "alternative" "2,3")
1882 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1884 (const_string "V4SF")
1885 (const_string "TI"))
1886 (eq_attr "alternative" "4")
1888 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1890 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1892 (const_string "V4SF")
1893 (const_string "TI"))]
1894 (const_string "DI")))])
1897 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1898 (match_operand:TI 1 "general_operand" ""))]
1900 && !SSE_REG_P (operands[0]) && !SSE_REG_P (operands[1])"
1902 "ix86_split_long_move (operands); DONE;")
1904 (define_insn "*movti_internal_sse"
1905 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
1906 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
1907 "TARGET_SSE && !TARGET_64BIT
1908 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1910 switch (which_alternative)
1913 if (get_attr_mode (insn) == MODE_V4SF)
1914 return "%vxorps\t%0, %d0";
1916 return "%vpxor\t%0, %d0";
1919 /* TDmode values are passed as TImode on the stack. Moving them
1920 to stack may result in unaligned memory access. */
1921 if (misaligned_operand (operands[0], TImode)
1922 || misaligned_operand (operands[1], TImode))
1924 if (get_attr_mode (insn) == MODE_V4SF)
1925 return "%vmovups\t{%1, %0|%0, %1}";
1927 return "%vmovdqu\t{%1, %0|%0, %1}";
1931 if (get_attr_mode (insn) == MODE_V4SF)
1932 return "%vmovaps\t{%1, %0|%0, %1}";
1934 return "%vmovdqa\t{%1, %0|%0, %1}";
1940 [(set_attr "type" "sselog1,ssemov,ssemov")
1941 (set_attr "prefix" "maybe_vex")
1943 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1944 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1946 (const_string "V4SF")
1947 (and (eq_attr "alternative" "2")
1948 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1950 (const_string "V4SF")]
1951 (const_string "TI")))])
1953 (define_insn "*movdi_internal_rex64"
1954 [(set (match_operand:DI 0 "nonimmediate_operand"
1955 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
1956 (match_operand:DI 1 "general_operand"
1957 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
1958 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1960 switch (get_attr_type (insn))
1963 if (SSE_REG_P (operands[0]))
1964 return "movq2dq\t{%1, %0|%0, %1}";
1966 return "movdq2q\t{%1, %0|%0, %1}";
1971 if (get_attr_mode (insn) == MODE_TI)
1972 return "vmovdqa\t{%1, %0|%0, %1}";
1974 return "vmovq\t{%1, %0|%0, %1}";
1977 if (get_attr_mode (insn) == MODE_TI)
1978 return "movdqa\t{%1, %0|%0, %1}";
1982 /* Moves from and into integer register is done using movd
1983 opcode with REX prefix. */
1984 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
1985 return "movd\t{%1, %0|%0, %1}";
1986 return "movq\t{%1, %0|%0, %1}";
1989 return "%vpxor\t%0, %d0";
1992 return "pxor\t%0, %0";
1998 return "lea{q}\t{%a1, %0|%0, %a1}";
2001 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2002 if (get_attr_mode (insn) == MODE_SI)
2003 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2004 else if (which_alternative == 2)
2005 return "movabs{q}\t{%1, %0|%0, %1}";
2007 return "mov{q}\t{%1, %0|%0, %1}";
2011 (cond [(eq_attr "alternative" "5")
2012 (const_string "mmx")
2013 (eq_attr "alternative" "6,7,8,9,10")
2014 (const_string "mmxmov")
2015 (eq_attr "alternative" "11")
2016 (const_string "sselog1")
2017 (eq_attr "alternative" "12,13,14,15,16")
2018 (const_string "ssemov")
2019 (eq_attr "alternative" "17,18")
2020 (const_string "ssecvt")
2021 (eq_attr "alternative" "4")
2022 (const_string "multi")
2023 (match_operand:DI 1 "pic_32bit_operand" "")
2024 (const_string "lea")
2026 (const_string "imov")))
2029 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2031 (const_string "*")))
2032 (set (attr "length_immediate")
2034 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2036 (const_string "*")))
2037 (set_attr "prefix_rex" "*,*,*,*,*,*,*,1,*,1,*,*,*,*,*,*,*,*,*")
2038 (set_attr "prefix_data16" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,1,*,*,*")
2039 (set (attr "prefix")
2040 (if_then_else (eq_attr "alternative" "11,12,13,14,15,16")
2041 (const_string "maybe_vex")
2042 (const_string "orig")))
2043 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2045 ;; Convert impossible stores of immediate to existing instructions.
2046 ;; First try to get scratch register and go through it. In case this
2047 ;; fails, move by 32bit parts.
2049 [(match_scratch:DI 2 "r")
2050 (set (match_operand:DI 0 "memory_operand" "")
2051 (match_operand:DI 1 "immediate_operand" ""))]
2052 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2053 && !x86_64_immediate_operand (operands[1], DImode)"
2054 [(set (match_dup 2) (match_dup 1))
2055 (set (match_dup 0) (match_dup 2))])
2057 ;; We need to define this as both peepholer and splitter for case
2058 ;; peephole2 pass is not run.
2059 ;; "&& 1" is needed to keep it from matching the previous pattern.
2061 [(set (match_operand:DI 0 "memory_operand" "")
2062 (match_operand:DI 1 "immediate_operand" ""))]
2063 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2064 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2065 [(set (match_dup 2) (match_dup 3))
2066 (set (match_dup 4) (match_dup 5))]
2067 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2070 [(set (match_operand:DI 0 "memory_operand" "")
2071 (match_operand:DI 1 "immediate_operand" ""))]
2072 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2073 ? epilogue_completed : reload_completed)
2074 && !symbolic_operand (operands[1], DImode)
2075 && !x86_64_immediate_operand (operands[1], DImode)"
2076 [(set (match_dup 2) (match_dup 3))
2077 (set (match_dup 4) (match_dup 5))]
2078 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2080 (define_insn "*movdi_internal"
2081 [(set (match_operand:DI 0 "nonimmediate_operand"
2082 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2083 (match_operand:DI 1 "general_operand"
2084 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2085 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2090 movq\t{%1, %0|%0, %1}
2091 movq\t{%1, %0|%0, %1}
2093 %vmovq\t{%1, %0|%0, %1}
2094 %vmovdqa\t{%1, %0|%0, %1}
2095 %vmovq\t{%1, %0|%0, %1}
2097 movlps\t{%1, %0|%0, %1}
2098 movaps\t{%1, %0|%0, %1}
2099 movlps\t{%1, %0|%0, %1}"
2100 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2101 (set (attr "prefix")
2102 (if_then_else (eq_attr "alternative" "5,6,7,8")
2103 (const_string "vex")
2104 (const_string "orig")))
2105 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2108 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2109 (match_operand:DI 1 "general_operand" ""))]
2110 "!TARGET_64BIT && reload_completed
2111 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))
2112 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
2114 "ix86_split_long_move (operands); DONE;")
2116 (define_insn "*movsi_internal"
2117 [(set (match_operand:SI 0 "nonimmediate_operand"
2118 "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
2119 (match_operand:SI 1 "general_operand"
2120 "g ,ri,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
2121 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2123 switch (get_attr_type (insn))
2126 if (get_attr_mode (insn) == MODE_TI)
2127 return "%vpxor\t%0, %d0";
2128 return "%vxorps\t%0, %d0";
2131 switch (get_attr_mode (insn))
2134 return "%vmovdqa\t{%1, %0|%0, %1}";
2136 return "%vmovaps\t{%1, %0|%0, %1}";
2138 return "%vmovd\t{%1, %0|%0, %1}";
2140 return "%vmovss\t{%1, %0|%0, %1}";
2146 return "pxor\t%0, %0";
2149 if (get_attr_mode (insn) == MODE_DI)
2150 return "movq\t{%1, %0|%0, %1}";
2151 return "movd\t{%1, %0|%0, %1}";
2154 return "lea{l}\t{%a1, %0|%0, %a1}";
2157 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2158 return "mov{l}\t{%1, %0|%0, %1}";
2162 (cond [(eq_attr "alternative" "2")
2163 (const_string "mmx")
2164 (eq_attr "alternative" "3,4,5")
2165 (const_string "mmxmov")
2166 (eq_attr "alternative" "6")
2167 (const_string "sselog1")
2168 (eq_attr "alternative" "7,8,9,10,11")
2169 (const_string "ssemov")
2170 (match_operand:DI 1 "pic_32bit_operand" "")
2171 (const_string "lea")
2173 (const_string "imov")))
2174 (set (attr "prefix")
2175 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
2176 (const_string "orig")
2177 (const_string "maybe_vex")))
2178 (set (attr "prefix_data16")
2179 (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
2181 (const_string "*")))
2183 (cond [(eq_attr "alternative" "2,3")
2185 (eq_attr "alternative" "6,7")
2187 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2188 (const_string "V4SF")
2189 (const_string "TI"))
2190 (and (eq_attr "alternative" "8,9,10,11")
2191 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
2194 (const_string "SI")))])
2196 (define_insn "*movhi_internal"
2197 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
2198 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
2199 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2201 switch (get_attr_type (insn))
2204 /* movzwl is faster than movw on p2 due to partial word stalls,
2205 though not as fast as an aligned movl. */
2206 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
2208 if (get_attr_mode (insn) == MODE_SI)
2209 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2211 return "mov{w}\t{%1, %0|%0, %1}";
2215 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
2217 (const_string "imov")
2218 (and (eq_attr "alternative" "0")
2219 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2221 (eq (symbol_ref "TARGET_HIMODE_MATH")
2223 (const_string "imov")
2224 (and (eq_attr "alternative" "1,2")
2225 (match_operand:HI 1 "aligned_operand" ""))
2226 (const_string "imov")
2227 (and (ne (symbol_ref "TARGET_MOVX")
2229 (eq_attr "alternative" "0,2"))
2230 (const_string "imovx")
2232 (const_string "imov")))
2234 (cond [(eq_attr "type" "imovx")
2236 (and (eq_attr "alternative" "1,2")
2237 (match_operand:HI 1 "aligned_operand" ""))
2239 (and (eq_attr "alternative" "0")
2240 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2242 (eq (symbol_ref "TARGET_HIMODE_MATH")
2246 (const_string "HI")))])
2248 ;; Situation is quite tricky about when to choose full sized (SImode) move
2249 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
2250 ;; partial register dependency machines (such as AMD Athlon), where QImode
2251 ;; moves issue extra dependency and for partial register stalls machines
2252 ;; that don't use QImode patterns (and QImode move cause stall on the next
2255 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2256 ;; register stall machines with, where we use QImode instructions, since
2257 ;; partial register stall can be caused there. Then we use movzx.
2258 (define_insn "*movqi_internal"
2259 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2260 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
2261 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2263 switch (get_attr_type (insn))
2266 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2267 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2269 if (get_attr_mode (insn) == MODE_SI)
2270 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2272 return "mov{b}\t{%1, %0|%0, %1}";
2276 (cond [(and (eq_attr "alternative" "5")
2277 (not (match_operand:QI 1 "aligned_operand" "")))
2278 (const_string "imovx")
2279 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2281 (const_string "imov")
2282 (and (eq_attr "alternative" "3")
2283 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2285 (eq (symbol_ref "TARGET_QIMODE_MATH")
2287 (const_string "imov")
2288 (eq_attr "alternative" "3,5")
2289 (const_string "imovx")
2290 (and (ne (symbol_ref "TARGET_MOVX")
2292 (eq_attr "alternative" "2"))
2293 (const_string "imovx")
2295 (const_string "imov")))
2297 (cond [(eq_attr "alternative" "3,4,5")
2299 (eq_attr "alternative" "6")
2301 (eq_attr "type" "imovx")
2303 (and (eq_attr "type" "imov")
2304 (and (eq_attr "alternative" "0,1")
2305 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2307 (and (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2309 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2312 ;; Avoid partial register stalls when not using QImode arithmetic
2313 (and (eq_attr "type" "imov")
2314 (and (eq_attr "alternative" "0,1")
2315 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2317 (eq (symbol_ref "TARGET_QIMODE_MATH")
2321 (const_string "QI")))])
2323 ;; Stores and loads of ax to arbitrary constant address.
2324 ;; We fake an second form of instruction to force reload to load address
2325 ;; into register when rax is not available
2326 (define_insn "*movabs<mode>_1"
2327 [(set (mem:SWI1248x (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2328 (match_operand:SWI1248x 1 "nonmemory_operand" "a,er"))]
2329 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2331 movabs{<imodesuffix>}\t{%1, %P0|%P0, %1}
2332 mov{<imodesuffix>}\t{%1, %a0|%a0, %1}"
2333 [(set_attr "type" "imov")
2334 (set_attr "modrm" "0,*")
2335 (set_attr "length_address" "8,0")
2336 (set_attr "length_immediate" "0,*")
2337 (set_attr "memory" "store")
2338 (set_attr "mode" "<MODE>")])
2340 (define_insn "*movabs<mode>_2"
2341 [(set (match_operand:SWI1248x 0 "register_operand" "=a,r")
2342 (mem:SWI1248x (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2343 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2345 movabs{<imodesuffix>}\t{%P1, %0|%0, %P1}
2346 mov{<imodesuffix>}\t{%a1, %0|%0, %a1}"
2347 [(set_attr "type" "imov")
2348 (set_attr "modrm" "0,*")
2349 (set_attr "length_address" "8,0")
2350 (set_attr "length_immediate" "0")
2351 (set_attr "memory" "load")
2352 (set_attr "mode" "<MODE>")])
2354 (define_insn "*swap<mode>"
2355 [(set (match_operand:SWI48 0 "register_operand" "+r")
2356 (match_operand:SWI48 1 "register_operand" "+r"))
2360 "xchg{<imodesuffix>}\t%1, %0"
2361 [(set_attr "type" "imov")
2362 (set_attr "mode" "<MODE>")
2363 (set_attr "pent_pair" "np")
2364 (set_attr "athlon_decode" "vector")
2365 (set_attr "amdfam10_decode" "double")
2366 (set_attr "bdver1_decode" "double")])
2368 (define_insn "*swap<mode>_1"
2369 [(set (match_operand:SWI12 0 "register_operand" "+r")
2370 (match_operand:SWI12 1 "register_operand" "+r"))
2373 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2375 [(set_attr "type" "imov")
2376 (set_attr "mode" "SI")
2377 (set_attr "pent_pair" "np")
2378 (set_attr "athlon_decode" "vector")
2379 (set_attr "amdfam10_decode" "double")
2380 (set_attr "bdver1_decode" "double")])
2382 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL
2383 ;; is disabled for AMDFAM10
2384 (define_insn "*swap<mode>_2"
2385 [(set (match_operand:SWI12 0 "register_operand" "+<r>")
2386 (match_operand:SWI12 1 "register_operand" "+<r>"))
2389 "TARGET_PARTIAL_REG_STALL"
2390 "xchg{<imodesuffix>}\t%1, %0"
2391 [(set_attr "type" "imov")
2392 (set_attr "mode" "<MODE>")
2393 (set_attr "pent_pair" "np")
2394 (set_attr "athlon_decode" "vector")])
2396 (define_expand "movstrict<mode>"
2397 [(set (strict_low_part (match_operand:SWI12 0 "nonimmediate_operand" ""))
2398 (match_operand:SWI12 1 "general_operand" ""))]
2401 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2403 /* Don't generate memory->memory moves, go through a register */
2404 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2405 operands[1] = force_reg (<MODE>mode, operands[1]);
2408 (define_insn "*movstrict<mode>_1"
2409 [(set (strict_low_part
2410 (match_operand:SWI12 0 "nonimmediate_operand" "+<r>m,<r>"))
2411 (match_operand:SWI12 1 "general_operand" "<r>n,m"))]
2412 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2413 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2414 "mov{<imodesuffix>}\t{%1, %0|%0, %1}"
2415 [(set_attr "type" "imov")
2416 (set_attr "mode" "<MODE>")])
2418 (define_insn "*movstrict<mode>_xor"
2419 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
2420 (match_operand:SWI12 1 "const0_operand" ""))
2421 (clobber (reg:CC FLAGS_REG))]
2423 "xor{<imodesuffix>}\t%0, %0"
2424 [(set_attr "type" "alu1")
2425 (set_attr "mode" "<MODE>")
2426 (set_attr "length_immediate" "0")])
2428 (define_insn "*mov<mode>_extv_1"
2429 [(set (match_operand:SWI24 0 "register_operand" "=R")
2430 (sign_extract:SWI24 (match_operand 1 "ext_register_operand" "Q")
2434 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2435 [(set_attr "type" "imovx")
2436 (set_attr "mode" "SI")])
2438 (define_insn "*movqi_extv_1_rex64"
2439 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2440 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2445 switch (get_attr_type (insn))
2448 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2450 return "mov{b}\t{%h1, %0|%0, %h1}";
2454 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2455 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2456 (ne (symbol_ref "TARGET_MOVX")
2458 (const_string "imovx")
2459 (const_string "imov")))
2461 (if_then_else (eq_attr "type" "imovx")
2463 (const_string "QI")))])
2465 (define_insn "*movqi_extv_1"
2466 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2467 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2472 switch (get_attr_type (insn))
2475 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2477 return "mov{b}\t{%h1, %0|%0, %h1}";
2481 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2482 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2483 (ne (symbol_ref "TARGET_MOVX")
2485 (const_string "imovx")
2486 (const_string "imov")))
2488 (if_then_else (eq_attr "type" "imovx")
2490 (const_string "QI")))])
2492 (define_insn "*mov<mode>_extzv_1"
2493 [(set (match_operand:SWI48 0 "register_operand" "=R")
2494 (zero_extract:SWI48 (match_operand 1 "ext_register_operand" "Q")
2498 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2499 [(set_attr "type" "imovx")
2500 (set_attr "mode" "SI")])
2502 (define_insn "*movqi_extzv_2_rex64"
2503 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2505 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2510 switch (get_attr_type (insn))
2513 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2515 return "mov{b}\t{%h1, %0|%0, %h1}";
2519 (if_then_else (ior (not (match_operand:QI 0 "q_regs_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 "*movqi_extzv_2"
2530 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2532 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2537 switch (get_attr_type (insn))
2540 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2542 return "mov{b}\t{%h1, %0|%0, %h1}";
2546 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2547 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2548 (ne (symbol_ref "TARGET_MOVX")
2550 (const_string "imovx")
2551 (const_string "imov")))
2553 (if_then_else (eq_attr "type" "imovx")
2555 (const_string "QI")))])
2557 (define_expand "mov<mode>_insv_1"
2558 [(set (zero_extract:SWI48 (match_operand 0 "ext_register_operand" "")
2561 (match_operand:SWI48 1 "nonmemory_operand" ""))])
2563 (define_insn "*mov<mode>_insv_1_rex64"
2564 [(set (zero_extract:SWI48x (match_operand 0 "ext_register_operand" "+Q")
2567 (match_operand:SWI48x 1 "nonmemory_operand" "Qn"))]
2569 "mov{b}\t{%b1, %h0|%h0, %b1}"
2570 [(set_attr "type" "imov")
2571 (set_attr "mode" "QI")])
2573 (define_insn "*movsi_insv_1"
2574 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2577 (match_operand:SI 1 "general_operand" "Qmn"))]
2579 "mov{b}\t{%b1, %h0|%h0, %b1}"
2580 [(set_attr "type" "imov")
2581 (set_attr "mode" "QI")])
2583 (define_insn "*movqi_insv_2"
2584 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2587 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2590 "mov{b}\t{%h1, %h0|%h0, %h1}"
2591 [(set_attr "type" "imov")
2592 (set_attr "mode" "QI")])
2594 ;; Floating point push instructions.
2596 (define_insn "*pushtf"
2597 [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2598 (match_operand:TF 1 "general_no_elim_operand" "x,Fo,*r"))]
2601 /* This insn should be already split before reg-stack. */
2604 [(set_attr "type" "multi")
2605 (set_attr "unit" "sse,*,*")
2606 (set_attr "mode" "TF,SI,SI")])
2609 [(set (match_operand:TF 0 "push_operand" "")
2610 (match_operand:TF 1 "sse_reg_operand" ""))]
2611 "TARGET_SSE2 && reload_completed"
2612 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
2613 (set (mem:TF (reg:P SP_REG)) (match_dup 1))])
2616 [(set (match_operand:TF 0 "push_operand" "")
2617 (match_operand:TF 1 "general_operand" ""))]
2618 "TARGET_SSE2 && reload_completed
2619 && !SSE_REG_P (operands[1])"
2621 "ix86_split_long_move (operands); DONE;")
2623 (define_insn "*pushxf"
2624 [(set (match_operand:XF 0 "push_operand" "=<,<")
2625 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
2626 "optimize_function_for_speed_p (cfun)"
2628 /* This insn should be already split before reg-stack. */
2631 [(set_attr "type" "multi")
2632 (set_attr "unit" "i387,*")
2633 (set_attr "mode" "XF,SI")])
2635 ;; Size of pushxf is 3 (for sub) + 2 (for fstp) + memory operand size.
2636 ;; Size of pushxf using integer instructions is 3+3*memory operand size
2637 ;; Pushing using integer instructions is longer except for constants
2638 ;; and direct memory references (assuming that any given constant is pushed
2639 ;; only once, but this ought to be handled elsewhere).
2641 (define_insn "*pushxf_nointeger"
2642 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
2643 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
2644 "optimize_function_for_size_p (cfun)"
2646 /* This insn should be already split before reg-stack. */
2649 [(set_attr "type" "multi")
2650 (set_attr "unit" "i387,*,*")
2651 (set_attr "mode" "XF,SI,SI")])
2654 [(set (match_operand:XF 0 "push_operand" "")
2655 (match_operand:XF 1 "fp_register_operand" ""))]
2657 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2658 (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
2659 "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
2662 [(set (match_operand:XF 0 "push_operand" "")
2663 (match_operand:XF 1 "general_operand" ""))]
2665 && !FP_REG_P (operands[1])"
2667 "ix86_split_long_move (operands); DONE;")
2669 (define_insn "*pushdf"
2670 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2671 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
2672 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2674 /* This insn should be already split before reg-stack. */
2677 [(set_attr "type" "multi")
2678 (set_attr "unit" "i387,*,*")
2679 (set_attr "mode" "DF,SI,DF")])
2681 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2682 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2683 ;; On the average, pushdf using integers can be still shorter. Allow this
2684 ;; pattern for optimize_size too.
2686 (define_insn "*pushdf_nointeger"
2687 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2688 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
2689 "!(TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES)"
2691 /* This insn should be already split before reg-stack. */
2694 [(set_attr "type" "multi")
2695 (set_attr "unit" "i387,*,*,*")
2696 (set_attr "mode" "DF,SI,SI,DF")])
2698 ;; %%% Kill this when call knows how to work this out.
2700 [(set (match_operand:DF 0 "push_operand" "")
2701 (match_operand:DF 1 "any_fp_register_operand" ""))]
2703 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
2704 (set (mem:DF (reg:P SP_REG)) (match_dup 1))])
2707 [(set (match_operand:DF 0 "push_operand" "")
2708 (match_operand:DF 1 "general_operand" ""))]
2710 && !ANY_FP_REG_P (operands[1])"
2712 "ix86_split_long_move (operands); DONE;")
2714 (define_insn "*pushsf_rex64"
2715 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2716 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2719 /* Anything else should be already split before reg-stack. */
2720 gcc_assert (which_alternative == 1);
2721 return "push{q}\t%q1";
2723 [(set_attr "type" "multi,push,multi")
2724 (set_attr "unit" "i387,*,*")
2725 (set_attr "mode" "SF,DI,SF")])
2727 (define_insn "*pushsf"
2728 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2729 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2732 /* Anything else should be already split before reg-stack. */
2733 gcc_assert (which_alternative == 1);
2734 return "push{l}\t%1";
2736 [(set_attr "type" "multi,push,multi")
2737 (set_attr "unit" "i387,*,*")
2738 (set_attr "mode" "SF,SI,SF")])
2741 [(set (match_operand:SF 0 "push_operand" "")
2742 (match_operand:SF 1 "memory_operand" ""))]
2744 && MEM_P (operands[1])
2745 && (operands[2] = find_constant_src (insn))"
2749 ;; %%% Kill this when call knows how to work this out.
2751 [(set (match_operand:SF 0 "push_operand" "")
2752 (match_operand:SF 1 "any_fp_register_operand" ""))]
2754 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2755 (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
2756 "operands[2] = GEN_INT (-GET_MODE_SIZE (<MODE>mode));")
2758 ;; Floating point move instructions.
2760 (define_expand "movtf"
2761 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2762 (match_operand:TF 1 "nonimmediate_operand" ""))]
2765 ix86_expand_move (TFmode, operands);
2769 (define_expand "mov<mode>"
2770 [(set (match_operand:X87MODEF 0 "nonimmediate_operand" "")
2771 (match_operand:X87MODEF 1 "general_operand" ""))]
2773 "ix86_expand_move (<MODE>mode, operands); DONE;")
2775 (define_insn "*movtf_internal"
2776 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?r,?o")
2777 (match_operand:TF 1 "general_operand" "xm,x,C,roF,Fr"))]
2779 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2781 switch (which_alternative)
2785 if (get_attr_mode (insn) == MODE_V4SF)
2786 return "%vmovaps\t{%1, %0|%0, %1}";
2788 return "%vmovdqa\t{%1, %0|%0, %1}";
2790 if (get_attr_mode (insn) == MODE_V4SF)
2791 return "%vxorps\t%0, %d0";
2793 return "%vpxor\t%0, %d0";
2801 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
2802 (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,*,*")
2804 (cond [(eq_attr "alternative" "0,2")
2806 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2808 (const_string "V4SF")
2809 (const_string "TI"))
2810 (eq_attr "alternative" "1")
2812 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2814 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2816 (const_string "V4SF")
2817 (const_string "TI"))]
2818 (const_string "DI")))])
2821 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2822 (match_operand:TF 1 "general_operand" ""))]
2824 && !(SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]))"
2826 "ix86_split_long_move (operands); DONE;")
2828 (define_insn "*movxf_internal"
2829 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,r,o")
2830 (match_operand:XF 1 "general_operand" "fm,f,G,roF,Fr"))]
2831 "optimize_function_for_speed_p (cfun)
2832 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2833 && (reload_in_progress || reload_completed
2834 || GET_CODE (operands[1]) != CONST_DOUBLE
2835 || memory_operand (operands[0], XFmode))"
2837 switch (which_alternative)
2841 return output_387_reg_move (insn, operands);
2844 return standard_80387_constant_opcode (operands[1]);
2853 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2854 (set_attr "mode" "XF,XF,XF,SI,SI")])
2856 ;; Do not use integer registers when optimizing for size
2857 (define_insn "*movxf_internal_nointeger"
2858 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2859 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2860 "optimize_function_for_size_p (cfun)
2861 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2862 && (reload_in_progress || reload_completed
2863 || standard_80387_constant_p (operands[1])
2864 || GET_CODE (operands[1]) != CONST_DOUBLE
2865 || memory_operand (operands[0], XFmode))"
2867 switch (which_alternative)
2871 return output_387_reg_move (insn, operands);
2874 return standard_80387_constant_opcode (operands[1]);
2882 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2883 (set_attr "mode" "XF,XF,XF,SI,SI")])
2886 [(set (match_operand:XF 0 "nonimmediate_operand" "")
2887 (match_operand:XF 1 "general_operand" ""))]
2889 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2890 && ! (FP_REG_P (operands[0]) ||
2891 (GET_CODE (operands[0]) == SUBREG
2892 && FP_REG_P (SUBREG_REG (operands[0]))))
2893 && ! (FP_REG_P (operands[1]) ||
2894 (GET_CODE (operands[1]) == SUBREG
2895 && FP_REG_P (SUBREG_REG (operands[1]))))"
2897 "ix86_split_long_move (operands); DONE;")
2899 (define_insn "*movdf_internal_rex64"
2900 [(set (match_operand:DF 0 "nonimmediate_operand"
2901 "=f,m,f,r ,m ,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
2902 (match_operand:DF 1 "general_operand"
2903 "fm,f,G,rmF,Fr,C ,Y2*x,m ,Y2*x,r ,Yi"))]
2904 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2905 && (reload_in_progress || reload_completed
2906 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2907 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
2908 && optimize_function_for_size_p (cfun)
2909 && standard_80387_constant_p (operands[1]))
2910 || GET_CODE (operands[1]) != CONST_DOUBLE
2911 || memory_operand (operands[0], DFmode))"
2913 switch (which_alternative)
2917 return output_387_reg_move (insn, operands);
2920 return standard_80387_constant_opcode (operands[1]);
2927 switch (get_attr_mode (insn))
2930 return "%vxorps\t%0, %d0";
2932 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2933 return "%vxorps\t%0, %d0";
2935 return "%vxorpd\t%0, %d0";
2937 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2938 return "%vxorps\t%0, %d0";
2940 return "%vpxor\t%0, %d0";
2947 switch (get_attr_mode (insn))
2950 return "%vmovaps\t{%1, %0|%0, %1}";
2952 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2953 return "%vmovaps\t{%1, %0|%0, %1}";
2955 return "%vmovapd\t{%1, %0|%0, %1}";
2957 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2958 return "%vmovaps\t{%1, %0|%0, %1}";
2960 return "%vmovdqa\t{%1, %0|%0, %1}";
2962 return "%vmovq\t{%1, %0|%0, %1}";
2966 if (REG_P (operands[0]) && REG_P (operands[1]))
2967 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
2969 return "vmovsd\t{%1, %0|%0, %1}";
2972 return "movsd\t{%1, %0|%0, %1}";
2974 return "%vmovlpd\t{%1, %d0|%d0, %1}";
2976 return "%vmovlps\t{%1, %d0|%d0, %1}";
2983 return "%vmovd\t{%1, %0|%0, %1}";
2989 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
2990 (set (attr "prefix")
2991 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
2992 (const_string "orig")
2993 (const_string "maybe_vex")))
2994 (set (attr "prefix_data16")
2995 (if_then_else (eq_attr "mode" "V1DF")
2997 (const_string "*")))
2999 (cond [(eq_attr "alternative" "0,1,2")
3001 (eq_attr "alternative" "3,4,9,10")
3004 /* For SSE1, we have many fewer alternatives. */
3005 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3006 (cond [(eq_attr "alternative" "5,6")
3007 (const_string "V4SF")
3009 (const_string "V2SF"))
3011 /* xorps is one byte shorter. */
3012 (eq_attr "alternative" "5")
3013 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3015 (const_string "V4SF")
3016 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3020 (const_string "V2DF"))
3022 /* For architectures resolving dependencies on
3023 whole SSE registers use APD move to break dependency
3024 chains, otherwise use short move to avoid extra work.
3026 movaps encodes one byte shorter. */
3027 (eq_attr "alternative" "6")
3029 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3031 (const_string "V4SF")
3032 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3034 (const_string "V2DF")
3036 (const_string "DF"))
3037 /* For architectures resolving dependencies on register
3038 parts we may avoid extra work to zero out upper part
3040 (eq_attr "alternative" "7")
3042 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3044 (const_string "V1DF")
3045 (const_string "DF"))
3047 (const_string "DF")))])
3049 (define_insn "*movdf_internal"
3050 [(set (match_operand:DF 0 "nonimmediate_operand"
3051 "=f,m,f,r ,o ,Y2*x,Y2*x,Y2*x,m ")
3052 (match_operand:DF 1 "general_operand"
3053 "fm,f,G,roF,Fr,C ,Y2*x,m ,Y2*x"))]
3054 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3055 && optimize_function_for_speed_p (cfun)
3056 && TARGET_INTEGER_DFMODE_MOVES
3057 && (reload_in_progress || reload_completed
3058 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3059 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3060 && optimize_function_for_size_p (cfun)
3061 && standard_80387_constant_p (operands[1]))
3062 || GET_CODE (operands[1]) != CONST_DOUBLE
3063 || memory_operand (operands[0], DFmode))"
3065 switch (which_alternative)
3069 return output_387_reg_move (insn, operands);
3072 return standard_80387_constant_opcode (operands[1]);
3079 switch (get_attr_mode (insn))
3082 return "xorps\t%0, %0";
3084 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3085 return "xorps\t%0, %0";
3087 return "xorpd\t%0, %0";
3089 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3090 return "xorps\t%0, %0";
3092 return "pxor\t%0, %0";
3099 switch (get_attr_mode (insn))
3102 return "movaps\t{%1, %0|%0, %1}";
3104 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3105 return "movaps\t{%1, %0|%0, %1}";
3107 return "movapd\t{%1, %0|%0, %1}";
3109 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3110 return "movaps\t{%1, %0|%0, %1}";
3112 return "movdqa\t{%1, %0|%0, %1}";
3114 return "movq\t{%1, %0|%0, %1}";
3116 return "movsd\t{%1, %0|%0, %1}";
3118 return "movlpd\t{%1, %0|%0, %1}";
3120 return "movlps\t{%1, %0|%0, %1}";
3129 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3130 (set (attr "prefix_data16")
3131 (if_then_else (eq_attr "mode" "V1DF")
3133 (const_string "*")))
3135 (cond [(eq_attr "alternative" "0,1,2")
3137 (eq_attr "alternative" "3,4")
3140 /* For SSE1, we have many fewer alternatives. */
3141 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3142 (cond [(eq_attr "alternative" "5,6")
3143 (const_string "V4SF")
3145 (const_string "V2SF"))
3147 /* xorps is one byte shorter. */
3148 (eq_attr "alternative" "5")
3149 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3151 (const_string "V4SF")
3152 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3156 (const_string "V2DF"))
3158 /* For architectures resolving dependencies on
3159 whole SSE registers use APD move to break dependency
3160 chains, otherwise use short move to avoid extra work.
3162 movaps encodes one byte shorter. */
3163 (eq_attr "alternative" "6")
3165 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3167 (const_string "V4SF")
3168 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3170 (const_string "V2DF")
3172 (const_string "DF"))
3173 /* For architectures resolving dependencies on register
3174 parts we may avoid extra work to zero out upper part
3176 (eq_attr "alternative" "7")
3178 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3180 (const_string "V1DF")
3181 (const_string "DF"))
3183 (const_string "DF")))])
3185 ;; Moving is usually shorter when only FP registers are used. This separate
3186 ;; movdf pattern avoids the use of integer registers for FP operations
3187 ;; when optimizing for size.
3189 (define_insn "*movdf_internal_nointeger"
3190 [(set (match_operand:DF 0 "nonimmediate_operand"
3191 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
3192 (match_operand:DF 1 "general_operand"
3193 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
3194 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3195 && ((optimize_function_for_size_p (cfun)
3196 || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
3197 && (reload_in_progress || reload_completed
3198 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3199 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3200 && optimize_function_for_size_p (cfun)
3201 && !memory_operand (operands[0], DFmode)
3202 && standard_80387_constant_p (operands[1]))
3203 || GET_CODE (operands[1]) != CONST_DOUBLE
3204 || ((optimize_function_for_size_p (cfun)
3205 || !TARGET_MEMORY_MISMATCH_STALL
3206 || reload_in_progress || reload_completed)
3207 && memory_operand (operands[0], DFmode)))"
3209 switch (which_alternative)
3213 return output_387_reg_move (insn, operands);
3216 return standard_80387_constant_opcode (operands[1]);
3223 switch (get_attr_mode (insn))
3226 return "%vxorps\t%0, %d0";
3228 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3229 return "%vxorps\t%0, %d0";
3231 return "%vxorpd\t%0, %d0";
3233 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3234 return "%vxorps\t%0, %d0";
3236 return "%vpxor\t%0, %d0";
3243 switch (get_attr_mode (insn))
3246 return "%vmovaps\t{%1, %0|%0, %1}";
3248 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3249 return "%vmovaps\t{%1, %0|%0, %1}";
3251 return "%vmovapd\t{%1, %0|%0, %1}";
3253 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3254 return "%vmovaps\t{%1, %0|%0, %1}";
3256 return "%vmovdqa\t{%1, %0|%0, %1}";
3258 return "%vmovq\t{%1, %0|%0, %1}";
3262 if (REG_P (operands[0]) && REG_P (operands[1]))
3263 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3265 return "vmovsd\t{%1, %0|%0, %1}";
3268 return "movsd\t{%1, %0|%0, %1}";
3272 if (REG_P (operands[0]))
3273 return "vmovlpd\t{%1, %0, %0|%0, %0, %1}";
3275 return "vmovlpd\t{%1, %0|%0, %1}";
3278 return "movlpd\t{%1, %0|%0, %1}";
3282 if (REG_P (operands[0]))
3283 return "vmovlps\t{%1, %0, %0|%0, %0, %1}";
3285 return "vmovlps\t{%1, %0|%0, %1}";
3288 return "movlps\t{%1, %0|%0, %1}";
3297 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3298 (set (attr "prefix")
3299 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3300 (const_string "orig")
3301 (const_string "maybe_vex")))
3302 (set (attr "prefix_data16")
3303 (if_then_else (eq_attr "mode" "V1DF")
3305 (const_string "*")))
3307 (cond [(eq_attr "alternative" "0,1,2")
3309 (eq_attr "alternative" "3,4")
3312 /* For SSE1, we have many fewer alternatives. */
3313 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3314 (cond [(eq_attr "alternative" "5,6")
3315 (const_string "V4SF")
3317 (const_string "V2SF"))
3319 /* xorps is one byte shorter. */
3320 (eq_attr "alternative" "5")
3321 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3323 (const_string "V4SF")
3324 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3328 (const_string "V2DF"))
3330 /* For architectures resolving dependencies on
3331 whole SSE registers use APD move to break dependency
3332 chains, otherwise use short move to avoid extra work.
3334 movaps encodes one byte shorter. */
3335 (eq_attr "alternative" "6")
3337 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3339 (const_string "V4SF")
3340 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3342 (const_string "V2DF")
3344 (const_string "DF"))
3345 /* For architectures resolving dependencies on register
3346 parts we may avoid extra work to zero out upper part
3348 (eq_attr "alternative" "7")
3350 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3352 (const_string "V1DF")
3353 (const_string "DF"))
3355 (const_string "DF")))])
3358 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3359 (match_operand:DF 1 "general_operand" ""))]
3361 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3362 && ! (ANY_FP_REG_P (operands[0]) ||
3363 (GET_CODE (operands[0]) == SUBREG
3364 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3365 && ! (ANY_FP_REG_P (operands[1]) ||
3366 (GET_CODE (operands[1]) == SUBREG
3367 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3369 "ix86_split_long_move (operands); DONE;")
3371 (define_insn "*movsf_internal"
3372 [(set (match_operand:SF 0 "nonimmediate_operand"
3373 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
3374 (match_operand:SF 1 "general_operand"
3375 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
3376 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3377 && (reload_in_progress || reload_completed
3378 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3379 || (!TARGET_SSE_MATH && optimize_function_for_size_p (cfun)
3380 && standard_80387_constant_p (operands[1]))
3381 || GET_CODE (operands[1]) != CONST_DOUBLE
3382 || memory_operand (operands[0], SFmode))"
3384 switch (which_alternative)
3388 return output_387_reg_move (insn, operands);
3391 return standard_80387_constant_opcode (operands[1]);
3395 return "mov{l}\t{%1, %0|%0, %1}";
3397 if (get_attr_mode (insn) == MODE_TI)
3398 return "%vpxor\t%0, %d0";
3400 return "%vxorps\t%0, %d0";
3402 if (get_attr_mode (insn) == MODE_V4SF)
3403 return "%vmovaps\t{%1, %0|%0, %1}";
3405 return "%vmovss\t{%1, %d0|%d0, %1}";
3408 return REG_P (operands[1]) ? "vmovss\t{%1, %0, %0|%0, %0, %1}"
3409 : "vmovss\t{%1, %0|%0, %1}";
3411 return "movss\t{%1, %0|%0, %1}";
3413 return "%vmovss\t{%1, %0|%0, %1}";
3415 case 9: case 10: case 14: case 15:
3416 return "movd\t{%1, %0|%0, %1}";
3418 return "%vmovd\t{%1, %0|%0, %1}";
3421 return "movq\t{%1, %0|%0, %1}";
3427 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
3428 (set (attr "prefix")
3429 (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
3430 (const_string "maybe_vex")
3431 (const_string "orig")))
3433 (cond [(eq_attr "alternative" "3,4,9,10")
3435 (eq_attr "alternative" "5")
3437 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3439 (ne (symbol_ref "TARGET_SSE2")
3441 (eq (symbol_ref "optimize_function_for_size_p (cfun)")
3444 (const_string "V4SF"))
3445 /* For architectures resolving dependencies on
3446 whole SSE registers use APS move to break dependency
3447 chains, otherwise use short move to avoid extra work.
3449 Do the same for architectures resolving dependencies on
3450 the parts. While in DF mode it is better to always handle
3451 just register parts, the SF mode is different due to lack
3452 of instructions to load just part of the register. It is
3453 better to maintain the whole registers in single format
3454 to avoid problems on using packed logical operations. */
3455 (eq_attr "alternative" "6")
3457 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3459 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3461 (const_string "V4SF")
3462 (const_string "SF"))
3463 (eq_attr "alternative" "11")
3464 (const_string "DI")]
3465 (const_string "SF")))])
3468 [(set (match_operand 0 "register_operand" "")
3469 (match_operand 1 "memory_operand" ""))]
3471 && MEM_P (operands[1])
3472 && (GET_MODE (operands[0]) == TFmode
3473 || GET_MODE (operands[0]) == XFmode
3474 || GET_MODE (operands[0]) == DFmode
3475 || GET_MODE (operands[0]) == SFmode)
3476 && (operands[2] = find_constant_src (insn))"
3477 [(set (match_dup 0) (match_dup 2))]
3479 rtx c = operands[2];
3480 rtx r = operands[0];
3482 if (GET_CODE (r) == SUBREG)
3487 if (!standard_sse_constant_p (c))
3490 else if (FP_REG_P (r))
3492 if (!standard_80387_constant_p (c))
3495 else if (MMX_REG_P (r))
3500 [(set (match_operand 0 "register_operand" "")
3501 (float_extend (match_operand 1 "memory_operand" "")))]
3503 && MEM_P (operands[1])
3504 && (GET_MODE (operands[0]) == TFmode
3505 || GET_MODE (operands[0]) == XFmode
3506 || GET_MODE (operands[0]) == DFmode
3507 || GET_MODE (operands[0]) == SFmode)
3508 && (operands[2] = find_constant_src (insn))"
3509 [(set (match_dup 0) (match_dup 2))]
3511 rtx c = operands[2];
3512 rtx r = operands[0];
3514 if (GET_CODE (r) == SUBREG)
3519 if (!standard_sse_constant_p (c))
3522 else if (FP_REG_P (r))
3524 if (!standard_80387_constant_p (c))
3527 else if (MMX_REG_P (r))
3531 ;; Split the load of -0.0 or -1.0 into fldz;fchs or fld1;fchs sequence
3533 [(set (match_operand:X87MODEF 0 "register_operand" "")
3534 (match_operand:X87MODEF 1 "immediate_operand" ""))]
3535 "reload_completed && FP_REGNO_P (REGNO (operands[0]))
3536 && (standard_80387_constant_p (operands[1]) == 8
3537 || standard_80387_constant_p (operands[1]) == 9)"
3538 [(set (match_dup 0)(match_dup 1))
3540 (neg:X87MODEF (match_dup 0)))]
3544 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
3545 if (real_isnegzero (&r))
3546 operands[1] = CONST0_RTX (<MODE>mode);
3548 operands[1] = CONST1_RTX (<MODE>mode);
3551 (define_insn "swapxf"
3552 [(set (match_operand:XF 0 "register_operand" "+f")
3553 (match_operand:XF 1 "register_operand" "+f"))
3558 if (STACK_TOP_P (operands[0]))
3563 [(set_attr "type" "fxch")
3564 (set_attr "mode" "XF")])
3566 (define_insn "*swap<mode>"
3567 [(set (match_operand:MODEF 0 "fp_register_operand" "+f")
3568 (match_operand:MODEF 1 "fp_register_operand" "+f"))
3571 "TARGET_80387 || reload_completed"
3573 if (STACK_TOP_P (operands[0]))
3578 [(set_attr "type" "fxch")
3579 (set_attr "mode" "<MODE>")])
3581 ;; Zero extension instructions
3583 (define_expand "zero_extendsidi2"
3584 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3585 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3590 emit_insn (gen_zero_extendsidi2_1 (operands[0], operands[1]));
3595 (define_insn "*zero_extendsidi2_rex64"
3596 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,?*Ym,?*y,?*Yi,*Y2")
3598 (match_operand:SI 1 "nonimmediate_operand" "rm,0,r ,m ,r ,m")))]
3601 mov\t{%k1, %k0|%k0, %k1}
3603 movd\t{%1, %0|%0, %1}
3604 movd\t{%1, %0|%0, %1}
3605 %vmovd\t{%1, %0|%0, %1}
3606 %vmovd\t{%1, %0|%0, %1}"
3607 [(set_attr "type" "imovx,imov,mmxmov,mmxmov,ssemov,ssemov")
3608 (set_attr "prefix" "orig,*,orig,orig,maybe_vex,maybe_vex")
3609 (set_attr "prefix_0f" "0,*,*,*,*,*")
3610 (set_attr "mode" "SI,DI,DI,DI,TI,TI")])
3613 [(set (match_operand:DI 0 "memory_operand" "")
3614 (zero_extend:DI (match_dup 0)))]
3616 [(set (match_dup 4) (const_int 0))]
3617 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3619 ;; %%% Kill me once multi-word ops are sane.
3620 (define_insn "zero_extendsidi2_1"
3621 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?o,?*Ym,?*y,?*Yi,*Y2")
3623 (match_operand:SI 1 "nonimmediate_operand" "0,rm,r ,r ,m ,r ,m")))
3624 (clobber (reg:CC FLAGS_REG))]
3630 movd\t{%1, %0|%0, %1}
3631 movd\t{%1, %0|%0, %1}
3632 %vmovd\t{%1, %0|%0, %1}
3633 %vmovd\t{%1, %0|%0, %1}"
3634 [(set_attr "type" "multi,multi,multi,mmxmov,mmxmov,ssemov,ssemov")
3635 (set_attr "prefix" "*,*,*,orig,orig,maybe_vex,maybe_vex")
3636 (set_attr "mode" "SI,SI,SI,DI,DI,TI,TI")])
3639 [(set (match_operand:DI 0 "register_operand" "")
3640 (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3641 (clobber (reg:CC FLAGS_REG))]
3642 "!TARGET_64BIT && reload_completed
3643 && true_regnum (operands[0]) == true_regnum (operands[1])"
3644 [(set (match_dup 4) (const_int 0))]
3645 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3648 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3649 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3650 (clobber (reg:CC FLAGS_REG))]
3651 "!TARGET_64BIT && reload_completed
3652 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))"
3653 [(set (match_dup 3) (match_dup 1))
3654 (set (match_dup 4) (const_int 0))]
3655 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3657 (define_insn "zero_extend<mode>di2"
3658 [(set (match_operand:DI 0 "register_operand" "=r")
3660 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3662 "movz{<imodesuffix>l|x}\t{%1, %k0|%k0, %1}"
3663 [(set_attr "type" "imovx")
3664 (set_attr "mode" "SI")])
3666 (define_expand "zero_extendhisi2"
3667 [(set (match_operand:SI 0 "register_operand" "")
3668 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3671 if (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3673 operands[1] = force_reg (HImode, operands[1]);
3674 emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3679 (define_insn_and_split "zero_extendhisi2_and"
3680 [(set (match_operand:SI 0 "register_operand" "=r")
3681 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3682 (clobber (reg:CC FLAGS_REG))]
3683 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3685 "&& reload_completed"
3686 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3687 (clobber (reg:CC FLAGS_REG))])]
3689 [(set_attr "type" "alu1")
3690 (set_attr "mode" "SI")])
3692 (define_insn "*zero_extendhisi2_movzwl"
3693 [(set (match_operand:SI 0 "register_operand" "=r")
3694 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3695 "!TARGET_ZERO_EXTEND_WITH_AND
3696 || optimize_function_for_size_p (cfun)"
3697 "movz{wl|x}\t{%1, %0|%0, %1}"
3698 [(set_attr "type" "imovx")
3699 (set_attr "mode" "SI")])
3701 (define_expand "zero_extendqi<mode>2"
3703 [(set (match_operand:SWI24 0 "register_operand" "")
3704 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3705 (clobber (reg:CC FLAGS_REG))])])
3707 (define_insn "*zero_extendqi<mode>2_and"
3708 [(set (match_operand:SWI24 0 "register_operand" "=r,?&q")
3709 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3710 (clobber (reg:CC FLAGS_REG))]
3711 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3713 [(set_attr "type" "alu1")
3714 (set_attr "mode" "<MODE>")])
3716 ;; When source and destination does not overlap, clear destination
3717 ;; first and then do the movb
3719 [(set (match_operand:SWI24 0 "register_operand" "")
3720 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3721 (clobber (reg:CC FLAGS_REG))]
3723 && (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3724 && ANY_QI_REG_P (operands[0])
3725 && (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]))
3726 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3727 [(set (strict_low_part (match_dup 2)) (match_dup 1))]
3729 operands[2] = gen_lowpart (QImode, operands[0]);
3730 ix86_expand_clear (operands[0]);
3733 (define_insn "*zero_extendqi<mode>2_movzbl_and"
3734 [(set (match_operand:SWI24 0 "register_operand" "=r,r")
3735 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3736 (clobber (reg:CC FLAGS_REG))]
3737 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun)"
3739 [(set_attr "type" "imovx,alu1")
3740 (set_attr "mode" "<MODE>")])
3742 ;; For the movzbl case strip only the clobber
3744 [(set (match_operand:SWI24 0 "register_operand" "")
3745 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3746 (clobber (reg:CC FLAGS_REG))]
3748 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))
3749 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3751 (zero_extend:SWI24 (match_dup 1)))])
3753 ; zero extend to SImode to avoid partial register stalls
3754 (define_insn "*zero_extendqi<mode>2_movzbl"
3755 [(set (match_operand:SWI24 0 "register_operand" "=r")
3756 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3758 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))"
3759 "movz{bl|x}\t{%1, %k0|%k0, %1}"
3760 [(set_attr "type" "imovx")
3761 (set_attr "mode" "SI")])
3763 ;; Rest is handled by single and.
3765 [(set (match_operand:SWI24 0 "register_operand" "")
3766 (zero_extend:SWI24 (match_operand:QI 1 "register_operand" "")))
3767 (clobber (reg:CC FLAGS_REG))]
3769 && true_regnum (operands[0]) == true_regnum (operands[1])"
3770 [(parallel [(set (match_dup 0) (and:SWI24 (match_dup 0) (const_int 255)))
3771 (clobber (reg:CC FLAGS_REG))])])
3773 ;; Sign extension instructions
3775 (define_expand "extendsidi2"
3776 [(set (match_operand:DI 0 "register_operand" "")
3777 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))]
3782 emit_insn (gen_extendsidi2_1 (operands[0], operands[1]));
3787 (define_insn "*extendsidi2_rex64"
3788 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3789 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3793 movs{lq|x}\t{%1, %0|%0, %1}"
3794 [(set_attr "type" "imovx")
3795 (set_attr "mode" "DI")
3796 (set_attr "prefix_0f" "0")
3797 (set_attr "modrm" "0,1")])
3799 (define_insn "extendsidi2_1"
3800 [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3801 (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3802 (clobber (reg:CC FLAGS_REG))
3803 (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3807 ;; Extend to memory case when source register does die.
3809 [(set (match_operand:DI 0 "memory_operand" "")
3810 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3811 (clobber (reg:CC FLAGS_REG))
3812 (clobber (match_operand:SI 2 "register_operand" ""))]
3814 && dead_or_set_p (insn, operands[1])
3815 && !reg_mentioned_p (operands[1], operands[0]))"
3816 [(set (match_dup 3) (match_dup 1))
3817 (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3818 (clobber (reg:CC FLAGS_REG))])
3819 (set (match_dup 4) (match_dup 1))]
3820 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3822 ;; Extend to memory case when source register does not die.
3824 [(set (match_operand:DI 0 "memory_operand" "")
3825 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3826 (clobber (reg:CC FLAGS_REG))
3827 (clobber (match_operand:SI 2 "register_operand" ""))]
3831 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3833 emit_move_insn (operands[3], operands[1]);
3835 /* Generate a cltd if possible and doing so it profitable. */
3836 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3837 && true_regnum (operands[1]) == AX_REG
3838 && true_regnum (operands[2]) == DX_REG)
3840 emit_insn (gen_ashrsi3_cvt (operands[2], operands[1], GEN_INT (31)));
3844 emit_move_insn (operands[2], operands[1]);
3845 emit_insn (gen_ashrsi3_cvt (operands[2], operands[2], GEN_INT (31)));
3847 emit_move_insn (operands[4], operands[2]);
3851 ;; Extend to register case. Optimize case where source and destination
3852 ;; registers match and cases where we can use cltd.
3854 [(set (match_operand:DI 0 "register_operand" "")
3855 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3856 (clobber (reg:CC FLAGS_REG))
3857 (clobber (match_scratch:SI 2 ""))]
3861 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3863 if (true_regnum (operands[3]) != true_regnum (operands[1]))
3864 emit_move_insn (operands[3], operands[1]);
3866 /* Generate a cltd if possible and doing so it profitable. */
3867 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3868 && true_regnum (operands[3]) == AX_REG
3869 && true_regnum (operands[4]) == DX_REG)
3871 emit_insn (gen_ashrsi3_cvt (operands[4], operands[3], GEN_INT (31)));
3875 if (true_regnum (operands[4]) != true_regnum (operands[1]))
3876 emit_move_insn (operands[4], operands[1]);
3878 emit_insn (gen_ashrsi3_cvt (operands[4], operands[4], GEN_INT (31)));
3882 (define_insn "extend<mode>di2"
3883 [(set (match_operand:DI 0 "register_operand" "=r")
3885 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3887 "movs{<imodesuffix>q|x}\t{%1, %0|%0, %1}"
3888 [(set_attr "type" "imovx")
3889 (set_attr "mode" "DI")])
3891 (define_insn "extendhisi2"
3892 [(set (match_operand:SI 0 "register_operand" "=*a,r")
3893 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3896 switch (get_attr_prefix_0f (insn))
3899 return "{cwtl|cwde}";
3901 return "movs{wl|x}\t{%1, %0|%0, %1}";
3904 [(set_attr "type" "imovx")
3905 (set_attr "mode" "SI")
3906 (set (attr "prefix_0f")
3907 ;; movsx is short decodable while cwtl is vector decoded.