OSDN Git Service

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