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)
184 (UNSPEC_SSE5_ASHIFT 154)
185 (UNSPEC_SSE5_LSHIFT 155)
187 (UNSPEC_CVTPH2PS 157)
188 (UNSPEC_CVTPS2PH 158)
192 (UNSPEC_AESENCLAST 160)
194 (UNSPEC_AESDECLAST 162)
196 (UNSPEC_AESKEYGENASSIST 164)
203 [(UNSPECV_BLOCKAGE 0)
204 (UNSPECV_STACK_PROBE 1)
213 (UNSPECV_CMPXCHG_1 10)
214 (UNSPECV_CMPXCHG_2 11)
217 (UNSPECV_PROLOGUE_USE 14)
220 ;; Constants to represent pcomtrue/pcomfalse variants
230 ;; Registers by name.
246 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
249 ;; In C guard expressions, put expressions which may be compile-time
250 ;; constants first. This allows for better optimization. For
251 ;; example, write "TARGET_64BIT && reload_completed", not
252 ;; "reload_completed && TARGET_64BIT".
255 ;; Processor type. This attribute must exactly match the processor_type
256 ;; enumeration in i386.h.
257 (define_attr "cpu" "i386,i486,pentium,pentiumpro,geode,k6,athlon,pentium4,k8,
258 nocona,core2,generic32,generic64,amdfam10"
259 (const (symbol_ref "ix86_tune")))
261 ;; A basic instruction type. Refinements due to arguments to be
262 ;; provided in other attributes.
265 alu,alu1,negnot,imov,imovx,lea,
266 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
267 icmp,test,ibr,setcc,icmov,
268 push,pop,call,callv,leave,
270 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
271 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
272 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
274 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
275 (const_string "other"))
277 ;; Main data type used by the insn
279 "unknown,none,QI,HI,SI,DI,SF,DF,XF,TI,V4SF,V2DF,V2SF,V1DF"
280 (const_string "unknown"))
282 ;; The CPU unit operations uses.
283 (define_attr "unit" "integer,i387,sse,mmx,unknown"
284 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
285 (const_string "i387")
286 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
287 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
288 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
290 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
292 (eq_attr "type" "other")
293 (const_string "unknown")]
294 (const_string "integer")))
296 ;; The (bounding maximum) length of an instruction immediate.
297 (define_attr "length_immediate" ""
298 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
301 (eq_attr "unit" "i387,sse,mmx")
303 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
305 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
306 (eq_attr "type" "imov,test")
307 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
308 (eq_attr "type" "call")
309 (if_then_else (match_operand 0 "constant_call_address_operand" "")
312 (eq_attr "type" "callv")
313 (if_then_else (match_operand 1 "constant_call_address_operand" "")
316 ;; We don't know the size before shorten_branches. Expect
317 ;; the instruction to fit for better scheduling.
318 (eq_attr "type" "ibr")
321 (symbol_ref "/* Update immediate_length and other attributes! */
322 gcc_unreachable (),1")))
324 ;; The (bounding maximum) length of an instruction address.
325 (define_attr "length_address" ""
326 (cond [(eq_attr "type" "str,other,multi,fxch")
328 (and (eq_attr "type" "call")
329 (match_operand 0 "constant_call_address_operand" ""))
331 (and (eq_attr "type" "callv")
332 (match_operand 1 "constant_call_address_operand" ""))
335 (symbol_ref "ix86_attr_length_address_default (insn)")))
337 ;; Set when length prefix is used.
338 (define_attr "prefix_data16" ""
339 (if_then_else (ior (eq_attr "mode" "HI")
340 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF")))
344 ;; Set when string REP prefix is used.
345 (define_attr "prefix_rep" ""
346 (if_then_else (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
350 ;; Set when 0f opcode prefix is used.
351 (define_attr "prefix_0f" ""
353 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
354 (eq_attr "unit" "sse,mmx"))
358 ;; Set when REX opcode prefix is used.
359 (define_attr "prefix_rex" ""
360 (cond [(and (eq_attr "mode" "DI")
361 (eq_attr "type" "!push,pop,call,callv,leave,ibr"))
363 (and (eq_attr "mode" "QI")
364 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
367 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
373 ;; There are also additional prefixes in SSSE3.
374 (define_attr "prefix_extra" "" (const_int 0))
376 ;; Set when modrm byte is used.
377 (define_attr "modrm" ""
378 (cond [(eq_attr "type" "str,leave")
380 (eq_attr "unit" "i387")
382 (and (eq_attr "type" "incdec")
383 (ior (match_operand:SI 1 "register_operand" "")
384 (match_operand:HI 1 "register_operand" "")))
386 (and (eq_attr "type" "push")
387 (not (match_operand 1 "memory_operand" "")))
389 (and (eq_attr "type" "pop")
390 (not (match_operand 0 "memory_operand" "")))
392 (and (eq_attr "type" "imov")
393 (ior (and (match_operand 0 "register_operand" "")
394 (match_operand 1 "immediate_operand" ""))
395 (ior (and (match_operand 0 "ax_reg_operand" "")
396 (match_operand 1 "memory_displacement_only_operand" ""))
397 (and (match_operand 0 "memory_displacement_only_operand" "")
398 (match_operand 1 "ax_reg_operand" "")))))
400 (and (eq_attr "type" "call")
401 (match_operand 0 "constant_call_address_operand" ""))
403 (and (eq_attr "type" "callv")
404 (match_operand 1 "constant_call_address_operand" ""))
409 ;; The (bounding maximum) length of an instruction in bytes.
410 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
411 ;; Later we may want to split them and compute proper length as for
413 (define_attr "length" ""
414 (cond [(eq_attr "type" "other,multi,fistp,frndint")
416 (eq_attr "type" "fcmp")
418 (eq_attr "unit" "i387")
420 (plus (attr "prefix_data16")
421 (attr "length_address")))]
422 (plus (plus (attr "modrm")
423 (plus (attr "prefix_0f")
424 (plus (attr "prefix_rex")
425 (plus (attr "prefix_extra")
427 (plus (attr "prefix_rep")
428 (plus (attr "prefix_data16")
429 (plus (attr "length_immediate")
430 (attr "length_address")))))))
432 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
433 ;; `store' if there is a simple memory reference therein, or `unknown'
434 ;; if the instruction is complex.
436 (define_attr "memory" "none,load,store,both,unknown"
437 (cond [(eq_attr "type" "other,multi,str")
438 (const_string "unknown")
439 (eq_attr "type" "lea,fcmov,fpspc")
440 (const_string "none")
441 (eq_attr "type" "fistp,leave")
442 (const_string "both")
443 (eq_attr "type" "frndint")
444 (const_string "load")
445 (eq_attr "type" "push")
446 (if_then_else (match_operand 1 "memory_operand" "")
447 (const_string "both")
448 (const_string "store"))
449 (eq_attr "type" "pop")
450 (if_then_else (match_operand 0 "memory_operand" "")
451 (const_string "both")
452 (const_string "load"))
453 (eq_attr "type" "setcc")
454 (if_then_else (match_operand 0 "memory_operand" "")
455 (const_string "store")
456 (const_string "none"))
457 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
458 (if_then_else (ior (match_operand 0 "memory_operand" "")
459 (match_operand 1 "memory_operand" ""))
460 (const_string "load")
461 (const_string "none"))
462 (eq_attr "type" "ibr")
463 (if_then_else (match_operand 0 "memory_operand" "")
464 (const_string "load")
465 (const_string "none"))
466 (eq_attr "type" "call")
467 (if_then_else (match_operand 0 "constant_call_address_operand" "")
468 (const_string "none")
469 (const_string "load"))
470 (eq_attr "type" "callv")
471 (if_then_else (match_operand 1 "constant_call_address_operand" "")
472 (const_string "none")
473 (const_string "load"))
474 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
475 (match_operand 1 "memory_operand" ""))
476 (const_string "both")
477 (and (match_operand 0 "memory_operand" "")
478 (match_operand 1 "memory_operand" ""))
479 (const_string "both")
480 (match_operand 0 "memory_operand" "")
481 (const_string "store")
482 (match_operand 1 "memory_operand" "")
483 (const_string "load")
485 "!alu1,negnot,ishift1,
486 imov,imovx,icmp,test,bitmanip,
488 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
489 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
490 (match_operand 2 "memory_operand" ""))
491 (const_string "load")
492 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
493 (match_operand 3 "memory_operand" ""))
494 (const_string "load")
496 (const_string "none")))
498 ;; Indicates if an instruction has both an immediate and a displacement.
500 (define_attr "imm_disp" "false,true,unknown"
501 (cond [(eq_attr "type" "other,multi")
502 (const_string "unknown")
503 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
504 (and (match_operand 0 "memory_displacement_operand" "")
505 (match_operand 1 "immediate_operand" "")))
506 (const_string "true")
507 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
508 (and (match_operand 0 "memory_displacement_operand" "")
509 (match_operand 2 "immediate_operand" "")))
510 (const_string "true")
512 (const_string "false")))
514 ;; Indicates if an FP operation has an integer source.
516 (define_attr "fp_int_src" "false,true"
517 (const_string "false"))
519 ;; Defines rounding mode of an FP operation.
521 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
522 (const_string "any"))
524 ;; Describe a user's asm statement.
525 (define_asm_attributes
526 [(set_attr "length" "128")
527 (set_attr "type" "multi")])
529 ;; All integer comparison codes.
530 (define_code_iterator int_cond [ne eq ge gt le lt geu gtu leu ltu ])
532 ;; All floating-point comparison codes.
533 (define_code_iterator fp_cond [unordered ordered
534 uneq unge ungt unle unlt ltgt ])
536 (define_code_iterator plusminus [plus minus])
538 ;; Base name for define_insn and insn mnemonic.
539 (define_code_attr addsub [(plus "add") (minus "sub")])
541 ;; Mark commutative operators as such in constraints.
542 (define_code_attr comm [(plus "%") (minus "")])
544 ;; Mapping of signed max and min
545 (define_code_iterator smaxmin [smax smin])
547 ;; Mapping of unsigned max and min
548 (define_code_iterator umaxmin [umax umin])
550 ;; Base name for integer and FP insn mnemonic
551 (define_code_attr maxminiprefix [(smax "maxs") (smin "mins")
552 (umax "maxu") (umin "minu")])
553 (define_code_attr maxminfprefix [(smax "max") (smin "min")])
555 ;; Mapping of parallel logic operators
556 (define_code_iterator plogic [and ior xor])
558 ;; Base name for insn mnemonic.
559 (define_code_attr plogicprefix [(and "and") (ior "or") (xor "xor")])
561 ;; Mapping of abs neg operators
562 (define_code_iterator absneg [abs neg])
564 ;; Base name for x87 insn mnemonic.
565 (define_code_attr absnegprefix [(abs "abs") (neg "chs")])
567 ;; All single word integer modes.
568 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
570 ;; Instruction suffix for integer modes.
571 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
573 ;; Register class for integer modes.
574 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
576 ;; Immediate operand constraint for integer modes.
577 (define_mode_attr i [(QI "i") (HI "i") (SI "i") (DI "e")])
579 ;; General operand predicate for integer modes.
580 (define_mode_attr general_operand
581 [(QI "general_operand")
582 (HI "general_operand")
583 (SI "general_operand")
584 (DI "x86_64_general_operand")])
586 ;; SSE and x87 SFmode and DFmode floating point modes
587 (define_mode_iterator MODEF [SF DF])
589 ;; All x87 floating point modes
590 (define_mode_iterator X87MODEF [SF DF XF])
592 ;; All integer modes handled by x87 fisttp operator.
593 (define_mode_iterator X87MODEI [HI SI DI])
595 ;; All integer modes handled by integer x87 operators.
596 (define_mode_iterator X87MODEI12 [HI SI])
598 ;; All integer modes handled by SSE cvtts?2si* operators.
599 (define_mode_iterator SSEMODEI24 [SI DI])
601 ;; SSE asm suffix for floating point modes
602 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
604 ;; SSE vector mode corresponding to a scalar mode
605 (define_mode_attr ssevecmode
606 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
608 ;; Instruction suffix for REX 64bit operators.
609 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
611 ;; Scheduling descriptions
613 (include "pentium.md")
616 (include "athlon.md")
620 ;; Operand and operator predicates and constraints
622 (include "predicates.md")
623 (include "constraints.md")
626 ;; Compare instructions.
628 ;; All compare insns have expanders that save the operands away without
629 ;; actually generating RTL. The bCOND or sCOND (emitted immediately
630 ;; after the cmp) will actually emit the cmpM.
632 (define_expand "cmpti"
633 [(set (reg:CC FLAGS_REG)
634 (compare:CC (match_operand:TI 0 "nonimmediate_operand" "")
635 (match_operand:TI 1 "x86_64_general_operand" "")))]
638 if (MEM_P (operands[0]) && MEM_P (operands[1]))
639 operands[0] = force_reg (TImode, operands[0]);
640 ix86_compare_op0 = operands[0];
641 ix86_compare_op1 = operands[1];
645 (define_expand "cmpdi"
646 [(set (reg:CC FLAGS_REG)
647 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
648 (match_operand:DI 1 "x86_64_general_operand" "")))]
651 if (MEM_P (operands[0]) && MEM_P (operands[1]))
652 operands[0] = force_reg (DImode, operands[0]);
653 ix86_compare_op0 = operands[0];
654 ix86_compare_op1 = operands[1];
658 (define_expand "cmpsi"
659 [(set (reg:CC FLAGS_REG)
660 (compare:CC (match_operand:SI 0 "cmpsi_operand" "")
661 (match_operand:SI 1 "general_operand" "")))]
664 if (MEM_P (operands[0]) && MEM_P (operands[1]))
665 operands[0] = force_reg (SImode, operands[0]);
666 ix86_compare_op0 = operands[0];
667 ix86_compare_op1 = operands[1];
671 (define_expand "cmphi"
672 [(set (reg:CC FLAGS_REG)
673 (compare:CC (match_operand:HI 0 "nonimmediate_operand" "")
674 (match_operand:HI 1 "general_operand" "")))]
677 if (MEM_P (operands[0]) && MEM_P (operands[1]))
678 operands[0] = force_reg (HImode, operands[0]);
679 ix86_compare_op0 = operands[0];
680 ix86_compare_op1 = operands[1];
684 (define_expand "cmpqi"
685 [(set (reg:CC FLAGS_REG)
686 (compare:CC (match_operand:QI 0 "nonimmediate_operand" "")
687 (match_operand:QI 1 "general_operand" "")))]
690 if (MEM_P (operands[0]) && MEM_P (operands[1]))
691 operands[0] = force_reg (QImode, operands[0]);
692 ix86_compare_op0 = operands[0];
693 ix86_compare_op1 = operands[1];
697 (define_insn "cmpdi_ccno_1_rex64"
698 [(set (reg FLAGS_REG)
699 (compare (match_operand:DI 0 "nonimmediate_operand" "r,?mr")
700 (match_operand:DI 1 "const0_operand" "n,n")))]
701 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
704 cmp{q}\t{%1, %0|%0, %1}"
705 [(set_attr "type" "test,icmp")
706 (set_attr "length_immediate" "0,1")
707 (set_attr "mode" "DI")])
709 (define_insn "*cmpdi_minus_1_rex64"
710 [(set (reg FLAGS_REG)
711 (compare (minus:DI (match_operand:DI 0 "nonimmediate_operand" "rm,r")
712 (match_operand:DI 1 "x86_64_general_operand" "re,mr"))
714 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)"
715 "cmp{q}\t{%1, %0|%0, %1}"
716 [(set_attr "type" "icmp")
717 (set_attr "mode" "DI")])
719 (define_expand "cmpdi_1_rex64"
720 [(set (reg:CC FLAGS_REG)
721 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
722 (match_operand:DI 1 "general_operand" "")))]
726 (define_insn "cmpdi_1_insn_rex64"
727 [(set (reg FLAGS_REG)
728 (compare (match_operand:DI 0 "nonimmediate_operand" "mr,r")
729 (match_operand:DI 1 "x86_64_general_operand" "re,mr")))]
730 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
731 "cmp{q}\t{%1, %0|%0, %1}"
732 [(set_attr "type" "icmp")
733 (set_attr "mode" "DI")])
736 (define_insn "*cmpsi_ccno_1"
737 [(set (reg FLAGS_REG)
738 (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr")
739 (match_operand:SI 1 "const0_operand" "n,n")))]
740 "ix86_match_ccmode (insn, CCNOmode)"
743 cmp{l}\t{%1, %0|%0, %1}"
744 [(set_attr "type" "test,icmp")
745 (set_attr "length_immediate" "0,1")
746 (set_attr "mode" "SI")])
748 (define_insn "*cmpsi_minus_1"
749 [(set (reg FLAGS_REG)
750 (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r")
751 (match_operand:SI 1 "general_operand" "ri,mr"))
753 "ix86_match_ccmode (insn, CCGOCmode)"
754 "cmp{l}\t{%1, %0|%0, %1}"
755 [(set_attr "type" "icmp")
756 (set_attr "mode" "SI")])
758 (define_expand "cmpsi_1"
759 [(set (reg:CC FLAGS_REG)
760 (compare:CC (match_operand:SI 0 "nonimmediate_operand" "")
761 (match_operand:SI 1 "general_operand" "")))]
765 (define_insn "*cmpsi_1_insn"
766 [(set (reg FLAGS_REG)
767 (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r")
768 (match_operand:SI 1 "general_operand" "ri,mr")))]
769 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
770 && ix86_match_ccmode (insn, CCmode)"
771 "cmp{l}\t{%1, %0|%0, %1}"
772 [(set_attr "type" "icmp")
773 (set_attr "mode" "SI")])
775 (define_insn "*cmphi_ccno_1"
776 [(set (reg FLAGS_REG)
777 (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr")
778 (match_operand:HI 1 "const0_operand" "n,n")))]
779 "ix86_match_ccmode (insn, CCNOmode)"
782 cmp{w}\t{%1, %0|%0, %1}"
783 [(set_attr "type" "test,icmp")
784 (set_attr "length_immediate" "0,1")
785 (set_attr "mode" "HI")])
787 (define_insn "*cmphi_minus_1"
788 [(set (reg FLAGS_REG)
789 (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r")
790 (match_operand:HI 1 "general_operand" "ri,mr"))
792 "ix86_match_ccmode (insn, CCGOCmode)"
793 "cmp{w}\t{%1, %0|%0, %1}"
794 [(set_attr "type" "icmp")
795 (set_attr "mode" "HI")])
797 (define_insn "*cmphi_1"
798 [(set (reg FLAGS_REG)
799 (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r")
800 (match_operand:HI 1 "general_operand" "ri,mr")))]
801 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
802 && ix86_match_ccmode (insn, CCmode)"
803 "cmp{w}\t{%1, %0|%0, %1}"
804 [(set_attr "type" "icmp")
805 (set_attr "mode" "HI")])
807 (define_insn "*cmpqi_ccno_1"
808 [(set (reg FLAGS_REG)
809 (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq")
810 (match_operand:QI 1 "const0_operand" "n,n")))]
811 "ix86_match_ccmode (insn, CCNOmode)"
814 cmp{b}\t{$0, %0|%0, 0}"
815 [(set_attr "type" "test,icmp")
816 (set_attr "length_immediate" "0,1")
817 (set_attr "mode" "QI")])
819 (define_insn "*cmpqi_1"
820 [(set (reg FLAGS_REG)
821 (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q")
822 (match_operand:QI 1 "general_operand" "qi,mq")))]
823 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
824 && ix86_match_ccmode (insn, CCmode)"
825 "cmp{b}\t{%1, %0|%0, %1}"
826 [(set_attr "type" "icmp")
827 (set_attr "mode" "QI")])
829 (define_insn "*cmpqi_minus_1"
830 [(set (reg FLAGS_REG)
831 (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q")
832 (match_operand:QI 1 "general_operand" "qi,mq"))
834 "ix86_match_ccmode (insn, CCGOCmode)"
835 "cmp{b}\t{%1, %0|%0, %1}"
836 [(set_attr "type" "icmp")
837 (set_attr "mode" "QI")])
839 (define_insn "*cmpqi_ext_1"
840 [(set (reg FLAGS_REG)
842 (match_operand:QI 0 "general_operand" "Qm")
845 (match_operand 1 "ext_register_operand" "Q")
848 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
849 "cmp{b}\t{%h1, %0|%0, %h1}"
850 [(set_attr "type" "icmp")
851 (set_attr "mode" "QI")])
853 (define_insn "*cmpqi_ext_1_rex64"
854 [(set (reg FLAGS_REG)
856 (match_operand:QI 0 "register_operand" "Q")
859 (match_operand 1 "ext_register_operand" "Q")
862 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
863 "cmp{b}\t{%h1, %0|%0, %h1}"
864 [(set_attr "type" "icmp")
865 (set_attr "mode" "QI")])
867 (define_insn "*cmpqi_ext_2"
868 [(set (reg FLAGS_REG)
872 (match_operand 0 "ext_register_operand" "Q")
875 (match_operand:QI 1 "const0_operand" "n")))]
876 "ix86_match_ccmode (insn, CCNOmode)"
878 [(set_attr "type" "test")
879 (set_attr "length_immediate" "0")
880 (set_attr "mode" "QI")])
882 (define_expand "cmpqi_ext_3"
883 [(set (reg:CC FLAGS_REG)
887 (match_operand 0 "ext_register_operand" "")
890 (match_operand:QI 1 "general_operand" "")))]
894 (define_insn "cmpqi_ext_3_insn"
895 [(set (reg FLAGS_REG)
899 (match_operand 0 "ext_register_operand" "Q")
902 (match_operand:QI 1 "general_operand" "Qmn")))]
903 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
904 "cmp{b}\t{%1, %h0|%h0, %1}"
905 [(set_attr "type" "icmp")
906 (set_attr "mode" "QI")])
908 (define_insn "cmpqi_ext_3_insn_rex64"
909 [(set (reg FLAGS_REG)
913 (match_operand 0 "ext_register_operand" "Q")
916 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
917 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
918 "cmp{b}\t{%1, %h0|%h0, %1}"
919 [(set_attr "type" "icmp")
920 (set_attr "mode" "QI")])
922 (define_insn "*cmpqi_ext_4"
923 [(set (reg FLAGS_REG)
927 (match_operand 0 "ext_register_operand" "Q")
932 (match_operand 1 "ext_register_operand" "Q")
935 "ix86_match_ccmode (insn, CCmode)"
936 "cmp{b}\t{%h1, %h0|%h0, %h1}"
937 [(set_attr "type" "icmp")
938 (set_attr "mode" "QI")])
940 ;; These implement float point compares.
941 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
942 ;; which would allow mix and match FP modes on the compares. Which is what
943 ;; the old patterns did, but with many more of them.
945 (define_expand "cmpxf"
946 [(set (reg:CC FLAGS_REG)
947 (compare:CC (match_operand:XF 0 "nonmemory_operand" "")
948 (match_operand:XF 1 "nonmemory_operand" "")))]
951 ix86_compare_op0 = operands[0];
952 ix86_compare_op1 = operands[1];
956 (define_expand "cmp<mode>"
957 [(set (reg:CC FLAGS_REG)
958 (compare:CC (match_operand:MODEF 0 "cmp_fp_expander_operand" "")
959 (match_operand:MODEF 1 "cmp_fp_expander_operand" "")))]
960 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
962 ix86_compare_op0 = operands[0];
963 ix86_compare_op1 = operands[1];
967 ;; FP compares, step 1:
968 ;; Set the FP condition codes.
970 ;; CCFPmode compare with exceptions
971 ;; CCFPUmode compare with no exceptions
973 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
974 ;; used to manage the reg stack popping would not be preserved.
976 (define_insn "*cmpfp_0"
977 [(set (match_operand:HI 0 "register_operand" "=a")
980 (match_operand 1 "register_operand" "f")
981 (match_operand 2 "const0_operand" "X"))]
983 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
984 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
985 "* return output_fp_compare (insn, operands, 0, 0);"
986 [(set_attr "type" "multi")
987 (set_attr "unit" "i387")
989 (cond [(match_operand:SF 1 "" "")
991 (match_operand:DF 1 "" "")
994 (const_string "XF")))])
996 (define_insn_and_split "*cmpfp_0_cc"
997 [(set (reg:CCFP FLAGS_REG)
999 (match_operand 1 "register_operand" "f")
1000 (match_operand 2 "const0_operand" "X")))
1001 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1002 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1003 && TARGET_SAHF && !TARGET_CMOVE
1004 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1006 "&& reload_completed"
1009 [(compare:CCFP (match_dup 1)(match_dup 2))]
1011 (set (reg:CC FLAGS_REG)
1012 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
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 "*cmpfp_xf"
1025 [(set (match_operand:HI 0 "register_operand" "=a")
1028 (match_operand:XF 1 "register_operand" "f")
1029 (match_operand:XF 2 "register_operand" "f"))]
1032 "* return output_fp_compare (insn, operands, 0, 0);"
1033 [(set_attr "type" "multi")
1034 (set_attr "unit" "i387")
1035 (set_attr "mode" "XF")])
1037 (define_insn_and_split "*cmpfp_xf_cc"
1038 [(set (reg:CCFP FLAGS_REG)
1040 (match_operand:XF 1 "register_operand" "f")
1041 (match_operand:XF 2 "register_operand" "f")))
1042 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1044 && TARGET_SAHF && !TARGET_CMOVE"
1046 "&& reload_completed"
1049 [(compare:CCFP (match_dup 1)(match_dup 2))]
1051 (set (reg:CC FLAGS_REG)
1052 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1054 [(set_attr "type" "multi")
1055 (set_attr "unit" "i387")
1056 (set_attr "mode" "XF")])
1058 (define_insn "*cmpfp_<mode>"
1059 [(set (match_operand:HI 0 "register_operand" "=a")
1062 (match_operand:MODEF 1 "register_operand" "f")
1063 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1066 "* return output_fp_compare (insn, operands, 0, 0);"
1067 [(set_attr "type" "multi")
1068 (set_attr "unit" "i387")
1069 (set_attr "mode" "<MODE>")])
1071 (define_insn_and_split "*cmpfp_<mode>_cc"
1072 [(set (reg:CCFP FLAGS_REG)
1074 (match_operand:MODEF 1 "register_operand" "f")
1075 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1076 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1078 && TARGET_SAHF && !TARGET_CMOVE"
1080 "&& reload_completed"
1083 [(compare:CCFP (match_dup 1)(match_dup 2))]
1085 (set (reg:CC FLAGS_REG)
1086 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1088 [(set_attr "type" "multi")
1089 (set_attr "unit" "i387")
1090 (set_attr "mode" "<MODE>")])
1092 (define_insn "*cmpfp_u"
1093 [(set (match_operand:HI 0 "register_operand" "=a")
1096 (match_operand 1 "register_operand" "f")
1097 (match_operand 2 "register_operand" "f"))]
1099 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1100 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1101 "* return output_fp_compare (insn, operands, 0, 1);"
1102 [(set_attr "type" "multi")
1103 (set_attr "unit" "i387")
1105 (cond [(match_operand:SF 1 "" "")
1107 (match_operand:DF 1 "" "")
1110 (const_string "XF")))])
1112 (define_insn_and_split "*cmpfp_u_cc"
1113 [(set (reg:CCFPU FLAGS_REG)
1115 (match_operand 1 "register_operand" "f")
1116 (match_operand 2 "register_operand" "f")))
1117 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1118 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1119 && TARGET_SAHF && !TARGET_CMOVE
1120 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1122 "&& reload_completed"
1125 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1127 (set (reg:CC FLAGS_REG)
1128 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
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 "*cmpfp_<mode>"
1141 [(set (match_operand:HI 0 "register_operand" "=a")
1144 (match_operand 1 "register_operand" "f")
1145 (match_operator 3 "float_operator"
1146 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1148 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1149 && TARGET_USE_<MODE>MODE_FIOP
1150 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1151 "* return output_fp_compare (insn, operands, 0, 0);"
1152 [(set_attr "type" "multi")
1153 (set_attr "unit" "i387")
1154 (set_attr "fp_int_src" "true")
1155 (set_attr "mode" "<MODE>")])
1157 (define_insn_and_split "*cmpfp_<mode>_cc"
1158 [(set (reg:CCFP FLAGS_REG)
1160 (match_operand 1 "register_operand" "f")
1161 (match_operator 3 "float_operator"
1162 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1163 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1164 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1165 && TARGET_SAHF && !TARGET_CMOVE
1166 && TARGET_USE_<MODE>MODE_FIOP
1167 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1169 "&& reload_completed"
1174 (match_op_dup 3 [(match_dup 2)]))]
1176 (set (reg:CC FLAGS_REG)
1177 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1179 [(set_attr "type" "multi")
1180 (set_attr "unit" "i387")
1181 (set_attr "fp_int_src" "true")
1182 (set_attr "mode" "<MODE>")])
1184 ;; FP compares, step 2
1185 ;; Move the fpsw to ax.
1187 (define_insn "x86_fnstsw_1"
1188 [(set (match_operand:HI 0 "register_operand" "=a")
1189 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1192 [(set_attr "length" "2")
1193 (set_attr "mode" "SI")
1194 (set_attr "unit" "i387")])
1196 ;; FP compares, step 3
1197 ;; Get ax into flags, general case.
1199 (define_insn "x86_sahf_1"
1200 [(set (reg:CC FLAGS_REG)
1201 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1205 #ifdef HAVE_AS_IX86_SAHF
1208 return ".byte\t0x9e";
1211 [(set_attr "length" "1")
1212 (set_attr "athlon_decode" "vector")
1213 (set_attr "amdfam10_decode" "direct")
1214 (set_attr "mode" "SI")])
1216 ;; Pentium Pro can do steps 1 through 3 in one go.
1217 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1218 (define_insn "*cmpfp_i_mixed"
1219 [(set (reg:CCFP FLAGS_REG)
1220 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1221 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1222 "TARGET_MIX_SSE_I387
1223 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1224 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1225 "* return output_fp_compare (insn, operands, 1, 0);"
1226 [(set_attr "type" "fcmp,ssecomi")
1228 (if_then_else (match_operand:SF 1 "" "")
1230 (const_string "DF")))
1231 (set_attr "athlon_decode" "vector")
1232 (set_attr "amdfam10_decode" "direct")])
1234 (define_insn "*cmpfp_i_sse"
1235 [(set (reg:CCFP FLAGS_REG)
1236 (compare:CCFP (match_operand 0 "register_operand" "x")
1237 (match_operand 1 "nonimmediate_operand" "xm")))]
1239 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1240 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1241 "* return output_fp_compare (insn, operands, 1, 0);"
1242 [(set_attr "type" "ssecomi")
1244 (if_then_else (match_operand:SF 1 "" "")
1246 (const_string "DF")))
1247 (set_attr "athlon_decode" "vector")
1248 (set_attr "amdfam10_decode" "direct")])
1250 (define_insn "*cmpfp_i_i387"
1251 [(set (reg:CCFP FLAGS_REG)
1252 (compare:CCFP (match_operand 0 "register_operand" "f")
1253 (match_operand 1 "register_operand" "f")))]
1254 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1256 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1257 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1258 "* return output_fp_compare (insn, operands, 1, 0);"
1259 [(set_attr "type" "fcmp")
1261 (cond [(match_operand:SF 1 "" "")
1263 (match_operand:DF 1 "" "")
1266 (const_string "XF")))
1267 (set_attr "athlon_decode" "vector")
1268 (set_attr "amdfam10_decode" "direct")])
1270 (define_insn "*cmpfp_iu_mixed"
1271 [(set (reg:CCFPU FLAGS_REG)
1272 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1273 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1274 "TARGET_MIX_SSE_I387
1275 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1276 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1277 "* return output_fp_compare (insn, operands, 1, 1);"
1278 [(set_attr "type" "fcmp,ssecomi")
1280 (if_then_else (match_operand:SF 1 "" "")
1282 (const_string "DF")))
1283 (set_attr "athlon_decode" "vector")
1284 (set_attr "amdfam10_decode" "direct")])
1286 (define_insn "*cmpfp_iu_sse"
1287 [(set (reg:CCFPU FLAGS_REG)
1288 (compare:CCFPU (match_operand 0 "register_operand" "x")
1289 (match_operand 1 "nonimmediate_operand" "xm")))]
1291 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1292 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1293 "* return output_fp_compare (insn, operands, 1, 1);"
1294 [(set_attr "type" "ssecomi")
1296 (if_then_else (match_operand:SF 1 "" "")
1298 (const_string "DF")))
1299 (set_attr "athlon_decode" "vector")
1300 (set_attr "amdfam10_decode" "direct")])
1302 (define_insn "*cmpfp_iu_387"
1303 [(set (reg:CCFPU FLAGS_REG)
1304 (compare:CCFPU (match_operand 0 "register_operand" "f")
1305 (match_operand 1 "register_operand" "f")))]
1306 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1308 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1309 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1310 "* return output_fp_compare (insn, operands, 1, 1);"
1311 [(set_attr "type" "fcmp")
1313 (cond [(match_operand:SF 1 "" "")
1315 (match_operand:DF 1 "" "")
1318 (const_string "XF")))
1319 (set_attr "athlon_decode" "vector")
1320 (set_attr "amdfam10_decode" "direct")])
1322 ;; Move instructions.
1324 ;; General case of fullword move.
1326 (define_expand "movsi"
1327 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1328 (match_operand:SI 1 "general_operand" ""))]
1330 "ix86_expand_move (SImode, operands); DONE;")
1332 ;; Push/pop instructions. They are separate since autoinc/dec is not a
1335 ;; %%% We don't use a post-inc memory reference because x86 is not a
1336 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1337 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1338 ;; targets without our curiosities, and it is just as easy to represent
1339 ;; this differently.
1341 (define_insn "*pushsi2"
1342 [(set (match_operand:SI 0 "push_operand" "=<")
1343 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1346 [(set_attr "type" "push")
1347 (set_attr "mode" "SI")])
1349 ;; For 64BIT abi we always round up to 8 bytes.
1350 (define_insn "*pushsi2_rex64"
1351 [(set (match_operand:SI 0 "push_operand" "=X")
1352 (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1355 [(set_attr "type" "push")
1356 (set_attr "mode" "SI")])
1358 (define_insn "*pushsi2_prologue"
1359 [(set (match_operand:SI 0 "push_operand" "=<")
1360 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1361 (clobber (mem:BLK (scratch)))]
1364 [(set_attr "type" "push")
1365 (set_attr "mode" "SI")])
1367 (define_insn "*popsi1_epilogue"
1368 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1369 (mem:SI (reg:SI SP_REG)))
1370 (set (reg:SI SP_REG)
1371 (plus:SI (reg:SI SP_REG) (const_int 4)))
1372 (clobber (mem:BLK (scratch)))]
1375 [(set_attr "type" "pop")
1376 (set_attr "mode" "SI")])
1378 (define_insn "popsi1"
1379 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1380 (mem:SI (reg:SI SP_REG)))
1381 (set (reg:SI SP_REG)
1382 (plus:SI (reg:SI SP_REG) (const_int 4)))]
1385 [(set_attr "type" "pop")
1386 (set_attr "mode" "SI")])
1388 (define_insn "*movsi_xor"
1389 [(set (match_operand:SI 0 "register_operand" "=r")
1390 (match_operand:SI 1 "const0_operand" "i"))
1391 (clobber (reg:CC FLAGS_REG))]
1392 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1394 [(set_attr "type" "alu1")
1395 (set_attr "mode" "SI")
1396 (set_attr "length_immediate" "0")])
1398 (define_insn "*movsi_or"
1399 [(set (match_operand:SI 0 "register_operand" "=r")
1400 (match_operand:SI 1 "immediate_operand" "i"))
1401 (clobber (reg:CC FLAGS_REG))]
1403 && operands[1] == constm1_rtx
1404 && (TARGET_MOVE_M1_VIA_OR || optimize_size)"
1406 operands[1] = constm1_rtx;
1407 return "or{l}\t{%1, %0|%0, %1}";
1409 [(set_attr "type" "alu1")
1410 (set_attr "mode" "SI")
1411 (set_attr "length_immediate" "1")])
1413 (define_insn "*movsi_1"
1414 [(set (match_operand:SI 0 "nonimmediate_operand"
1415 "=r ,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
1416 (match_operand:SI 1 "general_operand"
1417 "rinm,rin,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
1418 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1420 switch (get_attr_type (insn))
1423 if (get_attr_mode (insn) == MODE_TI)
1424 return "pxor\t%0, %0";
1425 return "xorps\t%0, %0";
1428 switch (get_attr_mode (insn))
1431 return "movdqa\t{%1, %0|%0, %1}";
1433 return "movaps\t{%1, %0|%0, %1}";
1435 return "movd\t{%1, %0|%0, %1}";
1437 return "movss\t{%1, %0|%0, %1}";
1443 return "pxor\t%0, %0";
1446 if (get_attr_mode (insn) == MODE_DI)
1447 return "movq\t{%1, %0|%0, %1}";
1448 return "movd\t{%1, %0|%0, %1}";
1451 return "lea{l}\t{%1, %0|%0, %1}";
1454 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
1455 return "mov{l}\t{%1, %0|%0, %1}";
1459 (cond [(eq_attr "alternative" "2")
1460 (const_string "mmxadd")
1461 (eq_attr "alternative" "3,4,5")
1462 (const_string "mmxmov")
1463 (eq_attr "alternative" "6")
1464 (const_string "sselog1")
1465 (eq_attr "alternative" "7,8,9,10,11")
1466 (const_string "ssemov")
1467 (match_operand:DI 1 "pic_32bit_operand" "")
1468 (const_string "lea")
1470 (const_string "imov")))
1472 (cond [(eq_attr "alternative" "2,3")
1474 (eq_attr "alternative" "6,7")
1476 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1477 (const_string "V4SF")
1478 (const_string "TI"))
1479 (and (eq_attr "alternative" "8,9,10,11")
1480 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
1483 (const_string "SI")))])
1485 ;; Stores and loads of ax to arbitrary constant address.
1486 ;; We fake an second form of instruction to force reload to load address
1487 ;; into register when rax is not available
1488 (define_insn "*movabssi_1_rex64"
1489 [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1490 (match_operand:SI 1 "nonmemory_operand" "a,er"))]
1491 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1493 movabs{l}\t{%1, %P0|%P0, %1}
1494 mov{l}\t{%1, %a0|%a0, %1}"
1495 [(set_attr "type" "imov")
1496 (set_attr "modrm" "0,*")
1497 (set_attr "length_address" "8,0")
1498 (set_attr "length_immediate" "0,*")
1499 (set_attr "memory" "store")
1500 (set_attr "mode" "SI")])
1502 (define_insn "*movabssi_2_rex64"
1503 [(set (match_operand:SI 0 "register_operand" "=a,r")
1504 (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1505 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1507 movabs{l}\t{%P1, %0|%0, %P1}
1508 mov{l}\t{%a1, %0|%0, %a1}"
1509 [(set_attr "type" "imov")
1510 (set_attr "modrm" "0,*")
1511 (set_attr "length_address" "8,0")
1512 (set_attr "length_immediate" "0")
1513 (set_attr "memory" "load")
1514 (set_attr "mode" "SI")])
1516 (define_insn "*swapsi"
1517 [(set (match_operand:SI 0 "register_operand" "+r")
1518 (match_operand:SI 1 "register_operand" "+r"))
1523 [(set_attr "type" "imov")
1524 (set_attr "mode" "SI")
1525 (set_attr "pent_pair" "np")
1526 (set_attr "athlon_decode" "vector")
1527 (set_attr "amdfam10_decode" "double")])
1529 (define_expand "movhi"
1530 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1531 (match_operand:HI 1 "general_operand" ""))]
1533 "ix86_expand_move (HImode, operands); DONE;")
1535 (define_insn "*pushhi2"
1536 [(set (match_operand:HI 0 "push_operand" "=X")
1537 (match_operand:HI 1 "nonmemory_no_elim_operand" "rn"))]
1540 [(set_attr "type" "push")
1541 (set_attr "mode" "SI")])
1543 ;; For 64BIT abi we always round up to 8 bytes.
1544 (define_insn "*pushhi2_rex64"
1545 [(set (match_operand:HI 0 "push_operand" "=X")
1546 (match_operand:HI 1 "nonmemory_no_elim_operand" "ri"))]
1549 [(set_attr "type" "push")
1550 (set_attr "mode" "DI")])
1552 (define_insn "*movhi_1"
1553 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
1554 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
1555 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1557 switch (get_attr_type (insn))
1560 /* movzwl is faster than movw on p2 due to partial word stalls,
1561 though not as fast as an aligned movl. */
1562 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1564 if (get_attr_mode (insn) == MODE_SI)
1565 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1567 return "mov{w}\t{%1, %0|%0, %1}";
1571 (cond [(ne (symbol_ref "optimize_size") (const_int 0))
1572 (const_string "imov")
1573 (and (eq_attr "alternative" "0")
1574 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1576 (eq (symbol_ref "TARGET_HIMODE_MATH")
1578 (const_string "imov")
1579 (and (eq_attr "alternative" "1,2")
1580 (match_operand:HI 1 "aligned_operand" ""))
1581 (const_string "imov")
1582 (and (ne (symbol_ref "TARGET_MOVX")
1584 (eq_attr "alternative" "0,2"))
1585 (const_string "imovx")
1587 (const_string "imov")))
1589 (cond [(eq_attr "type" "imovx")
1591 (and (eq_attr "alternative" "1,2")
1592 (match_operand:HI 1 "aligned_operand" ""))
1594 (and (eq_attr "alternative" "0")
1595 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1597 (eq (symbol_ref "TARGET_HIMODE_MATH")
1601 (const_string "HI")))])
1603 ;; Stores and loads of ax to arbitrary constant address.
1604 ;; We fake an second form of instruction to force reload to load address
1605 ;; into register when rax is not available
1606 (define_insn "*movabshi_1_rex64"
1607 [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1608 (match_operand:HI 1 "nonmemory_operand" "a,er"))]
1609 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1611 movabs{w}\t{%1, %P0|%P0, %1}
1612 mov{w}\t{%1, %a0|%a0, %1}"
1613 [(set_attr "type" "imov")
1614 (set_attr "modrm" "0,*")
1615 (set_attr "length_address" "8,0")
1616 (set_attr "length_immediate" "0,*")
1617 (set_attr "memory" "store")
1618 (set_attr "mode" "HI")])
1620 (define_insn "*movabshi_2_rex64"
1621 [(set (match_operand:HI 0 "register_operand" "=a,r")
1622 (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1623 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1625 movabs{w}\t{%P1, %0|%0, %P1}
1626 mov{w}\t{%a1, %0|%0, %a1}"
1627 [(set_attr "type" "imov")
1628 (set_attr "modrm" "0,*")
1629 (set_attr "length_address" "8,0")
1630 (set_attr "length_immediate" "0")
1631 (set_attr "memory" "load")
1632 (set_attr "mode" "HI")])
1634 (define_insn "*swaphi_1"
1635 [(set (match_operand:HI 0 "register_operand" "+r")
1636 (match_operand:HI 1 "register_operand" "+r"))
1639 "!TARGET_PARTIAL_REG_STALL || optimize_size"
1641 [(set_attr "type" "imov")
1642 (set_attr "mode" "SI")
1643 (set_attr "pent_pair" "np")
1644 (set_attr "athlon_decode" "vector")
1645 (set_attr "amdfam10_decode" "double")])
1647 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
1648 (define_insn "*swaphi_2"
1649 [(set (match_operand:HI 0 "register_operand" "+r")
1650 (match_operand:HI 1 "register_operand" "+r"))
1653 "TARGET_PARTIAL_REG_STALL"
1655 [(set_attr "type" "imov")
1656 (set_attr "mode" "HI")
1657 (set_attr "pent_pair" "np")
1658 (set_attr "athlon_decode" "vector")])
1660 (define_expand "movstricthi"
1661 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1662 (match_operand:HI 1 "general_operand" ""))]
1663 "! TARGET_PARTIAL_REG_STALL || optimize_size"
1665 /* Don't generate memory->memory moves, go through a register */
1666 if (MEM_P (operands[0]) && MEM_P (operands[1]))
1667 operands[1] = force_reg (HImode, operands[1]);
1670 (define_insn "*movstricthi_1"
1671 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1672 (match_operand:HI 1 "general_operand" "rn,m"))]
1673 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1674 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1675 "mov{w}\t{%1, %0|%0, %1}"
1676 [(set_attr "type" "imov")
1677 (set_attr "mode" "HI")])
1679 (define_insn "*movstricthi_xor"
1680 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1681 (match_operand:HI 1 "const0_operand" "i"))
1682 (clobber (reg:CC FLAGS_REG))]
1684 && ((!TARGET_USE_MOV0 && !TARGET_PARTIAL_REG_STALL) || optimize_size)"
1686 [(set_attr "type" "alu1")
1687 (set_attr "mode" "HI")
1688 (set_attr "length_immediate" "0")])
1690 (define_expand "movqi"
1691 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1692 (match_operand:QI 1 "general_operand" ""))]
1694 "ix86_expand_move (QImode, operands); DONE;")
1696 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1697 ;; "push a byte". But actually we use pushl, which has the effect
1698 ;; of rounding the amount pushed up to a word.
1700 (define_insn "*pushqi2"
1701 [(set (match_operand:QI 0 "push_operand" "=X")
1702 (match_operand:QI 1 "nonmemory_no_elim_operand" "rn"))]
1705 [(set_attr "type" "push")
1706 (set_attr "mode" "SI")])
1708 ;; For 64BIT abi we always round up to 8 bytes.
1709 (define_insn "*pushqi2_rex64"
1710 [(set (match_operand:QI 0 "push_operand" "=X")
1711 (match_operand:QI 1 "nonmemory_no_elim_operand" "qi"))]
1714 [(set_attr "type" "push")
1715 (set_attr "mode" "DI")])
1717 ;; Situation is quite tricky about when to choose full sized (SImode) move
1718 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
1719 ;; partial register dependency machines (such as AMD Athlon), where QImode
1720 ;; moves issue extra dependency and for partial register stalls machines
1721 ;; that don't use QImode patterns (and QImode move cause stall on the next
1724 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
1725 ;; register stall machines with, where we use QImode instructions, since
1726 ;; partial register stall can be caused there. Then we use movzx.
1727 (define_insn "*movqi_1"
1728 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
1729 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
1730 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1732 switch (get_attr_type (insn))
1735 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
1736 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
1738 if (get_attr_mode (insn) == MODE_SI)
1739 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1741 return "mov{b}\t{%1, %0|%0, %1}";
1745 (cond [(and (eq_attr "alternative" "5")
1746 (not (match_operand:QI 1 "aligned_operand" "")))
1747 (const_string "imovx")
1748 (ne (symbol_ref "optimize_size") (const_int 0))
1749 (const_string "imov")
1750 (and (eq_attr "alternative" "3")
1751 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1753 (eq (symbol_ref "TARGET_QIMODE_MATH")
1755 (const_string "imov")
1756 (eq_attr "alternative" "3,5")
1757 (const_string "imovx")
1758 (and (ne (symbol_ref "TARGET_MOVX")
1760 (eq_attr "alternative" "2"))
1761 (const_string "imovx")
1763 (const_string "imov")))
1765 (cond [(eq_attr "alternative" "3,4,5")
1767 (eq_attr "alternative" "6")
1769 (eq_attr "type" "imovx")
1771 (and (eq_attr "type" "imov")
1772 (and (eq_attr "alternative" "0,1")
1773 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
1775 (and (eq (symbol_ref "optimize_size")
1777 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1780 ;; Avoid partial register stalls when not using QImode arithmetic
1781 (and (eq_attr "type" "imov")
1782 (and (eq_attr "alternative" "0,1")
1783 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
1785 (eq (symbol_ref "TARGET_QIMODE_MATH")
1789 (const_string "QI")))])
1791 (define_expand "reload_outqi"
1792 [(parallel [(match_operand:QI 0 "" "=m")
1793 (match_operand:QI 1 "register_operand" "r")
1794 (match_operand:QI 2 "register_operand" "=&q")])]
1798 op0 = operands[0]; op1 = operands[1]; op2 = operands[2];
1800 gcc_assert (!reg_overlap_mentioned_p (op2, op0));
1801 if (! q_regs_operand (op1, QImode))
1803 emit_insn (gen_movqi (op2, op1));
1806 emit_insn (gen_movqi (op0, op1));
1810 (define_insn "*swapqi_1"
1811 [(set (match_operand:QI 0 "register_operand" "+r")
1812 (match_operand:QI 1 "register_operand" "+r"))
1815 "!TARGET_PARTIAL_REG_STALL || optimize_size"
1817 [(set_attr "type" "imov")
1818 (set_attr "mode" "SI")
1819 (set_attr "pent_pair" "np")
1820 (set_attr "athlon_decode" "vector")
1821 (set_attr "amdfam10_decode" "vector")])
1823 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
1824 (define_insn "*swapqi_2"
1825 [(set (match_operand:QI 0 "register_operand" "+q")
1826 (match_operand:QI 1 "register_operand" "+q"))
1829 "TARGET_PARTIAL_REG_STALL"
1831 [(set_attr "type" "imov")
1832 (set_attr "mode" "QI")
1833 (set_attr "pent_pair" "np")
1834 (set_attr "athlon_decode" "vector")])
1836 (define_expand "movstrictqi"
1837 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
1838 (match_operand:QI 1 "general_operand" ""))]
1839 "! TARGET_PARTIAL_REG_STALL || optimize_size"
1841 /* Don't generate memory->memory moves, go through a register. */
1842 if (MEM_P (operands[0]) && MEM_P (operands[1]))
1843 operands[1] = force_reg (QImode, operands[1]);
1846 (define_insn "*movstrictqi_1"
1847 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
1848 (match_operand:QI 1 "general_operand" "*qn,m"))]
1849 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1850 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1851 "mov{b}\t{%1, %0|%0, %1}"
1852 [(set_attr "type" "imov")
1853 (set_attr "mode" "QI")])
1855 (define_insn "*movstrictqi_xor"
1856 [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
1857 (match_operand:QI 1 "const0_operand" "i"))
1858 (clobber (reg:CC FLAGS_REG))]
1859 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1861 [(set_attr "type" "alu1")
1862 (set_attr "mode" "QI")
1863 (set_attr "length_immediate" "0")])
1865 (define_insn "*movsi_extv_1"
1866 [(set (match_operand:SI 0 "register_operand" "=R")
1867 (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
1871 "movs{bl|x}\t{%h1, %0|%0, %h1}"
1872 [(set_attr "type" "imovx")
1873 (set_attr "mode" "SI")])
1875 (define_insn "*movhi_extv_1"
1876 [(set (match_operand:HI 0 "register_operand" "=R")
1877 (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
1881 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
1882 [(set_attr "type" "imovx")
1883 (set_attr "mode" "SI")])
1885 (define_insn "*movqi_extv_1"
1886 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
1887 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
1892 switch (get_attr_type (insn))
1895 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
1897 return "mov{b}\t{%h1, %0|%0, %h1}";
1901 (if_then_else (and (match_operand:QI 0 "register_operand" "")
1902 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1903 (ne (symbol_ref "TARGET_MOVX")
1905 (const_string "imovx")
1906 (const_string "imov")))
1908 (if_then_else (eq_attr "type" "imovx")
1910 (const_string "QI")))])
1912 (define_insn "*movqi_extv_1_rex64"
1913 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
1914 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
1919 switch (get_attr_type (insn))
1922 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
1924 return "mov{b}\t{%h1, %0|%0, %h1}";
1928 (if_then_else (and (match_operand:QI 0 "register_operand" "")
1929 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1930 (ne (symbol_ref "TARGET_MOVX")
1932 (const_string "imovx")
1933 (const_string "imov")))
1935 (if_then_else (eq_attr "type" "imovx")
1937 (const_string "QI")))])
1939 ;; Stores and loads of ax to arbitrary constant address.
1940 ;; We fake an second form of instruction to force reload to load address
1941 ;; into register when rax is not available
1942 (define_insn "*movabsqi_1_rex64"
1943 [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1944 (match_operand:QI 1 "nonmemory_operand" "a,er"))]
1945 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1947 movabs{b}\t{%1, %P0|%P0, %1}
1948 mov{b}\t{%1, %a0|%a0, %1}"
1949 [(set_attr "type" "imov")
1950 (set_attr "modrm" "0,*")
1951 (set_attr "length_address" "8,0")
1952 (set_attr "length_immediate" "0,*")
1953 (set_attr "memory" "store")
1954 (set_attr "mode" "QI")])
1956 (define_insn "*movabsqi_2_rex64"
1957 [(set (match_operand:QI 0 "register_operand" "=a,r")
1958 (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1959 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1961 movabs{b}\t{%P1, %0|%0, %P1}
1962 mov{b}\t{%a1, %0|%0, %a1}"
1963 [(set_attr "type" "imov")
1964 (set_attr "modrm" "0,*")
1965 (set_attr "length_address" "8,0")
1966 (set_attr "length_immediate" "0")
1967 (set_attr "memory" "load")
1968 (set_attr "mode" "QI")])
1970 (define_insn "*movdi_extzv_1"
1971 [(set (match_operand:DI 0 "register_operand" "=R")
1972 (zero_extract:DI (match_operand 1 "ext_register_operand" "Q")
1976 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
1977 [(set_attr "type" "imovx")
1978 (set_attr "mode" "DI")])
1980 (define_insn "*movsi_extzv_1"
1981 [(set (match_operand:SI 0 "register_operand" "=R")
1982 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
1986 "movz{bl|x}\t{%h1, %0|%0, %h1}"
1987 [(set_attr "type" "imovx")
1988 (set_attr "mode" "SI")])
1990 (define_insn "*movqi_extzv_2"
1991 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
1992 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
1997 switch (get_attr_type (insn))
2000 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2002 return "mov{b}\t{%h1, %0|%0, %h1}";
2006 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2007 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2008 (ne (symbol_ref "TARGET_MOVX")
2010 (const_string "imovx")
2011 (const_string "imov")))
2013 (if_then_else (eq_attr "type" "imovx")
2015 (const_string "QI")))])
2017 (define_insn "*movqi_extzv_2_rex64"
2018 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2019 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2024 switch (get_attr_type (insn))
2027 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2029 return "mov{b}\t{%h1, %0|%0, %h1}";
2033 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2034 (ne (symbol_ref "TARGET_MOVX")
2036 (const_string "imovx")
2037 (const_string "imov")))
2039 (if_then_else (eq_attr "type" "imovx")
2041 (const_string "QI")))])
2043 (define_insn "movsi_insv_1"
2044 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2047 (match_operand:SI 1 "general_operand" "Qmn"))]
2049 "mov{b}\t{%b1, %h0|%h0, %b1}"
2050 [(set_attr "type" "imov")
2051 (set_attr "mode" "QI")])
2053 (define_insn "*movsi_insv_1_rex64"
2054 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2057 (match_operand:SI 1 "nonmemory_operand" "Qn"))]
2059 "mov{b}\t{%b1, %h0|%h0, %b1}"
2060 [(set_attr "type" "imov")
2061 (set_attr "mode" "QI")])
2063 (define_insn "movdi_insv_1_rex64"
2064 [(set (zero_extract:DI (match_operand 0 "ext_register_operand" "+Q")
2067 (match_operand:DI 1 "nonmemory_operand" "Qn"))]
2069 "mov{b}\t{%b1, %h0|%h0, %b1}"
2070 [(set_attr "type" "imov")
2071 (set_attr "mode" "QI")])
2073 (define_insn "*movqi_insv_2"
2074 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2077 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2080 "mov{b}\t{%h1, %h0|%h0, %h1}"
2081 [(set_attr "type" "imov")
2082 (set_attr "mode" "QI")])
2084 (define_expand "movdi"
2085 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2086 (match_operand:DI 1 "general_operand" ""))]
2088 "ix86_expand_move (DImode, operands); DONE;")
2090 (define_insn "*pushdi"
2091 [(set (match_operand:DI 0 "push_operand" "=<")
2092 (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
2096 (define_insn "*pushdi2_rex64"
2097 [(set (match_operand:DI 0 "push_operand" "=<,!<")
2098 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
2103 [(set_attr "type" "push,multi")
2104 (set_attr "mode" "DI")])
2106 ;; Convert impossible pushes of immediate to existing instructions.
2107 ;; First try to get scratch register and go through it. In case this
2108 ;; fails, push sign extended lower part first and then overwrite
2109 ;; upper part by 32bit move.
2111 [(match_scratch:DI 2 "r")
2112 (set (match_operand:DI 0 "push_operand" "")
2113 (match_operand:DI 1 "immediate_operand" ""))]
2114 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2115 && !x86_64_immediate_operand (operands[1], DImode)"
2116 [(set (match_dup 2) (match_dup 1))
2117 (set (match_dup 0) (match_dup 2))]
2120 ;; We need to define this as both peepholer and splitter for case
2121 ;; peephole2 pass is not run.
2122 ;; "&& 1" is needed to keep it from matching the previous pattern.
2124 [(set (match_operand:DI 0 "push_operand" "")
2125 (match_operand:DI 1 "immediate_operand" ""))]
2126 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2127 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2128 [(set (match_dup 0) (match_dup 1))
2129 (set (match_dup 2) (match_dup 3))]
2130 "split_di (operands + 1, 1, operands + 2, operands + 3);
2131 operands[1] = gen_lowpart (DImode, operands[2]);
2132 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2137 [(set (match_operand:DI 0 "push_operand" "")
2138 (match_operand:DI 1 "immediate_operand" ""))]
2139 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2140 ? epilogue_completed : reload_completed)
2141 && !symbolic_operand (operands[1], DImode)
2142 && !x86_64_immediate_operand (operands[1], DImode)"
2143 [(set (match_dup 0) (match_dup 1))
2144 (set (match_dup 2) (match_dup 3))]
2145 "split_di (operands + 1, 1, operands + 2, operands + 3);
2146 operands[1] = gen_lowpart (DImode, operands[2]);
2147 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2151 (define_insn "*pushdi2_prologue_rex64"
2152 [(set (match_operand:DI 0 "push_operand" "=<")
2153 (match_operand:DI 1 "general_no_elim_operand" "re*m"))
2154 (clobber (mem:BLK (scratch)))]
2157 [(set_attr "type" "push")
2158 (set_attr "mode" "DI")])
2160 (define_insn "*popdi1_epilogue_rex64"
2161 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2162 (mem:DI (reg:DI SP_REG)))
2163 (set (reg:DI SP_REG)
2164 (plus:DI (reg:DI SP_REG) (const_int 8)))
2165 (clobber (mem:BLK (scratch)))]
2168 [(set_attr "type" "pop")
2169 (set_attr "mode" "DI")])
2171 (define_insn "popdi1"
2172 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2173 (mem:DI (reg:DI SP_REG)))
2174 (set (reg:DI SP_REG)
2175 (plus:DI (reg:DI SP_REG) (const_int 8)))]
2178 [(set_attr "type" "pop")
2179 (set_attr "mode" "DI")])
2181 (define_insn "*movdi_xor_rex64"
2182 [(set (match_operand:DI 0 "register_operand" "=r")
2183 (match_operand:DI 1 "const0_operand" "i"))
2184 (clobber (reg:CC FLAGS_REG))]
2185 "TARGET_64BIT && (!TARGET_USE_MOV0 || optimize_size)
2186 && reload_completed"
2188 [(set_attr "type" "alu1")
2189 (set_attr "mode" "SI")
2190 (set_attr "length_immediate" "0")])
2192 (define_insn "*movdi_or_rex64"
2193 [(set (match_operand:DI 0 "register_operand" "=r")
2194 (match_operand:DI 1 "const_int_operand" "i"))
2195 (clobber (reg:CC FLAGS_REG))]
2196 "TARGET_64BIT && (TARGET_MOVE_M1_VIA_OR || optimize_size)
2198 && operands[1] == constm1_rtx"
2200 operands[1] = constm1_rtx;
2201 return "or{q}\t{%1, %0|%0, %1}";
2203 [(set_attr "type" "alu1")
2204 (set_attr "mode" "DI")
2205 (set_attr "length_immediate" "1")])
2207 (define_insn "*movdi_2"
2208 [(set (match_operand:DI 0 "nonimmediate_operand"
2209 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2210 (match_operand:DI 1 "general_operand"
2211 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2212 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2217 movq\t{%1, %0|%0, %1}
2218 movq\t{%1, %0|%0, %1}
2220 movq\t{%1, %0|%0, %1}
2221 movdqa\t{%1, %0|%0, %1}
2222 movq\t{%1, %0|%0, %1}
2224 movlps\t{%1, %0|%0, %1}
2225 movaps\t{%1, %0|%0, %1}
2226 movlps\t{%1, %0|%0, %1}"
2227 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2228 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2231 [(set (match_operand:DI 0 "push_operand" "")
2232 (match_operand:DI 1 "general_operand" ""))]
2233 "!TARGET_64BIT && reload_completed
2234 && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2236 "ix86_split_long_move (operands); DONE;")
2238 ;; %%% This multiword shite has got to go.
2240 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2241 (match_operand:DI 1 "general_operand" ""))]
2242 "!TARGET_64BIT && reload_completed
2243 && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
2244 && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2246 "ix86_split_long_move (operands); DONE;")
2248 (define_insn "*movdi_1_rex64"
2249 [(set (match_operand:DI 0 "nonimmediate_operand"
2250 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
2251 (match_operand:DI 1 "general_operand"
2252 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
2253 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2255 switch (get_attr_type (insn))
2258 if (SSE_REG_P (operands[0]))
2259 return "movq2dq\t{%1, %0|%0, %1}";
2261 return "movdq2q\t{%1, %0|%0, %1}";
2264 if (get_attr_mode (insn) == MODE_TI)
2265 return "movdqa\t{%1, %0|%0, %1}";
2269 /* Moves from and into integer register is done using movd
2270 opcode with REX prefix. */
2271 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2272 return "movd\t{%1, %0|%0, %1}";
2273 return "movq\t{%1, %0|%0, %1}";
2277 return "pxor\t%0, %0";
2283 return "lea{q}\t{%a1, %0|%0, %a1}";
2286 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2287 if (get_attr_mode (insn) == MODE_SI)
2288 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2289 else if (which_alternative == 2)
2290 return "movabs{q}\t{%1, %0|%0, %1}";
2292 return "mov{q}\t{%1, %0|%0, %1}";
2296 (cond [(eq_attr "alternative" "5")
2297 (const_string "mmxadd")
2298 (eq_attr "alternative" "6,7,8,9,10")
2299 (const_string "mmxmov")
2300 (eq_attr "alternative" "11")
2301 (const_string "sselog1")
2302 (eq_attr "alternative" "12,13,14,15,16")
2303 (const_string "ssemov")
2304 (eq_attr "alternative" "17,18")
2305 (const_string "ssecvt")
2306 (eq_attr "alternative" "4")
2307 (const_string "multi")
2308 (match_operand:DI 1 "pic_32bit_operand" "")
2309 (const_string "lea")
2311 (const_string "imov")))
2312 (set_attr "modrm" "*,0,0,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")
2313 (set_attr "length_immediate" "*,4,8,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")
2314 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2316 ;; Stores and loads of ax to arbitrary constant address.
2317 ;; We fake an second form of instruction to force reload to load address
2318 ;; into register when rax is not available
2319 (define_insn "*movabsdi_1_rex64"
2320 [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2321 (match_operand:DI 1 "nonmemory_operand" "a,er"))]
2322 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2324 movabs{q}\t{%1, %P0|%P0, %1}
2325 mov{q}\t{%1, %a0|%a0, %1}"
2326 [(set_attr "type" "imov")
2327 (set_attr "modrm" "0,*")
2328 (set_attr "length_address" "8,0")
2329 (set_attr "length_immediate" "0,*")
2330 (set_attr "memory" "store")
2331 (set_attr "mode" "DI")])
2333 (define_insn "*movabsdi_2_rex64"
2334 [(set (match_operand:DI 0 "register_operand" "=a,r")
2335 (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2336 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2338 movabs{q}\t{%P1, %0|%0, %P1}
2339 mov{q}\t{%a1, %0|%0, %a1}"
2340 [(set_attr "type" "imov")
2341 (set_attr "modrm" "0,*")
2342 (set_attr "length_address" "8,0")
2343 (set_attr "length_immediate" "0")
2344 (set_attr "memory" "load")
2345 (set_attr "mode" "DI")])
2347 ;; Convert impossible stores of immediate to existing instructions.
2348 ;; First try to get scratch register and go through it. In case this
2349 ;; fails, move by 32bit parts.
2351 [(match_scratch:DI 2 "r")
2352 (set (match_operand:DI 0 "memory_operand" "")
2353 (match_operand:DI 1 "immediate_operand" ""))]
2354 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2355 && !x86_64_immediate_operand (operands[1], DImode)"
2356 [(set (match_dup 2) (match_dup 1))
2357 (set (match_dup 0) (match_dup 2))]
2360 ;; We need to define this as both peepholer and splitter for case
2361 ;; peephole2 pass is not run.
2362 ;; "&& 1" is needed to keep it from matching the previous pattern.
2364 [(set (match_operand:DI 0 "memory_operand" "")
2365 (match_operand:DI 1 "immediate_operand" ""))]
2366 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2367 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2368 [(set (match_dup 2) (match_dup 3))
2369 (set (match_dup 4) (match_dup 5))]
2370 "split_di (operands, 2, operands + 2, operands + 4);")
2373 [(set (match_operand:DI 0 "memory_operand" "")
2374 (match_operand:DI 1 "immediate_operand" ""))]
2375 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2376 ? epilogue_completed : reload_completed)
2377 && !symbolic_operand (operands[1], DImode)
2378 && !x86_64_immediate_operand (operands[1], DImode)"
2379 [(set (match_dup 2) (match_dup 3))
2380 (set (match_dup 4) (match_dup 5))]
2381 "split_di (operands, 2, operands + 2, operands + 4);")
2383 (define_insn "*swapdi_rex64"
2384 [(set (match_operand:DI 0 "register_operand" "+r")
2385 (match_operand:DI 1 "register_operand" "+r"))
2390 [(set_attr "type" "imov")
2391 (set_attr "mode" "DI")
2392 (set_attr "pent_pair" "np")
2393 (set_attr "athlon_decode" "vector")
2394 (set_attr "amdfam10_decode" "double")])
2396 (define_expand "movti"
2397 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2398 (match_operand:TI 1 "nonimmediate_operand" ""))]
2399 "TARGET_SSE || TARGET_64BIT"
2402 ix86_expand_move (TImode, operands);
2403 else if (push_operand (operands[0], TImode))
2404 ix86_expand_push (TImode, operands[1]);
2406 ix86_expand_vector_move (TImode, operands);
2410 (define_insn "*movti_internal"
2411 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
2412 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
2413 "TARGET_SSE && !TARGET_64BIT
2414 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2416 switch (which_alternative)
2419 if (get_attr_mode (insn) == MODE_V4SF)
2420 return "xorps\t%0, %0";
2422 return "pxor\t%0, %0";
2425 /* TDmode values are passed as TImode on the stack. Moving them
2426 to stack may result in unaligned memory access. */
2427 if (misaligned_operand (operands[0], TImode)
2428 || misaligned_operand (operands[1], TImode))
2430 if (get_attr_mode (insn) == MODE_V4SF)
2431 return "movups\t{%1, %0|%0, %1}";
2433 return "movdqu\t{%1, %0|%0, %1}";
2437 if (get_attr_mode (insn) == MODE_V4SF)
2438 return "movaps\t{%1, %0|%0, %1}";
2440 return "movdqa\t{%1, %0|%0, %1}";
2446 [(set_attr "type" "sselog1,ssemov,ssemov")
2448 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2449 (ne (symbol_ref "optimize_size") (const_int 0)))
2450 (const_string "V4SF")
2451 (and (eq_attr "alternative" "2")
2452 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2454 (const_string "V4SF")]
2455 (const_string "TI")))])
2457 (define_insn "*movti_rex64"
2458 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o,x,x,xm")
2459 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
2461 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2463 switch (which_alternative)
2469 if (get_attr_mode (insn) == MODE_V4SF)
2470 return "xorps\t%0, %0";
2472 return "pxor\t%0, %0";
2475 /* TDmode values are passed as TImode on the stack. Moving them
2476 to stack may result in unaligned memory access. */
2477 if (misaligned_operand (operands[0], TImode)
2478 || misaligned_operand (operands[1], TImode))
2480 if (get_attr_mode (insn) == MODE_V4SF)
2481 return "movups\t{%1, %0|%0, %1}";
2483 return "movdqu\t{%1, %0|%0, %1}";
2487 if (get_attr_mode (insn) == MODE_V4SF)
2488 return "movaps\t{%1, %0|%0, %1}";
2490 return "movdqa\t{%1, %0|%0, %1}";
2496 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
2498 (cond [(eq_attr "alternative" "2,3")
2500 (ne (symbol_ref "optimize_size")
2502 (const_string "V4SF")
2503 (const_string "TI"))
2504 (eq_attr "alternative" "4")
2506 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2508 (ne (symbol_ref "optimize_size")
2510 (const_string "V4SF")
2511 (const_string "TI"))]
2512 (const_string "DI")))])
2515 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2516 (match_operand:TI 1 "general_operand" ""))]
2517 "reload_completed && !SSE_REG_P (operands[0])
2518 && !SSE_REG_P (operands[1])"
2520 "ix86_split_long_move (operands); DONE;")
2522 ;; This expands to what emit_move_complex would generate if we didn't
2523 ;; have a movti pattern. Having this avoids problems with reload on
2524 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
2525 ;; to have around all the time.
2526 (define_expand "movcdi"
2527 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
2528 (match_operand:CDI 1 "general_operand" ""))]
2531 if (push_operand (operands[0], CDImode))
2532 emit_move_complex_push (CDImode, operands[0], operands[1]);
2534 emit_move_complex_parts (operands[0], operands[1]);
2538 (define_expand "movsf"
2539 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2540 (match_operand:SF 1 "general_operand" ""))]
2542 "ix86_expand_move (SFmode, operands); DONE;")
2544 (define_insn "*pushsf"
2545 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2546 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2549 /* Anything else should be already split before reg-stack. */
2550 gcc_assert (which_alternative == 1);
2551 return "push{l}\t%1";
2553 [(set_attr "type" "multi,push,multi")
2554 (set_attr "unit" "i387,*,*")
2555 (set_attr "mode" "SF,SI,SF")])
2557 (define_insn "*pushsf_rex64"
2558 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2559 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2562 /* Anything else should be already split before reg-stack. */
2563 gcc_assert (which_alternative == 1);
2564 return "push{q}\t%q1";
2566 [(set_attr "type" "multi,push,multi")
2567 (set_attr "unit" "i387,*,*")
2568 (set_attr "mode" "SF,DI,SF")])
2571 [(set (match_operand:SF 0 "push_operand" "")
2572 (match_operand:SF 1 "memory_operand" ""))]
2574 && MEM_P (operands[1])
2575 && (operands[2] = find_constant_src (insn))"
2580 ;; %%% Kill this when call knows how to work this out.
2582 [(set (match_operand:SF 0 "push_operand" "")
2583 (match_operand:SF 1 "any_fp_register_operand" ""))]
2585 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
2586 (set (mem:SF (reg:SI SP_REG)) (match_dup 1))])
2589 [(set (match_operand:SF 0 "push_operand" "")
2590 (match_operand:SF 1 "any_fp_register_operand" ""))]
2592 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (const_int -8)))
2593 (set (mem:SF (reg:DI SP_REG)) (match_dup 1))])
2595 (define_insn "*movsf_1"
2596 [(set (match_operand:SF 0 "nonimmediate_operand"
2597 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
2598 (match_operand:SF 1 "general_operand"
2599 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
2600 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2601 && (reload_in_progress || reload_completed
2602 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2603 || (!TARGET_SSE_MATH && optimize_size
2604 && standard_80387_constant_p (operands[1]))
2605 || GET_CODE (operands[1]) != CONST_DOUBLE
2606 || memory_operand (operands[0], SFmode))"
2608 switch (which_alternative)
2612 return output_387_reg_move (insn, operands);
2615 return standard_80387_constant_opcode (operands[1]);
2619 return "mov{l}\t{%1, %0|%0, %1}";
2621 if (get_attr_mode (insn) == MODE_TI)
2622 return "pxor\t%0, %0";
2624 return "xorps\t%0, %0";
2626 if (get_attr_mode (insn) == MODE_V4SF)
2627 return "movaps\t{%1, %0|%0, %1}";
2629 return "movss\t{%1, %0|%0, %1}";
2631 return "movss\t{%1, %0|%0, %1}";
2634 case 12: case 13: case 14: case 15:
2635 return "movd\t{%1, %0|%0, %1}";
2638 return "movq\t{%1, %0|%0, %1}";
2644 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
2646 (cond [(eq_attr "alternative" "3,4,9,10")
2648 (eq_attr "alternative" "5")
2650 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2652 (ne (symbol_ref "TARGET_SSE2")
2654 (eq (symbol_ref "optimize_size")
2657 (const_string "V4SF"))
2658 /* For architectures resolving dependencies on
2659 whole SSE registers use APS move to break dependency
2660 chains, otherwise use short move to avoid extra work.
2662 Do the same for architectures resolving dependencies on
2663 the parts. While in DF mode it is better to always handle
2664 just register parts, the SF mode is different due to lack
2665 of instructions to load just part of the register. It is
2666 better to maintain the whole registers in single format
2667 to avoid problems on using packed logical operations. */
2668 (eq_attr "alternative" "6")
2670 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2672 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2674 (const_string "V4SF")
2675 (const_string "SF"))
2676 (eq_attr "alternative" "11")
2677 (const_string "DI")]
2678 (const_string "SF")))])
2680 (define_insn "*swapsf"
2681 [(set (match_operand:SF 0 "fp_register_operand" "+f")
2682 (match_operand:SF 1 "fp_register_operand" "+f"))
2685 "reload_completed || TARGET_80387"
2687 if (STACK_TOP_P (operands[0]))
2692 [(set_attr "type" "fxch")
2693 (set_attr "mode" "SF")])
2695 (define_expand "movdf"
2696 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2697 (match_operand:DF 1 "general_operand" ""))]
2699 "ix86_expand_move (DFmode, operands); DONE;")
2701 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2702 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2703 ;; On the average, pushdf using integers can be still shorter. Allow this
2704 ;; pattern for optimize_size too.
2706 (define_insn "*pushdf_nointeger"
2707 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2708 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
2709 "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
2711 /* This insn should be already split before reg-stack. */
2714 [(set_attr "type" "multi")
2715 (set_attr "unit" "i387,*,*,*")
2716 (set_attr "mode" "DF,SI,SI,DF")])
2718 (define_insn "*pushdf_integer"
2719 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2720 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
2721 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2723 /* This insn should be already split before reg-stack. */
2726 [(set_attr "type" "multi")
2727 (set_attr "unit" "i387,*,*")
2728 (set_attr "mode" "DF,SI,DF")])
2730 ;; %%% Kill this when call knows how to work this out.
2732 [(set (match_operand:DF 0 "push_operand" "")
2733 (match_operand:DF 1 "any_fp_register_operand" ""))]
2734 "!TARGET_64BIT && reload_completed"
2735 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -8)))
2736 (set (mem:DF (reg:SI SP_REG)) (match_dup 1))]
2740 [(set (match_operand:DF 0 "push_operand" "")
2741 (match_operand:DF 1 "any_fp_register_operand" ""))]
2742 "TARGET_64BIT && reload_completed"
2743 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (const_int -8)))
2744 (set (mem:DF (reg:DI SP_REG)) (match_dup 1))]
2748 [(set (match_operand:DF 0 "push_operand" "")
2749 (match_operand:DF 1 "general_operand" ""))]
2752 "ix86_split_long_move (operands); DONE;")
2754 ;; Moving is usually shorter when only FP registers are used. This separate
2755 ;; movdf pattern avoids the use of integer registers for FP operations
2756 ;; when optimizing for size.
2758 (define_insn "*movdf_nointeger"
2759 [(set (match_operand:DF 0 "nonimmediate_operand"
2760 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
2761 (match_operand:DF 1 "general_operand"
2762 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
2763 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2764 && ((optimize_size || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
2765 && (reload_in_progress || reload_completed
2766 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2767 || (!(TARGET_SSE2 && TARGET_SSE_MATH) && optimize_size
2768 && !memory_operand (operands[0], DFmode)
2769 && standard_80387_constant_p (operands[1]))
2770 || GET_CODE (operands[1]) != CONST_DOUBLE
2772 || !TARGET_MEMORY_MISMATCH_STALL
2773 || reload_in_progress || reload_completed)
2774 && memory_operand (operands[0], DFmode)))"
2776 switch (which_alternative)
2780 return output_387_reg_move (insn, operands);
2783 return standard_80387_constant_opcode (operands[1]);
2789 switch (get_attr_mode (insn))
2792 return "xorps\t%0, %0";
2794 return "xorpd\t%0, %0";
2796 return "pxor\t%0, %0";
2803 switch (get_attr_mode (insn))
2806 return "movaps\t{%1, %0|%0, %1}";
2808 return "movapd\t{%1, %0|%0, %1}";
2810 return "movdqa\t{%1, %0|%0, %1}";
2812 return "movq\t{%1, %0|%0, %1}";
2814 return "movsd\t{%1, %0|%0, %1}";
2816 return "movlpd\t{%1, %0|%0, %1}";
2818 return "movlps\t{%1, %0|%0, %1}";
2827 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
2829 (cond [(eq_attr "alternative" "0,1,2")
2831 (eq_attr "alternative" "3,4")
2834 /* For SSE1, we have many fewer alternatives. */
2835 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2836 (cond [(eq_attr "alternative" "5,6")
2837 (const_string "V4SF")
2839 (const_string "V2SF"))
2841 /* xorps is one byte shorter. */
2842 (eq_attr "alternative" "5")
2843 (cond [(ne (symbol_ref "optimize_size")
2845 (const_string "V4SF")
2846 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2850 (const_string "V2DF"))
2852 /* For architectures resolving dependencies on
2853 whole SSE registers use APD move to break dependency
2854 chains, otherwise use short move to avoid extra work.
2856 movaps encodes one byte shorter. */
2857 (eq_attr "alternative" "6")
2859 [(ne (symbol_ref "optimize_size")
2861 (const_string "V4SF")
2862 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2864 (const_string "V2DF")
2866 (const_string "DF"))
2867 /* For architectures resolving dependencies on register
2868 parts we may avoid extra work to zero out upper part
2870 (eq_attr "alternative" "7")
2872 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2874 (const_string "V1DF")
2875 (const_string "DF"))
2877 (const_string "DF")))])
2879 (define_insn "*movdf_integer_rex64"
2880 [(set (match_operand:DF 0 "nonimmediate_operand"
2881 "=f,m,f,r ,m ,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
2882 (match_operand:DF 1 "general_operand"
2883 "fm,f,G,rmF,Fr,C ,Y2*x,m ,Y2*x,r ,Yi"))]
2884 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2885 && (reload_in_progress || reload_completed
2886 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2887 || (!(TARGET_SSE2 && TARGET_SSE_MATH) && optimize_size
2888 && standard_80387_constant_p (operands[1]))
2889 || GET_CODE (operands[1]) != CONST_DOUBLE
2890 || memory_operand (operands[0], DFmode))"
2892 switch (which_alternative)
2896 return output_387_reg_move (insn, operands);
2899 return standard_80387_constant_opcode (operands[1]);
2906 switch (get_attr_mode (insn))
2909 return "xorps\t%0, %0";
2911 return "xorpd\t%0, %0";
2913 return "pxor\t%0, %0";
2920 switch (get_attr_mode (insn))
2923 return "movaps\t{%1, %0|%0, %1}";
2925 return "movapd\t{%1, %0|%0, %1}";
2927 return "movdqa\t{%1, %0|%0, %1}";
2929 return "movq\t{%1, %0|%0, %1}";
2931 return "movsd\t{%1, %0|%0, %1}";
2933 return "movlpd\t{%1, %0|%0, %1}";
2935 return "movlps\t{%1, %0|%0, %1}";
2942 return "movd\t{%1, %0|%0, %1}";
2948 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
2950 (cond [(eq_attr "alternative" "0,1,2")
2952 (eq_attr "alternative" "3,4,9,10")
2955 /* For SSE1, we have many fewer alternatives. */
2956 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2957 (cond [(eq_attr "alternative" "5,6")
2958 (const_string "V4SF")
2960 (const_string "V2SF"))
2962 /* xorps is one byte shorter. */
2963 (eq_attr "alternative" "5")
2964 (cond [(ne (symbol_ref "optimize_size")
2966 (const_string "V4SF")
2967 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2971 (const_string "V2DF"))
2973 /* For architectures resolving dependencies on
2974 whole SSE registers use APD move to break dependency
2975 chains, otherwise use short move to avoid extra work.
2977 movaps encodes one byte shorter. */
2978 (eq_attr "alternative" "6")
2980 [(ne (symbol_ref "optimize_size")
2982 (const_string "V4SF")
2983 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2985 (const_string "V2DF")
2987 (const_string "DF"))
2988 /* For architectures resolving dependencies on register
2989 parts we may avoid extra work to zero out upper part
2991 (eq_attr "alternative" "7")
2993 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2995 (const_string "V1DF")
2996 (const_string "DF"))
2998 (const_string "DF")))])
3000 (define_insn "*movdf_integer"
3001 [(set (match_operand:DF 0 "nonimmediate_operand"
3002 "=f,m,f,r ,o ,Y2*x,Y2*x,Y2*x,m ")
3003 (match_operand:DF 1 "general_operand"
3004 "fm,f,G,roF,Fr,C ,Y2*x,m ,Y2*x"))]
3005 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3006 && !optimize_size && TARGET_INTEGER_DFMODE_MOVES
3007 && (reload_in_progress || reload_completed
3008 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3009 || (!(TARGET_SSE2 && TARGET_SSE_MATH) && optimize_size
3010 && standard_80387_constant_p (operands[1]))
3011 || GET_CODE (operands[1]) != CONST_DOUBLE
3012 || memory_operand (operands[0], DFmode))"
3014 switch (which_alternative)
3018 return output_387_reg_move (insn, operands);
3021 return standard_80387_constant_opcode (operands[1]);
3028 switch (get_attr_mode (insn))
3031 return "xorps\t%0, %0";
3033 return "xorpd\t%0, %0";
3035 return "pxor\t%0, %0";
3042 switch (get_attr_mode (insn))
3045 return "movaps\t{%1, %0|%0, %1}";
3047 return "movapd\t{%1, %0|%0, %1}";
3049 return "movdqa\t{%1, %0|%0, %1}";
3051 return "movq\t{%1, %0|%0, %1}";
3053 return "movsd\t{%1, %0|%0, %1}";
3055 return "movlpd\t{%1, %0|%0, %1}";
3057 return "movlps\t{%1, %0|%0, %1}";
3066 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3068 (cond [(eq_attr "alternative" "0,1,2")
3070 (eq_attr "alternative" "3,4")
3073 /* For SSE1, we have many fewer alternatives. */
3074 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3075 (cond [(eq_attr "alternative" "5,6")
3076 (const_string "V4SF")
3078 (const_string "V2SF"))
3080 /* xorps is one byte shorter. */
3081 (eq_attr "alternative" "5")
3082 (cond [(ne (symbol_ref "optimize_size")
3084 (const_string "V4SF")
3085 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3089 (const_string "V2DF"))
3091 /* For architectures resolving dependencies on
3092 whole SSE registers use APD move to break dependency
3093 chains, otherwise use short move to avoid extra work.
3095 movaps encodes one byte shorter. */
3096 (eq_attr "alternative" "6")
3098 [(ne (symbol_ref "optimize_size")
3100 (const_string "V4SF")
3101 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3103 (const_string "V2DF")
3105 (const_string "DF"))
3106 /* For architectures resolving dependencies on register
3107 parts we may avoid extra work to zero out upper part
3109 (eq_attr "alternative" "7")
3111 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3113 (const_string "V1DF")
3114 (const_string "DF"))
3116 (const_string "DF")))])
3119 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3120 (match_operand:DF 1 "general_operand" ""))]
3122 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3123 && ! (ANY_FP_REG_P (operands[0]) ||
3124 (GET_CODE (operands[0]) == SUBREG
3125 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3126 && ! (ANY_FP_REG_P (operands[1]) ||
3127 (GET_CODE (operands[1]) == SUBREG
3128 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3130 "ix86_split_long_move (operands); DONE;")
3132 (define_insn "*swapdf"
3133 [(set (match_operand:DF 0 "fp_register_operand" "+f")
3134 (match_operand:DF 1 "fp_register_operand" "+f"))
3137 "reload_completed || TARGET_80387"
3139 if (STACK_TOP_P (operands[0]))
3144 [(set_attr "type" "fxch")
3145 (set_attr "mode" "DF")])
3147 (define_expand "movxf"
3148 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3149 (match_operand:XF 1 "general_operand" ""))]
3151 "ix86_expand_move (XFmode, operands); DONE;")
3153 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
3154 ;; Size of pushdf using integer instructions is 3+3*memory operand size
3155 ;; Pushing using integer instructions is longer except for constants
3156 ;; and direct memory references.
3157 ;; (assuming that any given constant is pushed only once, but this ought to be
3158 ;; handled elsewhere).
3160 (define_insn "*pushxf_nointeger"
3161 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
3162 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
3165 /* This insn should be already split before reg-stack. */
3168 [(set_attr "type" "multi")
3169 (set_attr "unit" "i387,*,*")
3170 (set_attr "mode" "XF,SI,SI")])
3172 (define_insn "*pushxf_integer"
3173 [(set (match_operand:XF 0 "push_operand" "=<,<")
3174 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
3177 /* This insn should be already split before reg-stack. */
3180 [(set_attr "type" "multi")
3181 (set_attr "unit" "i387,*")
3182 (set_attr "mode" "XF,SI")])
3185 [(set (match_operand 0 "push_operand" "")
3186 (match_operand 1 "general_operand" ""))]
3188 && (GET_MODE (operands[0]) == XFmode
3189 || GET_MODE (operands[0]) == DFmode)
3190 && !ANY_FP_REG_P (operands[1])"
3192 "ix86_split_long_move (operands); DONE;")
3195 [(set (match_operand:XF 0 "push_operand" "")
3196 (match_operand:XF 1 "any_fp_register_operand" ""))]
3198 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 2)))
3199 (set (mem:XF (reg:SI SP_REG)) (match_dup 1))]
3200 "operands[2] = GEN_INT (TARGET_128BIT_LONG_DOUBLE ? -16 : -12);")
3203 [(set (match_operand:XF 0 "push_operand" "")
3204 (match_operand:XF 1 "any_fp_register_operand" ""))]
3206 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (match_dup 2)))
3207 (set (mem:XF (reg:DI SP_REG)) (match_dup 1))]
3208 "operands[2] = GEN_INT (TARGET_128BIT_LONG_DOUBLE ? -16 : -12);")
3210 ;; Do not use integer registers when optimizing for size
3211 (define_insn "*movxf_nointeger"
3212 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
3213 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
3215 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3216 && (reload_in_progress || reload_completed
3217 || (optimize_size && standard_80387_constant_p (operands[1]))
3218 || GET_CODE (operands[1]) != CONST_DOUBLE
3219 || memory_operand (operands[0], XFmode))"
3221 switch (which_alternative)
3225 return output_387_reg_move (insn, operands);
3228 return standard_80387_constant_opcode (operands[1]);
3236 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3237 (set_attr "mode" "XF,XF,XF,SI,SI")])
3239 (define_insn "*movxf_integer"
3240 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,r,o")
3241 (match_operand:XF 1 "general_operand" "fm,f,G,roF,Fr"))]
3243 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3244 && (reload_in_progress || reload_completed
3245 || (optimize_size && standard_80387_constant_p (operands[1]))
3246 || GET_CODE (operands[1]) != CONST_DOUBLE
3247 || memory_operand (operands[0], XFmode))"
3249 switch (which_alternative)
3253 return output_387_reg_move (insn, operands);
3256 return standard_80387_constant_opcode (operands[1]);
3265 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3266 (set_attr "mode" "XF,XF,XF,SI,SI")])
3268 (define_expand "movtf"
3269 [(set (match_operand:TF 0 "nonimmediate_operand" "")
3270 (match_operand:TF 1 "nonimmediate_operand" ""))]
3273 ix86_expand_move (TFmode, operands);
3277 (define_insn "*movtf_internal"
3278 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?r,?o")
3279 (match_operand:TF 1 "general_operand" "xm,x,C,roF,Fr"))]
3281 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
3283 switch (which_alternative)
3287 if (get_attr_mode (insn) == MODE_V4SF)
3288 return "movaps\t{%1, %0|%0, %1}";
3290 return "movdqa\t{%1, %0|%0, %1}";
3292 if (get_attr_mode (insn) == MODE_V4SF)
3293 return "xorps\t%0, %0";
3295 return "pxor\t%0, %0";
3303 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
3305 (cond [(eq_attr "alternative" "0,2")
3307 (ne (symbol_ref "optimize_size")
3309 (const_string "V4SF")
3310 (const_string "TI"))
3311 (eq_attr "alternative" "1")
3313 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
3315 (ne (symbol_ref "optimize_size")
3317 (const_string "V4SF")
3318 (const_string "TI"))]
3319 (const_string "DI")))])
3322 [(set (match_operand 0 "nonimmediate_operand" "")
3323 (match_operand 1 "general_operand" ""))]
3325 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3326 && GET_MODE (operands[0]) == XFmode
3327 && ! (ANY_FP_REG_P (operands[0]) ||
3328 (GET_CODE (operands[0]) == SUBREG
3329 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3330 && ! (ANY_FP_REG_P (operands[1]) ||
3331 (GET_CODE (operands[1]) == SUBREG
3332 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3334 "ix86_split_long_move (operands); DONE;")
3337 [(set (match_operand 0 "register_operand" "")
3338 (match_operand 1 "memory_operand" ""))]
3340 && MEM_P (operands[1])
3341 && (GET_MODE (operands[0]) == TFmode
3342 || GET_MODE (operands[0]) == XFmode
3343 || GET_MODE (operands[0]) == SFmode
3344 || GET_MODE (operands[0]) == DFmode)
3345 && (operands[2] = find_constant_src (insn))"
3346 [(set (match_dup 0) (match_dup 2))]
3348 rtx c = operands[2];
3349 rtx r = operands[0];
3351 if (GET_CODE (r) == SUBREG)
3356 if (!standard_sse_constant_p (c))
3359 else if (FP_REG_P (r))
3361 if (!standard_80387_constant_p (c))
3364 else if (MMX_REG_P (r))
3369 [(set (match_operand 0 "register_operand" "")
3370 (float_extend (match_operand 1 "memory_operand" "")))]
3372 && MEM_P (operands[1])
3373 && (GET_MODE (operands[0]) == TFmode
3374 || GET_MODE (operands[0]) == XFmode
3375 || GET_MODE (operands[0]) == SFmode
3376 || GET_MODE (operands[0]) == DFmode)
3377 && (operands[2] = find_constant_src (insn))"
3378 [(set (match_dup 0) (match_dup 2))]
3380 rtx c = operands[2];
3381 rtx r = operands[0];
3383 if (GET_CODE (r) == SUBREG)
3388 if (!standard_sse_constant_p (c))
3391 else if (FP_REG_P (r))
3393 if (!standard_80387_constant_p (c))
3396 else if (MMX_REG_P (r))
3400 (define_insn "swapxf"
3401 [(set (match_operand:XF 0 "register_operand" "+f")
3402 (match_operand:XF 1 "register_operand" "+f"))
3407 if (STACK_TOP_P (operands[0]))
3412 [(set_attr "type" "fxch")
3413 (set_attr "mode" "XF")])
3415 ;; Split the load of -0.0 or -1.0 into fldz;fchs or fld1;fchs sequence
3417 [(set (match_operand:X87MODEF 0 "register_operand" "")
3418 (match_operand:X87MODEF 1 "immediate_operand" ""))]
3419 "reload_completed && FP_REGNO_P (REGNO (operands[0]))
3420 && (standard_80387_constant_p (operands[1]) == 8
3421 || standard_80387_constant_p (operands[1]) == 9)"
3422 [(set (match_dup 0)(match_dup 1))
3424 (neg:X87MODEF (match_dup 0)))]
3428 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
3429 if (real_isnegzero (&r))
3430 operands[1] = CONST0_RTX (<MODE>mode);
3432 operands[1] = CONST1_RTX (<MODE>mode);
3436 [(set (match_operand:TF 0 "nonimmediate_operand" "")
3437 (match_operand:TF 1 "general_operand" ""))]
3439 && !(SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]))"
3441 "ix86_split_long_move (operands); DONE;")
3443 ;; Zero extension instructions
3445 (define_expand "zero_extendhisi2"
3446 [(set (match_operand:SI 0 "register_operand" "")
3447 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3450 if (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3452 operands[1] = force_reg (HImode, operands[1]);
3453 emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3458 (define_insn "zero_extendhisi2_and"
3459 [(set (match_operand:SI 0 "register_operand" "=r")
3460 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3461 (clobber (reg:CC FLAGS_REG))]
3462 "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3464 [(set_attr "type" "alu1")
3465 (set_attr "mode" "SI")])
3468 [(set (match_operand:SI 0 "register_operand" "")
3469 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))
3470 (clobber (reg:CC FLAGS_REG))]
3471 "reload_completed && TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3472 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3473 (clobber (reg:CC FLAGS_REG))])]
3476 (define_insn "*zero_extendhisi2_movzwl"
3477 [(set (match_operand:SI 0 "register_operand" "=r")
3478 (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3479 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3480 "movz{wl|x}\t{%1, %0|%0, %1}"
3481 [(set_attr "type" "imovx")
3482 (set_attr "mode" "SI")])
3484 (define_expand "zero_extendqihi2"
3486 [(set (match_operand:HI 0 "register_operand" "")
3487 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3488 (clobber (reg:CC FLAGS_REG))])]
3492 (define_insn "*zero_extendqihi2_and"
3493 [(set (match_operand:HI 0 "register_operand" "=r,?&q")
3494 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3495 (clobber (reg:CC FLAGS_REG))]
3496 "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3498 [(set_attr "type" "alu1")
3499 (set_attr "mode" "HI")])
3501 (define_insn "*zero_extendqihi2_movzbw_and"
3502 [(set (match_operand:HI 0 "register_operand" "=r,r")
3503 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3504 (clobber (reg:CC FLAGS_REG))]
3505 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3507 [(set_attr "type" "imovx,alu1")
3508 (set_attr "mode" "HI")])
3510 ; zero extend to SImode here to avoid partial register stalls
3511 (define_insn "*zero_extendqihi2_movzbl"
3512 [(set (match_operand:HI 0 "register_operand" "=r")
3513 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3514 "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
3515 "movz{bl|x}\t{%1, %k0|%k0, %1}"
3516 [(set_attr "type" "imovx")
3517 (set_attr "mode" "SI")])
3519 ;; For the movzbw case strip only the clobber
3521 [(set (match_operand:HI 0 "register_operand" "")
3522 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3523 (clobber (reg:CC FLAGS_REG))]
3525 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3526 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3527 [(set (match_operand:HI 0 "register_operand" "")
3528 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))])
3530 ;; When source and destination does not overlap, clear destination
3531 ;; first and then do the movb
3533 [(set (match_operand:HI 0 "register_operand" "")
3534 (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3535 (clobber (reg:CC FLAGS_REG))]
3537 && ANY_QI_REG_P (operands[0])
3538 && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3539 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3540 [(set (match_dup 0) (const_int 0))
3541 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3542 "operands[2] = gen_lowpart (QImode, operands[0]);")
3544 ;; Rest is handled by single and.
3546 [(set (match_operand:HI 0 "register_operand" "")
3547 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))
3548 (clobber (reg:CC FLAGS_REG))]
3550 && true_regnum (operands[0]) == true_regnum (operands[1])"
3551 [(parallel [(set (match_dup 0) (and:HI (match_dup 0) (const_int 255)))
3552 (clobber (reg:CC FLAGS_REG))])]
3555 (define_expand "zero_extendqisi2"
3557 [(set (match_operand:SI 0 "register_operand" "")
3558 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3559 (clobber (reg:CC FLAGS_REG))])]
3563 (define_insn "*zero_extendqisi2_and"
3564 [(set (match_operand:SI 0 "register_operand" "=r,?&q")
3565 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3566 (clobber (reg:CC FLAGS_REG))]
3567 "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3569 [(set_attr "type" "alu1")
3570 (set_attr "mode" "SI")])
3572 (define_insn "*zero_extendqisi2_movzbw_and"
3573 [(set (match_operand:SI 0 "register_operand" "=r,r")
3574 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3575 (clobber (reg:CC FLAGS_REG))]
3576 "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3578 [(set_attr "type" "imovx,alu1")
3579 (set_attr "mode" "SI")])
3581 (define_insn "*zero_extendqisi2_movzbw"
3582 [(set (match_operand:SI 0 "register_operand" "=r")
3583 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3584 "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
3585 "movz{bl|x}\t{%1, %0|%0, %1}"
3586 [(set_attr "type" "imovx")
3587 (set_attr "mode" "SI")])
3589 ;; For the movzbl case strip only the clobber
3591 [(set (match_operand:SI 0 "register_operand" "")
3592 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3593 (clobber (reg:CC FLAGS_REG))]
3595 && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3596 && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3598 (zero_extend:SI (match_dup 1)))])
3600 ;; When source and destination does not overlap, clear destination
3601 ;; first and then do the movb
3603 [(set (match_operand:SI 0 "register_operand" "")
3604 (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3605 (clobber (reg:CC FLAGS_REG))]
3607 && ANY_QI_REG_P (operands[0])
3608 && (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]))
3609 && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3610 && !reg_overlap_mentioned_p (operands[0], operands[1])"
3611 [(set (match_dup 0) (const_int 0))
3612 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3613 "operands[2] = gen_lowpart (QImode, operands[0]);")
3615 ;; Rest is handled by single and.
3617 [(set (match_operand:SI 0 "register_operand" "")
3618 (zero_extend:SI (match_operand:QI 1 "register_operand" "")))
3619 (clobber (reg:CC FLAGS_REG))]
3621 && true_regnum (operands[0]) == true_regnum (operands[1])"
3622 [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 255)))
3623 (clobber (reg:CC FLAGS_REG))])]
3626 ;; %%% Kill me once multi-word ops are sane.
3627 (define_expand "zero_extendsidi2"
3628 [(set (match_operand:DI 0 "register_operand" "")
3629 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3634 emit_insn (gen_zero_extendsidi2_32 (operands[0], operands[1]));
3639 (define_insn "zero_extendsidi2_32"
3640 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?o,?*Ym,?*y,?*Yi,*Y2")
3642 (match_operand:SI 1 "nonimmediate_operand" "0,rm,r ,r ,m ,r ,m")))
3643 (clobber (reg:CC FLAGS_REG))]
3649 movd\t{%1, %0|%0, %1}
3650 movd\t{%1, %0|%0, %1}
3651 movd\t{%1, %0|%0, %1}
3652 movd\t{%1, %0|%0, %1}"
3653 [(set_attr "mode" "SI,SI,SI,DI,DI,TI,TI")
3654 (set_attr "type" "multi,multi,multi,mmxmov,mmxmov,ssemov,ssemov")])
3656 (define_insn "zero_extendsidi2_rex64"
3657 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,?*Ym,?*y,?*Yi,*Y2")
3659 (match_operand:SI 1 "nonimmediate_operand" "rm,0,r ,m ,r ,m")))]
3662 mov\t{%k1, %k0|%k0, %k1}
3664 movd\t{%1, %0|%0, %1}
3665 movd\t{%1, %0|%0, %1}
3666 movd\t{%1, %0|%0, %1}
3667 movd\t{%1, %0|%0, %1}"
3668 [(set_attr "type" "imovx,imov,mmxmov,mmxmov,ssemov,ssemov")
3669 (set_attr "mode" "SI,DI,DI,DI,TI,TI")])
3672 [(set (match_operand:DI 0 "memory_operand" "")
3673 (zero_extend:DI (match_dup 0)))]
3675 [(set (match_dup 4) (const_int 0))]
3676 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3679 [(set (match_operand:DI 0 "register_operand" "")
3680 (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3681 (clobber (reg:CC FLAGS_REG))]
3682 "!TARGET_64BIT && reload_completed
3683 && true_regnum (operands[0]) == true_regnum (operands[1])"
3684 [(set (match_dup 4) (const_int 0))]
3685 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3688 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3689 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3690 (clobber (reg:CC FLAGS_REG))]
3691 "!TARGET_64BIT && reload_completed
3692 && !SSE_REG_P (operands[0]) && !MMX_REG_P (operands[0])"
3693 [(set (match_dup 3) (match_dup 1))
3694 (set (match_dup 4) (const_int 0))]
3695 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3697 (define_insn "zero_extendhidi2"
3698 [(set (match_operand:DI 0 "register_operand" "=r")
3699 (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3701 "movz{wl|x}\t{%1, %k0|%k0, %1}"
3702 [(set_attr "type" "imovx")
3703 (set_attr "mode" "DI")])
3705 (define_insn "zero_extendqidi2"
3706 [(set (match_operand:DI 0 "register_operand" "=r")
3707 (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "rm")))]
3709 "movz{bl|x}\t{%1, %k0|%k0, %1}"
3710 [(set_attr "type" "imovx")
3711 (set_attr "mode" "DI")])
3713 ;; Sign extension instructions
3715 (define_expand "extendsidi2"
3716 [(parallel [(set (match_operand:DI 0 "register_operand" "")
3717 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3718 (clobber (reg:CC FLAGS_REG))
3719 (clobber (match_scratch:SI 2 ""))])]
3724 emit_insn (gen_extendsidi2_rex64 (operands[0], operands[1]));
3729 (define_insn "*extendsidi2_1"
3730 [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3731 (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3732 (clobber (reg:CC FLAGS_REG))
3733 (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3737 (define_insn "extendsidi2_rex64"
3738 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3739 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3743 movs{lq|x}\t{%1,%0|%0, %1}"
3744 [(set_attr "type" "imovx")
3745 (set_attr "mode" "DI")
3746 (set_attr "prefix_0f" "0")
3747 (set_attr "modrm" "0,1")])
3749 (define_insn "extendhidi2"
3750 [(set (match_operand:DI 0 "register_operand" "=r")
3751 (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3753 "movs{wq|x}\t{%1,%0|%0, %1}"
3754 [(set_attr "type" "imovx")
3755 (set_attr "mode" "DI")])
3757 (define_insn "extendqidi2"
3758 [(set (match_operand:DI 0 "register_operand" "=r")
3759 (sign_extend:DI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3761 "movs{bq|x}\t{%1,%0|%0, %1}"
3762 [(set_attr "type" "imovx")
3763 (set_attr "mode" "DI")])
3765 ;; Extend to memory case when source register does die.
3767 [(set (match_operand:DI 0 "memory_operand" "")
3768 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3769 (clobber (reg:CC FLAGS_REG))
3770 (clobber (match_operand:SI 2 "register_operand" ""))]
3772 && dead_or_set_p (insn, operands[1])
3773 && !reg_mentioned_p (operands[1], operands[0]))"
3774 [(set (match_dup 3) (match_dup 1))
3775 (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3776 (clobber (reg:CC FLAGS_REG))])
3777 (set (match_dup 4) (match_dup 1))]
3778 "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3780 ;; Extend to memory case when source register does not die.
3782 [(set (match_operand:DI 0 "memory_operand" "")
3783 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3784 (clobber (reg:CC FLAGS_REG))
3785 (clobber (match_operand:SI 2 "register_operand" ""))]
3789 split_di (&operands[0], 1, &operands[3], &operands[4]);
3791 emit_move_insn (operands[3], operands[1]);
3793 /* Generate a cltd if possible and doing so it profitable. */
3794 if ((optimize_size || TARGET_USE_CLTD)
3795 && true_regnum (operands[1]) == AX_REG
3796 && true_regnum (operands[2]) == DX_REG)
3798 emit_insn (gen_ashrsi3_31 (operands[2], operands[1], GEN_INT (31)));
3802 emit_move_insn (operands[2], operands[1]);
3803 emit_insn (gen_ashrsi3_31 (operands[2], operands[2], GEN_INT (31)));
3805 emit_move_insn (operands[4], operands[2]);
3809 ;; Extend to register case. Optimize case where source and destination
3810 ;; registers match and cases where we can use cltd.
3812 [(set (match_operand:DI 0 "register_operand" "")
3813 (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3814 (clobber (reg:CC FLAGS_REG))
3815 (clobber (match_scratch:SI 2 ""))]
3819 split_di (&operands[0], 1, &operands[3], &operands[4]);
3821 if (true_regnum (operands[3]) != true_regnum (operands[1]))
3822 emit_move_insn (operands[3], operands[1]);
3824 /* Generate a cltd if possible and doing so it profitable. */
3825 if ((optimize_size || TARGET_USE_CLTD)
3826 && true_regnum (operands[3]) == AX_REG)
3828 emit_insn (gen_ashrsi3_31 (operands[4], operands[3], GEN_INT (31)));
3832 if (true_regnum (operands[4]) != true_regnum (operands[1]))
3833 emit_move_insn (operands[4], operands[1]);
3835 emit_insn (gen_ashrsi3_31 (operands[4], operands[4], GEN_INT (31)));
3839 (define_insn "extendhisi2"
3840 [(set (match_operand:SI 0 "register_operand" "=*a,r")
3841 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3844 switch (get_attr_prefix_0f (insn))
3847 return "{cwtl|cwde}";
3849 return "movs{wl|x}\t{%1,%0|%0, %1}";
3852 [(set_attr "type" "imovx")
3853 (set_attr "mode" "SI")
3854 (set (attr "prefix_0f")
3855 ;; movsx is short decodable while cwtl is vector decoded.
3856 (if_then_else (and (eq_attr "cpu" "!k6")
3857 (eq_attr "alternative" "0"))
3859 (const_string "1")))
3861 (if_then_else (eq_attr "prefix_0f" "0")
3863 (const_string "1")))])
3865 (define_insn "*extendhisi2_zext"
3866 [(set (match_operand:DI 0 "register_operand" "=*a,r")
3868 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm"))))]
3871 switch (get_attr_prefix_0f (insn))
3874 return "{cwtl|cwde}";
3876 return "movs{wl|x}\t{%1,%k0|%k0, %1}";
3879 [(set_attr "type" "imovx")
3880 (set_attr "mode" "SI")
3881 (set (attr "prefix_0f")
3882 ;; movsx is short decodable while cwtl is vector decoded.
3883 (if_then_else (and (eq_attr "cpu" "!k6")
3884 (eq_attr "alternative" "0"))
3886 (const_string "1")))
3888 (if_then_else (eq_attr "prefix_0f" "0")
3890 (const_string "1")))])
3892 (define_insn "extendqihi2"
3893 [(set (match_operand:HI 0 "register_operand" "=*a,r")
3894 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "*0,qm")))]
3897 switch (get_attr_prefix_0f (insn))
3900 return "{cbtw|cbw}";
3902 return "movs{bw|x}\t{%1,%0|%0, %1}";
3905 [(set_attr "type" "imovx")
3906 (set_attr "mode" "HI")
3907 (set (attr "prefix_0f")
3908 ;; movsx is short decodable while cwtl is vector decoded.
3909 (if_then_else (and (eq_attr "cpu" "!k6")
3910 (eq_attr "alternative" "0"))
3912 (const_string "1")))
3914 (if_then_else (eq_attr "prefix_0f" "0")
3916 (const_string "1")))])
3918 (define_insn "extendqisi2"
3919 [(set (match_operand:SI 0 "register_operand" "=r")
3920 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3922 "movs{bl|x}\t{%1,%0|%0, %1}"
3923 [(set_attr "type" "imovx")
3924 (set_attr "mode" "SI")])
3926 (define_insn "*extendqisi2_zext"
3927 [(set (match_operand:DI 0 "register_operand" "=r")
3929 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm"))))]
3931 "movs{bl|x}\t{%1,%k0|%k0, %1}"
3932 [(set_attr "type" "imovx")
3933 (set_attr "mode" "SI")])
3935 ;; Conversions between float and double.
3937 ;; These are all no-ops in the model used for the 80387. So just
3940 ;; %%% Kill these when call knows how to work out a DFmode push earlier.
3941 (define_insn "*dummy_extendsfdf2"
3942 [(set (match_operand:DF 0 "push_operand" "=<")