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
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 ;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of
32 ;; 'L' Print the opcode suffix for a 32-bit integer opcode.
33 ;; 'W' Print the opcode suffix for a 16-bit integer opcode.
34 ;; 'B' Print the opcode suffix for an 8-bit integer opcode.
35 ;; 'Q' Print the opcode suffix for a 64-bit float opcode.
36 ;; 'S' Print the opcode suffix for a 32-bit float opcode.
37 ;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode.
38 ;; 'J' Print the appropriate jump operand.
40 ;; 'b' Print the QImode name of the register for the indicated operand.
41 ;; %b0 would print %al if operands[0] is reg 0.
42 ;; 'w' Likewise, print the HImode name of the register.
43 ;; 'k' Likewise, print the SImode name of the register.
44 ;; 'h' Print the QImode name for a "high" register, either ah, bh, ch or dh.
45 ;; 'y' Print "st(0)" instead of "st" as a register.
50 [; Relocation specifiers
63 (UNSPEC_STACK_ALLOC 11)
65 (UNSPEC_SSE_PROLOGUE_SAVE 13)
69 (UNSPEC_SET_GOT_OFFSET 17)
74 (UNSPEC_TLS_LD_BASE 20)
77 ; Other random patterns
86 (UNSPEC_LD_MPIC 38) ; load_macho_picbase
87 (UNSPEC_TRUNC_NOOP 39)
89 ; For SSE/MMX support:
90 (UNSPEC_FIX_NOTRUNC 40)
108 ; Generic math support
110 (UNSPEC_IEEE_MIN 51) ; not commutative
111 (UNSPEC_IEEE_MAX 52) ; not commutative
126 (UNSPEC_FRNDINT_FLOOR 70)
127 (UNSPEC_FRNDINT_CEIL 71)
128 (UNSPEC_FRNDINT_TRUNC 72)
129 (UNSPEC_FRNDINT_MASK_PM 73)
130 (UNSPEC_FIST_FLOOR 74)
131 (UNSPEC_FIST_CEIL 75)
133 ; x87 Double output FP
134 (UNSPEC_SINCOS_COS 80)
135 (UNSPEC_SINCOS_SIN 81)
136 (UNSPEC_XTRACT_FRACT 84)
137 (UNSPEC_XTRACT_EXP 85)
138 (UNSPEC_FSCALE_FRACT 86)
139 (UNSPEC_FSCALE_EXP 87)
150 (UNSPEC_SP_TLS_SET 102)
151 (UNSPEC_SP_TLS_TEST 103)
161 (UNSPEC_INSERTQI 132)
166 (UNSPEC_INSERTPS 135)
168 (UNSPEC_MOVNTDQA 137)
170 (UNSPEC_PHMINPOSUW 139)
176 (UNSPEC_PCMPESTR 144)
177 (UNSPEC_PCMPISTR 145)
180 (UNSPEC_SSE5_INTRINSIC 150)
181 (UNSPEC_SSE5_UNSIGNED_CMP 151)
182 (UNSPEC_SSE5_TRUEFALSE 152)
183 (UNSPEC_SSE5_PERMUTE 153)
185 (UNSPEC_CVTPH2PS 155)
186 (UNSPEC_CVTPS2PH 156)
190 (UNSPEC_AESENCLAST 160)
192 (UNSPEC_AESDECLAST 162)
194 (UNSPEC_AESKEYGENASSIST 164)
201 [(UNSPECV_BLOCKAGE 0)
202 (UNSPECV_STACK_PROBE 1)
211 (UNSPECV_CMPXCHG_1 10)
212 (UNSPECV_CMPXCHG_2 11)
215 (UNSPECV_PROLOGUE_USE 14)
219 ;; Constants to represent pcomtrue/pcomfalse variants
229 ;; Constants used in the SSE5 pperm instruction
231 [(PPERM_SRC 0x00) /* copy source */
232 (PPERM_INVERT 0x20) /* invert source */
233 (PPERM_REVERSE 0x40) /* bit reverse source */
234 (PPERM_REV_INV 0x60) /* bit reverse & invert src */
235 (PPERM_ZERO 0x80) /* all 0's */
236 (PPERM_ONES 0xa0) /* all 1's */
237 (PPERM_SIGN 0xc0) /* propagate sign bit */
238 (PPERM_INV_SIGN 0xe0) /* invert & propagate sign */
239 (PPERM_SRC1 0x00) /* use first source byte */
240 (PPERM_SRC2 0x10) /* use second source byte */
243 ;; Registers by name.
259 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
262 ;; In C guard expressions, put expressions which may be compile-time
263 ;; constants first. This allows for better optimization. For
264 ;; example, write "TARGET_64BIT && reload_completed", not
265 ;; "reload_completed && TARGET_64BIT".
268 ;; Processor type. This attribute must exactly match the processor_type
269 ;; enumeration in i386.h.
270 (define_attr "cpu" "i386,i486,pentium,pentiumpro,geode,k6,athlon,pentium4,k8,
271 nocona,core2,generic32,generic64,amdfam10"
272 (const (symbol_ref "ix86_tune")))
274 ;; A basic instruction type. Refinements due to arguments to be
275 ;; provided in other attributes.
278 alu,alu1,negnot,imov,imovx,lea,
279 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
280 icmp,test,ibr,setcc,icmov,
281 push,pop,call,callv,leave,
283 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
284 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
285 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
287 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
288 (const_string "other"))
290 ;; Main data type used by the insn
292 "unknown,none,QI,HI,SI,DI,SF,DF,XF,TI,V4SF,V2DF,V2SF,V1DF"
293 (const_string "unknown"))
295 ;; The CPU unit operations uses.
296 (define_attr "unit" "integer,i387,sse,mmx,unknown"
297 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
298 (const_string "i387")
299 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
300 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
301 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
303 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
305 (eq_attr "type" "other")
306 (const_string "unknown")]
307 (const_string "integer")))
309 ;; The (bounding maximum) length of an instruction immediate.
310 (define_attr "length_immediate" ""
311 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
314 (eq_attr "unit" "i387,sse,mmx")
316 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
318 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
319 (eq_attr "type" "imov,test")
320 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
321 (eq_attr "type" "call")
322 (if_then_else (match_operand 0 "constant_call_address_operand" "")
325 (eq_attr "type" "callv")
326 (if_then_else (match_operand 1 "constant_call_address_operand" "")
329 ;; We don't know the size before shorten_branches. Expect
330 ;; the instruction to fit for better scheduling.
331 (eq_attr "type" "ibr")
334 (symbol_ref "/* Update immediate_length and other attributes! */
335 gcc_unreachable (),1")))
337 ;; The (bounding maximum) length of an instruction address.
338 (define_attr "length_address" ""
339 (cond [(eq_attr "type" "str,other,multi,fxch")
341 (and (eq_attr "type" "call")
342 (match_operand 0 "constant_call_address_operand" ""))
344 (and (eq_attr "type" "callv")
345 (match_operand 1 "constant_call_address_operand" ""))
348 (symbol_ref "ix86_attr_length_address_default (insn)")))
350 ;; Set when length prefix is used.
351 (define_attr "prefix_data16" ""
352 (if_then_else (ior (eq_attr "mode" "HI")
353 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF")))
357 ;; Set when string REP prefix is used.
358 (define_attr "prefix_rep" ""
359 (if_then_else (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
363 ;; Set when 0f opcode prefix is used.
364 (define_attr "prefix_0f" ""
366 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
367 (eq_attr "unit" "sse,mmx"))
371 ;; Set when REX opcode prefix is used.
372 (define_attr "prefix_rex" ""
373 (cond [(and (eq_attr "mode" "DI")
374 (eq_attr "type" "!push,pop,call,callv,leave,ibr"))
376 (and (eq_attr "mode" "QI")
377 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
380 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
386 ;; There are also additional prefixes in SSSE3.
387 (define_attr "prefix_extra" "" (const_int 0))
389 ;; Set when modrm byte is used.
390 (define_attr "modrm" ""
391 (cond [(eq_attr "type" "str,leave")
393 (eq_attr "unit" "i387")
395 (and (eq_attr "type" "incdec")
396 (ior (match_operand:SI 1 "register_operand" "")
397 (match_operand:HI 1 "register_operand" "")))
399 (and (eq_attr "type" "push")
400 (not (match_operand 1 "memory_operand" "")))
402 (and (eq_attr "type" "pop")
403 (not (match_operand 0 "memory_operand" "")))
405 (and (eq_attr "type" "imov")
406 (ior (and (match_operand 0 "register_operand" "")
407 (match_operand 1 "immediate_operand" ""))
408 (ior (and (match_operand 0 "ax_reg_operand" "")
409 (match_operand 1 "memory_displacement_only_operand" ""))
410 (and (match_operand 0 "memory_displacement_only_operand" "")
411 (match_operand 1 "ax_reg_operand" "")))))
413 (and (eq_attr "type" "call")
414 (match_operand 0 "constant_call_address_operand" ""))
416 (and (eq_attr "type" "callv")
417 (match_operand 1 "constant_call_address_operand" ""))
422 ;; The (bounding maximum) length of an instruction in bytes.
423 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
424 ;; Later we may want to split them and compute proper length as for
426 (define_attr "length" ""
427 (cond [(eq_attr "type" "other,multi,fistp,frndint")
429 (eq_attr "type" "fcmp")
431 (eq_attr "unit" "i387")
433 (plus (attr "prefix_data16")
434 (attr "length_address")))]
435 (plus (plus (attr "modrm")
436 (plus (attr "prefix_0f")
437 (plus (attr "prefix_rex")
438 (plus (attr "prefix_extra")
440 (plus (attr "prefix_rep")
441 (plus (attr "prefix_data16")
442 (plus (attr "length_immediate")
443 (attr "length_address")))))))
445 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
446 ;; `store' if there is a simple memory reference therein, or `unknown'
447 ;; if the instruction is complex.
449 (define_attr "memory" "none,load,store,both,unknown"
450 (cond [(eq_attr "type" "other,multi,str")
451 (const_string "unknown")
452 (eq_attr "type" "lea,fcmov,fpspc")
453 (const_string "none")
454 (eq_attr "type" "fistp,leave")
455 (const_string "both")
456 (eq_attr "type" "frndint")
457 (const_string "load")
458 (eq_attr "type" "push")
459 (if_then_else (match_operand 1 "memory_operand" "")
460 (const_string "both")
461 (const_string "store"))
462 (eq_attr "type" "pop")
463 (if_then_else (match_operand 0 "memory_operand" "")
464 (const_string "both")
465 (const_string "load"))
466 (eq_attr "type" "setcc")
467 (if_then_else (match_operand 0 "memory_operand" "")
468 (const_string "store")
469 (const_string "none"))
470 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
471 (if_then_else (ior (match_operand 0 "memory_operand" "")
472 (match_operand 1 "memory_operand" ""))
473 (const_string "load")
474 (const_string "none"))
475 (eq_attr "type" "ibr")
476 (if_then_else (match_operand 0 "memory_operand" "")
477 (const_string "load")
478 (const_string "none"))
479 (eq_attr "type" "call")
480 (if_then_else (match_operand 0 "constant_call_address_operand" "")
481 (const_string "none")
482 (const_string "load"))
483 (eq_attr "type" "callv")
484 (if_then_else (match_operand 1 "constant_call_address_operand" "")
485 (const_string "none")
486 (const_string "load"))
487 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
488 (match_operand 1 "memory_operand" ""))
489 (const_string "both")
490 (and (match_operand 0 "memory_operand" "")
491 (match_operand 1 "memory_operand" ""))
492 (const_string "both")
493 (match_operand 0 "memory_operand" "")
494 (const_string "store")
495 (match_operand 1 "memory_operand" "")
496 (const_string "load")
498 "!alu1,negnot,ishift1,
499 imov,imovx,icmp,test,bitmanip,
501 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
502 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
503 (match_operand 2 "memory_operand" ""))
504 (const_string "load")
505 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
506 (match_operand 3 "memory_operand" ""))
507 (const_string "load")
509 (const_string "none")))
511 ;; Indicates if an instruction has both an immediate and a displacement.
513 (define_attr "imm_disp" "false,true,unknown"
514 (cond [(eq_attr "type" "other,multi")
515 (const_string "unknown")
516 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
517 (and (match_operand 0 "memory_displacement_operand" "")
518 (match_operand 1 "immediate_operand" "")))
519 (const_string "true")
520 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
521 (and (match_operand 0 "memory_displacement_operand" "")
522 (match_operand 2 "immediate_operand" "")))
523 (const_string "true")
525 (const_string "false")))
527 ;; Indicates if an FP operation has an integer source.
529 (define_attr "fp_int_src" "false,true"
530 (const_string "false"))
532 ;; Defines rounding mode of an FP operation.
534 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
535 (const_string "any"))
537 ;; Describe a user's asm statement.
538 (define_asm_attributes
539 [(set_attr "length" "128")
540 (set_attr "type" "multi")])
542 ;; All integer comparison codes.
543 (define_code_iterator int_cond [ne eq ge gt le lt geu gtu leu ltu ])
545 ;; All floating-point comparison codes.
546 (define_code_iterator fp_cond [unordered ordered
547 uneq unge ungt unle unlt ltgt ])
549 (define_code_iterator plusminus [plus minus])
551 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
553 ;; Base name for define_insn
554 (define_code_attr plusminus_insn
555 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
556 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
558 ;; Base name for insn mnemonic.
559 (define_code_attr plusminus_mnemonic
560 [(plus "add") (ss_plus "adds") (us_plus "addus")
561 (minus "sub") (ss_minus "subs") (us_minus "subus")])
563 ;; Mark commutative operators as such in constraints.
564 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
565 (minus "") (ss_minus "") (us_minus "")])
567 ;; Mapping of signed max and min
568 (define_code_iterator smaxmin [smax smin])
570 ;; Mapping of unsigned max and min
571 (define_code_iterator umaxmin [umax umin])
573 ;; Base name for integer and FP insn mnemonic
574 (define_code_attr maxminiprefix [(smax "maxs") (smin "mins")
575 (umax "maxu") (umin "minu")])
576 (define_code_attr maxminfprefix [(smax "max") (smin "min")])
578 ;; Mapping of parallel logic operators
579 (define_code_iterator plogic [and ior xor])
581 ;; Base name for insn mnemonic.
582 (define_code_attr plogicprefix [(and "and") (ior "or") (xor "xor")])
584 ;; Mapping of abs neg operators
585 (define_code_iterator absneg [abs neg])
587 ;; Base name for x87 insn mnemonic.
588 (define_code_attr absnegprefix [(abs "abs") (neg "chs")])
590 ;; All single word integer modes.
591 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
593 ;; Instruction suffix for integer modes.
594 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
596 ;; Register class for integer modes.
597 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
599 ;; Immediate operand constraint for integer modes.
600 (define_mode_attr i [(QI "i") (HI "i") (SI "i") (DI "e")])
602 ;; General operand predicate for integer modes.
603 (define_mode_attr general_operand
604 [(QI "general_operand")
605 (HI "general_operand")
606 (SI "general_operand")
607 (DI "x86_64_general_operand")])
609 ;; SSE and x87 SFmode and DFmode floating point modes
610 (define_mode_iterator MODEF [SF DF])
612 ;; All x87 floating point modes
613 (define_mode_iterator X87MODEF [SF DF XF])
615 ;; All integer modes handled by x87 fisttp operator.
616 (define_mode_iterator X87MODEI [HI SI DI])
618 ;; All integer modes handled by integer x87 operators.
619 (define_mode_iterator X87MODEI12 [HI SI])
621 ;; All integer modes handled by SSE cvtts?2si* operators.
622 (define_mode_iterator SSEMODEI24 [SI DI])
624 ;; SSE asm suffix for floating point modes
625 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
627 ;; SSE vector mode corresponding to a scalar mode
628 (define_mode_attr ssevecmode
629 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
631 ;; Instruction suffix for REX 64bit operators.
632 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
634 ;; This mode iterator allows :P to be used for patterns that operate on
635 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
636 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
639 ;; Scheduling descriptions
641 (include "pentium.md")
644 (include "athlon.md")
648 ;; Operand and operator predicates and constraints
650 (include "predicates.md")
651 (include "constraints.md")
654 ;; Compare instructions.
656 ;; All compare insns have expanders that save the operands away without
657 ;; actually generating RTL. The bCOND or sCOND (emitted immediately
658 ;; after the cmp) will actually emit the cmpM.
660 (define_expand "cmpti"
661 [(set (reg:CC FLAGS_REG)
662 (compare:CC (match_operand:TI 0 "nonimmediate_operand" "")
663 (match_operand:TI 1 "x86_64_general_operand" "")))]
666 if (MEM_P (operands[0]) && MEM_P (operands[1]))
667 operands[0] = force_reg (TImode, operands[0]);
668 ix86_compare_op0 = operands[0];
669 ix86_compare_op1 = operands[1];
673 (define_expand "cmpdi"
674 [(set (reg:CC FLAGS_REG)
675 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
676 (match_operand:DI 1 "x86_64_general_operand" "")))]
679 if (MEM_P (operands[0]) && MEM_P (operands[1]))
680 operands[0] = force_reg (DImode, operands[0]);
681 ix86_compare_op0 = operands[0];
682 ix86_compare_op1 = operands[1];
686 (define_expand "cmpsi"
687 [(set (reg:CC FLAGS_REG)
688 (compare:CC (match_operand:SI 0 "cmpsi_operand" "")
689 (match_operand:SI 1 "general_operand" "")))]
692 if (MEM_P (operands[0]) && MEM_P (operands[1]))
693 operands[0] = force_reg (SImode, operands[0]);
694 ix86_compare_op0 = operands[0];
695 ix86_compare_op1 = operands[1];
699 (define_expand "cmphi"
700 [(set (reg:CC FLAGS_REG)
701 (compare:CC (match_operand:HI 0 "nonimmediate_operand" "")
702 (match_operand:HI 1 "general_operand" "")))]
705 if (MEM_P (operands[0]) && MEM_P (operands[1]))
706 operands[0] = force_reg (HImode, operands[0]);
707 ix86_compare_op0 = operands[0];
708 ix86_compare_op1 = operands[1];
712 (define_expand "cmpqi"
713 [(set (reg:CC FLAGS_REG)
714 (compare:CC (match_operand:QI 0 "nonimmediate_operand" "")
715 (match_operand:QI 1 "general_operand" "")))]
718 if (MEM_P (operands[0]) && MEM_P (operands[1]))
719 operands[0] = force_reg (QImode, operands[0]);
720 ix86_compare_op0 = operands[0];
721 ix86_compare_op1 = operands[1];
725 (define_insn "cmpdi_ccno_1_rex64"
726 [(set (reg FLAGS_REG)
727 (compare (match_operand:DI 0 "nonimmediate_operand" "r,?mr")
728 (match_operand:DI 1 "const0_operand" "n,n")))]
729 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
732 cmp{q}\t{%1, %0|%0, %1}"
733 [(set_attr "type" "test,icmp")
734 (set_attr "length_immediate" "0,1")
735 (set_attr "mode" "DI")])
737 (define_insn "*cmpdi_minus_1_rex64"
738 [(set (reg FLAGS_REG)
739 (compare (minus:DI (match_operand:DI 0 "nonimmediate_operand" "rm,r")
740 (match_operand:DI 1 "x86_64_general_operand" "re,mr"))
742 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)"
743 "cmp{q}\t{%1, %0|%0, %1}"
744 [(set_attr "type" "icmp")
745 (set_attr "mode" "DI")])
747 (define_expand "cmpdi_1_rex64"
748 [(set (reg:CC FLAGS_REG)
749 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
750 (match_operand:DI 1 "general_operand" "")))]
754 (define_insn "cmpdi_1_insn_rex64"
755 [(set (reg FLAGS_REG)
756 (compare (match_operand:DI 0 "nonimmediate_operand" "mr,r")
757 (match_operand:DI 1 "x86_64_general_operand" "re,mr")))]
758 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
759 "cmp{q}\t{%1, %0|%0, %1}"
760 [(set_attr "type" "icmp")
761 (set_attr "mode" "DI")])
764 (define_insn "*cmpsi_ccno_1"
765 [(set (reg FLAGS_REG)
766 (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr")
767 (match_operand:SI 1 "const0_operand" "n,n")))]
768 "ix86_match_ccmode (insn, CCNOmode)"
771 cmp{l}\t{%1, %0|%0, %1}"
772 [(set_attr "type" "test,icmp")
773 (set_attr "length_immediate" "0,1")
774 (set_attr "mode" "SI")])
776 (define_insn "*cmpsi_minus_1"
777 [(set (reg FLAGS_REG)
778 (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r")
779 (match_operand:SI 1 "general_operand" "ri,mr"))
781 "ix86_match_ccmode (insn, CCGOCmode)"
782 "cmp{l}\t{%1, %0|%0, %1}"
783 [(set_attr "type" "icmp")
784 (set_attr "mode" "SI")])
786 (define_expand "cmpsi_1"
787 [(set (reg:CC FLAGS_REG)
788 (compare:CC (match_operand:SI 0 "nonimmediate_operand" "")
789 (match_operand:SI 1 "general_operand" "")))]
793 (define_insn "*cmpsi_1_insn"
794 [(set (reg FLAGS_REG)
795 (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r")
796 (match_operand:SI 1 "general_operand" "ri,mr")))]
797 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
798 && ix86_match_ccmode (insn, CCmode)"
799 "cmp{l}\t{%1, %0|%0, %1}"
800 [(set_attr "type" "icmp")
801 (set_attr "mode" "SI")])
803 (define_insn "*cmphi_ccno_1"
804 [(set (reg FLAGS_REG)
805 (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr")
806 (match_operand:HI 1 "const0_operand" "n,n")))]
807 "ix86_match_ccmode (insn, CCNOmode)"
810 cmp{w}\t{%1, %0|%0, %1}"
811 [(set_attr "type" "test,icmp")
812 (set_attr "length_immediate" "0,1")
813 (set_attr "mode" "HI")])
815 (define_insn "*cmphi_minus_1"
816 [(set (reg FLAGS_REG)
817 (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r")
818 (match_operand:HI 1 "general_operand" "ri,mr"))
820 "ix86_match_ccmode (insn, CCGOCmode)"
821 "cmp{w}\t{%1, %0|%0, %1}"
822 [(set_attr "type" "icmp")
823 (set_attr "mode" "HI")])
825 (define_insn "*cmphi_1"
826 [(set (reg FLAGS_REG)
827 (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r")
828 (match_operand:HI 1 "general_operand" "ri,mr")))]
829 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
830 && ix86_match_ccmode (insn, CCmode)"
831 "cmp{w}\t{%1, %0|%0, %1}"
832 [(set_attr "type" "icmp")
833 (set_attr "mode" "HI")])
835 (define_insn "*cmpqi_ccno_1"
836 [(set (reg FLAGS_REG)
837 (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq")
838 (match_operand:QI 1 "const0_operand" "n,n")))]
839 "ix86_match_ccmode (insn, CCNOmode)"
842 cmp{b}\t{$0, %0|%0, 0}"
843 [(set_attr "type" "test,icmp")
844 (set_attr "length_immediate" "0,1")
845 (set_attr "mode" "QI")])
847 (define_insn "*cmpqi_1"
848 [(set (reg FLAGS_REG)
849 (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q")
850 (match_operand:QI 1 "general_operand" "qi,mq")))]
851 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
852 && ix86_match_ccmode (insn, CCmode)"
853 "cmp{b}\t{%1, %0|%0, %1}"
854 [(set_attr "type" "icmp")
855 (set_attr "mode" "QI")])
857 (define_insn "*cmpqi_minus_1"
858 [(set (reg FLAGS_REG)
859 (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q")
860 (match_operand:QI 1 "general_operand" "qi,mq"))
862 "ix86_match_ccmode (insn, CCGOCmode)"
863 "cmp{b}\t{%1, %0|%0, %1}"
864 [(set_attr "type" "icmp")
865 (set_attr "mode" "QI")])
867 (define_insn "*cmpqi_ext_1"
868 [(set (reg FLAGS_REG)
870 (match_operand:QI 0 "general_operand" "Qm")
873 (match_operand 1 "ext_register_operand" "Q")
876 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
877 "cmp{b}\t{%h1, %0|%0, %h1}"
878 [(set_attr "type" "icmp")
879 (set_attr "mode" "QI")])
881 (define_insn "*cmpqi_ext_1_rex64"
882 [(set (reg FLAGS_REG)
884 (match_operand:QI 0 "register_operand" "Q")
887 (match_operand 1 "ext_register_operand" "Q")
890 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
891 "cmp{b}\t{%h1, %0|%0, %h1}"
892 [(set_attr "type" "icmp")
893 (set_attr "mode" "QI")])
895 (define_insn "*cmpqi_ext_2"
896 [(set (reg FLAGS_REG)
900 (match_operand 0 "ext_register_operand" "Q")
903 (match_operand:QI 1 "const0_operand" "n")))]
904 "ix86_match_ccmode (insn, CCNOmode)"
906 [(set_attr "type" "test")
907 (set_attr "length_immediate" "0")
908 (set_attr "mode" "QI")])
910 (define_expand "cmpqi_ext_3"
911 [(set (reg:CC FLAGS_REG)
915 (match_operand 0 "ext_register_operand" "")
918 (match_operand:QI 1 "general_operand" "")))]
922 (define_insn "cmpqi_ext_3_insn"
923 [(set (reg FLAGS_REG)
927 (match_operand 0 "ext_register_operand" "Q")
930 (match_operand:QI 1 "general_operand" "Qmn")))]
931 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
932 "cmp{b}\t{%1, %h0|%h0, %1}"
933 [(set_attr "type" "icmp")
934 (set_attr "mode" "QI")])
936 (define_insn "cmpqi_ext_3_insn_rex64"
937 [(set (reg FLAGS_REG)
941 (match_operand 0 "ext_register_operand" "Q")
944 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
945 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
946 "cmp{b}\t{%1, %h0|%h0, %1}"
947 [(set_attr "type" "icmp")
948 (set_attr "mode" "QI")])
950 (define_insn "*cmpqi_ext_4"
951 [(set (reg FLAGS_REG)
955 (match_operand 0 "ext_register_operand" "Q")
960 (match_operand 1 "ext_register_operand" "Q")
963 "ix86_match_ccmode (insn, CCmode)"
964 "cmp{b}\t{%h1, %h0|%h0, %h1}"
965 [(set_attr "type" "icmp")
966 (set_attr "mode" "QI")])
968 ;; These implement float point compares.
969 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
970 ;; which would allow mix and match FP modes on the compares. Which is what
971 ;; the old patterns did, but with many more of them.
973 (define_expand "cmpxf"
974 [(set (reg:CC FLAGS_REG)
975 (compare:CC (match_operand:XF 0 "nonmemory_operand" "")
976 (match_operand:XF 1 "nonmemory_operand" "")))]
979 ix86_compare_op0 = operands[0];
980 ix86_compare_op1 = operands[1];
984 (define_expand "cmp<mode>"
985 [(set (reg:CC FLAGS_REG)
986 (compare:CC (match_operand:MODEF 0 "cmp_fp_expander_operand" "")
987 (match_operand:MODEF 1 "cmp_fp_expander_operand" "")))]
988 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
990 ix86_compare_op0 = operands[0];
991 ix86_compare_op1 = operands[1];
995 ;; FP compares, step 1:
996 ;; Set the FP condition codes.
998 ;; CCFPmode compare with exceptions
999 ;; CCFPUmode compare with no exceptions
1001 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1002 ;; used to manage the reg stack popping would not be preserved.
1004 (define_insn "*cmpfp_0"
1005 [(set (match_operand:HI 0 "register_operand" "=a")
1008 (match_operand 1 "register_operand" "f")
1009 (match_operand 2 "const0_operand" "X"))]
1011 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1012 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1013 "* return output_fp_compare (insn, operands, 0, 0);"
1014 [(set_attr "type" "multi")
1015 (set_attr "unit" "i387")
1017 (cond [(match_operand:SF 1 "" "")
1019 (match_operand:DF 1 "" "")
1022 (const_string "XF")))])
1024 (define_insn_and_split "*cmpfp_0_cc"
1025 [(set (reg:CCFP FLAGS_REG)
1027 (match_operand 1 "register_operand" "f")
1028 (match_operand 2 "const0_operand" "X")))
1029 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1030 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1031 && TARGET_SAHF && !TARGET_CMOVE
1032 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1034 "&& reload_completed"
1037 [(compare:CCFP (match_dup 1)(match_dup 2))]
1039 (set (reg:CC FLAGS_REG)
1040 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1042 [(set_attr "type" "multi")
1043 (set_attr "unit" "i387")
1045 (cond [(match_operand:SF 1 "" "")
1047 (match_operand:DF 1 "" "")
1050 (const_string "XF")))])
1052 (define_insn "*cmpfp_xf"
1053 [(set (match_operand:HI 0 "register_operand" "=a")
1056 (match_operand:XF 1 "register_operand" "f")
1057 (match_operand:XF 2 "register_operand" "f"))]
1060 "* return output_fp_compare (insn, operands, 0, 0);"
1061 [(set_attr "type" "multi")
1062 (set_attr "unit" "i387")
1063 (set_attr "mode" "XF")])
1065 (define_insn_and_split "*cmpfp_xf_cc"
1066 [(set (reg:CCFP FLAGS_REG)
1068 (match_operand:XF 1 "register_operand" "f")
1069 (match_operand:XF 2 "register_operand" "f")))
1070 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1072 && TARGET_SAHF && !TARGET_CMOVE"
1074 "&& reload_completed"
1077 [(compare:CCFP (match_dup 1)(match_dup 2))]
1079 (set (reg:CC FLAGS_REG)
1080 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1082 [(set_attr "type" "multi")
1083 (set_attr "unit" "i387")
1084 (set_attr "mode" "XF")])
1086 (define_insn "*cmpfp_<mode>"
1087 [(set (match_operand:HI 0 "register_operand" "=a")
1090 (match_operand:MODEF 1 "register_operand" "f")
1091 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1094 "* return output_fp_compare (insn, operands, 0, 0);"
1095 [(set_attr "type" "multi")
1096 (set_attr "unit" "i387")
1097 (set_attr "mode" "<MODE>")])
1099 (define_insn_and_split "*cmpfp_<mode>_cc"
1100 [(set (reg:CCFP FLAGS_REG)
1102 (match_operand:MODEF 1 "register_operand" "f")
1103 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1104 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1106 && TARGET_SAHF && !TARGET_CMOVE"
1108 "&& reload_completed"
1111 [(compare:CCFP (match_dup 1)(match_dup 2))]
1113 (set (reg:CC FLAGS_REG)
1114 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1116 [(set_attr "type" "multi")
1117 (set_attr "unit" "i387")
1118 (set_attr "mode" "<MODE>")])
1120 (define_insn "*cmpfp_u"
1121 [(set (match_operand:HI 0 "register_operand" "=a")
1124 (match_operand 1 "register_operand" "f")
1125 (match_operand 2 "register_operand" "f"))]
1127 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1128 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1129 "* return output_fp_compare (insn, operands, 0, 1);"
1130 [(set_attr "type" "multi")
1131 (set_attr "unit" "i387")
1133 (cond [(match_operand:SF 1 "" "")
1135 (match_operand:DF 1 "" "")
1138 (const_string "XF")))])
1140 (define_insn_and_split "*cmpfp_u_cc"
1141 [(set (reg:CCFPU FLAGS_REG)
1143 (match_operand 1 "register_operand" "f")
1144 (match_operand 2 "register_operand" "f")))
1145 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1146 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1147 && TARGET_SAHF && !TARGET_CMOVE
1148 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1150 "&& reload_completed"
1153 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1155 (set (reg:CC FLAGS_REG)
1156 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1158 [(set_attr "type" "multi")
1159 (set_attr "unit" "i387")
1161 (cond [(match_operand:SF 1 "" "")
1163 (match_operand:DF 1 "" "")
1166 (const_string "XF")))])
1168 (define_insn "*cmpfp_<mode>"
1169 [(set (match_operand:HI 0 "register_operand" "=a")
1172 (match_operand 1 "register_operand" "f")
1173 (match_operator 3 "float_operator"
1174 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1176 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1177 && (TARGET_USE_<MODE>MODE_FIOP || optimize_size)
1178 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1179 "* return output_fp_compare (insn, operands, 0, 0);"
1180 [(set_attr "type" "multi")
1181 (set_attr "unit" "i387")
1182 (set_attr "fp_int_src" "true")
1183 (set_attr "mode" "<MODE>")])
1185 (define_insn_and_split "*cmpfp_<mode>_cc"
1186 [(set (reg:CCFP FLAGS_REG)
1188 (match_operand 1 "register_operand" "f")
1189 (match_operator 3 "float_operator"
1190 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1191 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1192 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1193 && TARGET_SAHF && !TARGET_CMOVE
1194 && (TARGET_USE_<MODE>MODE_FIOP || optimize_size)
1195 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1197 "&& reload_completed"
1202 (match_op_dup 3 [(match_dup 2)]))]
1204 (set (reg:CC FLAGS_REG)
1205 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1207 [(set_attr "type" "multi")
1208 (set_attr "unit" "i387")
1209 (set_attr "fp_int_src" "true")
1210 (set_attr "mode" "<MODE>")])
1212 ;; FP compares, step 2
1213 ;; Move the fpsw to ax.
1215 (define_insn "x86_fnstsw_1"
1216 [(set (match_operand:HI 0 "register_operand" "=a")
1217 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1220 [(set_attr "length" "2")
1221 (set_attr "mode" "SI")
1222 (set_attr "unit" "i387")])
1224 ;; FP compares, step 3
1225 ;; Get ax into flags, general case.
1227 (define_insn "x86_sahf_1"
1228 [(set (reg:CC FLAGS_REG)
1229 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1233 #ifdef HAVE_AS_IX86_SAHF
1236 return ".byte\t0x9e";
1239 [(set_attr "length" "1")
1240 (set_attr "athlon_decode" "vector")
1241 (set_attr "amdfam10_decode" "direct")
1242 (set_attr "mode" "SI")])
1244 ;; Pentium Pro can do steps 1 through 3 in one go.
1245 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1246 (define_insn "*cmpfp_i_mixed"
1247 [(set (reg:CCFP FLAGS_REG)
1248 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1249 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1250 "TARGET_MIX_SSE_I387
1251 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1252 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1253 "* return output_fp_compare (insn, operands, 1, 0);"
1254 [(set_attr "type" "fcmp,ssecomi")
1256 (if_then_else (match_operand:SF 1 "" "")
1258 (const_string "DF")))
1259 (set_attr "athlon_decode" "vector")
1260 (set_attr "amdfam10_decode" "direct")])
1262 (define_insn "*cmpfp_i_sse"
1263 [(set (reg:CCFP FLAGS_REG)
1264 (compare:CCFP (match_operand 0 "register_operand" "x")
1265 (match_operand 1 "nonimmediate_operand" "xm")))]
1267 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1268 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1269 "* return output_fp_compare (insn, operands, 1, 0);"
1270 [(set_attr "type" "ssecomi")
1272 (if_then_else (match_operand:SF 1 "" "")
1274 (const_string "DF")))
1275 (set_attr "athlon_decode" "vector")
1276 (set_attr "amdfam10_decode" "direct")])
1278 (define_insn "*cmpfp_i_i387"
1279 [(set (reg:CCFP FLAGS_REG)
1280 (compare:CCFP (match_operand 0 "register_operand" "f")
1281 (match_operand 1 "register_operand" "f")))]
1282 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1284 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1285 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1286 "* return output_fp_compare (insn, operands, 1, 0);"
1287 [(set_attr "type" "fcmp")
1289 (cond [(match_operand:SF 1 "" "")
1291 (match_operand:DF 1 "" "")
1294 (const_string "XF")))
1295 (set_attr "athlon_decode" "vector")
1296 (set_attr "amdfam10_decode" "direct")])
1298 (define_insn "*cmpfp_iu_mixed"
1299 [(set (reg:CCFPU FLAGS_REG)
1300 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1301 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1302 "TARGET_MIX_SSE_I387
1303 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1304 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1305 "* return output_fp_compare (insn, operands, 1, 1);"
1306 [(set_attr "type" "fcmp,ssecomi")
1308 (if_then_else (match_operand:SF 1 "" "")
1310 (const_string "DF")))
1311 (set_attr "athlon_decode" "vector")
1312 (set_attr "amdfam10_decode" "direct")])
1314 (define_insn "*cmpfp_iu_sse"
1315 [(set (reg:CCFPU FLAGS_REG)
1316 (compare:CCFPU (match_operand 0 "register_operand" "x")
1317 (match_operand 1 "nonimmediate_operand" "xm")))]
1319 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1320 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1321 "* return output_fp_compare (insn, operands, 1, 1);"
1322 [(set_attr "type" "ssecomi")
1324 (if_then_else (match_operand:SF 1 "" "")
1326 (const_string "DF")))
1327 (set_attr "athlon_decode" "vector")
1328 (set_attr "amdfam10_decode" "direct")])
1330 (define_insn "*cmpfp_iu_387"
1331 [(set (reg:CCFPU FLAGS_REG)
1332 (compare:CCFPU (match_operand 0 "register_operand" "f")
1333 (match_operand 1 "register_operand" "f")))]
1334 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1336 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1337 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1338 "* return output_fp_compare (insn, operands, 1, 1);"
1339 [(set_attr "type" "fcmp")
1341 (cond [(match_operand:SF 1 "" "")
1343 (match_operand:DF 1 "" "")
1346 (const_string "XF")))
1347 (set_attr "athlon_decode" "vector")
1348 (set_attr "amdfam10_decode" "direct")])
1350 ;; Move instructions.
1352 ;; General case of fullword move.
1354 (define_expand "movsi"
1355 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1356 (match_operand:SI 1 "general_operand" ""))]
1358 "ix86_expand_move (SImode, operands); DONE;")
1360 ;; Push/pop instructions. They are separate since autoinc/dec is not a
1363 ;; %%% We don't use a post-inc memory reference because x86 is not a
1364 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1365 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1366 ;; targets without our curiosities, and it is just as easy to represent
1367 ;; this differently.
1369 (define_insn "*pushsi2"
1370 [(set (match_operand:SI 0 "push_operand" "=<")
1371 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1374 [(set_attr "type" "push")
1375 (set_attr "mode" "SI")])
1377 ;; For 64BIT abi we always round up to 8 bytes.
1378 (define_insn "*pushsi2_rex64"
1379 [(set (match_operand:SI 0 "push_operand" "=X")
1380 (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1383 [(set_attr "type" "push")
1384 (set_attr "mode" "SI")])
1386 (define_insn "*pushsi2_prologue"
1387 [(set (match_operand:SI 0 "push_operand" "=<")
1388 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1389 (clobber (mem:BLK (scratch)))]
1392 [(set_attr "type" "push")
1393 (set_attr "mode" "SI")])
1395 (define_insn "*popsi1_epilogue"
1396 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1397 (mem:SI (reg:SI SP_REG)))
1398 (set (reg:SI SP_REG)
1399 (plus:SI (reg:SI SP_REG) (const_int 4)))
1400 (clobber (mem:BLK (scratch)))]
1403 [(set_attr "type" "pop")
1404 (set_attr "mode" "SI")])
1406 (define_insn "popsi1"
1407 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1408 (mem:SI (reg:SI SP_REG)))
1409 (set (reg:SI SP_REG)
1410 (plus:SI (reg:SI SP_REG) (const_int 4)))]
1413 [(set_attr "type" "pop")
1414 (set_attr "mode" "SI")])
1416 (define_insn "*movsi_xor"
1417 [(set (match_operand:SI 0 "register_operand" "=r")
1418 (match_operand:SI 1 "const0_operand" "i"))
1419 (clobber (reg:CC FLAGS_REG))]
1420 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1422 [(set_attr "type" "alu1")
1423 (set_attr "mode" "SI")
1424 (set_attr "length_immediate" "0")])
1426 (define_insn "*movsi_or"
1427 [(set (match_operand:SI 0 "register_operand" "=r")
1428 (match_operand:SI 1 "immediate_operand" "i"))
1429 (clobber (reg:CC FLAGS_REG))]
1431 && operands[1] == constm1_rtx
1432 && (TARGET_MOVE_M1_VIA_OR || optimize_size)"
1434 operands[1] = constm1_rtx;
1435 return "or{l}\t{%1, %0|%0, %1}";
1437 [(set_attr "type" "alu1")
1438 (set_attr "mode" "SI")
1439 (set_attr "length_immediate" "1")])
1441 (define_insn "*movsi_1"
1442 [(set (match_operand:SI 0 "nonimmediate_operand"
1443 "=r ,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
1444 (match_operand:SI 1 "general_operand"
1445 "rinm,rin,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
1446 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1448 switch (get_attr_type (insn))
1451 if (get_attr_mode (insn) == MODE_TI)
1452 return "pxor\t%0, %0";
1453 return "xorps\t%0, %0";
1456 switch (get_attr_mode (insn))
1459 return "movdqa\t{%1, %0|%0, %1}";
1461 return "movaps\t{%1, %0|%0, %1}";
1463 return "movd\t{%1, %0|%0, %1}";
1465 return "movss\t{%1, %0|%0, %1}";
1471 return "pxor\t%0, %0";
1474 if (get_attr_mode (insn) == MODE_DI)
1475 return "movq\t{%1, %0|%0, %1}";
1476 return "movd\t{%1, %0|%0, %1}";
1479 return "lea{l}\t{%1, %0|%0, %1}";
1482 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
1483 return "mov{l}\t{%1, %0|%0, %1}";
1487 (cond [(eq_attr "alternative" "2")
1488 (const_string "mmxadd")
1489 (eq_attr "alternative" "3,4,5")
1490 (const_string "mmxmov")
1491 (eq_attr "alternative" "6")
1492 (const_string "sselog1")
1493 (eq_attr "alternative" "7,8,9,10,11")
1494 (const_string "ssemov")
1495 (match_operand:DI 1 "pic_32bit_operand" "")
1496 (const_string "lea")
1498 (const_string "imov")))
1500 (cond [(eq_attr "alternative" "2,3")
1502 (eq_attr "alternative" "6,7")
1504 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1505 (const_string "V4SF")
1506 (const_string "TI"))
1507 (and (eq_attr "alternative" "8,9,10,11")
1508 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
1511 (const_string "SI")))])
1513 ;; Stores and loads of ax to arbitrary constant address.
1514 ;; We fake an second form of instruction to force reload to load address
1515 ;; into register when rax is not available
1516 (define_insn "*movabssi_1_rex64"
1517 [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1518 (match_operand:SI 1 "nonmemory_operand" "a,er"))]
1519 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1521 movabs{l}\t{%1, %P0|%P0, %1}
1522 mov{l}\t{%1, %a0|%a0, %1}"
1523 [(set_attr "type" "imov")
1524 (set_attr "modrm" "0,*")
1525 (set_attr "length_address" "8,0")
1526 (set_attr "length_immediate" "0,*")
1527 (set_attr "memory" "store")
1528 (set_attr "mode" "SI")])
1530 (define_insn "*movabssi_2_rex64"
1531 [(set (match_operand:SI 0 "register_operand" "=a,r")
1532 (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1533 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1535 movabs{l}\t{%P1, %0|%0, %P1}
1536 mov{l}\t{%a1, %0|%0, %a1}"
1537 [(set_attr "type" "imov")
1538 (set_attr "modrm" "0,*")
1539 (set_attr "length_address" "8,0")
1540 (set_attr "length_immediate" "0")
1541 (set_attr "memory" "load")
1542 (set_attr "mode" "SI")])
1544 (define_insn "*swapsi"
1545 [(set (match_operand:SI 0 "register_operand" "+r")
1546 (match_operand:SI 1 "register_operand" "+r"))
1551 [(set_attr "type" "imov")
1552 (set_attr "mode" "SI")
1553 (set_attr "pent_pair" "np")
1554 (set_attr "athlon_decode" "vector")
1555 (set_attr "amdfam10_decode" "double")])
1557 (define_expand "movhi"
1558 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1559 (match_operand:HI 1 "general_operand" ""))]
1561 "ix86_expand_move (HImode, operands); DONE;")
1563 (define_insn "*pushhi2"
1564 [(set (match_operand:HI 0 "push_operand" "=X")
1565 (match_operand:HI 1 "nonmemory_no_elim_operand" "rn"))]
1568 [(set_attr "type" "push")
1569 (set_attr "mode" "SI")])
1571 ;; For 64BIT abi we always round up to 8 bytes.
1572 (define_insn "*pushhi2_rex64"
1573 [(set (match_operand:HI 0 "push_operand" "=X")
1574 (match_operand:HI 1 "nonmemory_no_elim_operand" "ri"))]
1577 [(set_attr "type" "push")
1578 (set_attr "mode" "DI")])
1580 (define_insn "*movhi_1"
1581 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
1582 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
1583 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1585 switch (get_attr_type (insn))
1588 /* movzwl is faster than movw on p2 due to partial word stalls,
1589 though not as fast as an aligned movl. */
1590 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1592 if (get_attr_mode (insn) == MODE_SI)
1593 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1595 return "mov{w}\t{%1, %0|%0, %1}";
1599 (cond [(ne (symbol_ref "optimize_size") (const_int 0))
1600 (const_string "imov")
1601 (and (eq_attr "alternative" "0")
1602 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1604 (eq (symbol_ref "TARGET_HIMODE_MATH")
1606 (const_string "imov")
1607 (and (eq_attr "alternative" "1,2")
1608 (match_operand:HI 1 "aligned_operand" ""))
1609 (const_string "imov")
1610 (and (ne (symbol_ref "TARGET_MOVX")
1612 (eq_attr "alternative" "0,2"))
1613 (const_string "imovx")
1615 (const_string "imov")))
1617 (cond [(eq_attr "type" "imovx")
1619 (and (eq_attr "alternative" "1,2")
1620 (match_operand:HI 1 "aligned_operand" ""))
1622 (and (eq_attr "alternative" "0")
1623 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1625 (eq (symbol_ref "TARGET_HIMODE_MATH")
1629 (const_string "HI")))])
1631 ;; Stores and loads of ax to arbitrary constant address.
1632 ;; We fake an second form of instruction to force reload to load address
1633 ;; into register when rax is not available
1634 (define_insn "*movabshi_1_rex64"
1635 [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1636 (match_operand:HI 1 "nonmemory_operand" "a,er"))]
1637 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1639 movabs{w}\t{%1, %P0|%P0, %1}
1640 mov{w}\t{%1, %a0|%a0, %1}"
1641 [(set_attr "type" "imov")
1642 (set_attr "modrm" "0,*")
1643 (set_attr "length_address" "8,0")
1644 (set_attr "length_immediate" "0,*")
1645 (set_attr "memory" "store")
1646 (set_attr "mode" "HI")])
1648 (define_insn "*movabshi_2_rex64"
1649 [(set (match_operand:HI 0 "register_operand" "=a,r")
1650 (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1651 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1653 movabs{w}\t{%P1, %0|%0, %P1}
1654 mov{w}\t{%a1, %0|%0, %a1}"
1655 [(set_attr "type" "imov")
1656 (set_attr "modrm" "0,*")
1657 (set_attr "length_address" "8,0")
1658 (set_attr "length_immediate" "0")
1659 (set_attr "memory" "load")
1660 (set_attr "mode" "HI")])
1662 (define_insn "*swaphi_1"
1663 [(set (match_operand:HI 0 "register_operand" "+r")
1664 (match_operand:HI 1 "register_operand" "+r"))
1667 "!TARGET_PARTIAL_REG_STALL || optimize_size"
1669 [(set_attr "type" "imov")
1670 (set_attr "mode" "SI")
1671 (set_attr "pent_pair" "np")
1672 (set_attr "athlon_decode" "vector")
1673 (set_attr "amdfam10_decode" "double")])
1675 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
1676 (define_insn "*swaphi_2"
1677 [(set (match_operand:HI 0 "register_operand" "+r")
1678 (match_operand:HI 1 "register_operand" "+r"))
1681 "TARGET_PARTIAL_REG_STALL"
1683 [(set_attr "type" "imov")
1684 (set_attr "mode" "HI")
1685 (set_attr "pent_pair" "np")
1686 (set_attr "athlon_decode" "vector")])
1688 (define_expand "movstricthi"
1689 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1690 (match_operand:HI 1 "general_operand" ""))]
1691 "! TARGET_PARTIAL_REG_STALL || optimize_size"
1693 /* Don't generate memory->memory moves, go through a register */
1694 if (MEM_P (operands[0]) && MEM_P (operands[1]))
1695 operands[1] = force_reg (HImode, operands[1]);
1698 (define_insn "*movstricthi_1"
1699 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1700 (match_operand:HI 1 "general_operand" "rn,m"))]
1701 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1702 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1703 "mov{w}\t{%1, %0|%0, %1}"
1704 [(set_attr "type" "imov")
1705 (set_attr "mode" "HI")])
1707 (define_insn "*movstricthi_xor"
1708 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1709 (match_operand:HI 1 "const0_operand" "i"))
1710 (clobber (reg:CC FLAGS_REG))]
1712 && ((!TARGET_USE_MOV0 && !TARGET_PARTIAL_REG_STALL) || optimize_size)"
1714 [(set_attr "type" "alu1")
1715 (set_attr "mode" "HI")
1716 (set_attr "length_immediate" "0")])
1718 (define_expand "movqi"
1719 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1720 (match_operand:QI 1 "general_operand" ""))]
1722 "ix86_expand_move (QImode, operands); DONE;")
1724 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1725 ;; "push a byte". But actually we use pushl, which has the effect
1726 ;; of rounding the amount pushed up to a word.
1728 (define_insn "*pushqi2"
1729 [(set (match_operand:QI 0 "push_operand" "=X")
1730 (match_operand:QI 1 "nonmemory_no_elim_operand" "rn"))]
1733 [(set_attr "type" "push")
1734 (set_attr "mode" "SI")])
1736 ;; For 64BIT abi we always round up to 8 bytes.
1737 (define_insn "*pushqi2_rex64"
1738 [(set (match_operand:QI 0 "push_operand" "=X")
1739 (match_operand:QI 1 "nonmemory_no_elim_operand" "qi"))]
1742 [(set_attr "type" "push")
1743 (set_attr "mode" "DI")])
1745 ;; Situation is quite tricky about when to choose full sized (SImode) move
1746 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
1747 ;; partial register dependency machines (such as AMD Athlon), where QImode
1748 ;; moves issue extra dependency and for partial register stalls machines
1749 ;; that don't use QImode patterns (and QImode move cause stall on the next
1752 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
1753 ;; register stall machines with, where we use QImode instructions, since
1754 ;; partial register stall can be caused there. Then we use movzx.
1755 (define_insn "*movqi_1"
1756 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
1757 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
1758 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1760 switch (get_attr_type (insn))
1763 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
1764 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
1766 if (get_attr_mode (insn) == MODE_SI)
1767 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1769 return "mov{b}\t{%1, %0|%0, %1}";
1773 (cond [(and (eq_attr "alternative" "5")
1774 (not (match_operand:QI 1 "aligned_operand" "")))
1775 (const_string "imovx")
1776 (ne (symbol_ref "optimize_size") (const_int 0))
1777 (const_string "imov")
1778 (and (eq_attr "alternative" "3")
1779 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1781 (eq (symbol_ref "TARGET_QIMODE_MATH")
1783 (const_string "imov")
1784 (eq_attr "alternative" "3,5")
1785 (const_string "imovx")
1786 (and (ne (symbol_ref "TARGET_MOVX")
1788 (eq_attr "alternative" "2"))
1789 (const_string "imovx")
1791 (const_string "imov")))
1793 (cond [(eq_attr "alternative" "3,4,5")
1795 (eq_attr "alternative" "6")
1797 (eq_attr "type" "imovx")
1799 (and (eq_attr "type" "imov")
1800 (and (eq_attr "alternative" "0,1")
1801 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
1803 (and (eq (symbol_ref "optimize_size")
1805 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1808 ;; Avoid partial register stalls when not using QImode arithmetic
1809 (and (eq_attr "type" "imov")
1810 (and (eq_attr "alternative" "0,1")
1811 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
1813 (eq (symbol_ref "TARGET_QIMODE_MATH")
1817 (const_string "QI")))])
1819 (define_insn "*swapqi_1"
1820 [(set (match_operand:QI 0 "register_operand" "+r")
1821 (match_operand:QI 1 "register_operand" "+r"))
1824 "!TARGET_PARTIAL_REG_STALL || optimize_size"
1826 [(set_attr "type" "imov")
1827 (set_attr "mode" "SI")
1828 (set_attr "pent_pair" "np")
1829 (set_attr "athlon_decode" "vector")
1830 (set_attr "amdfam10_decode" "vector")])
1832 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
1833 (define_insn "*swapqi_2"
1834 [(set (match_operand:QI 0 "register_operand" "+q")
1835 (match_operand:QI 1 "register_operand" "+q"))
1838 "TARGET_PARTIAL_REG_STALL"
1840 [(set_attr "type" "imov")
1841 (set_attr "mode" "QI")
1842 (set_attr "pent_pair" "np")
1843 (set_attr "athlon_decode" "vector")])
1845 (define_expand "movstrictqi"
1846 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
1847 (match_operand:QI 1 "general_operand" ""))]
1848 "! TARGET_PARTIAL_REG_STALL || optimize_size"
1850 /* Don't generate memory->memory moves, go through a register. */
1851 if (MEM_P (operands[0]) && MEM_P (operands[1]))
1852 operands[1] = force_reg (QImode, operands[1]);
1855 (define_insn "*movstrictqi_1"
1856 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
1857 (match_operand:QI 1 "general_operand" "*qn,m"))]
1858 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1859 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1860 "mov{b}\t{%1, %0|%0, %1}"
1861 [(set_attr "type" "imov")
1862 (set_attr "mode" "QI")])
1864 (define_insn "*movstrictqi_xor"
1865 [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
1866 (match_operand:QI 1 "const0_operand" "i"))
1867 (clobber (reg:CC FLAGS_REG))]
1868 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1870 [(set_attr "type" "alu1")
1871 (set_attr "mode" "QI")
1872 (set_attr "length_immediate" "0")])
1874 (define_insn "*movsi_extv_1"
1875 [(set (match_operand:SI 0 "register_operand" "=R")
1876 (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
1880 "movs{bl|x}\t{%h1, %0|%0, %h1}"
1881 [(set_attr "type" "imovx")
1882 (set_attr "mode" "SI")])
1884 (define_insn "*movhi_extv_1"
1885 [(set (match_operand:HI 0 "register_operand" "=R")
1886 (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
1890 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
1891 [(set_attr "type" "imovx")
1892 (set_attr "mode" "SI")])
1894 (define_insn "*movqi_extv_1"
1895 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
1896 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
1901 switch (get_attr_type (insn))
1904 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
1906 return "mov{b}\t{%h1, %0|%0, %h1}";
1910 (if_then_else (and (match_operand:QI 0 "register_operand" "")
1911 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1912 (ne (symbol_ref "TARGET_MOVX")
1914 (const_string "imovx")
1915 (const_string "imov")))
1917 (if_then_else (eq_attr "type" "imovx")
1919 (const_string "QI")))])
1921 (define_insn "*movqi_extv_1_rex64"
1922 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
1923 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
1928 switch (get_attr_type (insn))
1931 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
1933 return "mov{b}\t{%h1, %0|%0, %h1}";
1937 (if_then_else (and (match_operand:QI 0 "register_operand" "")
1938 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1939 (ne (symbol_ref "TARGET_MOVX")
1941 (const_string "imovx")
1942 (const_string "imov")))
1944 (if_then_else (eq_attr "type" "imovx")
1946 (const_string "QI")))])
1948 ;; Stores and loads of ax to arbitrary constant address.
1949 ;; We fake an second form of instruction to force reload to load address
1950 ;; into register when rax is not available
1951 (define_insn "*movabsqi_1_rex64"
1952 [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1953 (match_operand:QI 1 "nonmemory_operand" "a,er"))]
1954 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1956 movabs{b}\t{%1, %P0|%P0, %1}
1957 mov{b}\t{%1, %a0|%a0, %1}"
1958 [(set_attr "type" "imov")
1959 (set_attr "modrm" "0,*")
1960 (set_attr "length_address" "8,0")
1961 (set_attr "length_immediate" "0,*")
1962 (set_attr "memory" "store")
1963 (set_attr "mode" "QI")])
1965 (define_insn "*movabsqi_2_rex64"
1966 [(set (match_operand:QI 0 "register_operand" "=a,r")
1967 (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1968 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1970 movabs{b}\t{%P1, %0|%0, %P1}
1971 mov{b}\t{%a1, %0|%0, %a1}"
1972 [(set_attr "type" "imov")
1973 (set_attr "modrm" "0,*")
1974 (set_attr "length_address" "8,0")
1975 (set_attr "length_immediate" "0")
1976 (set_attr "memory" "load")
1977 (set_attr "mode" "QI")])
1979 (define_insn "*movdi_extzv_1"
1980 [(set (match_operand:DI 0 "register_operand" "=R")
1981 (zero_extract:DI (match_operand 1 "ext_register_operand" "Q")
1985 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
1986 [(set_attr "type" "imovx")
1987 (set_attr "mode" "DI")])
1989 (define_insn "*movsi_extzv_1"
1990 [(set (match_operand:SI 0 "register_operand" "=R")
1991 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
1995 "movz{bl|x}\t{%h1, %0|%0, %h1}"
1996 [(set_attr "type" "imovx")
1997 (set_attr "mode" "SI")])
1999 (define_insn "*movqi_extzv_2"
2000 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2001 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2006 switch (get_attr_type (insn))
2009 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2011 return "mov{b}\t{%h1, %0|%0, %h1}";
2015 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2016 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2017 (ne (symbol_ref "TARGET_MOVX")
2019 (const_string "imovx")
2020 (const_string "imov")))
2022 (if_then_else (eq_attr "type" "imovx")
2024 (const_string "QI")))])
2026 (define_insn "*movqi_extzv_2_rex64"
2027 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2028 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2033 switch (get_attr_type (insn))
2036 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2038 return "mov{b}\t{%h1, %0|%0, %h1}";
2042 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2043 (ne (symbol_ref "TARGET_MOVX")
2045 (const_string "imovx")
2046 (const_string "imov")))
2048 (if_then_else (eq_attr "type" "imovx")
2050 (const_string "QI")))])
2052 (define_insn "movsi_insv_1"
2053 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2056 (match_operand:SI 1 "general_operand" "Qmn"))]
2058 "mov{b}\t{%b1, %h0|%h0, %b1}"
2059 [(set_attr "type" "imov")
2060 (set_attr "mode" "QI")])
2062 (define_insn "*movsi_insv_1_rex64"
2063 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2066 (match_operand:SI 1 "nonmemory_operand" "Qn"))]
2068 "mov{b}\t{%b1, %h0|%h0, %b1}"
2069 [(set_attr "type" "imov")
2070 (set_attr "mode" "QI")])
2072 (define_insn "movdi_insv_1_rex64"
2073 [(set (zero_extract:DI (match_operand 0 "ext_register_operand" "+Q")
2076 (match_operand:DI 1 "nonmemory_operand" "Qn"))]
2078 "mov{b}\t{%b1, %h0|%h0, %b1}"
2079 [(set_attr "type" "imov")
2080 (set_attr "mode" "QI")])
2082 (define_insn "*movqi_insv_2"
2083 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2086 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2089 "mov{b}\t{%h1, %h0|%h0, %h1}"
2090 [(set_attr "type" "imov")
2091 (set_attr "mode" "QI")])
2093 (define_expand "movdi"
2094 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2095 (match_operand:DI 1 "general_operand" ""))]
2097 "ix86_expand_move (DImode, operands); DONE;")
2099 (define_insn "*pushdi"
2100 [(set (match_operand:DI 0 "push_operand" "=<")
2101 (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
2105 (define_insn "*pushdi2_rex64"
2106 [(set (match_operand:DI 0 "push_operand" "=<,!<")
2107 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
2112 [(set_attr "type" "push,multi")
2113 (set_attr "mode" "DI")])
2115 ;; Convert impossible pushes of immediate to existing instructions.
2116 ;; First try to get scratch register and go through it. In case this
2117 ;; fails, push sign extended lower part first and then overwrite
2118 ;; upper part by 32bit move.
2120 [(match_scratch:DI 2 "r")
2121 (set (match_operand:DI 0 "push_operand" "")
2122 (match_operand:DI 1 "immediate_operand" ""))]
2123 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2124 && !x86_64_immediate_operand (operands[1], DImode)"
2125 [(set (match_dup 2) (match_dup 1))
2126 (set (match_dup 0) (match_dup 2))]
2129 ;; We need to define this as both peepholer and splitter for case
2130 ;; peephole2 pass is not run.
2131 ;; "&& 1" is needed to keep it from matching the previous pattern.
2133 [(set (match_operand:DI 0 "push_operand" "")
2134 (match_operand:DI 1 "immediate_operand" ""))]
2135 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2136 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2137 [(set (match_dup 0) (match_dup 1))
2138 (set (match_dup 2) (match_dup 3))]
2139 "split_di (&operands[1], 1, &operands[2], &operands[3]);
2140 operands[1] = gen_lowpart (DImode, operands[2]);
2141 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2146 [(set (match_operand:DI 0 "push_operand" "")
2147 (match_operand:DI 1 "immediate_operand" ""))]
2148 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2149 ? epilogue_completed : reload_completed)
2150 && !symbolic_operand (operands[1], DImode)
2151 && !x86_64_immediate_operand (operands[1], DImode)"
2152 [(set (match_dup 0) (match_dup 1))
2153 (set (match_dup 2) (match_dup 3))]
2154 "split_di (&operands[1], 1, &operands[2], &operands[3]);
2155 operands[1] = gen_lowpart (DImode, operands[2]);
2156 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2160 (define_insn "*pushdi2_prologue_rex64"
2161 [(set (match_operand:DI 0 "push_operand" "=<")
2162 (match_operand:DI 1 "general_no_elim_operand" "re*m"))
2163 (clobber (mem:BLK (scratch)))]
2166 [(set_attr "type" "push")
2167 (set_attr "mode" "DI")])
2169 (define_insn "*popdi1_epilogue_rex64"
2170 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2171 (mem:DI (reg:DI SP_REG)))
2172 (set (reg:DI SP_REG)
2173 (plus:DI (reg:DI SP_REG) (const_int 8)))
2174 (clobber (mem:BLK (scratch)))]
2177 [(set_attr "type" "pop")
2178 (set_attr "mode" "DI")])
2180 (define_insn "popdi1"
2181 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2182 (mem:DI (reg:DI SP_REG)))
2183 (set (reg:DI SP_REG)
2184 (plus:DI (reg:DI SP_REG) (const_int 8)))]
2187 [(set_attr "type" "pop")
2188 (set_attr "mode" "DI")])
2190 (define_insn "*movdi_xor_rex64"
2191 [(set (match_operand:DI 0 "register_operand" "=r")
2192 (match_operand:DI 1 "const0_operand" "i"))
2193 (clobber (reg:CC FLAGS_REG))]
2194 "TARGET_64BIT && (!TARGET_USE_MOV0 || optimize_size)
2195 && reload_completed"
2197 [(set_attr "type" "alu1")
2198 (set_attr "mode" "SI")
2199 (set_attr "length_immediate" "0")])
2201 (define_insn "*movdi_or_rex64"
2202 [(set (match_operand:DI 0 "register_operand" "=r")
2203 (match_operand:DI 1 "const_int_operand" "i"))
2204 (clobber (reg:CC FLAGS_REG))]
2205 "TARGET_64BIT && (TARGET_MOVE_M1_VIA_OR || optimize_size)
2207 && operands[1] == constm1_rtx"
2209 operands[1] = constm1_rtx;
2210 return "or{q}\t{%1, %0|%0, %1}";
2212 [(set_attr "type" "alu1")
2213 (set_attr "mode" "DI")
2214 (set_attr "length_immediate" "1")])
2216 (define_insn "*movdi_2"
2217 [(set (match_operand:DI 0 "nonimmediate_operand"
2218 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2219 (match_operand:DI 1 "general_operand"
2220 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2221 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2226 movq\t{%1, %0|%0, %1}
2227 movq\t{%1, %0|%0, %1}
2229 movq\t{%1, %0|%0, %1}
2230 movdqa\t{%1, %0|%0, %1}
2231 movq\t{%1, %0|%0, %1}
2233 movlps\t{%1, %0|%0, %1}
2234 movaps\t{%1, %0|%0, %1}
2235 movlps\t{%1, %0|%0, %1}"
2236 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2237 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2240 [(set (match_operand:DI 0 "push_operand" "")
2241 (match_operand:DI 1 "general_operand" ""))]
2242 "!TARGET_64BIT && reload_completed
2243 && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2245 "ix86_split_long_move (operands); DONE;")
2247 ;; %%% This multiword shite has got to go.
2249 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2250 (match_operand:DI 1 "general_operand" ""))]
2251 "!TARGET_64BIT && reload_completed
2252 && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
2253 && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2255 "ix86_split_long_move (operands); DONE;")
2257 (define_insn "*movdi_1_rex64"
2258 [(set (match_operand:DI 0 "nonimmediate_operand"
2259 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
2260 (match_operand:DI 1 "general_operand"
2261 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
2262 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2264 switch (get_attr_type (insn))
2267 if (SSE_REG_P (operands[0]))
2268 return "movq2dq\t{%1, %0|%0, %1}";
2270 return "movdq2q\t{%1, %0|%0, %1}";
2273 if (get_attr_mode (insn) == MODE_TI)
2274 return "movdqa\t{%1, %0|%0, %1}";
2278 /* Moves from and into integer register is done using movd
2279 opcode with REX prefix. */
2280 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2281 return "movd\t{%1, %0|%0, %1}";
2282 return "movq\t{%1, %0|%0, %1}";
2286 return "pxor\t%0, %0";
2292 return "lea{q}\t{%a1, %0|%0, %a1}";
2295 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2296 if (get_attr_mode (insn) == MODE_SI)
2297 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2298 else if (which_alternative == 2)
2299 return "movabs{q}\t{%1, %0|%0, %1}";
2301 return "mov{q}\t{%1, %0|%0, %1}";
2305 (cond [(eq_attr "alternative" "5")
2306 (const_string "mmxadd")
2307 (eq_attr "alternative" "6,7,8,9,10")
2308 (const_string "mmxmov")
2309 (eq_attr "alternative" "11")
2310 (const_string "sselog1")
2311 (eq_attr "alternative" "12,13,14,15,16")
2312 (const_string "ssemov")
2313 (eq_attr "alternative" "17,18")
2314 (const_string "ssecvt")
2315 (eq_attr "alternative" "4")
2316 (const_string "multi")
2317 (match_operand:DI 1 "pic_32bit_operand" "")
2318 (const_string "lea")
2320 (const_string "imov")))
2321 (set_attr "modrm" "*,0,0,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")
2322 (set_attr "length_immediate" "*,4,8,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")
2323 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2325 ;; Stores and loads of ax to arbitrary constant address.
2326 ;; We fake an second form of instruction to force reload to load address
2327 ;; into register when rax is not available
2328 (define_insn "*movabsdi_1_rex64"
2329 [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2330 (match_operand:DI 1 "nonmemory_operand" "a,er"))]
2331 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2333 movabs{q}\t{%1, %P0|%P0, %1}
2334 mov{q}\t{%1, %a0|%a0, %1}"
2335 [(set_attr "type" "imov")
2336 (set_attr "modrm" "0,*")
2337 (set_attr "length_address" "8,0")
2338 (set_attr "length_immediate" "0,*")
2339 (set_attr "memory" "store")
2340 (set_attr "mode" "DI")])
2342 (define_insn "*movabsdi_2_rex64"
2343 [(set (match_operand:DI 0 "register_operand" "=a,r")
2344 (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2345 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2347 movabs{q}\t{%P1, %0|%0, %P1}
2348 mov{q}\t{%a1, %0|%0, %a1}"
2349 [(set_attr "type" "imov")
2350 (set_attr "modrm" "0,*")
2351 (set_attr "length_address" "8,0")
2352 (set_attr "length_immediate" "0")
2353 (set_attr "memory" "load")
2354 (set_attr "mode" "DI")])
2356 ;; Convert impossible stores of immediate to existing instructions.
2357 ;; First try to get scratch register and go through it. In case this
2358 ;; fails, move by 32bit parts.
2360 [(match_scratch:DI 2 "r")
2361 (set (match_operand:DI 0 "memory_operand" "")
2362 (match_operand:DI 1 "immediate_operand" ""))]
2363 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2364 && !x86_64_immediate_operand (operands[1], DImode)"
2365 [(set (match_dup 2) (match_dup 1))
2366 (set (match_dup 0) (match_dup 2))]
2369 ;; We need to define this as both peepholer and splitter for case
2370 ;; peephole2 pass is not run.
2371 ;; "&& 1" is needed to keep it from matching the previous pattern.
2373 [(set (match_operand:DI 0 "memory_operand" "")
2374 (match_operand:DI 1 "immediate_operand" ""))]
2375 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2376 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2377 [(set (match_dup 2) (match_dup 3))
2378 (set (match_dup 4) (match_dup 5))]
2379 "split_di (&operands[0], 2, &operands[2], &operands[4]);")
2382 [(set (match_operand:DI 0 "memory_operand" "")
2383 (match_operand:DI 1 "immediate_operand" ""))]
2384 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2385 ? epilogue_completed : reload_completed)
2386 && !symbolic_operand (operands[1], DImode)
2387 && !x86_64_immediate_operand (operands[1], DImode)"
2388 [(set (match_dup 2) (match_dup 3))
2389 (set (match_dup 4) (match_dup 5))]
2390 "split_di (&operands[0], 2, &operands[2], &operands[4]);")
2392 (define_insn "*swapdi_rex64"
2393 [(set (match_operand:DI 0 "register_operand" "+r")
2394 (match_operand:DI 1 "register_operand" "+r"))
2399 [(set_attr "type" "imov")
2400 (set_attr "mode" "DI")
2401 (set_attr "pent_pair" "np")
2402 (set_attr "athlon_decode" "vector")
2403 (set_attr "amdfam10_decode" "double")])
2405 (define_expand "movti"
2406 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2407 (match_operand:TI 1 "nonimmediate_operand" ""))]
2408 "TARGET_SSE || TARGET_64BIT"
2411 ix86_expand_move (TImode, operands);
2412 else if (push_operand (operands[0], TImode))
2413 ix86_expand_push (TImode, operands[1]);
2415 ix86_expand_vector_move (TImode, operands);
2419 (define_insn "*movti_internal"
2420 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
2421 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
2422 "TARGET_SSE && !TARGET_64BIT
2423 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2425 switch (which_alternative)
2428 if (get_attr_mode (insn) == MODE_V4SF)
2429 return "xorps\t%0, %0";
2431 return "pxor\t%0, %0";
2434 /* TDmode values are passed as TImode on the stack. Moving them
2435 to stack may result in unaligned memory access. */
2436 if (misaligned_operand (operands[0], TImode)
2437 || misaligned_operand (operands[1], TImode))
2439 if (get_attr_mode (insn) == MODE_V4SF)
2440 return "movups\t{%1, %0|%0, %1}";
2442 return "movdqu\t{%1, %0|%0, %1}";
2446 if (get_attr_mode (insn) == MODE_V4SF)
2447 return "movaps\t{%1, %0|%0, %1}";
2449 return "movdqa\t{%1, %0|%0, %1}";
2455 [(set_attr "type" "sselog1,ssemov,ssemov")
2457 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2458 (ne (symbol_ref "optimize_size") (const_int 0)))
2459 (const_string "V4SF")
2460 (and (eq_attr "alternative" "2")
2461 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2463 (const_string "V4SF")]
2464 (const_string "TI")))])
2466 (define_insn "*movti_rex64"
2467 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o,x,x,xm")
2468 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
2470 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2472 switch (which_alternative)
2478 if (get_attr_mode (insn) == MODE_V4SF)
2479 return "xorps\t%0, %0";
2481 return "pxor\t%0, %0";
2484 /* TDmode values are passed as TImode on the stack. Moving them
2485 to stack may result in unaligned memory access. */
2486 if (misaligned_operand (operands[0], TImode)
2487 || misaligned_operand (operands[1], TImode))
2489 if (get_attr_mode (insn) == MODE_V4SF)
2490 return "movups\t{%1, %0|%0, %1}";
2492 return "movdqu\t{%1, %0|%0, %1}";
2496 if (get_attr_mode (insn) == MODE_V4SF)
2497 return "movaps\t{%1, %0|%0, %1}";
2499 return "movdqa\t{%1, %0|%0, %1}";
2505 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
2507 (cond [(eq_attr "alternative" "2,3")
2509 (ne (symbol_ref "optimize_size")
2511 (const_string "V4SF")
2512 (const_string "TI"))
2513 (eq_attr "alternative" "4")
2515 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2517 (ne (symbol_ref "optimize_size")
2519 (const_string "V4SF")
2520 (const_string "TI"))]
2521 (const_string "DI")))])
2524 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2525 (match_operand:TI 1 "general_operand" ""))]
2526 "reload_completed && !SSE_REG_P (operands[0])
2527 && !SSE_REG_P (operands[1])"
2529 "ix86_split_long_move (operands); DONE;")
2531 ;; This expands to what emit_move_complex would generate if we didn't
2532 ;; have a movti pattern. Having this avoids problems with reload on
2533 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
2534 ;; to have around all the time.
2535 (define_expand "movcdi"
2536 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
2537 (match_operand:CDI 1 "general_operand" ""))]
2540 if (push_operand (operands[0], CDImode))
2541 emit_move_complex_push (CDImode, operands[0], operands[1]);
2543 emit_move_complex_parts (operands[0], operands[1]);
2547 (define_expand "movsf"
2548 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2549 (match_operand:SF 1 "general_operand" ""))]
2551 "ix86_expand_move (SFmode, operands); DONE;")
2553 (define_insn "*pushsf"
2554 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2555 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2558 /* Anything else should be already split before reg-stack. */
2559 gcc_assert (which_alternative == 1);
2560 return "push{l}\t%1";
2562 [(set_attr "type" "multi,push,multi")
2563 (set_attr "unit" "i387,*,*")
2564 (set_attr "mode" "SF,SI,SF")])
2566 (define_insn "*pushsf_rex64"
2567 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2568 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2571 /* Anything else should be already split before reg-stack. */
2572 gcc_assert (which_alternative == 1);
2573 return "push{q}\t%q1";
2575 [(set_attr "type" "multi,push,multi")
2576 (set_attr "unit" "i387,*,*")
2577 (set_attr "mode" "SF,DI,SF")])
2580 [(set (match_operand:SF 0 "push_operand" "")
2581 (match_operand:SF 1 "memory_operand" ""))]
2583 && MEM_P (operands[1])
2584 && (operands[2] = find_constant_src (insn))"
2589 ;; %%% Kill this when call knows how to work this out.
2591 [(set (match_operand:SF 0 "push_operand" "")
2592 (match_operand:SF 1 "any_fp_register_operand" ""))]
2594 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
2595 (set (mem:SF (reg:SI SP_REG)) (match_dup 1))])
2598 [(set (match_operand:SF 0 "push_operand" "")
2599 (match_operand:SF 1 "any_fp_register_operand" ""))]
2601 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (const_int -8)))
2602 (set (mem:SF (reg:DI SP_REG)) (match_dup 1))])
2604 (define_insn "*movsf_1"
2605 [(set (match_operand:SF 0 "nonimmediate_operand"
2606 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
2607 (match_operand:SF 1 "general_operand"
2608 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
2609 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2610 && (reload_in_progress || reload_completed
2611 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2612 || (!TARGET_SSE_MATH && optimize_size
2613 && standard_80387_constant_p (operands[1]))
2614 || GET_CODE (operands[1]) != CONST_DOUBLE
2615 || memory_operand (operands[0], SFmode))"
2617 switch (which_alternative)
2621 return output_387_reg_move (insn, operands);
2624 return standard_80387_constant_opcode (operands[1]);
2628 return "mov{l}\t{%1, %0|%0, %1}";
2630 if (get_attr_mode (insn) == MODE_TI)
2631 return "pxor\t%0, %0";
2633 return "xorps\t%0, %0";
2635 if (get_attr_mode (insn) == MODE_V4SF)
2636 return "movaps\t{%1, %0|%0, %1}";
2638 return "movss\t{%1, %0|%0, %1}";
2640 return "movss\t{%1, %0|%0, %1}";
2643 case 12: case 13: case 14: case 15:
2644 return "movd\t{%1, %0|%0, %1}";
2647 return "movq\t{%1, %0|%0, %1}";
2653 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
2655 (cond [(eq_attr "alternative" "3,4,9,10")
2657 (eq_attr "alternative" "5")
2659 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2661 (ne (symbol_ref "TARGET_SSE2")
2663 (eq (symbol_ref "optimize_size")
2666 (const_string "V4SF"))
2667 /* For architectures resolving dependencies on
2668 whole SSE registers use APS move to break dependency
2669 chains, otherwise use short move to avoid extra work.
2671 Do the same for architectures resolving dependencies on
2672 the parts. While in DF mode it is better to always handle
2673 just register parts, the SF mode is different due to lack
2674 of instructions to load just part of the register. It is
2675 better to maintain the whole registers in single format
2676 to avoid problems on using packed logical operations. */
2677 (eq_attr "alternative" "6")
2679 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2681 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2683 (const_string "V4SF")
2684 (const_string "SF"))
2685 (eq_attr "alternative" "11")
2686 (const_string "DI")]
2687 (const_string "SF")))])
2689 (define_insn "*swapsf"
2690 [(set (match_operand:SF 0 "fp_register_operand" "+f")
2691 (match_operand:SF 1 "fp_register_operand" "+f"))
2694 "reload_completed || TARGET_80387"
2696 if (STACK_TOP_P (operands[0]))
2701 [(set_attr "type" "fxch")
2702 (set_attr "mode" "SF")])
2704 (define_expand "movdf"
2705 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2706 (match_operand:DF 1 "general_operand" ""))]
2708 "ix86_expand_move (DFmode, operands); DONE;")
2710 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2711 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2712 ;; On the average, pushdf using integers can be still shorter. Allow this
2713 ;; pattern for optimize_size too.
2715 (define_insn "*pushdf_nointeger"
2716 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2717 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
2718 "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
2720 /* This insn should be already split before reg-stack. */
2723 [(set_attr "type" "multi")
2724 (set_attr "unit" "i387,*,*,*")
2725 (set_attr "mode" "DF,SI,SI,DF")])
2727 (define_insn "*pushdf_integer"
2728 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2729 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
2730 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2732 /* This insn should be already split before reg-stack. */
2735 [(set_attr "type" "multi")
2736 (set_attr "unit" "i387,*,*")
2737 (set_attr "mode" "DF,SI,DF")])
2739 ;; %%% Kill this when call knows how to work this out.
2741 [(set (match_operand:DF 0 "push_operand" "")
2742 (match_operand:DF 1 "any_fp_register_operand" ""))]
2744 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
2745 (set (mem:DF (reg:P SP_REG)) (match_dup 1))]
2749 [(set (match_operand:DF 0 "push_operand" "")
2750 (match_operand:DF 1 "general_operand" ""))]
2753 "ix86_split_long_move (operands); DONE;")
2755 ;; Moving is usually shorter when only FP registers are used. This separate
2756 ;; movdf pattern avoids the use of integer registers for FP operations
2757 ;; when optimizing for size.
2759 (define_insn "*movdf_nointeger"
2760 [(set (match_operand:DF 0 "nonimmediate_operand"
2761 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
2762 (match_operand:DF 1 "general_operand"
2763 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
2764 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2765 && ((optimize_size || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
2766 && (reload_in_progress || reload_completed
2767 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2768 || (!(TARGET_SSE2 && TARGET_SSE_MATH) && optimize_size
2769 && !memory_operand (operands[0], DFmode)
2770 && standard_80387_constant_p (operands[1]))
2771 || GET_CODE (operands[1]) != CONST_DOUBLE
2773 || !TARGET_MEMORY_MISMATCH_STALL
2774 || reload_in_progress || reload_completed)
2775 && memory_operand (operands[0], DFmode)))"
2777 switch (which_alternative)
2781 return output_387_reg_move (insn, operands);
2784 return standard_80387_constant_opcode (operands[1]);
2790 switch (get_attr_mode (insn))
2793 return "xorps\t%0, %0";
2795 return "xorpd\t%0, %0";
2797 return "pxor\t%0, %0";
2804 switch (get_attr_mode (insn))
2807 return "movaps\t{%1, %0|%0, %1}";
2809 return "movapd\t{%1, %0|%0, %1}";
2811 return "movdqa\t{%1, %0|%0, %1}";
2813 return "movq\t{%1, %0|%0, %1}";
2815 return "movsd\t{%1, %0|%0, %1}";
2817 return "movlpd\t{%1, %0|%0, %1}";
2819 return "movlps\t{%1, %0|%0, %1}";
2828 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
2830 (cond [(eq_attr "alternative" "0,1,2")
2832 (eq_attr "alternative" "3,4")
2835 /* For SSE1, we have many fewer alternatives. */
2836 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2837 (cond [(eq_attr "alternative" "5,6")
2838 (const_string "V4SF")
2840 (const_string "V2SF"))
2842 /* xorps is one byte shorter. */
2843 (eq_attr "alternative" "5")
2844 (cond [(ne (symbol_ref "optimize_size")
2846 (const_string "V4SF")
2847 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2851 (const_string "V2DF"))
2853 /* For architectures resolving dependencies on
2854 whole SSE registers use APD move to break dependency
2855 chains, otherwise use short move to avoid extra work.
2857 movaps encodes one byte shorter. */
2858 (eq_attr "alternative" "6")
2860 [(ne (symbol_ref "optimize_size")
2862 (const_string "V4SF")
2863 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2865 (const_string "V2DF")
2867 (const_string "DF"))
2868 /* For architectures resolving dependencies on register
2869 parts we may avoid extra work to zero out upper part
2871 (eq_attr "alternative" "7")
2873 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2875 (const_string "V1DF")
2876 (const_string "DF"))
2878 (const_string "DF")))])
2880 (define_insn "*movdf_integer_rex64"
2881 [(set (match_operand:DF 0 "nonimmediate_operand"
2882 "=f,m,f,r ,m ,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
2883 (match_operand:DF 1 "general_operand"
2884 "fm,f,G,rmF,Fr,C ,Y2*x,m ,Y2*x,r ,Yi"))]
2885 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2886 && (reload_in_progress || reload_completed
2887 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2888 || (!(TARGET_SSE2 && TARGET_SSE_MATH) && optimize_size
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 "xorps\t%0, %0";
2912 return "xorpd\t%0, %0";
2914 return "pxor\t%0, %0";
2921 switch (get_attr_mode (insn))
2924 return "movaps\t{%1, %0|%0, %1}";
2926 return "movapd\t{%1, %0|%0, %1}";
2928 return "movdqa\t{%1, %0|%0, %1}";
2930 return "movq\t{%1, %0|%0, %1}";
2932 return "movsd\t{%1, %0|%0, %1}";
2934 return "movlpd\t{%1, %0|%0, %1}";
2936 return "movlps\t{%1, %0|%0, %1}";
2943 return "movd\t{%1, %0|%0, %1}";
2949 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
2951 (cond [(eq_attr "alternative" "0,1,2")
2953 (eq_attr "alternative" "3,4,9,10")
2956 /* For SSE1, we have many fewer alternatives. */
2957 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2958 (cond [(eq_attr "alternative" "5,6")
2959 (const_string "V4SF")
2961 (const_string "V2SF"))
2963 /* xorps is one byte shorter. */
2964 (eq_attr "alternative" "5")
2965 (cond [(ne (symbol_ref "optimize_size")
2967 (const_string "V4SF")
2968 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2972 (const_string "V2DF"))
2974 /* For architectures resolving dependencies on
2975 whole SSE registers use APD move to break dependency
2976 chains, otherwise use short move to avoid extra work.
2978 movaps encodes one byte shorter. */
2979 (eq_attr "alternative" "6")
2981 [(ne (symbol_ref "optimize_size")
2983 (const_string "V4SF")
2984 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2986 (const_string "V2DF")
2988 (const_string "DF"))
2989 /* For architectures resolving dependencies on register
2990 parts we may avoid extra work to zero out upper part
2992 (eq_attr "alternative" "7")
2994 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2996 (const_string "V1DF")
2997 (const_string "DF"))
2999 (const_string "DF")))])
3001 (define_insn "*movdf_integer"
3002 [(set (match_operand:DF 0 "nonimmediate_operand"
3003 "=f,m,f,r ,o ,Y2*x,Y2*x,Y2*x,m ")
3004 (match_operand:DF 1 "general_operand"
3005 "fm,f,G,roF,Fr,C ,Y2*x,m ,Y2*x"))]
3006 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3007 && !optimize_size && TARGET_INTEGER_DFMODE_MOVES
3008 && (reload_in_progress || reload_completed
3009 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3010 || (!(TARGET_SSE2 && TARGET_SSE_MATH) && optimize_size
3011 && standard_80387_constant_p (operands[1]))
3012 || GET_CODE (operands[1]) != CONST_DOUBLE
3013 || memory_operand (operands[0], DFmode))"
3015 switch (which_alternative)
3019 return output_387_reg_move (insn, operands);
3022 return standard_80387_constant_opcode (operands[1]);
3029 switch (get_attr_mode (insn))
3032 return "xorps\t%0, %0";
3034 return "xorpd\t%0, %0";
3036 return "pxor\t%0, %0";
3043 switch (get_attr_mode (insn))
3046 return "movaps\t{%1, %0|%0, %1}";
3048 return "movapd\t{%1, %0|%0, %1}";
3050 return "movdqa\t{%1, %0|%0, %1}";
3052 return "movq\t{%1, %0|%0, %1}";
3054 return "movsd\t{%1, %0|%0, %1}";
3056 return "movlpd\t{%1, %0|%0, %1}";
3058 return "movlps\t{%1, %0|%0, %1}";
3067 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3069 (cond [(eq_attr "alternative" "0,1,2")
3071 (eq_attr "alternative" "3,4")
3074 /* For SSE1, we have many fewer alternatives. */
3075 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3076 (cond [(eq_attr "alternative" "5,6")
3077 (const_string "V4SF")
3079 (const_string "V2SF"))
3081 /* xorps is one byte shorter. */
3082 (eq_attr "alternative" "5")
3083 (cond [(ne (symbol_ref "optimize_size")
3085 (const_string "V4SF")
3086 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3090 (const_string "V2DF"))
3092 /* For architectures resolving dependencies on
3093 whole SSE registers use APD move to break dependency
3094 chains, otherwise use short move to avoid extra work.
3096 movaps encodes one byte shorter. */
3097 (eq_attr "alternative" "6")
3099 [(ne (symbol_ref "optimize_size")
3101 (const_string "V4SF")
3102 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3104 (const_string "V2DF")
3106 (const_string "DF"))
3107 /* For architectures resolving dependencies on register
3108 parts we may avoid extra work to zero out upper part
3110 (eq_attr "alternative" "7")
3112 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3114 (const_string "V1DF")
3115 (const_string "DF"))
3117 (const_string "DF")))])
3120 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3121 (match_operand:DF 1 "general_operand" ""))]
3123 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3124 && ! (ANY_FP_REG_P (operands[0]) ||
3125 (GET_CODE (operands[0]) == SUBREG
3126 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3127 && ! (ANY_FP_REG_P (operands[1]) ||
3128 (GET_CODE (operands[1]) == SUBREG
3129 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3131 "ix86_split_long_move (operands); DONE;")
3133 (define_insn "*swapdf"
3134 [(set (match_operand:DF 0 "fp_register_operand" "+f")
3135 (match_operand:DF 1 "fp_register_operand" "+f"))
3138 "reload_completed || TARGET_80387"
3140 if (STACK_TOP_P (operands[0]))
3145 [(set_attr "type" "fxch")
3146 (set_attr "mode" "DF")])
3148 (define_expand "movxf"
3149 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3150 (match_operand:XF 1 "general_operand" ""))]
3152 "ix86_expand_move (XFmode, operands); DONE;")
3154 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
3155 ;; Size of pushdf using integer instructions is 3+3*memory operand size
3156 ;; Pushing using integer instructions is longer except for constants
3157 ;; and direct memory references.
3158 ;; (assuming that any given constant is pushed only once, but this ought to be
3159 ;; handled elsewhere).
3161 (define_insn "*pushxf_nointeger"
3162 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
3163 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
3166 /* This insn should be already split before reg-stack. */
3169 [(set_attr "type" "multi")
3170 (set_attr "unit" "i387,*,*")
3171 (set_attr "mode" "XF,SI,SI")])
3173 (define_insn "*pushxf_integer"
3174 [(set (match_operand:XF 0 "push_operand" "=<,<")
3175 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
3178 /* This insn should be already split before reg-stack. */
3181 [(set_attr "type" "multi")
3182 (set_attr "unit" "i387,*")
3183 (set_attr "mode" "XF,SI")])
3186 [(set (match_operand 0 "push_operand" "")
3187 (match_operand 1 "general_operand" ""))]
3189 && (GET_MODE (operands[0]) == XFmode
3190 || GET_MODE (operands[0]) == DFmode)
3191 && !ANY_FP_REG_P (operands[1])"
3193 "ix86_split_long_move (operands); DONE;")
3196 [(set (match_operand:XF 0 "push_operand" "")
3197 (match_operand:XF 1 "any_fp_register_operand" ""))]
3199 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
3200 (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
3201 "operands[2] = GEN_INT (TARGET_128BIT_LONG_DOUBLE ? -16 : -12);")
3203 ;; Do not use integer registers when optimizing for size
3204 (define_insn "*movxf_nointeger"
3205 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
3206 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
3208 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3209 && (reload_in_progress || reload_completed
3210 || (optimize_size && standard_80387_constant_p (operands[1]))
3211 || GET_CODE (operands[1]) != CONST_DOUBLE
3212 || memory_operand (operands[0], XFmode))"
3214 switch (which_alternative)
3218 return output_387_reg_move (insn, operands);
3221 return standard_80387_constant_opcode (operands[1]);
3229 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3230 (set_attr "mode" "XF,XF,XF,SI,SI")])
3232 (define_insn "*movxf_integer"
3233 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,r,o")
3234 (match_operand:XF 1 "general_operand" "fm,f,G,roF,Fr"))]
3236 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3237 && (reload_in_progress || reload_completed
3238 || (optimize_size && standard_80387_constant_p (operands[1]))
3239 || GET_CODE (operands[1]) != CONST_DOUBLE
3240 || memory_operand (operands[0], XFmode))"
3242 switch (which_alternative)
3246 return output_387_reg_move (insn, operands);
3249 return standard_80387_constant_opcode (operands[1]);
3258 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3259 (set_attr "mode" "XF,XF,XF,SI,SI")])
3261 (define_expand "movtf"
3262 [(set (match_operand:TF 0 "nonimmediate_operand" "")
3263 (match_operand:TF 1 "nonimmediate_operand" ""))]
3266 ix86_expand_move (TFmode, operands);
3270 (define_insn "*movtf_internal"
3271 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?r,?o")
3272 (match_operand:TF 1 "general_operand" "xm,x,C,roF,Fr"))]
3274 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
3276 switch (which_alternative)
3280 if (get_attr_mode (insn) == MODE_V4SF)
3281 return "movaps\t{%1, %0|%0, %1}";
3283 return "movdqa\t{%1, %0|%0, %1}";
3285 if (get_attr_mode (insn) == MODE_V4SF)
3286 return "xorps\t%0, %0";
3288 return "pxor\t%0, %0";
3296 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
3298 (cond [(eq_attr "alternative" "0,2")
3300 (ne (symbol_ref "optimize_size")
3302 (const_string "V4SF")
3303 (const_string "TI"))
3304 (eq_attr "alternative" "1")
3306 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
3308 (ne (symbol_ref "optimize_size")
3310 (const_string "V4SF")
3311 (const_string "TI"))]
3312 (const_string "DI")))])
3315 [(set (match_operand 0 "nonimmediate_operand" "")
3316 (match_operand 1 "general_operand" ""))]
3318 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3319 && GET_MODE (operands[0]) == XFmode
3320 && ! (ANY_FP_REG_P (operands[0]) ||
3321 (GET_CODE (operands[0]) == SUBREG
3322 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3323 && ! (ANY_FP_REG_P (operands[1]) ||
3324 (GET_CODE (operands[1]) == SUBREG
3325 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3327 "ix86_split_long_move (operands); DONE;")
3330 [(set (match_operand 0 "register_operand" "")
3331 (match_operand 1 "memory_operand" ""))]
3333 && MEM_P (operands[1])
3334 && (GET_MODE (operands[0]) == TFmode
3335 || GET_MODE (operands[0]) == XFmode
3336 || GET_MODE (operands[0]) == SFmode
3337 || GET_MODE (operands[0]) == DFmode)
3338 && (operands[2] = find_constant_src (insn))"
3339 [(set (match_dup 0) (match_dup 2))]
3341 rtx c = operands[2];
3342 rtx r = operands[0];
3344 if (GET_CODE (r) == SUBREG)
3349 if (!standard_sse_constant_p (c))
3352 else if (FP_REG_P (r))
3354 if (!standard_80387_constant_p (c))
3357 else if (MMX_REG_P (r))
3362 [(set (match_operand 0 "register_operand" "")
3363 (float_extend (match_operand 1 "memory_operand" "")))]
3365 && MEM_P (operands[1])
3366 && (GET_MODE (operands[0]) == TFmode
3367 || GET_MODE (operands[0]) == XFmode
3368 || GET_MODE (operands[0]) == SFmode
3369 || GET_MODE (operands[0]) == DFmode)
3370 && (operands[2] = find_constant_src (insn))"
3371 [(set (match_dup 0) (match_dup 2))]
3373 rtx c = operands[2];
3374 rtx r = operands[0];
3376 if (GET_CODE (r) == SUBREG)
3381 if (!standard_sse_constant_p (c))
3384 else if (FP_REG_P (r))
3386 if (!standard_80387_constant_p (c))
3389 else if (MMX_REG_P (r))
3393 (define_insn "swapxf"
3394 [(set (match_operand:XF 0 "register_operand" "+f")
3395 (match_operand:XF 1 "register_operand" "+f"))
3400 if (STACK_TOP_P (operands[0]))
3405 [(set_attr "type" "fxch")
3406 (set_attr "mode" "XF")])
3408 ;; Split the load of -0.0 or -1.0 into fldz;fchs or fld1;fchs sequence
3410 [(set (match_operand:X87MODEF 0 "register_operand" "")
3411 (match_operand:X87MODEF 1 "immediate_operand" ""))]
3412 "reload_completed && FP_REGNO_P (REGNO (operands[0]))
3413 && (standard_80387_constant_p (operands[1]) == 8
3414 || standard_80387_constant_p (operands[1]) == 9)"
3415 [(set (match_dup 0)(match_dup 1))
3417 (neg:X87MODEF (match_dup 0)))]
3421 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
3422 if (real_isnegzero (&r))
3423 operands[1] = CONST0_RTX (<MODE>mode);
3425 operands[1] = CONST1_RTX (<MODE>mode);
3429 [(set (match_operand:TF 0 "nonimmediate_operand" "")
3430 (match_operand:TF 1 "general_operand" ""))]
3432 && !(SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]))"
3434 "ix86_split_long_move (operands); DONE;")
3436 ;; Zero extension instructions
3438 (define_expand "zero_extendhisi2"
3439 [(set (match_operand:SI 0 "register_operand" "")
3440 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3443 if (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3445 operands[1] = force_reg (HImode, operands[1]);
3446 emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3451 (define_insn "zero_extendhisi2_and"
3452 [(set (match_operand:SI 0 "register_operand" "=r")
3453 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3454 (clobber (reg:CC FLAGS_REG))]
3455 "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3457 [(set_attr "type" "alu1")
3458 (set_attr "mode" "SI")])
3461 [(set (match_operand:SI 0 "register_operand" "")
3462 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))
3463 (clobber (reg:CC FLAGS_REG))]
3464 "reload_completed && TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3465 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3466 (clobber (reg:CC FLAGS_REG))])]
3469 (define_insn "*zero_extendhisi2_movzwl"
3470 [(set (match_operand:SI 0 "register_operand" "=r")
3471 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3472 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3473 "movz{wl|x}\t{%1, %0|%0, %1}"
3474 [(set_attr "type" "imovx")
3475 (set_attr "mode" "SI")])
3477 (define_expand "zero_extendqihi2"
3479 [(set (match_operand:HI 0 "register_operand" "")
3480 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3481 (clobber (reg:CC FLAGS_REG))])]
3485 (define_insn "*zero_extendqihi2_and"
3486 [(set (match_operand:HI 0 "register_operand" "=r,?&q")
3487 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3488 (clobber (reg:CC FLAGS_REG))]
3489 "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3491 [(set_attr "type" "alu1")
3492 (set_attr "mode" "HI")])
3494 (define_insn "*zero_extendqihi2_movzbw_and"
3495 [(set (match_operand:HI 0 "register_operand" "=r,r")
3496 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3497 (clobber (reg:CC FLAGS_REG))]
3498 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3500 [(set_attr "type" "imovx,alu1")
3501 (set_attr "mode" "HI")])
3503 ; zero extend to SImode here to avoid partial register stalls
3504 (define_insn "*zero_extendqihi2_movzbl"
3505 [(set (match_operand:HI 0 "register_operand" "=r")
3506 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3507 "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
3508 "movz{bl|x}\t{%1, %k0|%k0, %1}"
3509 [(set_attr "type" "imovx")
3510 (set_attr "mode" "SI")])
3512 ;; For the movzbw case strip only the clobber
3514 [(set (match_operand:HI 0 "register_operand" "")
3515 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3516 (clobber (reg:CC FLAGS_REG))]
3518 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3519 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3520 [(set (match_operand:HI 0 "register_operand" "")
3521 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))])
3523 ;; When source and destination does not overlap, clear destination
3524 ;; first and then do the movb
3526 [(set (match_operand:HI 0 "register_operand" "")
3527 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3528 (clobber (reg:CC FLAGS_REG))]
3530 && ANY_QI_REG_P (operands[0])
3531 && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3532 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3533 [(set (match_dup 0) (const_int 0))
3534 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3535 "operands[2] = gen_lowpart (QImode, operands[0]);")
3537 ;; Rest is handled by single and.
3539 [(set (match_operand:HI 0 "register_operand" "")
3540 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))
3541 (clobber (reg:CC FLAGS_REG))]
3543 && true_regnum (operands[0]) == true_regnum (operands[1])"
3544 [(parallel [(set (match_dup 0) (and:HI (match_dup 0) (const_int 255)))
3545 (clobber (reg:CC FLAGS_REG))])]
3548 (define_expand "zero_extendqisi2"
3550 [(set (match_operand:SI 0 "register_operand" "")
3551 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3552 (clobber (reg:CC FLAGS_REG))])]
3556 (define_insn "*zero_extendqisi2_and"
3557 [(set (match_operand:SI 0 "register_operand" "=r,?&q")
3558 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3559 (clobber (reg:CC FLAGS_REG))]
3560 "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3562 [(set_attr "type" "alu1")
3563 (set_attr "mode" "SI")])
3565 (define_insn "*zero_extendqisi2_movzbw_and"
3566 [(set (match_operand:SI 0 "register_operand" "=r,r")
3567 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3568 (clobber (reg:CC FLAGS_REG))]
3569 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3571 [(set_attr "type" "imovx,alu1")
3572 (set_attr "mode" "SI")])
3574 (define_insn "*zero_extendqisi2_movzbw"
3575 [(set (match_operand:SI 0 "register_operand" "=r")
3576 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3577 "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
3578 "movz{bl|x}\t{%1, %0|%0, %1}"
3579 [(set_attr "type" "imovx")
3580 (set_attr "mode" "SI")])
3582 ;; For the movzbl case strip only the clobber
3584 [(set (match_operand:SI 0 "register_operand" "")
3585 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3586 (clobber (reg:CC FLAGS_REG))]
3588 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3589 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3591 (zero_extend:SI (match_dup 1)))])
3593 ;; When source and destination does not overlap, clear destination
3594 ;; first and then do the movb
3596 [(set (match_operand:SI 0 "register_operand" "")
3597 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3598 (clobber (reg:CC FLAGS_REG))]
3600 && ANY_QI_REG_P (operands[0])
3601 && (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]))
3602 && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3603 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3604 [(set (match_dup 0) (const_int 0))
3605 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3606 "operands[2] = gen_lowpart (QImode, operands[0]);")
3608 ;; Rest is handled by single and.
3610 [(set (match_operand:SI 0 "register_operand" "")
3611 (zero_extend:SI (match_operand:QI 1 "register_operand" "")))
3612 (clobber (reg:CC FLAGS_REG))]
3614 && true_regnum (operands[0]) == true_regnum (operands[1])"
3615 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 255)))
3616 (clobber (reg:CC FLAGS_REG))])]
3619 ;; %%% Kill me once multi-word ops are sane.
3620 (define_expand "zero_extendsidi2"
3621 [(set (match_operand:DI 0 "register_operand" "")
3622 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3627 emit_insn (gen_zero_extendsidi2_32 (operands[0], operands[1]));
3632 (define_insn "zero_extendsidi2_32"
3633 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?o,?*Ym,?*y,?*Yi,*Y2")
3635 (match_operand:SI 1 "nonimmediate_operand" "0,rm,r ,r ,m ,r ,m")))
3636 (clobber (reg:CC FLAGS_REG))]
3642 movd\t{%1, %0|%0, %1}
3643 movd\t{%1, %0|%0, %1}
3644 movd\t{%1, %0|%0, %1}
3645 movd\t{%1, %0|%0, %1}"
3646 [(set_attr "mode" "SI,SI,SI,DI,DI,TI,TI")
3647 (set_attr "type" "multi,multi,multi,mmxmov,mmxmov,ssemov,ssemov")])
3649 (define_insn "zero_extendsidi2_rex64"
3650 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,?*Ym,?*y,?*Yi,*Y2")
3652 (match_operand:SI 1 "nonimmediate_operand" "rm,0,r ,m ,r ,m")))]
3655 mov\t{%k1, %k0|%k0, %k1}
3657 movd\t{%1, %0|%0, %1}
3658 movd\t{%1, %0|%0, %1}
3659 movd\t{%1, %0|%0, %1}
3660 movd\t{%1, %0|%0, %1}"
3661 [(set_attr "type" "imovx,imov,mmxmov,mmxmov,ssemov,ssemov")
3662 (set_attr "mode" "SI,DI,DI,DI,TI,TI")])
3665 [(set (match_operand:DI 0 "memory_operand" "")
3666 (zero_extend:DI (match_dup 0)))]
3668 [(set (match_dup 4) (const_int 0))]
3669 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3672 [(set (match_operand:DI 0 "register_operand" "")
3673 (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3674 (clobber (reg:CC FLAGS_REG))]
3675 "!TARGET_64BIT && reload_completed
3676 && true_regnum (operands[0]) == true_regnum (operands[1])"
3677 [(set (match_dup 4) (const_int 0))]
3678 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3681 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3682 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3683 (clobber (reg:CC FLAGS_REG))]
3684 "!TARGET_64BIT && reload_completed
3685 && !SSE_REG_P (operands[0]) && !MMX_REG_P (operands[0])"
3686 [(set (match_dup 3) (match_dup 1))
3687 (set (match_dup 4) (const_int 0))]
3688 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3690 (define_insn "zero_extendhidi2"
3691 [(set (match_operand:DI 0 "register_operand" "=r")
3692 (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3694 "movz{wl|x}\t{%1, %k0|%k0, %1}"
3695 [(set_attr "type" "imovx")
3696 (set_attr "mode" "DI")])
3698 (define_insn "zero_extendqidi2"
3699 [(set (match_operand:DI 0 "register_operand" "=r")
3700 (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "rm")))]
3702 "movz{bl|x}\t{%1, %k0|%k0, %1}"
3703 [(set_attr "type" "imovx")
3704 (set_attr "mode" "DI")])
3706 ;; Sign extension instructions
3708 (define_expand "extendsidi2"
3709 [(parallel [(set (match_operand:DI 0 "register_operand" "")
3710 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3711 (clobber (reg:CC FLAGS_REG))
3712 (clobber (match_scratch:SI 2 ""))])]
3717 emit_insn (gen_extendsidi2_rex64 (operands[0], operands[1]));
3722 (define_insn "*extendsidi2_1"
3723 [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3724 (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3725 (clobber (reg:CC FLAGS_REG))
3726 (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3730 (define_insn "extendsidi2_rex64"
3731 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3732 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3736 movs{lq|x}\t{%1,%0|%0, %1}"
3737 [(set_attr "type" "imovx")
3738 (set_attr "mode" "DI")
3739 (set_attr "prefix_0f" "0")
3740 (set_attr "modrm" "0,1")])
3742 (define_insn "extendhidi2"
3743 [(set (match_operand:DI 0 "register_operand" "=r")
3744 (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3746 "movs{wq|x}\t{%1,%0|%0, %1}"
3747 [(set_attr "type" "imovx")
3748 (set_attr "mode" "DI")])
3750 (define_insn "extendqidi2"
3751 [(set (match_operand:DI 0 "register_operand" "=r")
3752 (sign_extend:DI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3754 "movs{bq|x}\t{%1,%0|%0, %1}"
3755 [(set_attr "type" "imovx")
3756 (set_attr "mode" "DI")])
3758 ;; Extend to memory case when source register does die.
3760 [(set (match_operand:DI 0 "memory_operand" "")
3761 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3762 (clobber (reg:CC FLAGS_REG))
3763 (clobber (match_operand:SI 2 "register_operand" ""))]
3765 && dead_or_set_p (insn, operands[1])
3766 && !reg_mentioned_p (operands[1], operands[0]))"
3767 [(set (match_dup 3) (match_dup 1))
3768 (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3769 (clobber (reg:CC FLAGS_REG))])
3770 (set (match_dup 4) (match_dup 1))]
3771 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3773 ;; Extend to memory case when source register does not die.
3775 [(set (match_operand:DI 0 "memory_operand" "")
3776 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3777 (clobber (reg:CC FLAGS_REG))
3778 (clobber (match_operand:SI 2 "register_operand" ""))]
3782 split_di (&operands[0], 1, &operands[3], &operands[4]);
3784 emit_move_insn (operands[3], operands[1]);
3786 /* Generate a cltd if possible and doing so it profitable. */
3787 if ((optimize_size || TARGET_USE_CLTD)
3788 && true_regnum (operands[1]) == AX_REG
3789 && true_regnum (operands[2]) == DX_REG)
3791 emit_insn (gen_ashrsi3_31 (operands[2], operands[1], GEN_INT (31)));
3795 emit_move_insn (operands[2], operands[1]);
3796 emit_insn (gen_ashrsi3_31 (operands[2], operands[2], GEN_INT (31)));
3798 emit_move_insn (operands[4], operands[2]);
3802 ;; Extend to register case. Optimize case where source and destination
3803 ;; registers match and cases where we can use cltd.
3805 [(set (match_operand:DI 0 "register_operand" "")
3806 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3807 (clobber (reg:CC FLAGS_REG))
3808 (clobber (match_scratch:SI 2 ""))]
3812 split_di (&operands[0], 1, &operands[3], &operands[4]);
3814 if (true_regnum (operands[3]) != true_regnum (operands[1]))
3815 emit_move_insn (operands[3], operands[1]);
3817 /* Generate a cltd if possible and doing so it profitable. */
3818 if ((optimize_size || TARGET_USE_CLTD)
3819 && true_regnum (operands[3]) == AX_REG)
3821 emit_insn (gen_ashrsi3_31 (operands[4], operands[3], GEN_INT (31)));
3825 if (true_regnum (operands[4]) != true_regnum (operands[1]))
3826 emit_move_insn (operands[4], operands[1]);
3828 emit_insn (gen_ashrsi3_31 (operands[4], operands[4], GEN_INT (31)));
3832 (define_insn "extendhisi2"
3833 [(set (match_operand:SI 0 "register_operand" "=*a,r")
3834 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3837 switch (get_attr_prefix_0f (insn))
3840 return "{cwtl|cwde}";
3842 return "movs{wl|x}\t{%1,%0|%0, %1}";
3845 [(set_attr "type" "imovx")
3846 (set_attr "mode" "SI")
3847 (set (attr "prefix_0f")
3848 ;; movsx is short decodable while cwtl is vector decoded.
3849 (if_then_else (and (eq_attr "cpu" "!k6")
3850 (eq_attr "alternative" "0"))
3852 (const_string "1")))
3854 (if_then_else (eq_attr "prefix_0f" "0")
3856 (const_string "1")))])
3858 (define_insn "*extendhisi2_zext"
3859 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3861 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm"))))]
3864 switch (get_attr_prefix_0f (insn))
3867 return "{cwtl|cwde}";
3869 return "movs{wl|x}\t{%1,%k0|%k0, %1}";
3872 [(set_attr "type" "imovx")
3873 (set_attr "mode" "SI")
3874 (set (attr "prefix_0f")
3875 ;; movsx is short decodable while cwtl is vector decoded.
3876 (if_then_else (and (eq_attr "cpu" "!k6")
3877 (eq_attr "alternative" "0"))
3879 (const_string "1")))
3881 (if_then_else (eq_attr "prefix_0f" "0")
3883 (const_string "1")))])
3885 (define_insn "extendqihi2"
3886 [(set (match_operand:HI 0 "register_operand" "=*a,r")
3887 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "*0,qm")))]
3890 switch (get_attr_prefix_0f (insn))
3893 return "{cbtw|cbw}";
3895 return "movs{bw|x}\t{%1,%0|%0, %1}";
3898 [(set_attr "type" "imovx")
3899 (set_attr "mode" "HI")
3900 (set (attr "prefix_0f")
3901 ;; movsx is short decodable while cwtl is vector decoded.
3902 (if_then_else (and (eq_attr "cpu" "!k6")
3903 (eq_attr "alternative" "0"))
3905 (const_string "1")))
3907 (if_then_else (eq_attr "prefix_0f" "0")
3909 (const_string "1")))])
3911 (define_insn "extendqisi2"
3912 [(set (match_operand:SI 0 "register_operand" "=r")
3913 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3915 "movs{bl|x}\t{%1,%0|%0, %1}"
3916 [(set_attr "type" "imovx")
3917 (set_attr "mode" "SI")])
3919 (define_insn "*extendqisi2_zext"
3920 [(set (match_operand:DI 0 "register_operand" "=r")
3922 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm"))))]
3924 "movs{bl|x}\t{%1,%k0|%k0, %1}"
3925 [(set_attr "type" "imovx")
3926 (set_attr "mode" "SI")])
3928 ;; Conversions between float and double.
3930 ;; These are all no-ops in the model used for the 80387. So just
3933 ;; %%% Kill these when call knows how to work out a DFmode push earlier.
3934 (define_insn "*dummy_extendsfdf2"
3935 [(set (match_operand:DF 0 "push_operand" "=<")
3936 (float_extend:DF (match_operand:SF 1 "nonimmediate_operan