OSDN Git Service

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