OSDN Git Service

* config/i386/mmx.md (*mov<mode>_internal_rex64): Use %vmovq for
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / i386.md
1 ;; GCC machine description for IA-32 and x86-64.
2 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4 ;; Free Software Foundation, Inc.
5 ;; Mostly by William Schelter.
6 ;; x86_64 support added by Jan Hubicka
7 ;;
8 ;; This file is part of GCC.
9 ;;
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)
13 ;; any later version.
14 ;;
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.
19 ;;
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/>.  */
23 ;;
24 ;; The original PO technology requires these to be ordered by speed,
25 ;; so that assigner will pick the fastest.
26 ;;
27 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
28 ;;
29 ;; The special asm out single letter directives following a '%' are:
30 ;; L,W,B,Q,S,T -- print the opcode suffix for specified size of operand.
31 ;; C -- print opcode suffix for set/cmov insn.
32 ;; c -- like C, but print reversed condition
33 ;; F,f -- likewise, but for floating-point.
34 ;; O -- if HAVE_AS_IX86_CMOV_SUN_SYNTAX, expand to "w.", "l." or "q.",
35 ;;      otherwise nothing
36 ;; R -- print the prefix for register names.
37 ;; z -- print the opcode suffix for the size of the current operand.
38 ;; Z -- likewise, with special suffixes for x87 instructions.
39 ;; * -- print a star (in certain assembler syntax)
40 ;; A -- print an absolute memory reference.
41 ;; w -- print the operand as if it's a "word" (HImode) even if it isn't.
42 ;; s -- print a shift double count, followed by the assemblers argument
43 ;;      delimiter.
44 ;; b -- print the QImode name of the register for the indicated operand.
45 ;;      %b0 would print %al if operands[0] is reg 0.
46 ;; w --  likewise, print the HImode name of the register.
47 ;; k --  likewise, print the SImode name of the register.
48 ;; q --  likewise, print the DImode name of the register.
49 ;; x --  likewise, print the V4SFmode name of the register.
50 ;; t --  likewise, print the V8SFmode name of the register.
51 ;; h -- print the QImode name for a "high" register, either ah, bh, ch or dh.
52 ;; y -- print "st(0)" instead of "st" as a register.
53 ;; d -- print duplicated register operand for AVX instruction.
54 ;; D -- print condition for SSE cmp instruction.
55 ;; P -- if PIC, print an @PLT suffix.
56 ;; X -- don't print any sort of PIC '@' suffix for a symbol.
57 ;; & -- print some in-use local-dynamic symbol name.
58 ;; H -- print a memory address offset by 8; used for sse high-parts
59 ;; Y -- print condition for XOP pcom* instruction.
60 ;; + -- print a branch hint as 'cs' or 'ds' prefix
61 ;; ; -- print a semicolon (after prefixes due to bug in older gas).
62 ;; @ -- print a segment register of thread base pointer load
63
64 ;; UNSPEC usage:
65
66 (define_c_enum "unspec" [
67   ;; Relocation specifiers
68   UNSPEC_GOT
69   UNSPEC_GOTOFF
70   UNSPEC_GOTPCREL
71   UNSPEC_GOTTPOFF
72   UNSPEC_TPOFF
73   UNSPEC_NTPOFF
74   UNSPEC_DTPOFF
75   UNSPEC_GOTNTPOFF
76   UNSPEC_INDNTPOFF
77   UNSPEC_PLTOFF
78   UNSPEC_MACHOPIC_OFFSET
79   UNSPEC_PCREL
80
81   ;; Prologue support
82   UNSPEC_STACK_ALLOC
83   UNSPEC_SET_GOT
84   UNSPEC_REG_SAVE
85   UNSPEC_DEF_CFA
86   UNSPEC_SET_RIP
87   UNSPEC_SET_GOT_OFFSET
88   UNSPEC_MEMORY_BLOCKAGE
89   UNSPEC_STACK_CHECK
90
91   ;; TLS support
92   UNSPEC_TP
93   UNSPEC_TLS_GD
94   UNSPEC_TLS_LD_BASE
95   UNSPEC_TLSDESC
96   UNSPEC_TLS_IE_SUN
97
98   ;; Other random patterns
99   UNSPEC_SCAS
100   UNSPEC_FNSTSW
101   UNSPEC_SAHF
102   UNSPEC_PARITY
103   UNSPEC_FSTCW
104   UNSPEC_ADD_CARRY
105   UNSPEC_FLDCW
106   UNSPEC_REP
107   UNSPEC_LD_MPIC        ; load_macho_picbase
108   UNSPEC_TRUNC_NOOP
109   UNSPEC_DIV_ALREADY_SPLIT
110   UNSPEC_CALL_NEEDS_VZEROUPPER
111
112   ;; For SSE/MMX support:
113   UNSPEC_FIX_NOTRUNC
114   UNSPEC_MASKMOV
115   UNSPEC_MOVMSK
116   UNSPEC_MOVNT
117   UNSPEC_MOVU
118   UNSPEC_RCP
119   UNSPEC_RSQRT
120   UNSPEC_SFENCE
121   UNSPEC_PFRCP
122   UNSPEC_PFRCPIT1
123   UNSPEC_PFRCPIT2
124   UNSPEC_PFRSQRT
125   UNSPEC_PFRSQIT1
126   UNSPEC_MFENCE
127   UNSPEC_LFENCE
128   UNSPEC_PSADBW
129   UNSPEC_LDDQU
130   UNSPEC_MS_TO_SYSV_CALL
131
132   ;; Generic math support
133   UNSPEC_COPYSIGN
134   UNSPEC_IEEE_MIN       ; not commutative
135   UNSPEC_IEEE_MAX       ; not commutative
136
137   ;; x87 Floating point
138   UNSPEC_SIN
139   UNSPEC_COS
140   UNSPEC_FPATAN
141   UNSPEC_FYL2X
142   UNSPEC_FYL2XP1
143   UNSPEC_FRNDINT
144   UNSPEC_FIST
145   UNSPEC_F2XM1
146   UNSPEC_TAN
147   UNSPEC_FXAM
148
149   ;; x87 Rounding
150   UNSPEC_FRNDINT_FLOOR
151   UNSPEC_FRNDINT_CEIL
152   UNSPEC_FRNDINT_TRUNC
153   UNSPEC_FRNDINT_MASK_PM
154   UNSPEC_FIST_FLOOR
155   UNSPEC_FIST_CEIL
156
157   ;; x87 Double output FP
158   UNSPEC_SINCOS_COS
159   UNSPEC_SINCOS_SIN
160   UNSPEC_XTRACT_FRACT
161   UNSPEC_XTRACT_EXP
162   UNSPEC_FSCALE_FRACT
163   UNSPEC_FSCALE_EXP
164   UNSPEC_FPREM_F
165   UNSPEC_FPREM_U
166   UNSPEC_FPREM1_F
167   UNSPEC_FPREM1_U
168
169   UNSPEC_C2_FLAG
170   UNSPEC_FXAM_MEM
171
172   ;; SSP patterns
173   UNSPEC_SP_SET
174   UNSPEC_SP_TEST
175   UNSPEC_SP_TLS_SET
176   UNSPEC_SP_TLS_TEST
177
178   ;; SSSE3
179   UNSPEC_PSHUFB
180   UNSPEC_PSIGN
181   UNSPEC_PALIGNR
182
183   ;; For SSE4A support
184   UNSPEC_EXTRQI
185   UNSPEC_EXTRQ
186   UNSPEC_INSERTQI
187   UNSPEC_INSERTQ
188
189   ;; For SSE4.1 support
190   UNSPEC_BLENDV
191   UNSPEC_INSERTPS
192   UNSPEC_DP
193   UNSPEC_MOVNTDQA
194   UNSPEC_MPSADBW
195   UNSPEC_PHMINPOSUW
196   UNSPEC_PTEST
197   UNSPEC_ROUND
198
199   ;; For SSE4.2 support
200   UNSPEC_CRC32
201   UNSPEC_PCMPESTR
202   UNSPEC_PCMPISTR
203
204   ;; For FMA4 support
205   UNSPEC_FMADDSUB
206   UNSPEC_XOP_UNSIGNED_CMP
207   UNSPEC_XOP_TRUEFALSE
208   UNSPEC_XOP_PERMUTE
209   UNSPEC_FRCZ
210
211   ;; For AES support
212   UNSPEC_AESENC
213   UNSPEC_AESENCLAST
214   UNSPEC_AESDEC
215   UNSPEC_AESDECLAST
216   UNSPEC_AESIMC
217   UNSPEC_AESKEYGENASSIST
218
219   ;; For PCLMUL support
220   UNSPEC_PCLMUL
221
222   ;; For AVX support
223   UNSPEC_PCMP
224   UNSPEC_VPERMIL
225   UNSPEC_VPERMIL2
226   UNSPEC_VPERMIL2F128
227   UNSPEC_CAST
228   UNSPEC_VTESTP
229   UNSPEC_VCVTPH2PS
230   UNSPEC_VCVTPS2PH
231
232   ;; For BMI support
233   UNSPEC_BEXTR
234
235   ;; For RDRAND support
236   UNSPEC_RDRAND
237 ])
238
239 (define_c_enum "unspecv" [
240   UNSPECV_BLOCKAGE
241   UNSPECV_STACK_PROBE
242   UNSPECV_PROBE_STACK_RANGE
243   UNSPECV_EMMS
244   UNSPECV_LDMXCSR
245   UNSPECV_STMXCSR
246   UNSPECV_FEMMS
247   UNSPECV_CLFLUSH
248   UNSPECV_ALIGN
249   UNSPECV_MONITOR
250   UNSPECV_MWAIT
251   UNSPECV_CMPXCHG
252   UNSPECV_XCHG
253   UNSPECV_LOCK
254   UNSPECV_PROLOGUE_USE
255   UNSPECV_CLD
256   UNSPECV_NOPS
257   UNSPECV_VZEROALL
258   UNSPECV_VZEROUPPER
259   UNSPECV_RDTSC
260   UNSPECV_RDTSCP
261   UNSPECV_RDPMC
262   UNSPECV_LLWP_INTRINSIC
263   UNSPECV_SLWP_INTRINSIC
264   UNSPECV_LWPVAL_INTRINSIC
265   UNSPECV_LWPINS_INTRINSIC
266   UNSPECV_RDFSBASE
267   UNSPECV_RDGSBASE
268   UNSPECV_WRFSBASE
269   UNSPECV_WRGSBASE
270   UNSPECV_SPLIT_STACK_RETURN
271 ])
272
273 ;; Constants to represent rounding modes in the ROUND instruction
274 (define_constants
275   [(ROUND_FLOOR                 0x1)
276    (ROUND_CEIL                  0x2)
277    (ROUND_TRUNC                 0x3)
278    (ROUND_MXCSR                 0x4)
279    (ROUND_NO_EXC                0x8)
280   ])
281
282 ;; Constants to represent pcomtrue/pcomfalse variants
283 (define_constants
284   [(PCOM_FALSE                  0)
285    (PCOM_TRUE                   1)
286    (COM_FALSE_S                 2)
287    (COM_FALSE_P                 3)
288    (COM_TRUE_S                  4)
289    (COM_TRUE_P                  5)
290   ])
291
292 ;; Constants used in the XOP pperm instruction
293 (define_constants
294   [(PPERM_SRC                   0x00)   /* copy source */
295    (PPERM_INVERT                0x20)   /* invert source */
296    (PPERM_REVERSE               0x40)   /* bit reverse source */
297    (PPERM_REV_INV               0x60)   /* bit reverse & invert src */
298    (PPERM_ZERO                  0x80)   /* all 0's */
299    (PPERM_ONES                  0xa0)   /* all 1's */
300    (PPERM_SIGN                  0xc0)   /* propagate sign bit */
301    (PPERM_INV_SIGN              0xe0)   /* invert & propagate sign */
302    (PPERM_SRC1                  0x00)   /* use first source byte */
303    (PPERM_SRC2                  0x10)   /* use second source byte */
304    ])
305
306 ;; Registers by name.
307 (define_constants
308   [(AX_REG                       0)
309    (DX_REG                       1)
310    (CX_REG                       2)
311    (BX_REG                       3)
312    (SI_REG                       4)
313    (DI_REG                       5)
314    (BP_REG                       6)
315    (SP_REG                       7)
316    (ST0_REG                      8)
317    (ST1_REG                      9)
318    (ST2_REG                     10)
319    (ST3_REG                     11)
320    (ST4_REG                     12)
321    (ST5_REG                     13)
322    (ST6_REG                     14)
323    (ST7_REG                     15)
324    (FLAGS_REG                   17)
325    (FPSR_REG                    18)
326    (FPCR_REG                    19)
327    (XMM0_REG                    21)
328    (XMM1_REG                    22)
329    (XMM2_REG                    23)
330    (XMM3_REG                    24)
331    (XMM4_REG                    25)
332    (XMM5_REG                    26)
333    (XMM6_REG                    27)
334    (XMM7_REG                    28)
335    (MM0_REG                     29)
336    (MM1_REG                     30)
337    (MM2_REG                     31)
338    (MM3_REG                     32)
339    (MM4_REG                     33)
340    (MM5_REG                     34)
341    (MM6_REG                     35)
342    (MM7_REG                     36)
343    (R8_REG                      37)
344    (R9_REG                      38)
345    (R10_REG                     39)
346    (R11_REG                     40)
347    (R12_REG                     41)
348    (R13_REG                     42)
349    (XMM8_REG                    45)
350    (XMM9_REG                    46)
351    (XMM10_REG                   47)
352    (XMM11_REG                   48)
353    (XMM12_REG                   49)
354    (XMM13_REG                   50)
355    (XMM14_REG                   51)
356    (XMM15_REG                   52)
357   ])
358
359 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
360 ;; from i386.c.
361
362 ;; In C guard expressions, put expressions which may be compile-time
363 ;; constants first.  This allows for better optimization.  For
364 ;; example, write "TARGET_64BIT && reload_completed", not
365 ;; "reload_completed && TARGET_64BIT".
366
367 \f
368 ;; Processor type.
369 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,corei7,
370                     atom,generic64,amdfam10,bdver1,btver1"
371   (const (symbol_ref "ix86_schedule")))
372
373 ;; A basic instruction type.  Refinements due to arguments to be
374 ;; provided in other attributes.
375 (define_attr "type"
376   "other,multi,
377    alu,alu1,negnot,imov,imovx,lea,
378    incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
379    icmp,test,ibr,setcc,icmov,
380    push,pop,call,callv,leave,
381    str,bitmanip,
382    fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
383    sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
384    sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
385    ssemuladd,sse4arg,lwp,
386    mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
387   (const_string "other"))
388
389 ;; Main data type used by the insn
390 (define_attr "mode"
391   "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
392   (const_string "unknown"))
393
394 ;; The CPU unit operations uses.
395 (define_attr "unit" "integer,i387,sse,mmx,unknown"
396   (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
397            (const_string "i387")
398          (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
399                           sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
400                           ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
401            (const_string "sse")
402          (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
403            (const_string "mmx")
404          (eq_attr "type" "other")
405            (const_string "unknown")]
406          (const_string "integer")))
407
408 ;; The (bounding maximum) length of an instruction immediate.
409 (define_attr "length_immediate" ""
410   (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
411                           bitmanip")
412            (const_int 0)
413          (eq_attr "unit" "i387,sse,mmx")
414            (const_int 0)
415          (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
416                           imul,icmp,push,pop")
417            (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
418          (eq_attr "type" "imov,test")
419            (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
420          (eq_attr "type" "call")
421            (if_then_else (match_operand 0 "constant_call_address_operand" "")
422              (const_int 4)
423              (const_int 0))
424          (eq_attr "type" "callv")
425            (if_then_else (match_operand 1 "constant_call_address_operand" "")
426              (const_int 4)
427              (const_int 0))
428          ;; We don't know the size before shorten_branches.  Expect
429          ;; the instruction to fit for better scheduling.
430          (eq_attr "type" "ibr")
431            (const_int 1)
432          ]
433          (symbol_ref "/* Update immediate_length and other attributes! */
434                       gcc_unreachable (),1")))
435
436 ;; The (bounding maximum) length of an instruction address.
437 (define_attr "length_address" ""
438   (cond [(eq_attr "type" "str,other,multi,fxch")
439            (const_int 0)
440          (and (eq_attr "type" "call")
441               (match_operand 0 "constant_call_address_operand" ""))
442              (const_int 0)
443          (and (eq_attr "type" "callv")
444               (match_operand 1 "constant_call_address_operand" ""))
445              (const_int 0)
446          ]
447          (symbol_ref "ix86_attr_length_address_default (insn)")))
448
449 ;; Set when length prefix is used.
450 (define_attr "prefix_data16" ""
451   (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
452            (const_int 0)
453          (eq_attr "mode" "HI")
454            (const_int 1)
455          (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
456            (const_int 1)
457         ]
458         (const_int 0)))
459
460 ;; Set when string REP prefix is used.
461 (define_attr "prefix_rep" ""
462   (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
463            (const_int 0)
464          (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
465            (const_int 1)
466         ]
467         (const_int 0)))
468
469 ;; Set when 0f opcode prefix is used.
470 (define_attr "prefix_0f" ""
471   (if_then_else
472     (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
473          (eq_attr "unit" "sse,mmx"))
474     (const_int 1)
475     (const_int 0)))
476
477 ;; Set when REX opcode prefix is used.
478 (define_attr "prefix_rex" ""
479   (cond [(eq (symbol_ref "TARGET_64BIT") (const_int 0))
480            (const_int 0)
481          (and (eq_attr "mode" "DI")
482               (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
483                    (eq_attr "unit" "!mmx")))
484            (const_int 1)
485          (and (eq_attr "mode" "QI")
486               (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
487                   (const_int 0)))
488            (const_int 1)
489          (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
490              (const_int 0))
491            (const_int 1)
492          (and (eq_attr "type" "imovx")
493               (match_operand:QI 1 "ext_QIreg_operand" ""))
494            (const_int 1)
495         ]
496         (const_int 0)))
497
498 ;; There are also additional prefixes in 3DNOW, SSSE3.
499 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
500 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
501 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
502 (define_attr "prefix_extra" ""
503   (cond [(eq_attr "type" "ssemuladd,sse4arg")
504            (const_int 2)
505          (eq_attr "type" "sseiadd1,ssecvt1")
506            (const_int 1)
507         ]
508         (const_int 0)))
509
510 ;; Prefix used: original, VEX or maybe VEX.
511 (define_attr "prefix" "orig,vex,maybe_vex"
512   (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
513     (const_string "vex")
514     (const_string "orig")))
515
516 ;; VEX W bit is used.
517 (define_attr "prefix_vex_w" "" (const_int 0))
518
519 ;; The length of VEX prefix
520 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
521 ;; 0f38/0f3a prefixes can't.  In i386.md 0f3[8a] is
522 ;; still prefix_0f 1, with prefix_extra 1.
523 (define_attr "length_vex" ""
524   (if_then_else (and (eq_attr "prefix_0f" "1")
525                      (eq_attr "prefix_extra" "0"))
526     (if_then_else (eq_attr "prefix_vex_w" "1")
527       (symbol_ref "ix86_attr_length_vex_default (insn, 1, 1)")
528       (symbol_ref "ix86_attr_length_vex_default (insn, 1, 0)"))
529     (if_then_else (eq_attr "prefix_vex_w" "1")
530       (symbol_ref "ix86_attr_length_vex_default (insn, 0, 1)")
531       (symbol_ref "ix86_attr_length_vex_default (insn, 0, 0)"))))
532
533 ;; Set when modrm byte is used.
534 (define_attr "modrm" ""
535   (cond [(eq_attr "type" "str,leave")
536            (const_int 0)
537          (eq_attr "unit" "i387")
538            (const_int 0)
539          (and (eq_attr "type" "incdec")
540               (and (eq (symbol_ref "TARGET_64BIT") (const_int 0))
541                    (ior (match_operand:SI 1 "register_operand" "")
542                         (match_operand:HI 1 "register_operand" ""))))
543            (const_int 0)
544          (and (eq_attr "type" "push")
545               (not (match_operand 1 "memory_operand" "")))
546            (const_int 0)
547          (and (eq_attr "type" "pop")
548               (not (match_operand 0 "memory_operand" "")))
549            (const_int 0)
550          (and (eq_attr "type" "imov")
551               (and (not (eq_attr "mode" "DI"))
552                    (ior (and (match_operand 0 "register_operand" "")
553                              (match_operand 1 "immediate_operand" ""))
554                         (ior (and (match_operand 0 "ax_reg_operand" "")
555                                   (match_operand 1 "memory_displacement_only_operand" ""))
556                              (and (match_operand 0 "memory_displacement_only_operand" "")
557                                   (match_operand 1 "ax_reg_operand" ""))))))
558            (const_int 0)
559          (and (eq_attr "type" "call")
560               (match_operand 0 "constant_call_address_operand" ""))
561              (const_int 0)
562          (and (eq_attr "type" "callv")
563               (match_operand 1 "constant_call_address_operand" ""))
564              (const_int 0)
565          (and (eq_attr "type" "alu,alu1,icmp,test")
566               (match_operand 0 "ax_reg_operand" ""))
567              (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
568          ]
569          (const_int 1)))
570
571 ;; The (bounding maximum) length of an instruction in bytes.
572 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
573 ;; Later we may want to split them and compute proper length as for
574 ;; other insns.
575 (define_attr "length" ""
576   (cond [(eq_attr "type" "other,multi,fistp,frndint")
577            (const_int 16)
578          (eq_attr "type" "fcmp")
579            (const_int 4)
580          (eq_attr "unit" "i387")
581            (plus (const_int 2)
582                  (plus (attr "prefix_data16")
583                        (attr "length_address")))
584          (ior (eq_attr "prefix" "vex")
585               (and (eq_attr "prefix" "maybe_vex")
586                     (ne (symbol_ref "TARGET_AVX") (const_int 0))))
587            (plus (attr "length_vex")
588                  (plus (attr "length_immediate")
589                        (plus (attr "modrm")
590                              (attr "length_address"))))]
591          (plus (plus (attr "modrm")
592                      (plus (attr "prefix_0f")
593                            (plus (attr "prefix_rex")
594                                  (plus (attr "prefix_extra")
595                                        (const_int 1)))))
596                (plus (attr "prefix_rep")
597                      (plus (attr "prefix_data16")
598                            (plus (attr "length_immediate")
599                                  (attr "length_address")))))))
600
601 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
602 ;; `store' if there is a simple memory reference therein, or `unknown'
603 ;; if the instruction is complex.
604
605 (define_attr "memory" "none,load,store,both,unknown"
606   (cond [(eq_attr "type" "other,multi,str,lwp")
607            (const_string "unknown")
608          (eq_attr "type" "lea,fcmov,fpspc")
609            (const_string "none")
610          (eq_attr "type" "fistp,leave")
611            (const_string "both")
612          (eq_attr "type" "frndint")
613            (const_string "load")
614          (eq_attr "type" "push")
615            (if_then_else (match_operand 1 "memory_operand" "")
616              (const_string "both")
617              (const_string "store"))
618          (eq_attr "type" "pop")
619            (if_then_else (match_operand 0 "memory_operand" "")
620              (const_string "both")
621              (const_string "load"))
622          (eq_attr "type" "setcc")
623            (if_then_else (match_operand 0 "memory_operand" "")
624              (const_string "store")
625              (const_string "none"))
626          (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
627            (if_then_else (ior (match_operand 0 "memory_operand" "")
628                               (match_operand 1 "memory_operand" ""))
629              (const_string "load")
630              (const_string "none"))
631          (eq_attr "type" "ibr")
632            (if_then_else (match_operand 0 "memory_operand" "")
633              (const_string "load")
634              (const_string "none"))
635          (eq_attr "type" "call")
636            (if_then_else (match_operand 0 "constant_call_address_operand" "")
637              (const_string "none")
638              (const_string "load"))
639          (eq_attr "type" "callv")
640            (if_then_else (match_operand 1 "constant_call_address_operand" "")
641              (const_string "none")
642              (const_string "load"))
643          (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
644               (match_operand 1 "memory_operand" ""))
645            (const_string "both")
646          (and (match_operand 0 "memory_operand" "")
647               (match_operand 1 "memory_operand" ""))
648            (const_string "both")
649          (match_operand 0 "memory_operand" "")
650            (const_string "store")
651          (match_operand 1 "memory_operand" "")
652            (const_string "load")
653          (and (eq_attr "type"
654                  "!alu1,negnot,ishift1,
655                    imov,imovx,icmp,test,bitmanip,
656                    fmov,fcmp,fsgn,
657                    sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
658                    sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
659               (match_operand 2 "memory_operand" ""))
660            (const_string "load")
661          (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
662               (match_operand 3 "memory_operand" ""))
663            (const_string "load")
664         ]
665         (const_string "none")))
666
667 ;; Indicates if an instruction has both an immediate and a displacement.
668
669 (define_attr "imm_disp" "false,true,unknown"
670   (cond [(eq_attr "type" "other,multi")
671            (const_string "unknown")
672          (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
673               (and (match_operand 0 "memory_displacement_operand" "")
674                    (match_operand 1 "immediate_operand" "")))
675            (const_string "true")
676          (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
677               (and (match_operand 0 "memory_displacement_operand" "")
678                    (match_operand 2 "immediate_operand" "")))
679            (const_string "true")
680         ]
681         (const_string "false")))
682
683 ;; Indicates if an FP operation has an integer source.
684
685 (define_attr "fp_int_src" "false,true"
686   (const_string "false"))
687
688 ;; Defines rounding mode of an FP operation.
689
690 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
691   (const_string "any"))
692
693 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
694 (define_attr "use_carry" "0,1" (const_string "0"))
695
696 ;; Define attribute to indicate unaligned ssemov insns
697 (define_attr "movu" "0,1" (const_string "0"))
698
699 ;; Used to control the "enabled" attribute on a per-instruction basis.
700 (define_attr "isa" "base,noavx,avx"
701   (const_string "base"))
702
703 (define_attr "enabled" ""
704   (cond [(eq_attr "isa" "noavx") (symbol_ref "!TARGET_AVX")
705          (eq_attr "isa" "avx") (symbol_ref "TARGET_AVX")
706         ]
707         (const_int 1)))
708
709 ;; Describe a user's asm statement.
710 (define_asm_attributes
711   [(set_attr "length" "128")
712    (set_attr "type" "multi")])
713
714 (define_code_iterator plusminus [plus minus])
715
716 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
717
718 ;; Base name for define_insn
719 (define_code_attr plusminus_insn
720   [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
721    (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
722
723 ;; Base name for insn mnemonic.
724 (define_code_attr plusminus_mnemonic
725   [(plus "add") (ss_plus "adds") (us_plus "addus")
726    (minus "sub") (ss_minus "subs") (us_minus "subus")])
727 (define_code_attr plusminus_carry_mnemonic
728   [(plus "adc") (minus "sbb")])
729
730 ;; Mark commutative operators as such in constraints.
731 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
732                         (minus "") (ss_minus "") (us_minus "")])
733
734 ;; Mapping of signed max and min
735 (define_code_iterator smaxmin [smax smin])
736
737 ;; Mapping of unsigned max and min
738 (define_code_iterator umaxmin [umax umin])
739
740 ;; Base name for integer and FP insn mnemonic
741 (define_code_attr maxmin_int [(smax "maxs") (smin "mins")
742                               (umax "maxu") (umin "minu")])
743 (define_code_attr maxmin_float [(smax "max") (smin "min")])
744
745 ;; Mapping of logic operators
746 (define_code_iterator any_logic [and ior xor])
747 (define_code_iterator any_or [ior xor])
748
749 ;; Base name for insn mnemonic.
750 (define_code_attr logic [(and "and") (ior "or") (xor "xor")])
751
752 ;; Mapping of shift-right operators
753 (define_code_iterator any_shiftrt [lshiftrt ashiftrt])
754
755 ;; Base name for define_insn
756 (define_code_attr shiftrt_insn [(lshiftrt "lshr") (ashiftrt "ashr")])
757
758 ;; Base name for insn mnemonic.
759 (define_code_attr shiftrt [(lshiftrt "shr") (ashiftrt "sar")])
760
761 ;; Mapping of rotate operators
762 (define_code_iterator any_rotate [rotate rotatert])
763
764 ;; Base name for define_insn
765 (define_code_attr rotate_insn [(rotate "rotl") (rotatert "rotr")])
766
767 ;; Base name for insn mnemonic.
768 (define_code_attr rotate [(rotate "rol") (rotatert "ror")])
769
770 ;; Mapping of abs neg operators
771 (define_code_iterator absneg [abs neg])
772
773 ;; Base name for x87 insn mnemonic.
774 (define_code_attr absneg_mnemonic [(abs "abs") (neg "chs")])
775
776 ;; Used in signed and unsigned widening multiplications.
777 (define_code_iterator any_extend [sign_extend zero_extend])
778
779 ;; Various insn prefixes for signed and unsigned operations.
780 (define_code_attr u [(sign_extend "") (zero_extend "u")
781                      (div "") (udiv "u")])
782 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
783
784 ;; Used in signed and unsigned divisions.
785 (define_code_iterator any_div [div udiv])
786
787 ;; Instruction prefix for signed and unsigned operations.
788 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")
789                              (div "i") (udiv "")])
790
791 ;; 64bit single word integer modes.
792 (define_mode_iterator SWI1248x [QI HI SI DI])
793
794 ;; 64bit single word integer modes without QImode and HImode.
795 (define_mode_iterator SWI48x [SI DI])
796
797 ;; Single word integer modes.
798 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
799
800 ;; Single word integer modes without SImode and DImode.
801 (define_mode_iterator SWI12 [QI HI])
802
803 ;; Single word integer modes without DImode.
804 (define_mode_iterator SWI124 [QI HI SI])
805
806 ;; Single word integer modes without QImode and DImode.
807 (define_mode_iterator SWI24 [HI SI])
808
809 ;; Single word integer modes without QImode.
810 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
811
812 ;; Single word integer modes without QImode and HImode.
813 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
814
815 ;; All math-dependant single and double word integer modes.
816 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
817                              (HI "TARGET_HIMODE_MATH")
818                              SI DI (TI "TARGET_64BIT")])
819
820 ;; Math-dependant single word integer modes.
821 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
822                             (HI "TARGET_HIMODE_MATH")
823                             SI (DI "TARGET_64BIT")])
824
825 ;; Math-dependant single word integer modes without DImode.
826 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
827                                (HI "TARGET_HIMODE_MATH")
828                                SI])
829
830 ;; Math-dependant single word integer modes without QImode.
831 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
832                                SI (DI "TARGET_64BIT")])
833
834 ;; Double word integer modes.
835 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
836                            (TI "TARGET_64BIT")])
837
838 ;; Double word integer modes as mode attribute.
839 (define_mode_attr DWI [(SI "DI") (DI "TI")])
840 (define_mode_attr dwi [(SI "di") (DI "ti")])
841
842 ;; Half mode for double word integer modes.
843 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
844                             (DI "TARGET_64BIT")])
845
846 ;; Instruction suffix for integer modes.
847 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
848
849 ;; Pointer size prefix for integer modes (Intel asm dialect)
850 (define_mode_attr iptrsize [(QI "BYTE")
851                             (HI "WORD")
852                             (SI "DWORD")
853                             (DI "QWORD")])
854
855 ;; Register class for integer modes.
856 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
857
858 ;; Immediate operand constraint for integer modes.
859 (define_mode_attr i [(QI "n") (HI "n") (SI "i") (DI "e")])
860
861 ;; General operand constraint for word modes.
862 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "g") (DI "rme")])
863
864 ;; Immediate operand constraint for double integer modes.
865 (define_mode_attr di [(SI "iF") (DI "e")])
866
867 ;; Immediate operand constraint for shifts.
868 (define_mode_attr S [(QI "I") (HI "I") (SI "I") (DI "J") (TI "O")])
869
870 ;; General operand predicate for integer modes.
871 (define_mode_attr general_operand
872         [(QI "general_operand")
873          (HI "general_operand")
874          (SI "general_operand")
875          (DI "x86_64_general_operand")
876          (TI "x86_64_general_operand")])
877
878 ;; General sign/zero extend operand predicate for integer modes.
879 (define_mode_attr general_szext_operand
880         [(QI "general_operand")
881          (HI "general_operand")
882          (SI "general_operand")
883          (DI "x86_64_szext_general_operand")])
884
885 ;; Immediate operand predicate for integer modes.
886 (define_mode_attr immediate_operand
887         [(QI "immediate_operand")
888          (HI "immediate_operand")
889          (SI "immediate_operand")
890          (DI "x86_64_immediate_operand")])
891
892 ;; Nonmemory operand predicate for integer modes.
893 (define_mode_attr nonmemory_operand
894         [(QI "nonmemory_operand")
895          (HI "nonmemory_operand")
896          (SI "nonmemory_operand")
897          (DI "x86_64_nonmemory_operand")])
898
899 ;; Operand predicate for shifts.
900 (define_mode_attr shift_operand
901         [(QI "nonimmediate_operand")
902          (HI "nonimmediate_operand")
903          (SI "nonimmediate_operand")
904          (DI "shiftdi_operand")
905          (TI "register_operand")])
906
907 ;; Operand predicate for shift argument.
908 (define_mode_attr shift_immediate_operand
909         [(QI "const_1_to_31_operand")
910          (HI "const_1_to_31_operand")
911          (SI "const_1_to_31_operand")
912          (DI "const_1_to_63_operand")])
913
914 ;; Input operand predicate for arithmetic left shifts.
915 (define_mode_attr ashl_input_operand
916         [(QI "nonimmediate_operand")
917          (HI "nonimmediate_operand")
918          (SI "nonimmediate_operand")
919          (DI "ashldi_input_operand")
920          (TI "reg_or_pm1_operand")])
921
922 ;; SSE and x87 SFmode and DFmode floating point modes
923 (define_mode_iterator MODEF [SF DF])
924
925 ;; All x87 floating point modes
926 (define_mode_iterator X87MODEF [SF DF XF])
927
928 ;; All integer modes handled by x87 fisttp operator.
929 (define_mode_iterator X87MODEI [HI SI DI])
930
931 ;; All integer modes handled by integer x87 operators.
932 (define_mode_iterator X87MODEI12 [HI SI])
933
934 ;; All integer modes handled by SSE cvtts?2si* operators.
935 (define_mode_iterator SSEMODEI24 [SI DI])
936
937 ;; SSE instruction suffix for various modes
938 (define_mode_attr ssemodesuffix
939   [(SF "ss") (DF "sd")
940    (V8SF "ps") (V4DF "pd")
941    (V4SF "ps") (V2DF "pd")
942    (V16QI "b") (V8HI "w") (V4SI "d") (V2DI "q")
943    (V8SI "si")])
944
945 ;; SSE vector suffix for floating point modes
946 (define_mode_attr ssevecmodesuffix [(SF "ps") (DF "pd")])
947
948 ;; SSE vector mode corresponding to a scalar mode
949 (define_mode_attr ssevecmode
950   [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
951
952 ;; Instruction suffix for REX 64bit operators.
953 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
954
955 ;; This mode iterator allows :P to be used for patterns that operate on
956 ;; pointer-sized quantities.  Exactly one of the two alternatives will match.
957 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
958 \f
959 ;; Scheduling descriptions
960
961 (include "pentium.md")
962 (include "ppro.md")
963 (include "k6.md")
964 (include "athlon.md")
965 (include "bdver1.md")
966 (include "geode.md")
967 (include "atom.md")
968 (include "core2.md")
969
970 \f
971 ;; Operand and operator predicates and constraints
972
973 (include "predicates.md")
974 (include "constraints.md")
975
976 \f
977 ;; Compare and branch/compare and store instructions.
978
979 (define_expand "cbranch<mode>4"
980   [(set (reg:CC FLAGS_REG)
981         (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
982                     (match_operand:SDWIM 2 "<general_operand>" "")))
983    (set (pc) (if_then_else
984                (match_operator 0 "ordered_comparison_operator"
985                 [(reg:CC FLAGS_REG) (const_int 0)])
986                (label_ref (match_operand 3 "" ""))
987                (pc)))]
988   ""
989 {
990   if (MEM_P (operands[1]) && MEM_P (operands[2]))
991     operands[1] = force_reg (<MODE>mode, operands[1]);
992   ix86_expand_branch (GET_CODE (operands[0]),
993                       operands[1], operands[2], operands[3]);
994   DONE;
995 })
996
997 (define_expand "cstore<mode>4"
998   [(set (reg:CC FLAGS_REG)
999         (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
1000                     (match_operand:SWIM 3 "<general_operand>" "")))
1001    (set (match_operand:QI 0 "register_operand" "")
1002         (match_operator 1 "ordered_comparison_operator"
1003           [(reg:CC FLAGS_REG) (const_int 0)]))]
1004   ""
1005 {
1006   if (MEM_P (operands[2]) && MEM_P (operands[3]))
1007     operands[2] = force_reg (<MODE>mode, operands[2]);
1008   ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1009                      operands[2], operands[3]);
1010   DONE;
1011 })
1012
1013 (define_expand "cmp<mode>_1"
1014   [(set (reg:CC FLAGS_REG)
1015         (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
1016                     (match_operand:SWI48 1 "<general_operand>" "")))])
1017
1018 (define_insn "*cmp<mode>_ccno_1"
1019   [(set (reg FLAGS_REG)
1020         (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
1021                  (match_operand:SWI 1 "const0_operand" "")))]
1022   "ix86_match_ccmode (insn, CCNOmode)"
1023   "@
1024    test{<imodesuffix>}\t%0, %0
1025    cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1026   [(set_attr "type" "test,icmp")
1027    (set_attr "length_immediate" "0,1")
1028    (set_attr "mode" "<MODE>")])
1029
1030 (define_insn "*cmp<mode>_1"
1031   [(set (reg FLAGS_REG)
1032         (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1033                  (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
1034   "ix86_match_ccmode (insn, CCmode)"
1035   "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1036   [(set_attr "type" "icmp")
1037    (set_attr "mode" "<MODE>")])
1038
1039 (define_insn "*cmp<mode>_minus_1"
1040   [(set (reg FLAGS_REG)
1041         (compare
1042           (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1043                      (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
1044           (const_int 0)))]
1045   "ix86_match_ccmode (insn, CCGOCmode)"
1046   "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1047   [(set_attr "type" "icmp")
1048    (set_attr "mode" "<MODE>")])
1049
1050 (define_insn "*cmpqi_ext_1"
1051   [(set (reg FLAGS_REG)
1052         (compare
1053           (match_operand:QI 0 "general_operand" "Qm")
1054           (subreg:QI
1055             (zero_extract:SI
1056               (match_operand 1 "ext_register_operand" "Q")
1057               (const_int 8)
1058               (const_int 8)) 0)))]
1059   "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1060   "cmp{b}\t{%h1, %0|%0, %h1}"
1061   [(set_attr "type" "icmp")
1062    (set_attr "mode" "QI")])
1063
1064 (define_insn "*cmpqi_ext_1_rex64"
1065   [(set (reg FLAGS_REG)
1066         (compare
1067           (match_operand:QI 0 "register_operand" "Q")
1068           (subreg:QI
1069             (zero_extract:SI
1070               (match_operand 1 "ext_register_operand" "Q")
1071               (const_int 8)
1072               (const_int 8)) 0)))]
1073   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1074   "cmp{b}\t{%h1, %0|%0, %h1}"
1075   [(set_attr "type" "icmp")
1076    (set_attr "mode" "QI")])
1077
1078 (define_insn "*cmpqi_ext_2"
1079   [(set (reg FLAGS_REG)
1080         (compare
1081           (subreg:QI
1082             (zero_extract:SI
1083               (match_operand 0 "ext_register_operand" "Q")
1084               (const_int 8)
1085               (const_int 8)) 0)
1086           (match_operand:QI 1 "const0_operand" "")))]
1087   "ix86_match_ccmode (insn, CCNOmode)"
1088   "test{b}\t%h0, %h0"
1089   [(set_attr "type" "test")
1090    (set_attr "length_immediate" "0")
1091    (set_attr "mode" "QI")])
1092
1093 (define_expand "cmpqi_ext_3"
1094   [(set (reg:CC FLAGS_REG)
1095         (compare:CC
1096           (subreg:QI
1097             (zero_extract:SI
1098               (match_operand 0 "ext_register_operand" "")
1099               (const_int 8)
1100               (const_int 8)) 0)
1101           (match_operand:QI 1 "immediate_operand" "")))])
1102
1103 (define_insn "*cmpqi_ext_3_insn"
1104   [(set (reg FLAGS_REG)
1105         (compare
1106           (subreg:QI
1107             (zero_extract:SI
1108               (match_operand 0 "ext_register_operand" "Q")
1109               (const_int 8)
1110               (const_int 8)) 0)
1111           (match_operand:QI 1 "general_operand" "Qmn")))]
1112   "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1113   "cmp{b}\t{%1, %h0|%h0, %1}"
1114   [(set_attr "type" "icmp")
1115    (set_attr "modrm" "1")
1116    (set_attr "mode" "QI")])
1117
1118 (define_insn "*cmpqi_ext_3_insn_rex64"
1119   [(set (reg FLAGS_REG)
1120         (compare
1121           (subreg:QI
1122             (zero_extract:SI
1123               (match_operand 0 "ext_register_operand" "Q")
1124               (const_int 8)
1125               (const_int 8)) 0)
1126           (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1127   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1128   "cmp{b}\t{%1, %h0|%h0, %1}"
1129   [(set_attr "type" "icmp")
1130    (set_attr "modrm" "1")
1131    (set_attr "mode" "QI")])
1132
1133 (define_insn "*cmpqi_ext_4"
1134   [(set (reg FLAGS_REG)
1135         (compare
1136           (subreg:QI
1137             (zero_extract:SI
1138               (match_operand 0 "ext_register_operand" "Q")
1139               (const_int 8)
1140               (const_int 8)) 0)
1141           (subreg:QI
1142             (zero_extract:SI
1143               (match_operand 1 "ext_register_operand" "Q")
1144               (const_int 8)
1145               (const_int 8)) 0)))]
1146   "ix86_match_ccmode (insn, CCmode)"
1147   "cmp{b}\t{%h1, %h0|%h0, %h1}"
1148   [(set_attr "type" "icmp")
1149    (set_attr "mode" "QI")])
1150
1151 ;; These implement float point compares.
1152 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1153 ;; which would allow mix and match FP modes on the compares.  Which is what
1154 ;; the old patterns did, but with many more of them.
1155
1156 (define_expand "cbranchxf4"
1157   [(set (reg:CC FLAGS_REG)
1158         (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1159                     (match_operand:XF 2 "nonmemory_operand" "")))
1160    (set (pc) (if_then_else
1161               (match_operator 0 "ix86_fp_comparison_operator"
1162                [(reg:CC FLAGS_REG)
1163                 (const_int 0)])
1164               (label_ref (match_operand 3 "" ""))
1165               (pc)))]
1166   "TARGET_80387"
1167 {
1168   ix86_expand_branch (GET_CODE (operands[0]),
1169                       operands[1], operands[2], operands[3]);
1170   DONE;
1171 })
1172
1173 (define_expand "cstorexf4"
1174   [(set (reg:CC FLAGS_REG)
1175         (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1176                     (match_operand:XF 3 "nonmemory_operand" "")))
1177    (set (match_operand:QI 0 "register_operand" "")
1178               (match_operator 1 "ix86_fp_comparison_operator"
1179                [(reg:CC FLAGS_REG)
1180                 (const_int 0)]))]
1181   "TARGET_80387"
1182 {
1183   ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1184                      operands[2], operands[3]);
1185   DONE;
1186 })
1187
1188 (define_expand "cbranch<mode>4"
1189   [(set (reg:CC FLAGS_REG)
1190         (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1191                     (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1192    (set (pc) (if_then_else
1193               (match_operator 0 "ix86_fp_comparison_operator"
1194                [(reg:CC FLAGS_REG)
1195                 (const_int 0)])
1196               (label_ref (match_operand 3 "" ""))
1197               (pc)))]
1198   "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1199 {
1200   ix86_expand_branch (GET_CODE (operands[0]),
1201                       operands[1], operands[2], operands[3]);
1202   DONE;
1203 })
1204
1205 (define_expand "cstore<mode>4"
1206   [(set (reg:CC FLAGS_REG)
1207         (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1208                     (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1209    (set (match_operand:QI 0 "register_operand" "")
1210               (match_operator 1 "ix86_fp_comparison_operator"
1211                [(reg:CC FLAGS_REG)
1212                 (const_int 0)]))]
1213   "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1214 {
1215   ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1216                      operands[2], operands[3]);
1217   DONE;
1218 })
1219
1220 (define_expand "cbranchcc4"
1221   [(set (pc) (if_then_else
1222               (match_operator 0 "comparison_operator"
1223                [(match_operand 1 "flags_reg_operand" "")
1224                 (match_operand 2 "const0_operand" "")])
1225               (label_ref (match_operand 3 "" ""))
1226               (pc)))]
1227   ""
1228 {
1229   ix86_expand_branch (GET_CODE (operands[0]),
1230                       operands[1], operands[2], operands[3]);
1231   DONE;
1232 })
1233
1234 (define_expand "cstorecc4"
1235   [(set (match_operand:QI 0 "register_operand" "")
1236               (match_operator 1 "comparison_operator"
1237                [(match_operand 2 "flags_reg_operand" "")
1238                 (match_operand 3 "const0_operand" "")]))]
1239   ""
1240 {
1241   ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1242                      operands[2], operands[3]);
1243   DONE;
1244 })
1245
1246
1247 ;; FP compares, step 1:
1248 ;; Set the FP condition codes.
1249 ;;
1250 ;; CCFPmode     compare with exceptions
1251 ;; CCFPUmode    compare with no exceptions
1252
1253 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1254 ;; used to manage the reg stack popping would not be preserved.
1255
1256 (define_insn "*cmpfp_0"
1257   [(set (match_operand:HI 0 "register_operand" "=a")
1258         (unspec:HI
1259           [(compare:CCFP
1260              (match_operand 1 "register_operand" "f")
1261              (match_operand 2 "const0_operand" ""))]
1262         UNSPEC_FNSTSW))]
1263   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1264    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1265   "* return output_fp_compare (insn, operands, 0, 0);"
1266   [(set_attr "type" "multi")
1267    (set_attr "unit" "i387")
1268    (set (attr "mode")
1269      (cond [(match_operand:SF 1 "" "")
1270               (const_string "SF")
1271             (match_operand:DF 1 "" "")
1272               (const_string "DF")
1273            ]
1274            (const_string "XF")))])
1275
1276 (define_insn_and_split "*cmpfp_0_cc"
1277   [(set (reg:CCFP FLAGS_REG)
1278         (compare:CCFP
1279           (match_operand 1 "register_operand" "f")
1280           (match_operand 2 "const0_operand" "")))
1281    (clobber (match_operand:HI 0 "register_operand" "=a"))]
1282   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1283    && TARGET_SAHF && !TARGET_CMOVE
1284    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1285   "#"
1286   "&& reload_completed"
1287   [(set (match_dup 0)
1288         (unspec:HI
1289           [(compare:CCFP (match_dup 1)(match_dup 2))]
1290         UNSPEC_FNSTSW))
1291    (set (reg:CC FLAGS_REG)
1292         (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1293   ""
1294   [(set_attr "type" "multi")
1295    (set_attr "unit" "i387")
1296    (set (attr "mode")
1297      (cond [(match_operand:SF 1 "" "")
1298               (const_string "SF")
1299             (match_operand:DF 1 "" "")
1300               (const_string "DF")
1301            ]
1302            (const_string "XF")))])
1303
1304 (define_insn "*cmpfp_xf"
1305   [(set (match_operand:HI 0 "register_operand" "=a")
1306         (unspec:HI
1307           [(compare:CCFP
1308              (match_operand:XF 1 "register_operand" "f")
1309              (match_operand:XF 2 "register_operand" "f"))]
1310           UNSPEC_FNSTSW))]
1311   "TARGET_80387"
1312   "* return output_fp_compare (insn, operands, 0, 0);"
1313   [(set_attr "type" "multi")
1314    (set_attr "unit" "i387")
1315    (set_attr "mode" "XF")])
1316
1317 (define_insn_and_split "*cmpfp_xf_cc"
1318   [(set (reg:CCFP FLAGS_REG)
1319         (compare:CCFP
1320           (match_operand:XF 1 "register_operand" "f")
1321           (match_operand:XF 2 "register_operand" "f")))
1322    (clobber (match_operand:HI 0 "register_operand" "=a"))]
1323   "TARGET_80387
1324    && TARGET_SAHF && !TARGET_CMOVE"
1325   "#"
1326   "&& reload_completed"
1327   [(set (match_dup 0)
1328         (unspec:HI
1329           [(compare:CCFP (match_dup 1)(match_dup 2))]
1330         UNSPEC_FNSTSW))
1331    (set (reg:CC FLAGS_REG)
1332         (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1333   ""
1334   [(set_attr "type" "multi")
1335    (set_attr "unit" "i387")
1336    (set_attr "mode" "XF")])
1337
1338 (define_insn "*cmpfp_<mode>"
1339   [(set (match_operand:HI 0 "register_operand" "=a")
1340         (unspec:HI
1341           [(compare:CCFP
1342              (match_operand:MODEF 1 "register_operand" "f")
1343              (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1344           UNSPEC_FNSTSW))]
1345   "TARGET_80387"
1346   "* return output_fp_compare (insn, operands, 0, 0);"
1347   [(set_attr "type" "multi")
1348    (set_attr "unit" "i387")
1349    (set_attr "mode" "<MODE>")])
1350
1351 (define_insn_and_split "*cmpfp_<mode>_cc"
1352   [(set (reg:CCFP FLAGS_REG)
1353         (compare:CCFP
1354           (match_operand:MODEF 1 "register_operand" "f")
1355           (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1356    (clobber (match_operand:HI 0 "register_operand" "=a"))]
1357   "TARGET_80387
1358    && TARGET_SAHF && !TARGET_CMOVE"
1359   "#"
1360   "&& reload_completed"
1361   [(set (match_dup 0)
1362         (unspec:HI
1363           [(compare:CCFP (match_dup 1)(match_dup 2))]
1364         UNSPEC_FNSTSW))
1365    (set (reg:CC FLAGS_REG)
1366         (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1367   ""
1368   [(set_attr "type" "multi")
1369    (set_attr "unit" "i387")
1370    (set_attr "mode" "<MODE>")])
1371
1372 (define_insn "*cmpfp_u"
1373   [(set (match_operand:HI 0 "register_operand" "=a")
1374         (unspec:HI
1375           [(compare:CCFPU
1376              (match_operand 1 "register_operand" "f")
1377              (match_operand 2 "register_operand" "f"))]
1378           UNSPEC_FNSTSW))]
1379   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1380    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1381   "* return output_fp_compare (insn, operands, 0, 1);"
1382   [(set_attr "type" "multi")
1383    (set_attr "unit" "i387")
1384    (set (attr "mode")
1385      (cond [(match_operand:SF 1 "" "")
1386               (const_string "SF")
1387             (match_operand:DF 1 "" "")
1388               (const_string "DF")
1389            ]
1390            (const_string "XF")))])
1391
1392 (define_insn_and_split "*cmpfp_u_cc"
1393   [(set (reg:CCFPU FLAGS_REG)
1394         (compare:CCFPU
1395           (match_operand 1 "register_operand" "f")
1396           (match_operand 2 "register_operand" "f")))
1397    (clobber (match_operand:HI 0 "register_operand" "=a"))]
1398   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1399    && TARGET_SAHF && !TARGET_CMOVE
1400    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1401   "#"
1402   "&& reload_completed"
1403   [(set (match_dup 0)
1404         (unspec:HI
1405           [(compare:CCFPU (match_dup 1)(match_dup 2))]
1406         UNSPEC_FNSTSW))
1407    (set (reg:CC FLAGS_REG)
1408         (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1409   ""
1410   [(set_attr "type" "multi")
1411    (set_attr "unit" "i387")
1412    (set (attr "mode")
1413      (cond [(match_operand:SF 1 "" "")
1414               (const_string "SF")
1415             (match_operand:DF 1 "" "")
1416               (const_string "DF")
1417            ]
1418            (const_string "XF")))])
1419
1420 (define_insn "*cmpfp_<mode>"
1421   [(set (match_operand:HI 0 "register_operand" "=a")
1422         (unspec:HI
1423           [(compare:CCFP
1424              (match_operand 1 "register_operand" "f")
1425              (match_operator 3 "float_operator"
1426                [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1427           UNSPEC_FNSTSW))]
1428   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1429    && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1430    && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1431   "* return output_fp_compare (insn, operands, 0, 0);"
1432   [(set_attr "type" "multi")
1433    (set_attr "unit" "i387")
1434    (set_attr "fp_int_src" "true")
1435    (set_attr "mode" "<MODE>")])
1436
1437 (define_insn_and_split "*cmpfp_<mode>_cc"
1438   [(set (reg:CCFP FLAGS_REG)
1439         (compare:CCFP
1440           (match_operand 1 "register_operand" "f")
1441           (match_operator 3 "float_operator"
1442             [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1443    (clobber (match_operand:HI 0 "register_operand" "=a"))]
1444   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1445    && TARGET_SAHF && !TARGET_CMOVE
1446    && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1447    && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1448   "#"
1449   "&& reload_completed"
1450   [(set (match_dup 0)
1451         (unspec:HI
1452           [(compare:CCFP
1453              (match_dup 1)
1454              (match_op_dup 3 [(match_dup 2)]))]
1455         UNSPEC_FNSTSW))
1456    (set (reg:CC FLAGS_REG)
1457         (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1458   ""
1459   [(set_attr "type" "multi")
1460    (set_attr "unit" "i387")
1461    (set_attr "fp_int_src" "true")
1462    (set_attr "mode" "<MODE>")])
1463
1464 ;; FP compares, step 2
1465 ;; Move the fpsw to ax.
1466
1467 (define_insn "x86_fnstsw_1"
1468   [(set (match_operand:HI 0 "register_operand" "=a")
1469         (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1470   "TARGET_80387"
1471   "fnstsw\t%0"
1472   [(set (attr "length") (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1473    (set_attr "mode" "SI")
1474    (set_attr "unit" "i387")])
1475
1476 ;; FP compares, step 3
1477 ;; Get ax into flags, general case.
1478
1479 (define_insn "x86_sahf_1"
1480   [(set (reg:CC FLAGS_REG)
1481         (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1482                    UNSPEC_SAHF))]
1483   "TARGET_SAHF"
1484 {
1485 #ifndef HAVE_AS_IX86_SAHF
1486   if (TARGET_64BIT)
1487     return ASM_BYTE "0x9e";
1488   else
1489 #endif
1490   return "sahf";
1491 }
1492   [(set_attr "length" "1")
1493    (set_attr "athlon_decode" "vector")
1494    (set_attr "amdfam10_decode" "direct")
1495    (set_attr "bdver1_decode" "direct")
1496    (set_attr "mode" "SI")])
1497
1498 ;; Pentium Pro can do steps 1 through 3 in one go.
1499 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1500 (define_insn "*cmpfp_i_mixed"
1501   [(set (reg:CCFP FLAGS_REG)
1502         (compare:CCFP (match_operand 0 "register_operand" "f,x")
1503                       (match_operand 1 "nonimmediate_operand" "f,xm")))]
1504   "TARGET_MIX_SSE_I387
1505    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1506    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1507   "* return output_fp_compare (insn, operands, 1, 0);"
1508   [(set_attr "type" "fcmp,ssecomi")
1509    (set_attr "prefix" "orig,maybe_vex")
1510    (set (attr "mode")
1511      (if_then_else (match_operand:SF 1 "" "")
1512         (const_string "SF")
1513         (const_string "DF")))
1514    (set (attr "prefix_rep")
1515         (if_then_else (eq_attr "type" "ssecomi")
1516                       (const_string "0")
1517                       (const_string "*")))
1518    (set (attr "prefix_data16")
1519         (cond [(eq_attr "type" "fcmp")
1520                  (const_string "*")
1521                (eq_attr "mode" "DF")
1522                  (const_string "1")
1523               ]
1524               (const_string "0")))
1525    (set_attr "athlon_decode" "vector")
1526    (set_attr "amdfam10_decode" "direct")
1527    (set_attr "bdver1_decode" "double")])
1528
1529 (define_insn "*cmpfp_i_sse"
1530   [(set (reg:CCFP FLAGS_REG)
1531         (compare:CCFP (match_operand 0 "register_operand" "x")
1532                       (match_operand 1 "nonimmediate_operand" "xm")))]
1533   "TARGET_SSE_MATH
1534    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1535    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1536   "* return output_fp_compare (insn, operands, 1, 0);"
1537   [(set_attr "type" "ssecomi")
1538    (set_attr "prefix" "maybe_vex")
1539    (set (attr "mode")
1540      (if_then_else (match_operand:SF 1 "" "")
1541         (const_string "SF")
1542         (const_string "DF")))
1543    (set_attr "prefix_rep" "0")
1544    (set (attr "prefix_data16")
1545         (if_then_else (eq_attr "mode" "DF")
1546                       (const_string "1")
1547                       (const_string "0")))
1548    (set_attr "athlon_decode" "vector")
1549    (set_attr "amdfam10_decode" "direct")
1550    (set_attr "bdver1_decode" "double")])
1551
1552 (define_insn "*cmpfp_i_i387"
1553   [(set (reg:CCFP FLAGS_REG)
1554         (compare:CCFP (match_operand 0 "register_operand" "f")
1555                       (match_operand 1 "register_operand" "f")))]
1556   "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1557    && TARGET_CMOVE
1558    && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1559    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1560   "* return output_fp_compare (insn, operands, 1, 0);"
1561   [(set_attr "type" "fcmp")
1562    (set (attr "mode")
1563      (cond [(match_operand:SF 1 "" "")
1564               (const_string "SF")
1565             (match_operand:DF 1 "" "")
1566               (const_string "DF")
1567            ]
1568            (const_string "XF")))
1569    (set_attr "athlon_decode" "vector")
1570    (set_attr "amdfam10_decode" "direct")
1571    (set_attr "bdver1_decode" "double")])
1572
1573 (define_insn "*cmpfp_iu_mixed"
1574   [(set (reg:CCFPU FLAGS_REG)
1575         (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1576                        (match_operand 1 "nonimmediate_operand" "f,xm")))]
1577   "TARGET_MIX_SSE_I387
1578    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1579    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1580   "* return output_fp_compare (insn, operands, 1, 1);"
1581   [(set_attr "type" "fcmp,ssecomi")
1582    (set_attr "prefix" "orig,maybe_vex")
1583    (set (attr "mode")
1584      (if_then_else (match_operand:SF 1 "" "")
1585         (const_string "SF")
1586         (const_string "DF")))
1587    (set (attr "prefix_rep")
1588         (if_then_else (eq_attr "type" "ssecomi")
1589                       (const_string "0")
1590                       (const_string "*")))
1591    (set (attr "prefix_data16")
1592         (cond [(eq_attr "type" "fcmp")
1593                  (const_string "*")
1594                (eq_attr "mode" "DF")
1595                  (const_string "1")
1596               ]
1597               (const_string "0")))
1598    (set_attr "athlon_decode" "vector")
1599    (set_attr "amdfam10_decode" "direct")
1600    (set_attr "bdver1_decode" "double")])
1601
1602 (define_insn "*cmpfp_iu_sse"
1603   [(set (reg:CCFPU FLAGS_REG)
1604         (compare:CCFPU (match_operand 0 "register_operand" "x")
1605                        (match_operand 1 "nonimmediate_operand" "xm")))]
1606   "TARGET_SSE_MATH
1607    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1608    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1609   "* return output_fp_compare (insn, operands, 1, 1);"
1610   [(set_attr "type" "ssecomi")
1611    (set_attr "prefix" "maybe_vex")
1612    (set (attr "mode")
1613      (if_then_else (match_operand:SF 1 "" "")
1614         (const_string "SF")
1615         (const_string "DF")))
1616    (set_attr "prefix_rep" "0")
1617    (set (attr "prefix_data16")
1618         (if_then_else (eq_attr "mode" "DF")
1619                       (const_string "1")
1620                       (const_string "0")))
1621    (set_attr "athlon_decode" "vector")
1622    (set_attr "amdfam10_decode" "direct")
1623    (set_attr "bdver1_decode" "double")])
1624
1625 (define_insn "*cmpfp_iu_387"
1626   [(set (reg:CCFPU FLAGS_REG)
1627         (compare:CCFPU (match_operand 0 "register_operand" "f")
1628                        (match_operand 1 "register_operand" "f")))]
1629   "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1630    && TARGET_CMOVE
1631    && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1632    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1633   "* return output_fp_compare (insn, operands, 1, 1);"
1634   [(set_attr "type" "fcmp")
1635    (set (attr "mode")
1636      (cond [(match_operand:SF 1 "" "")
1637               (const_string "SF")
1638             (match_operand:DF 1 "" "")
1639               (const_string "DF")
1640            ]
1641            (const_string "XF")))
1642    (set_attr "athlon_decode" "vector")
1643    (set_attr "amdfam10_decode" "direct")
1644    (set_attr "bdver1_decode" "direct")])
1645 \f
1646 ;; Push/pop instructions.
1647
1648 (define_insn "*push<mode>2"
1649   [(set (match_operand:DWI 0 "push_operand" "=<")
1650         (match_operand:DWI 1 "general_no_elim_operand" "riF*m"))]
1651   ""
1652   "#")
1653
1654 (define_split
1655   [(set (match_operand:TI 0 "push_operand" "")
1656         (match_operand:TI 1 "general_operand" ""))]
1657   "TARGET_64BIT && reload_completed
1658    && !SSE_REG_P (operands[1])"
1659   [(const_int 0)]
1660   "ix86_split_long_move (operands); DONE;")
1661
1662 (define_insn "*pushdi2_rex64"
1663   [(set (match_operand:DI 0 "push_operand" "=<,!<")
1664         (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
1665   "TARGET_64BIT"
1666   "@
1667    push{q}\t%1
1668    #"
1669   [(set_attr "type" "push,multi")
1670    (set_attr "mode" "DI")])
1671
1672 ;; Convert impossible pushes of immediate to existing instructions.
1673 ;; First try to get scratch register and go through it.  In case this
1674 ;; fails, push sign extended lower part first and then overwrite
1675 ;; upper part by 32bit move.
1676 (define_peephole2
1677   [(match_scratch:DI 2 "r")
1678    (set (match_operand:DI 0 "push_operand" "")
1679         (match_operand:DI 1 "immediate_operand" ""))]
1680   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1681    && !x86_64_immediate_operand (operands[1], DImode)"
1682   [(set (match_dup 2) (match_dup 1))
1683    (set (match_dup 0) (match_dup 2))])
1684
1685 ;; We need to define this as both peepholer and splitter for case
1686 ;; peephole2 pass is not run.
1687 ;; "&& 1" is needed to keep it from matching the previous pattern.
1688 (define_peephole2
1689   [(set (match_operand:DI 0 "push_operand" "")
1690         (match_operand:DI 1 "immediate_operand" ""))]
1691   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1692    && !x86_64_immediate_operand (operands[1], DImode) && 1"
1693   [(set (match_dup 0) (match_dup 1))
1694    (set (match_dup 2) (match_dup 3))]
1695 {
1696   split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1697
1698   operands[1] = gen_lowpart (DImode, operands[2]);
1699   operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1700                                                    GEN_INT (4)));
1701 })
1702
1703 (define_split
1704   [(set (match_operand:DI 0 "push_operand" "")
1705         (match_operand:DI 1 "immediate_operand" ""))]
1706   "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
1707                     ? epilogue_completed : reload_completed)
1708    && !symbolic_operand (operands[1], DImode)
1709    && !x86_64_immediate_operand (operands[1], DImode)"
1710   [(set (match_dup 0) (match_dup 1))
1711    (set (match_dup 2) (match_dup 3))]
1712 {
1713   split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1714
1715   operands[1] = gen_lowpart (DImode, operands[2]);
1716   operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1717                                                    GEN_INT (4)));
1718 })
1719
1720 (define_split
1721   [(set (match_operand:DI 0 "push_operand" "")
1722         (match_operand:DI 1 "general_operand" ""))]
1723   "!TARGET_64BIT && reload_completed
1724    && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
1725   [(const_int 0)]
1726   "ix86_split_long_move (operands); DONE;")
1727
1728 (define_insn "*pushsi2"
1729   [(set (match_operand:SI 0 "push_operand" "=<")
1730         (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1731   "!TARGET_64BIT"
1732   "push{l}\t%1"
1733   [(set_attr "type" "push")
1734    (set_attr "mode" "SI")])
1735
1736 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1737 ;; "push a byte/word".  But actually we use pushl, which has the effect
1738 ;; of rounding the amount pushed up to a word.
1739
1740 ;; For TARGET_64BIT we always round up to 8 bytes.
1741 (define_insn "*push<mode>2_rex64"
1742   [(set (match_operand:SWI124 0 "push_operand" "=X")
1743         (match_operand:SWI124 1 "nonmemory_no_elim_operand" "r<i>"))]
1744   "TARGET_64BIT"
1745   "push{q}\t%q1"
1746   [(set_attr "type" "push")
1747    (set_attr "mode" "DI")])
1748
1749 (define_insn "*push<mode>2"
1750   [(set (match_operand:SWI12 0 "push_operand" "=X")
1751         (match_operand:SWI12 1 "nonmemory_no_elim_operand" "rn"))]
1752   "!TARGET_64BIT"
1753   "push{l}\t%k1"
1754   [(set_attr "type" "push")
1755    (set_attr "mode" "SI")])
1756
1757 (define_insn "*push<mode>2_prologue"
1758   [(set (match_operand:P 0 "push_operand" "=<")
1759         (match_operand:P 1 "general_no_elim_operand" "r<i>*m"))
1760    (clobber (mem:BLK (scratch)))]
1761   ""
1762   "push{<imodesuffix>}\t%1"
1763   [(set_attr "type" "push")
1764    (set_attr "mode" "<MODE>")])
1765
1766 (define_insn "*pop<mode>1"
1767   [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1768         (match_operand:P 1 "pop_operand" ">"))]
1769   ""
1770   "pop{<imodesuffix>}\t%0"
1771   [(set_attr "type" "pop")
1772    (set_attr "mode" "<MODE>")])
1773
1774 (define_insn "*pop<mode>1_epilogue"
1775   [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1776         (match_operand:P 1 "pop_operand" ">"))
1777    (clobber (mem:BLK (scratch)))]
1778   ""
1779   "pop{<imodesuffix>}\t%0"
1780   [(set_attr "type" "pop")
1781    (set_attr "mode" "<MODE>")])
1782 \f
1783 ;; Move instructions.
1784
1785 (define_expand "movoi"
1786   [(set (match_operand:OI 0 "nonimmediate_operand" "")
1787         (match_operand:OI 1 "general_operand" ""))]
1788   "TARGET_AVX"
1789   "ix86_expand_move (OImode, operands); DONE;")
1790
1791 (define_expand "movti"
1792   [(set (match_operand:TI 0 "nonimmediate_operand" "")
1793         (match_operand:TI 1 "nonimmediate_operand" ""))]
1794   "TARGET_64BIT || TARGET_SSE"
1795 {
1796   if (TARGET_64BIT)
1797     ix86_expand_move (TImode, operands);
1798   else if (push_operand (operands[0], TImode))
1799     ix86_expand_push (TImode, operands[1]);
1800   else
1801     ix86_expand_vector_move (TImode, operands);
1802   DONE;
1803 })
1804
1805 ;; This expands to what emit_move_complex would generate if we didn't
1806 ;; have a movti pattern.  Having this avoids problems with reload on
1807 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
1808 ;; to have around all the time.
1809 (define_expand "movcdi"
1810   [(set (match_operand:CDI 0 "nonimmediate_operand" "")
1811         (match_operand:CDI 1 "general_operand" ""))]
1812   ""
1813 {
1814   if (push_operand (operands[0], CDImode))
1815     emit_move_complex_push (CDImode, operands[0], operands[1]);
1816   else
1817     emit_move_complex_parts (operands[0], operands[1]);
1818   DONE;
1819 })
1820
1821 (define_expand "mov<mode>"
1822   [(set (match_operand:SWI1248x 0 "nonimmediate_operand" "")
1823         (match_operand:SWI1248x 1 "general_operand" ""))]
1824   ""
1825   "ix86_expand_move (<MODE>mode, operands); DONE;")
1826
1827 (define_insn "*mov<mode>_xor"
1828   [(set (match_operand:SWI48 0 "register_operand" "=r")
1829         (match_operand:SWI48 1 "const0_operand" ""))
1830    (clobber (reg:CC FLAGS_REG))]
1831   "reload_completed"
1832   "xor{l}\t%k0, %k0"
1833   [(set_attr "type" "alu1")
1834    (set_attr "mode" "SI")
1835    (set_attr "length_immediate" "0")])
1836
1837 (define_insn "*mov<mode>_or"
1838   [(set (match_operand:SWI48 0 "register_operand" "=r")
1839         (match_operand:SWI48 1 "const_int_operand" ""))
1840    (clobber (reg:CC FLAGS_REG))]
1841   "reload_completed
1842    && operands[1] == constm1_rtx"
1843   "or{<imodesuffix>}\t{%1, %0|%0, %1}"
1844   [(set_attr "type" "alu1")
1845    (set_attr "mode" "<MODE>")
1846    (set_attr "length_immediate" "1")])
1847
1848 (define_insn "*movoi_internal_avx"
1849   [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
1850         (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
1851   "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1852 {
1853   switch (which_alternative)
1854     {
1855     case 0:
1856       return "vxorps\t%0, %0, %0";
1857     case 1:
1858     case 2:
1859       if (misaligned_operand (operands[0], OImode)
1860           || misaligned_operand (operands[1], OImode))
1861         return "vmovdqu\t{%1, %0|%0, %1}";
1862       else
1863         return "vmovdqa\t{%1, %0|%0, %1}";
1864     default:
1865       gcc_unreachable ();
1866     }
1867 }
1868   [(set_attr "type" "sselog1,ssemov,ssemov")
1869    (set_attr "prefix" "vex")
1870    (set_attr "mode" "OI")])
1871
1872 (define_insn "*movti_internal_rex64"
1873   [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
1874         (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
1875   "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1876 {
1877   switch (which_alternative)
1878     {
1879     case 0:
1880     case 1:
1881       return "#";
1882     case 2:
1883       if (get_attr_mode (insn) == MODE_V4SF)
1884         return "%vxorps\t%0, %d0";
1885       else
1886         return "%vpxor\t%0, %d0";
1887     case 3:
1888     case 4:
1889       /* TDmode values are passed as TImode on the stack.  Moving them
1890          to stack may result in unaligned memory access.  */
1891       if (misaligned_operand (operands[0], TImode)
1892           || misaligned_operand (operands[1], TImode))
1893         {
1894           if (get_attr_mode (insn) == MODE_V4SF)
1895             return "%vmovups\t{%1, %0|%0, %1}";
1896          else
1897            return "%vmovdqu\t{%1, %0|%0, %1}";
1898         }
1899       else
1900         {
1901           if (get_attr_mode (insn) == MODE_V4SF)
1902             return "%vmovaps\t{%1, %0|%0, %1}";
1903          else
1904            return "%vmovdqa\t{%1, %0|%0, %1}";
1905         }
1906     default:
1907       gcc_unreachable ();
1908     }
1909 }
1910   [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
1911    (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
1912    (set (attr "mode")
1913         (cond [(eq_attr "alternative" "2,3")
1914                  (if_then_else
1915                    (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1916                        (const_int 0))
1917                    (const_string "V4SF")
1918                    (const_string "TI"))
1919                (eq_attr "alternative" "4")
1920                  (if_then_else
1921                    (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1922                             (const_int 0))
1923                         (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1924                             (const_int 0)))
1925                    (const_string "V4SF")
1926                    (const_string "TI"))]
1927                (const_string "DI")))])
1928
1929 (define_split
1930   [(set (match_operand:TI 0 "nonimmediate_operand" "")
1931         (match_operand:TI 1 "general_operand" ""))]
1932   "reload_completed
1933    && !SSE_REG_P (operands[0]) && !SSE_REG_P (operands[1])"
1934   [(const_int 0)]
1935   "ix86_split_long_move (operands); DONE;")
1936
1937 (define_insn "*movti_internal_sse"
1938   [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
1939         (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
1940   "TARGET_SSE && !TARGET_64BIT
1941    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1942 {
1943   switch (which_alternative)
1944     {
1945     case 0:
1946       if (get_attr_mode (insn) == MODE_V4SF)
1947         return "%vxorps\t%0, %d0";
1948       else
1949         return "%vpxor\t%0, %d0";
1950     case 1:
1951     case 2:
1952       /* TDmode values are passed as TImode on the stack.  Moving them
1953          to stack may result in unaligned memory access.  */
1954       if (misaligned_operand (operands[0], TImode)
1955           || misaligned_operand (operands[1], TImode))
1956         {
1957           if (get_attr_mode (insn) == MODE_V4SF)
1958             return "%vmovups\t{%1, %0|%0, %1}";
1959          else
1960            return "%vmovdqu\t{%1, %0|%0, %1}";
1961         }
1962       else
1963         {
1964           if (get_attr_mode (insn) == MODE_V4SF)
1965             return "%vmovaps\t{%1, %0|%0, %1}";
1966          else
1967            return "%vmovdqa\t{%1, %0|%0, %1}";
1968         }
1969     default:
1970       gcc_unreachable ();
1971     }
1972 }
1973   [(set_attr "type" "sselog1,ssemov,ssemov")
1974    (set_attr "prefix" "maybe_vex")
1975    (set (attr "mode")
1976         (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1977                     (ne (symbol_ref "optimize_function_for_size_p (cfun)")
1978                         (const_int 0)))
1979                  (const_string "V4SF")
1980                (and (eq_attr "alternative" "2")
1981                     (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
1982                         (const_int 0)))
1983                  (const_string "V4SF")]
1984               (const_string "TI")))])
1985
1986 (define_insn "*movdi_internal_rex64"
1987   [(set (match_operand:DI 0 "nonimmediate_operand"
1988           "=r,r  ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
1989         (match_operand:DI 1 "general_operand"
1990           "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r   ,m  ,C ,*x,*Yi,*x,r  ,m ,*Ym,*x"))]
1991   "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1992 {
1993   switch (get_attr_type (insn))
1994     {
1995     case TYPE_SSECVT:
1996       if (SSE_REG_P (operands[0]))
1997         return "movq2dq\t{%1, %0|%0, %1}";
1998       else
1999         return "movdq2q\t{%1, %0|%0, %1}";
2000
2001     case TYPE_SSEMOV:
2002       if (get_attr_mode (insn) == MODE_TI)
2003         return "%vmovdqa\t{%1, %0|%0, %1}";
2004       return "%vmovq\t{%1, %0|%0, %1}";
2005
2006     case TYPE_MMXMOV:
2007       /* Moves from and into integer register is done using movd
2008          opcode with REX prefix.  */
2009       if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2010         return "movd\t{%1, %0|%0, %1}";
2011       return "movq\t{%1, %0|%0, %1}";
2012
2013     case TYPE_SSELOG1:
2014       return "%vpxor\t%0, %d0";
2015
2016     case TYPE_MMX:
2017       return "pxor\t%0, %0";
2018
2019     case TYPE_MULTI:
2020       return "#";
2021
2022     case TYPE_LEA:
2023       return "lea{q}\t{%a1, %0|%0, %a1}";
2024
2025     default:
2026       gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2027       if (get_attr_mode (insn) == MODE_SI)
2028         return "mov{l}\t{%k1, %k0|%k0, %k1}";
2029       else if (which_alternative == 2)
2030         return "movabs{q}\t{%1, %0|%0, %1}";
2031       else
2032         return "mov{q}\t{%1, %0|%0, %1}";
2033     }
2034 }
2035   [(set (attr "type")
2036      (cond [(eq_attr "alternative" "5")
2037               (const_string "mmx")
2038             (eq_attr "alternative" "6,7,8,9,10")
2039               (const_string "mmxmov")
2040             (eq_attr "alternative" "11")
2041               (const_string "sselog1")
2042             (eq_attr "alternative" "12,13,14,15,16")
2043               (const_string "ssemov")
2044             (eq_attr "alternative" "17,18")
2045               (const_string "ssecvt")
2046             (eq_attr "alternative" "4")
2047               (const_string "multi")
2048             (match_operand:DI 1 "pic_32bit_operand" "")
2049               (const_string "lea")
2050            ]
2051            (const_string "imov")))
2052    (set (attr "modrm")
2053      (if_then_else
2054        (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2055          (const_string "0")
2056          (const_string "*")))
2057    (set (attr "length_immediate")
2058      (if_then_else
2059        (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2060          (const_string "8")
2061          (const_string "*")))
2062    (set_attr "prefix_rex" "*,*,*,*,*,*,*,1,*,1,*,*,*,*,*,*,*,*,*")
2063    (set_attr "prefix_data16" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,1,*,*,*")
2064    (set (attr "prefix")
2065      (if_then_else (eq_attr "alternative" "11,12,13,14,15,16")
2066        (const_string "maybe_vex")
2067        (const_string "orig")))
2068    (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2069
2070 ;; Convert impossible stores of immediate to existing instructions.
2071 ;; First try to get scratch register and go through it.  In case this
2072 ;; fails, move by 32bit parts.
2073 (define_peephole2
2074   [(match_scratch:DI 2 "r")
2075    (set (match_operand:DI 0 "memory_operand" "")
2076         (match_operand:DI 1 "immediate_operand" ""))]
2077   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2078    && !x86_64_immediate_operand (operands[1], DImode)"
2079   [(set (match_dup 2) (match_dup 1))
2080    (set (match_dup 0) (match_dup 2))])
2081
2082 ;; We need to define this as both peepholer and splitter for case
2083 ;; peephole2 pass is not run.
2084 ;; "&& 1" is needed to keep it from matching the previous pattern.
2085 (define_peephole2
2086   [(set (match_operand:DI 0 "memory_operand" "")
2087         (match_operand:DI 1 "immediate_operand" ""))]
2088   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2089    && !x86_64_immediate_operand (operands[1], DImode) && 1"
2090   [(set (match_dup 2) (match_dup 3))
2091    (set (match_dup 4) (match_dup 5))]
2092   "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2093
2094 (define_split
2095   [(set (match_operand:DI 0 "memory_operand" "")
2096         (match_operand:DI 1 "immediate_operand" ""))]
2097   "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2098                     ? epilogue_completed : reload_completed)
2099    && !symbolic_operand (operands[1], DImode)
2100    && !x86_64_immediate_operand (operands[1], DImode)"
2101   [(set (match_dup 2) (match_dup 3))
2102    (set (match_dup 4) (match_dup 5))]
2103   "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2104
2105 (define_insn "*movdi_internal"
2106   [(set (match_operand:DI 0 "nonimmediate_operand"
2107                         "=r  ,o  ,*y,m*y,*y,*Y2,m  ,*Y2,*Y2,*x,m ,*x,*x")
2108         (match_operand:DI 1 "general_operand"
2109                         "riFo,riF,C ,*y ,m ,C  ,*Y2,*Y2,m  ,C ,*x,*x,m "))]
2110   "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2111   "@
2112    #
2113    #
2114    pxor\t%0, %0
2115    movq\t{%1, %0|%0, %1}
2116    movq\t{%1, %0|%0, %1}
2117    %vpxor\t%0, %d0
2118    %vmovq\t{%1, %0|%0, %1}
2119    %vmovdqa\t{%1, %0|%0, %1}
2120    %vmovq\t{%1, %0|%0, %1}
2121    xorps\t%0, %0
2122    movlps\t{%1, %0|%0, %1}
2123    movaps\t{%1, %0|%0, %1}
2124    movlps\t{%1, %0|%0, %1}"
2125   [(set (attr "isa")
2126      (if_then_else (eq_attr "alternative" "9,10,11,12")
2127        (const_string "noavx")
2128        (const_string "base")))
2129    (set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2130    (set (attr "prefix")
2131      (if_then_else (eq_attr "alternative" "5,6,7,8")
2132        (const_string "maybe_vex")
2133        (const_string "orig")))
2134    (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2135
2136 (define_split
2137   [(set (match_operand:DI 0 "nonimmediate_operand" "")
2138         (match_operand:DI 1 "general_operand" ""))]
2139   "!TARGET_64BIT && reload_completed
2140    && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))
2141    && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
2142   [(const_int 0)]
2143   "ix86_split_long_move (operands); DONE;")
2144
2145 (define_insn "*movsi_internal"
2146   [(set (match_operand:SI 0 "nonimmediate_operand"
2147                         "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
2148         (match_operand:SI 1 "general_operand"
2149                         "g ,ri,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r   ,m "))]
2150   "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2151 {
2152   switch (get_attr_type (insn))
2153     {
2154     case TYPE_SSELOG1:
2155       if (get_attr_mode (insn) == MODE_TI)
2156         return "%vpxor\t%0, %d0";
2157       return "%vxorps\t%0, %d0";
2158
2159     case TYPE_SSEMOV:
2160       switch (get_attr_mode (insn))
2161         {
2162         case MODE_TI:
2163           return "%vmovdqa\t{%1, %0|%0, %1}";
2164         case MODE_V4SF:
2165           return "%vmovaps\t{%1, %0|%0, %1}";
2166         case MODE_SI:
2167           return "%vmovd\t{%1, %0|%0, %1}";
2168         case MODE_SF:
2169           return "%vmovss\t{%1, %0|%0, %1}";
2170         default:
2171           gcc_unreachable ();
2172         }
2173
2174     case TYPE_MMX:
2175       return "pxor\t%0, %0";
2176
2177     case TYPE_MMXMOV:
2178       if (get_attr_mode (insn) == MODE_DI)
2179         return "movq\t{%1, %0|%0, %1}";
2180       return "movd\t{%1, %0|%0, %1}";
2181
2182     case TYPE_LEA:
2183       return "lea{l}\t{%a1, %0|%0, %a1}";
2184
2185     default:
2186       gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2187       return "mov{l}\t{%1, %0|%0, %1}";
2188     }
2189 }
2190   [(set (attr "type")
2191      (cond [(eq_attr "alternative" "2")
2192               (const_string "mmx")
2193             (eq_attr "alternative" "3,4,5")
2194               (const_string "mmxmov")
2195             (eq_attr "alternative" "6")
2196               (const_string "sselog1")
2197             (eq_attr "alternative" "7,8,9,10,11")
2198               (const_string "ssemov")
2199             (match_operand:DI 1 "pic_32bit_operand" "")
2200               (const_string "lea")
2201            ]
2202            (const_string "imov")))
2203    (set (attr "prefix")
2204      (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
2205        (const_string "orig")
2206        (const_string "maybe_vex")))
2207    (set (attr "prefix_data16")
2208      (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
2209        (const_string "1")
2210        (const_string "*")))
2211    (set (attr "mode")
2212      (cond [(eq_attr "alternative" "2,3")
2213               (const_string "DI")
2214             (eq_attr "alternative" "6,7")
2215               (if_then_else
2216                 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2217                 (const_string "V4SF")
2218                 (const_string "TI"))
2219             (and (eq_attr "alternative" "8,9,10,11")
2220                  (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
2221               (const_string "SF")
2222            ]
2223            (const_string "SI")))])
2224
2225 (define_insn "*movhi_internal"
2226   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
2227         (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
2228   "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2229 {
2230   switch (get_attr_type (insn))
2231     {
2232     case TYPE_IMOVX:
2233       /* movzwl is faster than movw on p2 due to partial word stalls,
2234          though not as fast as an aligned movl.  */
2235       return "movz{wl|x}\t{%1, %k0|%k0, %1}";
2236     default:
2237       if (get_attr_mode (insn) == MODE_SI)
2238         return "mov{l}\t{%k1, %k0|%k0, %k1}";
2239       else
2240         return "mov{w}\t{%1, %0|%0, %1}";
2241     }
2242 }
2243   [(set (attr "type")
2244      (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
2245                 (const_int 0))
2246               (const_string "imov")
2247             (and (eq_attr "alternative" "0")
2248                  (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2249                           (const_int 0))
2250                       (eq (symbol_ref "TARGET_HIMODE_MATH")
2251                           (const_int 0))))
2252               (const_string "imov")
2253             (and (eq_attr "alternative" "1,2")
2254                  (match_operand:HI 1 "aligned_operand" ""))
2255               (const_string "imov")
2256             (and (ne (symbol_ref "TARGET_MOVX")
2257                      (const_int 0))
2258                  (eq_attr "alternative" "0,2"))
2259               (const_string "imovx")
2260            ]
2261            (const_string "imov")))
2262     (set (attr "mode")
2263       (cond [(eq_attr "type" "imovx")
2264                (const_string "SI")
2265              (and (eq_attr "alternative" "1,2")
2266                   (match_operand:HI 1 "aligned_operand" ""))
2267                (const_string "SI")
2268              (and (eq_attr "alternative" "0")
2269                   (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2270                            (const_int 0))
2271                        (eq (symbol_ref "TARGET_HIMODE_MATH")
2272                            (const_int 0))))
2273                (const_string "SI")
2274             ]
2275             (const_string "HI")))])
2276
2277 ;; Situation is quite tricky about when to choose full sized (SImode) move
2278 ;; over QImode moves.  For Q_REG -> Q_REG move we use full size only for
2279 ;; partial register dependency machines (such as AMD Athlon), where QImode
2280 ;; moves issue extra dependency and for partial register stalls machines
2281 ;; that don't use QImode patterns (and QImode move cause stall on the next
2282 ;; instruction).
2283 ;;
2284 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2285 ;; register stall machines with, where we use QImode instructions, since
2286 ;; partial register stall can be caused there.  Then we use movzx.
2287 (define_insn "*movqi_internal"
2288   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2289         (match_operand:QI 1 "general_operand"      " q,qn,qm,q,rn,qm,qn"))]
2290   "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2291 {
2292   switch (get_attr_type (insn))
2293     {
2294     case TYPE_IMOVX:
2295       gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2296       return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2297     default:
2298       if (get_attr_mode (insn) == MODE_SI)
2299         return "mov{l}\t{%k1, %k0|%k0, %k1}";
2300       else
2301         return "mov{b}\t{%1, %0|%0, %1}";
2302     }
2303 }
2304   [(set (attr "type")
2305      (cond [(and (eq_attr "alternative" "5")
2306                  (not (match_operand:QI 1 "aligned_operand" "")))
2307               (const_string "imovx")
2308             (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2309                 (const_int 0))
2310               (const_string "imov")
2311             (and (eq_attr "alternative" "3")
2312                  (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2313                           (const_int 0))
2314                       (eq (symbol_ref "TARGET_QIMODE_MATH")
2315                           (const_int 0))))
2316               (const_string "imov")
2317             (eq_attr "alternative" "3,5")
2318               (const_string "imovx")
2319             (and (ne (symbol_ref "TARGET_MOVX")
2320                      (const_int 0))
2321                  (eq_attr "alternative" "2"))
2322               (const_string "imovx")
2323            ]
2324            (const_string "imov")))
2325    (set (attr "mode")
2326       (cond [(eq_attr "alternative" "3,4,5")
2327                (const_string "SI")
2328              (eq_attr "alternative" "6")
2329                (const_string "QI")
2330              (eq_attr "type" "imovx")
2331                (const_string "SI")
2332              (and (eq_attr "type" "imov")
2333                   (and (eq_attr "alternative" "0,1")
2334                        (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2335                                 (const_int 0))
2336                             (and (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2337                                      (const_int 0))
2338                                  (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2339                                      (const_int 0))))))
2340                (const_string "SI")
2341              ;; Avoid partial register stalls when not using QImode arithmetic
2342              (and (eq_attr "type" "imov")
2343                   (and (eq_attr "alternative" "0,1")
2344                        (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2345                                 (const_int 0))
2346                             (eq (symbol_ref "TARGET_QIMODE_MATH")
2347                                 (const_int 0)))))
2348                (const_string "SI")
2349            ]
2350            (const_string "QI")))])
2351
2352 ;; Stores and loads of ax to arbitrary constant address.
2353 ;; We fake an second form of instruction to force reload to load address
2354 ;; into register when rax is not available
2355 (define_insn "*movabs<mode>_1"
2356   [(set (mem:SWI1248x (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2357         (match_operand:SWI1248x 1 "nonmemory_operand" "a,er"))]
2358   "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2359   "@
2360    movabs{<imodesuffix>}\t{%1, %P0|%P0, %1}
2361    mov{<imodesuffix>}\t{%1, %a0|%a0, %1}"
2362   [(set_attr "type" "imov")
2363    (set_attr "modrm" "0,*")
2364    (set_attr "length_address" "8,0")
2365    (set_attr "length_immediate" "0,*")
2366    (set_attr "memory" "store")
2367    (set_attr "mode" "<MODE>")])
2368
2369 (define_insn "*movabs<mode>_2"
2370   [(set (match_operand:SWI1248x 0 "register_operand" "=a,r")
2371         (mem:SWI1248x (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2372   "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2373   "@
2374    movabs{<imodesuffix>}\t{%P1, %0|%0, %P1}
2375    mov{<imodesuffix>}\t{%a1, %0|%0, %a1}"
2376   [(set_attr "type" "imov")
2377    (set_attr "modrm" "0,*")
2378    (set_attr "length_address" "8,0")
2379    (set_attr "length_immediate" "0")
2380    (set_attr "memory" "load")
2381    (set_attr "mode" "<MODE>")])
2382
2383 (define_insn "*swap<mode>"
2384   [(set (match_operand:SWI48 0 "register_operand" "+r")
2385         (match_operand:SWI48 1 "register_operand" "+r"))
2386    (set (match_dup 1)
2387         (match_dup 0))]
2388   ""
2389   "xchg{<imodesuffix>}\t%1, %0"
2390   [(set_attr "type" "imov")
2391    (set_attr "mode" "<MODE>")
2392    (set_attr "pent_pair" "np")
2393    (set_attr "athlon_decode" "vector")
2394    (set_attr "amdfam10_decode" "double")
2395    (set_attr "bdver1_decode" "double")])
2396
2397 (define_insn "*swap<mode>_1"
2398   [(set (match_operand:SWI12 0 "register_operand" "+r")
2399         (match_operand:SWI12 1 "register_operand" "+r"))
2400    (set (match_dup 1)
2401         (match_dup 0))]
2402   "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2403   "xchg{l}\t%k1, %k0"
2404   [(set_attr "type" "imov")
2405    (set_attr "mode" "SI")
2406    (set_attr "pent_pair" "np")
2407    (set_attr "athlon_decode" "vector")
2408    (set_attr "amdfam10_decode" "double")
2409    (set_attr "bdver1_decode" "double")])
2410
2411 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL
2412 ;; is disabled for AMDFAM10
2413 (define_insn "*swap<mode>_2"
2414   [(set (match_operand:SWI12 0 "register_operand" "+<r>")
2415         (match_operand:SWI12 1 "register_operand" "+<r>"))
2416    (set (match_dup 1)
2417         (match_dup 0))]
2418   "TARGET_PARTIAL_REG_STALL"
2419   "xchg{<imodesuffix>}\t%1, %0"
2420   [(set_attr "type" "imov")
2421    (set_attr "mode" "<MODE>")
2422    (set_attr "pent_pair" "np")
2423    (set_attr "athlon_decode" "vector")])
2424
2425 (define_expand "movstrict<mode>"
2426   [(set (strict_low_part (match_operand:SWI12 0 "nonimmediate_operand" ""))
2427         (match_operand:SWI12 1 "general_operand" ""))]
2428   ""
2429 {
2430   if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2431     FAIL;
2432   if (GET_CODE (operands[0]) == SUBREG
2433       && GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[0]))) != MODE_INT)
2434     FAIL;
2435   /* Don't generate memory->memory moves, go through a register */
2436   if (MEM_P (operands[0]) && MEM_P (operands[1]))
2437     operands[1] = force_reg (<MODE>mode, operands[1]);
2438 })
2439
2440 (define_insn "*movstrict<mode>_1"
2441   [(set (strict_low_part
2442           (match_operand:SWI12 0 "nonimmediate_operand" "+<r>m,<r>"))
2443         (match_operand:SWI12 1 "general_operand" "<r>n,m"))]
2444   "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2445    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2446   "mov{<imodesuffix>}\t{%1, %0|%0, %1}"
2447   [(set_attr "type" "imov")
2448    (set_attr "mode" "<MODE>")])
2449
2450 (define_insn "*movstrict<mode>_xor"
2451   [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
2452         (match_operand:SWI12 1 "const0_operand" ""))
2453    (clobber (reg:CC FLAGS_REG))]
2454   "reload_completed"
2455   "xor{<imodesuffix>}\t%0, %0"
2456   [(set_attr "type" "alu1")
2457    (set_attr "mode" "<MODE>")
2458    (set_attr "length_immediate" "0")])
2459
2460 (define_insn "*mov<mode>_extv_1"
2461   [(set (match_operand:SWI24 0 "register_operand" "=R")
2462         (sign_extract:SWI24 (match_operand 1 "ext_register_operand" "Q")
2463                             (const_int 8)
2464                             (const_int 8)))]
2465   ""
2466   "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2467   [(set_attr "type" "imovx")
2468    (set_attr "mode" "SI")])
2469
2470 (define_insn "*movqi_extv_1_rex64"
2471   [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2472         (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2473                          (const_int 8)
2474                          (const_int 8)))]
2475   "TARGET_64BIT"
2476 {
2477   switch (get_attr_type (insn))
2478     {
2479     case TYPE_IMOVX:
2480       return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2481     default:
2482       return "mov{b}\t{%h1, %0|%0, %h1}";
2483     }
2484 }
2485   [(set (attr "type")
2486      (if_then_else (and (match_operand:QI 0 "register_operand" "")
2487                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2488                              (ne (symbol_ref "TARGET_MOVX")
2489                                  (const_int 0))))
2490         (const_string "imovx")
2491         (const_string "imov")))
2492    (set (attr "mode")
2493      (if_then_else (eq_attr "type" "imovx")
2494         (const_string "SI")
2495         (const_string "QI")))])
2496
2497 (define_insn "*movqi_extv_1"
2498   [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2499         (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2500                          (const_int 8)
2501                          (const_int 8)))]
2502   "!TARGET_64BIT"
2503 {
2504   switch (get_attr_type (insn))
2505     {
2506     case TYPE_IMOVX:
2507       return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2508     default:
2509       return "mov{b}\t{%h1, %0|%0, %h1}";
2510     }
2511 }
2512   [(set (attr "type")
2513      (if_then_else (and (match_operand:QI 0 "register_operand" "")
2514                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2515                              (ne (symbol_ref "TARGET_MOVX")
2516                                  (const_int 0))))
2517         (const_string "imovx")
2518         (const_string "imov")))
2519    (set (attr "mode")
2520      (if_then_else (eq_attr "type" "imovx")
2521         (const_string "SI")
2522         (const_string "QI")))])
2523
2524 (define_insn "*mov<mode>_extzv_1"
2525   [(set (match_operand:SWI48 0 "register_operand" "=R")
2526         (zero_extract:SWI48 (match_operand 1 "ext_register_operand" "Q")
2527                             (const_int 8)
2528                             (const_int 8)))]
2529   ""
2530   "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2531   [(set_attr "type" "imovx")
2532    (set_attr "mode" "SI")])
2533
2534 (define_insn "*movqi_extzv_2_rex64"
2535   [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2536         (subreg:QI
2537           (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2538                            (const_int 8)
2539                            (const_int 8)) 0))]
2540   "TARGET_64BIT"
2541 {
2542   switch (get_attr_type (insn))
2543     {
2544     case TYPE_IMOVX:
2545       return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2546     default:
2547       return "mov{b}\t{%h1, %0|%0, %h1}";
2548     }
2549 }
2550   [(set (attr "type")
2551      (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2552                         (ne (symbol_ref "TARGET_MOVX")
2553                             (const_int 0)))
2554         (const_string "imovx")
2555         (const_string "imov")))
2556    (set (attr "mode")
2557      (if_then_else (eq_attr "type" "imovx")
2558         (const_string "SI")
2559         (const_string "QI")))])
2560
2561 (define_insn "*movqi_extzv_2"
2562   [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2563         (subreg:QI
2564           (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2565                            (const_int 8)
2566                            (const_int 8)) 0))]
2567   "!TARGET_64BIT"
2568 {
2569   switch (get_attr_type (insn))
2570     {
2571     case TYPE_IMOVX:
2572       return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2573     default:
2574       return "mov{b}\t{%h1, %0|%0, %h1}";
2575     }
2576 }
2577   [(set (attr "type")
2578      (if_then_else (and (match_operand:QI 0 "register_operand" "")
2579                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2580                              (ne (symbol_ref "TARGET_MOVX")
2581                                  (const_int 0))))
2582         (const_string "imovx")
2583         (const_string "imov")))
2584    (set (attr "mode")
2585      (if_then_else (eq_attr "type" "imovx")
2586         (const_string "SI")
2587         (const_string "QI")))])
2588
2589 (define_expand "mov<mode>_insv_1"
2590   [(set (zero_extract:SWI48 (match_operand 0 "ext_register_operand" "")
2591                             (const_int 8)
2592                             (const_int 8))
2593         (match_operand:SWI48 1 "nonmemory_operand" ""))])
2594
2595 (define_insn "*mov<mode>_insv_1_rex64"
2596   [(set (zero_extract:SWI48x (match_operand 0 "ext_register_operand" "+Q")
2597                              (const_int 8)
2598                              (const_int 8))
2599         (match_operand:SWI48x 1 "nonmemory_operand" "Qn"))]
2600   "TARGET_64BIT"
2601   "mov{b}\t{%b1, %h0|%h0, %b1}"
2602   [(set_attr "type" "imov")
2603    (set_attr "mode" "QI")])
2604
2605 (define_insn "*movsi_insv_1"
2606   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2607                          (const_int 8)
2608                          (const_int 8))
2609         (match_operand:SI 1 "general_operand" "Qmn"))]
2610   "!TARGET_64BIT"
2611   "mov{b}\t{%b1, %h0|%h0, %b1}"
2612   [(set_attr "type" "imov")
2613    (set_attr "mode" "QI")])
2614
2615 (define_insn "*movqi_insv_2"
2616   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2617                          (const_int 8)
2618                          (const_int 8))
2619         (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2620                      (const_int 8)))]
2621   ""
2622   "mov{b}\t{%h1, %h0|%h0, %h1}"
2623   [(set_attr "type" "imov")
2624    (set_attr "mode" "QI")])
2625 \f
2626 ;; Floating point push instructions.
2627
2628 (define_insn "*pushtf"
2629   [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2630         (match_operand:TF 1 "general_no_elim_operand" "x,Fo,*r"))]
2631   "TARGET_SSE2"
2632 {
2633   /* This insn should be already split before reg-stack.  */
2634   gcc_unreachable ();
2635 }
2636   [(set_attr "type" "multi")
2637    (set_attr "unit" "sse,*,*")
2638    (set_attr "mode" "TF,SI,SI")])
2639
2640 (define_split
2641   [(set (match_operand:TF 0 "push_operand" "")
2642         (match_operand:TF 1 "sse_reg_operand" ""))]
2643   "TARGET_SSE2 && reload_completed"
2644   [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
2645    (set (mem:TF (reg:P SP_REG)) (match_dup 1))])
2646
2647 (define_split
2648   [(set (match_operand:TF 0 "push_operand" "")
2649         (match_operand:TF 1 "general_operand" ""))]
2650   "TARGET_SSE2 && reload_completed
2651    && !SSE_REG_P (operands[1])"
2652   [(const_int 0)]
2653   "ix86_split_long_move (operands); DONE;")
2654
2655 (define_insn "*pushxf"
2656   [(set (match_operand:XF 0 "push_operand" "=<,<")
2657         (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
2658   "optimize_function_for_speed_p (cfun)"
2659 {
2660   /* This insn should be already split before reg-stack.  */
2661   gcc_unreachable ();
2662 }
2663   [(set_attr "type" "multi")
2664    (set_attr "unit" "i387,*")
2665    (set_attr "mode" "XF,SI")])
2666
2667 ;; Size of pushxf is 3 (for sub) + 2 (for fstp) + memory operand size.
2668 ;; Size of pushxf using integer instructions is 3+3*memory operand size
2669 ;; Pushing using integer instructions is longer except for constants
2670 ;; and direct memory references (assuming that any given constant is pushed
2671 ;; only once, but this ought to be handled elsewhere).
2672
2673 (define_insn "*pushxf_nointeger"
2674   [(set (match_operand:XF 0 "push_operand" "=X,X,X")
2675         (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
2676   "optimize_function_for_size_p (cfun)"
2677 {
2678   /* This insn should be already split before reg-stack.  */
2679   gcc_unreachable ();
2680 }
2681   [(set_attr "type" "multi")
2682    (set_attr "unit" "i387,*,*")
2683    (set_attr "mode" "XF,SI,SI")])
2684
2685 (define_split
2686   [(set (match_operand:XF 0 "push_operand" "")
2687         (match_operand:XF 1 "fp_register_operand" ""))]
2688   "reload_completed"
2689   [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2690    (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
2691   "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
2692
2693 (define_split
2694   [(set (match_operand:XF 0 "push_operand" "")
2695         (match_operand:XF 1 "general_operand" ""))]
2696   "reload_completed
2697    && !FP_REG_P (operands[1])"
2698   [(const_int 0)]
2699   "ix86_split_long_move (operands); DONE;")
2700
2701 (define_insn "*pushdf"
2702   [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2703         (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
2704   "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2705 {
2706   /* This insn should be already split before reg-stack.  */
2707   gcc_unreachable ();
2708 }
2709   [(set_attr "type" "multi")
2710    (set_attr "unit" "i387,*,*")
2711    (set_attr "mode" "DF,SI,DF")])
2712
2713 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2714 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2715 ;; On the average, pushdf using integers can be still shorter.  Allow this
2716 ;; pattern for optimize_size too.
2717
2718 (define_insn "*pushdf_nointeger"
2719   [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2720         (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
2721   "!(TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES)"
2722 {
2723   /* This insn should be already split before reg-stack.  */
2724   gcc_unreachable ();
2725 }
2726   [(set_attr "type" "multi")
2727    (set_attr "unit" "i387,*,*,*")
2728    (set_attr "mode" "DF,SI,SI,DF")])
2729
2730 ;; %%% Kill this when call knows how to work this out.
2731 (define_split
2732   [(set (match_operand:DF 0 "push_operand" "")
2733         (match_operand:DF 1 "any_fp_register_operand" ""))]
2734   "reload_completed"
2735   [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
2736    (set (mem:DF (reg:P SP_REG)) (match_dup 1))])
2737
2738 (define_split
2739   [(set (match_operand:DF 0 "push_operand" "")
2740         (match_operand:DF 1 "general_operand" ""))]
2741   "reload_completed
2742    && !ANY_FP_REG_P (operands[1])"
2743   [(const_int 0)]
2744   "ix86_split_long_move (operands); DONE;")
2745
2746 (define_insn "*pushsf_rex64"
2747   [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2748         (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2749   "TARGET_64BIT"
2750 {
2751   /* Anything else should be already split before reg-stack.  */
2752   gcc_assert (which_alternative == 1);
2753   return "push{q}\t%q1";
2754 }
2755   [(set_attr "type" "multi,push,multi")
2756    (set_attr "unit" "i387,*,*")
2757    (set_attr "mode" "SF,DI,SF")])
2758
2759 (define_insn "*pushsf"
2760   [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2761         (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2762   "!TARGET_64BIT"
2763 {
2764   /* Anything else should be already split before reg-stack.  */
2765   gcc_assert (which_alternative == 1);
2766   return "push{l}\t%1";
2767 }
2768   [(set_attr "type" "multi,push,multi")
2769    (set_attr "unit" "i387,*,*")
2770    (set_attr "mode" "SF,SI,SF")])
2771
2772 (define_split
2773   [(set (match_operand:SF 0 "push_operand" "")
2774         (match_operand:SF 1 "memory_operand" ""))]
2775   "reload_completed
2776    && MEM_P (operands[1])
2777    && (operands[2] = find_constant_src (insn))"
2778   [(set (match_dup 0)
2779         (match_dup 2))])
2780
2781 ;; %%% Kill this when call knows how to work this out.
2782 (define_split
2783   [(set (match_operand:SF 0 "push_operand" "")
2784         (match_operand:SF 1 "any_fp_register_operand" ""))]
2785   "reload_completed"
2786   [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2787    (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
2788   "operands[2] = GEN_INT (-GET_MODE_SIZE (<MODE>mode));")
2789 \f
2790 ;; Floating point move instructions.
2791
2792 (define_expand "movtf"
2793   [(set (match_operand:TF 0 "nonimmediate_operand" "")
2794         (match_operand:TF 1 "nonimmediate_operand" ""))]
2795   "TARGET_SSE2"
2796 {
2797   ix86_expand_move (TFmode, operands);
2798   DONE;
2799 })
2800
2801 (define_expand "mov<mode>"
2802   [(set (match_operand:X87MODEF 0 "nonimmediate_operand" "")
2803         (match_operand:X87MODEF 1 "general_operand" ""))]
2804   ""
2805   "ix86_expand_move (<MODE>mode, operands); DONE;")
2806
2807 (define_insn "*movtf_internal"
2808   [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?r,?o")
2809         (match_operand:TF 1 "general_operand" "xm,x,C,roF,Fr"))]
2810   "TARGET_SSE2
2811    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2812 {
2813   switch (which_alternative)
2814     {
2815     case 0:
2816     case 1:
2817       if (get_attr_mode (insn) == MODE_V4SF)
2818         return "%vmovaps\t{%1, %0|%0, %1}";
2819       else
2820         return "%vmovdqa\t{%1, %0|%0, %1}";
2821     case 2:
2822       if (get_attr_mode (insn) == MODE_V4SF)
2823         return "%vxorps\t%0, %d0";
2824       else
2825         return "%vpxor\t%0, %d0";
2826     case 3:
2827     case 4:
2828         return "#";
2829     default:
2830       gcc_unreachable ();
2831     }
2832 }
2833   [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
2834    (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,*,*")
2835    (set (attr "mode")
2836         (cond [(eq_attr "alternative" "0,2")
2837                  (if_then_else
2838                    (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2839                        (const_int 0))
2840                    (const_string "V4SF")
2841                    (const_string "TI"))
2842                (eq_attr "alternative" "1")
2843                  (if_then_else
2844                    (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2845                             (const_int 0))
2846                         (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2847                             (const_int 0)))
2848                    (const_string "V4SF")
2849                    (const_string "TI"))]
2850                (const_string "DI")))])
2851
2852 (define_split
2853   [(set (match_operand:TF 0 "nonimmediate_operand" "")
2854         (match_operand:TF 1 "general_operand" ""))]
2855   "reload_completed
2856    && !(SSE_REG_P (operands[0]) || SSE_REG_P (operands[1]))"
2857   [(const_int 0)]
2858   "ix86_split_long_move (operands); DONE;")
2859
2860 (define_insn "*movxf_internal"
2861   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,r,o")
2862         (match_operand:XF 1 "general_operand" "fm,f,G,roF,Fr"))]
2863   "optimize_function_for_speed_p (cfun)
2864    && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2865    && (reload_in_progress || reload_completed
2866        || GET_CODE (operands[1]) != CONST_DOUBLE
2867        || memory_operand (operands[0], XFmode))"
2868 {
2869   switch (which_alternative)
2870     {
2871     case 0:
2872     case 1:
2873       return output_387_reg_move (insn, operands);
2874
2875     case 2:
2876       return standard_80387_constant_opcode (operands[1]);
2877
2878     case 3: case 4:
2879       return "#";
2880
2881     default:
2882       gcc_unreachable ();
2883     }
2884 }
2885   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2886    (set_attr "mode" "XF,XF,XF,SI,SI")])
2887
2888 ;; Do not use integer registers when optimizing for size
2889 (define_insn "*movxf_internal_nointeger"
2890   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2891         (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2892   "optimize_function_for_size_p (cfun)
2893    && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2894    && (reload_in_progress || reload_completed
2895        || standard_80387_constant_p (operands[1])
2896        || GET_CODE (operands[1]) != CONST_DOUBLE
2897        || memory_operand (operands[0], XFmode))"
2898 {
2899   switch (which_alternative)
2900     {
2901     case 0:
2902     case 1:
2903       return output_387_reg_move (insn, operands);
2904
2905     case 2:
2906       return standard_80387_constant_opcode (operands[1]);
2907
2908     case 3: case 4:
2909       return "#";
2910     default:
2911       gcc_unreachable ();
2912     }
2913 }
2914   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2915    (set_attr "mode" "XF,XF,XF,SI,SI")])
2916
2917 (define_split
2918   [(set (match_operand:XF 0 "nonimmediate_operand" "")
2919         (match_operand:XF 1 "general_operand" ""))]
2920   "reload_completed
2921    && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2922    && ! (FP_REG_P (operands[0]) ||
2923          (GET_CODE (operands[0]) == SUBREG
2924           && FP_REG_P (SUBREG_REG (operands[0]))))
2925    && ! (FP_REG_P (operands[1]) ||
2926          (GET_CODE (operands[1]) == SUBREG
2927           && FP_REG_P (SUBREG_REG (operands[1]))))"
2928   [(const_int 0)]
2929   "ix86_split_long_move (operands); DONE;")
2930
2931 (define_insn "*movdf_internal_rex64"
2932   [(set (match_operand:DF 0 "nonimmediate_operand"
2933                 "=f,m,f,r ,m,!r,!m,Y2*x,Y2*x,Y2*x,m   ,Yi,r ")
2934         (match_operand:DF 1 "general_operand"
2935                 "fm,f,G,rm,r,F ,F ,C   ,Y2*x,m   ,Y2*x,r ,Yi"))]
2936   "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2937    && (reload_in_progress || reload_completed
2938        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2939        || (!(TARGET_SSE2 && TARGET_SSE_MATH)
2940            && optimize_function_for_size_p (cfun)
2941            && standard_80387_constant_p (operands[1]))
2942        || GET_CODE (operands[1]) != CONST_DOUBLE
2943        || memory_operand (operands[0], DFmode))"
2944 {
2945   switch (which_alternative)
2946     {
2947     case 0:
2948     case 1:
2949       return output_387_reg_move (insn, operands);
2950
2951     case 2:
2952       return standard_80387_constant_opcode (operands[1]);
2953
2954     case 3:
2955     case 4:
2956       return "mov{q}\t{%1, %0|%0, %1}";
2957
2958     case 5:
2959       return "movabs{q}\t{%1, %0|%0, %1}";
2960
2961     case 6:
2962       return "#";
2963
2964     case 7:
2965       switch (get_attr_mode (insn))
2966         {
2967         case MODE_V4SF:
2968           return "%vxorps\t%0, %d0";
2969         case MODE_V2DF:
2970           if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2971             return "%vxorps\t%0, %d0";
2972           else
2973             return "%vxorpd\t%0, %d0";
2974         case MODE_TI:
2975           if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2976             return "%vxorps\t%0, %d0";
2977           else
2978             return "%vpxor\t%0, %d0";
2979         default:
2980           gcc_unreachable ();
2981         }
2982     case 8:
2983     case 9:
2984     case 10:
2985       switch (get_attr_mode (insn))
2986         {
2987         case MODE_V4SF:
2988           return "%vmovaps\t{%1, %0|%0, %1}";
2989         case MODE_V2DF:
2990           if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2991             return "%vmovaps\t{%1, %0|%0, %1}";
2992           else
2993             return "%vmovapd\t{%1, %0|%0, %1}";
2994         case MODE_TI:
2995           if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
2996             return "%vmovaps\t{%1, %0|%0, %1}";
2997           else
2998             return "%vmovdqa\t{%1, %0|%0, %1}";
2999         case MODE_DI:
3000           return "%vmovq\t{%1, %0|%0, %1}";
3001         case MODE_DF:
3002           if (TARGET_AVX)
3003             {
3004               if (REG_P (operands[0]) && REG_P (operands[1]))
3005                 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3006               else
3007                 return "vmovsd\t{%1, %0|%0, %1}";
3008             }
3009           else
3010             return "movsd\t{%1, %0|%0, %1}";
3011         case MODE_V1DF:
3012           return "%vmovlpd\t{%1, %d0|%d0, %1}";
3013         case MODE_V2SF:
3014           return "%vmovlps\t{%1, %d0|%d0, %1}";
3015         default:
3016           gcc_unreachable ();
3017         }
3018
3019     case 11:
3020     case 12:
3021     return "%vmovd\t{%1, %0|%0, %1}";
3022
3023     default:
3024       gcc_unreachable();
3025     }
3026 }
3027   [(set_attr "type" "fmov,fmov,fmov,imov,imov,imov,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
3028    (set (attr "modrm")
3029      (if_then_else
3030        (and (eq_attr "alternative" "5") (eq_attr "type" "imov"))
3031          (const_string "0")
3032          (const_string "*")))
3033    (set (attr "length_immediate")
3034      (if_then_else
3035        (and (eq_attr "alternative" "5") (eq_attr "type" "imov"))
3036          (const_string "8")
3037          (const_string "*")))
3038    (set (attr "prefix")
3039      (if_then_else (eq_attr "alternative" "0,1,2,3,4,5,6")
3040        (const_string "orig")
3041        (const_string "maybe_vex")))
3042    (set (attr "prefix_data16")
3043      (if_then_else (eq_attr "mode" "V1DF")
3044        (const_string "1")
3045        (const_string "*")))
3046    (set (attr "mode")
3047         (cond [(eq_attr "alternative" "0,1,2")
3048                  (const_string "DF")
3049                (eq_attr "alternative" "3,4,5,6,11,12")
3050                  (const_string "DI")
3051
3052                /* For SSE1, we have many fewer alternatives.  */
3053                (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3054                  (cond [(eq_attr "alternative" "7,8")
3055                           (const_string "V4SF")
3056                        ]
3057                    (const_string "V2SF"))
3058
3059                /* xorps is one byte shorter.  */
3060                (eq_attr "alternative" "7")
3061                  (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3062                             (const_int 0))
3063                           (const_string "V4SF")
3064                         (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3065                             (const_int 0))
3066                           (const_string "TI")
3067                        ]
3068                        (const_string "V2DF"))
3069
3070                /* For architectures resolving dependencies on
3071                   whole SSE registers use APD move to break dependency
3072                   chains, otherwise use short move to avoid extra work.
3073
3074                   movaps encodes one byte shorter.  */
3075                (eq_attr "alternative" "8")
3076                  (cond
3077                    [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3078                         (const_int 0))
3079                       (const_string "V4SF")
3080                     (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3081                         (const_int 0))
3082                       (const_string "V2DF")
3083                    ]
3084                    (const_string "DF"))
3085                /* For architectures resolving dependencies on register
3086                   parts we may avoid extra work to zero out upper part
3087                   of register.  */
3088                (eq_attr "alternative" "9")
3089                  (if_then_else
3090                    (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3091                        (const_int 0))
3092                    (const_string "V1DF")
3093                    (const_string "DF"))
3094               ]
3095               (const_string "DF")))])
3096
3097 (define_insn "*movdf_internal"
3098   [(set (match_operand:DF 0 "nonimmediate_operand"
3099                 "=f,m,f,r  ,o ,Y2*x,Y2*x,Y2*x,m   ")
3100         (match_operand:DF 1 "general_operand"
3101                 "fm,f,G,roF,Fr,C   ,Y2*x,m   ,Y2*x"))]
3102   "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3103    && optimize_function_for_speed_p (cfun)
3104    && TARGET_INTEGER_DFMODE_MOVES
3105    && (reload_in_progress || reload_completed
3106        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3107        || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3108            && optimize_function_for_size_p (cfun)
3109            && standard_80387_constant_p (operands[1]))
3110        || GET_CODE (operands[1]) != CONST_DOUBLE
3111        || memory_operand (operands[0], DFmode))"
3112 {
3113   switch (which_alternative)
3114     {
3115     case 0:
3116     case 1:
3117       return output_387_reg_move (insn, operands);
3118
3119     case 2:
3120       return standard_80387_constant_opcode (operands[1]);
3121
3122     case 3:
3123     case 4:
3124       return "#";
3125
3126     case 5:
3127       switch (get_attr_mode (insn))
3128         {
3129         case MODE_V4SF:
3130           return "%vxorps\t%0, %d0";
3131         case MODE_V2DF:
3132           if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3133             return "%vxorps\t%0, %d0";
3134           else
3135             return "%vxorpd\t%0, %d0";
3136         case MODE_TI:
3137           if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3138             return "%vxorps\t%0, %d0";
3139           else
3140             return "%vpxor\t%0, %d0";
3141         default:
3142           gcc_unreachable ();
3143         }
3144     case 6:
3145     case 7:
3146     case 8:
3147       switch (get_attr_mode (insn))
3148         {
3149         case MODE_V4SF:
3150           return "%vmovaps\t{%1, %0|%0, %1}";
3151         case MODE_V2DF:
3152           if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3153             return "%vmovaps\t{%1, %0|%0, %1}";
3154           else
3155             return "%vmovapd\t{%1, %0|%0, %1}";
3156         case MODE_TI:
3157           if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3158             return "%vmovaps\t{%1, %0|%0, %1}";
3159           else
3160             return "%vmovdqa\t{%1, %0|%0, %1}";
3161         case MODE_DI:
3162           return "%vmovq\t{%1, %0|%0, %1}";
3163         case MODE_DF:
3164           if (TARGET_AVX)
3165             {
3166               if (REG_P (operands[0]) && REG_P (operands[1]))
3167                 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3168               else
3169                 return "vmovsd\t{%1, %0|%0, %1}";
3170             }
3171           else
3172             return "movsd\t{%1, %0|%0, %1}";
3173         case MODE_V1DF:
3174           if (TARGET_AVX)
3175             {
3176               if (REG_P (operands[0]))
3177                 return "vmovlpd\t{%1, %0, %0|%0, %0, %1}";
3178               else
3179                 return "vmovlpd\t{%1, %0|%0, %1}";
3180             }
3181           else
3182             return "movlpd\t{%1, %0|%0, %1}";
3183         case MODE_V2SF:
3184           if (TARGET_AVX)
3185             {
3186               if (REG_P (operands[0]))
3187                 return "vmovlps\t{%1, %0, %0|%0, %0, %1}";
3188               else
3189                 return "vmovlps\t{%1, %0|%0, %1}";
3190             }
3191           else
3192             return "movlps\t{%1, %0|%0, %1}";
3193         default:
3194           gcc_unreachable ();
3195         }
3196
3197     default:
3198       gcc_unreachable ();
3199     }
3200 }
3201   [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3202    (set (attr "prefix")
3203      (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3204        (const_string "orig")
3205        (const_string "maybe_vex")))
3206    (set (attr "prefix_data16")
3207      (if_then_else (eq_attr "mode" "V1DF")
3208        (const_string "1")
3209        (const_string "*")))
3210    (set (attr "mode")
3211         (cond [(eq_attr "alternative" "0,1,2")
3212                  (const_string "DF")
3213                (eq_attr "alternative" "3,4")
3214                  (const_string "SI")
3215
3216                /* For SSE1, we have many fewer alternatives.  */
3217                (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3218                  (cond [(eq_attr "alternative" "5,6")
3219                           (const_string "V4SF")
3220                        ]
3221                    (const_string "V2SF"))
3222
3223                /* xorps is one byte shorter.  */
3224                (eq_attr "alternative" "5")
3225                  (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3226                             (const_int 0))
3227                           (const_string "V4SF")
3228                         (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3229                             (const_int 0))
3230                           (const_string "TI")
3231                        ]
3232                        (const_string "V2DF"))
3233
3234                /* For architectures resolving dependencies on
3235                   whole SSE registers use APD move to break dependency
3236                   chains, otherwise use short move to avoid extra work.
3237
3238                   movaps encodes one byte shorter.  */
3239                (eq_attr "alternative" "6")
3240                  (cond
3241                    [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3242                         (const_int 0))
3243                       (const_string "V4SF")
3244                     (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3245                         (const_int 0))
3246                       (const_string "V2DF")
3247                    ]
3248                    (const_string "DF"))
3249                /* For architectures resolving dependencies on register
3250                   parts we may avoid extra work to zero out upper part
3251                   of register.  */
3252                (eq_attr "alternative" "7")
3253                  (if_then_else
3254                    (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3255                        (const_int 0))
3256                    (const_string "V1DF")
3257                    (const_string "DF"))
3258               ]
3259               (const_string "DF")))])
3260
3261 ;; Moving is usually shorter when only FP registers are used. This separate
3262 ;; movdf pattern avoids the use of integer registers for FP operations
3263 ;; when optimizing for size.
3264
3265 (define_insn "*movdf_internal_nointeger"
3266   [(set (match_operand:DF 0 "nonimmediate_operand"
3267                         "=f,m,f,*r  ,o  ,Y2*x,Y2*x,Y2*x ,m  ")
3268         (match_operand:DF 1 "general_operand"
3269                         "fm,f,G,*roF,*Fr,C   ,Y2*x,mY2*x,Y2*x"))]
3270   "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3271    && (optimize_function_for_size_p (cfun)
3272        || !TARGET_INTEGER_DFMODE_MOVES)
3273    && (reload_in_progress || reload_completed
3274        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3275        || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3276            && optimize_function_for_size_p (cfun)
3277            && !memory_operand (operands[0], DFmode)
3278            && standard_80387_constant_p (operands[1]))
3279        || GET_CODE (operands[1]) != CONST_DOUBLE
3280        || ((optimize_function_for_size_p (cfun)
3281             || !TARGET_MEMORY_MISMATCH_STALL
3282             || reload_in_progress || reload_completed)
3283            && memory_operand (operands[0], DFmode)))"
3284 {
3285   switch (which_alternative)
3286     {
3287     case 0:
3288     case 1:
3289       return output_387_reg_move (insn, operands);
3290
3291     case 2:
3292       return standard_80387_constant_opcode (operands[1]);
3293
3294     case 3:
3295     case 4:
3296       return "#";
3297
3298     case 5:
3299       switch (get_attr_mode (insn))
3300         {
3301         case MODE_V4SF:
3302           return "%vxorps\t%0, %d0";
3303         case MODE_V2DF:
3304           if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3305             return "%vxorps\t%0, %d0";
3306           else
3307             return "%vxorpd\t%0, %d0";
3308         case MODE_TI:
3309           if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3310             return "%vxorps\t%0, %d0";
3311           else
3312             return "%vpxor\t%0, %d0";
3313         default:
3314           gcc_unreachable ();
3315         }
3316     case 6:
3317     case 7:
3318     case 8:
3319       switch (get_attr_mode (insn))
3320         {
3321         case MODE_V4SF:
3322           return "%vmovaps\t{%1, %0|%0, %1}";
3323         case MODE_V2DF:
3324           if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3325             return "%vmovaps\t{%1, %0|%0, %1}";
3326           else
3327             return "%vmovapd\t{%1, %0|%0, %1}";
3328         case MODE_TI:
3329           if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3330             return "%vmovaps\t{%1, %0|%0, %1}";
3331           else
3332             return "%vmovdqa\t{%1, %0|%0, %1}";
3333         case MODE_DI:
3334           return "%vmovq\t{%1, %0|%0, %1}";
3335         case MODE_DF:
3336           if (TARGET_AVX)
3337             {
3338               if (REG_P (operands[0]) && REG_P (operands[1]))
3339                 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3340               else
3341                 return "vmovsd\t{%1, %0|%0, %1}";
3342             }
3343           else
3344             return "movsd\t{%1, %0|%0, %1}";
3345         case MODE_V1DF:
3346           if (TARGET_AVX)
3347             {
3348               if (REG_P (operands[0]))
3349                 return "vmovlpd\t{%1, %0, %0|%0, %0, %1}";
3350               else
3351                 return "vmovlpd\t{%1, %0|%0, %1}";
3352             }
3353           else
3354             return "movlpd\t{%1, %0|%0, %1}";
3355         case MODE_V2SF:
3356           if (TARGET_AVX)
3357             {
3358               if (REG_P (operands[0]))
3359                 return "vmovlps\t{%1, %0, %0|%0, %0, %1}";
3360               else
3361                 return "vmovlps\t{%1, %0|%0, %1}";
3362             }
3363           else
3364             return "movlps\t{%1, %0|%0, %1}";
3365         default:
3366           gcc_unreachable ();
3367         }
3368
3369     default:
3370       gcc_unreachable ();
3371     }
3372 }
3373   [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3374    (set (attr "prefix")
3375      (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3376        (const_string "orig")
3377        (const_string "maybe_vex")))
3378    (set (attr "prefix_data16")
3379      (if_then_else (eq_attr "mode" "V1DF")
3380        (const_string "1")
3381        (const_string "*")))
3382    (set (attr "mode")
3383         (cond [(eq_attr "alternative" "0,1,2")
3384                  (const_string "DF")
3385                (eq_attr "alternative" "3,4")
3386                  (const_string "SI")
3387
3388                /* For SSE1, we have many fewer alternatives.  */
3389                (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3390                  (cond [(eq_attr "alternative" "5,6")
3391                           (const_string "V4SF")
3392                        ]
3393                    (const_string "V2SF"))
3394
3395                /* xorps is one byte shorter.  */
3396                (eq_attr "alternative" "5")
3397                  (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3398                             (const_int 0))
3399                           (const_string "V4SF")
3400                         (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3401                             (const_int 0))
3402                           (const_string "TI")
3403                        ]
3404                        (const_string "V2DF"))
3405
3406                /* For architectures resolving dependencies on
3407                   whole SSE registers use APD move to break dependency
3408                   chains, otherwise use short move to avoid extra work.
3409
3410                   movaps encodes one byte shorter.  */
3411                (eq_attr "alternative" "6")
3412                  (cond
3413                    [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3414                         (const_int 0))
3415                       (const_string "V4SF")
3416                     (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3417                         (const_int 0))
3418                       (const_string "V2DF")
3419                    ]
3420                    (const_string "DF"))
3421                /* For architectures resolving dependencies on register
3422                   parts we may avoid extra work to zero out upper part
3423                   of register.  */
3424                (eq_attr "alternative" "7")
3425                  (if_then_else
3426                    (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3427                        (const_int 0))
3428                    (const_string "V1DF")
3429                    (const_string "DF"))
3430               ]
3431               (const_string "DF")))])
3432
3433 (define_split
3434   [(set (match_operand:DF 0 "nonimmediate_operand" "")
3435         (match_operand:DF 1 "general_operand" ""))]
3436   "reload_completed
3437    && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3438    && ! (ANY_FP_REG_P (operands[0]) ||
3439          (GET_CODE (operands[0]) == SUBREG
3440           && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3441    && ! (ANY_FP_REG_P (operands[1]) ||
3442          (GET_CODE (operands[1]) == SUBREG
3443           && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3444   [(const_int 0)]
3445   "ix86_split_long_move (operands); DONE;")
3446
3447 (define_insn "*movsf_internal"
3448   [(set (match_operand:SF 0 "nonimmediate_operand"
3449           "=f,m,f,r  ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
3450         (match_operand:SF 1 "general_operand"
3451           "fm,f,G,rmF,Fr,C,x,xm,x,m  ,*y,*y ,r  ,Yi,r   ,*Ym"))]
3452   "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3453    && (reload_in_progress || reload_completed
3454        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3455        || (!TARGET_SSE_MATH && optimize_function_for_size_p (cfun)
3456            && standard_80387_constant_p (operands[1]))
3457        || GET_CODE (operands[1]) != CONST_DOUBLE
3458        || memory_operand (operands[0], SFmode))"
3459 {
3460   switch (which_alternative)
3461     {
3462     case 0:
3463     case 1:
3464       return output_387_reg_move (insn, operands);
3465
3466     case 2:
3467       return standard_80387_constant_opcode (operands[1]);
3468
3469     case 3:
3470     case 4:
3471       return "mov{l}\t{%1, %0|%0, %1}";
3472     case 5:
3473       if (get_attr_mode (insn) == MODE_TI)
3474         return "%vpxor\t%0, %d0";
3475       else
3476         return "%vxorps\t%0, %d0";
3477     case 6:
3478       if (get_attr_mode (insn) == MODE_V4SF)
3479         return "%vmovaps\t{%1, %0|%0, %1}";
3480       else
3481         return "%vmovss\t{%1, %d0|%d0, %1}";
3482     case 7:
3483       if (TARGET_AVX)
3484         {
3485           if (REG_P (operands[1]))
3486             return "vmovss\t{%1, %0, %0|%0, %0, %1}";
3487           else
3488             return "vmovss\t{%1, %0|%0, %1}";
3489         }
3490       else
3491         return "movss\t{%1, %0|%0, %1}";
3492     case 8:
3493       return "%vmovss\t{%1, %0|%0, %1}";
3494
3495     case 9: case 10: case 14: case 15:
3496       return "movd\t{%1, %0|%0, %1}";
3497     case 12: case 13:
3498       return "%vmovd\t{%1, %0|%0, %1}";
3499
3500     case 11:
3501       return "movq\t{%1, %0|%0, %1}";
3502
3503     default:
3504       gcc_unreachable ();
3505     }
3506 }
3507   [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
3508    (set (attr "prefix")
3509      (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
3510        (const_string "maybe_vex")
3511        (const_string "orig")))
3512    (set (attr "mode")
3513         (cond [(eq_attr "alternative" "3,4,9,10")
3514                  (const_string "SI")
3515                (eq_attr "alternative" "5")
3516                  (if_then_else
3517                    (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3518                                  (const_int 0))
3519                              (ne (symbol_ref "TARGET_SSE2")
3520                                  (const_int 0)))
3521                         (eq (symbol_ref "optimize_function_for_size_p (cfun)")
3522                             (const_int 0)))
3523                    (const_string "TI")
3524                    (const_string "V4SF"))
3525                /* For architectures resolving dependencies on
3526                   whole SSE registers use APS move to break dependency
3527                   chains, otherwise use short move to avoid extra work.
3528
3529                   Do the same for architectures resolving dependencies on
3530                   the parts.  While in DF mode it is better to always handle
3531                   just register parts, the SF mode is different due to lack
3532                   of instructions to load just part of the register.  It is
3533                   better to maintain the whole registers in single format
3534                   to avoid problems on using packed logical operations.  */
3535                (eq_attr "alternative" "6")
3536                  (if_then_else
3537                    (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3538                             (const_int 0))
3539                         (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3540                             (const_int 0)))
3541                    (const_string "V4SF")
3542                    (const_string "SF"))
3543                (eq_attr "alternative" "11")
3544                  (const_string "DI")]
3545                (const_string "SF")))])
3546
3547 (define_split
3548   [(set (match_operand 0 "register_operand" "")
3549         (match_operand 1 "memory_operand" ""))]
3550   "reload_completed
3551    && MEM_P (operands[1])
3552    && (GET_MODE (operands[0]) == TFmode
3553        || GET_MODE (operands[0]) == XFmode
3554        || GET_MODE (operands[0]) == DFmode
3555        || GET_MODE (operands[0]) == SFmode)
3556    && (operands[2] = find_constant_src (insn))"
3557   [(set (match_dup 0) (match_dup 2))]
3558 {
3559   rtx c = operands[2];
3560   rtx r = operands[0];
3561
3562   if (GET_CODE (r) == SUBREG)
3563     r = SUBREG_REG (r);
3564
3565   if (SSE_REG_P (r))
3566     {
3567       if (!standard_sse_constant_p (c))
3568         FAIL;
3569     }
3570   else if (FP_REG_P (r))
3571     {
3572       if (!standard_80387_constant_p (c))
3573         FAIL;
3574     }
3575   else if (MMX_REG_P (r))
3576     FAIL;
3577 })
3578
3579 (define_split
3580   [(set (match_operand 0 "register_operand" "")
3581         (float_extend (match_operand 1 "memory_operand" "")))]
3582   "reload_completed
3583    && MEM_P (operands[1])
3584    && (GET_MODE (operands[0]) == TFmode
3585        || GET_MODE (operands[0]) == XFmode
3586        || GET_MODE (operands[0]) == DFmode
3587        || GET_MODE (operands[0]) == SFmode)
3588    && (operands[2] = find_constant_src (insn))"
3589   [(set (match_dup 0) (match_dup 2))]
3590 {
3591   rtx c = operands[2];
3592   rtx r = operands[0];
3593
3594   if (GET_CODE (r) == SUBREG)
3595     r = SUBREG_REG (r);
3596
3597   if (SSE_REG_P (r))
3598     {
3599       if (!standard_sse_constant_p (c))
3600         FAIL;
3601     }
3602   else if (FP_REG_P (r))
3603     {
3604       if (!standard_80387_constant_p (c))
3605         FAIL;
3606     }
3607   else if (MMX_REG_P (r))
3608     FAIL;
3609 })
3610
3611 ;; Split the load of -0.0 or -1.0 into fldz;fchs or fld1;fchs sequence
3612 (define_split
3613   [(set (match_operand:X87MODEF 0 "register_operand" "")
3614         (match_operand:X87MODEF 1 "immediate_operand" ""))]
3615   "reload_completed && FP_REGNO_P (REGNO (operands[0]))
3616    && (standard_80387_constant_p (operands[1]) == 8
3617        || standard_80387_constant_p (operands[1]) == 9)"
3618   [(set (match_dup 0)(match_dup 1))
3619    (set (match_dup 0)
3620         (neg:X87MODEF (match_dup 0)))]
3621 {
3622   REAL_VALUE_TYPE r;
3623
3624   REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
3625   if (real_isnegzero (&r))
3626     operands[1] = CONST0_RTX (<MODE>mode);
3627   else
3628     operands[1] = CONST1_RTX (<MODE>mode);
3629 })
3630
3631 (define_insn "swapxf"
3632   [(set (match_operand:XF 0 "register_operand" "+f")
3633         (match_operand:XF 1 "register_operand" "+f"))
3634    (set (match_dup 1)
3635         (match_dup 0))]
3636   "TARGET_80387"
3637 {
3638   if (STACK_TOP_P (operands[0]))
3639     return "fxch\t%1";
3640   else
3641     return "fxch\t%0";
3642 }
3643   [(set_attr "type" "fxch")
3644    (set_attr "mode" "XF")])
3645
3646 (define_insn "*swap<mode>"
3647   [(set (match_operand:MODEF 0 "fp_register_operand" "+f")
3648         (match_operand:MODEF 1 "fp_register_operand" "+f"))
3649    (set (match_dup 1)
3650         (match_dup 0))]
3651   "TARGET_80387 || reload_completed"
3652 {
3653   if (STACK_TOP_P (operands[0]))
3654     return "fxch\t%1";
3655   else
3656     return "fxch\t%0";
3657 }
3658   [(set_attr "type" "fxch")
3659    (set_attr "mode" "<MODE>")])
3660 \f
3661 ;; Zero extension instructions
3662
3663 (define_expand "zero_extendsidi2"
3664   [(set (match_operand:DI 0 "nonimmediate_operand" "")
3665         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3666   ""
3667 {
3668   if (!TARGET_64BIT)
3669     {
3670       emit_insn (gen_zero_extendsidi2_1 (operands[0], operands[1]));
3671       DONE;
3672     }
3673 })
3674
3675 (define_insn "*zero_extendsidi2_rex64"
3676   [(set (match_operand:DI 0 "nonimmediate_operand"  "=r,o,?*Ym,?*y,?*Yi,*Y2")
3677         (zero_extend:DI
3678          (match_operand:SI 1 "nonimmediate_operand" "rm,0,r   ,m  ,r   ,m")))]
3679   "TARGET_64BIT"
3680   "@
3681    mov\t{%k1, %k0|%k0, %k1}
3682    #
3683    movd\t{%1, %0|%0, %1}
3684    movd\t{%1, %0|%0, %1}
3685    %vmovd\t{%1, %0|%0, %1}
3686    %vmovd\t{%1, %0|%0, %1}"
3687   [(set_attr "type" "imovx,imov,mmxmov,mmxmov,ssemov,ssemov")
3688    (set_attr "prefix" "orig,*,orig,orig,maybe_vex,maybe_vex")
3689    (set_attr "prefix_0f" "0,*,*,*,*,*")
3690    (set_attr "mode" "SI,DI,DI,DI,TI,TI")])
3691
3692 (define_split
3693   [(set (match_operand:DI 0 "memory_operand" "")
3694         (zero_extend:DI (match_dup 0)))]
3695   "TARGET_64BIT"
3696   [(set (match_dup 4) (const_int 0))]
3697   "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3698
3699 ;; %%% Kill me once multi-word ops are sane.
3700 (define_insn "zero_extendsidi2_1"
3701   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?o,?*Ym,?*y,?*Yi,*Y2")
3702         (zero_extend:DI
3703          (match_operand:SI 1 "nonimmediate_operand" "0,rm,r ,r   ,m  ,r   ,m")))
3704    (clobber (reg:CC FLAGS_REG))]
3705   "!TARGET_64BIT"
3706   "@
3707    #
3708    #
3709    #
3710    movd\t{%1, %0|%0, %1}
3711    movd\t{%1, %0|%0, %1}
3712    %vmovd\t{%1, %0|%0, %1}
3713    %vmovd\t{%1, %0|%0, %1}"
3714   [(set_attr "type" "multi,multi,multi,mmxmov,mmxmov,ssemov,ssemov")
3715    (set_attr "prefix" "*,*,*,orig,orig,maybe_vex,maybe_vex")
3716    (set_attr "mode" "SI,SI,SI,DI,DI,TI,TI")])
3717
3718 (define_split
3719   [(set (match_operand:DI 0 "register_operand" "")
3720         (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3721    (clobber (reg:CC FLAGS_REG))]
3722   "!TARGET_64BIT && reload_completed
3723    && true_regnum (operands[0]) == true_regnum (operands[1])"
3724   [(set (match_dup 4) (const_int 0))]
3725   "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3726
3727 (define_split
3728   [(set (match_operand:DI 0 "nonimmediate_operand" "")
3729         (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3730    (clobber (reg:CC FLAGS_REG))]
3731   "!TARGET_64BIT && reload_completed
3732    && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))"
3733   [(set (match_dup 3) (match_dup 1))
3734    (set (match_dup 4) (const_int 0))]
3735   "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")
3736
3737 (define_insn "zero_extend<mode>di2"
3738   [(set (match_operand:DI 0 "register_operand" "=r")
3739         (zero_extend:DI
3740          (match_operand:SWI12 1 "nonimmediate_operand" "<r>m")))]
3741   "TARGET_64BIT"
3742   "movz{<imodesuffix>l|x}\t{%1, %k0|%k0, %1}"
3743   [(set_attr "type" "imovx")
3744    (set_attr "mode" "SI")])
3745
3746 (define_expand "zero_extendhisi2"
3747   [(set (match_operand:SI 0 "register_operand" "")
3748         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
3749   ""
3750 {
3751   if (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3752     {
3753       operands[1] = force_reg (HImode, operands[1]);
3754       emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
3755       DONE;
3756     }
3757 })
3758
3759 (define_insn_and_split "zero_extendhisi2_and"
3760   [(set (match_operand:SI 0 "register_operand" "=r")
3761         (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
3762    (clobber (reg:CC FLAGS_REG))]
3763   "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3764   "#"
3765   "&& reload_completed"
3766   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
3767               (clobber (reg:CC FLAGS_REG))])]
3768   ""
3769   [(set_attr "type" "alu1")
3770    (set_attr "mode" "SI")])
3771
3772 (define_insn "*zero_extendhisi2_movzwl"
3773   [(set (match_operand:SI 0 "register_operand" "=r")
3774         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3775   "!TARGET_ZERO_EXTEND_WITH_AND
3776    || optimize_function_for_size_p (cfun)"
3777   "movz{wl|x}\t{%1, %0|%0, %1}"
3778   [(set_attr "type" "imovx")
3779    (set_attr "mode" "SI")])
3780
3781 (define_expand "zero_extendqi<mode>2"
3782   [(parallel
3783     [(set (match_operand:SWI24 0 "register_operand" "")
3784           (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3785      (clobber (reg:CC FLAGS_REG))])])
3786
3787 (define_insn "*zero_extendqi<mode>2_and"
3788   [(set (match_operand:SWI24 0 "register_operand" "=r,?&q")
3789         (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3790    (clobber (reg:CC FLAGS_REG))]
3791   "TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun)"
3792   "#"
3793   [(set_attr "type" "alu1")
3794    (set_attr "mode" "<MODE>")])
3795
3796 ;; When source and destination does not overlap, clear destination
3797 ;; first and then do the movb
3798 (define_split
3799   [(set (match_operand:SWI24 0 "register_operand" "")
3800         (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3801    (clobber (reg:CC FLAGS_REG))]
3802   "reload_completed
3803    && (TARGET_ZERO_EXTEND_WITH_AND && optimize_function_for_speed_p (cfun))
3804    && ANY_QI_REG_P (operands[0])
3805    && (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]))
3806    && !reg_overlap_mentioned_p (operands[0], operands[1])"
3807   [(set (strict_low_part (match_dup 2)) (match_dup 1))]
3808 {
3809   operands[2] = gen_lowpart (QImode, operands[0]);
3810   ix86_expand_clear (operands[0]);
3811 })
3812
3813 (define_insn "*zero_extendqi<mode>2_movzbl_and"
3814   [(set (match_operand:SWI24 0 "register_operand" "=r,r")
3815         (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3816    (clobber (reg:CC FLAGS_REG))]
3817   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun)"
3818   "#"
3819   [(set_attr "type" "imovx,alu1")
3820    (set_attr "mode" "<MODE>")])
3821
3822 ;; For the movzbl case strip only the clobber
3823 (define_split
3824   [(set (match_operand:SWI24 0 "register_operand" "")
3825         (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "")))
3826    (clobber (reg:CC FLAGS_REG))]
3827   "reload_completed
3828    && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))
3829    && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3830   [(set (match_dup 0)
3831         (zero_extend:SWI24 (match_dup 1)))])
3832
3833 ; zero extend to SImode to avoid partial register stalls
3834 (define_insn "*zero_extendqi<mode>2_movzbl"
3835   [(set (match_operand:SWI24 0 "register_operand" "=r")
3836         (zero_extend:SWI24 (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3837   "reload_completed
3838    && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_function_for_size_p (cfun))"
3839   "movz{bl|x}\t{%1, %k0|%k0, %1}"
3840   [(set_attr "type" "imovx")
3841    (set_attr "mode" "SI")])
3842
3843 ;; Rest is handled by single and.
3844 (define_split
3845   [(set (match_operand:SWI24 0 "register_operand" "")
3846         (zero_extend:SWI24 (match_operand:QI 1 "register_operand" "")))
3847    (clobber (reg:CC FLAGS_REG))]
3848   "reload_completed
3849    && true_regnum (operands[0]) == true_regnum (operands[1])"
3850   [(parallel [(set (match_dup 0) (and:SWI24 (match_dup 0) (const_int 255)))
3851               (clobber (reg:CC FLAGS_REG))])])
3852 \f
3853 ;; Sign extension instructions
3854
3855 (define_expand "extendsidi2"
3856   [(set (match_operand:DI 0 "register_operand" "")
3857         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))]
3858   ""
3859 {
3860   if (!TARGET_64BIT)
3861     {
3862       emit_insn (gen_extendsidi2_1 (operands[0], operands[1]));
3863       DONE;
3864     }
3865 })
3866
3867 (define_insn "*extendsidi2_rex64"
3868   [(set (match_operand:DI 0 "register_operand" "=*a,r")
3869         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3870   "TARGET_64BIT"
3871   "@
3872    {cltq|cdqe}
3873    movs{lq|x}\t{%1, %0|%0, %1}"
3874   [(set_attr "type" "imovx")
3875    (set_attr "mode" "DI")
3876    (set_attr "prefix_0f" "0")
3877    (set_attr "modrm" "0,1")])
3878
3879 (define_insn "extendsidi2_1"
3880   [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3881         (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3882    (clobber (reg:CC FLAGS_REG))
3883    (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3884   "!TARGET_64BIT"
3885   "#")
3886
3887 ;; Extend to memory case when source register does die.
3888 (define_split
3889   [(set (match_operand:DI 0 "memory_operand" "")
3890         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3891    (clobber (reg:CC FLAGS_REG))
3892    (clobber (match_operand:SI 2 "register_operand" ""))]
3893   "(reload_completed
3894     && dead_or_set_p (insn, operands[1])
3895     && !reg_mentioned_p (operands[1], operands[0]))"
3896   [(set (match_dup 3) (match_dup 1))
3897    (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3898               (clobber (reg:CC FLAGS_REG))])
3899    (set (match_dup 4) (match_dup 1))]
3900   "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);")