OSDN Git Service

PR target/49781
[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,bdver2,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 ;; All integer modes.
794 (define_mode_iterator SWI1248x [QI HI SI DI])
795
796 ;; All integer modes without QImode.
797 (define_mode_iterator SWI248x [HI SI DI])
798
799 ;; All integer modes without QImode and HImode.
800 (define_mode_iterator SWI48x [SI DI])
801
802 ;; All integer modes without SImode and DImode.
803 (define_mode_iterator SWI12 [QI HI])
804
805 ;; All integer modes without DImode.
806 (define_mode_iterator SWI124 [QI HI SI])
807
808 ;; All integer modes without QImode and DImode.
809 (define_mode_iterator SWI24 [HI SI])
810
811 ;; Single word integer modes.
812 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
813
814 ;; Single word integer modes without QImode.
815 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
816
817 ;; Single word integer modes without QImode and HImode.
818 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
819
820 ;; All math-dependant single and double word integer modes.
821 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
822                              (HI "TARGET_HIMODE_MATH")
823                              SI DI (TI "TARGET_64BIT")])
824
825 ;; Math-dependant single word integer modes.
826 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
827                             (HI "TARGET_HIMODE_MATH")
828                             SI (DI "TARGET_64BIT")])
829
830 ;; Math-dependant integer modes without DImode.
831 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
832                                (HI "TARGET_HIMODE_MATH")
833                                SI])
834
835 ;; Math-dependant single word integer modes without QImode.
836 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
837                                SI (DI "TARGET_64BIT")])
838
839 ;; Double word integer modes.
840 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
841                            (TI "TARGET_64BIT")])
842
843 ;; Double word integer modes as mode attribute.
844 (define_mode_attr DWI [(SI "DI") (DI "TI")])
845 (define_mode_attr dwi [(SI "di") (DI "ti")])
846
847 ;; Half mode for double word integer modes.
848 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
849                             (DI "TARGET_64BIT")])
850
851 ;; Instruction suffix for integer modes.
852 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
853
854 ;; Pointer size prefix for integer modes (Intel asm dialect)
855 (define_mode_attr iptrsize [(QI "BYTE")
856                             (HI "WORD")
857                             (SI "DWORD")
858                             (DI "QWORD")])
859
860 ;; Register class for integer modes.
861 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
862
863 ;; Immediate operand constraint for integer modes.
864 (define_mode_attr i [(QI "n") (HI "n") (SI "e") (DI "e")])
865
866 ;; General operand constraint for word modes.
867 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "rme") (DI "rme")])
868
869 ;; Immediate operand constraint for double integer modes.
870 (define_mode_attr di [(SI "nF") (DI "e")])
871
872 ;; Immediate operand constraint for shifts.
873 (define_mode_attr S [(QI "I") (HI "I") (SI "I") (DI "J") (TI "O")])
874
875 ;; General operand predicate for integer modes.
876 (define_mode_attr general_operand
877         [(QI "general_operand")
878          (HI "general_operand")
879          (SI "x86_64_general_operand")
880          (DI "x86_64_general_operand")
881          (TI "x86_64_general_operand")])
882
883 ;; General sign/zero extend operand predicate for integer modes.
884 (define_mode_attr general_szext_operand
885         [(QI "general_operand")
886          (HI "general_operand")
887          (SI "x86_64_szext_general_operand")
888          (DI "x86_64_szext_general_operand")])
889
890 ;; Immediate operand predicate for integer modes.
891 (define_mode_attr immediate_operand
892         [(QI "immediate_operand")
893          (HI "immediate_operand")
894          (SI "x86_64_immediate_operand")
895          (DI "x86_64_immediate_operand")])
896
897 ;; Nonmemory operand predicate for integer modes.
898 (define_mode_attr nonmemory_operand
899         [(QI "nonmemory_operand")
900          (HI "nonmemory_operand")
901          (SI "x86_64_nonmemory_operand")
902          (DI "x86_64_nonmemory_operand")])
903
904 ;; Operand predicate for shifts.
905 (define_mode_attr shift_operand
906         [(QI "nonimmediate_operand")
907          (HI "nonimmediate_operand")
908          (SI "nonimmediate_operand")
909          (DI "shiftdi_operand")
910          (TI "register_operand")])
911
912 ;; Operand predicate for shift argument.
913 (define_mode_attr shift_immediate_operand
914         [(QI "const_1_to_31_operand")
915          (HI "const_1_to_31_operand")
916          (SI "const_1_to_31_operand")
917          (DI "const_1_to_63_operand")])
918
919 ;; Input operand predicate for arithmetic left shifts.
920 (define_mode_attr ashl_input_operand
921         [(QI "nonimmediate_operand")
922          (HI "nonimmediate_operand")
923          (SI "nonimmediate_operand")
924          (DI "ashldi_input_operand")
925          (TI "reg_or_pm1_operand")])
926
927 ;; SSE and x87 SFmode and DFmode floating point modes
928 (define_mode_iterator MODEF [SF DF])
929
930 ;; All x87 floating point modes
931 (define_mode_iterator X87MODEF [SF DF XF])
932
933 ;; SSE instruction suffix for various modes
934 (define_mode_attr ssemodesuffix
935   [(SF "ss") (DF "sd")
936    (V8SF "ps") (V4DF "pd")
937    (V4SF "ps") (V2DF "pd")
938    (V16QI "b") (V8HI "w") (V4SI "d") (V2DI "q")])
939
940 ;; SSE vector suffix for floating point modes
941 (define_mode_attr ssevecmodesuffix [(SF "ps") (DF "pd")])
942
943 ;; SSE vector mode corresponding to a scalar mode
944 (define_mode_attr ssevecmode
945   [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
946
947 ;; Instruction suffix for REX 64bit operators.
948 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
949
950 ;; This mode iterator allows :P to be used for patterns that operate on
951 ;; pointer-sized quantities.  Exactly one of the two alternatives will match.
952 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
953
954 ;; This mode iterator allows :PTR to be used for patterns that operate on
955 ;; ptr_mode sized quantities.
956 (define_mode_iterator PTR
957   [(SI "ptr_mode == SImode") (DI "ptr_mode == DImode")])
958 \f
959 ;; Scheduling descriptions
960
961 (include "pentium.md")
962 (include "ppro.md")
963 (include "k6.md")
964 (include "athlon.md")
965 (include "bdver1.md")
966 (include "geode.md")
967 (include "atom.md")
968 (include "core2.md")
969
970 \f
971 ;; Operand and operator predicates and constraints
972
973 (include "predicates.md")
974 (include "constraints.md")
975
976 \f
977 ;; Compare and branch/compare and store instructions.
978
979 (define_expand "cbranch<mode>4"
980   [(set (reg:CC FLAGS_REG)
981         (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
982                     (match_operand:SDWIM 2 "<general_operand>" "")))
983    (set (pc) (if_then_else
984                (match_operator 0 "ordered_comparison_operator"
985                 [(reg:CC FLAGS_REG) (const_int 0)])
986                (label_ref (match_operand 3 "" ""))
987                (pc)))]
988   ""
989 {
990   if (MEM_P (operands[1]) && MEM_P (operands[2]))
991     operands[1] = force_reg (<MODE>mode, operands[1]);
992   ix86_expand_branch (GET_CODE (operands[0]),
993                       operands[1], operands[2], operands[3]);
994   DONE;
995 })
996
997 (define_expand "cstore<mode>4"
998   [(set (reg:CC FLAGS_REG)
999         (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
1000                     (match_operand:SWIM 3 "<general_operand>" "")))
1001    (set (match_operand:QI 0 "register_operand" "")
1002         (match_operator 1 "ordered_comparison_operator"
1003           [(reg:CC FLAGS_REG) (const_int 0)]))]
1004   ""
1005 {
1006   if (MEM_P (operands[2]) && MEM_P (operands[3]))
1007     operands[2] = force_reg (<MODE>mode, operands[2]);
1008   ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1009                      operands[2], operands[3]);
1010   DONE;
1011 })
1012
1013 (define_expand "cmp<mode>_1"
1014   [(set (reg:CC FLAGS_REG)
1015         (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
1016                     (match_operand:SWI48 1 "<general_operand>" "")))])
1017
1018 (define_insn "*cmp<mode>_ccno_1"
1019   [(set (reg FLAGS_REG)
1020         (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
1021                  (match_operand:SWI 1 "const0_operand" "")))]
1022   "ix86_match_ccmode (insn, CCNOmode)"
1023   "@
1024    test{<imodesuffix>}\t%0, %0
1025    cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1026   [(set_attr "type" "test,icmp")
1027    (set_attr "length_immediate" "0,1")
1028    (set_attr "mode" "<MODE>")])
1029
1030 (define_insn "*cmp<mode>_1"
1031   [(set (reg FLAGS_REG)
1032         (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1033                  (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
1034   "ix86_match_ccmode (insn, CCmode)"
1035   "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1036   [(set_attr "type" "icmp")
1037    (set_attr "mode" "<MODE>")])
1038
1039 (define_insn "*cmp<mode>_minus_1"
1040   [(set (reg FLAGS_REG)
1041         (compare
1042           (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
1043                      (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
1044           (const_int 0)))]
1045   "ix86_match_ccmode (insn, CCGOCmode)"
1046   "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
1047   [(set_attr "type" "icmp")
1048    (set_attr "mode" "<MODE>")])
1049
1050 (define_insn "*cmpqi_ext_1"
1051   [(set (reg FLAGS_REG)
1052         (compare
1053           (match_operand:QI 0 "general_operand" "Qm")
1054           (subreg:QI
1055             (zero_extract:SI
1056               (match_operand 1 "ext_register_operand" "Q")
1057               (const_int 8)
1058               (const_int 8)) 0)))]
1059   "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1060   "cmp{b}\t{%h1, %0|%0, %h1}"
1061   [(set_attr "type" "icmp")
1062    (set_attr "mode" "QI")])
1063
1064 (define_insn "*cmpqi_ext_1_rex64"
1065   [(set (reg FLAGS_REG)
1066         (compare
1067           (match_operand:QI 0 "register_operand" "Q")
1068           (subreg:QI
1069             (zero_extract:SI
1070               (match_operand 1 "ext_register_operand" "Q")
1071               (const_int 8)
1072               (const_int 8)) 0)))]
1073   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1074   "cmp{b}\t{%h1, %0|%0, %h1}"
1075   [(set_attr "type" "icmp")
1076    (set_attr "mode" "QI")])
1077
1078 (define_insn "*cmpqi_ext_2"
1079   [(set (reg FLAGS_REG)
1080         (compare
1081           (subreg:QI
1082             (zero_extract:SI
1083               (match_operand 0 "ext_register_operand" "Q")
1084               (const_int 8)
1085               (const_int 8)) 0)
1086           (match_operand:QI 1 "const0_operand" "")))]
1087   "ix86_match_ccmode (insn, CCNOmode)"
1088   "test{b}\t%h0, %h0"
1089   [(set_attr "type" "test")
1090    (set_attr "length_immediate" "0")
1091    (set_attr "mode" "QI")])
1092
1093 (define_expand "cmpqi_ext_3"
1094   [(set (reg:CC FLAGS_REG)
1095         (compare:CC
1096           (subreg:QI
1097             (zero_extract:SI
1098               (match_operand 0 "ext_register_operand" "")
1099               (const_int 8)
1100               (const_int 8)) 0)
1101           (match_operand:QI 1 "immediate_operand" "")))])
1102
1103 (define_insn "*cmpqi_ext_3_insn"
1104   [(set (reg FLAGS_REG)
1105         (compare
1106           (subreg:QI
1107             (zero_extract:SI
1108               (match_operand 0 "ext_register_operand" "Q")
1109               (const_int 8)
1110               (const_int 8)) 0)
1111           (match_operand:QI 1 "general_operand" "Qmn")))]
1112   "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1113   "cmp{b}\t{%1, %h0|%h0, %1}"
1114   [(set_attr "type" "icmp")
1115    (set_attr "modrm" "1")
1116    (set_attr "mode" "QI")])
1117
1118 (define_insn "*cmpqi_ext_3_insn_rex64"
1119   [(set (reg FLAGS_REG)
1120         (compare
1121           (subreg:QI
1122             (zero_extract:SI
1123               (match_operand 0 "ext_register_operand" "Q")
1124               (const_int 8)
1125               (const_int 8)) 0)
1126           (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1127   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1128   "cmp{b}\t{%1, %h0|%h0, %1}"
1129   [(set_attr "type" "icmp")
1130    (set_attr "modrm" "1")
1131    (set_attr "mode" "QI")])
1132
1133 (define_insn "*cmpqi_ext_4"
1134   [(set (reg FLAGS_REG)
1135         (compare
1136           (subreg:QI
1137             (zero_extract:SI
1138               (match_operand 0 "ext_register_operand" "Q")
1139               (const_int 8)
1140               (const_int 8)) 0)
1141           (subreg:QI
1142             (zero_extract:SI
1143               (match_operand 1 "ext_register_operand" "Q")
1144               (const_int 8)
1145               (const_int 8)) 0)))]
1146   "ix86_match_ccmode (insn, CCmode)"
1147   "cmp{b}\t{%h1, %h0|%h0, %h1}"
1148   [(set_attr "type" "icmp")
1149    (set_attr "mode" "QI")])
1150
1151 ;; These implement float point compares.
1152 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1153 ;; which would allow mix and match FP modes on the compares.  Which is what
1154 ;; the old patterns did, but with many more of them.
1155
1156 (define_expand "cbranchxf4"
1157   [(set (reg:CC FLAGS_REG)
1158         (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1159                     (match_operand:XF 2 "nonmemory_operand" "")))
1160    (set (pc) (if_then_else
1161               (match_operator 0 "ix86_fp_comparison_operator"
1162                [(reg:CC FLAGS_REG)
1163                 (const_int 0)])
1164               (label_ref (match_operand 3 "" ""))
1165               (pc)))]
1166   "TARGET_80387"
1167 {
1168   ix86_expand_branch (GET_CODE (operands[0]),
1169                       operands[1], operands[2], operands[3]);
1170   DONE;
1171 })
1172
1173 (define_expand "cstorexf4"
1174   [(set (reg:CC FLAGS_REG)
1175         (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1176                     (match_operand:XF 3 "nonmemory_operand" "")))
1177    (set (match_operand:QI 0 "register_operand" "")
1178               (match_operator 1 "ix86_fp_comparison_operator"
1179                [(reg:CC FLAGS_REG)
1180                 (const_int 0)]))]
1181   "TARGET_80387"
1182 {
1183   ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1184                      operands[2], operands[3]);
1185   DONE;
1186 })
1187
1188 (define_expand "cbranch<mode>4"
1189   [(set (reg:CC FLAGS_REG)
1190         (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1191                     (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1192    (set (pc) (if_then_else
1193               (match_operator 0 "ix86_fp_comparison_operator"
1194                [(reg:CC FLAGS_REG)
1195                 (const_int 0)])
1196               (label_ref (match_operand 3 "" ""))
1197               (pc)))]
1198   "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1199 {
1200   ix86_expand_branch (GET_CODE (operands[0]),
1201                       operands[1], operands[2], operands[3]);
1202   DONE;
1203 })
1204
1205 (define_expand "cstore<mode>4"
1206   [(set (reg:CC FLAGS_REG)
1207         (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1208                     (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1209    (set (match_operand:QI 0 "register_operand" "")
1210               (match_operator 1 "ix86_fp_comparison_operator"
1211                [(reg:CC FLAGS_REG)
1212                 (const_int 0)]))]
1213   "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1214 {
1215   ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1216                      operands[2], operands[3]);
1217   DONE;
1218 })
1219
1220 (define_expand "cbranchcc4"
1221   [(set (pc) (if_then_else
1222               (match_operator 0 "comparison_operator"
1223                [(match_operand 1 "flags_reg_operand" "")
1224                 (match_operand 2 "const0_operand" "")])
1225               (label_ref (match_operand 3 "" ""))
1226               (pc)))]
1227   ""
1228 {
1229   ix86_expand_branch (GET_CODE (operands[0]),
1230                       operands[1], operands[2], operands[3]);
1231   DONE;
1232 })
1233
1234 (define_expand "cstorecc4"
1235   [(set (match_operand:QI 0 "register_operand" "")
1236               (match_operator 1 "comparison_operator"
1237                [(match_operand 2 "flags_reg_operand" "")
1238                 (match_operand 3 "const0_operand" "")]))]
1239   ""
1240 {
1241   ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1242                      operands[2], operands[3]);
1243   DONE;
1244 })
1245
1246
1247 ;; FP compares, step 1:
1248 ;; Set the FP condition codes.
1249 ;;
1250 ;; CCFPmode     compare with exceptions
1251 ;; CCFPUmode    compare with no exceptions
1252
1253 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1254 ;; used to manage the reg stack popping would not be preserved.
1255
1256 (define_insn "*cmpfp_0"
1257   [(set (match_operand:HI 0 "register_operand" "=a")
1258         (unspec:HI
1259           [(compare:CCFP
1260              (match_operand 1 "register_operand" "f")
1261              (match_operand 2 "const0_operand" ""))]
1262         UNSPEC_FNSTSW))]
1263   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1264    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1265   "* return output_fp_compare (insn, operands, false, false);"
1266   [(set_attr "type" "multi")
1267    (set_attr "unit" "i387")
1268    (set (attr "mode")
1269      (cond [(match_operand:SF 1 "" "")
1270               (const_string "SF")
1271             (match_operand:DF 1 "" "")
1272               (const_string "DF")
1273            ]
1274            (const_string "XF")))])
1275
1276 (define_insn_and_split "*cmpfp_0_cc"
1277   [(set (reg:CCFP FLAGS_REG)
1278         (compare:CCFP
1279           (match_operand 1 "register_operand" "f")
1280           (match_operand 2 "const0_operand" "")))
1281    (clobber (match_operand:HI 0 "register_operand" "=a"))]
1282   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1283    && TARGET_SAHF && !TARGET_CMOVE
1284    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1285   "#"
1286   "&& reload_completed"
1287   [(set (match_dup 0)
1288         (unspec:HI
1289           [(compare:CCFP (match_dup 1)(match_dup 2))]
1290         UNSPEC_FNSTSW))
1291    (set (reg:CC FLAGS_REG)
1292         (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1293   ""
1294   [(set_attr "type" "multi")
1295    (set_attr "unit" "i387")
1296    (set (attr "mode")
1297      (cond [(match_operand:SF 1 "" "")
1298               (const_string "SF")
1299             (match_operand:DF 1 "" "")
1300               (const_string "DF")
1301            ]
1302            (const_string "XF")))])
1303
1304 (define_insn "*cmpfp_xf"
1305   [(set (match_operand:HI 0 "register_operand" "=a")
1306         (unspec:HI
1307           [(compare:CCFP
1308              (match_operand:XF 1 "register_operand" "f")
1309              (match_operand:XF 2 "register_operand" "f"))]
1310           UNSPEC_FNSTSW))]
1311   "TARGET_80387"
1312   "* return output_fp_compare (insn, operands, false, false);"
1313   [(set_attr "type" "multi")
1314    (set_attr "unit" "i387")
1315    (set_attr "mode" "XF")])
1316
1317 (define_insn_and_split "*cmpfp_xf_cc"
1318   [(set (reg:CCFP FLAGS_REG)
1319         (compare:CCFP
1320           (match_operand:XF 1 "register_operand" "f")
1321           (match_operand:XF 2 "register_operand" "f")))
1322    (clobber (match_operand:HI 0 "register_operand" "=a"))]
1323   "TARGET_80387
1324    && TARGET_SAHF && !TARGET_CMOVE"
1325   "#"
1326   "&& reload_completed"
1327   [(set (match_dup 0)
1328         (unspec:HI
1329           [(compare:CCFP (match_dup 1)(match_dup 2))]
1330         UNSPEC_FNSTSW))
1331    (set (reg:CC FLAGS_REG)
1332         (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1333   ""
1334   [(set_attr "type" "multi")
1335    (set_attr "unit" "i387")
1336    (set_attr "mode" "XF")])
1337
1338 (define_insn "*cmpfp_<mode>"
1339   [(set (match_operand:HI 0 "register_operand" "=a")
1340         (unspec:HI
1341           [(compare:CCFP
1342              (match_operand:MODEF 1 "register_operand" "f")
1343              (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1344           UNSPEC_FNSTSW))]
1345   "TARGET_80387"
1346   "* return output_fp_compare (insn, operands, false, false);"
1347   [(set_attr "type" "multi")
1348    (set_attr "unit" "i387")
1349    (set_attr "mode" "<MODE>")])
1350
1351 (define_insn_and_split "*cmpfp_<mode>_cc"
1352   [(set (reg:CCFP FLAGS_REG)
1353         (compare:CCFP
1354           (match_operand:MODEF 1 "register_operand" "f")
1355           (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1356    (clobber (match_operand:HI 0 "register_operand" "=a"))]
1357   "TARGET_80387
1358    && TARGET_SAHF && !TARGET_CMOVE"
1359   "#"
1360   "&& reload_completed"
1361   [(set (match_dup 0)
1362         (unspec:HI
1363           [(compare:CCFP (match_dup 1)(match_dup 2))]
1364         UNSPEC_FNSTSW))
1365    (set (reg:CC FLAGS_REG)
1366         (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1367   ""
1368   [(set_attr "type" "multi")
1369    (set_attr "unit" "i387")
1370    (set_attr "mode" "<MODE>")])
1371
1372 (define_insn "*cmpfp_u"
1373   [(set (match_operand:HI 0 "register_operand" "=a")
1374         (unspec:HI
1375           [(compare:CCFPU
1376              (match_operand 1 "register_operand" "f")
1377              (match_operand 2 "register_operand" "f"))]
1378           UNSPEC_FNSTSW))]
1379   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1380    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1381   "* return output_fp_compare (insn, operands, false, true);"
1382   [(set_attr "type" "multi")
1383    (set_attr "unit" "i387")
1384    (set (attr "mode")
1385      (cond [(match_operand:SF 1 "" "")
1386               (const_string "SF")
1387             (match_operand:DF 1 "" "")
1388               (const_string "DF")
1389            ]
1390            (const_string "XF")))])
1391
1392 (define_insn_and_split "*cmpfp_u_cc"
1393   [(set (reg:CCFPU FLAGS_REG)
1394         (compare:CCFPU
1395           (match_operand 1 "register_operand" "f")
1396           (match_operand 2 "register_operand" "f")))
1397    (clobber (match_operand:HI 0 "register_operand" "=a"))]
1398   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1399    && TARGET_SAHF && !TARGET_CMOVE
1400    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1401   "#"
1402   "&& reload_completed"
1403   [(set (match_dup 0)
1404         (unspec:HI
1405           [(compare:CCFPU (match_dup 1)(match_dup 2))]
1406         UNSPEC_FNSTSW))
1407    (set (reg:CC FLAGS_REG)
1408         (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1409   ""
1410   [(set_attr "type" "multi")
1411    (set_attr "unit" "i387")
1412    (set (attr "mode")
1413      (cond [(match_operand:SF 1 "" "")
1414               (const_string "SF")
1415             (match_operand:DF 1 "" "")
1416               (const_string "DF")
1417            ]
1418            (const_string "XF")))])
1419
1420 (define_insn "*cmpfp_<mode>"
1421   [(set (match_operand:HI 0 "register_operand" "=a")
1422         (unspec:HI
1423           [(compare:CCFP
1424              (match_operand 1 "register_operand" "f")
1425              (match_operator 3 "float_operator"
1426                [(match_operand:SWI24 2 "memory_operand" "m")]))]
1427           UNSPEC_FNSTSW))]
1428   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1429    && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1430    && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1431   "* return output_fp_compare (insn, operands, false, false);"
1432   [(set_attr "type" "multi")
1433    (set_attr "unit" "i387")
1434    (set_attr "fp_int_src" "true")
1435    (set_attr "mode" "<MODE>")])
1436
1437 (define_insn_and_split "*cmpfp_<mode>_cc"
1438   [(set (reg:CCFP FLAGS_REG)
1439         (compare:CCFP
1440           (match_operand 1 "register_operand" "f")
1441           (match_operator 3 "float_operator"
1442             [(match_operand:SWI24 2 "memory_operand" "m")])))
1443    (clobber (match_operand:HI 0 "register_operand" "=a"))]
1444   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1445    && TARGET_SAHF && !TARGET_CMOVE
1446    && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1447    && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1448   "#"
1449   "&& reload_completed"
1450   [(set (match_dup 0)
1451         (unspec:HI
1452           [(compare:CCFP
1453              (match_dup 1)
1454              (match_op_dup 3 [(match_dup 2)]))]
1455         UNSPEC_FNSTSW))
1456    (set (reg:CC FLAGS_REG)
1457         (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1458   ""
1459   [(set_attr "type" "multi")
1460    (set_attr "unit" "i387")
1461    (set_attr "fp_int_src" "true")
1462    (set_attr "mode" "<MODE>")])
1463
1464 ;; FP compares, step 2
1465 ;; Move the fpsw to ax.
1466
1467 (define_insn "x86_fnstsw_1"
1468   [(set (match_operand:HI 0 "register_operand" "=a")
1469         (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1470   "TARGET_80387"
1471   "fnstsw\t%0"
1472   [(set (attr "length") (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1473    (set_attr "mode" "SI")
1474    (set_attr "unit" "i387")])
1475
1476 ;; FP compares, step 3
1477 ;; Get ax into flags, general case.
1478
1479 (define_insn "x86_sahf_1"
1480   [(set (reg:CC FLAGS_REG)
1481         (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1482                    UNSPEC_SAHF))]
1483   "TARGET_SAHF"
1484 {
1485 #ifndef HAVE_AS_IX86_SAHF
1486   if (TARGET_64BIT)
1487     return ASM_BYTE "0x9e";
1488   else
1489 #endif
1490   return "sahf";
1491 }
1492   [(set_attr "length" "1")
1493    (set_attr "athlon_decode" "vector")
1494    (set_attr "amdfam10_decode" "direct")
1495    (set_attr "bdver1_decode" "direct")
1496    (set_attr "mode" "SI")])
1497
1498 ;; Pentium Pro can do steps 1 through 3 in one go.
1499 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1500 (define_insn "*cmpfp_i_mixed"
1501   [(set (reg:CCFP FLAGS_REG)
1502         (compare:CCFP (match_operand 0 "register_operand" "f,x")
1503                       (match_operand 1 "nonimmediate_operand" "f,xm")))]
1504   "TARGET_MIX_SSE_I387
1505    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1506    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1507   "* return output_fp_compare (insn, operands, true, false);"
1508   [(set_attr "type" "fcmp,ssecomi")
1509    (set_attr "prefix" "orig,maybe_vex")
1510    (set (attr "mode")
1511      (if_then_else (match_operand:SF 1 "" "")
1512         (const_string "SF")
1513         (const_string "DF")))
1514    (set (attr "prefix_rep")
1515         (if_then_else (eq_attr "type" "ssecomi")
1516                       (const_string "0")
1517                       (const_string "*")))
1518    (set (attr "prefix_data16")
1519         (cond [(eq_attr "type" "fcmp")
1520                  (const_string "*")
1521                (eq_attr "mode" "DF")
1522                  (const_string "1")
1523               ]
1524               (const_string "0")))
1525    (set_attr "athlon_decode" "vector")
1526    (set_attr "amdfam10_decode" "direct")
1527    (set_attr "bdver1_decode" "double")])
1528
1529 (define_insn "*cmpfp_i_sse"
1530   [(set (reg:CCFP FLAGS_REG)
1531         (compare:CCFP (match_operand 0 "register_operand" "x")
1532                       (match_operand 1 "nonimmediate_operand" "xm")))]
1533   "TARGET_SSE_MATH
1534    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1535    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1536   "* return output_fp_compare (insn, operands, true, false);"
1537   [(set_attr "type" "ssecomi")
1538    (set_attr "prefix" "maybe_vex")
1539    (set (attr "mode")
1540      (if_then_else (match_operand:SF 1 "" "")
1541         (const_string "SF")
1542         (const_string "DF")))
1543    (set_attr "prefix_rep" "0")
1544    (set (attr "prefix_data16")
1545         (if_then_else (eq_attr "mode" "DF")
1546                       (const_string "1")
1547                       (const_string "0")))
1548    (set_attr "athlon_decode" "vector")
1549    (set_attr "amdfam10_decode" "direct")
1550    (set_attr "bdver1_decode" "double")])
1551
1552 (define_insn "*cmpfp_i_i387"
1553   [(set (reg:CCFP FLAGS_REG)
1554         (compare:CCFP (match_operand 0 "register_operand" "f")
1555                       (match_operand 1 "register_operand" "f")))]
1556   "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1557    && TARGET_CMOVE
1558    && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1559    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1560   "* return output_fp_compare (insn, operands, true, false);"
1561   [(set_attr "type" "fcmp")
1562    (set (attr "mode")
1563      (cond [(match_operand:SF 1 "" "")
1564               (const_string "SF")
1565             (match_operand:DF 1 "" "")
1566               (const_string "DF")
1567            ]
1568            (const_string "XF")))
1569    (set_attr "athlon_decode" "vector")
1570    (set_attr "amdfam10_decode" "direct")
1571    (set_attr "bdver1_decode" "double")])
1572
1573 (define_insn "*cmpfp_iu_mixed"
1574   [(set (reg:CCFPU FLAGS_REG)
1575         (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1576                        (match_operand 1 "nonimmediate_operand" "f,xm")))]
1577   "TARGET_MIX_SSE_I387
1578    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1579    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1580   "* return output_fp_compare (insn, operands, true, true);"
1581   [(set_attr "type" "fcmp,ssecomi")
1582    (set_attr "prefix" "orig,maybe_vex")
1583    (set (attr "mode")
1584      (if_then_else (match_operand:SF 1 "" "")
1585         (const_string "SF")
1586         (const_string "DF")))
1587    (set (attr "prefix_rep")
1588         (if_then_else (eq_attr "type" "ssecomi")
1589                       (const_string "0")
1590                       (const_string "*")))
1591    (set (attr "prefix_data16")
1592         (cond [(eq_attr "type" "fcmp")
1593                  (const_string "*")
1594                (eq_attr "mode" "DF")
1595                  (const_string "1")
1596               ]
1597               (const_string "0")))
1598    (set_attr "athlon_decode" "vector")
1599    (set_attr "amdfam10_decode" "direct")
1600    (set_attr "bdver1_decode" "double")])
1601
1602 (define_insn "*cmpfp_iu_sse"
1603   [(set (reg:CCFPU FLAGS_REG)
1604         (compare:CCFPU (match_operand 0 "register_operand" "x")
1605                        (match_operand 1 "nonimmediate_operand" "xm")))]
1606   "TARGET_SSE_MATH
1607    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1608    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1609   "* return output_fp_compare (insn, operands, true, true);"
1610   [(set_attr "type" "ssecomi")
1611    (set_attr "prefix" "maybe_vex")
1612    (set (attr "mode")
1613      (if_then_else (match_operand:SF 1 "" "")
1614         (const_string "SF")
1615         (const_string "DF")))
1616    (set_attr "prefix_rep" "0")
1617    (set (attr "prefix_data16")
1618         (if_then_else (eq_attr "mode" "DF")
1619                       (const_string "1")
1620                       (const_string "0")))
1621    (set_attr "athlon_decode" "vector")
1622    (set_attr "amdfam10_decode" "direct")
1623    (set_attr "bdver1_decode" "double")])
1624
1625 (define_insn "*cmpfp_iu_387"
1626   [(set (reg:CCFPU FLAGS_REG)
1627         (compare:CCFPU (match_operand 0 "register_operand" "f")
1628                        (match_operand 1 "register_operand" "f")))]
1629   "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1630    && TARGET_CMOVE
1631    && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1632    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1633   "* return output_fp_compare (insn, operands, true, true);"
1634   [(set_attr "type" "fcmp")
1635    (set (attr "mode")
1636      (cond [(match_operand:SF 1 "" "")
1637               (const_string "SF")
1638             (match_operand:DF 1 "" "")
1639               (const_string "DF")
1640            ]
1641            (const_string "XF")))
1642    (set_attr "athlon_decode" "vector")
1643    (set_attr "amdfam10_decode" "direct")
1644    (set_attr "bdver1_decode" "direct")])
1645 \f
1646 ;; Push/pop instructions.
1647
1648 (define_insn "*push<mode>2"
1649   [(set (match_operand:DWI 0 "push_operand" "=<")
1650         (match_operand:DWI 1 "general_no_elim_operand" "riF*o"))]
1651   ""
1652   "#"
1653   [(set_attr "type" "multi")
1654    (set_attr "mode" "<MODE>")])
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 ,!o,*y,m*y,?*y,?r ,?*Ym,*x,m ,*x,*x,?r ,?*Yi,?*x,?*Ym")
1985         (match_operand:DI 1 "general_operand"
1986           "Z ,rem,i,re,n ,C ,*y ,m  ,*Ym,r   ,C ,*x,*x,m ,*Yi,r   ,*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" "4")
2037               (const_string "multi")
2038             (eq_attr "alternative" "5")
2039               (const_string "mmx")
2040             (eq_attr "alternative" "6,7,8,9")
2041               (const_string "mmxmov")
2042             (eq_attr "alternative" "10")
2043               (const_string "sselog1")
2044             (eq_attr "alternative" "11,12,13,14,15")
2045               (const_string "ssemov")
2046             (eq_attr "alternative" "16,17")
2047               (const_string "ssecvt")
2048             (match_operand 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" "8,9")
2064        (const_string "1")
2065        (const_string "*")))
2066    (set (attr "prefix_data16")
2067      (if_then_else (eq_attr "alternative" "11")
2068        (const_string "1")
2069        (const_string "*")))
2070    (set (attr "prefix")
2071      (if_then_else (eq_attr "alternative" "10,11,12,13,14,15")
2072        (const_string "maybe_vex")
2073        (const_string "orig")))
2074    (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,TI,DI,TI,DI,DI,DI,DI,DI")])
2075
2076 ;; Reload patterns to support multi-word load/store
2077 ;; with non-offsetable address.
2078 (define_expand "reload_noff_store"
2079   [(parallel [(match_operand 0 "memory_operand" "=m")
2080               (match_operand 1 "register_operand" "r")
2081               (match_operand:DI 2 "register_operand" "=&r")])]
2082   "TARGET_64BIT"
2083 {
2084   rtx mem = operands[0];
2085   rtx addr = XEXP (mem, 0);
2086
2087   emit_move_insn (operands[2], addr);
2088   mem = replace_equiv_address_nv (mem, operands[2]);
2089
2090   emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
2091   DONE;
2092 })
2093
2094 (define_expand "reload_noff_load"
2095   [(parallel [(match_operand 0 "register_operand" "=r")
2096               (match_operand 1 "memory_operand" "m")
2097               (match_operand:DI 2 "register_operand" "=r")])]
2098   "TARGET_64BIT"
2099 {
2100   rtx mem = operands[1];
2101   rtx addr = XEXP (mem, 0);
2102
2103   emit_move_insn (operands[2], addr);
2104   mem = replace_equiv_address_nv (mem, operands[2]);
2105
2106   emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
2107   DONE;
2108 })
2109
2110 ;; Convert impossible stores of immediate to existing instructions.
2111 ;; First try to get scratch register and go through it.  In case this
2112 ;; fails, move by 32bit parts.
2113 (define_peephole2
2114   [(match_scratch:DI 2 "r")
2115    (set (match_operand:DI 0 "memory_operand" "")
2116         (match_operand:DI 1 "immediate_operand" ""))]
2117   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2118    && !x86_64_immediate_operand (operands[1], DImode)"
2119   [(set (match_dup 2) (match_dup 1))
2120    (set (match_dup 0) (match_dup 2))])
2121
2122 ;; We need to define this as both peepholer and splitter for case
2123 ;; peephole2 pass is not run.
2124 ;; "&& 1" is needed to keep it from matching the previous pattern.
2125 (define_peephole2
2126   [(set (match_operand:DI 0 "memory_operand" "")
2127         (match_operand:DI 1 "immediate_operand" ""))]
2128   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2129    && !x86_64_immediate_operand (operands[1], DImode) && 1"
2130   [(set (match_dup 2) (match_dup 3))
2131    (set (match_dup 4) (match_dup 5))]
2132   "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2133
2134 (define_split
2135   [(set (match_operand:DI 0 "memory_operand" "")
2136         (match_operand:DI 1 "immediate_operand" ""))]
2137   "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2138                     ? epilogue_completed : reload_completed)
2139    && !symbolic_operand (operands[1], DImode)
2140    && !x86_64_immediate_operand (operands[1], DImode)"
2141   [(set (match_dup 2) (match_dup 3))
2142    (set (match_dup 4) (match_dup 5))]
2143   "split_double_mode (DImode, &operands[0], 2, &operands[2], &operands[4]);")
2144
2145 (define_insn "*movdi_internal"
2146   [(set (match_operand:DI 0 "nonimmediate_operand"
2147           "=r  ,o  ,*y,m*y,*y,*Y2,m  ,*Y2,*Y2,*x,m ,*x,*x,?*Y2,?*Ym")
2148         (match_operand:DI 1 "general_operand"
2149           "riFo,riF,C ,*y ,m ,C  ,*Y2,*Y2,m  ,C ,*x,*x,m ,*Ym ,*Y2"))]
2150   "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2151 {
2152   switch (get_attr_type (insn))
2153     {
2154     case TYPE_SSECVT:
2155       if (SSE_REG_P (operands[0]))
2156         return "movq2dq\t{%1, %0|%0, %1}";
2157       else
2158         return "movdq2q\t{%1, %0|%0, %1}";
2159
2160     case TYPE_SSEMOV:
2161       switch (get_attr_mode (insn))
2162         {
2163         case MODE_TI:
2164           return "%vmovdqa\t{%1, %0|%0, %1}";
2165         case MODE_DI:
2166            return "%vmovq\t{%1, %0|%0, %1}";
2167         case MODE_V4SF:
2168           return "movaps\t{%1, %0|%0, %1}";
2169         case MODE_V2SF:
2170           return "movlps\t{%1, %0|%0, %1}";
2171         default:
2172           gcc_unreachable ();
2173         }
2174
2175     case TYPE_MMXMOV:
2176       return "movq\t{%1, %0|%0, %1}";
2177
2178     case TYPE_SSELOG1:
2179       return standard_sse_constant_opcode (insn, operands[1]);
2180
2181     case TYPE_MMX:
2182       return "pxor\t%0, %0";
2183
2184     case TYPE_MULTI:
2185       return "#";
2186
2187     default:
2188       gcc_unreachable ();
2189     }
2190 }
2191   [(set (attr "isa")
2192      (if_then_else (eq_attr "alternative" "9,10,11,12")
2193        (const_string "noavx")
2194        (const_string "*")))
2195    (set (attr "type")
2196      (cond [(eq_attr "alternative" "0,1")
2197               (const_string "multi")
2198             (eq_attr "alternative" "2")
2199               (const_string "mmx")
2200             (eq_attr "alternative" "3,4")
2201               (const_string "mmxmov")
2202             (eq_attr "alternative" "5,9")
2203               (const_string "sselog1")
2204             (eq_attr "alternative" "13,14")
2205               (const_string "ssecvt")
2206            ]
2207            (const_string "ssemov")))
2208    (set (attr "prefix")
2209      (if_then_else (eq_attr "alternative" "5,6,7,8")
2210        (const_string "maybe_vex")
2211        (const_string "orig")))
2212    (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF,DI,DI")])
2213
2214 (define_split
2215   [(set (match_operand:DI 0 "nonimmediate_operand" "")
2216         (match_operand:DI 1 "general_operand" ""))]
2217   "!TARGET_64BIT && reload_completed
2218    && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))
2219    && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
2220   [(const_int 0)]
2221   "ix86_split_long_move (operands); DONE;")
2222
2223 (define_insn "*movsi_internal"
2224   [(set (match_operand:SI 0 "nonimmediate_operand"
2225                         "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
2226         (match_operand:SI 1 "general_operand"
2227                         "g ,re,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r   ,m "))]
2228   "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2229 {
2230   switch (get_attr_type (insn))
2231     {
2232     case TYPE_SSELOG1:
2233       return standard_sse_constant_opcode (insn, operands[1]);
2234
2235     case TYPE_SSEMOV:
2236       switch (get_attr_mode (insn))
2237         {
2238         case MODE_TI:
2239           return "%vmovdqa\t{%1, %0|%0, %1}";
2240         case MODE_V4SF:
2241           return "%vmovaps\t{%1, %0|%0, %1}";
2242         case MODE_SI:
2243           return "%vmovd\t{%1, %0|%0, %1}";
2244         case MODE_SF:
2245           return "%vmovss\t{%1, %0|%0, %1}";
2246         default:
2247           gcc_unreachable ();
2248         }
2249
2250     case TYPE_MMX:
2251       return "pxor\t%0, %0";
2252
2253     case TYPE_MMXMOV:
2254       if (get_attr_mode (insn) == MODE_DI)
2255         return "movq\t{%1, %0|%0, %1}";
2256       return "movd\t{%1, %0|%0, %1}";
2257
2258     case TYPE_LEA:
2259       return "lea{l}\t{%a1, %0|%0, %a1}";
2260
2261     default:
2262       gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2263       return "mov{l}\t{%1, %0|%0, %1}";
2264     }
2265 }
2266   [(set (attr "type")
2267      (cond [(eq_attr "alternative" "2")
2268               (const_string "mmx")
2269             (eq_attr "alternative" "3,4,5")
2270               (const_string "mmxmov")
2271             (eq_attr "alternative" "6")
2272               (const_string "sselog1")
2273             (eq_attr "alternative" "7,8,9,10,11")
2274               (const_string "ssemov")
2275             (match_operand 1 "pic_32bit_operand" "")
2276               (const_string "lea")
2277            ]
2278            (const_string "imov")))
2279    (set (attr "prefix")
2280      (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
2281        (const_string "orig")
2282        (const_string "maybe_vex")))
2283    (set (attr "prefix_data16")
2284      (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
2285        (const_string "1")
2286        (const_string "*")))
2287    (set (attr "mode")
2288      (cond [(eq_attr "alternative" "2,3")
2289               (const_string "DI")
2290             (eq_attr "alternative" "6,7")
2291               (if_then_else
2292                 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2293                 (const_string "V4SF")
2294                 (const_string "TI"))
2295             (and (eq_attr "alternative" "8,9,10,11")
2296                  (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
2297               (const_string "SF")
2298            ]
2299            (const_string "SI")))])
2300
2301 (define_insn "*movhi_internal"
2302   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
2303         (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
2304   "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2305 {
2306   switch (get_attr_type (insn))
2307     {
2308     case TYPE_IMOVX:
2309       /* movzwl is faster than movw on p2 due to partial word stalls,
2310          though not as fast as an aligned movl.  */
2311       return "movz{wl|x}\t{%1, %k0|%k0, %1}";
2312     default:
2313       if (get_attr_mode (insn) == MODE_SI)
2314         return "mov{l}\t{%k1, %k0|%k0, %k1}";
2315       else
2316         return "mov{w}\t{%1, %0|%0, %1}";
2317     }
2318 }
2319   [(set (attr "type")
2320      (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
2321                 (const_int 0))
2322               (const_string "imov")
2323             (and (eq_attr "alternative" "0")
2324                  (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2325                           (const_int 0))
2326                       (eq (symbol_ref "TARGET_HIMODE_MATH")
2327                           (const_int 0))))
2328               (const_string "imov")
2329             (and (eq_attr "alternative" "1,2")
2330                  (match_operand:HI 1 "aligned_operand" ""))
2331               (const_string "imov")
2332             (and (ne (symbol_ref "TARGET_MOVX")
2333                      (const_int 0))
2334                  (eq_attr "alternative" "0,2"))
2335               (const_string "imovx")
2336            ]
2337            (const_string "imov")))
2338     (set (attr "mode")
2339       (cond [(eq_attr "type" "imovx")
2340                (const_string "SI")
2341              (and (eq_attr "alternative" "1,2")
2342                   (match_operand:HI 1 "aligned_operand" ""))
2343                (const_string "SI")
2344              (and (eq_attr "alternative" "0")
2345                   (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2346                            (const_int 0))
2347                        (eq (symbol_ref "TARGET_HIMODE_MATH")
2348                            (const_int 0))))
2349                (const_string "SI")
2350             ]
2351             (const_string "HI")))])
2352
2353 ;; Situation is quite tricky about when to choose full sized (SImode) move
2354 ;; over QImode moves.  For Q_REG -> Q_REG move we use full size only for
2355 ;; partial register dependency machines (such as AMD Athlon), where QImode
2356 ;; moves issue extra dependency and for partial register stalls machines
2357 ;; that don't use QImode patterns (and QImode move cause stall on the next
2358 ;; instruction).
2359 ;;
2360 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2361 ;; register stall machines with, where we use QImode instructions, since
2362 ;; partial register stall can be caused there.  Then we use movzx.
2363 (define_insn "*movqi_internal"
2364   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2365         (match_operand:QI 1 "general_operand"      " q,qn,qm,q,rn,qm,qn"))]
2366   "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2367 {
2368   switch (get_attr_type (insn))
2369     {
2370     case TYPE_IMOVX:
2371       gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2372       return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2373     default:
2374       if (get_attr_mode (insn) == MODE_SI)
2375         return "mov{l}\t{%k1, %k0|%k0, %k1}";
2376       else
2377         return "mov{b}\t{%1, %0|%0, %1}";
2378     }
2379 }
2380   [(set (attr "type")
2381      (cond [(and (eq_attr "alternative" "5")
2382                  (not (match_operand:QI 1 "aligned_operand" "")))
2383               (const_string "imovx")
2384             (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2385                 (const_int 0))
2386               (const_string "imov")
2387             (and (eq_attr "alternative" "3")
2388                  (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2389                           (const_int 0))
2390                       (eq (symbol_ref "TARGET_QIMODE_MATH")
2391                           (const_int 0))))
2392               (const_string "imov")
2393             (eq_attr "alternative" "3,5")
2394               (const_string "imovx")
2395             (and (ne (symbol_ref "TARGET_MOVX")
2396                      (const_int 0))
2397                  (eq_attr "alternative" "2"))
2398               (const_string "imovx")
2399            ]
2400            (const_string "imov")))
2401    (set (attr "mode")
2402       (cond [(eq_attr "alternative" "3,4,5")
2403                (const_string "SI")
2404              (eq_attr "alternative" "6")
2405                (const_string "QI")
2406              (eq_attr "type" "imovx")
2407                (const_string "SI")
2408              (and (eq_attr "type" "imov")
2409                   (and (eq_attr "alternative" "0,1")
2410                        (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2411                                 (const_int 0))
2412                             (and (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2413                                      (const_int 0))
2414                                  (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2415                                      (const_int 0))))))
2416                (const_string "SI")
2417              ;; Avoid partial register stalls when not using QImode arithmetic
2418              (and (eq_attr "type" "imov")
2419                   (and (eq_attr "alternative" "0,1")
2420                        (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2421                                 (const_int 0))
2422                             (eq (symbol_ref "TARGET_QIMODE_MATH")
2423                                 (const_int 0)))))
2424                (const_string "SI")
2425            ]
2426            (const_string "QI")))])
2427
2428 ;; Stores and loads of ax to arbitrary constant address.
2429 ;; We fake an second form of instruction to force reload to load address
2430 ;; into register when rax is not available
2431 (define_insn "*movabs<mode>_1"
2432   [(set (mem:SWI1248x (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2433         (match_operand:SWI1248x 1 "nonmemory_operand" "a,er"))]
2434   "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2435   "@
2436    movabs{<imodesuffix>}\t{%1, %P0|%P0, %1}
2437    mov{<imodesuffix>}\t{%1, %a0|%a0, %1}"
2438   [(set_attr "type" "imov")
2439    (set_attr "modrm" "0,*")
2440    (set_attr "length_address" "8,0")
2441    (set_attr "length_immediate" "0,*")
2442    (set_attr "memory" "store")
2443    (set_attr "mode" "<MODE>")])
2444
2445 (define_insn "*movabs<mode>_2"
2446   [(set (match_operand:SWI1248x 0 "register_operand" "=a,r")
2447         (mem:SWI1248x (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2448   "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2449   "@
2450    movabs{<imodesuffix>}\t{%P1, %0|%0, %P1}
2451    mov{<imodesuffix>}\t{%a1, %0|%0, %a1}"
2452   [(set_attr "type" "imov")
2453    (set_attr "modrm" "0,*")
2454    (set_attr "length_address" "8,0")
2455    (set_attr "length_immediate" "0")
2456    (set_attr "memory" "load")
2457    (set_attr "mode" "<MODE>")])
2458
2459 (define_insn "*swap<mode>"
2460   [(set (match_operand:SWI48 0 "register_operand" "+r")
2461         (match_operand:SWI48 1 "register_operand" "+r"))
2462    (set (match_dup 1)
2463         (match_dup 0))]
2464   ""
2465   "xchg{<imodesuffix>}\t%1, %0"
2466   [(set_attr "type" "imov")
2467    (set_attr "mode" "<MODE>")
2468    (set_attr "pent_pair" "np")
2469    (set_attr "athlon_decode" "vector")
2470    (set_attr "amdfam10_decode" "double")
2471    (set_attr "bdver1_decode" "double")])
2472
2473 (define_insn "*swap<mode>_1"
2474   [(set (match_operand:SWI12 0 "register_operand" "+r")
2475         (match_operand:SWI12 1 "register_operand" "+r"))
2476    (set (match_dup 1)
2477         (match_dup 0))]
2478   "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2479   "xchg{l}\t%k1, %k0"
2480   [(set_attr "type" "imov")
2481    (set_attr "mode" "SI")
2482    (set_attr "pent_pair" "np")
2483    (set_attr "athlon_decode" "vector")
2484    (set_attr "amdfam10_decode" "double")
2485    (set_attr "bdver1_decode" "double")])
2486
2487 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL
2488 ;; is disabled for AMDFAM10
2489 (define_insn "*swap<mode>_2"
2490   [(set (match_operand:SWI12 0 "register_operand" "+<r>")
2491         (match_operand:SWI12 1 "register_operand" "+<r>"))
2492    (set (match_dup 1)
2493         (match_dup 0))]
2494   "TARGET_PARTIAL_REG_STALL"
2495   "xchg{<imodesuffix>}\t%1, %0"
2496   [(set_attr "type" "imov")
2497    (set_attr "mode" "<MODE>")
2498    (set_attr "pent_pair" "np")
2499    (set_attr "athlon_decode" "vector")])
2500
2501 (define_expand "movstrict<mode>"
2502   [(set (strict_low_part (match_operand:SWI12 0 "nonimmediate_operand" ""))
2503         (match_operand:SWI12 1 "general_operand" ""))]
2504   ""
2505 {
2506   if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2507     FAIL;
2508   if (GET_CODE (operands[0]) == SUBREG
2509       && GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[0]))) != MODE_INT)
2510     FAIL;
2511   /* Don't generate memory->memory moves, go through a register */
2512   if (MEM_P (operands[0]) && MEM_P (operands[1]))
2513     operands[1] = force_reg (<MODE>mode, operands[1]);
2514 })
2515
2516 (define_insn "*movstrict<mode>_1"
2517   [(set (strict_low_part
2518           (match_operand:SWI12 0 "nonimmediate_operand" "+<r>m,<r>"))
2519         (match_operand:SWI12 1 "general_operand" "<r>n,m"))]
2520   "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2521    && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2522   "mov{<imodesuffix>}\t{%1, %0|%0, %1}"
2523   [(set_attr "type" "imov")
2524    (set_attr "mode" "<MODE>")])
2525
2526 (define_insn "*movstrict<mode>_xor"
2527   [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
2528         (match_operand:SWI12 1 "const0_operand" ""))
2529    (clobber (reg:CC FLAGS_REG))]
2530   "reload_completed"
2531   "xor{<imodesuffix>}\t%0, %0"
2532   [(set_attr "type" "alu1")
2533    (set_attr "mode" "<MODE>")
2534    (set_attr "length_immediate" "0")])
2535
2536 (define_insn "*mov<mode>_extv_1"
2537   [(set (match_operand:SWI24 0 "register_operand" "=R")
2538         (sign_extract:SWI24 (match_operand 1 "ext_register_operand" "Q")
2539                             (const_int 8)
2540                             (const_int 8)))]
2541   ""
2542   "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2543   [(set_attr "type" "imovx")
2544    (set_attr "mode" "SI")])
2545
2546 (define_insn "*movqi_extv_1_rex64"
2547   [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2548         (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2549                          (const_int 8)
2550                          (const_int 8)))]
2551   "TARGET_64BIT"
2552 {
2553   switch (get_attr_type (insn))
2554     {
2555     case TYPE_IMOVX:
2556       return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2557     default:
2558       return "mov{b}\t{%h1, %0|%0, %h1}";
2559     }
2560 }
2561   [(set (attr "type")
2562      (if_then_else (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2563                         (ne (symbol_ref "TARGET_MOVX")
2564                             (const_int 0)))
2565         (const_string "imovx")
2566         (const_string "imov")))
2567    (set (attr "mode")
2568      (if_then_else (eq_attr "type" "imovx")
2569         (const_string "SI")
2570         (const_string "QI")))])
2571
2572 (define_insn "*movqi_extv_1"
2573   [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2574         (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2575                          (const_int 8)
2576                          (const_int 8)))]
2577   "!TARGET_64BIT"
2578 {
2579   switch (get_attr_type (insn))
2580     {
2581     case TYPE_IMOVX:
2582       return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2583     default:
2584       return "mov{b}\t{%h1, %0|%0, %h1}";
2585     }
2586 }
2587   [(set (attr "type")
2588      (if_then_else (and (match_operand:QI 0 "register_operand" "")
2589                         (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2590                              (ne (symbol_ref "TARGET_MOVX")
2591                                  (const_int 0))))
2592         (const_string "imovx")
2593         (const_string "imov")))
2594    (set (attr "mode")
2595      (if_then_else (eq_attr "type" "imovx")
2596         (const_string "SI")
2597         (const_string "QI")))])
2598
2599 (define_insn "*mov<mode>_extzv_1"
2600   [(set (match_operand:SWI48 0 "register_operand" "=R")
2601         (zero_extract:SWI48 (match_operand 1 "ext_register_operand" "Q")
2602                             (const_int 8)
2603                             (const_int 8)))]
2604   ""
2605   "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2606   [(set_attr "type" "imovx")
2607    (set_attr "mode" "SI")])
2608
2609 (define_insn "*movqi_extzv_2_rex64"
2610   [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2611         (subreg:QI
2612           (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2613                            (const_int 8)
2614                            (const_int 8)) 0))]
2615   "TARGET_64BIT"
2616 {
2617   switch (get_attr_type (insn))
2618     {
2619     case TYPE_IMOVX:
2620       return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2621     default:
2622       return "mov{b}\t{%h1, %0|%0, %h1}";
2623     }
2624 }
2625   [(set (attr "type")
2626      (if_then_else (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2627                         (ne (symbol_ref "TARGET_MOVX")
2628                             (const_int 0)))
2629         (const_string "imovx")
2630         (const_string "imov")))
2631    (set (attr "mode")
2632      (if_then_else (eq_attr "type" "imovx")
2633         (const_string "SI")
2634         (const_string "QI")))])
2635
2636 (define_insn "*movqi_extzv_2"
2637   [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2638         (subreg:QI
2639           (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2640                            (const_int 8)
2641                            (const_int 8)) 0))]
2642   "!TARGET_64BIT"
2643 {
2644   switch (get_attr_type (insn))
2645     {
2646     case TYPE_IMOVX:
2647       return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2648     default:
2649       return "mov{b}\t{%h1, %0|%0, %h1}";
2650     }
2651 }
2652   [(set (attr "type")
2653      (if_then_else (and (match_operand:QI 0 "register_operand" "")
2654                         (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2655                              (ne (symbol_ref "TARGET_MOVX")
2656                                  (const_int 0))))
2657         (const_string "imovx")
2658         (const_string "imov")))
2659    (set (attr "mode")
2660      (if_then_else (eq_attr "type" "imovx")
2661         (const_string "SI")
2662         (const_string "QI")))])
2663
2664 (define_expand "mov<mode>_insv_1"
2665   [(set (zero_extract:SWI48 (match_operand 0 "ext_register_operand" "")
2666                             (const_int 8)
2667                             (const_int 8))
2668         (match_operand:SWI48 1 "nonmemory_operand" ""))])
2669
2670 (define_insn "*mov<mode>_insv_1_rex64"
2671   [(set (zero_extract:SWI48x (match_operand 0 "ext_register_operand" "+Q")
2672                              (const_int 8)
2673                              (const_int 8))
2674         (match_operand:SWI48x 1 "nonmemory_operand" "Qn"))]
2675   "TARGET_64BIT"
2676   "mov{b}\t{%b1, %h0|%h0, %b1}"
2677   [(set_attr "type" "imov")
2678    (set_attr "mode" "QI")])
2679
2680 (define_insn "*movsi_insv_1"
2681   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2682                          (const_int 8)
2683                          (const_int 8))
2684         (match_operand:SI 1 "general_operand" "Qmn"))]
2685   "!TARGET_64BIT"
2686   "mov{b}\t{%b1, %h0|%h0, %b1}"
2687   [(set_attr "type" "imov")
2688    (set_attr "mode" "QI")])
2689
2690 (define_insn "*movqi_insv_2"
2691   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2692                          (const_int 8)
2693                          (const_int 8))
2694         (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2695                      (const_int 8)))]
2696   ""
2697   "mov{b}\t{%h1, %h0|%h0, %h1}"
2698   [(set_attr "type" "imov")
2699    (set_attr "mode" "QI")])
2700 \f
2701 ;; Floating point push instructions.
2702
2703 (define_insn "*pushtf"
2704   [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2705         (match_operand:TF 1 "general_no_elim_operand" "x,Fo,*r"))]
2706   "TARGET_SSE2"
2707 {
2708   /* This insn should be already split before reg-stack.  */
2709   gcc_unreachable ();
2710 }
2711   [(set_attr "type" "multi")
2712    (set_attr "unit" "sse,*,*")
2713    (set_attr "mode" "TF,SI,SI")])
2714
2715 ;; %%% Kill this when call knows how to work this out.
2716 (define_split
2717   [(set (match_operand:TF 0 "push_operand" "")
2718         (match_operand:TF 1 "sse_reg_operand" ""))]
2719   "TARGET_SSE2 && reload_completed"
2720   [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
2721    (set (mem:TF (reg:P SP_REG)) (match_dup 1))])
2722
2723 (define_insn "*pushxf"
2724   [(set (match_operand:XF 0 "push_operand" "=<,<")
2725         (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
2726   "optimize_function_for_speed_p (cfun)"
2727 {
2728   /* This insn should be already split before reg-stack.  */
2729   gcc_unreachable ();
2730 }
2731   [(set_attr "type" "multi")
2732    (set_attr "unit" "i387,*")
2733    (set_attr "mode" "XF,SI")])
2734
2735 ;; Size of pushxf is 3 (for sub) + 2 (for fstp) + memory operand size.
2736 ;; Size of pushxf using integer instructions is 3+3*memory operand size
2737 ;; Pushing using integer instructions is longer except for constants
2738 ;; and direct memory references (assuming that any given constant is pushed
2739 ;; only once, but this ought to be handled elsewhere).
2740
2741 (define_insn "*pushxf_nointeger"
2742   [(set (match_operand:XF 0 "push_operand" "=<,<")
2743         (match_operand:XF 1 "general_no_elim_operand" "f,*rFo"))]
2744   "optimize_function_for_size_p (cfun)"
2745 {
2746   /* This insn should be already split before reg-stack.  */
2747   gcc_unreachable ();
2748 }
2749   [(set_attr "type" "multi")
2750    (set_attr "unit" "i387,*")
2751    (set_attr "mode" "XF,SI")])
2752
2753 ;; %%% Kill this when call knows how to work this out.
2754 (define_split
2755   [(set (match_operand:XF 0 "push_operand" "")
2756         (match_operand:XF 1 "fp_register_operand" ""))]
2757   "reload_completed"
2758   [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2759    (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
2760   "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
2761
2762 (define_insn "*pushdf_rex64"
2763   [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2764         (match_operand:DF 1 "general_no_elim_operand" "f,Yd*rFm,Y2"))]
2765   "TARGET_64BIT"
2766 {
2767   /* This insn should be already split before reg-stack.  */
2768   gcc_unreachable ();
2769 }
2770   [(set_attr "type" "multi")
2771    (set_attr "unit" "i387,*,*")
2772    (set_attr "mode" "DF,DI,DF")])
2773
2774 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2775 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2776 ;; On the average, pushdf using integers can be still shorter.
2777
2778 (define_insn "*pushdf"
2779   [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2780         (match_operand:DF 1 "general_no_elim_operand" "f,Yd*rFo,Y2"))]
2781   "!TARGET_64BIT"
2782 {
2783   /* This insn should be already split before reg-stack.  */
2784   gcc_unreachable ();
2785 }
2786   [(set_attr "type" "multi")
2787    (set_attr "unit" "i387,*,*")
2788    (set_attr "mode" "DF,DI,DF")])
2789
2790 ;; %%% Kill this when call knows how to work this out.
2791 (define_split
2792   [(set (match_operand:DF 0 "push_operand" "")
2793         (match_operand:DF 1 "any_fp_register_operand" ""))]
2794   "reload_completed"
2795   [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
2796    (set (mem:DF (reg:P SP_REG)) (match_dup 1))])
2797
2798 (define_insn "*pushsf_rex64"
2799   [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2800         (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2801   "TARGET_64BIT"
2802 {
2803   /* Anything else should be already split before reg-stack.  */
2804   gcc_assert (which_alternative == 1);
2805   return "push{q}\t%q1";
2806 }
2807   [(set_attr "type" "multi,push,multi")
2808    (set_attr "unit" "i387,*,*")
2809    (set_attr "mode" "SF,DI,SF")])
2810
2811 (define_insn "*pushsf"
2812   [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2813         (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2814   "!TARGET_64BIT"
2815 {
2816   /* Anything else should be already split before reg-stack.  */
2817   gcc_assert (which_alternative == 1);
2818   return "push{l}\t%1";
2819 }
2820   [(set_attr "type" "multi,push,multi")
2821    (set_attr "unit" "i387,*,*")
2822    (set_attr "mode" "SF,SI,SF")])
2823
2824 ;; %%% Kill this when call knows how to work this out.
2825 (define_split
2826   [(set (match_operand:SF 0 "push_operand" "")
2827         (match_operand:SF 1 "any_fp_register_operand" ""))]
2828   "reload_completed"
2829   [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2830    (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
2831   "operands[2] = GEN_INT (-GET_MODE_SIZE (<P:MODE>mode));")
2832
2833 (define_split
2834   [(set (match_operand:SF 0 "push_operand" "")
2835         (match_operand:SF 1 "memory_operand" ""))]
2836   "reload_completed
2837    && (operands[2] = find_constant_src (insn))"
2838   [(set (match_dup 0) (match_dup 2))])
2839
2840 (define_split
2841   [(set (match_operand 0 "push_operand" "")
2842         (match_operand 1 "general_operand" ""))]
2843   "reload_completed
2844    && (GET_MODE (operands[0]) == TFmode
2845        || GET_MODE (operands[0]) == XFmode
2846        || GET_MODE (operands[0]) == DFmode)
2847    && !ANY_FP_REG_P (operands[1])"
2848   [(const_int 0)]
2849   "ix86_split_long_move (operands); DONE;")
2850 \f
2851 ;; Floating point move instructions.
2852
2853 (define_expand "movtf"
2854   [(set (match_operand:TF 0 "nonimmediate_operand" "")
2855         (match_operand:TF 1 "nonimmediate_operand" ""))]
2856   "TARGET_SSE2"
2857 {
2858   ix86_expand_move (TFmode, operands);
2859   DONE;
2860 })
2861
2862 (define_expand "mov<mode>"
2863   [(set (match_operand:X87MODEF 0 "nonimmediate_operand" "")
2864         (match_operand:X87MODEF 1 "general_operand" ""))]
2865   ""
2866   "ix86_expand_move (<MODE>mode, operands); DONE;")
2867
2868 (define_insn "*movtf_internal"
2869   [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?*r ,!o")
2870         (match_operand:TF 1 "general_operand"      "xm,x,C,*roF,F*r"))]
2871   "TARGET_SSE2
2872    && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2873    && (!can_create_pseudo_p ()
2874        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2875        || GET_CODE (operands[1]) != CONST_DOUBLE
2876        || (optimize_function_for_size_p (cfun)
2877            && standard_sse_constant_p (operands[1])
2878            && !memory_operand (operands[0], TFmode))
2879        || (!TARGET_MEMORY_MISMATCH_STALL
2880            && memory_operand (operands[0], TFmode)))"
2881 {
2882   switch (which_alternative)
2883     {
2884     case 0:
2885     case 1:
2886       /* Handle misaligned load/store since we
2887          don't have movmisaligntf pattern. */
2888       if (misaligned_operand (operands[0], TFmode)
2889           || misaligned_operand (operands[1], TFmode))
2890         {
2891           if (get_attr_mode (insn) == MODE_V4SF)
2892             return "%vmovups\t{%1, %0|%0, %1}";
2893           else
2894             return "%vmovdqu\t{%1, %0|%0, %1}";
2895         }
2896       else
2897         {
2898           if (get_attr_mode (insn) == MODE_V4SF)
2899             return "%vmovaps\t{%1, %0|%0, %1}";
2900           else
2901             return "%vmovdqa\t{%1, %0|%0, %1}";
2902         }
2903
2904     case 2:
2905       return standard_sse_constant_opcode (insn, operands[1]);
2906
2907     case 3:
2908     case 4:
2909         return "#";
2910
2911     default:
2912       gcc_unreachable ();
2913     }
2914 }
2915   [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
2916    (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,*,*")
2917    (set (attr "mode")
2918         (cond [(eq_attr "alternative" "0,2")
2919                  (if_then_else
2920                    (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2921                        (const_int 0))
2922                    (const_string "V4SF")
2923                    (const_string "TI"))
2924                (eq_attr "alternative" "1")
2925                  (if_then_else
2926                    (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2927                             (const_int 0))
2928                         (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2929                             (const_int 0)))
2930                    (const_string "V4SF")
2931                    (const_string "TI"))]
2932                (const_string "DI")))])
2933
2934 ;; Possible store forwarding (partial memory) stall in alternative 4.
2935 (define_insn "*movxf_internal"
2936   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,?Yx*r ,!o")
2937         (match_operand:XF 1 "general_operand"      "fm,f,G,Yx*roF,FYx*r"))]
2938   "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2939    && (!can_create_pseudo_p ()
2940        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2941        || GET_CODE (operands[1]) != CONST_DOUBLE
2942        || (optimize_function_for_size_p (cfun)
2943            && standard_80387_constant_p (operands[1]) > 0
2944            && !memory_operand (operands[0], XFmode))
2945        || (!TARGET_MEMORY_MISMATCH_STALL
2946            && memory_operand (operands[0], XFmode)))"
2947 {
2948   switch (which_alternative)
2949     {
2950     case 0:
2951     case 1:
2952       return output_387_reg_move (insn, operands);
2953
2954     case 2:
2955       return standard_80387_constant_opcode (operands[1]);
2956
2957     case 3:
2958     case 4:
2959       return "#";
2960
2961     default:
2962       gcc_unreachable ();
2963     }
2964 }
2965   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2966    (set_attr "mode" "XF,XF,XF,SI,SI")])
2967
2968 (define_insn "*movdf_internal_rex64"
2969   [(set (match_operand:DF 0 "nonimmediate_operand"
2970                 "=f,m,f,?r,?m,?r,!o,Y2*x,Y2*x,Y2*x,m   ,Yi,r ")
2971         (match_operand:DF 1 "general_operand"
2972                 "fm,f,G,rm,r ,F ,F ,C   ,Y2*x,m   ,Y2*x,r ,Yi"))]
2973   "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2974    && (!can_create_pseudo_p ()
2975        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2976        || GET_CODE (operands[1]) != CONST_DOUBLE
2977        || (optimize_function_for_size_p (cfun)
2978            && ((!(TARGET_SSE2 && TARGET_SSE_MATH)
2979                 && standard_80387_constant_p (operands[1]) > 0)
2980                || (TARGET_SSE2 && TARGET_SSE_MATH
2981                    && standard_sse_constant_p (operands[1]))))
2982        || memory_operand (operands[0], DFmode))"
2983 {
2984   switch (which_alternative)
2985     {
2986     case 0:
2987     case 1:
2988       return output_387_reg_move (insn, operands);
2989
2990     case 2:
2991       return standard_80387_constant_opcode (operands[1]);
2992
2993     case 3:
2994     case 4:
2995       return "mov{q}\t{%1, %0|%0, %1}";
2996
2997     case 5:
2998       return "movabs{q}\t{%1, %0|%0, %1}";
2999
3000     case 6:
3001       return "#";
3002
3003     case 7:
3004       return standard_sse_constant_opcode (insn, operands[1]);
3005
3006     case 8:
3007     case 9:
3008     case 10:
3009       switch (get_attr_mode (insn))
3010         {
3011         case MODE_V2DF:
3012           if (!TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3013             return "%vmovapd\t{%1, %0|%0, %1}";
3014         case MODE_V4SF:
3015           return "%vmovaps\t{%1, %0|%0, %1}";
3016
3017         case MODE_DI:
3018           return "%vmovq\t{%1, %0|%0, %1}";
3019         case MODE_DF:
3020           if (TARGET_AVX && REG_P (operands[0]) && REG_P (operands[1]))
3021             return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3022           return "%vmovsd\t{%1, %0|%0, %1}";
3023         case MODE_V1DF:
3024           return "%vmovlpd\t{%1, %d0|%d0, %1}";
3025         case MODE_V2SF:
3026           return "%vmovlps\t{%1, %d0|%d0, %1}";
3027         default:
3028           gcc_unreachable ();
3029         }
3030
3031     case 11:
3032     case 12:
3033       /* Handle broken assemblers that require movd instead of movq.  */
3034       return "%vmovd\t{%1, %0|%0, %1}";
3035
3036     default:
3037       gcc_unreachable();
3038     }
3039 }
3040   [(set_attr "type" "fmov,fmov,fmov,imov,imov,imov,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
3041    (set (attr "modrm")
3042      (if_then_else
3043        (and (eq_attr "alternative" "5") (eq_attr "type" "imov"))
3044          (const_string "0")
3045          (const_string "*")))
3046    (set (attr "length_immediate")
3047      (if_then_else
3048        (and (eq_attr "alternative" "5") (eq_attr "type" "imov"))
3049          (const_string "8")
3050          (const_string "*")))
3051    (set (attr "prefix")
3052      (if_then_else (eq_attr "alternative" "0,1,2,3,4,5,6")
3053        (const_string "orig")
3054        (const_string "maybe_vex")))
3055    (set (attr "prefix_data16")
3056      (if_then_else (eq_attr "mode" "V1DF")
3057        (const_string "1")
3058        (const_string "*")))
3059    (set (attr "mode")
3060         (cond [(eq_attr "alternative" "0,1,2")
3061                  (const_string "DF")
3062                (eq_attr "alternative" "3,4,5,6,11,12")
3063                  (const_string "DI")
3064
3065                /* xorps is one byte shorter.  */
3066                (eq_attr "alternative" "7")
3067                  (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3068                             (const_int 0))
3069                           (const_string "V4SF")
3070                         (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3071                             (const_int 0))
3072                           (const_string "TI")
3073                        ]
3074                        (const_string "V2DF"))
3075
3076                /* For architectures resolving dependencies on
3077                   whole SSE registers use APD move to break dependency
3078                   chains, otherwise use short move to avoid extra work.
3079
3080                   movaps encodes one byte shorter.  */
3081                (eq_attr "alternative" "8")
3082                  (cond
3083                    [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3084                         (const_int 0))
3085                       (const_string "V4SF")
3086                     (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3087                         (const_int 0))
3088                       (const_string "V2DF")
3089                    ]
3090                    (const_string "DF"))
3091                /* For architectures resolving dependencies on register
3092                   parts we may avoid extra work to zero out upper part
3093                   of register.  */
3094                (eq_attr "alternative" "9")
3095                  (if_then_else
3096                    (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3097                        (const_int 0))
3098                    (const_string "V1DF")
3099                    (const_string "DF"))
3100               ]
3101               (const_string "DF")))])
3102
3103 ;; Possible store forwarding (partial memory) stall in alternative 4.
3104 (define_insn "*movdf_internal"
3105   [(set (match_operand:DF 0 "nonimmediate_operand"
3106                 "=f,m,f,?Yd*r ,!o   ,Y2*x,Y2*x,Y2*x,m  ")
3107         (match_operand:DF 1 "general_operand"
3108                 "fm,f,G,Yd*roF,FYd*r,C   ,Y2*x,m   ,Y2*x"))]
3109   "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3110    && (!can_create_pseudo_p ()
3111        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3112        || GET_CODE (operands[1]) != CONST_DOUBLE
3113        || (optimize_function_for_size_p (cfun)
3114            && ((!(TARGET_SSE2 && TARGET_SSE_MATH)
3115                 && standard_80387_constant_p (operands[1]) > 0)
3116                || (TARGET_SSE2 && TARGET_SSE_MATH
3117                    && standard_sse_constant_p (operands[1])))
3118            && !memory_operand (operands[0], DFmode))
3119        || (!TARGET_MEMORY_MISMATCH_STALL
3120            && memory_operand (operands[0], DFmode)))"
3121 {
3122   switch (which_alternative)
3123     {
3124     case 0:
3125     case 1:
3126       return output_387_reg_move (insn, operands);
3127
3128     case 2:
3129       return standard_80387_constant_opcode (operands[1]);
3130
3131     case 3:
3132     case 4:
3133       return "#";
3134
3135     case 5:
3136       return standard_sse_constant_opcode (insn, operands[1]);
3137
3138     case 6:
3139     case 7:
3140     case 8:
3141       switch (get_attr_mode (insn))
3142         {
3143         case MODE_V2DF:
3144           if (!TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3145             return "%vmovapd\t{%1, %0|%0, %1}";
3146         case MODE_V4SF:
3147           return "%vmovaps\t{%1, %0|%0, %1}";
3148
3149         case MODE_DI:
3150           return "%vmovq\t{%1, %0|%0, %1}";
3151         case MODE_DF:
3152           if (TARGET_AVX && REG_P (operands[0]) && REG_P (operands[1]))
3153             return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3154           return "%vmovsd\t{%1, %0|%0, %1}";
3155         case MODE_V1DF:
3156           return "%vmovlpd\t{%1, %d0|%d0, %1}";
3157         case MODE_V2SF:
3158           return "%vmovlps\t{%1, %d0|%d0, %1}";
3159         default:
3160           gcc_unreachable ();
3161         }
3162
3163     default:
3164       gcc_unreachable ();
3165     }
3166 }
3167   [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3168    (set (attr "prefix")
3169      (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3170        (const_string "orig")
3171        (const_string "maybe_vex")))
3172    (set (attr "prefix_data16")
3173      (if_then_else (eq_attr "mode" "V1DF")
3174        (const_string "1")
3175        (const_string "*")))
3176    (set (attr "mode")
3177         (cond [(eq_attr "alternative" "0,1,2")
3178                  (const_string "DF")
3179                (eq_attr "alternative" "3,4")
3180                  (const_string "SI")
3181
3182                /* For SSE1, we have many fewer alternatives.  */
3183                (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3184                  (if_then_else
3185                    (eq_attr "alternative" "5,6")
3186                    (const_string "V4SF")
3187                    (const_string "V2SF"))
3188
3189                /* xorps is one byte shorter.  */
3190                (eq_attr "alternative" "5")
3191                  (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3192                             (const_int 0))
3193                           (const_string "V4SF")
3194                         (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3195                             (const_int 0))
3196                           (const_string "TI")
3197                        ]
3198                        (const_string "V2DF"))
3199
3200                /* For architectures resolving dependencies on
3201                   whole SSE registers use APD move to break dependency
3202                   chains, otherwise use short move to avoid extra work.
3203
3204                   movaps encodes one byte shorter.  */
3205                (eq_attr "alternative" "6")
3206                  (cond
3207                    [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3208                         (const_int 0))
3209                       (const_string "V4SF")
3210                     (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3211                         (const_int 0))
3212                       (const_string "V2DF")
3213                    ]
3214                    (const_string "DF"))
3215                /* For architectures resolving dependencies on register
3216                   parts we may avoid extra work to zero out upper part
3217                   of register.  */
3218                (eq_attr "alternative" "7")
3219                  (if_then_else
3220                    (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3221                        (const_int 0))
3222                    (const_string "V1DF")
3223                    (const_string "DF"))
3224               ]
3225               (const_string "DF")))])
3226
3227 (define_insn "*movsf_internal"
3228   [(set (match_operand:SF 0 "nonimmediate_operand"
3229           "=f,m,f,?r ,?m,x,x,x,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
3230         (match_operand:SF 1 "general_operand"
3231           "fm,f,G,rmF,Fr,C,x,m,x,m  ,*y,*y ,r  ,Yi,r   ,*Ym"))]
3232   "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3233    && (!can_create_pseudo_p ()
3234        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3235        || GET_CODE (operands[1]) != CONST_DOUBLE
3236        || (optimize_function_for_size_p (cfun)
3237            && ((!TARGET_SSE_MATH
3238                 && standard_80387_constant_p (operands[1]) > 0)
3239                || (TARGET_SSE_MATH
3240                    && standard_sse_constant_p (operands[1]))))
3241        || memory_operand (operands[0], SFmode))"
3242 {
3243   switch (which_alternative)
3244     {
3245     case 0:
3246     case 1:
3247       return output_387_reg_move (insn, operands);
3248
3249     case 2:
3250       return standard_80387_constant_opcode (operands[1]);
3251
3252     case 3:
3253     case 4:
3254       return "mov{l}\t{%1, %0|%0, %1}";
3255
3256     case 5:
3257       return standard_sse_constant_opcode (insn, operands[1]);
3258
3259     case 6:
3260       if (get_attr_mode (insn) == MODE_V4SF)
3261         return "%vmovaps\t{%1, %0|%0, %1}";
3262       if (TARGET_AVX)
3263         return "vmovss\t{%1, %0, %0|%0, %0, %1}";
3264
3265     case 7:
3266     case 8:
3267       return "%vmovss\t{%1, %0|%0, %1}";
3268
3269     case 9:
3270     case 10:
3271     case 14:
3272     case 15:
3273       return "movd\t{%1, %0|%0, %1}";
3274
3275     case 11:
3276       return "movq\t{%1, %0|%0, %1}";
3277
3278     case 12:
3279     case 13:
3280       return "%vmovd\t{%1, %0|%0, %1}";
3281
3282     default:
3283       gcc_unreachable ();
3284     }
3285 }
3286   [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
3287    (set (attr "prefix")
3288      (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
3289        (const_string "maybe_vex")
3290        (const_string "orig")))
3291    (set (attr "mode")
3292         (cond [(eq_attr "alternative" "3,4,9,10")
3293                  (const_string "SI")
3294                (eq_attr "alternative" "5")
3295                  (if_then_else
3296                    (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3297                                  (const_int 0))
3298                              (ne (symbol_ref "TARGET_SSE2")
3299                                  (const_int 0)))
3300                         (eq (symbol_ref "optimize_function_for_size_p (cfun)")
3301                             (const_int 0)))
3302                    (const_string "TI")
3303                    (const_string "V4SF"))
3304                /* For architectures resolving dependencies on
3305                   whole SSE registers use APS move to break dependency
3306                   chains, otherwise use short move to avoid extra work.
3307
3308                   Do the same for architectures resolving dependencies on
3309                   the parts.  While in DF mode it is better to always handle
3310                   just register parts, the SF mode is different due to lack
3311                   of instructions to load just part of the register.  It is
3312                   better to maintain the whole registers in single format
3313                   to avoid problems on using packed logical operations.  */
3314                (eq_attr "alternative" "6")
3315                  (if_then_else
3316                    (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3317                             (const_int 0))
3318                         (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3319                             (const_int 0)))
3320                    (const_string "V4SF")
3321                    (const_string "SF"))
3322                (eq_attr "alternative" "11")
3323                  (const_string "DI")]
3324                (const_string "SF")))])
3325
3326 (define_split
3327   [(set (match_operand 0 "any_fp_register_operand" "")
3328         (match_operand 1 "memory_operand" ""))]
3329   "reload_completed
3330    && (GET_MODE (operands[0]) == TFmode
3331        || GET_MODE (operands[0]) == XFmode
3332        || GET_MODE (operands[0]) == DFmode
3333        || GET_MODE (operands[0]) == SFmode)
3334    && (operands[2] = find_constant_src (insn))"
3335   [(set (match_dup 0) (match_dup 2))]
3336 {
3337   rtx c = operands[2];
3338   int r = REGNO (operands[0]);
3339
3340   if ((SSE_REGNO_P (r) && !standard_sse_constant_p (c))
3341       || (FP_REGNO_P (r) && standard_80387_constant_p (c) < 1))
3342     FAIL;
3343 })
3344
3345 (define_split
3346   [(set (match_operand 0 "any_fp_register_operand" "")
3347         (float_extend (match_operand 1 "memory_operand" "")))]
3348   "reload_completed
3349    && (GET_MODE (operands[0]) == TFmode
3350        || GET_MODE (operands[0]) == XFmode
3351        || GET_MODE (operands[0]) == DFmode)
3352    && (operands[2] = find_constant_src (insn))"
3353   [(set (match_dup 0) (match_dup 2))]
3354 {
3355   rtx c = operands[2];