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
264 UNSPECV_SPLIT_STACK_RETURN
267 ;; Constants to represent pcomtrue/pcomfalse variants
277 ;; Constants used in the XOP pperm instruction
279 [(PPERM_SRC 0x00) /* copy source */
280 (PPERM_INVERT 0x20) /* invert source */
281 (PPERM_REVERSE 0x40) /* bit reverse source */
282 (PPERM_REV_INV 0x60) /* bit reverse & invert src */
283 (PPERM_ZERO 0x80) /* all 0's */
284 (PPERM_ONES 0xa0) /* all 1's */
285 (PPERM_SIGN 0xc0) /* propagate sign bit */
286 (PPERM_INV_SIGN 0xe0) /* invert & propagate sign */
287 (PPERM_SRC1 0x00) /* use first source byte */
288 (PPERM_SRC2 0x10) /* use second source byte */
291 ;; Registers by name.
344 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
347 ;; In C guard expressions, put expressions which may be compile-time
348 ;; constants first. This allows for better optimization. For
349 ;; example, write "TARGET_64BIT && reload_completed", not
350 ;; "reload_completed && TARGET_64BIT".
354 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,atom,
355 generic64,amdfam10,bdver1"
356 (const (symbol_ref "ix86_schedule")))
358 ;; A basic instruction type. Refinements due to arguments to be
359 ;; provided in other attributes.
362 alu,alu1,negnot,imov,imovx,lea,
363 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
364 icmp,test,ibr,setcc,icmov,
365 push,pop,call,callv,leave,
367 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
368 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
369 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
370 ssemuladd,sse4arg,lwp,
371 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
372 (const_string "other"))
374 ;; Main data type used by the insn
376 "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
377 (const_string "unknown"))
379 ;; The CPU unit operations uses.
380 (define_attr "unit" "integer,i387,sse,mmx,unknown"
381 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
382 (const_string "i387")
383 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
384 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
385 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
387 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
389 (eq_attr "type" "other")
390 (const_string "unknown")]
391 (const_string "integer")))
393 ;; The (bounding maximum) length of an instruction immediate.
394 (define_attr "length_immediate" ""
395 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
398 (eq_attr "unit" "i387,sse,mmx")
400 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
402 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
403 (eq_attr "type" "imov,test")
404 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
405 (eq_attr "type" "call")
406 (if_then_else (match_operand 0 "constant_call_address_operand" "")
409 (eq_attr "type" "callv")
410 (if_then_else (match_operand 1 "constant_call_address_operand" "")
413 ;; We don't know the size before shorten_branches. Expect
414 ;; the instruction to fit for better scheduling.
415 (eq_attr "type" "ibr")
418 (symbol_ref "/* Update immediate_length and other attributes! */
419 gcc_unreachable (),1")))
421 ;; The (bounding maximum) length of an instruction address.
422 (define_attr "length_address" ""
423 (cond [(eq_attr "type" "str,other,multi,fxch")
425 (and (eq_attr "type" "call")
426 (match_operand 0 "constant_call_address_operand" ""))
428 (and (eq_attr "type" "callv")
429 (match_operand 1 "constant_call_address_operand" ""))
432 (symbol_ref "ix86_attr_length_address_default (insn)")))
434 ;; Set when length prefix is used.
435 (define_attr "prefix_data16" ""
436 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
438 (eq_attr "mode" "HI")
440 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
445 ;; Set when string REP prefix is used.
446 (define_attr "prefix_rep" ""
447 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
449 (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
454 ;; Set when 0f opcode prefix is used.
455 (define_attr "prefix_0f" ""
457 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
458 (eq_attr "unit" "sse,mmx"))
462 ;; Set when REX opcode prefix is used.
463 (define_attr "prefix_rex" ""
464 (cond [(eq (symbol_ref "TARGET_64BIT") (const_int 0))
466 (and (eq_attr "mode" "DI")
467 (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
468 (eq_attr "unit" "!mmx")))
470 (and (eq_attr "mode" "QI")
471 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
474 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
477 (and (eq_attr "type" "imovx")
478 (match_operand:QI 1 "ext_QIreg_operand" ""))
483 ;; There are also additional prefixes in 3DNOW, SSSE3.
484 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
485 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
486 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
487 (define_attr "prefix_extra" ""
488 (cond [(eq_attr "type" "ssemuladd,sse4arg")
490 (eq_attr "type" "sseiadd1,ssecvt1")
495 ;; Prefix used: original, VEX or maybe VEX.
496 (define_attr "prefix" "orig,vex,maybe_vex"
497 (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
499 (const_string "orig")))
501 ;; VEX W bit is used.
502 (define_attr "prefix_vex_w" "" (const_int 0))
504 ;; The length of VEX prefix
505 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
506 ;; 0f38/0f3a prefixes can't. In i386.md 0f3[8a] is
507 ;; still prefix_0f 1, with prefix_extra 1.
508 (define_attr "length_vex" ""
509 (if_then_else (and (eq_attr "prefix_0f" "1")
510 (eq_attr "prefix_extra" "0"))
511 (if_then_else (eq_attr "prefix_vex_w" "1")
512 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 1)")
513 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 0)"))
514 (if_then_else (eq_attr "prefix_vex_w" "1")
515 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 1)")
516 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 0)"))))
518 ;; Set when modrm byte is used.
519 (define_attr "modrm" ""
520 (cond [(eq_attr "type" "str,leave")
522 (eq_attr "unit" "i387")
524 (and (eq_attr "type" "incdec")
525 (and (eq (symbol_ref "TARGET_64BIT") (const_int 0))
526 (ior (match_operand:SI 1 "register_operand" "")
527 (match_operand:HI 1 "register_operand" ""))))
529 (and (eq_attr "type" "push")
530 (not (match_operand 1 "memory_operand" "")))
532 (and (eq_attr "type" "pop")
533 (not (match_operand 0 "memory_operand" "")))
535 (and (eq_attr "type" "imov")
536 (and (not (eq_attr "mode" "DI"))
537 (ior (and (match_operand 0 "register_operand" "")
538 (match_operand 1 "immediate_operand" ""))
539 (ior (and (match_operand 0 "ax_reg_operand" "")
540 (match_operand 1 "memory_displacement_only_operand" ""))
541 (and (match_operand 0 "memory_displacement_only_operand" "")
542 (match_operand 1 "ax_reg_operand" ""))))))
544 (and (eq_attr "type" "call")
545 (match_operand 0 "constant_call_address_operand" ""))
547 (and (eq_attr "type" "callv")
548 (match_operand 1 "constant_call_address_operand" ""))
550 (and (eq_attr "type" "alu,alu1,icmp,test")
551 (match_operand 0 "ax_reg_operand" ""))
552 (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
556 ;; The (bounding maximum) length of an instruction in bytes.
557 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
558 ;; Later we may want to split them and compute proper length as for
560 (define_attr "length" ""
561 (cond [(eq_attr "type" "other,multi,fistp,frndint")
563 (eq_attr "type" "fcmp")
565 (eq_attr "unit" "i387")
567 (plus (attr "prefix_data16")
568 (attr "length_address")))
569 (ior (eq_attr "prefix" "vex")
570 (and (eq_attr "prefix" "maybe_vex")
571 (ne (symbol_ref "TARGET_AVX") (const_int 0))))
572 (plus (attr "length_vex")
573 (plus (attr "length_immediate")
575 (attr "length_address"))))]
576 (plus (plus (attr "modrm")
577 (plus (attr "prefix_0f")
578 (plus (attr "prefix_rex")
579 (plus (attr "prefix_extra")
581 (plus (attr "prefix_rep")
582 (plus (attr "prefix_data16")
583 (plus (attr "length_immediate")
584 (attr "length_address")))))))
586 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
587 ;; `store' if there is a simple memory reference therein, or `unknown'
588 ;; if the instruction is complex.
590 (define_attr "memory" "none,load,store,both,unknown"
591 (cond [(eq_attr "type" "other,multi,str,lwp")
592 (const_string "unknown")
593 (eq_attr "type" "lea,fcmov,fpspc")
594 (const_string "none")
595 (eq_attr "type" "fistp,leave")
596 (const_string "both")
597 (eq_attr "type" "frndint")
598 (const_string "load")
599 (eq_attr "type" "push")
600 (if_then_else (match_operand 1 "memory_operand" "")
601 (const_string "both")
602 (const_string "store"))
603 (eq_attr "type" "pop")
604 (if_then_else (match_operand 0 "memory_operand" "")
605 (const_string "both")
606 (const_string "load"))
607 (eq_attr "type" "setcc")
608 (if_then_else (match_operand 0 "memory_operand" "")
609 (const_string "store")
610 (const_string "none"))
611 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
612 (if_then_else (ior (match_operand 0 "memory_operand" "")
613 (match_operand 1 "memory_operand" ""))
614 (const_string "load")
615 (const_string "none"))
616 (eq_attr "type" "ibr")
617 (if_then_else (match_operand 0 "memory_operand" "")
618 (const_string "load")
619 (const_string "none"))
620 (eq_attr "type" "call")
621 (if_then_else (match_operand 0 "constant_call_address_operand" "")
622 (const_string "none")
623 (const_string "load"))
624 (eq_attr "type" "callv")
625 (if_then_else (match_operand 1 "constant_call_address_operand" "")
626 (const_string "none")
627 (const_string "load"))
628 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
629 (match_operand 1 "memory_operand" ""))
630 (const_string "both")
631 (and (match_operand 0 "memory_operand" "")
632 (match_operand 1 "memory_operand" ""))
633 (const_string "both")
634 (match_operand 0 "memory_operand" "")
635 (const_string "store")
636 (match_operand 1 "memory_operand" "")
637 (const_string "load")
639 "!alu1,negnot,ishift1,
640 imov,imovx,icmp,test,bitmanip,
642 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
643 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
644 (match_operand 2 "memory_operand" ""))
645 (const_string "load")
646 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
647 (match_operand 3 "memory_operand" ""))
648 (const_string "load")
650 (const_string "none")))
652 ;; Indicates if an instruction has both an immediate and a displacement.
654 (define_attr "imm_disp" "false,true,unknown"
655 (cond [(eq_attr "type" "other,multi")
656 (const_string "unknown")
657 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
658 (and (match_operand 0 "memory_displacement_operand" "")
659 (match_operand 1 "immediate_operand" "")))
660 (const_string "true")
661 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
662 (and (match_operand 0 "memory_displacement_operand" "")
663 (match_operand 2 "immediate_operand" "")))
664 (const_string "true")
666 (const_string "false")))
668 ;; Indicates if an FP operation has an integer source.
670 (define_attr "fp_int_src" "false,true"
671 (const_string "false"))
673 ;; Defines rounding mode of an FP operation.
675 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
676 (const_string "any"))
678 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
679 (define_attr "use_carry" "0,1" (const_string "0"))
681 ;; Define attribute to indicate unaligned ssemov insns
682 (define_attr "movu" "0,1" (const_string "0"))
684 ;; Describe a user's asm statement.
685 (define_asm_attributes
686 [(set_attr "length" "128")
687 (set_attr "type" "multi")])
689 (define_code_iterator plusminus [plus minus])
691 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
693 ;; Base name for define_insn
694 (define_code_attr plusminus_insn
695 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
696 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
698 ;; Base name for insn mnemonic.
699 (define_code_attr plusminus_mnemonic
700 [(plus "add") (ss_plus "adds") (us_plus "addus")
701 (minus "sub") (ss_minus "subs") (us_minus "subus")])
702 (define_code_attr plusminus_carry_mnemonic
703 [(plus "adc") (minus "sbb")])
705 ;; Mark commutative operators as such in constraints.
706 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
707 (minus "") (ss_minus "") (us_minus "")])
709 ;; Mapping of signed max and min
710 (define_code_iterator smaxmin [smax smin])
712 ;; Mapping of unsigned max and min
713 (define_code_iterator umaxmin [umax umin])
715 ;; Base name for integer and FP insn mnemonic
716 (define_code_attr maxmin_int [(smax "maxs") (smin "mins")
717 (umax "maxu") (umin "minu")])
718 (define_code_attr maxmin_float [(smax "max") (smin "min")])
720 ;; Mapping of logic operators
721 (define_code_iterator any_logic [and ior xor])
722 (define_code_iterator any_or [ior xor])
724 ;; Base name for insn mnemonic.
725 (define_code_attr logic [(and "and") (ior "or") (xor "xor")])
727 ;; Mapping of shift-right operators
728 (define_code_iterator any_shiftrt [lshiftrt ashiftrt])
730 ;; Base name for define_insn
731 (define_code_attr shiftrt_insn [(lshiftrt "lshr") (ashiftrt "ashr")])
733 ;; Base name for insn mnemonic.
734 (define_code_attr shiftrt [(lshiftrt "shr") (ashiftrt "sar")])
736 ;; Mapping of rotate operators
737 (define_code_iterator any_rotate [rotate rotatert])
739 ;; Base name for define_insn
740 (define_code_attr rotate_insn [(rotate "rotl") (rotatert "rotr")])
742 ;; Base name for insn mnemonic.
743 (define_code_attr rotate [(rotate "rol") (rotatert "ror")])
745 ;; Mapping of abs neg operators
746 (define_code_iterator absneg [abs neg])
748 ;; Base name for x87 insn mnemonic.
749 (define_code_attr absneg_mnemonic [(abs "abs") (neg "chs")])
751 ;; Used in signed and unsigned widening multiplications.
752 (define_code_iterator any_extend [sign_extend zero_extend])
754 ;; Various insn prefixes for signed and unsigned operations.
755 (define_code_attr u [(sign_extend "") (zero_extend "u")
756 (div "") (udiv "u")])
757 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
759 ;; Used in signed and unsigned divisions.
760 (define_code_iterator any_div [div udiv])
762 ;; Instruction prefix for signed and unsigned operations.
763 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")
764 (div "i") (udiv "")])
766 ;; 64bit single word integer modes.
767 (define_mode_iterator SWI1248x [QI HI SI DI])
769 ;; 64bit single word integer modes without QImode and HImode.
770 (define_mode_iterator SWI48x [SI DI])
772 ;; Single word integer modes.
773 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
775 ;; Single word integer modes without SImode and DImode.
776 (define_mode_iterator SWI12 [QI HI])
778 ;; Single word integer modes without DImode.
779 (define_mode_iterator SWI124 [QI HI SI])
781 ;; Single word integer modes without QImode and DImode.
782 (define_mode_iterator SWI24 [HI SI])
784 ;; Single word integer modes without QImode.
785 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
787 ;; Single word integer modes without QImode and HImode.
788 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
790 ;; All math-dependant single and double word integer modes.
791 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
792 (HI "TARGET_HIMODE_MATH")
793 SI DI (TI "TARGET_64BIT")])
795 ;; Math-dependant single word integer modes.
796 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
797 (HI "TARGET_HIMODE_MATH")
798 SI (DI "TARGET_64BIT")])
800 ;; Math-dependant single word integer modes without DImode.
801 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
802 (HI "TARGET_HIMODE_MATH")
805 ;; Math-dependant single word integer modes without QImode.
806 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
807 SI (DI "TARGET_64BIT")])
809 ;; Double word integer modes.
810 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
811 (TI "TARGET_64BIT")])
813 ;; Double word integer modes as mode attribute.
814 (define_mode_attr DWI [(SI "DI") (DI "TI")])
815 (define_mode_attr dwi [(SI "di") (DI "ti")])
817 ;; Half mode for double word integer modes.
818 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
819 (DI "TARGET_64BIT")])
821 ;; Instruction suffix for integer modes.
822 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
824 ;; Pointer size prefix for integer modes (Intel asm dialect)
825 (define_mode_attr iptrsize [(QI "BYTE")
830 ;; Register class for integer modes.
831 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
833 ;; Immediate operand constraint for integer modes.
834 (define_mode_attr i [(QI "n") (HI "n") (SI "i") (DI "e")])
836 ;; General operand constraint for word modes.
837 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "g") (DI "rme")])
839 ;; Immediate operand constraint for double integer modes.
840 (define_mode_attr di [(SI "iF") (DI "e")])
842 ;; Immediate operand constraint for shifts.
843 (define_mode_attr S [(QI "I") (HI "I") (SI "I") (DI "J") (TI "O")])
845 ;; General operand predicate for integer modes.
846 (define_mode_attr general_operand
847 [(QI "general_operand")
848 (HI "general_operand")
849 (SI "general_operand")
850 (DI "x86_64_general_operand")
851 (TI "x86_64_general_operand")])
853 ;; General sign/zero extend operand predicate for integer modes.
854 (define_mode_attr general_szext_operand
855 [(QI "general_operand")
856 (HI "general_operand")
857 (SI "general_operand")
858 (DI "x86_64_szext_general_operand")])
860 ;; Immediate operand predicate for integer modes.
861 (define_mode_attr immediate_operand
862 [(QI "immediate_operand")
863 (HI "immediate_operand")
864 (SI "immediate_operand")
865 (DI "x86_64_immediate_operand")])
867 ;; Nonmemory operand predicate for integer modes.
868 (define_mode_attr nonmemory_operand
869 [(QI "nonmemory_operand")
870 (HI "nonmemory_operand")
871 (SI "nonmemory_operand")
872 (DI "x86_64_nonmemory_operand")])
874 ;; Operand predicate for shifts.
875 (define_mode_attr shift_operand
876 [(QI "nonimmediate_operand")
877 (HI "nonimmediate_operand")
878 (SI "nonimmediate_operand")
879 (DI "shiftdi_operand")
880 (TI "register_operand")])
882 ;; Operand predicate for shift argument.
883 (define_mode_attr shift_immediate_operand
884 [(QI "const_1_to_31_operand")
885 (HI "const_1_to_31_operand")
886 (SI "const_1_to_31_operand")
887 (DI "const_1_to_63_operand")])
889 ;; Input operand predicate for arithmetic left shifts.
890 (define_mode_attr ashl_input_operand
891 [(QI "nonimmediate_operand")
892 (HI "nonimmediate_operand")
893 (SI "nonimmediate_operand")
894 (DI "ashldi_input_operand")
895 (TI "reg_or_pm1_operand")])
897 ;; SSE and x87 SFmode and DFmode floating point modes
898 (define_mode_iterator MODEF [SF DF])
900 ;; All x87 floating point modes
901 (define_mode_iterator X87MODEF [SF DF XF])
903 ;; All integer modes handled by x87 fisttp operator.
904 (define_mode_iterator X87MODEI [HI SI DI])
906 ;; All integer modes handled by integer x87 operators.
907 (define_mode_iterator X87MODEI12 [HI SI])
909 ;; All integer modes handled by SSE cvtts?2si* operators.
910 (define_mode_iterator SSEMODEI24 [SI DI])
912 ;; SSE asm suffix for floating point modes
913 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
915 ;; SSE vector mode corresponding to a scalar mode
916 (define_mode_attr ssevecmode
917 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
919 ;; Instruction suffix for REX 64bit operators.
920 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
922 ;; This mode iterator allows :P to be used for patterns that operate on
923 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
924 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
926 ;; Scheduling descriptions
928 (include "pentium.md")
931 (include "athlon.md")
932 (include "bdver1.md")
937 ;; Operand and operator predicates and constraints
939 (include "predicates.md")
940 (include "constraints.md")
943 ;; Compare and branch/compare and store instructions.
945 (define_expand "cbranch<mode>4"
946 [(set (reg:CC FLAGS_REG)
947 (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
948 (match_operand:SDWIM 2 "<general_operand>" "")))
949 (set (pc) (if_then_else
950 (match_operator 0 "ordered_comparison_operator"
951 [(reg:CC FLAGS_REG) (const_int 0)])
952 (label_ref (match_operand 3 "" ""))
956 if (MEM_P (operands[1]) && MEM_P (operands[2]))
957 operands[1] = force_reg (<MODE>mode, operands[1]);
958 ix86_expand_branch (GET_CODE (operands[0]),
959 operands[1], operands[2], operands[3]);
963 (define_expand "cstore<mode>4"
964 [(set (reg:CC FLAGS_REG)
965 (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
966 (match_operand:SWIM 3 "<general_operand>" "")))
967 (set (match_operand:QI 0 "register_operand" "")
968 (match_operator 1 "ordered_comparison_operator"
969 [(reg:CC FLAGS_REG) (const_int 0)]))]
972 if (MEM_P (operands[2]) && MEM_P (operands[3]))
973 operands[2] = force_reg (<MODE>mode, operands[2]);
974 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
975 operands[2], operands[3]);
979 (define_expand "cmp<mode>_1"
980 [(set (reg:CC FLAGS_REG)
981 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
982 (match_operand:SWI48 1 "<general_operand>" "")))])
984 (define_insn "*cmp<mode>_ccno_1"
985 [(set (reg FLAGS_REG)
986 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
987 (match_operand:SWI 1 "const0_operand" "")))]
988 "ix86_match_ccmode (insn, CCNOmode)"
990 test{<imodesuffix>}\t%0, %0
991 cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
992 [(set_attr "type" "test,icmp")
993 (set_attr "length_immediate" "0,1")
994 (set_attr "mode" "<MODE>")])
996 (define_insn "*cmp<mode>_1"
997 [(set (reg FLAGS_REG)
998 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
999 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
1000 "ix86_match_ccmode (insn, CCmode)"
1001 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1002 [(set_attr "type" "icmp")
1003 (set_attr "mode" "<MODE>")])
1005 (define_insn "*cmp<mode>_minus_1"
1006 [(set (reg FLAGS_REG)
1008 (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1009 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
1011 "ix86_match_ccmode (insn, CCGOCmode)"
1012 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1013 [(set_attr "type" "icmp")
1014 (set_attr "mode" "<MODE>")])
1016 (define_insn "*cmpqi_ext_1"
1017 [(set (reg FLAGS_REG)
1019 (match_operand:QI 0 "general_operand" "Qm")
1022 (match_operand 1 "ext_register_operand" "Q")
1024 (const_int 8)) 0)))]
1025 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1026 "cmp{b}\t{%h1, %0|%0, %h1}"
1027 [(set_attr "type" "icmp")
1028 (set_attr "mode" "QI")])
1030 (define_insn "*cmpqi_ext_1_rex64"
1031 [(set (reg FLAGS_REG)
1033 (match_operand:QI 0 "register_operand" "Q")
1036 (match_operand 1 "ext_register_operand" "Q")
1038 (const_int 8)) 0)))]
1039 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1040 "cmp{b}\t{%h1, %0|%0, %h1}"
1041 [(set_attr "type" "icmp")
1042 (set_attr "mode" "QI")])
1044 (define_insn "*cmpqi_ext_2"
1045 [(set (reg FLAGS_REG)
1049 (match_operand 0 "ext_register_operand" "Q")
1052 (match_operand:QI 1 "const0_operand" "")))]
1053 "ix86_match_ccmode (insn, CCNOmode)"
1055 [(set_attr "type" "test")
1056 (set_attr "length_immediate" "0")
1057 (set_attr "mode" "QI")])
1059 (define_expand "cmpqi_ext_3"
1060 [(set (reg:CC FLAGS_REG)
1064 (match_operand 0 "ext_register_operand" "")
1067 (match_operand:QI 1 "immediate_operand" "")))])
1069 (define_insn "*cmpqi_ext_3_insn"
1070 [(set (reg FLAGS_REG)
1074 (match_operand 0 "ext_register_operand" "Q")
1077 (match_operand:QI 1 "general_operand" "Qmn")))]
1078 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1079 "cmp{b}\t{%1, %h0|%h0, %1}"
1080 [(set_attr "type" "icmp")
1081 (set_attr "modrm" "1")
1082 (set_attr "mode" "QI")])
1084 (define_insn "*cmpqi_ext_3_insn_rex64"
1085 [(set (reg FLAGS_REG)
1089 (match_operand 0 "ext_register_operand" "Q")
1092 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1093 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1094 "cmp{b}\t{%1, %h0|%h0, %1}"
1095 [(set_attr "type" "icmp")
1096 (set_attr "modrm" "1")
1097 (set_attr "mode" "QI")])
1099 (define_insn "*cmpqi_ext_4"
1100 [(set (reg FLAGS_REG)
1104 (match_operand 0 "ext_register_operand" "Q")
1109 (match_operand 1 "ext_register_operand" "Q")
1111 (const_int 8)) 0)))]
1112 "ix86_match_ccmode (insn, CCmode)"
1113 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1114 [(set_attr "type" "icmp")
1115 (set_attr "mode" "QI")])
1117 ;; These implement float point compares.
1118 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1119 ;; which would allow mix and match FP modes on the compares. Which is what
1120 ;; the old patterns did, but with many more of them.
1122 (define_expand "cbranchxf4"
1123 [(set (reg:CC FLAGS_REG)
1124 (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1125 (match_operand:XF 2 "nonmemory_operand" "")))
1126 (set (pc) (if_then_else
1127 (match_operator 0 "ix86_fp_comparison_operator"
1130 (label_ref (match_operand 3 "" ""))
1134 ix86_expand_branch (GET_CODE (operands[0]),
1135 operands[1], operands[2], operands[3]);
1139 (define_expand "cstorexf4"
1140 [(set (reg:CC FLAGS_REG)
1141 (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1142 (match_operand:XF 3 "nonmemory_operand" "")))
1143 (set (match_operand:QI 0 "register_operand" "")
1144 (match_operator 1 "ix86_fp_comparison_operator"
1149 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1150 operands[2], operands[3]);
1154 (define_expand "cbranch<mode>4"
1155 [(set (reg:CC FLAGS_REG)
1156 (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1157 (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1158 (set (pc) (if_then_else
1159 (match_operator 0 "ix86_fp_comparison_operator"
1162 (label_ref (match_operand 3 "" ""))
1164 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1166 ix86_expand_branch (GET_CODE (operands[0]),
1167 operands[1], operands[2], operands[3]);
1171 (define_expand "cstore<mode>4"
1172 [(set (reg:CC FLAGS_REG)
1173 (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1174 (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1175 (set (match_operand:QI 0 "register_operand" "")
1176 (match_operator 1 "ix86_fp_comparison_operator"
1179 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1181 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1182 operands[2], operands[3]);
1186 (define_expand "cbranchcc4"
1187 [(set (pc) (if_then_else
1188 (match_operator 0 "comparison_operator"
1189 [(match_operand 1 "flags_reg_operand" "")
1190 (match_operand 2 "const0_operand" "")])
1191 (label_ref (match_operand 3 "" ""))
1195 ix86_expand_branch (GET_CODE (operands[0]),
1196 operands[1], operands[2], operands[3]);
1200 (define_expand "cstorecc4"
1201 [(set (match_operand:QI 0 "register_operand" "")
1202 (match_operator 1 "comparison_operator"
1203 [(match_operand 2 "flags_reg_operand" "")
1204 (match_operand 3 "const0_operand" "")]))]
1207 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1208 operands[2], operands[3]);
1213 ;; FP compares, step 1:
1214 ;; Set the FP condition codes.
1216 ;; CCFPmode compare with exceptions
1217 ;; CCFPUmode compare with no exceptions
1219 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1220 ;; used to manage the reg stack popping would not be preserved.
1222 (define_insn "*cmpfp_0"
1223 [(set (match_operand:HI 0 "register_operand" "=a")
1226 (match_operand 1 "register_operand" "f")
1227 (match_operand 2 "const0_operand" ""))]
1229 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1230 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1231 "* return output_fp_compare (insn, operands, 0, 0);"
1232 [(set_attr "type" "multi")
1233 (set_attr "unit" "i387")
1235 (cond [(match_operand:SF 1 "" "")
1237 (match_operand:DF 1 "" "")
1240 (const_string "XF")))])
1242 (define_insn_and_split "*cmpfp_0_cc"
1243 [(set (reg:CCFP FLAGS_REG)
1245 (match_operand 1 "register_operand" "f")
1246 (match_operand 2 "const0_operand" "")))
1247 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1248 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1249 && TARGET_SAHF && !TARGET_CMOVE
1250 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1252 "&& reload_completed"
1255 [(compare:CCFP (match_dup 1)(match_dup 2))]
1257 (set (reg:CC FLAGS_REG)
1258 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1260 [(set_attr "type" "multi")
1261 (set_attr "unit" "i387")
1263 (cond [(match_operand:SF 1 "" "")
1265 (match_operand:DF 1 "" "")
1268 (const_string "XF")))])
1270 (define_insn "*cmpfp_xf"
1271 [(set (match_operand:HI 0 "register_operand" "=a")
1274 (match_operand:XF 1 "register_operand" "f")
1275 (match_operand:XF 2 "register_operand" "f"))]
1278 "* return output_fp_compare (insn, operands, 0, 0);"
1279 [(set_attr "type" "multi")
1280 (set_attr "unit" "i387")
1281 (set_attr "mode" "XF")])
1283 (define_insn_and_split "*cmpfp_xf_cc"
1284 [(set (reg:CCFP FLAGS_REG)
1286 (match_operand:XF 1 "register_operand" "f")
1287 (match_operand:XF 2 "register_operand" "f")))
1288 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1290 && TARGET_SAHF && !TARGET_CMOVE"
1292 "&& reload_completed"
1295 [(compare:CCFP (match_dup 1)(match_dup 2))]
1297 (set (reg:CC FLAGS_REG)
1298 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1300 [(set_attr "type" "multi")
1301 (set_attr "unit" "i387")
1302 (set_attr "mode" "XF")])
1304 (define_insn "*cmpfp_<mode>"
1305 [(set (match_operand:HI 0 "register_operand" "=a")
1308 (match_operand:MODEF 1 "register_operand" "f")
1309 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1312 "* return output_fp_compare (insn, operands, 0, 0);"
1313 [(set_attr "type" "multi")
1314 (set_attr "unit" "i387")
1315 (set_attr "mode" "<MODE>")])
1317 (define_insn_and_split "*cmpfp_<mode>_cc"
1318 [(set (reg:CCFP FLAGS_REG)
1320 (match_operand:MODEF 1 "register_operand" "f")
1321 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1322 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1324 && TARGET_SAHF && !TARGET_CMOVE"
1326 "&& reload_completed"
1329 [(compare:CCFP (match_dup 1)(match_dup 2))]
1331 (set (reg:CC FLAGS_REG)
1332 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1334 [(set_attr "type" "multi")
1335 (set_attr "unit" "i387")
1336 (set_attr "mode" "<MODE>")])
1338 (define_insn "*cmpfp_u"
1339 [(set (match_operand:HI 0 "register_operand" "=a")
1342 (match_operand 1 "register_operand" "f")
1343 (match_operand 2 "register_operand" "f"))]
1345 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1346 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1347 "* return output_fp_compare (insn, operands, 0, 1);"
1348 [(set_attr "type" "multi")
1349 (set_attr "unit" "i387")
1351 (cond [(match_operand:SF 1 "" "")
1353 (match_operand:DF 1 "" "")
1356 (const_string "XF")))])
1358 (define_insn_and_split "*cmpfp_u_cc"
1359 [(set (reg:CCFPU FLAGS_REG)
1361 (match_operand 1 "register_operand" "f")
1362 (match_operand 2 "register_operand" "f")))
1363 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1364 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1365 && TARGET_SAHF && !TARGET_CMOVE
1366 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1368 "&& reload_completed"
1371 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1373 (set (reg:CC FLAGS_REG)
1374 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1376 [(set_attr "type" "multi")
1377 (set_attr "unit" "i387")
1379 (cond [(match_operand:SF 1 "" "")
1381 (match_operand:DF 1 "" "")
1384 (const_string "XF")))])
1386 (define_insn "*cmpfp_<mode>"
1387 [(set (match_operand:HI 0 "register_operand" "=a")
1390 (match_operand 1 "register_operand" "f")
1391 (match_operator 3 "float_operator"
1392 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1394 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1395 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1396 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1397 "* return output_fp_compare (insn, operands, 0, 0);"
1398 [(set_attr "type" "multi")
1399 (set_attr "unit" "i387")
1400 (set_attr "fp_int_src" "true")
1401 (set_attr "mode" "<MODE>")])
1403 (define_insn_and_split "*cmpfp_<mode>_cc"
1404 [(set (reg:CCFP FLAGS_REG)
1406 (match_operand 1 "register_operand" "f")
1407 (match_operator 3 "float_operator"
1408 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1409 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1410 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1411 && TARGET_SAHF && !TARGET_CMOVE
1412 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1413 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1415 "&& reload_completed"
1420 (match_op_dup 3 [(match_dup 2)]))]
1422 (set (reg:CC FLAGS_REG)
1423 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1425 [(set_attr "type" "multi")
1426 (set_attr "unit" "i387")
1427 (set_attr "fp_int_src" "true")
1428 (set_attr "mode" "<MODE>")])
1430 ;; FP compares, step 2
1431 ;; Move the fpsw to ax.
1433 (define_insn "x86_fnstsw_1"
1434 [(set (match_operand:HI 0 "register_operand" "=a")
1435 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1438 [(set (attr "length") (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1439 (set_attr "mode" "SI")
1440 (set_attr "unit" "i387")])
1442 ;; FP compares, step 3
1443 ;; Get ax into flags, general case.
1445 (define_insn "x86_sahf_1"
1446 [(set (reg:CC FLAGS_REG)
1447 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1451 #ifndef HAVE_AS_IX86_SAHF
1453 return ASM_BYTE "0x9e";
1458 [(set_attr "length" "1")
1459 (set_attr "athlon_decode" "vector")
1460 (set_attr "amdfam10_decode" "direct")
1461 (set_attr "bdver1_decode" "direct")
1462 (set_attr "mode" "SI")])
1464 ;; Pentium Pro can do steps 1 through 3 in one go.
1465 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1466 (define_insn "*cmpfp_i_mixed"
1467 [(set (reg:CCFP FLAGS_REG)
1468 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1469 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1470 "TARGET_MIX_SSE_I387
1471 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1472 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1473 "* return output_fp_compare (insn, operands, 1, 0);"
1474 [(set_attr "type" "fcmp,ssecomi")
1475 (set_attr "prefix" "orig,maybe_vex")
1477 (if_then_else (match_operand:SF 1 "" "")
1479 (const_string "DF")))
1480 (set (attr "prefix_rep")
1481 (if_then_else (eq_attr "type" "ssecomi")
1483 (const_string "*")))
1484 (set (attr "prefix_data16")
1485 (cond [(eq_attr "type" "fcmp")
1487 (eq_attr "mode" "DF")
1490 (const_string "0")))
1491 (set_attr "athlon_decode" "vector")
1492 (set_attr "amdfam10_decode" "direct")
1493 (set_attr "bdver1_decode" "double")])
1495 (define_insn "*cmpfp_i_sse"
1496 [(set (reg:CCFP FLAGS_REG)
1497 (compare:CCFP (match_operand 0 "register_operand" "x")
1498 (match_operand 1 "nonimmediate_operand" "xm")))]
1500 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1501 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1502 "* return output_fp_compare (insn, operands, 1, 0);"
1503 [(set_attr "type" "ssecomi")
1504 (set_attr "prefix" "maybe_vex")
1506 (if_then_else (match_operand:SF 1 "" "")
1508 (const_string "DF")))
1509 (set_attr "prefix_rep" "0")
1510 (set (attr "prefix_data16")
1511 (if_then_else (eq_attr "mode" "DF")
1513 (const_string "0")))
1514 (set_attr "athlon_decode" "vector")
1515 (set_attr "amdfam10_decode" "direct")
1516 (set_attr "bdver1_decode" "double")])
1518 (define_insn "*cmpfp_i_i387"
1519 [(set (reg:CCFP FLAGS_REG)
1520 (compare:CCFP (match_operand 0 "register_operand" "f")
1521 (match_operand 1 "register_operand" "f")))]
1522 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1524 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1525 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1526 "* return output_fp_compare (insn, operands, 1, 0);"
1527 [(set_attr "type" "fcmp")
1529 (cond [(match_operand:SF 1 "" "")
1531 (match_operand:DF 1 "" "")
1534 (const_string "XF")))
1535 (set_attr "athlon_decode" "vector")
1536 (set_attr "amdfam10_decode" "direct")
1537 (set_attr "bdver1_decode" "double")])
1539 (define_insn "*cmpfp_iu_mixed"
1540 [(set (reg:CCFPU FLAGS_REG)
1541 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1542 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1543 "TARGET_MIX_SSE_I387
1544 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1545 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1546 "* return output_fp_compare (insn, operands, 1, 1);"
1547 [(set_attr "type" "fcmp,ssecomi")
1548 (set_attr "prefix" "orig,maybe_vex")
1550 (if_then_else (match_operand:SF 1 "" "")
1552 (const_string "DF")))
1553 (set (attr "prefix_rep")
1554 (if_then_else (eq_attr "type" "ssecomi")
1556 (const_string "*")))
1557 (set (attr "prefix_data16")
1558 (cond [(eq_attr "type" "fcmp")
1560 (eq_attr "mode" "DF")
1563 (const_string "0")))
1564 (set_attr "athlon_decode" "vector")
1565 (set_attr "amdfam10_decode" "direct")
1566 (set_attr "bdver1_decode" "double")])
1568 (define_insn "*cmpfp_iu_sse"
1569 [(set (reg:CCFPU FLAGS_REG)
1570 (compare:CCFPU (match_operand 0 "register_operand" "x")
1571 (match_operand 1 "nonimmediate_operand" "xm")))]
1573 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1574 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1575 "* return output_fp_compare (insn, operands, 1, 1);"
1576 [(set_attr "type" "ssecomi")
1577 (set_attr "prefix" "maybe_vex")
1579 (if_then_else (match_operand:SF 1 "" "")
1581 (const_string "DF")))
1582 (set_attr "prefix_rep" "0")
1583 (set (attr "prefix_data16")
1584 (if_then_else (eq_attr "mode" "DF")
1586 (const_string "0")))
1587 (set_attr "athlon_decode" "vector")
1588 (set_attr "amdfam10_decode" "direct")
1589 (set_attr "bdver1_decode" "double")])
1591 (define_insn "*cmpfp_iu_387"
1592 [(set (reg:CCFPU FLAGS_REG)
1593 (compare:CCFPU (match_operand 0 "register_operand" "f")
1594 (match_operand 1 "register_operand" "f")))]
1595 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1597 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1598 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1599 "* return output_fp_compare (insn, operands, 1, 1);"
1600 [(set_attr "type" "fcmp")
1602 (cond [(match_operand:SF 1 "" "")
1604 (match_operand:DF 1 "" "")
1607 (const_string "XF")))
1608 (set_attr "athlon_decode" "vector")
1609 (set_attr "amdfam10_decode" "direct")
1610 (set_attr "bdver1_decode" "direct")])
1612 ;; Push/pop instructions.
1614 (define_insn "*push<mode>2"
1615 [(set (match_operand:DWI 0 "push_operand" "=<")
1616 (match_operand:DWI 1 "general_no_elim_operand" "riF*m"))]
1621 [(set (match_operand:TI 0 "push_operand" "")
1622 (match_operand:TI 1 "general_operand" ""))]
1623 "TARGET_64BIT && reload_completed
1624 && !SSE_REG_P (operands[1])"
1626 "ix86_split_long_move (operands); DONE;")
1628 (define_insn "*pushdi2_rex64"
1629 [(set (match_operand:DI 0 "push_operand" "=<,!<")
1630 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
1635 [(set_attr "type" "push,multi")
1636 (set_attr "mode" "DI")])
1638 ;; Convert impossible pushes of immediate to existing instructions.
1639 ;; First try to get scratch register and go through it. In case this
1640 ;; fails, push sign extended lower part first and then overwrite
1641 ;; upper part by 32bit move.
1643 [(match_scratch:DI 2 "r")
1644 (set (match_operand:DI 0 "push_operand" "")
1645 (match_operand:DI 1 "immediate_operand" ""))]
1646 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1647 && !x86_64_immediate_operand (operands[1], DImode)"
1648 [(set (match_dup 2) (match_dup 1))
1649 (set (match_dup 0) (match_dup 2))])
1651 ;; We need to define this as both peepholer and splitter for case
1652 ;; peephole2 pass is not run.
1653 ;; "&& 1" is needed to keep it from matching the previous pattern.
1655 [(set (match_operand:DI 0 "push_operand" "")
1656 (match_operand:DI 1 "immediate_operand" ""))]
1657 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1658 && !x86_64_immediate_operand (operands[1], DImode) && 1"
1659 [(set (match_dup 0) (match_dup 1))
1660 (set (match_dup 2) (match_dup 3))]
1662 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1664 operands[1] = gen_lowpart (DImode, operands[2]);
1665 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1670 [(set (match_operand:DI 0 "push_operand" "")
1671 (match_operand:DI 1 "immediate_operand" ""))]
1672 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
1673 ? epilogue_completed : reload_completed)
1674 && !symbolic_operand (operands[1], DImode)
1675 && !x86_64_immediate_operand (operands[1], DImode)"
1676 [(set (match_dup 0) (match_dup 1))
1677 (set (match_dup 2) (match_dup 3))]
1679 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1681 operands[1] = gen_lowpart (DImode, operands[2]);
1682 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1687 [(set (match_operand:DI 0 "push_operand" "")
1688 (match_operand:DI 1 "general_operand" ""))]
1689 "!TARGET_64BIT && reload_completed
1690 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
1692 "ix86_split_long_move (operands); DONE;")
1694 (define_insn "*pushsi2"
1695 [(set (match_operand:SI 0 "push_operand" "=<")
1696 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1699 [(set_attr "type" "push")
1700 (set_attr "mode" "SI")])
1702 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1703 ;; "push a byte/word". But actually we use pushl, which has the effect
1704 ;; of rounding the amount pushed up to a word.
1706 ;; For TARGET_64BIT we always round up to 8 bytes.
1707 (define_insn "*push<mode>2_rex64"
1708 [(set (match_operand:SWI124 0 "push_operand" "=X")
1709 (match_operand:SWI124 1 "nonmemory_no_elim_operand" "r<i>"))]
1712 [(set_attr "type" "push")
1713 (set_attr "mode" "DI")])
1715 (define_insn "*push<mode>2"
1716 [(set (match_operand:SWI12 0 "push_operand" "=X")
1717 (match_operand:SWI12 1 "nonmemory_no_elim_operand" "rn"))]
1720 [(set_attr "type" "push")
1721 (set_attr "mode" "SI")])
1723 (define_insn "*push<mode>2_prologue"
1724 [(set (match_operand:P 0 "push_operand" "=<")
1725 (match_operand:P 1 "general_no_elim_operand" "r<i>*m"))
1726 (clobber (mem:BLK (scratch)))]
1728 "push{<imodesuffix>}\t%1"
1729 [(set_attr "type" "push")
1730 (set_attr "mode" "<MODE>")])
1732 (define_insn "*pop<mode>1"
1733 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1734 (match_operand:P 1 "pop_operand" ">"))]
1736 "pop{<imodesuffix>}\t%0"
1737 [(set_attr "type" "pop")
1738 (set_attr "mode" "<MODE>")])
1740 (define_insn "*pop<mode>1_epilogue"
1741 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1742 (match_operand:P 1 "pop_operand" ">"))
1743 (clobber (mem:BLK (scratch)))]
1745 "pop{<imodesuffix>}\t%0"
1746 [(set_attr "type" "pop")
1747 (set_attr "mode" "<MODE>")])
1749 ;; Move instructions.
1751 (define_expand "movoi"
1752 [(set (match_operand:OI 0 "nonimmediate_operand" "")
1753 (match_operand:OI 1 "general_operand" ""))]
1755 "ix86_expand_move (OImode, operands); DONE;")
1757 (define_expand "movti"
1758 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1759 (match_operand:TI 1 "nonimmediate_operand" ""))]
1760 "TARGET_64BIT || TARGET_SSE"
1763 ix86_expand_move (TImode, operands);
1764 else if (push_operand (operands[0], TImode))
1765 ix86_expand_push (TImode, operands[1]);
1767 ix86_expand_vector_move (TImode, operands);
1771 ;; This expands to what emit_move_complex would generate if we didn't
1772 ;; have a movti pattern. Having this avoids problems with reload on
1773 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
1774 ;; to have around all the time.
1775 (define_expand "movcdi"
1776 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
1777 (match_operand:CDI 1 "general_operand" ""))]
1780 if (push_operand (operands[0], CDImode))
1781 emit_move_complex_push (CDImode, operands[0], operands[1]);
1783 emit_move_complex_parts (operands[0], operands[1]);
1787 (define_expand "mov<mode>"
1788 [(set (match_operand:SWI1248x 0 "nonimmediate_operand" "")
1789 (match_operand:SWI1248x 1 "general_operand" ""))]
1791 "ix86_expand_move (<MODE>mode, operands); DONE;")
1793 (define_insn "*mov<mode>_xor"
1794 [(set (match_operand:SWI48 0 "register_operand" "=r")
1795 (match_operand:SWI48 1 "const0_operand" ""))
1796 (clobber (reg:CC FLAGS_REG))]
1799 [(set_attr "type" "alu1")
1800 (set_attr "mode" "SI")
1801 (set_attr "length_immediate" "0")])
1803 (define_insn "*mov<mode>_or"
1804 [(set (match_operand:SWI48 0 "register_operand" "=r")
1805 (match_operand:SWI48 1 "const_int_operand" ""))
1806 (clobber (reg:CC FLAGS_REG))]
1808 && operands[1] == constm1_rtx"
1809 "or{<imodesuffix>}\t{%1, %0|%0, %1}"
1810 [(set_attr "type" "alu1")
1811 (set_attr "mode" "<MODE>")
1812 (set_attr "length_immediate" "1")])
1814 (define_insn "*movoi_internal_avx"
1815 [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
1816 (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
1817 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1819 switch (which_alternative)
1822 return "vxorps\t%0, %0, %0";
1825 if (misaligned_operand (operands[0], OImode)
1826 || misaligned_operand (operands[1], OImode))
1827 return "vmovdqu\t{%1, %0|%0, %1}";
1829 return "vmovdqa\t{%1, %0|%0, %1}";
1834 [(set_attr "type" "sselog1,ssemov,ssemov")
1835 (set_attr "prefix" "vex")
1836 (set_attr "mode" "OI")])
1838 (define_insn "*movti_internal_rex64"
1839 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
1840 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
1841 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1843 switch (which_alternative)
1849 if (get_attr_mode (insn) == MODE_V4SF)
1850 return "%vxorps\t%0, %d0";
1852 return "%vpxor\t%0, %d0";
1855 /* TDmode values are passed as TImode on the stack. Moving them
1856 to stack may result in unaligned memory access. */
1857 if (misaligned_operand (operands[0], TImode)
1858 || misaligned_operand (operands[1], TImode))
1860 if (get_attr_mode (insn) == MODE_V4SF)
1861 return "%vmovups\t{%1, %0|%0, %1}";
1863 return "%vmovdqu\t{%1, %0|%0, %1}";
1867 if (get_attr_mode (insn) == MODE_V4SF)
1868 return "%vmovaps\t{%1, %0|%0, %1}";
1870 return "%vmovdqa\t{%1, %0|%0, %1}";
1876 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
1877 (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
1879 (cond [(eq_attr "alternative" "2,3")
1881 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1883 (const_string "V4SF")
1884 (const_string "TI"))
1885 (eq_attr "alternative" "4")
1887 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1889 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1891 (const_string "V4SF")
1892 (const_string "TI"))]
1893 (const_string "DI")))])
1896 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1897 (match_operand:TI 1 "general_operand" ""))]
1899 && !SSE_REG_P (operands[0]) && !SSE_REG_P (operands[1])"
1901 "ix86_split_long_move (operands); DONE;")
1903 (define_insn "*movti_internal_sse"
1904 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
1905 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
1906 "TARGET_SSE && !TARGET_64BIT
1907 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1909 switch (which_alternative)
1912 if (get_attr_mode (insn) == MODE_V4SF)
1913 return "%vxorps\t%0, %d0";
1915 return "%vpxor\t%0, %d0";
1918 /* TDmode values are passed as TImode on the stack. Moving them
1919 to stack may result in unaligned memory access. */
1920 if (misaligned_operand (operands[0], TImode)
1921 || misaligned_operand (operands[1], TImode))
1923 if (get_attr_mode (insn) == MODE_V4SF)
1924 return "%vmovups\t{%1, %0|%0, %1}";
1926 return "%vmovdqu\t{%1, %0|%0, %1}";
1930 if (get_attr_mode (insn) == MODE_V4SF)
1931 return "%vmovaps\t{%1, %0|%0, %1}";
1933 return "%vmovdqa\t{%1, %0|%0, %1}";
1939 [(set_attr "type" "sselog1,ssemov,ssemov")
1940 (set_attr "prefix" "maybe_vex")
1942 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1943 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1945 (const_string "V4SF")
1946 (and (eq_attr "alternative" "2")
1947 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1949 (const_string "V4SF")]
1950 (const_string "TI")))])
1952 (define_insn "*movdi_internal_rex64"
1953 [(set (match_operand:DI 0 "nonimmediate_operand"
1954 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
1955 (match_operand:DI 1 "general_operand"
1956 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
1957 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1959 switch (get_attr_type (insn))
1962 if (SSE_REG_P (operands[0]))
1963 return "movq2dq\t{%1, %0|%0, %1}";
1965 return "movdq2q\t{%1, %0|%0, %1}";
1970 if (get_attr_mode (insn) == MODE_TI)
1971 return "vmovdqa\t{%1, %0|%0, %1}";
1973 return "vmovq\t{%1, %0|%0, %1}";
1976 if (get_attr_mode (insn) == MODE_TI)
1977 return "movdqa\t{%1, %0|%0, %1}";
1981 /* Moves from and into integer register is done using movd
1982 opcode with REX prefix. */
1983 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
1984 return "movd\t{%1, %0|%0, %1}";
1985 return "movq\t{%1, %0|%0, %1}";
1988 return "%vpxor\t%0, %d0";
1991 return "pxor\t%0, %0";
1997 return "lea{q}\t{%a1, %0|%0, %a1}";
2000 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2001 if (get_attr_mode (insn) == MODE_SI)
2002 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2003 else if (which_alternative == 2)
2004 return "movabs{q}\t{%1, %0|%0, %1}";
2006 return "mov{q}\t{%1, %0|%0, %1}";
2010 (cond [(eq_attr "alternative" "5")
2011 (const_string "mmx")
2012 (eq_attr "alternative" "6,7,8,9,10")
2013 (const_string "mmxmov")
2014 (eq_attr "alternative" "11")
2015 (const_string "sselog1")
2016 (eq_attr "alternative" "12,13,14,15,16")
2017 (const_string "ssemov")
2018 (eq_attr "alternative" "17,18")
2019 (const_string "ssecvt")
2020 (eq_attr "alternative" "4")
2021 (const_string "multi")
2022 (match_operand:DI 1 "pic_32bit_operand" "")
2023 (const_string "lea")
2025 (const_string "imov")))
2028 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2030 (const_string "*")))
2031 (set (attr "length_immediate")
2033 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2035 (const_string "*")))
2036 (set_attr "prefix_rex" "*,*,*,*,*,*,*,1,*,1,*,*,*,*,*,*,*,*,*")
2037 (set_attr "prefix_data16" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,1,*,*,*")
2038 (set (attr "prefix")
2039 (if_then_else (eq_attr "alternative" "11,12,13,14,15,16")
2040 (const_string "maybe_vex")
2041 (const_string "orig")))
2042 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2044 ;; Convert impossible stores of immediate to existing instructions.
2045 ;; First try to get scratch register and go through it. In case this
2046 ;; fails, move by 32bit parts.
2048 [(match_scratch:DI 2 "r")
2049 (set (match_operand:DI 0 "memory_operand" "")
2050 (match_operand:DI 1 "immediate_operand" ""))]
2051 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2052 && !x86_64_immediate_operand (operands[1], DImode)"
2053 [(set (match_dup 2) (match_dup 1))
2054 (set (match_dup 0) (match_dup 2))])
2056 ;; We need to define this as both peepholer and splitter for case
2057 ;; peephole2 pass is not run.
2058 ;; "&& 1" is needed to keep it from matching the previous pattern.
2060 [(set (match_operand:DI 0 "memory_operand" "")
2061 (match_operand:DI 1 "immediate_operand" ""))]
2062 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2063 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2064 [(set (match_dup 2) (match_dup 3))
2065 (set (match_dup 4) (match_dup 5))]
2066 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2069 [(set (match_operand:DI 0 "memory_operand" "")
2070 (match_operand:DI 1 "immediate_operand" ""))]
2071 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2072 ? epilogue_completed : reload_completed)
2073 && !symbolic_operand (operands[1], DImode)
2074 && !x86_64_immediate_operand (operands[1], DImode)"
2075 [(set (match_dup 2) (match_dup 3))
2076 (set (match_dup 4) (match_dup 5))]
2077 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2079 (define_insn "*movdi_internal"
2080 [(set (match_operand:DI 0 "nonimmediate_operand"
2081 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2082 (match_operand:DI 1 "general_operand"
2083 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2084 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2089 movq\t{%1, %0|%0, %1}
2090 movq\t{%1, %0|%0, %1}
2092 %vmovq\t{%1, %0|%0, %1}
2093 %vmovdqa\t{%1, %0|%0, %1}
2094 %vmovq\t{%1, %0|%0, %1}
2096 movlps\t{%1, %0|%0, %1}
2097 movaps\t{%1, %0|%0, %1}
2098 movlps\t{%1, %0|%0, %1}"
2099 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2100 (set (attr "prefix")
2101 (if_then_else (eq_attr "alternative" "5,6,7,8")
2102 (const_string "vex")
2103 (const_string "orig")))
2104 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2107 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2108 (match_operand:DI 1 "general_operand" ""))]
2109 "!TARGET_64BIT && reload_completed
2110 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))
2111 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
2113 "ix86_split_long_move (operands); DONE;")
2115 (define_insn "*movsi_internal"
2116 [(set (match_operand:SI 0 "nonimmediate_operand"
2117 "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
2118 (match_operand:SI 1 "general_operand"
2119 "g ,ri,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
2120 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2122 switch (get_attr_type (insn))
2125 if (get_attr_mode (insn) == MODE_TI)
2126 return "%vpxor\t%0, %d0";
2127 return "%vxorps\t%0, %d0";
2130 switch (get_attr_mode (insn))
2133 return "%vmovdqa\t{%1, %0|%0, %1}";
2135 return "%vmovaps\t{%1, %0|%0, %1}";
2137 return "%vmovd\t{%1, %0|%0, %1}";
2139 return "%vmovss\t{%1, %0|%0, %1}";
2145 return "pxor\t%0, %0";
2148 if (get_attr_mode (insn) == MODE_DI)
2149 return "movq\t{%1, %0|%0, %1}";
2150 return "movd\t{%1, %0|%0, %1}";
2153 return "lea{l}\t{%a1, %0|%0, %a1}";
2156 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2157 return "mov{l}\t{%1, %0|%0, %1}";
2161 (cond [(eq_attr "alternative" "2")
2162 (const_string "mmx")
2163 (eq_attr "alternative" "3,4,5")
2164 (const_string "mmxmov")
2165 (eq_attr "alternative" "6")
2166 (const_string "sselog1")
2167 (eq_attr "alternative" "7,8,9,10,11")
2168 (const_string "ssemov")
2169 (match_operand:DI 1 "pic_32bit_operand" "")
2170 (const_string "lea")
2172 (const_string "imov")))
2173 (set (attr "prefix")
2174 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
2175 (const_string "orig")
2176 (const_string "maybe_vex")))
2177 (set (attr "prefix_data16")
2178 (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
2180 (const_string "*")))
2182 (cond [(eq_attr "alternative" "2,3")
2184 (eq_attr "alternative" "6,7")
2186 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2187 (const_string "V4SF")
2188 (const_string "TI"))
2189 (and (eq_attr "alternative" "8,9,10,11")
2190 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
2193 (const_string "SI")))])
2195 (define_insn "*movhi_internal"
2196 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
2197 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
2198 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2200 switch (get_attr_type (insn))
2203 /* movzwl is faster than movw on p2 due to partial word stalls,
2204 though not as fast as an aligned movl. */
2205 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
2207 if (get_attr_mode (insn) == MODE_SI)
2208 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2210 return "mov{w}\t{%1, %0|%0, %1}";
2214 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
2216 (const_string "imov")
2217 (and (eq_attr "alternative" "0")
2218 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2220 (eq (symbol_ref "TARGET_HIMODE_MATH")
2222 (const_string "imov")
2223 (and (eq_attr "alternative" "1,2")
2224 (match_operand:HI 1 "aligned_operand" ""))
2225 (const_string "imov")
2226 (and (ne (symbol_ref "TARGET_MOVX")
2228 (eq_attr "alternative" "0,2"))
2229 (const_string "imovx")
2231 (const_string "imov")))
2233 (cond [(eq_attr "type" "imovx")
2235 (and (eq_attr "alternative" "1,2")
2236 (match_operand:HI 1 "aligned_operand" ""))
2238 (and (eq_attr "alternative" "0")
2239 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2241 (eq (symbol_ref "TARGET_HIMODE_MATH")
2245 (const_string "HI")))])
2247 ;; Situation is quite tricky about when to choose full sized (SImode) move
2248 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
2249 ;; partial register dependency machines (such as AMD Athlon), where QImode
2250 ;; moves issue extra dependency and for partial register stalls machines
2251 ;; that don't use QImode patterns (and QImode move cause stall on the next
2254 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2255 ;; register stall machines with, where we use QImode instructions, since
2256 ;; partial register stall can be caused there. Then we use movzx.
2257 (define_insn "*movqi_internal"
2258 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2259 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
2260 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2262 switch (get_attr_type (insn))
2265 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2266 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2268 if (get_attr_mode (insn) == MODE_SI)
2269 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2271 return "mov{b}\t{%1, %0|%0, %1}";
2275 (cond [(and (eq_attr "alternative" "5")
2276 (not (match_operand:QI 1 "aligned_operand" "")))
2277 (const_string "imovx")
2278 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2280 (const_string "imov")
2281 (and (eq_attr "alternative" "3")
2282 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2284 (eq (symbol_ref "TARGET_QIMODE_MATH")
2286 (const_string "imov")
2287 (eq_attr "alternative" "3,5")
2288 (const_string "imovx")
2289 (and (ne (symbol_ref "TARGET_MOVX")
2291 (eq_attr "alternative" "2"))
2292 (const_string "imovx")
2294 (const_string "imov")))
2296 (cond [(eq_attr "alternative" "3,4,5")
2298 (eq_attr "alternative" "6")
2300 (eq_attr "type" "imovx")
2302 (and (eq_attr "type" "imov")
2303 (and (eq_attr "alternative" "0,1")
2304 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2306 (and (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2308 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2311 ;; Avoid partial register stalls when not using QImode arithmetic
2312 (and (eq_attr "type" "imov")
2313 (and (eq_attr "alternative" "0,1")
2314 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2316 (eq (symbol_ref "TARGET_QIMODE_MATH")
2320 (const_string "QI")))])
2322 ;; Stores and loads of ax to arbitrary constant address.
2323 ;; We fake an second form of instruction to force reload to load address
2324 ;; into register when rax is not available
2325 (define_insn "*movabs<mode>_1"
2326 [(set (mem:SWI1248x (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2327 (match_operand:SWI1248x 1 "nonmemory_operand" "a,er"))]
2328 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2330 movabs{<imodesuffix>}\t{%1, %P0|%P0, %1}
2331 mov{<imodesuffix>}\t{%1, %a0|%a0, %1}"
2332 [(set_attr "type" "imov")
2333 (set_attr "modrm" "0,*")
2334 (set_attr "length_address" "8,0")
2335 (set_attr "length_immediate" "0,*")
2336 (set_attr "memory" "store")
2337 (set_attr "mode" "<MODE>")])
2339 (define_insn "*movabs<mode>_2"
2340 [(set (match_operand:SWI1248x 0 "register_operand" "=a,r")
2341 (mem:SWI1248x (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2342 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2344 movabs{<imodesuffix>}\t{%P1, %0|%0, %P1}
2345 mov{<imodesuffix>}\t{%a1, %0|%0, %a1}"
2346 [(set_attr "type" "imov")
2347 (set_attr "modrm" "0,*")
2348 (set_attr "length_address" "8,0")
2349 (set_attr "length_immediate" "0")
2350 (set_attr "memory" "load")
2351 (set_attr "mode" "<MODE>")])
2353 (define_insn "*swap<mode>"
2354 [(set (match_operand:SWI48 0 "register_operand" "+r")
2355 (match_operand:SWI48 1 "register_operand" "+r"))
2359 "xchg{<imodesuffix>}\t%1, %0"
2360 [(set_attr "type" "imov")
2361 (set_attr "mode" "<MODE>")
2362 (set_attr "pent_pair" "np")
2363 (set_attr "athlon_decode" "vector")
2364 (set_attr "amdfam10_decode" "double")
2365 (set_attr "bdver1_decode" "double")])
2367 (define_insn "*swap<mode>_1"
2368 [(set (match_operand:SWI12 0 "register_operand" "+r")
2369 (match_operand:SWI12 1 "register_operand" "+r"))
2372 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2374 [(set_attr "type" "imov")
2375 (set_attr "mode" "SI")
2376 (set_attr "pent_pair" "np")
2377 (set_attr "athlon_decode" "vector")
2378 (set_attr "amdfam10_decode" "double")
2379 (set_attr "bdver1_decode" "double")])
2381 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL
2382 ;; is disabled for AMDFAM10
2383 (define_insn "*swap<mode>_2"
2384 [(set (match_operand:SWI12 0 "register_operand" "+<r>")
2385 (match_operand:SWI12 1 "register_operand" "+<r>"))
2388 "TARGET_PARTIAL_REG_STALL"
2389 "xchg{<imodesuffix>}\t%1, %0"
2390 [(set_attr "type" "imov")
2391 (set_attr "mode" "<MODE>")
2392 (set_attr "pent_pair" "np")
2393 (set_attr "athlon_decode" "vector")])
2395 (define_expand "movstrict<mode>"
2396 [(set (strict_low_part (match_operand:SWI12 0 "nonimmediate_operand" ""))
2397 (match_operand:SWI12 1 "general_operand" ""))]
2400 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2402 /* Don't generate memory->memory moves, go through a register */
2403 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2404 operands[1] = force_reg (<MODE>mode, operands[1]);
2407 (define_insn "*movstrict<mode>_1"
2408 [(set (strict_low_part
2409 (match_operand:SWI12 0 "nonimmediate_operand" "+<r>m,<r>"))
2410 (match_operand:SWI12 1 "general_operand" "<r>n,m"))]
2411 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2412 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2413 "mov{<imodesuffix>}\t{%1, %0|%0, %1}"
2414 [(set_attr "type" "imov")
2415 (set_attr "mode" "<MODE>")])
2417 (define_insn "*movstrict<mode>_xor"
2418 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
2419 (match_operand:SWI12 1 "const0_operand" ""))
2420 (clobber (reg:CC FLAGS_REG))]
2422 "xor{<imodesuffix>}\t%0, %0"
2423 [(set_attr "type" "alu1")
2424 (set_attr "mode" "<MODE>")
2425 (set_attr "length_immediate" "0")])
2427 (define_insn "*mov<mode>_extv_1"
2428 [(set (match_operand:SWI24 0 "register_operand" "=R")
2429 (sign_extract:SWI24 (match_operand 1 "ext_register_operand" "Q")
2433 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2434 [(set_attr "type" "imovx")
2435 (set_attr "mode" "SI")])
2437 (define_insn "*movqi_extv_1_rex64"
2438 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2439 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2444 switch (get_attr_type (insn))
2447 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2449 return "mov{b}\t{%h1, %0|%0, %h1}";
2453 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2454 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2455 (ne (symbol_ref "TARGET_MOVX")
2457 (const_string "imovx")
2458 (const_string "imov")))
2460 (if_then_else (eq_attr "type" "imovx")
2462 (const_string "QI")))])
2464 (define_insn "*movqi_extv_1"
2465 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2466 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2471 switch (get_attr_type (insn))
2474 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2476 return "mov{b}\t{%h1, %0|%0, %h1}";
2480 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2481 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2482 (ne (symbol_ref "TARGET_MOVX")
2484 (const_string "imovx")
2485 (const_string "imov")))
2487 (if_then_else (eq_attr "type" "imovx")
2489 (const_string "QI")))])
2491 (define_insn "*mov<mode>_extzv_1"
2492 [(set (match_operand:SWI48 0 "register_operand" "=R")
2493 (zero_extract:SWI48 (match_operand 1 "ext_register_operand" "Q")
2497 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2498 [(set_attr "type" "imovx")
2499 (set_attr "mode" "SI")])
2501 (define_insn "*movqi_extzv_2_rex64"
2502 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2504 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2509 switch (get_attr_type (insn))
2512 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2514 return "mov{b}\t{%h1, %0|%0, %h1}";
2518 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2519 (ne (symbol_ref "TARGET_MOVX")
2521 (const_string "imovx")
2522 (const_string "imov")))
2524 (if_then_else (eq_attr "type" "imovx")
2526 (const_string "QI")))])
2528 (define_insn "*movqi_extzv_2"
2529 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2531 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2536 switch (get_attr_type (insn))
2539 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2541 return "mov{b}\t{%h1, %0|%0, %h1}";
2545 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2546 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2547 (ne (symbol_ref "TARGET_MOVX")
2549 (const_string "imovx")
2550 (const_string "imov")))
2552 (if_then_else (eq_attr "type" "imovx")
2554 (const_string "QI")))])
2556 (define_expand "mov<mode>_insv_1"
2557 [(set (zero_extract:SWI48 (match_operand 0 "ext_register_operand" "")
2560 (match_operand:SWI48 1 "nonmemory_operand" ""))])
2562 (define_insn "*mov<mode>_insv_1_rex64"
2563 [(set (zero_extract:SWI48x (match_operand 0 "ext_register_operand" "+Q")
2566 (match_operand:SWI48x 1 "nonmemory_operand" "Qn"))]
2568 "mov{b}\t{%b1, %h0|%h0, %b1}"
2569 [(set_attr "type" "imov")
2570 (set_attr "mode" "QI")])
2572 (define_insn "*movsi_insv_1"
2573 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2576 (match_operand:SI 1 "general_operand" "Qmn"))]
2578 "mov{b}\t{%b1, %h0|%h0, %b1}"
2579 [(set_attr "type" "imov")
2580 (set_attr "mode" "QI")])
2582 (define_insn "*movqi_insv_2"
2583 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2586 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2589 "mov{b}\t{%h1, %h0|%h0, %h1}"
2590 [(set_attr "type" "imov")
2591 (set_attr "mode" "QI")])
2593 ;; Floating point push instructions.
2595 (define_insn "*pushtf"
2596 [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2597 (match_operand:TF 1 "general_no_elim_operand" "x,Fo,*r"))]
2600 /* This insn should be already split before reg-stack. */
2603 [(set_attr "type" "multi")
2604 (set_attr "unit" "sse,*,*")
2605 (set_attr "mode" "TF,SI,SI")])
2608 [(set (match_operand:TF 0 "push_operand" "")
2609 (match_operand:TF 1 "sse_reg_operand" ""))]
2610 "TARGET_SSE2 && reload_completed"
2611 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
2612 (set (mem:TF (reg:P SP_REG)) (match_dup 1))])
2615 [(set (match_operand:TF 0 "push_operand" "")
2616 (match_operand:TF 1 "general_operand" ""))]
2617 "TARGET_SSE2 && reload_completed
2618 && !SSE_REG_P (operands[1])"
2620 "ix86_split_long_move (operands); DONE;")
2622 (define_insn "*pushxf"
2623 [(set (match_operand:XF 0 "push_operand" "=<,<")
2624 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
2625 "optimize_function_for_speed_p (cfun)"
2627 /* This insn should be already split before reg-stack. */
2630 [(set_attr "type" "multi")
2631 (set_attr "unit" "i387,*")
2632 (set_attr "mode" "XF,SI")])
2634 ;; Size of pushxf is 3 (for sub) + 2 (for fstp) + memory operand size.
2635 ;; Size of pushxf using integer instructions is 3+3*memory operand size
2636 ;; Pushing using integer instructions is longer except for constants
2637 ;; and direct memory references (assuming that any given constant is pushed
2638 ;; only once, but this ought to be handled elsewhere).
2640 (define_insn "*pushxf_nointeger"
2641 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
2642 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
2643 "optimize_function_for_size_p (cfun)"
2645 /* This insn should be already split before reg-stack. */
2648 [(set_attr "type" "multi")
2649 (set_attr "unit" "i387,*,*")
2650 (set_attr "mode" "XF,SI,SI")])
2653 [(set (match_operand:XF 0 "push_operand" "")
2654 (match_operand:XF 1 "fp_register_operand" ""))]
2656 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2657 (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
2658 "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
2661 [(set (match_operand:XF 0 "push_operand" "")
2662 (match_operand:XF 1 "general_operand" ""))]
2664 && !FP_REG_P (operands[1])"
2666 "ix86_split_long_move (operands); DONE;")
2668 (define_insn "*pushdf"
2669 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2670 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
2671 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2673 /* This insn should be already split before reg-stack. */
2676 [(set_attr "type" "multi")
2677 (set_attr "unit" "i387,*,*")
2678 (set_attr "mode" "DF,SI,DF")])
2680 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2681 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2682 ;; On the average, pushdf using integers can be still shorter. Allow this
2683 ;; pattern for optimize_size too.
2685 (define_insn "*pushdf_nointeger"
2686 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2687 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
2688 "!(TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES)"
2690 /* This insn should be already split before reg-stack. */
2693 [(set_attr "type" "multi")
2694 (set_attr "unit" "i387,*,*,*")
2695 (set_attr "mode" "DF,SI,SI,DF")])
2697 ;; %%% Kill this when call knows how to work this out.
2699 [(set (match_operand:DF 0 "push_operand" "")
2700 (match_operand:DF 1 "any_fp_register_operand" ""))]
2702 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
2703 (set (mem:DF (reg:P SP_REG)) (match_dup 1))])
2706 [(set (match_operand:DF 0 "push_operand" "")
2707 (match_operand:DF 1 "general_operand" ""))]
2709 && !ANY_FP_REG_P (operands[1])"
2711 "ix86_split_long_move (operands); DONE;")
2713 (define_insn "*pushsf_rex64"
2714 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2715 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2718 /* Anything else should be already split before reg-stack. */
2719 gcc_assert (which_alternative == 1);
2720 return "push{q}\t%q1";
2722 [(set_attr "type" "multi,push,multi")
2723 (set_attr "unit" "i387,*,*")
2724 (set_attr "mode" "SF,DI,SF")])
2726 (define_insn "*pushsf"
2727 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2728 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2731 /* Anything else should be already split before reg-stack. */
2732 gcc_assert (which_alternative == 1);
2733 return "push{l}\t%1";
2735 [(set_attr "type" "multi,push,multi")
2736 (set_attr "unit" "i387,*,*")
2737 (set_attr "mode" "SF,SI,SF")])
2740 [(set (match_operand:SF 0 "push_operand" "")
2741 (match_operand:SF 1 "memory_operand" ""))]
2743 && MEM_P (operands[1])
2744 && (operands[2] = find_constant_src (insn))"
2748 ;; %%% Kill this when call knows how to work this out.
2750 [(set (match_operand:SF 0 "push_operand" "")
2751 (match_operand:SF 1 "any_fp_register_operand" ""))]
2753 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2754 (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
2755 "operands[2] = GEN_INT (-GET_MODE_SIZE (<MODE>mode));")
2757 ;; Floating point move instructions.
2759 (define_expand "movtf"
2760 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2761 (match_operand:TF 1 "nonimmediate_operand" ""))]
2764 ix86_expand_move (TFmode, operands);
2768 (define_expand "mov<mode>"
2769 [(set (match_operand:X87MODEF 0 "nonimmediate_operand" "")
2770 (match_operand:X87MODEF 1 "general_operand" ""))]
2772 "ix86_expand_move (<MODE>mode, operands); DONE;")
2774 (define_insn "*movtf_internal"
2775 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?r,?o")
2776 (match_operand:TF 1 "general_operand" "xm,x,C,roF,Fr"))]
2778 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2780 switch (which_alternative)
2784 if (get_attr_mode (insn) == MODE_V4SF)
2785 return "%vmovaps\t{%1, %0|%0, %1}";
2787 return "%vmovdqa\t{%1, %0|%0, %1}";
2789 if (get_attr_mode (insn) == MODE_V4SF)
2790 return "%vxorps\t%0, %d0";
2792 return "%vpxor\t%0, %d0";
2800 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
2801 (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,*,*")
2803 (cond [(eq_attr "alternative" "0,2")
2805 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2807 (const_string "V4SF")
2808 (const_string "TI"))
2809 (eq_attr "alternative" "1")
2811 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2813 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2815 (const_string "V4SF")
2816 (const_string "TI"))]
2817 (const_string "DI")))])
2820 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2821 (match_operand:TF 1 "general_operand" ""))]
2823 && !(SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]))"
2825 "ix86_split_long_move (operands); DONE;")
2827 (define_insn "*movxf_internal"
2828 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,r,o")
2829 (match_operand:XF 1 "general_operand" "fm,f,G,roF,Fr"))]
2830 "optimize_function_for_speed_p (cfun)
2831 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2832 && (reload_in_progress || reload_completed
2833 || GET_CODE (operands[1]) != CONST_DOUBLE
2834 || memory_operand (operands[0], XFmode))"
2836 switch (which_alternative)
2840 return output_387_reg_move (insn, operands);
2843 return standard_80387_constant_opcode (operands[1]);
2852 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2853 (set_attr "mode" "XF,XF,XF,SI,SI")])
2855 ;; Do not use integer registers when optimizing for size
2856 (define_insn "*movxf_internal_nointeger"
2857 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2858 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2859 "optimize_function_for_size_p (cfun)
2860 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2861 && (reload_in_progress || reload_completed
2862 || standard_80387_constant_p (operands[1])
2863 || GET_CODE (operands[1]) != CONST_DOUBLE
2864 || memory_operand (operands[0], XFmode))"
2866 switch (which_alternative)
2870 return output_387_reg_move (insn, operands);
2873 return standard_80387_constant_opcode (operands[1]);
2881 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2882 (set_attr "mode" "XF,XF,XF,SI,SI")])
2885 [(set (match_operand:XF 0 "nonimmediate_operand" "")
2886 (match_operand:XF 1 "general_operand" ""))]
2888 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2889 && ! (FP_REG_P (operands[0]) ||
2890 (GET_CODE (operands[0]) == SUBREG
2891 && FP_REG_P (SUBREG_REG (operands[0]))))
2892 && ! (FP_REG_P (operands[1]) ||
2893 (GET_CODE (operands[1]) == SUBREG
2894 && FP_REG_P (SUBREG_REG (operands[1]))))"
2896 "ix86_split_long_move (operands); DONE;")
2898 (define_insn "*movdf_internal_rex64"
2899 [(set (match_operand:DF 0 "nonimmediate_operand"
2900 "=f,m,f,r ,m ,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
2901 (match_operand:DF 1 "general_operand"
2902 "fm,f,G,rmF,Fr,C ,Y2*x,m ,Y2*x,r ,Yi"))]
2903 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2904 && (reload_in_progress || reload_completed
2905 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2906 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
2907 && optimize_function_for_size_p (cfun)
2908 && standard_80387_constant_p (operands[1]))
2909 || GET_CODE (operands[1]) != CONST_DOUBLE
2910 || memory_operand (operands[0], DFmode))"
2912 switch (which_alternative)
2916 return output_387_reg_move (insn, operands);
2919 return standard_80387_constant_opcode (operands[1]);
2926 switch (get_attr_mode (insn))
2929 return "%vxorps\t%0, %d0";
2931 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2932 return "%vxorps\t%0, %d0";
2934 return "%vxorpd\t%0, %d0";
2936 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2937 return "%vxorps\t%0, %d0";
2939 return "%vpxor\t%0, %d0";
2946 switch (get_attr_mode (insn))
2949 return "%vmovaps\t{%1, %0|%0, %1}";
2951 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2952 return "%vmovaps\t{%1, %0|%0, %1}";
2954 return "%vmovapd\t{%1, %0|%0, %1}";
2956 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2957 return "%vmovaps\t{%1, %0|%0, %1}";
2959 return "%vmovdqa\t{%1, %0|%0, %1}";
2961 return "%vmovq\t{%1, %0|%0, %1}";
2965 if (REG_P (operands[0]) && REG_P (operands[1]))
2966 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
2968 return "vmovsd\t{%1, %0|%0, %1}";
2971 return "movsd\t{%1, %0|%0, %1}";
2973 return "%vmovlpd\t{%1, %d0|%d0, %1}";
2975 return "%vmovlps\t{%1, %d0|%d0, %1}";
2982 return "%vmovd\t{%1, %0|%0, %1}";
2988 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
2989 (set (attr "prefix")
2990 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
2991 (const_string "orig")
2992 (const_string "maybe_vex")))
2993 (set (attr "prefix_data16")
2994 (if_then_else (eq_attr "mode" "V1DF")
2996 (const_string "*")))
2998 (cond [(eq_attr "alternative" "0,1,2")
3000 (eq_attr "alternative" "3,4,9,10")
3003 /* For SSE1, we have many fewer alternatives. */
3004 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3005 (cond [(eq_attr "alternative" "5,6")
3006 (const_string "V4SF")
3008 (const_string "V2SF"))
3010 /* xorps is one byte shorter. */
3011 (eq_attr "alternative" "5")
3012 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3014 (const_string "V4SF")
3015 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3019 (const_string "V2DF"))
3021 /* For architectures resolving dependencies on
3022 whole SSE registers use APD move to break dependency
3023 chains, otherwise use short move to avoid extra work.
3025 movaps encodes one byte shorter. */
3026 (eq_attr "alternative" "6")
3028 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3030 (const_string "V4SF")
3031 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3033 (const_string "V2DF")
3035 (const_string "DF"))
3036 /* For architectures resolving dependencies on register
3037 parts we may avoid extra work to zero out upper part
3039 (eq_attr "alternative" "7")
3041 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3043 (const_string "V1DF")
3044 (const_string "DF"))
3046 (const_string "DF")))])
3048 (define_insn "*movdf_internal"
3049 [(set (match_operand:DF 0 "nonimmediate_operand"
3050 "=f,m,f,r ,o ,Y2*x,Y2*x,Y2*x,m ")
3051 (match_operand:DF 1 "general_operand"
3052 "fm,f,G,roF,Fr,C ,Y2*x,m ,Y2*x"))]
3053 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3054 && optimize_function_for_speed_p (cfun)
3055 && TARGET_INTEGER_DFMODE_MOVES
3056 && (reload_in_progress || reload_completed
3057 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3058 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3059 && optimize_function_for_size_p (cfun)
3060 && standard_80387_constant_p (operands[1]))
3061 || GET_CODE (operands[1]) != CONST_DOUBLE
3062 || memory_operand (operands[0], DFmode))"
3064 switch (which_alternative)
3068 return output_387_reg_move (insn, operands);
3071 return standard_80387_constant_opcode (operands[1]);
3078 switch (get_attr_mode (insn))
3081 return "xorps\t%0, %0";
3083 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3084 return "xorps\t%0, %0";
3086 return "xorpd\t%0, %0";
3088 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3089 return "xorps\t%0, %0";
3091 return "pxor\t%0, %0";
3098 switch (get_attr_mode (insn))
3101 return "movaps\t{%1, %0|%0, %1}";
3103 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3104 return "movaps\t{%1, %0|%0, %1}";
3106 return "movapd\t{%1, %0|%0, %1}";
3108 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3109 return "movaps\t{%1, %0|%0, %1}";
3111 return "movdqa\t{%1, %0|%0, %1}";
3113 return "movq\t{%1, %0|%0, %1}";
3115 return "movsd\t{%1, %0|%0, %1}";
3117 return "movlpd\t{%1, %0|%0, %1}";
3119 return "movlps\t{%1, %0|%0, %1}";
3128 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3129 (set (attr "prefix_data16")
3130 (if_then_else (eq_attr "mode" "V1DF")
3132 (const_string "*")))
3134 (cond [(eq_attr "alternative" "0,1,2")
3136 (eq_attr "alternative" "3,4")
3139 /* For SSE1, we have many fewer alternatives. */
3140 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3141 (cond [(eq_attr "alternative" "5,6")
3142 (const_string "V4SF")
3144 (const_string "V2SF"))
3146 /* xorps is one byte shorter. */
3147 (eq_attr "alternative" "5")
3148 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3150 (const_string "V4SF")
3151 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3155 (const_string "V2DF"))
3157 /* For architectures resolving dependencies on
3158 whole SSE registers use APD move to break dependency
3159 chains, otherwise use short move to avoid extra work.
3161 movaps encodes one byte shorter. */
3162 (eq_attr "alternative" "6")
3164 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3166 (const_string "V4SF")
3167 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3169 (const_string "V2DF")
3171 (const_string "DF"))
3172 /* For architectures resolving dependencies on register
3173 parts we may avoid extra work to zero out upper part
3175 (eq_attr "alternative" "7")
3177 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3179 (const_string "V1DF")
3180 (const_string "DF"))
3182 (const_string "DF")))])
3184 ;; Moving is usually shorter when only FP registers are used. This separate
3185 ;; movdf pattern avoids the use of integer registers for FP operations
3186 ;; when optimizing for size.
3188 (define_insn "*movdf_internal_nointeger"
3189 [(set (match_operand:DF 0 "nonimmediate_operand"
3190 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
3191 (match_operand:DF 1 "general_operand"
3192 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
3193 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3194 && ((optimize_function_for_size_p (cfun)
3195 || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
3196 && (reload_in_progress || reload_completed
3197 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3198 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3199 && optimize_function_for_size_p (cfun)
3200 && !memory_operand (operands[0], DFmode)
3201 && standard_80387_constant_p (operands[1]))
3202 || GET_CODE (operands[1]) != CONST_DOUBLE
3203 || ((optimize_function_for_size_p (cfun)
3204 || !TARGET_MEMORY_MISMATCH_STALL
3205 || reload_in_progress || reload_completed)
3206 && memory_operand (operands[0], DFmode)))"
3208 switch (which_alternative)
3212 return output_387_reg_move (insn, operands);
3215 return standard_80387_constant_opcode (operands[1]);
3222 switch (get_attr_mode (insn))
3225 return "%vxorps\t%0, %d0";
3227 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3228 return "%vxorps\t%0, %d0";
3230 return "%vxorpd\t%0, %d0";
3232 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3233 return "%vxorps\t%0, %d0";
3235 return "%vpxor\t%0, %d0";
3242 switch (get_attr_mode (insn))
3245 return "%vmovaps\t{%1, %0|%0, %1}";
3247 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3248 return "%vmovaps\t{%1, %0|%0, %1}";
3250 return "%vmovapd\t{%1, %0|%0, %1}";
3252 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3253 return "%vmovaps\t{%1, %0|%0, %1}";
3255 return "%vmovdqa\t{%1, %0|%0, %1}";
3257 return "%vmovq\t{%1, %0|%0, %1}";
3261 if (REG_P (operands[0]) && REG_P (operands[1]))
3262 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3264 return "vmovsd\t{%1, %0|%0, %1}";
3267 return "movsd\t{%1, %0|%0, %1}";
3271 if (REG_P (operands[0]))
3272 return "vmovlpd\t{%1, %0, %0|%0, %0, %1}";
3274 return "vmovlpd\t{%1, %0|%0, %1}";
3277 return "movlpd\t{%1, %0|%0, %1}";
3281 if (REG_P (operands[0]))
3282 return "vmovlps\t{%1, %0, %0|%0, %0, %1}";
3284 return "vmovlps\t{%1, %0|%0, %1}";
3287 return "movlps\t{%1, %0|%0, %1}";
3296 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3297 (set (attr "prefix")
3298 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3299 (const_string "orig")
3300 (const_string "maybe_vex")))
3301 (set (attr "prefix_data16")
3302 (if_then_else (eq_attr "mode" "V1DF")
3304 (const_string "*")))
3306 (cond [(eq_attr "alternative" "0,1,2")
3308 (eq_attr "alternative" "3,4")
3311 /* For SSE1, we have many fewer alternatives. */
3312 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3313 (cond [(eq_attr "alternative" "5,6")
3314 (const_string "V4SF")
3316 (const_string "V2SF"))
3318 /* xorps is one byte shorter. */
3319 (eq_attr "alternative" "5")
3320 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3322 (const_string "V4SF")
3323 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3327 (const_string "V2DF"))
3329 /* For architectures resolving dependencies on
3330 whole SSE registers use APD move to break dependency
3331 chains, otherwise use short move to avoid extra work.
3333 movaps encodes one byte shorter. */
3334 (eq_attr "alternative" "6")
3336 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3338 (const_string "V4SF")
3339 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3341 (const_string "V2DF")
3343 (const_string "DF"))
3344 /* For architectures resolving dependencies on register
3345 parts we may avoid extra work to zero out upper part
3347 (eq_attr "alternative" "7")
3349 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3351 (const_string "V1DF")
3352 (const_string "DF"))
3354 (const_string "DF")))])
3357 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3358 (match_operand:DF 1 "general_operand" ""))]
3360 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3361 && ! (ANY_FP_REG_P (operands[0]) ||
3362 (GET_CODE (operands[0]) == SUBREG
3363 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3364 && ! (ANY_FP_REG_P (operands[1]) ||
3365 (GET_CODE (operands[1]) == SUBREG
3366 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3368 "ix86_split_long_move (operands); DONE;")
3370 (define_insn "*movsf_internal"
3371 [(set (match_operand:SF 0 "nonimmediate_operand"
3372 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
3373 (match_operand:SF 1 "general_operand"
3374 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
3375 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3376 && (reload_in_progress || reload_completed
3377 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3378 || (!TARGET_SSE_MATH && optimize_function_for_size_p (cfun)
3379 && standard_80387_constant_p (operands[1]))
3380 || GET_CODE (operands[1]) != CONST_DOUBLE
3381 || memory_operand (operands[0], SFmode))"
3383 switch (which_alternative)
3387 return output_387_reg_move (insn, operands);
3390 return standard_80387_constant_opcode (operands[1]);
3394 return "mov{l}\t{%1, %0|%0, %1}";
3396 if (get_attr_mode (insn) == MODE_TI)
3397 return "%vpxor\t%0, %d0";
3399 return "%vxorps\t%0, %d0";
3401 if (get_attr_mode (insn) == MODE_V4SF)
3402 return "%vmovaps\t{%1, %0|%0, %1}";
3404 return "%vmovss\t{%1, %d0|%d0, %1}";
3407 return REG_P (operands[1]) ? "vmovss\t{%1, %0, %0|%0, %0, %1}"
3408 : "vmovss\t{%1, %0|%0, %1}";
3410 return "movss\t{%1, %0|%0, %1}";
3412 return "%vmovss\t{%1, %0|%0, %1}";
3414 case 9: case 10: case 14: case 15:
3415 return "movd\t{%1, %0|%0, %1}";
3417 return "%vmovd\t{%1, %0|%0, %1}";
3420 return "movq\t{%1, %0|%0, %1}";
3426 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
3427 (set (attr "prefix")
3428 (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
3429 (const_string "maybe_vex")
3430 (const_string "orig")))
3432 (cond [(eq_attr "alternative" "3,4,9,10")
3434 (eq_attr "alternative" "5")
3436 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3438 (ne (symbol_ref "TARGET_SSE2")
3440 (eq (symbol_ref "optimize_function_for_size_p (cfun)")
3443 (const_string "V4SF"))
3444 /* For architectures resolving dependencies on
3445 whole SSE registers use APS move to break dependency
3446 chains, otherwise use short move to avoid extra work.
3448 Do the same for architectures resolving dependencies on
3449 the parts. While in DF mode it is better to always handle
3450 just register parts, the SF mode is different due to lack
3451 of instructions to load just part of the register. It is
3452 better to maintain the whole registers in single format
3453 to avoid problems on using packed logical operations. */
3454 (eq_attr "alternative" "6")
3456 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3458 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3460 (const_string "V4SF")
3461 (const_string "SF"))
3462 (eq_attr "alternative" "11")
3463 (const_string "DI")]
3464 (const_string "SF")))])
3467 [(set (match_operand 0 "register_operand" "")
3468 (match_operand 1 "memory_operand" ""))]
3470 && MEM_P (operands[1])
3471 && (GET_MODE (operands[0]) == TFmode
3472 || GET_MODE (operands[0]) == XFmode
3473 || GET_MODE (operands[0]) == DFmode
3474 || GET_MODE (operands[0]) == SFmode)
3475 && (operands[2] = find_constant_src (insn))"
3476 [(set (match_dup 0) (match_dup 2))]
3478 rtx c = operands[2];
3479 rtx r = operands[0];
3481 if (GET_CODE (r) == SUBREG)
3486 if (!standard_sse_constant_p (c))
3489 else if (FP_REG_P (r))
3491 if (!standard_80387_constant_p (c))
3494 else if (MMX_REG_P (r))
3499 [(set (match_operand 0 "register_operand" "")
3500 (float_extend (match_operand 1 "memory_operand" "")))]
3502 && MEM_P (operands[1])
3503 && (GET_MODE (operands[0]) == TFmode
3504 || GET_MODE (operands[0]) == XFmode
3505 || GET_MODE (operands[0]) == DFmode
3506 || GET_MODE (operands[0]) == SFmode)
3507 && (operands[2] = find_constant_src (insn))"
3508 [(set (match_dup 0) (match_dup 2))]
3510 rtx c = operands[2];
3511 rtx r = operands[0];
3513 if (GET_CODE (r) == SUBREG)
3518 if (!standard_sse_constant_p (c))
3521 else if (FP_REG_P (r))
3523 if (!standard_80387_constant_p (c))
3526 else if (MMX_REG_P (r))
3530 ;; Split the load of -0.0 or -1.0 into fldz;fchs or fld1;fchs sequence
3532 [(set (match_operand:X87MODEF 0 "register_operand" "")
3533 (match_operand:X87MODEF 1 "immediate_operand" ""))]
3534 "reload_completed && FP_REGNO_P (REGNO (operands[0]))
3535 && (standard_80387_constant_p (operands[1]) == 8
3536 || standard_80387_constant_p (operands[1]) == 9)"
3537 [(set (match_dup 0)(match_dup 1))
3539 (neg:X87MODEF (match_dup 0)))]
3543 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
3544 if (real_isnegzero (&r))
3545 operands[1] = CONST0_RTX (<MODE>mode);
3547 operands[1] = CONST1_RTX (<MODE>mode);
3550 (define_insn "swapxf"
3551 [(set (match_operand:XF 0 "register_operand" "+f")
3552 (match_operand:XF 1 "register_operand" "+f"))
3557 if (STACK_TOP_P (operands[0]))
3562 [(set_attr "type" "fxch")
3563 (set_attr "mode" "XF")])
3565 (define_insn "*swap<mode>"
3566 [(set (match_operand:MODEF 0 "fp_register_operand" "+f")
3567 (match_operand:MODEF 1 "fp_register_operand" "+f"))
3570 "TARGET_80387 || reload_completed"
3572 if (STACK_TOP_P (operands[0]))
3577 [(set_attr "type" "fxch")
3578 (set_attr "mode" "<MODE>")])
3580 ;; Zero extension instructions
3582 (define_expand "zero_extendsidi2"
3583 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3584 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3589 emit_insn (gen_zero_extendsidi2_1 (operands[0], operands[1]));
3594 (define_insn "*zero_extendsidi2_rex64"
3595 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,?*Ym,?*y,?*Yi,*Y2")
3597 (match_operand:SI 1 "nonimmediate_operand" "rm,0,r ,m ,r ,m")))]
3600 mov\t{%k1, %k0|%k0, %k1}
3602 movd\t{%1, %0|%0, %1}
3603 movd\t{%1, %0|%0, %1}
3604 %vmovd\t{%1, %0|%0, %1}
3605 %vmovd\t{%1, %0|%0, %1}"
3606 [(set_attr "type" "imovx,imov,mmxmov,mmxmov,ssemov,ssemov")
3607 (set_attr "prefix" "orig,*,orig,orig,maybe_vex,maybe_vex")
3608 (set_attr "prefix_0f" "0,*,*,*,*,*")
3609 (set_attr "mode" "SI,DI,DI,DI,TI,TI")])
3612 [(set (match_operand:DI 0 "memory_operand" "")
3613 (zero_extend:DI (match_dup 0)))]
3615 [(set (match_dup 4) (const_int 0))]
3616 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3618 ;; %%% Kill me once multi-word ops are sane.
3619 (define_insn "zero_extendsidi2_1"
3620 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?o,?*Ym,?*y,?*Yi,*Y2")
3622 (match_operand:SI 1 "nonimmediate_operand" "0,rm,r ,r ,m ,r ,m")))
3623 (clobber (reg:CC FLAGS_REG))]
3629 movd\t{%1, %0|%0, %1}
3630 movd\t{%1, %0|%0, %1}
3631 %vmovd\t{%1, %0|%0, %1}
3632 %vmovd\t{%1, %0|%0, %1}"
3633 [(set_attr "type" "multi,multi,multi,mmxmov,mmxmov,ssemov,ssemov")
3634 (set_attr "prefix" "*,*,*,orig,orig,maybe_vex,maybe_vex")
3635 (set_attr "mode" "SI,SI,SI,DI,DI,TI,TI")])
3638 [(set (match_operand:DI 0 "register_operand" "")
3639 (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3640 (clobber (reg:CC FLAGS_REG))]
3641 "!TARGET_64BIT && reload_completed
3642 && true_regnum (operands[0]) == true_regnum (operands[1])"
3643 [(set (match_dup 4) (const_int 0))]
3644 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3647 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3648 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3649 (clobber (reg:CC FLAGS_REG))]
3650 "!TARGET_64BIT && reload_completed
3651 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))"
3652 [(set (match_dup 3) (match_dup 1))
3653 (set (match_dup 4) (const_int 0))]
3654 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3656 (define_insn "zero_extend<mode>di2"
3657 [(set (match_operand:DI 0 "register_operand" "=r")
3659 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3661 "movz{<imodesuffix>l|x}\t{%1, %k0|%k0, %1}"
3662 [(set_attr "type" "imovx")
3663 (set_attr "mode" "SI")])
3665 (define_expand "zero_extendhisi2"
3666 [(set (match_operand:SI 0 "register_operand" "")
3667 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3670 if (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3672 operands[1] = force_reg (HImode, operands[1]);
3673 emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3678 (define_insn_and_split "zero_extendhisi2_and"
3679 [(set (match_operand:SI 0 "register_operand" "=r")
3680 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3681 (clobber (reg:CC FLAGS_REG))]
3682 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3684 "&& reload_completed"
3685 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3686 (clobber (reg:CC FLAGS_REG))])]
3688 [(set_attr "type" "alu1")
3689 (set_attr "mode" "SI")])
3691 (define_insn "*zero_extendhisi2_movzwl"
3692 [(set (match_operand:SI 0 "register_operand" "=r")
3693 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3694 "!TARGET_ZERO_EXTEND_WITH_AND
3695 || optimize_function_for_size_p (cfun)"
3696 "movz{wl|x}\t{%1, %0|%0, %1}"
3697 [(set_attr "type" "imovx")
3698 (set_attr "mode" "SI")])
3700 (define_expand "zero_extendqi<mode>2"
3702 [(set (match_operand:SWI24 0 "register_operand" "")
3703 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3704 (clobber (reg:CC FLAGS_REG))])])
3706 (define_insn "*zero_extendqi<mode>2_and"
3707 [(set (match_operand:SWI24 0 "register_operand" "=r,?&q")
3708 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3709 (clobber (reg:CC FLAGS_REG))]
3710 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3712 [(set_attr "type" "alu1")
3713 (set_attr "mode" "<MODE>")])
3715 ;; When source and destination does not overlap, clear destination
3716 ;; first and then do the movb
3718 [(set (match_operand:SWI24 0 "register_operand" "")
3719 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3720 (clobber (reg:CC FLAGS_REG))]
3722 && (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3723 && ANY_QI_REG_P (operands[0])
3724 && (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]))
3725 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3726 [(set (strict_low_part (match_dup 2)) (match_dup 1))]
3728 operands[2] = gen_lowpart (QImode, operands[0]);
3729 ix86_expand_clear (operands[0]);
3732 (define_insn "*zero_extendqi<mode>2_movzbl_and"
3733 [(set (match_operand:SWI24 0 "register_operand" "=r,r")
3734 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3735 (clobber (reg:CC FLAGS_REG))]
3736 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun)"
3738 [(set_attr "type" "imovx,alu1")
3739 (set_attr "mode" "<MODE>")])
3741 ;; For the movzbl case strip only the clobber
3743 [(set (match_operand:SWI24 0 "register_operand" "")
3744 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3745 (clobber (reg:CC FLAGS_REG))]
3747 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))
3748 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3750 (zero_extend:SWI24 (match_dup 1)))])
3752 ; zero extend to SImode to avoid partial register stalls
3753 (define_insn "*zero_extendqi<mode>2_movzbl"
3754 [(set (match_operand:SWI24 0 "register_operand" "=r")
3755 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3757 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))"
3758 "movz{bl|x}\t{%1, %k0|%k0, %1}"
3759 [(set_attr "type" "imovx")
3760 (set_attr "mode" "SI")])
3762 ;; Rest is handled by single and.
3764 [(set (match_operand:SWI24 0 "register_operand" "")
3765 (zero_extend:SWI24 (match_operand:QI 1 "register_operand" "")))
3766 (clobber (reg:CC FLAGS_REG))]
3768 && true_regnum (operands[0]) == true_regnum (operands[1])"
3769 [(parallel [(set (match_dup 0) (and:SWI24 (match_dup 0) (const_int 255)))
3770 (clobber (reg:CC FLAGS_REG))])])
3772 ;; Sign extension instructions
3774 (define_expand "extendsidi2"
3775 [(set (match_operand:DI 0 "register_operand" "")
3776 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))]
3781 emit_insn (gen_extendsidi2_1 (operands[0], operands[1]));
3786 (define_insn "*extendsidi2_rex64"
3787 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3788 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3792 movs{lq|x}\t{%1, %0|%0, %1}"
3793 [(set_attr "type" "imovx")
3794 (set_attr "mode" "DI")
3795 (set_attr "prefix_0f" "0")
3796 (set_attr "modrm" "0,1")])
3798 (define_insn "extendsidi2_1"
3799 [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3800 (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3801 (clobber (reg:CC FLAGS_REG))
3802 (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3806 ;; Extend to memory case when source register does die.
3808 [(set (match_operand:DI 0 "memory_operand" "")
3809 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3810 (clobber (reg:CC FLAGS_REG))
3811 (clobber (match_operand:SI 2 "register_operand" ""))]
3813 && dead_or_set_p (insn, operands[1])
3814 && !reg_mentioned_p (operands[1], operands[0]))"
3815 [(set (match_dup 3) (match_dup 1))
3816 (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3817 (clobber (reg:CC FLAGS_REG))])
3818 (set (match_dup 4) (match_dup 1))]
3819 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3821 ;; Extend to memory case when source register does not die.
3823 [(set (match_operand:DI 0 "memory_operand" "")
3824 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3825 (clobber (reg:CC FLAGS_REG))
3826 (clobber (match_operand:SI 2 "register_operand" ""))]
3830 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3832 emit_move_insn (operands[3], operands[1]);
3834 /* Generate a cltd if possible and doing so it profitable. */
3835 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3836 && true_regnum (operands[1]) == AX_REG
3837 && true_regnum (operands[2]) == DX_REG)
3839 emit_insn (gen_ashrsi3_cvt (operands[2], operands[1], GEN_INT (31)));
3843 emit_move_insn (operands[2], operands[1]);
3844 emit_insn (gen_ashrsi3_cvt (operands[2], operands[2], GEN_INT (31)));
3846 emit_move_insn (operands[4], operands[2]);
3850 ;; Extend to register case. Optimize case where source and destination
3851 ;; registers match and cases where we can use cltd.
3853 [(set (match_operand:DI 0 "register_operand" "")
3854 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3855 (clobber (reg:CC FLAGS_REG))
3856 (clobber (match_scratch:SI 2 ""))]
3860 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3862 if (true_regnum (operands[3]) != true_regnum (operands[1]))
3863 emit_move_insn (operands[3], operands[1]);
3865 /* Generate a cltd if possible and doing so it profitable. */
3866 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3867 && true_regnum (operands[3]) == AX_REG
3868 && true_regnum (operands[4]) == DX_REG)
3870 emit_insn (gen_ashrsi3_cvt (operands[4], operands[3], GEN_INT (31)));
3874 if (true_regnum (operands[4]) != true_regnum (operands[1]))
3875 emit_move_insn (operands[4], operands[1]);
3877 emit_insn (gen_ashrsi3_cvt (operands[4], operands[4], GEN_INT (31)));
3881 (define_insn "extend<mode>di2"
3882 [(set (match_operand:DI 0 "register_operand" "=r")
3884 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3886 "movs{<imodesuffix>q|x}\t{%1, %0|%0, %1}"
3887 [(set_attr "type" "imovx")
3888 (set_attr "mode" "DI")])
3890 (define_insn "extendhisi2"
3891 [(set (match_operand:SI 0 "register_operand" "=*a,r")
3892 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3895 switch (get_attr_prefix_0f (insn))
3898 return "{cwtl|cwde}";
3900 return "movs{wl|x}\t{%1, %0|%0, %1}";
3903 [(set_attr "type" "imovx")
3904 (set_attr "mode" "SI")
3905 (set (attr "prefix_0f")
3906 ;; movsx is short decodable while cwtl is vector decoded.
3907 (if_then_else (and (eq_attr "cpu" "!k6&