OSDN Git Service

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