1 ;; GCC machine description for IA-32 and x86-64.
2 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 ;; Free Software Foundation, Inc.
5 ;; Mostly by William Schelter.
6 ;; x86_64 support added by Jan Hubicka
8 ;; This file is part of GCC.
10 ;; GCC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; GCC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING3. If not see
22 ;; <http://www.gnu.org/licenses/>. */
24 ;; The original PO technology requires these to be ordered by speed,
25 ;; so that assigner will pick the fastest.
27 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
29 ;; The special asm out single letter directives following a '%' are:
30 ;; L,W,B,Q,S,T -- print the opcode suffix for specified size of operand.
31 ;; C -- print opcode suffix for set/cmov insn.
32 ;; c -- like C, but print reversed condition
33 ;; F,f -- likewise, but for floating-point.
34 ;; O -- if HAVE_AS_IX86_CMOV_SUN_SYNTAX, expand to "w.", "l." or "q.",
36 ;; R -- print the prefix for register names.
37 ;; z -- print the opcode suffix for the size of the current operand.
38 ;; Z -- likewise, with special suffixes for x87 instructions.
39 ;; * -- print a star (in certain assembler syntax)
40 ;; A -- print an absolute memory reference.
41 ;; w -- print the operand as if it's a "word" (HImode) even if it isn't.
42 ;; s -- print a shift double count, followed by the assemblers argument
44 ;; b -- print the QImode name of the register for the indicated operand.
45 ;; %b0 would print %al if operands[0] is reg 0.
46 ;; w -- likewise, print the HImode name of the register.
47 ;; k -- likewise, print the SImode name of the register.
48 ;; q -- likewise, print the DImode name of the register.
49 ;; x -- likewise, print the V4SFmode name of the register.
50 ;; t -- likewise, print the V8SFmode name of the register.
51 ;; h -- print the QImode name for a "high" register, either ah, bh, ch or dh.
52 ;; y -- print "st(0)" instead of "st" as a register.
53 ;; d -- print duplicated register operand for AVX instruction.
54 ;; D -- print condition for SSE cmp instruction.
55 ;; P -- if PIC, print an @PLT suffix.
56 ;; X -- don't print any sort of PIC '@' suffix for a symbol.
57 ;; & -- print some in-use local-dynamic symbol name.
58 ;; H -- print a memory address offset by 8; used for sse high-parts
59 ;; Y -- print condition for XOP pcom* instruction.
60 ;; + -- print a branch hint as 'cs' or 'ds' prefix
61 ;; ; -- print a semicolon (after prefixes due to bug in older gas).
62 ;; @ -- print a segment register of thread base pointer load
66 (define_c_enum "unspec" [
67 ;; Relocation specifiers
78 UNSPEC_MACHOPIC_OFFSET
87 UNSPEC_MEMORY_BLOCKAGE
96 ;; Other random patterns
105 UNSPEC_LD_MPIC ; load_macho_picbase
107 UNSPEC_DIV_ALREADY_SPLIT
109 ;; For SSE/MMX support:
127 UNSPEC_MS_TO_SYSV_CALL
129 ;; Generic math support
131 UNSPEC_IEEE_MIN ; not commutative
132 UNSPEC_IEEE_MAX ; not commutative
134 ;; x87 Floating point
150 UNSPEC_FRNDINT_MASK_PM
154 ;; x87 Double output FP
186 ;; For SSE4.1 support
196 ;; For SSE4.2 support
203 UNSPEC_XOP_UNSIGNED_CMP
214 UNSPEC_AESKEYGENASSIST
216 ;; For PCLMUL support
232 (define_c_enum "unspecv" [
235 UNSPECV_PROBE_STACK_RANGE
255 UNSPECV_LLWP_INTRINSIC
256 UNSPECV_SLWP_INTRINSIC
257 UNSPECV_LWPVAL_INTRINSIC
258 UNSPECV_LWPINS_INTRINSIC
266 ;; Constants to represent pcomtrue/pcomfalse variants
276 ;; Constants used in the XOP pperm instruction
278 [(PPERM_SRC 0x00) /* copy source */
279 (PPERM_INVERT 0x20) /* invert source */
280 (PPERM_REVERSE 0x40) /* bit reverse source */
281 (PPERM_REV_INV 0x60) /* bit reverse & invert src */
282 (PPERM_ZERO 0x80) /* all 0's */
283 (PPERM_ONES 0xa0) /* all 1's */
284 (PPERM_SIGN 0xc0) /* propagate sign bit */
285 (PPERM_INV_SIGN 0xe0) /* invert & propagate sign */
286 (PPERM_SRC1 0x00) /* use first source byte */
287 (PPERM_SRC2 0x10) /* use second source byte */
290 ;; Registers by name.
343 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
346 ;; In C guard expressions, put expressions which may be compile-time
347 ;; constants first. This allows for better optimization. For
348 ;; example, write "TARGET_64BIT && reload_completed", not
349 ;; "reload_completed && TARGET_64BIT".
353 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,atom,
354 generic64,amdfam10,bdver1"
355 (const (symbol_ref "ix86_schedule")))
357 ;; A basic instruction type. Refinements due to arguments to be
358 ;; provided in other attributes.
361 alu,alu1,negnot,imov,imovx,lea,
362 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
363 icmp,test,ibr,setcc,icmov,
364 push,pop,call,callv,leave,
366 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
367 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
368 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
369 ssemuladd,sse4arg,lwp,
370 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
371 (const_string "other"))
373 ;; Main data type used by the insn
375 "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
376 (const_string "unknown"))
378 ;; The CPU unit operations uses.
379 (define_attr "unit" "integer,i387,sse,mmx,unknown"
380 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
381 (const_string "i387")
382 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
383 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
384 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
386 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
388 (eq_attr "type" "other")
389 (const_string "unknown")]
390 (const_string "integer")))
392 ;; The (bounding maximum) length of an instruction immediate.
393 (define_attr "length_immediate" ""
394 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
397 (eq_attr "unit" "i387,sse,mmx")
399 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
401 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
402 (eq_attr "type" "imov,test")
403 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
404 (eq_attr "type" "call")
405 (if_then_else (match_operand 0 "constant_call_address_operand" "")
408 (eq_attr "type" "callv")
409 (if_then_else (match_operand 1 "constant_call_address_operand" "")
412 ;; We don't know the size before shorten_branches. Expect
413 ;; the instruction to fit for better scheduling.
414 (eq_attr "type" "ibr")
417 (symbol_ref "/* Update immediate_length and other attributes! */
418 gcc_unreachable (),1")))
420 ;; The (bounding maximum) length of an instruction address.
421 (define_attr "length_address" ""
422 (cond [(eq_attr "type" "str,other,multi,fxch")
424 (and (eq_attr "type" "call")
425 (match_operand 0 "constant_call_address_operand" ""))
427 (and (eq_attr "type" "callv")
428 (match_operand 1 "constant_call_address_operand" ""))
431 (symbol_ref "ix86_attr_length_address_default (insn)")))
433 ;; Set when length prefix is used.
434 (define_attr "prefix_data16" ""
435 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
437 (eq_attr "mode" "HI")
439 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
444 ;; Set when string REP prefix is used.
445 (define_attr "prefix_rep" ""
446 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
448 (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
453 ;; Set when 0f opcode prefix is used.
454 (define_attr "prefix_0f" ""
456 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
457 (eq_attr "unit" "sse,mmx"))
461 ;; Set when REX opcode prefix is used.
462 (define_attr "prefix_rex" ""
463 (cond [(eq (symbol_ref "TARGET_64BIT") (const_int 0))
465 (and (eq_attr "mode" "DI")
466 (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
467 (eq_attr "unit" "!mmx")))
469 (and (eq_attr "mode" "QI")
470 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
473 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
476 (and (eq_attr "type" "imovx")
477 (match_operand:QI 1 "ext_QIreg_operand" ""))
482 ;; There are also additional prefixes in 3DNOW, SSSE3.
483 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
484 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
485 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
486 (define_attr "prefix_extra" ""
487 (cond [(eq_attr "type" "ssemuladd,sse4arg")
489 (eq_attr "type" "sseiadd1,ssecvt1")
494 ;; Prefix used: original, VEX or maybe VEX.
495 (define_attr "prefix" "orig,vex,maybe_vex"
496 (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
498 (const_string "orig")))
500 ;; VEX W bit is used.
501 (define_attr "prefix_vex_w" "" (const_int 0))
503 ;; The length of VEX prefix
504 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
505 ;; 0f38/0f3a prefixes can't. In i386.md 0f3[8a] is
506 ;; still prefix_0f 1, with prefix_extra 1.
507 (define_attr "length_vex" ""
508 (if_then_else (and (eq_attr "prefix_0f" "1")
509 (eq_attr "prefix_extra" "0"))
510 (if_then_else (eq_attr "prefix_vex_w" "1")
511 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 1)")
512 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 0)"))
513 (if_then_else (eq_attr "prefix_vex_w" "1")
514 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 1)")
515 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 0)"))))
517 ;; Set when modrm byte is used.
518 (define_attr "modrm" ""
519 (cond [(eq_attr "type" "str,leave")
521 (eq_attr "unit" "i387")
523 (and (eq_attr "type" "incdec")
524 (and (eq (symbol_ref "TARGET_64BIT") (const_int 0))
525 (ior (match_operand:SI 1 "register_operand" "")
526 (match_operand:HI 1 "register_operand" ""))))
528 (and (eq_attr "type" "push")
529 (not (match_operand 1 "memory_operand" "")))
531 (and (eq_attr "type" "pop")
532 (not (match_operand 0 "memory_operand" "")))
534 (and (eq_attr "type" "imov")
535 (and (not (eq_attr "mode" "DI"))
536 (ior (and (match_operand 0 "register_operand" "")
537 (match_operand 1 "immediate_operand" ""))
538 (ior (and (match_operand 0 "ax_reg_operand" "")
539 (match_operand 1 "memory_displacement_only_operand" ""))
540 (and (match_operand 0 "memory_displacement_only_operand" "")
541 (match_operand 1 "ax_reg_operand" ""))))))
543 (and (eq_attr "type" "call")
544 (match_operand 0 "constant_call_address_operand" ""))
546 (and (eq_attr "type" "callv")
547 (match_operand 1 "constant_call_address_operand" ""))
549 (and (eq_attr "type" "alu,alu1,icmp,test")
550 (match_operand 0 "ax_reg_operand" ""))
551 (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
555 ;; The (bounding maximum) length of an instruction in bytes.
556 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
557 ;; Later we may want to split them and compute proper length as for
559 (define_attr "length" ""
560 (cond [(eq_attr "type" "other,multi,fistp,frndint")
562 (eq_attr "type" "fcmp")
564 (eq_attr "unit" "i387")
566 (plus (attr "prefix_data16")
567 (attr "length_address")))
568 (ior (eq_attr "prefix" "vex")
569 (and (eq_attr "prefix" "maybe_vex")
570 (ne (symbol_ref "TARGET_AVX") (const_int 0))))
571 (plus (attr "length_vex")
572 (plus (attr "length_immediate")
574 (attr "length_address"))))]
575 (plus (plus (attr "modrm")
576 (plus (attr "prefix_0f")
577 (plus (attr "prefix_rex")
578 (plus (attr "prefix_extra")
580 (plus (attr "prefix_rep")
581 (plus (attr "prefix_data16")
582 (plus (attr "length_immediate")
583 (attr "length_address")))))))
585 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
586 ;; `store' if there is a simple memory reference therein, or `unknown'
587 ;; if the instruction is complex.
589 (define_attr "memory" "none,load,store,both,unknown"
590 (cond [(eq_attr "type" "other,multi,str,lwp")
591 (const_string "unknown")
592 (eq_attr "type" "lea,fcmov,fpspc")
593 (const_string "none")
594 (eq_attr "type" "fistp,leave")
595 (const_string "both")
596 (eq_attr "type" "frndint")
597 (const_string "load")
598 (eq_attr "type" "push")
599 (if_then_else (match_operand 1 "memory_operand" "")
600 (const_string "both")
601 (const_string "store"))
602 (eq_attr "type" "pop")
603 (if_then_else (match_operand 0 "memory_operand" "")
604 (const_string "both")
605 (const_string "load"))
606 (eq_attr "type" "setcc")
607 (if_then_else (match_operand 0 "memory_operand" "")
608 (const_string "store")
609 (const_string "none"))
610 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
611 (if_then_else (ior (match_operand 0 "memory_operand" "")
612 (match_operand 1 "memory_operand" ""))
613 (const_string "load")
614 (const_string "none"))
615 (eq_attr "type" "ibr")
616 (if_then_else (match_operand 0 "memory_operand" "")
617 (const_string "load")
618 (const_string "none"))
619 (eq_attr "type" "call")
620 (if_then_else (match_operand 0 "constant_call_address_operand" "")
621 (const_string "none")
622 (const_string "load"))
623 (eq_attr "type" "callv")
624 (if_then_else (match_operand 1 "constant_call_address_operand" "")
625 (const_string "none")
626 (const_string "load"))
627 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
628 (match_operand 1 "memory_operand" ""))
629 (const_string "both")
630 (and (match_operand 0 "memory_operand" "")
631 (match_operand 1 "memory_operand" ""))
632 (const_string "both")
633 (match_operand 0 "memory_operand" "")
634 (const_string "store")
635 (match_operand 1 "memory_operand" "")
636 (const_string "load")
638 "!alu1,negnot,ishift1,
639 imov,imovx,icmp,test,bitmanip,
641 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
642 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
643 (match_operand 2 "memory_operand" ""))
644 (const_string "load")
645 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
646 (match_operand 3 "memory_operand" ""))
647 (const_string "load")
649 (const_string "none")))
651 ;; Indicates if an instruction has both an immediate and a displacement.
653 (define_attr "imm_disp" "false,true,unknown"
654 (cond [(eq_attr "type" "other,multi")
655 (const_string "unknown")
656 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
657 (and (match_operand 0 "memory_displacement_operand" "")
658 (match_operand 1 "immediate_operand" "")))
659 (const_string "true")
660 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
661 (and (match_operand 0 "memory_displacement_operand" "")
662 (match_operand 2 "immediate_operand" "")))
663 (const_string "true")
665 (const_string "false")))
667 ;; Indicates if an FP operation has an integer source.
669 (define_attr "fp_int_src" "false,true"
670 (const_string "false"))
672 ;; Defines rounding mode of an FP operation.
674 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
675 (const_string "any"))
677 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
678 (define_attr "use_carry" "0,1" (const_string "0"))
680 ;; Define attribute to indicate unaligned ssemov insns
681 (define_attr "movu" "0,1" (const_string "0"))
683 ;; Describe a user's asm statement.
684 (define_asm_attributes
685 [(set_attr "length" "128")
686 (set_attr "type" "multi")])
688 (define_code_iterator plusminus [plus minus])
690 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
692 ;; Base name for define_insn
693 (define_code_attr plusminus_insn
694 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
695 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
697 ;; Base name for insn mnemonic.
698 (define_code_attr plusminus_mnemonic
699 [(plus "add") (ss_plus "adds") (us_plus "addus")
700 (minus "sub") (ss_minus "subs") (us_minus "subus")])
701 (define_code_attr plusminus_carry_mnemonic
702 [(plus "adc") (minus "sbb")])
704 ;; Mark commutative operators as such in constraints.
705 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
706 (minus "") (ss_minus "") (us_minus "")])
708 ;; Mapping of signed max and min
709 (define_code_iterator smaxmin [smax smin])
711 ;; Mapping of unsigned max and min
712 (define_code_iterator umaxmin [umax umin])
714 ;; Base name for integer and FP insn mnemonic
715 (define_code_attr maxmin_int [(smax "maxs") (smin "mins")
716 (umax "maxu") (umin "minu")])
717 (define_code_attr maxmin_float [(smax "max") (smin "min")])
719 ;; Mapping of logic operators
720 (define_code_iterator any_logic [and ior xor])
721 (define_code_iterator any_or [ior xor])
723 ;; Base name for insn mnemonic.
724 (define_code_attr logic [(and "and") (ior "or") (xor "xor")])
726 ;; Mapping of shift-right operators
727 (define_code_iterator any_shiftrt [lshiftrt ashiftrt])
729 ;; Base name for define_insn
730 (define_code_attr shiftrt_insn [(lshiftrt "lshr") (ashiftrt "ashr")])
732 ;; Base name for insn mnemonic.
733 (define_code_attr shiftrt [(lshiftrt "shr") (ashiftrt "sar")])
735 ;; Mapping of rotate operators
736 (define_code_iterator any_rotate [rotate rotatert])
738 ;; Base name for define_insn
739 (define_code_attr rotate_insn [(rotate "rotl") (rotatert "rotr")])
741 ;; Base name for insn mnemonic.
742 (define_code_attr rotate [(rotate "rol") (rotatert "ror")])
744 ;; Mapping of abs neg operators
745 (define_code_iterator absneg [abs neg])
747 ;; Base name for x87 insn mnemonic.
748 (define_code_attr absneg_mnemonic [(abs "abs") (neg "chs")])
750 ;; Used in signed and unsigned widening multiplications.
751 (define_code_iterator any_extend [sign_extend zero_extend])
753 ;; Various insn prefixes for signed and unsigned operations.
754 (define_code_attr u [(sign_extend "") (zero_extend "u")
755 (div "") (udiv "u")])
756 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
758 ;; Used in signed and unsigned divisions.
759 (define_code_iterator any_div [div udiv])
761 ;; Instruction prefix for signed and unsigned operations.
762 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")
763 (div "i") (udiv "")])
765 ;; 64bit single word integer modes.
766 (define_mode_iterator SWI1248x [QI HI SI DI])
768 ;; 64bit single word integer modes without QImode and HImode.
769 (define_mode_iterator SWI48x [SI DI])
771 ;; Single word integer modes.
772 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
774 ;; Single word integer modes without SImode and DImode.
775 (define_mode_iterator SWI12 [QI HI])
777 ;; Single word integer modes without DImode.
778 (define_mode_iterator SWI124 [QI HI SI])
780 ;; Single word integer modes without QImode and DImode.
781 (define_mode_iterator SWI24 [HI SI])
783 ;; Single word integer modes without QImode.
784 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
786 ;; Single word integer modes without QImode and HImode.
787 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
789 ;; All math-dependant single and double word integer modes.
790 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
791 (HI "TARGET_HIMODE_MATH")
792 SI DI (TI "TARGET_64BIT")])
794 ;; Math-dependant single word integer modes.
795 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
796 (HI "TARGET_HIMODE_MATH")
797 SI (DI "TARGET_64BIT")])
799 ;; Math-dependant single word integer modes without DImode.
800 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
801 (HI "TARGET_HIMODE_MATH")
804 ;; Math-dependant single word integer modes without QImode.
805 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
806 SI (DI "TARGET_64BIT")])
808 ;; Double word integer modes.
809 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
810 (TI "TARGET_64BIT")])
812 ;; Double word integer modes as mode attribute.
813 (define_mode_attr DWI [(SI "DI") (DI "TI")])
814 (define_mode_attr dwi [(SI "di") (DI "ti")])
816 ;; Half mode for double word integer modes.
817 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
818 (DI "TARGET_64BIT")])
820 ;; Instruction suffix for integer modes.
821 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
823 ;; Pointer size prefix for integer modes (Intel asm dialect)
824 (define_mode_attr iptrsize [(QI "BYTE")
829 ;; Register class for integer modes.
830 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
832 ;; Immediate operand constraint for integer modes.
833 (define_mode_attr i [(QI "n") (HI "n") (SI "i") (DI "e")])
835 ;; General operand constraint for word modes.
836 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "g") (DI "rme")])
838 ;; Immediate operand constraint for double integer modes.
839 (define_mode_attr di [(SI "iF") (DI "e")])
841 ;; Immediate operand constraint for shifts.
842 (define_mode_attr S [(QI "I") (HI "I") (SI "I") (DI "J") (TI "O")])
844 ;; General operand predicate for integer modes.
845 (define_mode_attr general_operand
846 [(QI "general_operand")
847 (HI "general_operand")
848 (SI "general_operand")
849 (DI "x86_64_general_operand")
850 (TI "x86_64_general_operand")])
852 ;; General sign/zero extend operand predicate for integer modes.
853 (define_mode_attr general_szext_operand
854 [(QI "general_operand")
855 (HI "general_operand")
856 (SI "general_operand")
857 (DI "x86_64_szext_general_operand")])
859 ;; Immediate operand predicate for integer modes.
860 (define_mode_attr immediate_operand
861 [(QI "immediate_operand")
862 (HI "immediate_operand")
863 (SI "immediate_operand")
864 (DI "x86_64_immediate_operand")])
866 ;; Nonmemory operand predicate for integer modes.
867 (define_mode_attr nonmemory_operand
868 [(QI "nonmemory_operand")
869 (HI "nonmemory_operand")
870 (SI "nonmemory_operand")
871 (DI "x86_64_nonmemory_operand")])
873 ;; Operand predicate for shifts.
874 (define_mode_attr shift_operand
875 [(QI "nonimmediate_operand")
876 (HI "nonimmediate_operand")
877 (SI "nonimmediate_operand")
878 (DI "shiftdi_operand")
879 (TI "register_operand")])
881 ;; Operand predicate for shift argument.
882 (define_mode_attr shift_immediate_operand
883 [(QI "const_1_to_31_operand")
884 (HI "const_1_to_31_operand")
885 (SI "const_1_to_31_operand")
886 (DI "const_1_to_63_operand")])
888 ;; Input operand predicate for arithmetic left shifts.
889 (define_mode_attr ashl_input_operand
890 [(QI "nonimmediate_operand")
891 (HI "nonimmediate_operand")
892 (SI "nonimmediate_operand")
893 (DI "ashldi_input_operand")
894 (TI "reg_or_pm1_operand")])
896 ;; SSE and x87 SFmode and DFmode floating point modes
897 (define_mode_iterator MODEF [SF DF])
899 ;; All x87 floating point modes
900 (define_mode_iterator X87MODEF [SF DF XF])
902 ;; All integer modes handled by x87 fisttp operator.
903 (define_mode_iterator X87MODEI [HI SI DI])
905 ;; All integer modes handled by integer x87 operators.
906 (define_mode_iterator X87MODEI12 [HI SI])
908 ;; All integer modes handled by SSE cvtts?2si* operators.
909 (define_mode_iterator SSEMODEI24 [SI DI])
911 ;; SSE asm suffix for floating point modes
912 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
914 ;; SSE vector mode corresponding to a scalar mode
915 (define_mode_attr ssevecmode
916 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
918 ;; Instruction suffix for REX 64bit operators.
919 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
921 ;; This mode iterator allows :P to be used for patterns that operate on
922 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
923 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
925 ;; Scheduling descriptions
927 (include "pentium.md")
930 (include "athlon.md")
935 ;; Operand and operator predicates and constraints
937 (include "predicates.md")
938 (include "constraints.md")
941 ;; Compare and branch/compare and store instructions.
943 (define_expand "cbranch<mode>4"
944 [(set (reg:CC FLAGS_REG)
945 (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
946 (match_operand:SDWIM 2 "<general_operand>" "")))
947 (set (pc) (if_then_else
948 (match_operator 0 "ordered_comparison_operator"
949 [(reg:CC FLAGS_REG) (const_int 0)])
950 (label_ref (match_operand 3 "" ""))
954 if (MEM_P (operands[1]) && MEM_P (operands[2]))
955 operands[1] = force_reg (<MODE>mode, operands[1]);
956 ix86_expand_branch (GET_CODE (operands[0]),
957 operands[1], operands[2], operands[3]);
961 (define_expand "cstore<mode>4"
962 [(set (reg:CC FLAGS_REG)
963 (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
964 (match_operand:SWIM 3 "<general_operand>" "")))
965 (set (match_operand:QI 0 "register_operand" "")
966 (match_operator 1 "ordered_comparison_operator"
967 [(reg:CC FLAGS_REG) (const_int 0)]))]
970 if (MEM_P (operands[2]) && MEM_P (operands[3]))
971 operands[2] = force_reg (<MODE>mode, operands[2]);
972 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
973 operands[2], operands[3]);
977 (define_expand "cmp<mode>_1"
978 [(set (reg:CC FLAGS_REG)
979 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
980 (match_operand:SWI48 1 "<general_operand>" "")))])
982 (define_insn "*cmp<mode>_ccno_1"
983 [(set (reg FLAGS_REG)
984 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
985 (match_operand:SWI 1 "const0_operand" "")))]
986 "ix86_match_ccmode (insn, CCNOmode)"
988 test{<imodesuffix>}\t%0, %0
989 cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
990 [(set_attr "type" "test,icmp")
991 (set_attr "length_immediate" "0,1")
992 (set_attr "mode" "<MODE>")])
994 (define_insn "*cmp<mode>_1"
995 [(set (reg FLAGS_REG)
996 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
997 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
998 "ix86_match_ccmode (insn, CCmode)"
999 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1000 [(set_attr "type" "icmp")
1001 (set_attr "mode" "<MODE>")])
1003 (define_insn "*cmp<mode>_minus_1"
1004 [(set (reg FLAGS_REG)
1006 (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1007 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
1009 "ix86_match_ccmode (insn, CCGOCmode)"
1010 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1011 [(set_attr "type" "icmp")
1012 (set_attr "mode" "<MODE>")])
1014 (define_insn "*cmpqi_ext_1"
1015 [(set (reg FLAGS_REG)
1017 (match_operand:QI 0 "general_operand" "Qm")
1020 (match_operand 1 "ext_register_operand" "Q")
1022 (const_int 8)) 0)))]
1023 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1024 "cmp{b}\t{%h1, %0|%0, %h1}"
1025 [(set_attr "type" "icmp")
1026 (set_attr "mode" "QI")])
1028 (define_insn "*cmpqi_ext_1_rex64"
1029 [(set (reg FLAGS_REG)
1031 (match_operand:QI 0 "register_operand" "Q")
1034 (match_operand 1 "ext_register_operand" "Q")
1036 (const_int 8)) 0)))]
1037 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1038 "cmp{b}\t{%h1, %0|%0, %h1}"
1039 [(set_attr "type" "icmp")
1040 (set_attr "mode" "QI")])
1042 (define_insn "*cmpqi_ext_2"
1043 [(set (reg FLAGS_REG)
1047 (match_operand 0 "ext_register_operand" "Q")
1050 (match_operand:QI 1 "const0_operand" "")))]
1051 "ix86_match_ccmode (insn, CCNOmode)"
1053 [(set_attr "type" "test")
1054 (set_attr "length_immediate" "0")
1055 (set_attr "mode" "QI")])
1057 (define_expand "cmpqi_ext_3"
1058 [(set (reg:CC FLAGS_REG)
1062 (match_operand 0 "ext_register_operand" "")
1065 (match_operand:QI 1 "immediate_operand" "")))])
1067 (define_insn "*cmpqi_ext_3_insn"
1068 [(set (reg FLAGS_REG)
1072 (match_operand 0 "ext_register_operand" "Q")
1075 (match_operand:QI 1 "general_operand" "Qmn")))]
1076 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1077 "cmp{b}\t{%1, %h0|%h0, %1}"
1078 [(set_attr "type" "icmp")
1079 (set_attr "modrm" "1")
1080 (set_attr "mode" "QI")])
1082 (define_insn "*cmpqi_ext_3_insn_rex64"
1083 [(set (reg FLAGS_REG)
1087 (match_operand 0 "ext_register_operand" "Q")
1090 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1091 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1092 "cmp{b}\t{%1, %h0|%h0, %1}"
1093 [(set_attr "type" "icmp")
1094 (set_attr "modrm" "1")
1095 (set_attr "mode" "QI")])
1097 (define_insn "*cmpqi_ext_4"
1098 [(set (reg FLAGS_REG)
1102 (match_operand 0 "ext_register_operand" "Q")
1107 (match_operand 1 "ext_register_operand" "Q")
1109 (const_int 8)) 0)))]
1110 "ix86_match_ccmode (insn, CCmode)"
1111 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1112 [(set_attr "type" "icmp")
1113 (set_attr "mode" "QI")])
1115 ;; These implement float point compares.
1116 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1117 ;; which would allow mix and match FP modes on the compares. Which is what
1118 ;; the old patterns did, but with many more of them.
1120 (define_expand "cbranchxf4"
1121 [(set (reg:CC FLAGS_REG)
1122 (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1123 (match_operand:XF 2 "nonmemory_operand" "")))
1124 (set (pc) (if_then_else
1125 (match_operator 0 "ix86_fp_comparison_operator"
1128 (label_ref (match_operand 3 "" ""))
1132 ix86_expand_branch (GET_CODE (operands[0]),
1133 operands[1], operands[2], operands[3]);
1137 (define_expand "cstorexf4"
1138 [(set (reg:CC FLAGS_REG)
1139 (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1140 (match_operand:XF 3 "nonmemory_operand" "")))
1141 (set (match_operand:QI 0 "register_operand" "")
1142 (match_operator 1 "ix86_fp_comparison_operator"
1147 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1148 operands[2], operands[3]);
1152 (define_expand "cbranch<mode>4"
1153 [(set (reg:CC FLAGS_REG)
1154 (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1155 (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1156 (set (pc) (if_then_else
1157 (match_operator 0 "ix86_fp_comparison_operator"
1160 (label_ref (match_operand 3 "" ""))
1162 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1164 ix86_expand_branch (GET_CODE (operands[0]),
1165 operands[1], operands[2], operands[3]);
1169 (define_expand "cstore<mode>4"
1170 [(set (reg:CC FLAGS_REG)
1171 (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1172 (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1173 (set (match_operand:QI 0 "register_operand" "")
1174 (match_operator 1 "ix86_fp_comparison_operator"
1177 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1179 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1180 operands[2], operands[3]);
1184 (define_expand "cbranchcc4"
1185 [(set (pc) (if_then_else
1186 (match_operator 0 "comparison_operator"
1187 [(match_operand 1 "flags_reg_operand" "")
1188 (match_operand 2 "const0_operand" "")])
1189 (label_ref (match_operand 3 "" ""))
1193 ix86_expand_branch (GET_CODE (operands[0]),
1194 operands[1], operands[2], operands[3]);
1198 (define_expand "cstorecc4"
1199 [(set (match_operand:QI 0 "register_operand" "")
1200 (match_operator 1 "comparison_operator"
1201 [(match_operand 2 "flags_reg_operand" "")
1202 (match_operand 3 "const0_operand" "")]))]
1205 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1206 operands[2], operands[3]);
1211 ;; FP compares, step 1:
1212 ;; Set the FP condition codes.
1214 ;; CCFPmode compare with exceptions
1215 ;; CCFPUmode compare with no exceptions
1217 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1218 ;; used to manage the reg stack popping would not be preserved.
1220 (define_insn "*cmpfp_0"
1221 [(set (match_operand:HI 0 "register_operand" "=a")
1224 (match_operand 1 "register_operand" "f")
1225 (match_operand 2 "const0_operand" ""))]
1227 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1228 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1229 "* return output_fp_compare (insn, operands, 0, 0);"
1230 [(set_attr "type" "multi")
1231 (set_attr "unit" "i387")
1233 (cond [(match_operand:SF 1 "" "")
1235 (match_operand:DF 1 "" "")
1238 (const_string "XF")))])
1240 (define_insn_and_split "*cmpfp_0_cc"
1241 [(set (reg:CCFP FLAGS_REG)
1243 (match_operand 1 "register_operand" "f")
1244 (match_operand 2 "const0_operand" "")))
1245 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1246 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1247 && TARGET_SAHF && !TARGET_CMOVE
1248 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1250 "&& reload_completed"
1253 [(compare:CCFP (match_dup 1)(match_dup 2))]
1255 (set (reg:CC FLAGS_REG)
1256 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1258 [(set_attr "type" "multi")
1259 (set_attr "unit" "i387")
1261 (cond [(match_operand:SF 1 "" "")
1263 (match_operand:DF 1 "" "")
1266 (const_string "XF")))])
1268 (define_insn "*cmpfp_xf"
1269 [(set (match_operand:HI 0 "register_operand" "=a")
1272 (match_operand:XF 1 "register_operand" "f")
1273 (match_operand:XF 2 "register_operand" "f"))]
1276 "* return output_fp_compare (insn, operands, 0, 0);"
1277 [(set_attr "type" "multi")
1278 (set_attr "unit" "i387")
1279 (set_attr "mode" "XF")])
1281 (define_insn_and_split "*cmpfp_xf_cc"
1282 [(set (reg:CCFP FLAGS_REG)
1284 (match_operand:XF 1 "register_operand" "f")
1285 (match_operand:XF 2 "register_operand" "f")))
1286 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1288 && TARGET_SAHF && !TARGET_CMOVE"
1290 "&& reload_completed"
1293 [(compare:CCFP (match_dup 1)(match_dup 2))]
1295 (set (reg:CC FLAGS_REG)
1296 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1298 [(set_attr "type" "multi")
1299 (set_attr "unit" "i387")
1300 (set_attr "mode" "XF")])
1302 (define_insn "*cmpfp_<mode>"
1303 [(set (match_operand:HI 0 "register_operand" "=a")
1306 (match_operand:MODEF 1 "register_operand" "f")
1307 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1310 "* return output_fp_compare (insn, operands, 0, 0);"
1311 [(set_attr "type" "multi")
1312 (set_attr "unit" "i387")
1313 (set_attr "mode" "<MODE>")])
1315 (define_insn_and_split "*cmpfp_<mode>_cc"
1316 [(set (reg:CCFP FLAGS_REG)
1318 (match_operand:MODEF 1 "register_operand" "f")
1319 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1320 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1322 && TARGET_SAHF && !TARGET_CMOVE"
1324 "&& reload_completed"
1327 [(compare:CCFP (match_dup 1)(match_dup 2))]
1329 (set (reg:CC FLAGS_REG)
1330 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1332 [(set_attr "type" "multi")
1333 (set_attr "unit" "i387")
1334 (set_attr "mode" "<MODE>")])
1336 (define_insn "*cmpfp_u"
1337 [(set (match_operand:HI 0 "register_operand" "=a")
1340 (match_operand 1 "register_operand" "f")
1341 (match_operand 2 "register_operand" "f"))]
1343 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1344 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1345 "* return output_fp_compare (insn, operands, 0, 1);"
1346 [(set_attr "type" "multi")
1347 (set_attr "unit" "i387")
1349 (cond [(match_operand:SF 1 "" "")
1351 (match_operand:DF 1 "" "")
1354 (const_string "XF")))])
1356 (define_insn_and_split "*cmpfp_u_cc"
1357 [(set (reg:CCFPU FLAGS_REG)
1359 (match_operand 1 "register_operand" "f")
1360 (match_operand 2 "register_operand" "f")))
1361 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1362 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1363 && TARGET_SAHF && !TARGET_CMOVE
1364 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1366 "&& reload_completed"
1369 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1371 (set (reg:CC FLAGS_REG)
1372 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1374 [(set_attr "type" "multi")
1375 (set_attr "unit" "i387")
1377 (cond [(match_operand:SF 1 "" "")
1379 (match_operand:DF 1 "" "")
1382 (const_string "XF")))])
1384 (define_insn "*cmpfp_<mode>"
1385 [(set (match_operand:HI 0 "register_operand" "=a")
1388 (match_operand 1 "register_operand" "f")
1389 (match_operator 3 "float_operator"
1390 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1392 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1393 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1394 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1395 "* return output_fp_compare (insn, operands, 0, 0);"
1396 [(set_attr "type" "multi")
1397 (set_attr "unit" "i387")
1398 (set_attr "fp_int_src" "true")
1399 (set_attr "mode" "<MODE>")])
1401 (define_insn_and_split "*cmpfp_<mode>_cc"
1402 [(set (reg:CCFP FLAGS_REG)
1404 (match_operand 1 "register_operand" "f")
1405 (match_operator 3 "float_operator"
1406 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1407 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1408 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1409 && TARGET_SAHF && !TARGET_CMOVE
1410 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1411 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1413 "&& reload_completed"
1418 (match_op_dup 3 [(match_dup 2)]))]
1420 (set (reg:CC FLAGS_REG)
1421 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1423 [(set_attr "type" "multi")
1424 (set_attr "unit" "i387")
1425 (set_attr "fp_int_src" "true")
1426 (set_attr "mode" "<MODE>")])
1428 ;; FP compares, step 2
1429 ;; Move the fpsw to ax.
1431 (define_insn "x86_fnstsw_1"
1432 [(set (match_operand:HI 0 "register_operand" "=a")
1433 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1436 [(set (attr "length") (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1437 (set_attr "mode" "SI")
1438 (set_attr "unit" "i387")])
1440 ;; FP compares, step 3
1441 ;; Get ax into flags, general case.
1443 (define_insn "x86_sahf_1"
1444 [(set (reg:CC FLAGS_REG)
1445 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1449 #ifndef HAVE_AS_IX86_SAHF
1451 return ASM_BYTE "0x9e";
1456 [(set_attr "length" "1")
1457 (set_attr "athlon_decode" "vector")
1458 (set_attr "amdfam10_decode" "direct")
1459 (set_attr "mode" "SI")])
1461 ;; Pentium Pro can do steps 1 through 3 in one go.
1462 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1463 (define_insn "*cmpfp_i_mixed"
1464 [(set (reg:CCFP FLAGS_REG)
1465 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1466 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1467 "TARGET_MIX_SSE_I387
1468 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1469 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1470 "* return output_fp_compare (insn, operands, 1, 0);"
1471 [(set_attr "type" "fcmp,ssecomi")
1472 (set_attr "prefix" "orig,maybe_vex")
1474 (if_then_else (match_operand:SF 1 "" "")
1476 (const_string "DF")))
1477 (set (attr "prefix_rep")
1478 (if_then_else (eq_attr "type" "ssecomi")
1480 (const_string "*")))
1481 (set (attr "prefix_data16")
1482 (cond [(eq_attr "type" "fcmp")
1484 (eq_attr "mode" "DF")
1487 (const_string "0")))
1488 (set_attr "athlon_decode" "vector")
1489 (set_attr "amdfam10_decode" "direct")])
1491 (define_insn "*cmpfp_i_sse"
1492 [(set (reg:CCFP FLAGS_REG)
1493 (compare:CCFP (match_operand 0 "register_operand" "x")
1494 (match_operand 1 "nonimmediate_operand" "xm")))]
1496 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1497 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1498 "* return output_fp_compare (insn, operands, 1, 0);"
1499 [(set_attr "type" "ssecomi")
1500 (set_attr "prefix" "maybe_vex")
1502 (if_then_else (match_operand:SF 1 "" "")
1504 (const_string "DF")))
1505 (set_attr "prefix_rep" "0")
1506 (set (attr "prefix_data16")
1507 (if_then_else (eq_attr "mode" "DF")
1509 (const_string "0")))
1510 (set_attr "athlon_decode" "vector")
1511 (set_attr "amdfam10_decode" "direct")])
1513 (define_insn "*cmpfp_i_i387"
1514 [(set (reg:CCFP FLAGS_REG)
1515 (compare:CCFP (match_operand 0 "register_operand" "f")
1516 (match_operand 1 "register_operand" "f")))]
1517 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1519 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1520 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1521 "* return output_fp_compare (insn, operands, 1, 0);"
1522 [(set_attr "type" "fcmp")
1524 (cond [(match_operand:SF 1 "" "")
1526 (match_operand:DF 1 "" "")
1529 (const_string "XF")))
1530 (set_attr "athlon_decode" "vector")
1531 (set_attr "amdfam10_decode" "direct")])
1533 (define_insn "*cmpfp_iu_mixed"
1534 [(set (reg:CCFPU FLAGS_REG)
1535 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1536 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1537 "TARGET_MIX_SSE_I387
1538 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1539 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1540 "* return output_fp_compare (insn, operands, 1, 1);"
1541 [(set_attr "type" "fcmp,ssecomi")
1542 (set_attr "prefix" "orig,maybe_vex")
1544 (if_then_else (match_operand:SF 1 "" "")
1546 (const_string "DF")))
1547 (set (attr "prefix_rep")
1548 (if_then_else (eq_attr "type" "ssecomi")
1550 (const_string "*")))
1551 (set (attr "prefix_data16")
1552 (cond [(eq_attr "type" "fcmp")
1554 (eq_attr "mode" "DF")
1557 (const_string "0")))
1558 (set_attr "athlon_decode" "vector")
1559 (set_attr "amdfam10_decode" "direct")])
1561 (define_insn "*cmpfp_iu_sse"
1562 [(set (reg:CCFPU FLAGS_REG)
1563 (compare:CCFPU (match_operand 0 "register_operand" "x")
1564 (match_operand 1 "nonimmediate_operand" "xm")))]
1566 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1567 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1568 "* return output_fp_compare (insn, operands, 1, 1);"
1569 [(set_attr "type" "ssecomi")
1570 (set_attr "prefix" "maybe_vex")
1572 (if_then_else (match_operand:SF 1 "" "")
1574 (const_string "DF")))
1575 (set_attr "prefix_rep" "0")
1576 (set (attr "prefix_data16")
1577 (if_then_else (eq_attr "mode" "DF")
1579 (const_string "0")))
1580 (set_attr "athlon_decode" "vector")
1581 (set_attr "amdfam10_decode" "direct")])
1583 (define_insn "*cmpfp_iu_387"
1584 [(set (reg:CCFPU FLAGS_REG)
1585 (compare:CCFPU (match_operand 0 "register_operand" "f")
1586 (match_operand 1 "register_operand" "f")))]
1587 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1589 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1590 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1591 "* return output_fp_compare (insn, operands, 1, 1);"
1592 [(set_attr "type" "fcmp")
1594 (cond [(match_operand:SF 1 "" "")
1596 (match_operand:DF 1 "" "")
1599 (const_string "XF")))
1600 (set_attr "athlon_decode" "vector")
1601 (set_attr "amdfam10_decode" "direct")])
1603 ;; Push/pop instructions.
1605 (define_insn "*pushdi2_rex64"
1606 [(set (match_operand:DI 0 "push_operand" "=<,!<")
1607 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
1612 [(set_attr "type" "push,multi")
1613 (set_attr "mode" "DI")])
1615 ;; Convert impossible pushes of immediate to existing instructions.
1616 ;; First try to get scratch register and go through it. In case this
1617 ;; fails, push sign extended lower part first and then overwrite
1618 ;; upper part by 32bit move.
1620 [(match_scratch:DI 2 "r")
1621 (set (match_operand:DI 0 "push_operand" "")
1622 (match_operand:DI 1 "immediate_operand" ""))]
1623 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1624 && !x86_64_immediate_operand (operands[1], DImode)"
1625 [(set (match_dup 2) (match_dup 1))
1626 (set (match_dup 0) (match_dup 2))])
1628 ;; We need to define this as both peepholer and splitter for case
1629 ;; peephole2 pass is not run.
1630 ;; "&& 1" is needed to keep it from matching the previous pattern.
1632 [(set (match_operand:DI 0 "push_operand" "")
1633 (match_operand:DI 1 "immediate_operand" ""))]
1634 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1635 && !x86_64_immediate_operand (operands[1], DImode) && 1"
1636 [(set (match_dup 0) (match_dup 1))
1637 (set (match_dup 2) (match_dup 3))]
1639 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1641 operands[1] = gen_lowpart (DImode, operands[2]);
1642 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1647 [(set (match_operand:DI 0 "push_operand" "")
1648 (match_operand:DI 1 "immediate_operand" ""))]
1649 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
1650 ? epilogue_completed : reload_completed)
1651 && !symbolic_operand (operands[1], DImode)
1652 && !x86_64_immediate_operand (operands[1], DImode)"
1653 [(set (match_dup 0) (match_dup 1))
1654 (set (match_dup 2) (match_dup 3))]
1656 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1658 operands[1] = gen_lowpart (DImode, operands[2]);
1659 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1663 (define_insn "*pushdi2"
1664 [(set (match_operand:DI 0 "push_operand" "=<")
1665 (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
1670 [(set (match_operand:DI 0 "push_operand" "")
1671 (match_operand:DI 1 "general_operand" ""))]
1672 "!TARGET_64BIT && reload_completed
1673 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
1675 "ix86_split_long_move (operands); DONE;")
1677 (define_insn "*pushsi2"
1678 [(set (match_operand:SI 0 "push_operand" "=<")
1679 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1682 [(set_attr "type" "push")
1683 (set_attr "mode" "SI")])
1685 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1686 ;; "push a byte/word". But actually we use pushl, which has the effect
1687 ;; of rounding the amount pushed up to a word.
1689 ;; For TARGET_64BIT we always round up to 8 bytes.
1690 (define_insn "*push<mode>2_rex64"
1691 [(set (match_operand:SWI124 0 "push_operand" "=X")
1692 (match_operand:SWI124 1 "nonmemory_no_elim_operand" "r<i>"))]
1695 [(set_attr "type" "push")
1696 (set_attr "mode" "DI")])
1698 (define_insn "*push<mode>2"
1699 [(set (match_operand:SWI12 0 "push_operand" "=X")
1700 (match_operand:SWI12 1 "nonmemory_no_elim_operand" "rn"))]
1703 [(set_attr "type" "push")
1704 (set_attr "mode" "SI")])
1706 (define_insn "*push<mode>2_prologue"
1707 [(set (match_operand:P 0 "push_operand" "=<")
1708 (match_operand:P 1 "general_no_elim_operand" "r<i>*m"))
1709 (clobber (mem:BLK (scratch)))]
1711 "push{<imodesuffix>}\t%1"
1712 [(set_attr "type" "push")
1713 (set_attr "mode" "<MODE>")])
1715 (define_insn "*pop<mode>1"
1716 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1717 (match_operand:P 1 "pop_operand" ">"))]
1719 "pop{<imodesuffix>}\t%0"
1720 [(set_attr "type" "pop")
1721 (set_attr "mode" "<MODE>")])
1723 (define_insn "*pop<mode>1_epilogue"
1724 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1725 (match_operand:P 1 "pop_operand" ">"))
1726 (clobber (mem:BLK (scratch)))]
1728 "pop{<imodesuffix>}\t%0"
1729 [(set_attr "type" "pop")
1730 (set_attr "mode" "<MODE>")])
1732 ;; Move instructions.
1734 (define_expand "movoi"
1735 [(set (match_operand:OI 0 "nonimmediate_operand" "")
1736 (match_operand:OI 1 "general_operand" ""))]
1738 "ix86_expand_move (OImode, operands); DONE;")
1740 (define_expand "movti"
1741 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1742 (match_operand:TI 1 "nonimmediate_operand" ""))]
1743 "TARGET_64BIT || TARGET_SSE"
1746 ix86_expand_move (TImode, operands);
1747 else if (push_operand (operands[0], TImode))
1748 ix86_expand_push (TImode, operands[1]);
1750 ix86_expand_vector_move (TImode, operands);
1754 ;; This expands to what emit_move_complex would generate if we didn't
1755 ;; have a movti pattern. Having this avoids problems with reload on
1756 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
1757 ;; to have around all the time.
1758 (define_expand "movcdi"
1759 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
1760 (match_operand:CDI 1 "general_operand" ""))]
1763 if (push_operand (operands[0], CDImode))
1764 emit_move_complex_push (CDImode, operands[0], operands[1]);
1766 emit_move_complex_parts (operands[0], operands[1]);
1770 (define_expand "mov<mode>"
1771 [(set (match_operand:SWI1248x 0 "nonimmediate_operand" "")
1772 (match_operand:SWI1248x 1 "general_operand" ""))]
1774 "ix86_expand_move (<MODE>mode, operands); DONE;")
1776 (define_insn "*mov<mode>_xor"
1777 [(set (match_operand:SWI48 0 "register_operand" "=r")
1778 (match_operand:SWI48 1 "const0_operand" ""))
1779 (clobber (reg:CC FLAGS_REG))]
1782 [(set_attr "type" "alu1")
1783 (set_attr "mode" "SI")
1784 (set_attr "length_immediate" "0")])
1786 (define_insn "*mov<mode>_or"
1787 [(set (match_operand:SWI48 0 "register_operand" "=r")
1788 (match_operand:SWI48 1 "const_int_operand" ""))
1789 (clobber (reg:CC FLAGS_REG))]
1791 && operands[1] == constm1_rtx"
1792 "or{<imodesuffix>}\t{%1, %0|%0, %1}"
1793 [(set_attr "type" "alu1")
1794 (set_attr "mode" "<MODE>")
1795 (set_attr "length_immediate" "1")])
1797 (define_insn "*movoi_internal_avx"
1798 [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
1799 (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
1800 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1802 switch (which_alternative)
1805 return "vxorps\t%0, %0, %0";
1808 if (misaligned_operand (operands[0], OImode)
1809 || misaligned_operand (operands[1], OImode))
1810 return "vmovdqu\t{%1, %0|%0, %1}";
1812 return "vmovdqa\t{%1, %0|%0, %1}";
1817 [(set_attr "type" "sselog1,ssemov,ssemov")
1818 (set_attr "prefix" "vex")
1819 (set_attr "mode" "OI")])
1821 (define_insn "*movti_internal_rex64"
1822 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
1823 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
1824 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1826 switch (which_alternative)
1832 if (get_attr_mode (insn) == MODE_V4SF)
1833 return "%vxorps\t%0, %d0";
1835 return "%vpxor\t%0, %d0";
1838 /* TDmode values are passed as TImode on the stack. Moving them
1839 to stack may result in unaligned memory access. */
1840 if (misaligned_operand (operands[0], TImode)
1841 || misaligned_operand (operands[1], TImode))
1843 if (get_attr_mode (insn) == MODE_V4SF)
1844 return "%vmovups\t{%1, %0|%0, %1}";
1846 return "%vmovdqu\t{%1, %0|%0, %1}";
1850 if (get_attr_mode (insn) == MODE_V4SF)
1851 return "%vmovaps\t{%1, %0|%0, %1}";
1853 return "%vmovdqa\t{%1, %0|%0, %1}";
1859 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
1860 (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
1862 (cond [(eq_attr "alternative" "2,3")
1864 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1866 (const_string "V4SF")
1867 (const_string "TI"))
1868 (eq_attr "alternative" "4")
1870 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1872 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1874 (const_string "V4SF")
1875 (const_string "TI"))]
1876 (const_string "DI")))])
1879 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1880 (match_operand:TI 1 "general_operand" ""))]
1882 && !SSE_REG_P (operands[0]) && !SSE_REG_P (operands[1])"
1884 "ix86_split_long_move (operands); DONE;")
1886 (define_insn "*movti_internal_sse"
1887 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
1888 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
1889 "TARGET_SSE && !TARGET_64BIT
1890 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1892 switch (which_alternative)
1895 if (get_attr_mode (insn) == MODE_V4SF)
1896 return "%vxorps\t%0, %d0";
1898 return "%vpxor\t%0, %d0";
1901 /* TDmode values are passed as TImode on the stack. Moving them
1902 to stack may result in unaligned memory access. */
1903 if (misaligned_operand (operands[0], TImode)
1904 || misaligned_operand (operands[1], TImode))
1906 if (get_attr_mode (insn) == MODE_V4SF)
1907 return "%vmovups\t{%1, %0|%0, %1}";
1909 return "%vmovdqu\t{%1, %0|%0, %1}";
1913 if (get_attr_mode (insn) == MODE_V4SF)
1914 return "%vmovaps\t{%1, %0|%0, %1}";
1916 return "%vmovdqa\t{%1, %0|%0, %1}";
1922 [(set_attr "type" "sselog1,ssemov,ssemov")
1923 (set_attr "prefix" "maybe_vex")
1925 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1926 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1928 (const_string "V4SF")
1929 (and (eq_attr "alternative" "2")
1930 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1932 (const_string "V4SF")]
1933 (const_string "TI")))])
1935 (define_insn "*movdi_internal_rex64"
1936 [(set (match_operand:DI 0 "nonimmediate_operand"
1937 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
1938 (match_operand:DI 1 "general_operand"
1939 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
1940 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1942 switch (get_attr_type (insn))
1945 if (SSE_REG_P (operands[0]))
1946 return "movq2dq\t{%1, %0|%0, %1}";
1948 return "movdq2q\t{%1, %0|%0, %1}";
1953 if (get_attr_mode (insn) == MODE_TI)
1954 return "vmovdqa\t{%1, %0|%0, %1}";
1956 return "vmovq\t{%1, %0|%0, %1}";
1959 if (get_attr_mode (insn) == MODE_TI)
1960 return "movdqa\t{%1, %0|%0, %1}";
1964 /* Moves from and into integer register is done using movd
1965 opcode with REX prefix. */
1966 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
1967 return "movd\t{%1, %0|%0, %1}";
1968 return "movq\t{%1, %0|%0, %1}";
1971 return "%vpxor\t%0, %d0";
1974 return "pxor\t%0, %0";
1980 return "lea{q}\t{%a1, %0|%0, %a1}";
1983 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
1984 if (get_attr_mode (insn) == MODE_SI)
1985 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1986 else if (which_alternative == 2)
1987 return "movabs{q}\t{%1, %0|%0, %1}";
1989 return "mov{q}\t{%1, %0|%0, %1}";
1993 (cond [(eq_attr "alternative" "5")
1994 (const_string "mmx")
1995 (eq_attr "alternative" "6,7,8,9,10")
1996 (const_string "mmxmov")
1997 (eq_attr "alternative" "11")
1998 (const_string "sselog1")
1999 (eq_attr "alternative" "12,13,14,15,16")
2000 (const_string "ssemov")
2001 (eq_attr "alternative" "17,18")
2002 (const_string "ssecvt")
2003 (eq_attr "alternative" "4")
2004 (const_string "multi")
2005 (match_operand:DI 1 "pic_32bit_operand" "")
2006 (const_string "lea")
2008 (const_string "imov")))
2011 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2013 (const_string "*")))
2014 (set (attr "length_immediate")
2016 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2018 (const_string "*")))
2019 (set_attr "prefix_rex" "*,*,*,*,*,*,*,1,*,1,*,*,*,*,*,*,*,*,*")
2020 (set_attr "prefix_data16" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,1,*,*,*")
2021 (set (attr "prefix")
2022 (if_then_else (eq_attr "alternative" "11,12,13,14,15,16")
2023 (const_string "maybe_vex")
2024 (const_string "orig")))
2025 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2027 ;; Convert impossible stores of immediate to existing instructions.
2028 ;; First try to get scratch register and go through it. In case this
2029 ;; fails, move by 32bit parts.
2031 [(match_scratch:DI 2 "r")
2032 (set (match_operand:DI 0 "memory_operand" "")
2033 (match_operand:DI 1 "immediate_operand" ""))]
2034 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2035 && !x86_64_immediate_operand (operands[1], DImode)"
2036 [(set (match_dup 2) (match_dup 1))
2037 (set (match_dup 0) (match_dup 2))])
2039 ;; We need to define this as both peepholer and splitter for case
2040 ;; peephole2 pass is not run.
2041 ;; "&& 1" is needed to keep it from matching the previous pattern.
2043 [(set (match_operand:DI 0 "memory_operand" "")
2044 (match_operand:DI 1 "immediate_operand" ""))]
2045 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2046 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2047 [(set (match_dup 2) (match_dup 3))
2048 (set (match_dup 4) (match_dup 5))]
2049 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2052 [(set (match_operand:DI 0 "memory_operand" "")
2053 (match_operand:DI 1 "immediate_operand" ""))]
2054 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2055 ? epilogue_completed : reload_completed)
2056 && !symbolic_operand (operands[1], DImode)
2057 && !x86_64_immediate_operand (operands[1], DImode)"
2058 [(set (match_dup 2) (match_dup 3))
2059 (set (match_dup 4) (match_dup 5))]
2060 "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2062 (define_insn "*movdi_internal"
2063 [(set (match_operand:DI 0 "nonimmediate_operand"
2064 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2065 (match_operand:DI 1 "general_operand"
2066 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2067 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2072 movq\t{%1, %0|%0, %1}
2073 movq\t{%1, %0|%0, %1}
2075 %vmovq\t{%1, %0|%0, %1}
2076 %vmovdqa\t{%1, %0|%0, %1}
2077 %vmovq\t{%1, %0|%0, %1}
2079 movlps\t{%1, %0|%0, %1}
2080 movaps\t{%1, %0|%0, %1}
2081 movlps\t{%1, %0|%0, %1}"
2082 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2083 (set (attr "prefix")
2084 (if_then_else (eq_attr "alternative" "5,6,7,8")
2085 (const_string "vex")
2086 (const_string "orig")))
2087 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2090 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2091 (match_operand:DI 1 "general_operand" ""))]
2092 "!TARGET_64BIT && reload_completed
2093 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))
2094 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
2096 "ix86_split_long_move (operands); DONE;")
2098 (define_insn "*movsi_internal"
2099 [(set (match_operand:SI 0 "nonimmediate_operand"
2100 "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
2101 (match_operand:SI 1 "general_operand"
2102 "g ,ri,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
2103 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2105 switch (get_attr_type (insn))
2108 if (get_attr_mode (insn) == MODE_TI)
2109 return "%vpxor\t%0, %d0";
2110 return "%vxorps\t%0, %d0";
2113 switch (get_attr_mode (insn))
2116 return "%vmovdqa\t{%1, %0|%0, %1}";
2118 return "%vmovaps\t{%1, %0|%0, %1}";
2120 return "%vmovd\t{%1, %0|%0, %1}";
2122 return "%vmovss\t{%1, %0|%0, %1}";
2128 return "pxor\t%0, %0";
2131 if (get_attr_mode (insn) == MODE_DI)
2132 return "movq\t{%1, %0|%0, %1}";
2133 return "movd\t{%1, %0|%0, %1}";
2136 return "lea{l}\t{%a1, %0|%0, %a1}";
2139 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2140 return "mov{l}\t{%1, %0|%0, %1}";
2144 (cond [(eq_attr "alternative" "2")
2145 (const_string "mmx")
2146 (eq_attr "alternative" "3,4,5")
2147 (const_string "mmxmov")
2148 (eq_attr "alternative" "6")
2149 (const_string "sselog1")
2150 (eq_attr "alternative" "7,8,9,10,11")
2151 (const_string "ssemov")
2152 (match_operand:DI 1 "pic_32bit_operand" "")
2153 (const_string "lea")
2155 (const_string "imov")))
2156 (set (attr "prefix")
2157 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
2158 (const_string "orig")
2159 (const_string "maybe_vex")))
2160 (set (attr "prefix_data16")
2161 (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
2163 (const_string "*")))
2165 (cond [(eq_attr "alternative" "2,3")
2167 (eq_attr "alternative" "6,7")
2169 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2170 (const_string "V4SF")
2171 (const_string "TI"))
2172 (and (eq_attr "alternative" "8,9,10,11")
2173 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
2176 (const_string "SI")))])
2178 (define_insn "*movhi_internal"
2179 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
2180 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
2181 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2183 switch (get_attr_type (insn))
2186 /* movzwl is faster than movw on p2 due to partial word stalls,
2187 though not as fast as an aligned movl. */
2188 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
2190 if (get_attr_mode (insn) == MODE_SI)
2191 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2193 return "mov{w}\t{%1, %0|%0, %1}";
2197 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
2199 (const_string "imov")
2200 (and (eq_attr "alternative" "0")
2201 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2203 (eq (symbol_ref "TARGET_HIMODE_MATH")
2205 (const_string "imov")
2206 (and (eq_attr "alternative" "1,2")
2207 (match_operand:HI 1 "aligned_operand" ""))
2208 (const_string "imov")
2209 (and (ne (symbol_ref "TARGET_MOVX")
2211 (eq_attr "alternative" "0,2"))
2212 (const_string "imovx")
2214 (const_string "imov")))
2216 (cond [(eq_attr "type" "imovx")
2218 (and (eq_attr "alternative" "1,2")
2219 (match_operand:HI 1 "aligned_operand" ""))
2221 (and (eq_attr "alternative" "0")
2222 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2224 (eq (symbol_ref "TARGET_HIMODE_MATH")
2228 (const_string "HI")))])
2230 ;; Situation is quite tricky about when to choose full sized (SImode) move
2231 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
2232 ;; partial register dependency machines (such as AMD Athlon), where QImode
2233 ;; moves issue extra dependency and for partial register stalls machines
2234 ;; that don't use QImode patterns (and QImode move cause stall on the next
2237 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2238 ;; register stall machines with, where we use QImode instructions, since
2239 ;; partial register stall can be caused there. Then we use movzx.
2240 (define_insn "*movqi_internal"
2241 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2242 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
2243 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2245 switch (get_attr_type (insn))
2248 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2249 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2251 if (get_attr_mode (insn) == MODE_SI)
2252 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2254 return "mov{b}\t{%1, %0|%0, %1}";
2258 (cond [(and (eq_attr "alternative" "5")
2259 (not (match_operand:QI 1 "aligned_operand" "")))
2260 (const_string "imovx")
2261 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2263 (const_string "imov")
2264 (and (eq_attr "alternative" "3")
2265 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2267 (eq (symbol_ref "TARGET_QIMODE_MATH")
2269 (const_string "imov")
2270 (eq_attr "alternative" "3,5")
2271 (const_string "imovx")
2272 (and (ne (symbol_ref "TARGET_MOVX")
2274 (eq_attr "alternative" "2"))
2275 (const_string "imovx")
2277 (const_string "imov")))
2279 (cond [(eq_attr "alternative" "3,4,5")
2281 (eq_attr "alternative" "6")
2283 (eq_attr "type" "imovx")
2285 (and (eq_attr "type" "imov")
2286 (and (eq_attr "alternative" "0,1")
2287 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2289 (and (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2291 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2294 ;; Avoid partial register stalls when not using QImode arithmetic
2295 (and (eq_attr "type" "imov")
2296 (and (eq_attr "alternative" "0,1")
2297 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2299 (eq (symbol_ref "TARGET_QIMODE_MATH")
2303 (const_string "QI")))])
2305 ;; Stores and loads of ax to arbitrary constant address.
2306 ;; We fake an second form of instruction to force reload to load address
2307 ;; into register when rax is not available
2308 (define_insn "*movabs<mode>_1"
2309 [(set (mem:SWI1248x (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2310 (match_operand:SWI1248x 1 "nonmemory_operand" "a,er"))]
2311 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2313 movabs{<imodesuffix>}\t{%1, %P0|%P0, %1}
2314 mov{<imodesuffix>}\t{%1, %a0|%a0, %1}"
2315 [(set_attr "type" "imov")
2316 (set_attr "modrm" "0,*")
2317 (set_attr "length_address" "8,0")
2318 (set_attr "length_immediate" "0,*")
2319 (set_attr "memory" "store")
2320 (set_attr "mode" "<MODE>")])
2322 (define_insn "*movabs<mode>_2"
2323 [(set (match_operand:SWI1248x 0 "register_operand" "=a,r")
2324 (mem:SWI1248x (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2325 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2327 movabs{<imodesuffix>}\t{%P1, %0|%0, %P1}
2328 mov{<imodesuffix>}\t{%a1, %0|%0, %a1}"
2329 [(set_attr "type" "imov")
2330 (set_attr "modrm" "0,*")
2331 (set_attr "length_address" "8,0")
2332 (set_attr "length_immediate" "0")
2333 (set_attr "memory" "load")
2334 (set_attr "mode" "<MODE>")])
2336 (define_insn "*swap<mode>"
2337 [(set (match_operand:SWI48 0 "register_operand" "+r")
2338 (match_operand:SWI48 1 "register_operand" "+r"))
2342 "xchg{<imodesuffix>}\t%1, %0"
2343 [(set_attr "type" "imov")
2344 (set_attr "mode" "<MODE>")
2345 (set_attr "pent_pair" "np")
2346 (set_attr "athlon_decode" "vector")
2347 (set_attr "amdfam10_decode" "double")])
2349 (define_insn "*swap<mode>_1"
2350 [(set (match_operand:SWI12 0 "register_operand" "+r")
2351 (match_operand:SWI12 1 "register_operand" "+r"))
2354 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2356 [(set_attr "type" "imov")
2357 (set_attr "mode" "SI")
2358 (set_attr "pent_pair" "np")
2359 (set_attr "athlon_decode" "vector")
2360 (set_attr "amdfam10_decode" "double")])
2362 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL
2363 ;; is disabled for AMDFAM10
2364 (define_insn "*swap<mode>_2"
2365 [(set (match_operand:SWI12 0 "register_operand" "+<r>")
2366 (match_operand:SWI12 1 "register_operand" "+<r>"))
2369 "TARGET_PARTIAL_REG_STALL"
2370 "xchg{<imodesuffix>}\t%1, %0"
2371 [(set_attr "type" "imov")
2372 (set_attr "mode" "<MODE>")
2373 (set_attr "pent_pair" "np")
2374 (set_attr "athlon_decode" "vector")])
2376 (define_expand "movstrict<mode>"
2377 [(set (strict_low_part (match_operand:SWI12 0 "nonimmediate_operand" ""))
2378 (match_operand:SWI12 1 "general_operand" ""))]
2381 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2383 /* Don't generate memory->memory moves, go through a register */
2384 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2385 operands[1] = force_reg (<MODE>mode, operands[1]);
2388 (define_insn "*movstrict<mode>_1"
2389 [(set (strict_low_part
2390 (match_operand:SWI12 0 "nonimmediate_operand" "+<r>m,<r>"))
2391 (match_operand:SWI12 1 "general_operand" "<r>n,m"))]
2392 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2393 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2394 "mov{<imodesuffix>}\t{%1, %0|%0, %1}"
2395 [(set_attr "type" "imov")
2396 (set_attr "mode" "<MODE>")])
2398 (define_insn "*movstrict<mode>_xor"
2399 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
2400 (match_operand:SWI12 1 "const0_operand" ""))
2401 (clobber (reg:CC FLAGS_REG))]
2403 "xor{<imodesuffix>}\t%0, %0"
2404 [(set_attr "type" "alu1")
2405 (set_attr "mode" "<MODE>")
2406 (set_attr "length_immediate" "0")])
2408 (define_insn "*mov<mode>_extv_1"
2409 [(set (match_operand:SWI24 0 "register_operand" "=R")
2410 (sign_extract:SWI24 (match_operand 1 "ext_register_operand" "Q")
2414 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2415 [(set_attr "type" "imovx")
2416 (set_attr "mode" "SI")])
2418 (define_insn "*movqi_extv_1_rex64"
2419 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2420 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2425 switch (get_attr_type (insn))
2428 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2430 return "mov{b}\t{%h1, %0|%0, %h1}";
2434 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2435 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2436 (ne (symbol_ref "TARGET_MOVX")
2438 (const_string "imovx")
2439 (const_string "imov")))
2441 (if_then_else (eq_attr "type" "imovx")
2443 (const_string "QI")))])
2445 (define_insn "*movqi_extv_1"
2446 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2447 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2452 switch (get_attr_type (insn))
2455 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2457 return "mov{b}\t{%h1, %0|%0, %h1}";
2461 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2462 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2463 (ne (symbol_ref "TARGET_MOVX")
2465 (const_string "imovx")
2466 (const_string "imov")))
2468 (if_then_else (eq_attr "type" "imovx")
2470 (const_string "QI")))])
2472 (define_insn "*mov<mode>_extzv_1"
2473 [(set (match_operand:SWI48 0 "register_operand" "=R")
2474 (zero_extract:SWI48 (match_operand 1 "ext_register_operand" "Q")
2478 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2479 [(set_attr "type" "imovx")
2480 (set_attr "mode" "SI")])
2482 (define_insn "*movqi_extzv_2_rex64"
2483 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2485 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2490 switch (get_attr_type (insn))
2493 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2495 return "mov{b}\t{%h1, %0|%0, %h1}";
2499 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2500 (ne (symbol_ref "TARGET_MOVX")
2502 (const_string "imovx")
2503 (const_string "imov")))
2505 (if_then_else (eq_attr "type" "imovx")
2507 (const_string "QI")))])
2509 (define_insn "*movqi_extzv_2"
2510 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2512 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2517 switch (get_attr_type (insn))
2520 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2522 return "mov{b}\t{%h1, %0|%0, %h1}";
2526 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2527 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2528 (ne (symbol_ref "TARGET_MOVX")
2530 (const_string "imovx")
2531 (const_string "imov")))
2533 (if_then_else (eq_attr "type" "imovx")
2535 (const_string "QI")))])
2537 (define_expand "mov<mode>_insv_1"
2538 [(set (zero_extract:SWI48 (match_operand 0 "ext_register_operand" "")
2541 (match_operand:SWI48 1 "nonmemory_operand" ""))])
2543 (define_insn "*mov<mode>_insv_1_rex64"
2544 [(set (zero_extract:SWI48x (match_operand 0 "ext_register_operand" "+Q")
2547 (match_operand:SWI48x 1 "nonmemory_operand" "Qn"))]
2549 "mov{b}\t{%b1, %h0|%h0, %b1}"
2550 [(set_attr "type" "imov")
2551 (set_attr "mode" "QI")])
2553 (define_insn "*movsi_insv_1"
2554 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2557 (match_operand:SI 1 "general_operand" "Qmn"))]
2559 "mov{b}\t{%b1, %h0|%h0, %b1}"
2560 [(set_attr "type" "imov")
2561 (set_attr "mode" "QI")])
2563 (define_insn "*movqi_insv_2"
2564 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2567 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2570 "mov{b}\t{%h1, %h0|%h0, %h1}"
2571 [(set_attr "type" "imov")
2572 (set_attr "mode" "QI")])
2574 ;; Floating point push instructions.
2576 (define_insn "*pushtf"
2577 [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2578 (match_operand:TF 1 "general_no_elim_operand" "x,Fo,*r"))]
2581 /* This insn should be already split before reg-stack. */
2584 [(set_attr "type" "multi")
2585 (set_attr "unit" "sse,*,*")
2586 (set_attr "mode" "TF,SI,SI")])
2589 [(set (match_operand:TF 0 "push_operand" "")
2590 (match_operand:TF 1 "sse_reg_operand" ""))]
2591 "TARGET_SSE2 && reload_completed"
2592 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
2593 (set (mem:TF (reg:P SP_REG)) (match_dup 1))])
2596 [(set (match_operand:TF 0 "push_operand" "")
2597 (match_operand:TF 1 "general_operand" ""))]
2598 "TARGET_SSE2 && reload_completed
2599 && !SSE_REG_P (operands[1])"
2601 "ix86_split_long_move (operands); DONE;")
2603 (define_insn "*pushxf"
2604 [(set (match_operand:XF 0 "push_operand" "=<,<")
2605 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
2606 "optimize_function_for_speed_p (cfun)"
2608 /* This insn should be already split before reg-stack. */
2611 [(set_attr "type" "multi")
2612 (set_attr "unit" "i387,*")
2613 (set_attr "mode" "XF,SI")])
2615 ;; Size of pushxf is 3 (for sub) + 2 (for fstp) + memory operand size.
2616 ;; Size of pushxf using integer instructions is 3+3*memory operand size
2617 ;; Pushing using integer instructions is longer except for constants
2618 ;; and direct memory references (assuming that any given constant is pushed
2619 ;; only once, but this ought to be handled elsewhere).
2621 (define_insn "*pushxf_nointeger"
2622 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
2623 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
2624 "optimize_function_for_size_p (cfun)"
2626 /* This insn should be already split before reg-stack. */
2629 [(set_attr "type" "multi")
2630 (set_attr "unit" "i387,*,*")
2631 (set_attr "mode" "XF,SI,SI")])
2634 [(set (match_operand:XF 0 "push_operand" "")
2635 (match_operand:XF 1 "fp_register_operand" ""))]
2637 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2638 (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
2639 "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
2642 [(set (match_operand:XF 0 "push_operand" "")
2643 (match_operand:XF 1 "general_operand" ""))]
2645 && !FP_REG_P (operands[1])"
2647 "ix86_split_long_move (operands); DONE;")
2649 (define_insn "*pushdf"
2650 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2651 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
2652 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2654 /* This insn should be already split before reg-stack. */
2657 [(set_attr "type" "multi")
2658 (set_attr "unit" "i387,*,*")
2659 (set_attr "mode" "DF,SI,DF")])
2661 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2662 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2663 ;; On the average, pushdf using integers can be still shorter. Allow this
2664 ;; pattern for optimize_size too.
2666 (define_insn "*pushdf_nointeger"
2667 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2668 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
2669 "!(TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES)"
2671 /* This insn should be already split before reg-stack. */
2674 [(set_attr "type" "multi")
2675 (set_attr "unit" "i387,*,*,*")
2676 (set_attr "mode" "DF,SI,SI,DF")])
2678 ;; %%% Kill this when call knows how to work this out.
2680 [(set (match_operand:DF 0 "push_operand" "")
2681 (match_operand:DF 1 "any_fp_register_operand" ""))]
2683 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
2684 (set (mem:DF (reg:P SP_REG)) (match_dup 1))])
2687 [(set (match_operand:DF 0 "push_operand" "")
2688 (match_operand:DF 1 "general_operand" ""))]
2690 && !ANY_FP_REG_P (operands[1])"
2692 "ix86_split_long_move (operands); DONE;")
2694 (define_insn "*pushsf_rex64"
2695 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2696 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2699 /* Anything else should be already split before reg-stack. */
2700 gcc_assert (which_alternative == 1);
2701 return "push{q}\t%q1";
2703 [(set_attr "type" "multi,push,multi")
2704 (set_attr "unit" "i387,*,*")
2705 (set_attr "mode" "SF,DI,SF")])
2707 (define_insn "*pushsf"
2708 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2709 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2712 /* Anything else should be already split before reg-stack. */
2713 gcc_assert (which_alternative == 1);
2714 return "push{l}\t%1";
2716 [(set_attr "type" "multi,push,multi")
2717 (set_attr "unit" "i387,*,*")
2718 (set_attr "mode" "SF,SI,SF")])
2721 [(set (match_operand:SF 0 "push_operand" "")
2722 (match_operand:SF 1 "memory_operand" ""))]
2724 && MEM_P (operands[1])
2725 && (operands[2] = find_constant_src (insn))"
2729 ;; %%% Kill this when call knows how to work this out.
2731 [(set (match_operand:SF 0 "push_operand" "")
2732 (match_operand:SF 1 "any_fp_register_operand" ""))]
2734 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2735 (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
2736 "operands[2] = GEN_INT (-GET_MODE_SIZE (<MODE>mode));")
2738 ;; Floating point move instructions.
2740 (define_expand "movtf"
2741 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2742 (match_operand:TF 1 "nonimmediate_operand" ""))]
2745 ix86_expand_move (TFmode, operands);
2749 (define_expand "mov<mode>"
2750 [(set (match_operand:X87MODEF 0 "nonimmediate_operand" "")
2751 (match_operand:X87MODEF 1 "general_operand" ""))]
2753 "ix86_expand_move (<MODE>mode, operands); DONE;")
2755 (define_insn "*movtf_internal"
2756 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?r,?o")
2757 (match_operand:TF 1 "general_operand" "xm,x,C,roF,Fr"))]
2759 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2761 switch (which_alternative)
2765 if (get_attr_mode (insn) == MODE_V4SF)
2766 return "%vmovaps\t{%1, %0|%0, %1}";
2768 return "%vmovdqa\t{%1, %0|%0, %1}";
2770 if (get_attr_mode (insn) == MODE_V4SF)
2771 return "%vxorps\t%0, %d0";
2773 return "%vpxor\t%0, %d0";
2781 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
2782 (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,*,*")
2784 (cond [(eq_attr "alternative" "0,2")
2786 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2788 (const_string "V4SF")
2789 (const_string "TI"))
2790 (eq_attr "alternative" "1")
2792 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2794 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2796 (const_string "V4SF")
2797 (const_string "TI"))]
2798 (const_string "DI")))])
2801 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2802 (match_operand:TF 1 "general_operand" ""))]
2804 && !(SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]))"
2806 "ix86_split_long_move (operands); DONE;")
2808 (define_insn "*movxf_internal"
2809 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,r,o")
2810 (match_operand:XF 1 "general_operand" "fm,f,G,roF,Fr"))]
2811 "optimize_function_for_speed_p (cfun)
2812 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2813 && (reload_in_progress || reload_completed
2814 || GET_CODE (operands[1]) != CONST_DOUBLE
2815 || memory_operand (operands[0], XFmode))"
2817 switch (which_alternative)
2821 return output_387_reg_move (insn, operands);
2824 return standard_80387_constant_opcode (operands[1]);
2833 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2834 (set_attr "mode" "XF,XF,XF,SI,SI")])
2836 ;; Do not use integer registers when optimizing for size
2837 (define_insn "*movxf_internal_nointeger"
2838 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2839 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2840 "optimize_function_for_size_p (cfun)
2841 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2842 && (reload_in_progress || reload_completed
2843 || standard_80387_constant_p (operands[1])
2844 || GET_CODE (operands[1]) != CONST_DOUBLE
2845 || memory_operand (operands[0], XFmode))"
2847 switch (which_alternative)
2851 return output_387_reg_move (insn, operands);
2854 return standard_80387_constant_opcode (operands[1]);
2862 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2863 (set_attr "mode" "XF,XF,XF,SI,SI")])
2866 [(set (match_operand:XF 0 "nonimmediate_operand" "")
2867 (match_operand:XF 1 "general_operand" ""))]
2869 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2870 && ! (FP_REG_P (operands[0]) ||
2871 (GET_CODE (operands[0]) == SUBREG
2872 && FP_REG_P (SUBREG_REG (operands[0]))))
2873 && ! (FP_REG_P (operands[1]) ||
2874 (GET_CODE (operands[1]) == SUBREG
2875 && FP_REG_P (SUBREG_REG (operands[1]))))"
2877 "ix86_split_long_move (operands); DONE;")
2879 (define_insn "*movdf_internal_rex64"
2880 [(set (match_operand:DF 0 "nonimmediate_operand"
2881 "=f,m,f,r ,m ,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
2882 (match_operand:DF 1 "general_operand"
2883 "fm,f,G,rmF,Fr,C ,Y2*x,m ,Y2*x,r ,Yi"))]
2884 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2885 && (reload_in_progress || reload_completed
2886 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2887 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
2888 && optimize_function_for_size_p (cfun)
2889 && standard_80387_constant_p (operands[1]))
2890 || GET_CODE (operands[1]) != CONST_DOUBLE
2891 || memory_operand (operands[0], DFmode))"
2893 switch (which_alternative)
2897 return output_387_reg_move (insn, operands);
2900 return standard_80387_constant_opcode (operands[1]);
2907 switch (get_attr_mode (insn))
2910 return "%vxorps\t%0, %d0";
2912 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2913 return "%vxorps\t%0, %d0";
2915 return "%vxorpd\t%0, %d0";
2917 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2918 return "%vxorps\t%0, %d0";
2920 return "%vpxor\t%0, %d0";
2927 switch (get_attr_mode (insn))
2930 return "%vmovaps\t{%1, %0|%0, %1}";
2932 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2933 return "%vmovaps\t{%1, %0|%0, %1}";
2935 return "%vmovapd\t{%1, %0|%0, %1}";
2937 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2938 return "%vmovaps\t{%1, %0|%0, %1}";
2940 return "%vmovdqa\t{%1, %0|%0, %1}";
2942 return "%vmovq\t{%1, %0|%0, %1}";
2946 if (REG_P (operands[0]) && REG_P (operands[1]))
2947 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
2949 return "vmovsd\t{%1, %0|%0, %1}";
2952 return "movsd\t{%1, %0|%0, %1}";
2954 return "%vmovlpd\t{%1, %d0|%d0, %1}";
2956 return "%vmovlps\t{%1, %d0|%d0, %1}";
2963 return "%vmovd\t{%1, %0|%0, %1}";
2969 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
2970 (set (attr "prefix")
2971 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
2972 (const_string "orig")
2973 (const_string "maybe_vex")))
2974 (set (attr "prefix_data16")
2975 (if_then_else (eq_attr "mode" "V1DF")
2977 (const_string "*")))
2979 (cond [(eq_attr "alternative" "0,1,2")
2981 (eq_attr "alternative" "3,4,9,10")
2984 /* For SSE1, we have many fewer alternatives. */
2985 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2986 (cond [(eq_attr "alternative" "5,6")
2987 (const_string "V4SF")
2989 (const_string "V2SF"))
2991 /* xorps is one byte shorter. */
2992 (eq_attr "alternative" "5")
2993 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
2995 (const_string "V4SF")
2996 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3000 (const_string "V2DF"))
3002 /* For architectures resolving dependencies on
3003 whole SSE registers use APD move to break dependency
3004 chains, otherwise use short move to avoid extra work.
3006 movaps encodes one byte shorter. */
3007 (eq_attr "alternative" "6")
3009 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3011 (const_string "V4SF")
3012 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3014 (const_string "V2DF")
3016 (const_string "DF"))
3017 /* For architectures resolving dependencies on register
3018 parts we may avoid extra work to zero out upper part
3020 (eq_attr "alternative" "7")
3022 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3024 (const_string "V1DF")
3025 (const_string "DF"))
3027 (const_string "DF")))])
3029 (define_insn "*movdf_internal"
3030 [(set (match_operand:DF 0 "nonimmediate_operand"
3031 "=f,m,f,r ,o ,Y2*x,Y2*x,Y2*x,m ")
3032 (match_operand:DF 1 "general_operand"
3033 "fm,f,G,roF,Fr,C ,Y2*x,m ,Y2*x"))]
3034 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3035 && optimize_function_for_speed_p (cfun)
3036 && TARGET_INTEGER_DFMODE_MOVES
3037 && (reload_in_progress || reload_completed
3038 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3039 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3040 && optimize_function_for_size_p (cfun)
3041 && standard_80387_constant_p (operands[1]))
3042 || GET_CODE (operands[1]) != CONST_DOUBLE
3043 || memory_operand (operands[0], DFmode))"
3045 switch (which_alternative)
3049 return output_387_reg_move (insn, operands);
3052 return standard_80387_constant_opcode (operands[1]);
3059 switch (get_attr_mode (insn))
3062 return "xorps\t%0, %0";
3064 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3065 return "xorps\t%0, %0";
3067 return "xorpd\t%0, %0";
3069 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3070 return "xorps\t%0, %0";
3072 return "pxor\t%0, %0";
3079 switch (get_attr_mode (insn))
3082 return "movaps\t{%1, %0|%0, %1}";
3084 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3085 return "movaps\t{%1, %0|%0, %1}";
3087 return "movapd\t{%1, %0|%0, %1}";
3089 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3090 return "movaps\t{%1, %0|%0, %1}";
3092 return "movdqa\t{%1, %0|%0, %1}";
3094 return "movq\t{%1, %0|%0, %1}";
3096 return "movsd\t{%1, %0|%0, %1}";
3098 return "movlpd\t{%1, %0|%0, %1}";
3100 return "movlps\t{%1, %0|%0, %1}";
3109 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3110 (set (attr "prefix_data16")
3111 (if_then_else (eq_attr "mode" "V1DF")
3113 (const_string "*")))
3115 (cond [(eq_attr "alternative" "0,1,2")
3117 (eq_attr "alternative" "3,4")
3120 /* For SSE1, we have many fewer alternatives. */
3121 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3122 (cond [(eq_attr "alternative" "5,6")
3123 (const_string "V4SF")
3125 (const_string "V2SF"))
3127 /* xorps is one byte shorter. */
3128 (eq_attr "alternative" "5")
3129 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3131 (const_string "V4SF")
3132 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3136 (const_string "V2DF"))
3138 /* For architectures resolving dependencies on
3139 whole SSE registers use APD move to break dependency
3140 chains, otherwise use short move to avoid extra work.
3142 movaps encodes one byte shorter. */
3143 (eq_attr "alternative" "6")
3145 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3147 (const_string "V4SF")
3148 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3150 (const_string "V2DF")
3152 (const_string "DF"))
3153 /* For architectures resolving dependencies on register
3154 parts we may avoid extra work to zero out upper part
3156 (eq_attr "alternative" "7")
3158 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3160 (const_string "V1DF")
3161 (const_string "DF"))
3163 (const_string "DF")))])
3165 ;; Moving is usually shorter when only FP registers are used. This separate
3166 ;; movdf pattern avoids the use of integer registers for FP operations
3167 ;; when optimizing for size.
3169 (define_insn "*movdf_internal_nointeger"
3170 [(set (match_operand:DF 0 "nonimmediate_operand"
3171 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
3172 (match_operand:DF 1 "general_operand"
3173 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
3174 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3175 && ((optimize_function_for_size_p (cfun)
3176 || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
3177 && (reload_in_progress || reload_completed
3178 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3179 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3180 && optimize_function_for_size_p (cfun)
3181 && !memory_operand (operands[0], DFmode)
3182 && standard_80387_constant_p (operands[1]))
3183 || GET_CODE (operands[1]) != CONST_DOUBLE
3184 || ((optimize_function_for_size_p (cfun)
3185 || !TARGET_MEMORY_MISMATCH_STALL
3186 || reload_in_progress || reload_completed)
3187 && memory_operand (operands[0], DFmode)))"
3189 switch (which_alternative)
3193 return output_387_reg_move (insn, operands);
3196 return standard_80387_constant_opcode (operands[1]);
3203 switch (get_attr_mode (insn))
3206 return "%vxorps\t%0, %d0";
3208 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3209 return "%vxorps\t%0, %d0";
3211 return "%vxorpd\t%0, %d0";
3213 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3214 return "%vxorps\t%0, %d0";
3216 return "%vpxor\t%0, %d0";
3223 switch (get_attr_mode (insn))
3226 return "%vmovaps\t{%1, %0|%0, %1}";
3228 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3229 return "%vmovaps\t{%1, %0|%0, %1}";
3231 return "%vmovapd\t{%1, %0|%0, %1}";
3233 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3234 return "%vmovaps\t{%1, %0|%0, %1}";
3236 return "%vmovdqa\t{%1, %0|%0, %1}";
3238 return "%vmovq\t{%1, %0|%0, %1}";
3242 if (REG_P (operands[0]) && REG_P (operands[1]))
3243 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3245 return "vmovsd\t{%1, %0|%0, %1}";
3248 return "movsd\t{%1, %0|%0, %1}";
3252 if (REG_P (operands[0]))
3253 return "vmovlpd\t{%1, %0, %0|%0, %0, %1}";
3255 return "vmovlpd\t{%1, %0|%0, %1}";
3258 return "movlpd\t{%1, %0|%0, %1}";
3262 if (REG_P (operands[0]))
3263 return "vmovlps\t{%1, %0, %0|%0, %0, %1}";
3265 return "vmovlps\t{%1, %0|%0, %1}";
3268 return "movlps\t{%1, %0|%0, %1}";
3277 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3278 (set (attr "prefix")
3279 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3280 (const_string "orig")
3281 (const_string "maybe_vex")))
3282 (set (attr "prefix_data16")
3283 (if_then_else (eq_attr "mode" "V1DF")
3285 (const_string "*")))
3287 (cond [(eq_attr "alternative" "0,1,2")
3289 (eq_attr "alternative" "3,4")
3292 /* For SSE1, we have many fewer alternatives. */
3293 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3294 (cond [(eq_attr "alternative" "5,6")
3295 (const_string "V4SF")
3297 (const_string "V2SF"))
3299 /* xorps is one byte shorter. */
3300 (eq_attr "alternative" "5")
3301 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3303 (const_string "V4SF")
3304 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3308 (const_string "V2DF"))
3310 /* For architectures resolving dependencies on
3311 whole SSE registers use APD move to break dependency
3312 chains, otherwise use short move to avoid extra work.
3314 movaps encodes one byte shorter. */
3315 (eq_attr "alternative" "6")
3317 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3319 (const_string "V4SF")
3320 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3322 (const_string "V2DF")
3324 (const_string "DF"))
3325 /* For architectures resolving dependencies on register
3326 parts we may avoid extra work to zero out upper part
3328 (eq_attr "alternative" "7")
3330 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3332 (const_string "V1DF")
3333 (const_string "DF"))
3335 (const_string "DF")))])
3338 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3339 (match_operand:DF 1 "general_operand" ""))]
3341 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3342 && ! (ANY_FP_REG_P (operands[0]) ||
3343 (GET_CODE (operands[0]) == SUBREG
3344 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3345 && ! (ANY_FP_REG_P (operands[1]) ||
3346 (GET_CODE (operands[1]) == SUBREG
3347 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3349 "ix86_split_long_move (operands); DONE;")
3351 (define_insn "*movsf_internal"
3352 [(set (match_operand:SF 0 "nonimmediate_operand"
3353 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
3354 (match_operand:SF 1 "general_operand"
3355 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
3356 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3357 && (reload_in_progress || reload_completed
3358 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3359 || (!TARGET_SSE_MATH && optimize_function_for_size_p (cfun)
3360 && standard_80387_constant_p (operands[1]))
3361 || GET_CODE (operands[1]) != CONST_DOUBLE
3362 || memory_operand (operands[0], SFmode))"
3364 switch (which_alternative)
3368 return output_387_reg_move (insn, operands);
3371 return standard_80387_constant_opcode (operands[1]);
3375 return "mov{l}\t{%1, %0|%0, %1}";
3377 if (get_attr_mode (insn) == MODE_TI)
3378 return "%vpxor\t%0, %d0";
3380 return "%vxorps\t%0, %d0";
3382 if (get_attr_mode (insn) == MODE_V4SF)
3383 return "%vmovaps\t{%1, %0|%0, %1}";
3385 return "%vmovss\t{%1, %d0|%d0, %1}";
3388 return REG_P (operands[1]) ? "vmovss\t{%1, %0, %0|%0, %0, %1}"
3389 : "vmovss\t{%1, %0|%0, %1}";
3391 return "movss\t{%1, %0|%0, %1}";
3393 return "%vmovss\t{%1, %0|%0, %1}";
3395 case 9: case 10: case 14: case 15:
3396 return "movd\t{%1, %0|%0, %1}";
3398 return "%vmovd\t{%1, %0|%0, %1}";
3401 return "movq\t{%1, %0|%0, %1}";
3407 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
3408 (set (attr "prefix")
3409 (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
3410 (const_string "maybe_vex")
3411 (const_string "orig")))
3413 (cond [(eq_attr "alternative" "3,4,9,10")
3415 (eq_attr "alternative" "5")
3417 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3419 (ne (symbol_ref "TARGET_SSE2")
3421 (eq (symbol_ref "optimize_function_for_size_p (cfun)")
3424 (const_string "V4SF"))
3425 /* For architectures resolving dependencies on
3426 whole SSE registers use APS move to break dependency
3427 chains, otherwise use short move to avoid extra work.
3429 Do the same for architectures resolving dependencies on
3430 the parts. While in DF mode it is better to always handle
3431 just register parts, the SF mode is different due to lack
3432 of instructions to load just part of the register. It is
3433 better to maintain the whole registers in single format
3434 to avoid problems on using packed logical operations. */
3435 (eq_attr "alternative" "6")
3437 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3439 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3441 (const_string "V4SF")
3442 (const_string "SF"))
3443 (eq_attr "alternative" "11")
3444 (const_string "DI")]
3445 (const_string "SF")))])
3448 [(set (match_operand 0 "register_operand" "")
3449 (match_operand 1 "memory_operand" ""))]
3451 && MEM_P (operands[1])
3452 && (GET_MODE (operands[0]) == TFmode
3453 || GET_MODE (operands[0]) == XFmode
3454 || GET_MODE (operands[0]) == DFmode
3455 || GET_MODE (operands[0]) == SFmode)
3456 && (operands[2] = find_constant_src (insn))"
3457 [(set (match_dup 0) (match_dup 2))]
3459 rtx c = operands[2];
3460 rtx r = operands[0];
3462 if (GET_CODE (r) == SUBREG)
3467 if (!standard_sse_constant_p (c))
3470 else if (FP_REG_P (r))
3472 if (!standard_80387_constant_p (c))
3475 else if (MMX_REG_P (r))
3480 [(set (match_operand 0 "register_operand" "")
3481 (float_extend (match_operand 1 "memory_operand" "")))]
3483 && MEM_P (operands[1])
3484 && (GET_MODE (operands[0]) == TFmode
3485 || GET_MODE (operands[0]) == XFmode
3486 || GET_MODE (operands[0]) == DFmode
3487 || GET_MODE (operands[0]) == SFmode)
3488 && (operands[2] = find_constant_src (insn))"
3489 [(set (match_dup 0) (match_dup 2))]
3491 rtx c = operands[2];
3492 rtx r = operands[0];
3494 if (GET_CODE (r) == SUBREG)
3499 if (!standard_sse_constant_p (c))
3502 else if (FP_REG_P (r))
3504 if (!standard_80387_constant_p (c))
3507 else if (MMX_REG_P (r))
3511 ;; Split the load of -0.0 or -1.0 into fldz;fchs or fld1;fchs sequence
3513 [(set (match_operand:X87MODEF 0 "register_operand" "")
3514 (match_operand:X87MODEF 1 "immediate_operand" ""))]
3515 "reload_completed && FP_REGNO_P (REGNO (operands[0]))
3516 && (standard_80387_constant_p (operands[1]) == 8
3517 || standard_80387_constant_p (operands[1]) == 9)"
3518 [(set (match_dup 0)(match_dup 1))
3520 (neg:X87MODEF (match_dup 0)))]
3524 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
3525 if (real_isnegzero (&r))
3526 operands[1] = CONST0_RTX (<MODE>mode);
3528 operands[1] = CONST1_RTX (<MODE>mode);
3531 (define_insn "swapxf"
3532 [(set (match_operand:XF 0 "register_operand" "+f")
3533 (match_operand:XF 1 "register_operand" "+f"))
3538 if (STACK_TOP_P (operands[0]))
3543 [(set_attr "type" "fxch")
3544 (set_attr "mode" "XF")])
3546 (define_insn "*swap<mode>"
3547 [(set (match_operand:MODEF 0 "fp_register_operand" "+f")
3548 (match_operand:MODEF 1 "fp_register_operand" "+f"))
3551 "TARGET_80387 || reload_completed"
3553 if (STACK_TOP_P (operands[0]))
3558 [(set_attr "type" "fxch")
3559 (set_attr "mode" "<MODE>")])
3561 ;; Zero extension instructions
3563 (define_expand "zero_extendsidi2"
3564 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3565 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3570 emit_insn (gen_zero_extendsidi2_1 (operands[0], operands[1]));
3575 (define_insn "*zero_extendsidi2_rex64"
3576 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,?*Ym,?*y,?*Yi,*Y2")
3578 (match_operand:SI 1 "nonimmediate_operand" "rm,0,r ,m ,r ,m")))]
3581 mov\t{%k1, %k0|%k0, %k1}
3583 movd\t{%1, %0|%0, %1}
3584 movd\t{%1, %0|%0, %1}
3585 %vmovd\t{%1, %0|%0, %1}
3586 %vmovd\t{%1, %0|%0, %1}"
3587 [(set_attr "type" "imovx,imov,mmxmov,mmxmov,ssemov,ssemov")
3588 (set_attr "prefix" "orig,*,orig,orig,maybe_vex,maybe_vex")
3589 (set_attr "prefix_0f" "0,*,*,*,*,*")
3590 (set_attr "mode" "SI,DI,DI,DI,TI,TI")])
3593 [(set (match_operand:DI 0 "memory_operand" "")
3594 (zero_extend:DI (match_dup 0)))]
3596 [(set (match_dup 4) (const_int 0))]
3597 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3599 ;; %%% Kill me once multi-word ops are sane.
3600 (define_insn "zero_extendsidi2_1"
3601 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?o,?*Ym,?*y,?*Yi,*Y2")
3603 (match_operand:SI 1 "nonimmediate_operand" "0,rm,r ,r ,m ,r ,m")))
3604 (clobber (reg:CC FLAGS_REG))]
3610 movd\t{%1, %0|%0, %1}
3611 movd\t{%1, %0|%0, %1}
3612 %vmovd\t{%1, %0|%0, %1}
3613 %vmovd\t{%1, %0|%0, %1}"
3614 [(set_attr "type" "multi,multi,multi,mmxmov,mmxmov,ssemov,ssemov")
3615 (set_attr "prefix" "*,*,*,orig,orig,maybe_vex,maybe_vex")
3616 (set_attr "mode" "SI,SI,SI,DI,DI,TI,TI")])
3619 [(set (match_operand:DI 0 "register_operand" "")
3620 (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3621 (clobber (reg:CC FLAGS_REG))]
3622 "!TARGET_64BIT && reload_completed
3623 && true_regnum (operands[0]) == true_regnum (operands[1])"
3624 [(set (match_dup 4) (const_int 0))]
3625 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3628 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3629 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3630 (clobber (reg:CC FLAGS_REG))]
3631 "!TARGET_64BIT && reload_completed
3632 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))"
3633 [(set (match_dup 3) (match_dup 1))
3634 (set (match_dup 4) (const_int 0))]
3635 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3637 (define_insn "zero_extend<mode>di2"
3638 [(set (match_operand:DI 0 "register_operand" "=r")
3640 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3642 "movz{<imodesuffix>l|x}\t{%1, %k0|%k0, %1}"
3643 [(set_attr "type" "imovx")
3644 (set_attr "mode" "SI")])
3646 (define_expand "zero_extendhisi2"
3647 [(set (match_operand:SI 0 "register_operand" "")
3648 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3651 if (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3653 operands[1] = force_reg (HImode, operands[1]);
3654 emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3659 (define_insn_and_split "zero_extendhisi2_and"
3660 [(set (match_operand:SI 0 "register_operand" "=r")
3661 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3662 (clobber (reg:CC FLAGS_REG))]
3663 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3665 "&& reload_completed"
3666 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3667 (clobber (reg:CC FLAGS_REG))])]
3669 [(set_attr "type" "alu1")
3670 (set_attr "mode" "SI")])
3672 (define_insn "*zero_extendhisi2_movzwl"
3673 [(set (match_operand:SI 0 "register_operand" "=r")
3674 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3675 "!TARGET_ZERO_EXTEND_WITH_AND
3676 || optimize_function_for_size_p (cfun)"
3677 "movz{wl|x}\t{%1, %0|%0, %1}"
3678 [(set_attr "type" "imovx")
3679 (set_attr "mode" "SI")])
3681 (define_expand "zero_extendqi<mode>2"
3683 [(set (match_operand:SWI24 0 "register_operand" "")
3684 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3685 (clobber (reg:CC FLAGS_REG))])])
3687 (define_insn "*zero_extendqi<mode>2_and"
3688 [(set (match_operand:SWI24 0 "register_operand" "=r,?&q")
3689 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3690 (clobber (reg:CC FLAGS_REG))]
3691 "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3693 [(set_attr "type" "alu1")
3694 (set_attr "mode" "<MODE>")])
3696 ;; When source and destination does not overlap, clear destination
3697 ;; first and then do the movb
3699 [(set (match_operand:SWI24 0 "register_operand" "")
3700 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3701 (clobber (reg:CC FLAGS_REG))]
3703 && (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3704 && ANY_QI_REG_P (operands[0])
3705 && (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]))
3706 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3707 [(set (strict_low_part (match_dup 2)) (match_dup 1))]
3709 operands[2] = gen_lowpart (QImode, operands[0]);
3710 ix86_expand_clear (operands[0]);
3713 (define_insn "*zero_extendqi<mode>2_movzbl_and"
3714 [(set (match_operand:SWI24 0 "register_operand" "=r,r")
3715 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3716 (clobber (reg:CC FLAGS_REG))]
3717 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun)"
3719 [(set_attr "type" "imovx,alu1")
3720 (set_attr "mode" "<MODE>")])
3722 ;; For the movzbl case strip only the clobber
3724 [(set (match_operand:SWI24 0 "register_operand" "")
3725 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3726 (clobber (reg:CC FLAGS_REG))]
3728 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))
3729 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3731 (zero_extend:SWI24 (match_dup 1)))])
3733 ; zero extend to SImode to avoid partial register stalls
3734 (define_insn "*zero_extendqi<mode>2_movzbl"
3735 [(set (match_operand:SWI24 0 "register_operand" "=r")
3736 (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3738 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))"
3739 "movz{bl|x}\t{%1, %k0|%k0, %1}"
3740 [(set_attr "type" "imovx")
3741 (set_attr "mode" "SI")])
3743 ;; Rest is handled by single and.
3745 [(set (match_operand:SWI24 0 "register_operand" "")
3746 (zero_extend:SWI24 (match_operand:QI 1 "register_operand" "")))
3747 (clobber (reg:CC FLAGS_REG))]
3749 && true_regnum (operands[0]) == true_regnum (operands[1])"
3750 [(parallel [(set (match_dup 0) (and:SWI24 (match_dup 0) (const_int 255)))
3751 (clobber (reg:CC FLAGS_REG))])])
3753 ;; Sign extension instructions
3755 (define_expand "extendsidi2"
3756 [(set (match_operand:DI 0 "register_operand" "")
3757 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))]
3762 emit_insn (gen_extendsidi2_1 (operands[0], operands[1]));
3767 (define_insn "*extendsidi2_rex64"
3768 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3769 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3773 movs{lq|x}\t{%1, %0|%0, %1}"
3774 [(set_attr "type" "imovx")
3775 (set_attr "mode" "DI")
3776 (set_attr "prefix_0f" "0")
3777 (set_attr "modrm" "0,1")])
3779 (define_insn "extendsidi2_1"
3780 [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3781 (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3782 (clobber (reg:CC FLAGS_REG))
3783 (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3787 ;; Extend to memory case when source register does die.
3789 [(set (match_operand:DI 0 "memory_operand" "")
3790 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3791 (clobber (reg:CC FLAGS_REG))
3792 (clobber (match_operand:SI 2 "register_operand" ""))]
3794 && dead_or_set_p (insn, operands[1])
3795 && !reg_mentioned_p (operands[1], operands[0]))"
3796 [(set (match_dup 3) (match_dup 1))
3797 (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3798 (clobber (reg:CC FLAGS_REG))])
3799 (set (match_dup 4) (match_dup 1))]
3800 "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3802 ;; Extend to memory case when source register does not die.
3804 [(set (match_operand:DI 0 "memory_operand" "")
3805 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3806 (clobber (reg:CC FLAGS_REG))
3807 (clobber (match_operand:SI 2 "register_operand" ""))]
3811 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3813 emit_move_insn (operands[3], operands[1]);
3815 /* Generate a cltd if possible and doing so it profitable. */
3816 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3817 && true_regnum (operands[1]) == AX_REG
3818 && true_regnum (operands[2]) == DX_REG)
3820 emit_insn (gen_ashrsi3_cvt (operands[2], operands[1], GEN_INT (31)));
3824 emit_move_insn (operands[2], operands[1]);
3825 emit_insn (gen_ashrsi3_cvt (operands[2], operands[2], GEN_INT (31)));
3827 emit_move_insn (operands[4], operands[2]);
3831 ;; Extend to register case. Optimize case where source and destination
3832 ;; registers match and cases where we can use cltd.
3834 [(set (match_operand:DI 0 "register_operand" "")
3835 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3836 (clobber (reg:CC FLAGS_REG))
3837 (clobber (match_scratch:SI 2 ""))]
3841 split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);
3843 if (true_regnum (operands[3]) != true_regnum (operands[1]))
3844 emit_move_insn (operands[3], operands[1]);
3846 /* Generate a cltd if possible and doing so it profitable. */
3847 if ((optimize_function_for_size_p (cfun) || TARGET_USE_CLTD)
3848 && true_regnum (operands[3]) == AX_REG
3849 && true_regnum (operands[4]) == DX_REG)
3851 emit_insn (gen_ashrsi3_cvt (operands[4], operands[3], GEN_INT (31)));
3855 if (true_regnum (operands[4]) != true_regnum (operands[1]))
3856 emit_move_insn (operands[4], operands[1]);
3858 emit_insn (gen_ashrsi3_cvt (operands[4], operands[4], GEN_INT (31)));
3862 (define_insn "extend<mode>di2"
3863 [(set (match_operand:DI 0 "register_operand" "=r")
3865 (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3867 "movs{<imodesuffix>q|x}\t{%1, %0|%0, %1}"
3868 [(set_attr "type" "imovx")
3869 (set_attr "mode" "DI")])
3871 (define_insn "extendhisi2"
3872 [(set (match_operand:SI 0 "register_operand" "=*a,r")
3873 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3876 switch (get_attr_prefix_0f (insn))
3879 return "{cwtl|cwde}";
3881 return "movs{wl|x}\t{%1, %0|%0, %1}";
3884 [(set_attr "type" "imovx")
3885 (set_attr "mode" "SI")
3886 (set (attr "prefix_0f")
3887 ;; movsx is short decodable while cwtl is vector decoded.
3888 (if_then_else (and (eq_attr "cpu" "!k6")
3889 (eq_attr "alternative" "0"))
3891 (const_string "1")))
3893 (if_then_else (eq_attr "prefix_0f" "0")
3895 (const_string "1")))])
3897 (define_insn "*extendhisi2_zext"
3898 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3901 (match_operand:HI 1 "nonimmediate_operand" "*0,rm"))))]
3904 switch (get_attr_prefix_0f (insn))