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
109 ;; For SSE/MMX support:
127 UNSPEC_MS_TO_SYSV_CALL
129 ;; Generic math support
131 UNSPEC_IEEE_MIN ; not commutative
132 UNSPEC_IEEE_MAX ; not commutative
134 ;; x87 Floating point
150 UNSPEC_FRNDINT_MASK_PM
154 ;; x87 Double output FP
186 ;; For SSE4.1 support
196 ;; For SSE4.2 support
203 UNSPEC_XOP_UNSIGNED_CMP
214 UNSPEC_AESKEYGENASSIST
216 ;; For PCLMUL support
232 (define_c_enum "unspecv" [
235 UNSPECV_PROBE_STACK_RANGE
255 UNSPECV_LLWP_INTRINSIC
256 UNSPECV_SLWP_INTRINSIC
257 UNSPECV_LWPVAL_INTRINSIC
258 UNSPECV_LWPINS_INTRINSIC
266 ;; Constants to represent pcomtrue/pcomfalse variants
276 ;; Constants used in the XOP pperm instruction
278 [(PPERM_SRC 0x00) /* copy source */
279 (PPERM_INVERT 0x20) /* invert source */
280 (PPERM_REVERSE 0x40) /* bit reverse source */
281 (PPERM_REV_INV 0x60) /* bit reverse & invert src */
282 (PPERM_ZERO 0x80) /* all 0's */
283 (PPERM_ONES 0xa0) /* all 1's */
284 (PPERM_SIGN 0xc0) /* propagate sign bit */
285 (PPERM_INV_SIGN 0xe0) /* invert & propagate sign */
286 (PPERM_SRC1 0x00) /* use first source byte */
287 (PPERM_SRC2 0x10) /* use second source byte */
290 ;; Registers by name.
343 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
346 ;; In C guard expressions, put expressions which may be compile-time
347 ;; constants first. This allows for better optimization. For
348 ;; example, write "TARGET_64BIT && reload_completed", not
349 ;; "reload_completed && TARGET_64BIT".
353 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,atom,
354 generic64,amdfam10,bdver1"
355 (const (symbol_ref "ix86_schedule")))
357 ;; A basic instruction type. Refinements due to arguments to be
358 ;; provided in other attributes.
361 alu,alu1,negnot,imov,imovx,lea,
362 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
363 icmp,test,ibr,setcc,icmov,
364 push,pop,call,callv,leave,
366 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
367 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
368 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
369 ssemuladd,sse4arg,lwp,
370 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
371 (const_string "other"))
373 ;; Main data type used by the insn
375 "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
376 (const_string "unknown"))
378 ;; The CPU unit operations uses.
379 (define_attr "unit" "integer,i387,sse,mmx,unknown"
380 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
381 (const_string "i387")
382 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
383 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
384 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
386 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
388 (eq_attr "type" "other")
389 (const_string "unknown")]
390 (const_string "integer")))
392 ;; The (bounding maximum) length of an instruction immediate.
393 (define_attr "length_immediate" ""
394 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
397 (eq_attr "unit" "i387,sse,mmx")
399 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
401 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
402 (eq_attr "type" "imov,test")
403 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
404 (eq_attr "type" "call")
405 (if_then_else (match_operand 0 "constant_call_address_operand" "")
408 (eq_attr "type" "callv")
409 (if_then_else (match_operand 1 "constant_call_address_operand" "")
412 ;; We don't know the size before shorten_branches. Expect
413 ;; the instruction to fit for better scheduling.
414 (eq_attr "type" "ibr")
417 (symbol_ref "/* Update immediate_length and other attributes! */
418 gcc_unreachable (),1")))
420 ;; The (bounding maximum) length of an instruction address.
421 (define_attr "length_address" ""
422 (cond [(eq_attr "type" "str,other,multi,fxch")
424 (and (eq_attr "type" "call")
425 (match_operand 0 "constant_call_address_operand" ""))
427 (and (eq_attr "type" "callv")
428 (match_operand 1 "constant_call_address_operand" ""))
431 (symbol_ref "ix86_attr_length_address_default (insn)")))
433 ;; Set when length prefix is used.
434 (define_attr "prefix_data16" ""
435 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
437 (eq_attr "mode" "HI")
439 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
444 ;; Set when string REP prefix is used.
445 (define_attr "prefix_rep" ""
446 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
448 (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
453 ;; Set when 0f opcode prefix is used.
454 (define_attr "prefix_0f" ""
456 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
457 (eq_attr "unit" "sse,mmx"))
461 ;; Set when REX opcode prefix is used.
462 (define_attr "prefix_rex" ""
463 (cond [(eq (symbol_ref "TARGET_64BIT") (const_int 0))
465 (and (eq_attr "mode" "DI")
466 (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
467 (eq_attr "unit" "!mmx")))
469 (and (eq_attr "mode" "QI")
470 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
473 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
476 (and (eq_attr "type" "imovx")
477 (match_operand:QI 1 "ext_QIreg_operand" ""))
482 ;; There are also additional prefixes in 3DNOW, SSSE3.
483 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
484 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
485 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
486 (define_attr "prefix_extra" ""
487 (cond [(eq_attr "type" "ssemuladd,sse4arg")
489 (eq_attr "type" "sseiadd1,ssecvt1")
494 ;; Prefix used: original, VEX or maybe VEX.
495 (define_attr "prefix" "orig,vex,maybe_vex"
496 (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
498 (const_string "orig")))
500 ;; VEX W bit is used.
501 (define_attr "prefix_vex_w" "" (const_int 0))
503 ;; The length of VEX prefix
504 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
505 ;; 0f38/0f3a prefixes can't. In i386.md 0f3[8a] is
506 ;; still prefix_0f 1, with prefix_extra 1.
507 (define_attr "length_vex" ""
508 (if_then_else (and (eq_attr "prefix_0f" "1")
509 (eq_attr "prefix_extra" "0"))
510 (if_then_else (eq_attr "prefix_vex_w" "1")
511 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 1)")
512 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 0)"))
513 (if_then_else (eq_attr "prefix_vex_w" "1")
514 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 1)")
515 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 0)"))))
517 ;; Set when modrm byte is used.
518 (define_attr "modrm" ""
519 (cond [(eq_attr "type" "str,leave")
521 (eq_attr "unit" "i387")
523 (and (eq_attr "type" "incdec")
524 (and (eq (symbol_ref "TARGET_64BIT") (const_int 0))
525 (ior (match_operand:SI 1 "register_operand" "")
526 (match_operand:HI 1 "register_operand" ""))))
528 (and (eq_attr "type" "push")
529 (not (match_operand 1 "memory_operand" "")))
531 (and (eq_attr "type" "pop")
532 (not (match_operand 0 "memory_operand" "")))
534 (and (eq_attr "type" "imov")
535 (and (not (eq_attr "mode" "DI"))
536 (ior (and (match_operand 0 "register_operand" "")
537 (match_operand 1 "immediate_operand" ""))
538 (ior (and (match_operand 0 "ax_reg_operand" "")
539 (match_operand 1 "memory_displacement_only_operand" ""))
540 (and (match_operand 0 "memory_displacement_only_operand" "")
541 (match_operand 1 "ax_reg_operand" ""))))))
543 (and (eq_attr "type" "call")
544 (match_operand 0 "constant_call_address_operand" ""))
546 (and (eq_attr "type" "callv")
547 (match_operand 1 "constant_call_address_operand" ""))
549 (and (eq_attr "type" "alu,alu1,icmp,test")
550 (match_operand 0 "ax_reg_operand" ""))
551 (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
555 ;; The (bounding maximum) length of an instruction in bytes.
556 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
557 ;; Later we may want to split them and compute proper length as for
559 (define_attr "length" ""
560 (cond [(eq_attr "type" "other,multi,fistp,frndint")
562 (eq_attr "type" "fcmp")
564 (eq_attr "unit" "i387")
566 (plus (attr "prefix_data16")
567 (attr "length_address")))
568 (ior (eq_attr "prefix" "vex")
569 (and (eq_attr "prefix" "maybe_vex")
570 (ne (symbol_ref "TARGET_AVX") (const_int 0))))
571 (plus (attr "length_vex")
572 (plus (attr "length_immediate")
574 (attr "length_address"))))]
575 (plus (plus (attr "modrm")
576 (plus (attr "prefix_0f")
577 (plus (attr "prefix_rex")
578 (plus (attr "prefix_extra")
580 (plus (attr "prefix_rep")
581 (plus (attr "prefix_data16")
582 (plus (attr "length_immediate")
583 (attr "length_address")))))))
585 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
586 ;; `store' if there is a simple memory reference therein, or `unknown'
587 ;; if the instruction is complex.
589 (define_attr "memory" "none,load,store,both,unknown"
590 (cond [(eq_attr "type" "other,multi,str,lwp")
591 (const_string "unknown")
592 (eq_attr "type" "lea,fcmov,fpspc")
593 (const_string "none")
594 (eq_attr "type" "fistp,leave")
595 (const_string "both")
596 (eq_attr "type" "frndint")
597 (const_string "load")
598 (eq_attr "type" "push")
599 (if_then_else (match_operand 1 "memory_operand" "")
600 (const_string "both")
601 (const_string "store"))
602 (eq_attr "type" "pop")
603 (if_then_else (match_operand 0 "memory_operand" "")
604 (const_string "both")
605 (const_string "load"))
606 (eq_attr "type" "setcc")
607 (if_then_else (match_operand 0 "memory_operand" "")
608 (const_string "store")
609 (const_string "none"))
610 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
611 (if_then_else (ior (match_operand 0 "memory_operand" "")
612 (match_operand 1 "memory_operand" ""))
613 (const_string "load")
614 (const_string "none"))
615 (eq_attr "type" "ibr")
616 (if_then_else (match_operand 0 "memory_operand" "")
617 (const_string "load")
618 (const_string "none"))
619 (eq_attr "type" "call")
620 (if_then_else (match_operand 0 "constant_call_address_operand" "")
621 (const_string "none")
622 (const_string "load"))
623 (eq_attr "type" "callv")
624 (if_then_else (match_operand 1 "constant_call_address_operand" "")
625 (const_string "none")
626 (const_string "load"))
627 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
628 (match_operand 1 "memory_operand" ""))
629 (const_string "both")
630 (and (match_operand 0 "memory_operand" "")
631 (match_operand 1 "memory_operand" ""))
632 (const_string "both")
633 (match_operand 0 "memory_operand" "")
634 (const_string "store")
635 (match_operand 1 "memory_operand" "")
636 (const_string "load")
638 "!alu1,negnot,ishift1,
639 imov,imovx,icmp,test,bitmanip,
641 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
642 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
643 (match_operand 2 "memory_operand" ""))
644 (const_string "load")
645 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
646 (match_operand 3 "memory_operand" ""))
647 (const_string "load")
649 (const_string "none")))
651 ;; Indicates if an instruction has both an immediate and a displacement.
653 (define_attr "imm_disp" "false,true,unknown"
654 (cond [(eq_attr "type" "other,multi")
655 (const_string "unknown")
656 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
657 (and (match_operand 0 "memory_displacement_operand" "")
658 (match_operand 1 "immediate_operand" "")))
659 (const_string "true")
660 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
661 (and (match_operand 0 "memory_displacement_operand" "")
662 (match_operand 2 "immediate_operand" "")))
663 (const_string "true")
665 (const_string "false")))
667 ;; Indicates if an FP operation has an integer source.
669 (define_attr "fp_int_src" "false,true"
670 (const_string "false"))
672 ;; Defines rounding mode of an FP operation.
674 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
675 (const_string "any"))
677 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
678 (define_attr "use_carry" "0,1" (const_string "0"))
680 ;; Define attribute to indicate unaligned ssemov insns
681 (define_attr "movu" "0,1" (const_string "0"))
683 ;; Describe a user's asm statement.
684 (define_asm_attributes
685 [(set_attr "length" "128")
686 (set_attr "type" "multi")])
688 (define_code_iterator plusminus [plus minus])
690 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
692 ;; Base name for define_insn
693 (define_code_attr plusminus_insn
694 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
695 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
697 ;; Base name for insn mnemonic.
698 (define_code_attr plusminus_mnemonic
699 [(plus "add") (ss_plus "adds") (us_plus "addus")
700 (minus "sub") (ss_minus "subs") (us_minus "subus")])
701 (define_code_attr plusminus_carry_mnemonic
702 [(plus "adc") (minus "sbb")])
704 ;; Mark commutative operators as such in constraints.
705 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
706 (minus "") (ss_minus "") (us_minus "")])
708 ;; Mapping of signed max and min
709 (define_code_iterator smaxmin [smax smin])
711 ;; Mapping of unsigned max and min
712 (define_code_iterator umaxmin [umax umin])
714 ;; Base name for integer and FP insn mnemonic
715 (define_code_attr maxmin_int [(smax "maxs") (smin "mins")
716 (umax "maxu") (umin "minu")])
717 (define_code_attr maxmin_float [(smax "max") (smin "min")])
719 ;; Mapping of logic operators
720 (define_code_iterator any_logic [and ior xor])
721 (define_code_iterator any_or [ior xor])
723 ;; Base name for insn mnemonic.
724 (define_code_attr logic [(and "and") (ior "or") (xor "xor")])
726 ;; Mapping of shift-right operators
727 (define_code_iterator any_shiftrt [lshiftrt ashiftrt])
729 ;; Base name for define_insn
730 (define_code_attr shiftrt_insn [(lshiftrt "lshr") (ashiftrt "ashr")])
732 ;; Base name for insn mnemonic.
733 (define_code_attr shiftrt [(lshiftrt "shr") (ashiftrt "sar")])
735 ;; Mapping of rotate operators
736 (define_code_iterator any_rotate [rotate rotatert])
738 ;; Base name for define_insn
739 (define_code_attr rotate_insn [(rotate "rotl") (rotatert "rotr")])
741 ;; Base name for insn mnemonic.
742 (define_code_attr rotate [(rotate "rol") (rotatert "ror")])
744 ;; Mapping of abs neg operators
745 (define_code_iterator absneg [abs neg])
747 ;; Base name for x87 insn mnemonic.
748 (define_code_attr absneg_mnemonic [(abs "abs") (neg "chs")])
750 ;; Used in signed and unsigned widening multiplications.
751 (define_code_iterator any_extend [sign_extend zero_extend])
753 ;; Various insn prefixes for signed and unsigned operations.
754 (define_code_attr u [(sign_extend "") (zero_extend "u")
755 (div "") (udiv "u")])
756 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
758 ;; Used in signed and unsigned divisions.
759 (define_code_iterator any_div [div udiv])
761 ;; Instruction prefix for signed and unsigned operations.
762 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")
763 (div "i") (udiv "")])
765 ;; 64bit single word integer modes.
766 (define_mode_iterator SWI1248x [QI HI SI DI])
768 ;; 64bit single word integer modes without QImode and HImode.
769 (define_mode_iterator SWI48x [SI DI])
771 ;; Single word integer modes.
772 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
774 ;; Single word integer modes without SImode and DImode.
775 (define_mode_iterator SWI12 [QI HI])
777 ;; Single word integer modes without DImode.
778 (define_mode_iterator SWI124 [QI HI SI])
780 ;; Single word integer modes without QImode and DImode.
781 (define_mode_iterator SWI24 [HI SI])
783 ;; Single word integer modes without QImode.
784 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
786 ;; Single word integer modes without QImode and HImode.
787 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
789 ;; All math-dependant single and double word integer modes.
790 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
791 (HI "TARGET_HIMODE_MATH")
792 SI DI (TI "TARGET_64BIT")])
794 ;; Math-dependant single word integer modes.
795 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
796 (HI "TARGET_HIMODE_MATH")
797 SI (DI "TARGET_64BIT")])
799 ;; Math-dependant single word integer modes without DImode.
800 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
801 (HI "TARGET_HIMODE_MATH")
804 ;; Math-dependant single word integer modes without QImode.
805 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
806 SI (DI "TARGET_64BIT")])
808 ;; Double word integer modes.
809 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
810 (TI "TARGET_64BIT")])
812 ;; Double word integer modes as mode attribute.
813 (define_mode_attr DWI [(SI "DI") (DI "TI")])
814 (define_mode_attr dwi [(SI "di") (DI "ti")])
816 ;; Half mode for double word integer modes.
817 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
818 (DI "TARGET_64BIT")])
820 ;; Instruction suffix for integer modes.
821 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
823 ;; Pointer size prefix for integer modes (Intel asm dialect)
824 (define_mode_attr iptrsize [(QI "BYTE")
829 ;; Register class for integer modes.
830 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
832 ;; Immediate operand constraint for integer modes.
833 (define_mode_attr i [(QI "n") (HI "n") (SI "i") (DI "e")])
835 ;; General operand constraint for word modes.
836 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "g") (DI "rme")])
838 ;; Immediate operand constraint for double integer modes.
839 (define_mode_attr di [(SI "iF") (DI "e")])
841 ;; Immediate operand constraint for shifts.
842 (define_mode_attr S [(QI "I") (HI "I") (SI "I") (DI "J") (TI "O")])
844 ;; General operand predicate for integer modes.
845 (define_mode_attr general_operand
846 [(QI "general_operand")
847 (HI "general_operand")
848 (SI "general_operand")
849 (DI "x86_64_general_operand")
850 (TI "x86_64_general_operand")])
852 ;; General sign/zero extend operand predicate for integer modes.
853 (define_mode_attr general_szext_operand
854 [(QI "general_operand")
855 (HI "general_operand")
856 (SI "general_operand")
857 (DI "x86_64_szext_general_operand")])
859 ;; Immediate operand predicate for integer modes.
860 (define_mode_attr immediate_operand
861 [(QI "immediate_operand")
862 (HI "immediate_operand")
863 (SI "immediate_operand")
864 (DI "x86_64_immediate_operand")])
866 ;; Nonmemory operand predicate for integer modes.
867 (define_mode_attr nonmemory_operand
868 [(QI "nonmemory_operand")
869 (HI "nonmemory_operand")
870 (SI "nonmemory_operand")
871 (DI "x86_64_nonmemory_operand")])
873 ;; Operand predicate for shifts.
874 (define_mode_attr shift_operand
875 [(QI "nonimmediate_operand")
876 (HI "nonimmediate_operand")
877 (SI "nonimmediate_operand")
878 (DI "shiftdi_operand")
879 (TI "register_operand")])
881 ;; Operand predicate for shift argument.
882 (define_mode_attr shift_immediate_operand
883 [(QI "const_1_to_31_operand")
884 (HI "const_1_to_31_operand")
885 (SI "const_1_to_31_operand")
886 (DI "const_1_to_63_operand")])
888 ;; Input operand predicate for arithmetic left shifts.
889 (define_mode_attr ashl_input_operand
890 [(QI "nonimmediate_operand")
891 (HI "nonimmediate_operand")
892 (SI "nonimmediate_operand")
893 (DI "ashldi_input_operand")
894 (TI "reg_or_pm1_operand")])
896 ;; SSE and x87 SFmode and DFmode floating point modes
897 (define_mode_iterator MODEF [SF DF])
899 ;; All x87 floating point modes
900 (define_mode_iterator X87MODEF [SF DF XF])
902 ;; All integer modes handled by x87 fisttp operator.
903 (define_mode_iterator X87MODEI [HI SI DI])
905 ;; All integer modes handled by integer x87 operators.
906 (define_mode_iterator X87MODEI12 [HI SI])
908 ;; All integer modes handled by SSE cvtts?2si* operators.
909 (define_mode_iterator SSEMODEI24 [SI DI])
911 ;; SSE asm suffix for floating point modes
912 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
914 ;; SSE vector mode corresponding to a scalar mode
915 (define_mode_attr ssevecmode
916 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
918 ;; Instruction suffix for REX 64bit operators.
919 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
921 ;; This mode iterator allows :P to be used for patterns that operate on
922 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
923 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
925 ;; Scheduling descriptions
927 (include "pentium.md")
930 (include "athlon.md")
931 (include "bdver1.md")
936 ;; Operand and operator predicates and constraints
938 (include "predicates.md")
939 (include "constraints.md")
942 ;; Compare and branch/compare and store instructions.
944 (define_expand "cbranch<mode>4"
945 [(set (reg:CC FLAGS_REG)
946 (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
947 (match_operand:SDWIM 2 "<general_operand>" "")))
948 (set (pc) (if_then_else
949 (match_operator 0 "ordered_comparison_operator"
950 [(reg:CC FLAGS_REG) (const_int 0)])
951 (label_ref (match_operand 3 "" ""))
955 if (MEM_P (operands[1]) && MEM_P (operands[2]))
956 operands[1] = force_reg (<MODE>mode, operands[1]);
957 ix86_expand_branch (GET_CODE (operands[0]),
958 operands[1], operands[2], operands[3]);
962 (define_expand "cstore<mode>4"
963 [(set (reg:CC FLAGS_REG)
964 (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
965 (match_operand:SWIM 3 "<general_operand>" "")))
966 (set (match_operand:QI 0 "register_operand" "")
967 (match_operator 1 "ordered_comparison_operator"
968 [(reg:CC FLAGS_REG) (const_int 0)]))]
971 if (MEM_P (operands[2]) && MEM_P (operands[3]))
972 operands[2] = force_reg (<MODE>mode, operands[2]);
973 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
974 operands[2], operands[3]);
978 (define_expand "cmp<mode>_1"
979 [(set (reg:CC FLAGS_REG)
980 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
981 (match_operand:SWI48 1 "<general_operand>" "")))])
983 (define_insn "*cmp<mode>_ccno_1"
984 [(set (reg FLAGS_REG)
985 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
986 (match_operand:SWI 1 "const0_operand" "")))]
987 "ix86_match_ccmode (insn, CCNOmode)"
989 test{<imodesuffix>}\t%0, %0
990 cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
991 [(set_attr "type" "test,icmp")
992 (set_attr "length_immediate" "0,1")
993 (set_attr "mode" "<MODE>")])
995 (define_insn "*cmp<mode>_1"
996 [(set (reg FLAGS_REG)
997 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
998 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
999 "ix86_match_ccmode (insn, CCmode)"
1000 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1001 [(set_attr "type" "icmp")
1002 (set_attr "mode" "<MODE>")])
1004 (define_insn "*cmp<mode>_minus_1"
1005 [(set (reg FLAGS_REG)
1007 (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1008 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
1010 "ix86_match_ccmode (insn, CCGOCmode)"
1011 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1012 [(set_attr "type" "icmp")
1013 (set_attr "mode" "<MODE>")])
1015 (define_insn "*cmpqi_ext_1"
1016 [(set (reg FLAGS_REG)
1018 (match_operand:QI 0 "general_operand" "Qm")
1021 (match_operand 1 "ext_register_operand" "Q")
1023 (const_int 8)) 0)))]
1024 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1025 "cmp{b}\t{%h1, %0|%0, %h1}"
1026 [(set_attr "type" "icmp")
1027 (set_attr "mode" "QI")])
1029 (define_insn "*cmpqi_ext_1_rex64"
1030 [(set (reg FLAGS_REG)
1032 (match_operand:QI 0 "register_operand" "Q")
1035 (match_operand 1 "ext_register_operand" "Q")
1037 (const_int 8)) 0)))]
1038 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1039 "cmp{b}\t{%h1, %0|%0, %h1}"
1040 [(set_attr "type" "icmp")
1041 (set_attr "mode" "QI")])
1043 (define_insn "*cmpqi_ext_2"
1044 [(set (reg FLAGS_REG)
1048 (match_operand 0 "ext_register_operand" "Q")
1051 (match_operand:QI 1 "const0_operand" "")))]
1052 "ix86_match_ccmode (insn, CCNOmode)"
1054 [(set_attr "type" "test")
1055 (set_attr "length_immediate" "0")
1056 (set_attr "mode" "QI")])
1058 (define_expand "cmpqi_ext_3"
1059 [(set (reg:CC FLAGS_REG)
1063 (match_operand 0 "ext_register_operand" "")
1066 (match_operand:QI 1 "immediate_operand" "")))])
1068 (define_insn "*cmpqi_ext_3_insn"
1069 [(set (reg FLAGS_REG)
1073 (match_operand 0 "ext_register_operand" "Q")
1076 (match_operand:QI 1 "general_operand" "Qmn")))]
1077 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1078 "cmp{b}\t{%1, %h0|%h0, %1}"
1079 [(set_attr "type" "icmp")
1080 (set_attr "modrm" "1")
1081 (set_attr "mode" "QI")])
1083 (define_insn "*cmpqi_ext_3_insn_rex64"
1084 [(set (reg FLAGS_REG)
1088 (match_operand 0 "ext_register_operand" "Q")
1091 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1092 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1093 "cmp{b}\t{%1, %h0|%h0, %1}"
1094 [(set_attr "type" "icmp")
1095 (set_attr "modrm" "1")
1096 (set_attr "mode" "QI")])
1098 (define_insn "*cmpqi_ext_4"
1099 [(set (reg FLAGS_REG)
1103 (match_operand 0 "ext_register_operand" "Q")
1108 (match_operand 1 "ext_register_operand" "Q")
1110 (const_int 8)) 0)))]
1111 "ix86_match_ccmode (insn, CCmode)"
1112 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1113 [(set_attr "type" "icmp")
1114 (set_attr "mode" "QI")])
1116 ;; These implement float point compares.
1117 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1118 ;; which would allow mix and match FP modes on the compares. Which is what
1119 ;; the old patterns did, but with many more of them.
1121 (define_expand "cbranchxf4"
1122 [(set (reg:CC FLAGS_REG)
1123 (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1124 (match_operand:XF 2 "nonmemory_operand" "")))
1125 (set (pc) (if_then_else
1126 (match_operator 0 "ix86_fp_comparison_operator"
1129 (label_ref (match_operand 3 "" ""))
1133 ix86_expand_branch (GET_CODE (operands[0]),
1134 operands[1], operands[2], operands[3]);
1138 (define_expand "cstorexf4"
1139 [(set (reg:CC FLAGS_REG)
1140 (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1141 (match_operand:XF 3 "nonmemory_operand" "")))
1142 (set (match_operand:QI 0 "register_operand" "")
1143 (match_operator 1 "ix86_fp_comparison_operator"
1148 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1149 operands[2], operands[3]);
1153 (define_expand "cbranch<mode>4"
1154 [(set (reg:CC FLAGS_REG)
1155 (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1156 (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1157 (set (pc) (if_then_else
1158 (match_operator 0 "ix86_fp_comparison_operator"
1161 (label_ref (match_operand 3 "" ""))
1163 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1165 ix86_expand_branch (GET_CODE (operands[0]),
1166 operands[1], operands[2], operands[3]);
1170 (define_expand "cstore<mode>4"
1171 [(set (reg:CC FLAGS_REG)
1172 (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1173 (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1174 (set (match_operand:QI 0 "register_operand" "")
1175 (match_operator 1 "ix86_fp_comparison_operator"
1178 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1180 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1181 operands[2], operands[3]);
1185 (define_expand "cbranchcc4"
1186 [(set (pc) (if_then_else
1187 (match_operator 0 "comparison_operator"
1188 [(match_operand 1 "flags_reg_operand" "")
1189 (match_operand 2 "const0_operand" "")])
1190 (label_ref (match_operand 3 "" ""))
1194 ix86_expand_branch (GET_CODE (operands[0]),
1195 operands[1], operands[2], operands[3]);
1199 (define_expand "cstorecc4"
1200 [(set (match_operand:QI 0 "register_operand" "")
1201 (match_operator 1 "comparison_operator"
1202 [(match_operand 2 "flags_reg_operand" "")
1203 (match_operand 3 "const0_operand" "")]))]
1206 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1207 operands[2], operands[3]);
1212 ;; FP compares, step 1:
1213 ;; Set the FP condition codes.
1215 ;; CCFPmode compare with exceptions
1216 ;; CCFPUmode compare with no exceptions
1218 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1219 ;; used to manage the reg stack popping would not be preserved.
1221 (define_insn "*cmpfp_0"
1222 [(set (match_operand:HI 0 "register_operand" "=a")
1225 (match_operand 1 "register_operand" "f")
1226 (match_operand 2 "const0_operand" ""))]
1228 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1229 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1230 "* return output_fp_compare (insn, operands, 0, 0);"
1231 [(set_attr "type" "multi")
1232 (set_attr "unit" "i387")
1234 (cond [(match_operand:SF 1 "" "")
1236 (match_operand:DF 1 "" "")
1239 (const_string "XF")))])
1241 (define_insn_and_split "*cmpfp_0_cc"
1242 [(set (reg:CCFP FLAGS_REG)
1244 (match_operand 1 "register_operand" "f")
1245 (match_operand 2 "const0_operand" "")))
1246 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1247 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1248 && TARGET_SAHF && !TARGET_CMOVE
1249 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1251 "&& reload_completed"
1254 [(compare:CCFP (match_dup 1)(match_dup 2))]
1256 (set (reg:CC FLAGS_REG)
1257 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1259 [(set_attr "type" "multi")
1260 (set_attr "unit" "i387")
1262 (cond [(match_operand:SF 1 "" "")
1264 (match_operand:DF 1 "" "")
1267 (const_string "XF")))])
1269 (define_insn "*cmpfp_xf"
1270 [(set (match_operand:HI 0 "register_operand" "=a")
1273 (match_operand:XF 1 "register_operand" "f")
1274 (match_operand:XF 2 "register_operand" "f"))]
1277 "* return output_fp_compare (insn, operands, 0, 0);"
1278 [(set_attr "type" "multi")
1279 (set_attr "unit" "i387")
1280 (set_attr "mode" "XF")])
1282 (define_insn_and_split "*cmpfp_xf_cc"
1283 [(set (reg:CCFP FLAGS_REG)
1285 (match_operand:XF 1 "register_operand" "f")
1286 (match_operand:XF 2 "register_operand" "f")))
1287 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1289 && TARGET_SAHF && !TARGET_CMOVE"
1291 "&& reload_completed"
1294 [(compare:CCFP (match_dup 1)(match_dup 2))]
1296 (set (reg:CC FLAGS_REG)
1297 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1299 [(set_attr "type" "multi")
1300 (set_attr "unit" "i387")
1301 (set_attr "mode" "XF")])
1303 (define_insn "*cmpfp_<mode>"
1304 [(set (match_operand:HI 0 "register_operand" "=a")
1307 (match_operand:MODEF 1 "register_operand" "f")
1308 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1311 "* return output_fp_compare (insn, operands, 0, 0);"
1312 [(set_attr "type" "multi")
1313 (set_attr "unit" "i387")
1314 (set_attr "mode" "<MODE>")])
1316 (define_insn_and_split "*cmpfp_<mode>_cc"
1317 [(set (reg:CCFP FLAGS_REG)
1319 (match_operand:MODEF 1 "register_operand" "f")
1320 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1321 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1323 && TARGET_SAHF && !TARGET_CMOVE"
1325 "&& reload_completed"
1328 [(compare:CCFP (match_dup 1)(match_dup 2))]
1330 (set (reg:CC FLAGS_REG)
1331 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1333 [(set_attr "type" "multi")
1334 (set_attr "unit" "i387")
1335 (set_attr "mode" "<MODE>")])
1337 (define_insn "*cmpfp_u"
1338 [(set (match_operand:HI 0 "register_operand" "=a")
1341 (match_operand 1 "register_operand" "f")
1342 (match_operand 2 "register_operand" "f"))]
1344 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1345 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1346 "* return output_fp_compare (insn, operands, 0, 1);"
1347 [(set_attr "type" "multi")
1348 (set_attr "unit" "i387")
1350 (cond [(match_operand:SF 1 "" "")
1352 (match_operand:DF 1 "" "")
1355 (const_string "XF")))])
1357 (define_insn_and_split "*cmpfp_u_cc"
1358 [(set (reg:CCFPU FLAGS_REG)
1360 (match_operand 1 "register_operand" "f")
1361 (match_operand 2 "register_operand" "f")))
1362 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1363 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1364 && TARGET_SAHF && !TARGET_CMOVE
1365 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1367 "&& reload_completed"
1370 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1372 (set (reg:CC FLAGS_REG)
1373 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1375 [(set_attr "type" "multi")
1376 (set_attr "unit" "i387")
1378 (cond [(match_operand:SF 1 "" "")
1380 (match_operand:DF 1 "" "")
1383 (const_string "XF")))])
1385 (define_insn "*cmpfp_<mode>"
1386 [(set (match_operand:HI 0 "register_operand" "=a")
1389 (match_operand 1 "register_operand" "f")
1390 (match_operator 3 "float_operator"
1391 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1393 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1394 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1395 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1396 "* return output_fp_compare (insn, operands, 0, 0);"
1397 [(set_attr "type" "multi")
1398 (set_attr "unit" "i387")
1399 (set_attr "fp_int_src" "true")
1400 (set_attr "mode" "<MODE>")])
1402 (define_insn_and_split "*cmpfp_<mode>_cc"
1403 [(set (reg:CCFP FLAGS_REG)
1405 (match_operand 1 "register_operand" "f")
1406 (match_operator 3 "float_operator"
1407 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1408 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1409 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1410 && TARGET_SAHF && !TARGET_CMOVE
1411 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1412 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1414 "&& reload_completed"
1419 (match_op_dup 3 [(match_dup 2)]))]
1421 (set (reg:CC FLAGS_REG)
1422 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1424 [(set_attr "type" "multi")
1425 (set_attr "unit" "i387")
1426 (set_attr "fp_int_src" "true")
1427 (set_attr "mode" "<MODE>")])
1429 ;; FP compares, step 2
1430 ;; Move the fpsw to ax.
1432 (define_insn "x86_fnstsw_1"
1433 [(set (match_operand:HI 0 "register_operand" "=a")
1434 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1437 [(set (attr "length") (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1438 (set_attr "mode" "SI")
1439 (set_attr "unit" "i387")])
1441 ;; FP compares, step 3
1442 ;; Get ax into flags, general case.
1444 (define_insn "x86_sahf_1"
1445 [(set (reg:CC FLAGS_REG)
1446 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1450 #ifndef HAVE_AS_IX86_SAHF
1452 return ASM_BYTE "0x9e";
1457 [(set_attr "length" "1")
1458 (set_attr "athlon_decode" "vector")
1459 (set_attr "amdfam10_decode" "direct")
1460 (set_attr "bdver1_decode" "direct")
1461 (set_attr "mode" "SI")])
1463 ;; Pentium Pro can do steps 1 through 3 in one go.
1464 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1465 (define_insn "*cmpfp_i_mixed"
1466 [(set (reg:CCFP FLAGS_REG)
1467 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1468 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1469 "TARGET_MIX_SSE_I387
1470 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1471 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1472 "* return output_fp_compare (insn, operands, 1, 0);"
1473 [(set_attr "type" "fcmp,ssecomi")
1474 (set_attr "prefix" "orig,maybe_vex")
1476 (if_then_else (match_operand:SF 1 "" "")
1478 (const_string "DF")))
1479 (set (attr "prefix_rep")
1480 (if_then_else (eq_attr "type" "ssecomi")
1482 (const_string "*")))
1483 (set (attr "prefix_data16")
1484 (cond [(eq_attr "type" "fcmp")
1486 (eq_attr "mode" "DF")
1489 (const_string "0")))
1490 (set_attr "athlon_decode" "vector")
1491 (set_attr "amdfam10_decode" "direct")
1492 (set_attr "bdver1_decode" "double")])
1494 (define_insn "*cmpfp_i_sse"
1495 [(set (reg:CCFP FLAGS_REG)
1496 (compare:CCFP (match_operand 0 "register_operand" "x")
1497 (match_operand 1 "nonimmediate_operand" "xm")))]
1499 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1500 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1501 "* return output_fp_compare (insn, operands, 1, 0);"
1502 [(set_attr "type" "ssecomi")
1503 (set_attr "prefix" "maybe_vex")
1505 (if_then_else (match_operand:SF 1 "" "")
1507 (const_string "DF")))
1508 (set_attr "prefix_rep" "0")
1509 (set (attr "prefix_data16")
1510 (if_then_else (eq_attr "mode" "DF")
1512 (const_string "0")))
1513 (set_attr "athlon_decode" "vector")
1514 (set_attr "amdfam10_decode" "direct")
1515 (set_attr "bdver1_decode" "double")])
1517 (define_insn "*cmpfp_i_i387"
1518 [(set (reg:CCFP FLAGS_REG)
1519 (compare:CCFP (match_operand 0 "register_operand" "f")
1520 (match_operand 1 "register_operand" "f")))]
1521 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1523 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1524 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1525 "* return output_fp_compare (insn, operands, 1, 0);"
1526 [(set_attr "type" "fcmp")
1528 (cond [(match_operand:SF 1 "" "")
1530 (match_operand:DF 1 "" "")
1533 (const_string "XF")))
1534 (set_attr "athlon_decode" "vector")
1535 (set_attr "amdfam10_decode" "direct")
1536 (set_attr "bdver1_decode" "double")])
1538 (define_insn "*cmpfp_iu_mixed"
1539 [(set (reg:CCFPU FLAGS_REG)
1540 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1541 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1542 "TARGET_MIX_SSE_I387
1543 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1544 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1545 "* return output_fp_compare (insn, operands, 1, 1);"
1546 [(set_attr "type" "fcmp,ssecomi")
1547 (set_attr "prefix" "orig,maybe_vex")
1549 (if_then_else (match_operand:SF 1 "" "")
1551 (const_string "DF")))
1552 (set (attr "prefix_rep")
1553 (if_then_else (eq_attr "type" "ssecomi")
1555 (const_string "*")))
1556 (set (attr "prefix_data16")
1557 (cond [(eq_attr "type" "fcmp")
1559 (eq_attr "mode" "DF")
1562 (const_string "0")))
1563 (set_attr "athlon_decode" "vector")
1564 (set_attr "amdfam10_decode" "direct")
1565 (set_attr "bdver1_decode" "double")])
1567 (define_insn "*cmpfp_iu_sse"
1568 [(set (reg:CCFPU FLAGS_REG)
1569 (compare:CCFPU (match_operand 0 "register_operand" "x")
1570 (match_operand 1 "nonimmediate_operand" "xm")))]
1572 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1573 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1574 "* return output_fp_compare (insn, operands, 1, 1);"
1575 [(set_attr "type" "ssecomi")
1576 (set_attr "prefix" "maybe_vex")
1578 (if_then_else (match_operand:SF 1 "" "")
1580 (const_string "DF")))
1581 (set_attr "prefix_rep" "0")
1582 (set (attr "prefix_data16")
1583 (if_then_else (eq_attr "mode" "DF")
1585 (const_string "0")))
1586 (set_attr "athlon_decode" "vector")
1587 (set_attr "amdfam10_decode" "direct")
1588 (set_attr "bdver1_decode" "double")])
1590 (define_insn "*cmpfp_iu_387"
1591 [(set (reg:CCFPU FLAGS_REG)
1592 (compare:CCFPU (match_operand 0 "register_operand" "f")
1593 (match_operand 1 "register_operand" "f")))]
1594 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1596 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1597 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1598 "* return output_fp_compare (insn, operands, 1, 1);"
1599 [(set_attr "type" "fcmp")
1601 (cond [(match_operand:SF 1 "" "")
1603 (match_operand:DF 1 "" "")
1606 (const_string "XF")))
1607 (set_attr "athlon_decode" "vector")
1608 (set_attr "amdfam10_decode" "direct")
1609 (set_attr "bdver1_decode" "direct")])
1611 ;; Push/pop instructions.
1613 (define_insn "*push<mode>2"
1614 [(set (match_operand:DWI 0 "push_operand" "=<")
1615 (match_operand:DWI 1 "general_no_elim_operand" "riF*m"))]
1620 [(set (match_operand:TI 0 "push_operand" "")
1621 (match_operand:TI 1 "general_operand" ""))]
1622 "TARGET_64BIT && reload_completed
1623 && !SSE_REG_P (operands[1])"
1625 "ix86_split_long_move (operands); DONE;")
1627 (define_insn "*pushdi2_rex64"
1628 [(set (match_operand:DI 0 "push_operand" "=<,!<")
1629 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
1634 [(set_attr "type" "push,multi")
1635 (set_attr "mode" "DI")])
1637 ;; Convert impossible pushes of immediate to existing instructions.
1638 ;; First try to get scratch register and go through it. In case this
1639 ;; fails, push sign extended lower part first and then overwrite
1640 ;; upper part by 32bit move.
1642 [(match_scratch:DI 2 "r")
1643 (set (match_operand:DI 0 "push_operand" "")
1644 (match_operand:DI 1 "immediate_operand" ""))]
1645 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1646 && !x86_64_immediate_operand (operands[1], DImode)"
1647 [(set (match_dup 2) (match_dup 1))
1648 (set (match_dup 0) (match_dup 2))])
1650 ;; We need to define this as both peepholer and splitter for case
1651 ;; peephole2 pass is not run.
1652 ;; "&& 1" is needed to keep it from matching the previous pattern.
1654 [(set (match_operand:DI 0 "push_operand" "")
1655 (match_operand:DI 1 "immediate_operand" ""))]
1656 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1657 && !x86_64_immediate_operand (operands[1], DImode) && 1"
1658 [(set (match_dup 0) (match_dup 1))
1659 (set (match_dup 2) (match_dup 3))]
1661 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1663 operands[1] = gen_lowpart (DImode, operands[2]);
1664 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1669 [(set (match_operand:DI 0 "push_operand" "")
1670 (match_operand:DI 1 "immediate_operand" ""))]
1671 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
1672 ? epilogue_completed : reload_completed)
1673 && !symbolic_operand (operands[1], DImode)
1674 && !x86_64_immediate_operand (operands[1], DImode)"
1675 [(set (match_dup 0) (match_dup 1))
1676 (set (match_dup 2) (match_dup 3))]
1678 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1680 operands[1] = gen_lowpart (DImode, operands[2]);
1681 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1686 [(set (match_operand:DI 0 "push_operand" "")
1687 (match_operand:DI 1 "general_operand" ""))]
1688 "!TARGET_64BIT && reload_completed
1689 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
1691 "ix86_split_long_move (operands); DONE;")
1693 (define_insn "*pushsi2"
1694 [(set (match_operand:SI 0 "push_operand" "=<")
1695 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1698 [(set_attr "type" "push")
1699 (set_attr "mode" "SI")])
1701 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1702 ;; "push a byte/word". But actually we use pushl, which has the effect
1703 ;; of rounding the amount pushed up to a word.
1705 ;; For TARGET_64BIT we always round up to 8 bytes.
1706 (define_insn "*push<mode>2_rex64"
1707 [(set (match_operand:SWI124 0 "push_operand" "=X")
1708 (match_operand:SWI124 1 "nonmemory_no_elim_operand" "r<i>"))]
1711 [(set_attr "type" "push")
1712 (set_attr "mode" "DI")])
1714 (define_insn "*push<mode>2"
1715 [(set (match_operand:SWI12 0 "push_operand" "=X")
1716 (match_operand:SWI12 1 "nonmemory_no_elim_operand" "rn"))]
1719 [(set_attr "type" "push")
1720 (set_attr "mode" "SI")])
1722 (define_insn "*push<mode>2_prologue"
1723 [(set (match_operand:P 0 "push_operand" "=<")
1724 (match_operand:P 1 "general_no_elim_operand" "r<i>*m"))
1725 (clobber (mem:BLK (scratch)))]
1727 "push{<imodesuffix>}\t%1"
1728 [(set_attr "type" "push")
1729 (set_attr "mode" "<MODE>")])
1731 (define_insn "*pop<mode>1"
1732 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1733 (match_operand:P 1 "pop_operand" ">"))]
1735 "pop{<imodesuffix>}\t%0"
1736 [(set_attr "type" "pop")
1737 (set_attr "mode" "<MODE>")])
1739 (define_insn "*pop<mode>1_epilogue"
1740 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1741 (match_operand:P 1 "pop_operand" ">"))
1742 (clobber (mem:BLK (scratch)))]
1744 "pop{<imodesuffix>}\t%0"
1745 [(set_attr "type" "pop")
1746 (set_attr "mode" "<MODE>")])
1748 ;; Move instructions.
1750 (define_expand "movoi"
1751 [(set (match_operand:OI 0 "nonimmediate_operand" "")
1752 (match_operand:OI 1 "general_operand" ""))]
1754 "ix86_expand_move (OImode, operands); DONE;")
1756 (define_expand "movti"
1757 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1758 (match_operand:TI 1 "nonimmediate_operand" ""))]
1759 "TARGET_64BIT || TARGET_SSE"
1762 ix86_expand_move (TImode, operands);
1763 else if (push_operand (operands[0], TImode))
1764 ix86_expand_push (TImode, operands[1]);
1766 ix86_expand_vector_move (TImode, operands);
1770 ;; This expands to what emit_move_complex would generate if we didn't
1771 ;; have a movti pattern. Having this avoids problems with reload on
1772 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
1773 ;; to have around all the time.
1774 (define_expand "movcdi"
1775 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
1776 (match_operand:CDI 1 "general_operand" ""))]
1779 if (push_operand (operands[0], CDImode))
1780 emit_move_complex_push (CDImode, operands[0], operands[1]);
1782 emit_move_complex_parts (operands[0], operands[1]);
1786 (define_expand "mov<mode>"
1787 [(set (match_operand:SWI1248x 0 "nonimmediate_operand" "")
1788 (match_operand:SWI1248x 1 "general_operand" ""))]
1790 "ix86_expand_move (<MODE>mode, operands); DONE;")
1792 (define_insn "*mov<mode>_xor"
1793 [(set (match_operand:SWI48 0 "register_operand" "=r")
1794 (match_operand:SWI48 1 "const0_operand" ""))
1795 (clobber (reg:CC FLAGS_REG))]
1798 [(set_attr "type" "alu1")
1799 (set_attr "mode" "SI")
1800 (set_attr "length_immediate" "0")])
1802 (define_insn "*mov<mode>_or"
1803 [(set (match_operand:SWI48 0 "register_operand" "=r")
1804 (match_operand:SWI48 1 "const_int_operand" ""))
1805 (clobber (reg:CC FLAGS_REG))]
1807 && operands[1] == constm1_rtx"
1808 "or{<imodesuffix>}\t{%1, %0|%0, %1}"
1809 [(set_attr "type" "alu1")
1810 (set_attr "mode" "<MODE>")
1811 (set_attr "length_immediate" "1")])
1813 (define_insn "*movoi_internal_avx"
1814 [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
1815 (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
1816 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1818 switch (which_alternative)
1821 return "vxorps\t%0, %0, %0";
1824 if (misaligned_operand (operands[0], OImode)
1825 || misaligned_operand (operands[1], OImode))
1826 return "vmovdqu\t{%1, %0|%0, %1}";
1828 return "vmovdqa\t{%1, %0|%0, %1}";
1833 [(set_attr "type" "sselog1,ssemov,ssemov")
1834 (set_attr "prefix" "vex")
1835 (set_attr "mode" "OI")])
1837 (define_insn "*movti_internal_rex64"
1838 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
1839 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
1840 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1842 switch (which_alternative)
1848 if (get_attr_mode (insn) == MODE_V4SF)
1849 return "%vxorps\t%0, %d0";
1851 return "%vpxor\t%0, %d0";
1854 /* TDmode values are passed as TImode on the stack. Moving them
1855 to stack may result in unaligned memory access. */
1856 if (misaligned_operand (operands[0], TImode)
1857 || misaligned_operand (operands[1], TImode))
1859 if (get_attr_mode (insn) == MODE_V4SF)
1860 return "%vmovups\t{%1, %0|%0, %1}";
1862 return "%vmovdqu\t{%1, %0|%0, %1}";
1866 if (get_attr_mode (insn) == MODE_V4SF)
1867 return "%vmovaps\t{%1, %0|%0, %1}";
1869 return "%vmovdqa\t{%1, %0|%0, %1}";
1875 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
1876 (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
1878 (cond [(eq_attr "alternative" "2,3")
1880 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1882 (const_string "V4SF")
1883 (const_string "TI"))
1884 (eq_attr "alternative" "4")
1886 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1888 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1890 (const_string "V4SF")
1891 (const_string "TI"))]
1892 (const_string "DI")))])
1895 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1896 (match_operand:TI 1 "general_operand" ""))]
1898 && !SSE_REG_P (operands[0]) && !SSE_REG_P (operands[1])"
1900 "ix86_split_long_move (operands); DONE;")
1902 (define_insn "*movti_internal_sse"
1903 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
1904 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
1905 "TARGET_SSE && !TARGET_64BIT
1906 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1908 switch (which_alternative)
1911 if (get_attr_mode (insn) == MODE_V4SF)
1912 return "%vxorps\t%0, %d0";
1914 return "%vpxor\t%0, %d0";
1917 /* TDmode values are passed as TImode on the stack. Moving them
1918 to stack may result in unaligned memory access. */
1919 if (misaligned_operand (operands[0], TImode)
1920 || misaligned_operand (operands[1], TImode))
1922 if (get_attr_mode (insn) == MODE_V4SF)
1923 return "%vmovups\t{%1, %0|%0, %1}";
1925 return "%vmovdqu\t{%1, %0|%0, %1}";
1929 if (get_attr_mode (insn) == MODE_V4SF)
1930 return "%vmovaps\t{%1, %0|%0, %1}";
1932 return "%vmovdqa\t{%1, %0|%0, %1}";
1938 [(set_attr "type" "sselog1,ssemov,ssemov")
1939 (set_attr "prefix" "maybe_vex")
1941 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1942 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1944 (const_string "V4SF")
1945 (and (eq_attr "alternative" "2")
1946 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1948 (const_string "V4SF")]
1949 (const_string "TI")))])
1951 (define_insn "*movdi_internal_rex64"
1952 [(set (match_operand:DI 0 "nonimmediate_operand"
1953 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
1954 (match_operand:DI 1 "general_operand"
1955 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
1956 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1958 switch (get_attr_type (insn))
1961 if (SSE_REG_P (operands[0]))
1962 return "movq2dq\t{%1, %0|%0, %1}";
1964 return "movdq2q\t{%1, %0|%0, %1}";
1969 if (get_attr_mode (insn) == MODE_TI)
1970 return "vmovdqa\t{%1, %0|%0, %1}";
1972 return "vmovq\t{%1, %0|%0, %1}";
1975 if (get_attr_mode (insn) == MODE_TI)
1976 return "movdqa\t{%1, %0|%0, %1}";
1980 /* Moves from and into integer register is done using movd
1981 opcode with REX prefix. */
1982 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
1983 return "movd\t{%1, %0|%0, %1}";
1984 return "movq\t{%1, %0|%0, %1}";
1987 return "%vpxor\t%0, %d0";
1990 return "pxor\t%0, %0";
1996 return "lea{q}\t{%a1, %0|%0, %a1}";
1999 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2000 if (get_attr_mode (insn) == MODE_SI)
2001 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2002 else if (which_alternative == 2)
2003 return "movabs{q}\t{%1, %0|%0, %1}";
2005 return "mov{q}\t{%1, %0|%0, %1}";
2009 (cond [(eq_attr "alternative" "5")
2010 (const_string "mmx")
2011 (eq_attr "alternative" "6,7,8,9,10")
2012 (const_string "mmxmov")
2013 (eq_attr "alternative" "11")
2014 (const_string "sselog1")
2015 (eq_attr "alternative" "12,13,14,15,16")
2016 (const_string "ssemov")
2017 (eq_attr "alternative" "17,18")
2018 (const_string "ssecvt")
2019 (eq_attr "alternative" "4")
2020 (const_string "multi")
2021 (match_operand:DI 1 "pic_32bit_operand" "")
2022 (const_string "lea")
2024 (const_string "imov")))
2027 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2029 (const_string "*")))
2030 (set (attr "length_immediate")
2032 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2034 (const_string "*")))
2035 (set_attr "prefix_rex" "*,*,*,*,*,*,*,1,*,1,*,*,*,*,*,*,*,*,*")
2036 (set_attr "prefix_data16" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,1,*,*,*")
2037 (set (attr "prefix")
2038 (if_then_else (eq_attr "alternative" "11,12,13,14,15,16")
2039 (const_string "maybe_vex")
2040 (const_string "orig")))
2041 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2043 ;; Convert impossible stores of immediate to existing instructions.
2044 ;; First try to get scratch register and go through it. In case this
2045 ;; fails, move by 32bit parts.
2047 [(match_scratch:DI 2 "r")
2048 (set (match_operand:DI 0 "memory_operand" "")
2049 (match_operand:DI 1 "immediate_operand" ""))]
2050 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2051 && !x86_64_immediate_operand (operands[1], DImode)"
2052 [(set (match_dup 2) (match_dup 1))
2053 (set (match_dup 0) (match_dup 2))])
2055 ;; We need to define this as both peepholer and splitter for case
2056 ;; peephole2 pass is not run.
2057 ;; "&& 1" is needed to keep it from matching the previous pattern.
2059 [(set (match_operand:DI 0 "memory_operand" "")
2060 (match_operand:DI 1 "immediate_operand" ""))]
2061 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2062 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2063 [(set (match_dup 2) (match_dup 3))
2064 (set (match_dup 4) (match_dup 5))]
2065 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2068 [(set (match_operand:DI 0 "memory_operand" "")
2069 (match_operand:DI 1 "immediate_operand" ""))]
2070 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2071 ? epilogue_completed : reload_completed)
2072 && !symbolic_operand (operands[1], DImode)
2073 && !x86_64_immediate_operand (operands[1], DImode)"
2074 [(set (match_dup 2) (match_dup 3))
2075 (set (match_dup 4) (match_dup 5))]
2076 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2078 (define_insn "*movdi_internal"
2079 [(set (match_operand:DI 0 "nonimmediate_operand"
2080 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2081 (match_operand:DI 1 "general_operand"
2082 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2083 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2088 movq\t{%1, %0|%0, %1}
2089 movq\t{%1, %0|%0, %1}
2091 %vmovq\t{%1, %0|%0, %1}
2092 %vmovdqa\t{%1, %0|%0, %1}
2093 %vmovq\t{%1, %0|%0, %1}
2095 movlps\t{%1, %0|%0, %1}
2096 movaps\t{%1, %0|%0, %1}
2097 movlps\t{%1, %0|%0, %1}"
2098 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2099 (set (attr "prefix")
2100 (if_then_else (eq_attr "alternative" "5,6,7,8")
2101 (const_string "vex")
2102 (const_string "orig")))
2103 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2106 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2107 (match_operand:DI 1 "general_operand" ""))]
2108 "!TARGET_64BIT && reload_completed
2109 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))
2110 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
2112 "ix86_split_long_move (operands); DONE;")
2114 (define_insn "*movsi_internal"
2115 [(set (match_operand:SI 0 "nonimmediate_operand"
2116 "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
2117 (match_operand:SI 1 "general_operand"
2118 "g ,ri,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
2119 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2121 switch (get_attr_type (insn))
2124 if (get_attr_mode (insn) == MODE_TI)
2125 return "%vpxor\t%0, %d0";
2126 return "%vxorps\t%0, %d0";
2129 switch (get_attr_mode (insn))
2132 return "%vmovdqa\t{%1, %0|%0, %1}";
2134 return "%vmovaps\t{%1, %0|%0, %1}";
2136 return "%vmovd\t{%1, %0|%0, %1}";
2138 return "%vmovss\t{%1, %0|%0, %1}";
2144 return "pxor\t%0, %0";
2147 if (get_attr_mode (insn) == MODE_DI)
2148 return "movq\t{%1, %0|%0, %1}";
2149 return "movd\t{%1, %0|%0, %1}";
2152 return "lea{l}\t{%a1, %0|%0, %a1}";
2155 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2156 return "mov{l}\t{%1, %0|%0, %1}";
2160 (cond [(eq_attr "alternative" "2")
2161 (const_string "mmx")
2162 (eq_attr "alternative" "3,4,5")
2163 (const_string "mmxmov")
2164 (eq_attr "alternative" "6")
2165 (const_string "sselog1")
2166 (eq_attr "alternative" "7,8,9,10,11")
2167 (const_string "ssemov")
2168 (match_operand:DI 1 "pic_32bit_operand" "")
2169 (const_string "lea")
2171 (const_string "imov")))
2172 (set (attr "prefix")
2173 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
2174 (const_string "orig")
2175 (const_string "maybe_vex")))
2176 (set (attr "prefix_data16")
2177 (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
2179 (const_string "*")))
2181 (cond [(eq_attr "alternative" "2,3")
2183 (eq_attr "alternative" "6,7")
2185 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2186 (const_string "V4SF")
2187 (const_string "TI"))
2188 (and (eq_attr "alternative" "8,9,10,11")
2189 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
2192 (const_string "SI")))])
2194 (define_insn "*movhi_internal"
2195 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
2196 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
2197 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2199 switch (get_attr_type (insn))
2202 /* movzwl is faster than movw on p2 due to partial word stalls,
2203 though not as fast as an aligned movl. */
2204 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
2206 if (get_attr_mode (insn) == MODE_SI)
2207 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2209 return "mov{w}\t{%1, %0|%0, %1}";
2213 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
2215 (const_string "imov")
2216 (and (eq_attr "alternative" "0")
2217 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2219 (eq (symbol_ref "TARGET_HIMODE_MATH")
2221 (const_string "imov")
2222 (and (eq_attr "alternative" "1,2")
2223 (match_operand:HI 1 "aligned_operand" ""))
2224 (const_string "imov")
2225 (and (ne (symbol_ref "TARGET_MOVX")
2227 (eq_attr "alternative" "0,2"))
2228 (const_string "imovx")
2230 (const_string "imov")))
2232 (cond [(eq_attr "type" "imovx")
2234 (and (eq_attr "alternative" "1,2")
2235 (match_operand:HI 1 "aligned_operand" ""))
2237 (and (eq_attr "alternative" "0")
2238 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2240 (eq (symbol_ref "TARGET_HIMODE_MATH")
2244 (const_string "HI")))])
2246 ;; Situation is quite tricky about when to choose full sized (SImode) move
2247 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
2248 ;; partial register dependency machines (such as AMD Athlon), where QImode
2249 ;; moves issue extra dependency and for partial register stalls machines
2250 ;; that don't use QImode patterns (and QImode move cause stall on the next
2253 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2254 ;; register stall machines with, where we use QImode instructions, since
2255 ;; partial register stall can be caused there. Then we use movzx.
2256 (define_insn "*movqi_internal"
2257 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2258 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
2259 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2261 switch (get_attr_type (insn))
2264 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2265 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2267 if (get_attr_mode (insn) == MODE_SI)
2268 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2270 return "mov{b}\t{%1, %0|%0, %1}";
2274 (cond [(and (eq_attr "alternative" "5")
2275 (not (match_operand:QI 1 "aligned_operand" "")))
2276 (const_string "imovx")
2277 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2279 (const_string "imov")
2280 (and (eq_attr "alternative" "3")
2281 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2283 (eq (symbol_ref "TARGET_QIMODE_MATH")
2285 (const_string "imov")
2286 (eq_attr "alternative" "3,5")
2287 (const_string "imovx")
2288 (and (ne (symbol_ref "TARGET_MOVX")
2290 (eq_attr "alternative" "2"))
2291 (const_string "imovx")
2293 (const_string "imov")))
2295 (cond [(eq_attr "alternative" "3,4,5")
2297 (eq_attr "alternative" "6")
2299 (eq_attr "type" "imovx")
2301 (and (eq_attr "type" "imov")
2302 (and (eq_attr "alternative" "0,1")
2303 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2305 (and (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2307 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2310 ;; Avoid partial register stalls when not using QImode arithmetic
2311 (and (eq_attr "type" "imov")
2312 (and (eq_attr "alternative" "0,1")
2313 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2315 (eq (symbol_ref "TARGET_QIMODE_MATH")
2319 (const_string "QI")))])
2321 ;; Stores and loads of ax to arbitrary constant address.
2322 ;; We fake an second form of instruction to force reload to load address
2323 ;; into register when rax is not available
2324 (define_insn "*movabs<mode>_1"
2325 [(set (mem:SWI1248x (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2326 (match_operand:SWI1248x 1 "nonmemory_operand" "a,er"))]
2327 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2329 movabs{<imodesuffix>}\t{%1, %P0|%P0, %1}
2330 mov{<imodesuffix>}\t{%1, %a0|%a0, %1}"
2331 [(set_attr "type" "imov")
2332 (set_attr "modrm" "0,*")
2333 (set_attr "length_address" "8,0")
2334 (set_attr "length_immediate" "0,*")
2335 (set_attr "memory" "store")
2336 (set_attr "mode" "<MODE>")])
2338 (define_insn "*movabs<mode>_2"
2339 [(set (match_operand:SWI1248x 0 "register_operand" "=a,r")
2340 (mem:SWI1248x (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2341 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2343 movabs{<imodesuffix>}\t{%P1, %0|%0, %P1}
2344 mov{<imodesuffix>}\t{%a1, %0|%0, %a1}"
2345 [(set_attr "type" "imov")
2346 (set_attr "modrm" "0,*")
2347 (set_attr "length_address" "8,0")
2348 (set_attr "length_immediate" "0")
2349 (set_attr "memory" "load")
2350 (set_attr "mode" "<MODE>")])
2352 (define_insn "*swap<mode>"
2353 [(set (match_operand:SWI48 0 "register_operand" "+r")
2354 (match_operand:SWI48 1 "register_operand" "+r"))
2358 "xchg{<imodesuffix>}\t%1, %0"
2359 [(set_attr "type" "imov")
2360 (set_attr "mode" "<MODE>")
2361 (set_attr "pent_pair" "np")
2362 (set_attr "athlon_decode" "vector")
2363 (set_attr "amdfam10_decode" "double")
2364 (set_attr "bdver1_decode" "double")])
2366 (define_insn "*swap<mode>_1"
2367 [(set (match_operand:SWI12 0 "register_operand" "+r")
2368 (match_operand:SWI12 1 "register_operand" "+r"))
2371 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2373 [(set_attr "type" "imov")
2374 (set_attr "mode" "SI")
2375 (set_attr "pent_pair" "np")
2376 (set_attr "athlon_decode" "vector")
2377 (set_attr "amdfam10_decode" "double")
2378 (set_attr "bdver1_decode" "double")])
2380 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL
2381 ;; is disabled for AMDFAM10
2382 (define_insn "*swap<mode>_2"
2383 [(set (match_operand:SWI12 0 "register_operand" "+<r>")
2384 (match_operand:SWI12 1 "register_operand" "+<r>"))
2387 "TARGET_PARTIAL_REG_STALL"
2388 "xchg{<imodesuffix>}\t%1, %0"
2389 [(set_attr "type" "imov")
2390 (set_attr "mode" "<MODE>")
2391 (set_attr "pent_pair" "np")
2392 (set_attr "athlon_decode" "vector")])
2394 (define_expand "movstrict<mode>"
2395 [(set (strict_low_part (match_operand:SWI12 0 "nonimmediate_operand" ""))
2396 (match_operand:SWI12 1 "general_operand" ""))]
2399 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2401 /* Don't generate memory->memory moves, go through a register */
2402 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2403 operands[1] = force_reg (<MODE>mode, operands[1]);
2406 (define_insn "*movstrict<mode>_1"
2407 [(set (strict_low_part
2408 (match_operand:SWI12 0 "nonimmediate_operand" "+<r>m,<r>"))
2409 (match_operand:SWI12 1 "general_operand" "<r>n,m"))]
2410 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2411 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2412 "mov{<imodesuffix>}\t{%1, %0|%0, %1}"
2413 [(set_attr "type" "imov")
2414 (set_attr "mode" "<MODE>")])
2416 (define_insn "*movstrict<mode>_xor"
2417 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
2418 (match_operand:SWI12 1 "const0_operand" ""))
2419 (clobber (reg:CC FLAGS_REG))]
2421 "xor{<imodesuffix>}\t%0, %0"
2422 [(set_attr "type" "alu1")
2423 (set_attr "mode" "<MODE>")
2424 (set_attr "length_immediate" "0")])
2426 (define_insn "*mov<mode>_extv_1"
2427 [(set (match_operand:SWI24 0 "register_operand" "=R")
2428 (sign_extract:SWI24 (match_operand 1 "ext_register_operand" "Q")
2432 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2433 [(set_attr "type" "imovx")
2434 (set_attr "mode" "SI")])
2436 (define_insn "*movqi_extv_1_rex64"
2437 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2438 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2443 switch (get_attr_type (insn))
2446 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2448 return "mov{b}\t{%h1, %0|%0, %h1}";
2452 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2453 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2454 (ne (symbol_ref "TARGET_MOVX")
2456 (const_string "imovx")
2457 (const_string "imov")))
2459 (if_then_else (eq_attr "type" "imovx")
2461 (const_string "QI")))])
2463 (define_insn "*movqi_extv_1"
2464 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2465 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2470 switch (get_attr_type (insn))
2473 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2475 return "mov{b}\t{%h1, %0|%0, %h1}";
2479 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2480 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2481 (ne (symbol_ref "TARGET_MOVX")
2483 (const_string "imovx")
2484 (const_string "imov")))
2486 (if_then_else (eq_attr "type" "imovx")
2488 (const_string "QI")))])
2490 (define_insn "*mov<mode>_extzv_1"
2491 [(set (match_operand:SWI48 0 "register_operand" "=R")
2492 (zero_extract:SWI48 (match_operand 1 "ext_register_operand" "Q")
2496 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2497 [(set_attr "type" "imovx")
2498 (set_attr "mode" "SI")])
2500 (define_insn "*movqi_extzv_2_rex64"
2501 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2503 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2508 switch (get_attr_type (insn))
2511 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2513 return "mov{b}\t{%h1, %0|%0, %h1}";
2517 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2518 (ne (symbol_ref "TARGET_MOVX")
2520 (const_string "imovx")
2521 (const_string "imov")))
2523 (if_then_else (eq_attr "type" "imovx")
2525 (const_string "QI")))])
2527 (define_insn "*movqi_extzv_2"
2528 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2530 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2535 switch (get_attr_type (insn))
2538 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2540 return "mov{b}\t{%h1, %0|%0, %h1}";
2544 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2545 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2546 (ne (symbol_ref "TARGET_MOVX")
2548 (const_string "imovx")
2549 (const_string "imov")))
2551 (if_then_else (eq_attr "type" "imovx")
2553 (const_string "QI")))])
2555 (define_expand "mov<mode>_insv_1"
2556 [(set (zero_extract:SWI48 (match_operand 0 "ext_register_operand" "")
2559 (match_operand:SWI48 1 "nonmemory_operand" ""))])
2561 (define_insn "*mov<mode>_insv_1_rex64"
2562 [(set (zero_extract:SWI48x (match_operand 0 "ext_register_operand" "+Q")
2565 (match_operand:SWI48x 1 "nonmemory_operand" "Qn"))]
2567 "mov{b}\t{%b1, %h0|%h0, %b1}"
2568 [(set_attr "type" "imov")
2569 (set_attr "mode" "QI")])
2571 (define_insn "*movsi_insv_1"
2572 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2575 (match_operand:SI 1 "general_operand" "Qmn"))]
2577 "mov{b}\t{%b1, %h0|%h0, %b1}"
2578 [(set_attr "type" "imov")
2579 (set_attr "mode" "QI")])
2581 (define_insn "*movqi_insv_2"
2582 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2585 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2588 "mov{b}\t{%h1, %h0|%h0, %h1}"
2589 [(set_attr "type" "imov")
2590 (set_attr "mode" "QI")])
2592 ;; Floating point push instructions.
2594 (define_insn "*pushtf"
2595 [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2596 (match_operand:TF 1 "general_no_elim_operand" "x,Fo,*r"))]
2599 /* This insn should be already split before reg-stack. */
2602 [(set_attr "type" "multi")
2603 (set_attr "unit" "sse,*,*")
2604 (set_attr "mode" "TF,SI,SI")])
2607 [(set (match_operand:TF 0 "push_operand" "")
2608 (match_operand:TF 1 "sse_reg_operand" ""))]
2609 "TARGET_SSE2 && reload_completed"
2610 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
2611 (set (mem:TF (reg:P SP_REG)) (match_dup 1))])
2614 [(set (match_operand:TF 0 "push_operand" "")
2615 (match_operand:TF 1 "general_operand" ""))]
2616 "TARGET_SSE2 && reload_completed
2617 && !SSE_REG_P (operands[1])"
2619 "ix86_split_long_move (operands); DONE;")
2621 (define_insn "*pushxf"
2622 [(set (match_operand:XF 0 "push_operand" "=<,<")
2623 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
2624 "optimize_function_for_speed_p (cfun)"
2626 /* This insn should be already split before reg-stack. */
2629 [(set_attr "type" "multi")
2630 (set_attr "unit" "i387,*")
2631 (set_attr "mode" "XF,SI")])
2633 ;; Size of pushxf is 3 (for sub) + 2 (for fstp) + memory operand size.
2634 ;; Size of pushxf using integer instructions is 3+3*memory operand size
2635 ;; Pushing using integer instructions is longer except for constants
2636 ;; and direct memory references (assuming that any given constant is pushed
2637 ;; only once, but this ought to be handled elsewhere).
2639 (define_insn "*pushxf_nointeger"
2640 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
2641 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
2642 "optimize_function_for_size_p (cfun)"
2644 /* This insn should be already split before reg-stack. */
2647 [(set_attr "type" "multi")
2648 (set_attr "unit" "i387,*,*")
2649 (set_attr "mode" "XF,SI,SI")])
2652 [(set (match_operand:XF 0 "push_operand" "")
2653 (match_operand:XF 1 "fp_register_operand" ""))]
2655 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2656 (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
2657 "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
2660 [(set (match_operand:XF 0 "push_operand" "")
2661 (match_operand:XF 1 "general_operand" ""))]
2663 && !FP_REG_P (operands[1])"
2665 "ix86_split_long_move (operands); DONE;")
2667 (define_insn "*pushdf"
2668 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2669 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
2670 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2672 /* This insn should be already split before reg-stack. */
2675 [(set_attr "type" "multi")
2676 (set_attr "unit" "i387,*,*")
2677 (set_attr "mode" "DF,SI,DF")])
2679 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2680 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2681 ;; On the average, pushdf using integers can be still shorter. Allow this
2682 ;; pattern for optimize_size too.
2684 (define_insn "*pushdf_nointeger"
2685 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2686 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
2687 "!(TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES)"
2689 /* This insn should be already split before reg-stack. */
2692 [(set_attr "type" "multi")
2693 (set_attr "unit" "i387,*,*,*")
2694 (set_attr "mode" "DF,SI,SI,DF")])
2696 ;; %%% Kill this when call knows how to work this out.
2698 [(set (match_operand:DF 0 "push_operand" "")
2699 (match_operand:DF 1 "any_fp_register_operand" ""))]
2701 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
2702 (set (mem:DF (reg:P SP_REG)) (match_dup 1))])
2705 [(set (match_operand:DF 0 "push_operand" "")
2706 (match_operand:DF 1 "general_operand" ""))]
2708 && !ANY_FP_REG_P (operands[1])"
2710 "ix86_split_long_move (operands); DONE;")
2712 (define_insn "*pushsf_rex64"
2713 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2714 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2717 /* Anything else should be already split before reg-stack. */
2718 gcc_assert (which_alternative == 1);
2719 return "push{q}\t%q1";
2721 [(set_attr "type" "multi,push,multi")
2722 (set_attr "unit" "i387,*,*")
2723 (set_attr "mode" "SF,DI,SF")])
2725 (define_insn "*pushsf"
2726 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2727 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2730 /* Anything else should be already split before reg-stack. */
2731 gcc_assert (which_alternative == 1);
2732 return "push{l}\t%1";
2734 [(set_attr "type" "multi,push,multi")
2735 (set_attr "unit" "i387,*,*")
2736 (set_attr "mode" "SF,SI,SF")])
2739 [(set (match_operand:SF 0 "push_operand" "")
2740 (match_operand:SF 1 "memory_operand" ""))]
2742 && MEM_P (operands[1])
2743 && (operands[2] = find_constant_src (insn))"
2747 ;; %%% Kill this when call knows how to work this out.
2749 [(set (match_operand:SF 0 "push_operand" "")
2750 (match_operand:SF 1 "any_fp_register_operand" ""))]
2752 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2753 (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
2754 "operands[2] = GEN_INT (-GET_MODE_SIZE (<MODE>mode));")
2756 ;; Floating point move instructions.
2758 (define_expand "movtf"
2759 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2760 (match_operand:TF 1 "nonimmediate_operand" ""))]
2763 ix86_expand_move (TFmode, operands);
2767 (define_expand "mov<mode>"
2768 [(set (match_operand:X87MODEF 0 "nonimmediate_operand" "")
2769 (match_operand:X87MODEF 1 "general_operand" ""))]
2771 "ix86_expand_move (<MODE>mode, operands); DONE;")
2773 (define_insn "*movtf_internal"
2774 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?r,?o")
2775 (match_operand:TF 1 "general_operand" "xm,x,C,roF,Fr"))]
2777 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2779 switch (which_alternative)
2783 if (get_attr_mode (insn) == MODE_V4SF)
2784 return "%vmovaps\t{%1, %0|%0, %1}";
2786 return "%vmovdqa\t{%1, %0|%0, %1}";
2788 if (get_attr_mode (insn) == MODE_V4SF)
2789 return "%vxorps\t%0, %d0";
2791 return "%vpxor\t%0, %d0";
2799 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
2800 (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,*,*")
2802 (cond [(eq_attr "alternative" "0,2")
2804 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2806 (const_string "V4SF")
2807 (const_string "TI"))
2808 (eq_attr "alternative" "1")
2810 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2812 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2814 (const_string "V4SF")
2815 (const_string "TI"))]
2816 (const_string "DI")))])
2819 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2820 (match_operand:TF 1 "general_operand" ""))]
2822 && !(SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]))"
2824 "ix86_split_long_move (operands); DONE;")
2826 (define_insn "*movxf_internal"
2827 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,r,o")
2828 (match_operand:XF 1 "general_operand" "fm,f,G,roF,Fr"))]
2829 "optimize_function_for_speed_p (cfun)
2830 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2831 && (reload_in_progress || reload_completed
2832 || GET_CODE (operands[1]) != CONST_DOUBLE
2833 || memory_operand (operands[0], XFmode))"
2835 switch (which_alternative)
2839 return output_387_reg_move (insn, operands);
2842 return standard_80387_constant_opcode (operands[1]);
2851 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2852 (set_attr "mode" "XF,XF,XF,SI,SI")])
2854 ;; Do not use integer registers when optimizing for size
2855 (define_insn "*movxf_internal_nointeger"
2856 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2857 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2858 "optimize_function_for_size_p (cfun)
2859 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2860 && (reload_in_progress || reload_completed
2861 || standard_80387_constant_p (operands[1])
2862 || GET_CODE (operands[1]) != CONST_DOUBLE
2863 || memory_operand (operands[0], XFmode))"
2865 switch (which_alternative)
2869 return output_387_reg_move (insn, operands);
2872 return standard_80387_constant_opcode (operands[1]);
2880 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2881 (set_attr "mode" "XF,XF,XF,SI,SI")])
2884 [(set (match_operand:XF 0 "nonimmediate_operand" "")
2885 (match_operand:XF 1 "general_operand" ""))]
2887 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2888 && ! (FP_REG_P (operands[0]) ||
2889 (GET_CODE (operands[0]) == SUBREG
2890 && FP_REG_P (SUBREG_REG (operands[0]))))
2891 && ! (FP_REG_P (operands[1]) ||
2892 (GET_CODE (operands[1]) == SUBREG
2893 && FP_REG_P (SUBREG_REG (operands[1]))))"
2895 "ix86_split_long_move (operands); DONE;")
2897 (define_insn "*movdf_internal_rex64"
2898 [(set (match_operand:DF 0 "nonimmediate_operand"
2899 "=f,m,f,r ,m ,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
2900 (match_operand:DF 1 "general_operand"
2901 "fm,f,G,rmF,Fr,C ,Y2*x,m ,Y2*x,r ,Yi"))]
2902 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2903 && (reload_in_progress || reload_completed
2904 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2905 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
2906 && optimize_function_for_size_p (cfun)
2907 && standard_80387_constant_p (operands[1]))
2908 || GET_CODE (operands[1]) != CONST_DOUBLE
2909 || memory_operand (operands[0], DFmode))"
2911 switch (which_alternative)
2915 return output_387_reg_move (insn, operands);
2918 return standard_80387_constant_opcode (operands[1]);
2925 switch (get_attr_mode (insn))
2928 return "%vxorps\t%0, %d0";
2930 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2931 return "%vxorps\t%0, %d0";
2933 return "%vxorpd\t%0, %d0";
2935 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2936 return "%vxorps\t%0, %d0";
2938 return "%vpxor\t%0, %d0";
2945 switch (get_attr_mode (insn))
2948 return "%vmovaps\t{%1, %0|%0, %1}";
2950 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2951 return "%vmovaps\t{%1, %0|%0, %1}";
2953 return "%vmovapd\t{%1, %0|%0, %1}";
2955 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2956 return "%vmovaps\t{%1, %0|%0, %1}";
2958 return "%vmovdqa\t{%1, %0|%0, %1}";
2960 return "%vmovq\t{%1, %0|%0, %1}";
2964 if (REG_P (operands[0]) && REG_P (operands[1]))
2965 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
2967 return "vmovsd\t{%1, %0|%0, %1}";
2970 return "movsd\t{%1, %0|%0, %1}";
2972 return "%vmovlpd\t{%1, %d0|%d0, %1}";
2974 return "%vmovlps\t{%1, %d0|%d0, %1}";
2981 return "%vmovd\t{%1, %0|%0, %1}";
2987 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
2988 (set (attr "prefix")
2989 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
2990 (const_string "orig")
2991 (const_string "maybe_vex")))
2992 (set (attr "prefix_data16")
2993 (if_then_else (eq_attr "mode" "V1DF")
2995 (const_string "*")))
2997 (cond [(eq_attr "alternative" "0,1,2")
2999 (eq_attr "alternative" "3,4,9,10")
3002 /* For SSE1, we have many fewer alternatives. */
3003 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3004 (cond [(eq_attr "alternative" "5,6")
3005 (const_string "V4SF")
3007 (const_string "V2SF"))
3009 /* xorps is one byte shorter. */
3010 (eq_attr "alternative" "5")
3011 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3013 (const_string "V4SF")
3014 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3018 (const_string "V2DF"))
3020 /* For architectures resolving dependencies on
3021 whole SSE registers use APD move to break dependency
3022 chains, otherwise use short move to avoid extra work.
3024 movaps encodes one byte shorter. */
3025 (eq_attr "alternative" "6")
3027 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3029 (const_string "V4SF")
3030 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3032 (const_string "V2DF")
3034 (const_string "DF"))
3035 /* For architectures resolving dependencies on register
3036 parts we may avoid extra work to zero out upper part
3038 (eq_attr "alternative" "7")
3040 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3042 (const_string "V1DF")
3043 (const_string "DF"))
3045 (const_string "DF")))])
3047 (define_insn "*movdf_internal"
3048 [(set (match_operand:DF 0 "nonimmediate_operand"
3049 "=f,m,f,r ,o ,Y2*x,Y2*x,Y2*x,m ")
3050 (match_operand:DF 1 "general_operand"
3051 "fm,f,G,roF,Fr,C ,Y2*x,m ,Y2*x"))]
3052 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3053 && optimize_function_for_speed_p (cfun)
3054 && TARGET_INTEGER_DFMODE_MOVES
3055 && (reload_in_progress || reload_completed
3056 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3057 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3058 && optimize_function_for_size_p (cfun)
3059 && standard_80387_constant_p (operands[1]))
3060 || GET_CODE (operands[1]) != CONST_DOUBLE
3061 || memory_operand (operands[0], DFmode))"
3063 switch (which_alternative)
3067 return output_387_reg_move (insn, operands);
3070 return standard_80387_constant_opcode (operands[1]);
3077 switch (get_attr_mode (insn))
3080 return "xorps\t%0, %0";
3082 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3083 return "xorps\t%0, %0";
3085 return "xorpd\t%0, %0";
3087 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3088 return "xorps\t%0, %0";
3090 return "pxor\t%0, %0";
3097 switch (get_attr_mode (insn))
3100 return "movaps\t{%1, %0|%0, %1}";
3102 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3103 return "movaps\t{%1, %0|%0, %1}";
3105 return "movapd\t{%1, %0|%0, %1}";
3107 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3108 return "movaps\t{%1, %0|%0, %1}";
3110 return "movdqa\t{%1, %0|%0, %1}";
3112 return "movq\t{%1, %0|%0, %1}";
3114 return "movsd\t{%1, %0|%0, %1}";
3116 return "movlpd\t{%1, %0|%0, %1}";
3118 return "movlps\t{%1, %0|%0, %1}";
3127 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3128 (set (attr "prefix_data16")
3129 (if_then_else (eq_attr "mode" "V1DF")
3131 (const_string "*")))
3133 (cond [(eq_attr "alternative" "0,1,2")
3135 (eq_attr "alternative" "3,4")
3138 /* For SSE1, we have many fewer alternatives. */
3139 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3140 (cond [(eq_attr "alternative" "5,6")
3141 (const_string "V4SF")
3143 (const_string "V2SF"))
3145 /* xorps is one byte shorter. */
3146 (eq_attr "alternative" "5")
3147 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3149 (const_string "V4SF")
3150 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3154 (const_string "V2DF"))
3156 /* For architectures resolving dependencies on
3157 whole SSE registers use APD move to break dependency
3158 chains, otherwise use short move to avoid extra work.
3160 movaps encodes one byte shorter. */
3161 (eq_attr "alternative" "6")
3163 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3165 (const_string "V4SF")
3166 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3168 (const_string "V2DF")
3170 (const_string "DF"))
3171 /* For architectures resolving dependencies on register
3172 parts we may avoid extra work to zero out upper part
3174 (eq_attr "alternative" "7")
3176 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3178 (const_string "V1DF")
3179 (const_string "DF"))
3181 (const_string "DF")))])
3183 ;; Moving is usually shorter when only FP registers are used. This separate
3184 ;; movdf pattern avoids the use of integer registers for FP operations
3185 ;; when optimizing for size.
3187 (define_insn "*movdf_internal_nointeger"
3188 [(set (match_operand:DF 0 "nonimmediate_operand"
3189 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
3190 (match_operand:DF 1 "general_operand"
3191 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
3192 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3193 && ((optimize_function_for_size_p (cfun)
3194 || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
3195 && (reload_in_progress || reload_completed
3196 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3197 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3198 && optimize_function_for_size_p (cfun)
3199 && !memory_operand (operands[0], DFmode)
3200 && standard_80387_constant_p (operands[1]))
3201 || GET_CODE (operands[1]) != CONST_DOUBLE
3202 || ((optimize_function_for_size_p (cfun)
3203 || !TARGET_MEMORY_MISMATCH_STALL
3204 || reload_in_progress || reload_completed)
3205 && memory_operand (operands[0], DFmode)))"
3207 switch (which_alternative)
3211 return output_387_reg_move (insn, operands);
3214 return standard_80387_constant_opcode (operands[1]);
3221 switch (get_attr_mode (insn))
3224 return "%vxorps\t%0, %d0";
3226 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3227 return "%vxorps\t%0, %d0";
3229 return "%vxorpd\t%0, %d0";
3231 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3232 return "%vxorps\t%0, %d0";
3234 return "%vpxor\t%0, %d0";
3241 switch (get_attr_mode (insn))
3244 return "%vmovaps\t{%1, %0|%0, %1}";
3246 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3247 return "%vmovaps\t{%1, %0|%0, %1}";
3249 return "%vmovapd\t{%1, %0|%0, %1}";
3251 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3252 return "%vmovaps\t{%1, %0|%0, %1}";
3254 return "%vmovdqa\t{%1, %0|%0, %1}";
3256 return "%vmovq\t{%1, %0|%0, %1}";
3260 if (REG_P (operands[0]) && REG_P (operands[1]))
3261 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3263 return "vmovsd\t{%1, %0|%0, %1}";
3266 return "movsd\t{%1, %0|%0, %1}";
3270 if (REG_P (operands[0]))
3271 return "vmovlpd\t{%1, %0, %0|%0, %0, %1}";
3273 return "vmovlpd\t{%1, %0|%0, %1}";
3276 return "movlpd\t{%1, %0|%0, %1}";
3280 if (REG_P (operands[0]))
3281 return "vmovlps\t{%1, %0, %0|%0, %0, %1}";
3283 return "vmovlps\t{%1, %0|%0, %1}";
3286 return "movlps\t{%1, %0|%0, %1}";
3295 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3296 (set (attr "prefix")
3297 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3298 (const_string "orig")
3299 (const_string "maybe_vex")))
3300 (set (attr "prefix_data16")
3301 (if_then_else (eq_attr "mode" "V1DF")
3303 (const_string "*")))
3305 (cond [(eq_attr "alternative" "0,1,2")
3307 (eq_attr "alternative" "3,4")
3310 /* For SSE1, we have many fewer alternatives. */
3311 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3312 (cond [(eq_attr "alternative" "5,6")
3313 (const_string "V4SF")
3315 (const_string "V2SF"))
3317 /* xorps is one byte shorter. */
3318 (eq_attr "alternative" "5")
3319 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3321 (const_string "V4SF")
3322 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3326 (const_string "V2DF"))
3328 /* For architectures resolving dependencies on
3329 whole SSE registers use APD move to break dependency
3330 chains, otherwise use short move to avoid extra work.
3332 movaps encodes one byte shorter. */
3333 (eq_attr "alternative" "6")
3335 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3337 (const_string "V4SF")
3338 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3340 (const_string "V2DF")
3342 (const_string "DF"))
3343 /* For architectures resolving dependencies on register
3344 parts we may avoid extra work to zero out upper part
3346 (eq_attr "alternative" "7")
3348 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3350 (const_string "V1DF")
3351 (const_string "DF"))
3353 (const_string "DF")))])
3356 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3357 (match_operand:DF 1 "general_operand" ""))]
3359 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3360 && ! (ANY_FP_REG_P (operands[0]) ||
3361 (GET_CODE (operands[0]) == SUBREG
3362 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3363 && ! (ANY_FP_REG_P (operands[1]) ||
3364 (GET_CODE (operands[1]) == SUBREG
3365 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3367 "ix86_split_long_move (operands); DONE;")
3369 (define_insn "*movsf_internal"
3370 [(set (match_operand:SF 0 "nonimmediate_operand"
3371 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
3372 (match_operand:SF 1 "general_operand"
3373 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
3374 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3375 && (reload_in_progress || reload_completed
3376 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3377 || (!TARGET_SSE_MATH && optimize_function_for_size_p (cfun)
3378 && standard_80387_constant_p (operands[1]))
3379 || GET_CODE (operands[1]) != CONST_DOUBLE
3380 || memory_operand (operands[0], SFmode))"
3382 switch (which_alternative)
3386 return output_387_reg_move (insn, operands);
3389 return standard_80387_constant_opcode (operands[1]);
3393 return "mov{l}\t{%1, %0|%0, %1}";
3395 if (get_attr_mode (insn) == MODE_TI)
3396 return "%vpxor\t%0, %d0";
3398 return "%vxorps\t%0, %d0";
3400 if (get_attr_mode (insn) == MODE_V4SF)
3401 return "%vmovaps\t{%1, %0|%0, %1}";
3403 return "%vmovss\t{%1, %d0|%d0, %1}";
3406 return REG_P (operands[1]) ? "vmovss\t{%1, %0, %0|%0, %0, %1}"
3407 : "vmovss\t{%1, %0|%0, %1}";
3409 return "movss\t{%1, %0|%0, %1}";
3411 return "%vmovss\t{%1, %0|%0, %1}";
3413 case 9: case 10: case 14: case 15:
3414 return "movd\t{%1, %0|%0, %1}";
3416 return "%vmovd\t{%1, %0|%0, %1}";
3419 return "movq\t{%1, %0|%0, %1}";
3425 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
3426 (set (attr "prefix")
3427 (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
3428 (const_string "maybe_vex")
3429 (const_string "orig")))
3431 (cond [(eq_attr "alternative" "3,4,9,10")
3433 (eq_attr "alternative" "5")
3435 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3437 (ne (symbol_ref "TARGET_SSE2")
3439 (eq (symbol_ref "optimize_function_for_size_p (cfun)")
3442 (const_string "V4SF"))
3443 /* For architectures resolving dependencies on
3444 whole SSE registers use APS move to break dependency
3445 chains, otherwise use short move to avoid extra work.
3447 Do the same for architectures resolving dependencies on
3448 the parts. While in DF mode it is better to always handle
3449 just register parts, the SF mode is different due to lack
3450 of instructions to load just part of the register. It is
3451 better to maintain the whole registers in single format
3452 to avoid problems on using packed logical operations. */
3453 (eq_attr "alternative" "6")
3455 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3457 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3459 (const_string "V4SF")
3460 (const_string "SF"))
3461 (eq_attr "alternative" "11")
3462 (const_string "DI")]
3463 (const_string "SF")))])
3466 [(set (match_operand 0 "register_operand" "")
3467 (match_operand 1 "memory_operand" ""))]
3469 && MEM_P (operands[1])
3470 && (GET_MODE (operands[0]) == TFmode
3471 || GET_MODE (operands[0]) == XFmode
3472 || GET_MODE (operands[0]) == DFmode
3473 || GET_MODE (operands[0]) == SFmode)
3474 && (operands[2] = find_constant_src (insn))"
3475 [(set (match_dup 0) (match_dup 2))]
3477 rtx c = operands[2];
3478 rtx r = operands[0];
3480 if (GET_CODE (r) == SUBREG)
3485 if (!standard_sse_constant_p (c))
3488 else if (FP_REG_P (r))
3490 if (!standard_80387_constant_p (c))
3493 else if (MMX_REG_P (r))
3498 [(set (match_operand 0 "register_operand" "")
3499 (float_extend (match_operand 1 "memory_operand" "")))]
3501 && MEM_P (operands[1])
3502 && (GET_MODE (operands[0]) == TFmode
3503 || GET_MODE (operands[0]) == XFmode
3504 || GET_MODE (operands[0]) == DFmode
3505 || GET_MODE (operands[0]) == SFmode)
3506 && (operands[2] = find_constant_src (insn))"
3507 [(set (match_dup 0) (match_dup 2))]
3509 rtx c = operands[2];
3510 rtx r = operands[0];
3512 if (GET_CODE (r) == SUBREG)
3517 if (!standard_sse_constant_p (c))
3520 else if (FP_REG_P (r))
3522 if (!standard_80387_constant_p (c))
3525 else if (MMX_REG_P (r))
3529 ;; Split the load of -0.0 or -1.0 into fldz;fchs or fld1;fchs sequence
3531 [(set (match_operand:X87MODEF 0 "register_operand" "")
3532 (match_operand:X87MODEF 1 "immediate_operand" ""))]
3533 "reload_completed && FP_REGNO_P (REGNO (operands[0]))
3534 && (standard_80387_constant_p (operands[1]) == 8
3535 || standard_80387_constant_p (operands[1]) == 9)"
3536 [(set (match_dup 0)(match_dup 1))
3538 (neg:X87MODEF (match_dup 0)))]
3542 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
3543 if (real_isnegzero (&r))
3544 operands[1] = CONST0_RTX (<MODE>mode);
3546 operands[1] = CONST1_RTX (<MODE>mode);
3549 (define_insn "swapxf"
3550 [(set (match_operand:XF 0 "register_operand" "+f")
3551 (match_operand:XF 1 "register_operand" "+f"))
3556 if (STACK_TOP_P (operands[0]))
3561 [(set_attr "type" "fxch")
3562 (set_attr "mode" "XF")])
3564 (define_insn "*swap<mode>"
3565 [(set (match_operand:MODEF 0 "fp_register_operand" "+f")
3566 (match_operand:MODEF 1 "fp_register_operand" "+f"))
3569 "TARGET_80387 || reload_completed"
3571 if (STACK_TOP_P (operands[0]))
3576 [(set_attr "type" "fxch")
3577 (set_attr "mode" "<MODE>")])
3579 ;; Zero extension instructions
3581 (define_expand "zero_extendsidi2"
3582 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3583 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3588 emit_insn (gen_zero_extendsidi2_1 (operands[0], operands[1]));
3593 (define_insn "*zero_extendsidi2_rex64"
3594 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,?*Ym,?*y,?*Yi,*Y2")
3596 (match_operand:SI 1 "nonimmediate_operand" "rm,0,r ,m ,r ,m")))]
3599 mov\t{%k1, %k0|%k0, %k1}
3601 movd\t{%1, %0|%0, %1}
3602 movd\t{%1, %0|%0, %1}
3603 %vmovd\t{%1, %0|%0, %1}
3604 %vmovd\t{%1, %0|%0, %1}"
3605 [(set_attr "type" "imovx,imov,mmxmov,mmxmov,ssemov,ssemov")
3606 (set_attr "prefix" "orig,*,orig,orig,maybe_vex,maybe_vex")
3607 (set_attr "prefix_0f" "0,*,*,*,*,*")
3608 (set_attr "mode" "SI,DI,DI,DI,TI,TI")])
3611 [(set (match_operand:DI 0 "memory_operand" "")
3612 (zero_extend:DI (match_dup 0)))]
3614 [(set (match_dup 4) (const_int 0))]
3615 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3617 ;; %%% Kill me once multi-word ops are sane.
3618 (define_insn "zero_extendsidi2_1"
3619 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?o,?*Ym,?*y,?*Yi,*Y2")
3621 (match_operand:SI 1 "nonimmediate_operand" "0,rm,r ,r ,m ,r ,m")))
3622 (clobber (reg:CC FLAGS_REG))]
3628 movd\t{%1, %0|%0, %1}
3629 movd\t{%1, %0|%0, %1}
3630 %vmovd\t{%1, %0|%0, %1}
3631 %vmovd\t{%1, %0|%0, %1}"
3632 [(set_attr "type" "multi,multi,multi,mmxmov,mmxmov,ssemov,ssemov")
3633 (set_attr "prefix" "*,*,*,orig,orig,maybe_vex,maybe_vex")
3634 (set_attr "mode" "SI,SI,SI,DI,DI,TI,TI")])
3637 [(set (match_operand:DI 0 "register_operand" "")
3638 (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3639 (clobber (reg:CC FLAGS_REG))]
3640 "!TARGET_64BIT && reload_completed
3641 && true_regnum (operands[0]) == true_regnum (operands[1])"
3642 [(set (match_dup 4) (const_int 0))]
3643 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3646 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3647 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3648 (clobber (reg:CC FLAGS_REG))]
3649 "!TARGET_64BIT && reload_completed
3650 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))"
3651 [(set (match_dup 3) (match_dup 1))
3652 (set (match_dup 4) (const_int 0))]
3653 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3655 (define_insn "zero_extend<mode>di2"
3656 [(set (match_operand:DI 0 "register_operand" "=r")
3658 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3660 "movz{<imodesuffix>l|x}\t{%1, %k0|%k0, %1}"
3661 [(set_attr "type" "imovx")
3662 (set_attr "mode" "SI")])
3664 (define_expand "zero_extendhisi2"
3665 [(set (match_operand:SI 0 "register_operand" "")
3666 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3669 if (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3671 operands[1] = force_reg (HImode, operands[1]);
3672 emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3677 (define_insn_and_split "zero_extendhisi2_and"
3678 [(set (match_operand:SI 0 "register_operand" "=r")
3679 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3680 (clobber (reg:CC FLAGS_REG))]
3681 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3683 "&& reload_completed"
3684 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3685 (clobber (reg:CC FLAGS_REG))])]
3687 [(set_attr "type" "alu1")
3688 (set_attr "mode" "SI")])
3690 (define_insn "*zero_extendhisi2_movzwl"
3691 [(set (match_operand:SI 0 "register_operand" "=r")
3692 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3693 "!TARGET_ZERO_EXTEND_WITH_AND
3694 || optimize_function_for_size_p (cfun)"
3695 "movz{wl|x}\t{%1, %0|%0, %1}"
3696 [(set_attr "type" "imovx")
3697 (set_attr "mode" "SI")])
3699 (define_expand "zero_extendqi<mode>2"
3701 [(set (match_operand:SWI24 0 "register_operand" "")
3702 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3703 (clobber (reg:CC FLAGS_REG))])])
3705 (define_insn "*zero_extendqi<mode>2_and"
3706 [(set (match_operand:SWI24 0 "register_operand" "=r,?&q")
3707 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3708 (clobber (reg:CC FLAGS_REG))]
3709 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3711 [(set_attr "type" "alu1")
3712 (set_attr "mode" "<MODE>")])
3714 ;; When source and destination does not overlap, clear destination
3715 ;; first and then do the movb
3717 [(set (match_operand:SWI24 0 "register_operand" "")
3718 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3719 (clobber (reg:CC FLAGS_REG))]
3721 && (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3722 && ANY_QI_REG_P (operands[0])
3723 && (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]))
3724 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3725 [(set (strict_low_part (match_dup 2)) (match_dup 1))]
3727 operands[2] = gen_lowpart (QImode, operands[0]);
3728 ix86_expand_clear (operands[0]);
3731 (define_insn "*zero_extendqi<mode>2_movzbl_and"
3732 [(set (match_operand:SWI24 0 "register_operand" "=r,r")
3733 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3734 (clobber (reg:CC FLAGS_REG))]
3735 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun)"
3737 [(set_attr "type" "imovx,alu1")
3738 (set_attr "mode" "<MODE>")])
3740 ;; For the movzbl case strip only the clobber
3742 [(set (match_operand:SWI24 0 "register_operand" "")
3743 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3744 (clobber (reg:CC FLAGS_REG))]
3746 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))
3747 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3749 (zero_extend:SWI24 (match_dup 1)))])
3751 ; zero extend to SImode to avoid partial register stalls
3752 (define_insn "*zero_extendqi<mode>2_movzbl"
3753 [(set (match_operand:SWI24 0 "register_operand" "=r")
3754 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3756 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))"
3757 "movz{bl|x}\t{%1, %k0|%k0, %1}"
3758 [(set_attr "type" "imovx")
3759 (set_attr "mode" "SI")])
3761 ;; Rest is handled by single and.
3763 [(set (match_operand:SWI24 0 "register_operand" "")
3764 (zero_extend:SWI24 (match_operand:QI 1 "register_operand" "")))
3765 (clobber (reg:CC FLAGS_REG))]
3767 && true_regnum (operands[0]) == true_regnum (operands[1])"
3768 [(parallel [(set (match_dup 0) (and:SWI24 (match_dup 0) (const_int 255)))
3769 (clobber (reg:CC FLAGS_REG))])])
3771 ;; Sign extension instructions
3773 (define_expand "extendsidi2"
3774 [(set (match_operand:DI 0 "register_operand" "")
3775 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))]
3780 emit_insn (gen_extendsidi2_1 (operands[0], operands[1]));
3785 (define_insn "*extendsidi2_rex64"
3786 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3787 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3791 movs{lq|x}\t{%1, %0|%0, %1}"
3792 [(set_attr "type" "imovx")
3793 (set_attr "mode" "DI")
3794 (set_attr "prefix_0f" "0")
3795 (set_attr "modrm" "0,1")])
3797 (define_insn "extendsidi2_1"
3798 [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3799 (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3800 (clobber (reg:CC FLAGS_REG))
3801 (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3805 ;; Extend to memory case when source register does die.
3807 [(set (match_operand:DI 0 "memory_operand" "")
3808 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3809 (clobber (reg:CC FLAGS_REG))
3810 (clobber (match_operand:SI 2 "register_operand" ""))]
3812 && dead_or_set_p (insn, operands[1])
3813 && !reg_mentioned_p (operands[1], operands[0]))"
3814 [(set (match_dup 3) (match_dup 1))
3815 (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3816 (clobber (reg:CC FLAGS_REG))])
3817 (set (match_dup 4) (match_dup 1))]
3818 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3820 ;; Extend to memory case when source register does not die.
3822 [(set (match_operand:DI 0 "memory_operand" "")
3823 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3824 (clobber (reg:CC FLAGS_REG))
3825 (clobber (match_operand:SI 2 "register_operand" ""))]
3829 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3831 emit_move_insn (operands[3], operands[1]);
3833 /* Generate a cltd if possible and doing so it profitable. */
3834 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3835 && true_regnum (operands[1]) == AX_REG
3836 && true_regnum (operands[2]) == DX_REG)
3838 emit_insn (gen_ashrsi3_cvt (operands[2], operands[1], GEN_INT (31)));
3842 emit_move_insn (operands[2], operands[1]);
3843 emit_insn (gen_ashrsi3_cvt (operands[2], operands[2], GEN_INT (31)));
3845 emit_move_insn (operands[4], operands[2]);
3849 ;; Extend to register case. Optimize case where source and destination
3850 ;; registers match and cases where we can use cltd.
3852 [(set (match_operand:DI 0 "register_operand" "")
3853 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3854 (clobber (reg:CC FLAGS_REG))
3855 (clobber (match_scratch:SI 2 ""))]
3859 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3861 if (true_regnum (operands[3]) != true_regnum (operands[1]))
3862 emit_move_insn (operands[3], operands[1]);
3864 /* Generate a cltd if possible and doing so it profitable. */
3865 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3866 && true_regnum (operands[3]) == AX_REG
3867 && true_regnum (operands[4]) == DX_REG)
3869 emit_insn (gen_ashrsi3_cvt (operands[4], operands[3], GEN_INT (31)));
3873 if (true_regnum (operands[4]) != true_regnum (operands[1]))
3874 emit_move_insn (operands[4], operands[1]);
3876 emit_insn (gen_ashrsi3_cvt (operands[4], operands[4], GEN_INT (31)));
3880 (define_insn "extend<mode>di2"
3881 [(set (match_operand:DI 0 "register_operand" "=r")
3883 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3885 "movs{<imodesuffix>q|x}\t{%1, %0|%0, %1}"
3886 [(set_attr "type" "imovx")
3887 (set_attr "mode" "DI")])
3889 (define_insn "extendhisi2"
3890 [(set (match_operand:SI 0 "register_operand" "=*a,r")
3891 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3894 switch (get_attr_prefix_0f (insn))
3897 return "{cwtl|cwde}";
3899 return "movs{wl|x}\t{%1, %0|%0, %1}";
3902 [(set_attr "type" "imovx")
3903 (set_attr "mode" "SI")
3904 (set (attr "prefix_0f")
3905 ;; movsx is short decodable while cwtl is vector decoded.
3906 (if_then_else (and (eq_attr "cpu" "!k6")