* i386-protos.h (x86_emit_floatuns): Declare.
[official-gcc.git] / gcc / config / i386 / i386.md
blob875617d69961229dbaafeaa724f3212b0d0af349
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
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 GNU CC.
9 ;;
10 ;; GNU CC 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 2, or (at your option)
13 ;; any later version.
15 ;; GNU CC 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.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU CC; see the file COPYING.  If not, write to
22 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.  */
25 ;; The original PO technology requires these to be ordered by speed,
26 ;; so that assigner will pick the fastest.
28 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
30 ;; Macro #define NOTICE_UPDATE_CC in file i386.h handles condition code
31 ;; updates for most instructions.
33 ;; Macro REG_CLASS_FROM_LETTER in file i386.h defines the register
34 ;; constraint letters.
36 ;; The special asm out single letter directives following a '%' are:
37 ;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of
38 ;;     operands[1].
39 ;; 'L' Print the opcode suffix for a 32-bit integer opcode.
40 ;; 'W' Print the opcode suffix for a 16-bit integer opcode.
41 ;; 'B' Print the opcode suffix for an 8-bit integer opcode.
42 ;; 'Q' Print the opcode suffix for a 64-bit float opcode.
43 ;; 'S' Print the opcode suffix for a 32-bit float opcode.
44 ;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode.
45 ;; 'J' Print the appropriate jump operand.
47 ;; 'b' Print the QImode name of the register for the indicated operand.
48 ;;     %b0 would print %al if operands[0] is reg 0.
49 ;; 'w' Likewise, print the HImode name of the register.
50 ;; 'k' Likewise, print the SImode 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.
54 ;; UNSPEC usage:
56 (define_constants
57   [; Relocation specifiers
58    (UNSPEC_GOT                  0)
59    (UNSPEC_GOTOFF               1)
60    (UNSPEC_GOTPCREL             2)
61    (UNSPEC_GOTTPOFF             3)
62    (UNSPEC_TPOFF                4)
63    (UNSPEC_NTPOFF               5)
64    (UNSPEC_DTPOFF               6)
65    (UNSPEC_GOTNTPOFF            7)
66    (UNSPEC_INDNTPOFF            8)
68    ; Prologue support
69    (UNSPEC_STACK_PROBE          10)
70    (UNSPEC_STACK_ALLOC          11)
71    (UNSPEC_SET_GOT              12)
72    (UNSPEC_SSE_PROLOGUE_SAVE    13)
74    ; TLS support
75    (UNSPEC_TP                   15)
76    (UNSPEC_TLS_GD               16)
77    (UNSPEC_TLS_LD_BASE          17)
79    ; Other random patterns
80    (UNSPEC_SCAS                 20)
81    (UNSPEC_SIN                  21)
82    (UNSPEC_COS                  22)
83    (UNSPEC_FNSTSW               24)
84    (UNSPEC_SAHF                 25)
85    (UNSPEC_FSTCW                26)
86    (UNSPEC_ADD_CARRY            27)
87    (UNSPEC_FLDCW                28)
89    ; For SSE/MMX support:
90    (UNSPEC_FIX                  30)
91    (UNSPEC_MASKMOV              32)
92    (UNSPEC_MOVMSK               33)
93    (UNSPEC_MOVNT                34)
94    (UNSPEC_MOVA                 38)
95    (UNSPEC_MOVU                 39)
96    (UNSPEC_SHUFFLE              41)
97    (UNSPEC_RCP                  42)
98    (UNSPEC_RSQRT                43)
99    (UNSPEC_SFENCE               44)
100    (UNSPEC_NOP                  45)     ; prevents combiner cleverness
101    (UNSPEC_PAVGUSB              49)
102    (UNSPEC_PFRCP                50)
103    (UNSPEC_PFRCPIT1             51)
104    (UNSPEC_PFRCPIT2             52)
105    (UNSPEC_PFRSQRT              53)
106    (UNSPEC_PFRSQIT1             54)
107    (UNSPEC_PSHUFLW              55)
108    (UNSPEC_PSHUFHW              56)
109    (UNSPEC_MFENCE               59)
110    (UNSPEC_LFENCE               60)
111    (UNSPEC_PSADBW               61)
112   ])
114 (define_constants
115   [(UNSPECV_BLOCKAGE            0)
116    (UNSPECV_EH_RETURN           13)
117    (UNSPECV_EMMS                31)
118    (UNSPECV_LDMXCSR             37)
119    (UNSPECV_STMXCSR             40)
120    (UNSPECV_FEMMS               46)
121    (UNSPECV_CLFLUSH             57)
122   ])
124 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
125 ;; from i386.c.
127 ;; In C guard expressions, put expressions which may be compile-time
128 ;; constants first.  This allows for better optimization.  For
129 ;; example, write "TARGET_64BIT && reload_completed", not
130 ;; "reload_completed && TARGET_64BIT".
133 ;; Processor type.  This attribute must exactly match the processor_type
134 ;; enumeration in i386.h.
135 (define_attr "cpu" "i386,i486,pentium,pentiumpro,k6,athlon,pentium4,k8"
136   (const (symbol_ref "ix86_cpu")))
138 ;; A basic instruction type.  Refinements due to arguments to be
139 ;; provided in other attributes.
140 (define_attr "type"
141   "other,multi,
142    alu,alu1,negnot,imov,imovx,lea,
143    incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
144    icmp,test,ibr,setcc,icmov,
145    push,pop,call,callv,leave,
146    str,cld,
147    fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,
148    sselog,sseiadd,sseishft,sseimul,
149    sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,sseicvt,ssediv,
150    mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
151   (const_string "other"))
153 ;; Main data type used by the insn
154 (define_attr "mode"
155   "unknown,none,QI,HI,SI,DI,SF,DF,XF,TI,V4SF,V2DF,V2SF"
156   (const_string "unknown"))
158 ;; The CPU unit operations uses.
159 (define_attr "unit" "integer,i387,sse,mmx,unknown"
160   (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp")
161            (const_string "i387")
162          (eq_attr "type" "sselog,sseiadd,sseishft,sseimul,
163                           sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,sseicvt,ssediv")
164            (const_string "sse")
165          (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
166            (const_string "mmx")
167          (eq_attr "type" "other")
168            (const_string "unknown")]
169          (const_string "integer")))
171 ;; The (bounding maximum) length of an instruction immediate.
172 (define_attr "length_immediate" ""
173   (cond [(eq_attr "type" "incdec,setcc,icmov,str,cld,lea,other,multi,idiv,leave")
174            (const_int 0)
175          (eq_attr "unit" "i387,sse,mmx")
176            (const_int 0)
177          (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
178                           imul,icmp,push,pop")
179            (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
180          (eq_attr "type" "imov,test")
181            (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
182          (eq_attr "type" "call")
183            (if_then_else (match_operand 0 "constant_call_address_operand" "")
184              (const_int 4)
185              (const_int 0))
186          (eq_attr "type" "callv")
187            (if_then_else (match_operand 1 "constant_call_address_operand" "")
188              (const_int 4)
189              (const_int 0))
190          ;; We don't know the size before shorten_branches.  Expect
191          ;; the instruction to fit for better scheduling.
192          (eq_attr "type" "ibr")
193            (const_int 1)
194          ]
195          (symbol_ref "/* Update immediate_length and other attributes! */
196                       abort(),1")))
198 ;; The (bounding maximum) length of an instruction address.
199 (define_attr "length_address" ""
200   (cond [(eq_attr "type" "str,cld,other,multi,fxch")
201            (const_int 0)
202          (and (eq_attr "type" "call")
203               (match_operand 0 "constant_call_address_operand" ""))
204              (const_int 0)
205          (and (eq_attr "type" "callv")
206               (match_operand 1 "constant_call_address_operand" ""))
207              (const_int 0)
208          ]
209          (symbol_ref "ix86_attr_length_address_default (insn)")))
211 ;; Set when length prefix is used.
212 (define_attr "prefix_data16" ""
213   (if_then_else (ior (eq_attr "mode" "HI")
214                      (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF")))
215     (const_int 1)
216     (const_int 0)))
218 ;; Set when string REP prefix is used.
219 (define_attr "prefix_rep" "" 
220   (if_then_else (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
221     (const_int 1)
222     (const_int 0)))
224 ;; Set when 0f opcode prefix is used.
225 (define_attr "prefix_0f" ""
226   (if_then_else 
227     (ior (eq_attr "type" "imovx,setcc,icmov")
228          (eq_attr "unit" "sse,mmx"))
229     (const_int 1)
230     (const_int 0)))
232 ;; Set when 0f opcode prefix is used.
233 (define_attr "prefix_rex" ""
234   (cond [(and (eq_attr "mode" "DI")
235               (eq_attr "type" "!push,pop,call,callv,leave,ibr"))
236            (const_int 1)
237          (and (eq_attr "mode" "QI")
238               (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
239                   (const_int 0)))
240            (const_int 1)
241          (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
242              (const_int 0))
243            (const_int 1)
244         ]
245         (const_int 0)))
247 ;; Set when modrm byte is used.
248 (define_attr "modrm" ""
249   (cond [(eq_attr "type" "str,cld,leave")
250            (const_int 0)
251          (eq_attr "unit" "i387")
252            (const_int 0)
253          (and (eq_attr "type" "incdec")
254               (ior (match_operand:SI 1 "register_operand" "")
255                    (match_operand:HI 1 "register_operand" "")))
256            (const_int 0)
257          (and (eq_attr "type" "push")
258               (not (match_operand 1 "memory_operand" "")))
259            (const_int 0)
260          (and (eq_attr "type" "pop")
261               (not (match_operand 0 "memory_operand" "")))
262            (const_int 0)
263          (and (eq_attr "type" "imov")
264               (and (match_operand 0 "register_operand" "")
265                    (match_operand 1 "immediate_operand" "")))
266            (const_int 0)
267          (and (eq_attr "type" "call")
268               (match_operand 0 "constant_call_address_operand" ""))
269              (const_int 0)
270          (and (eq_attr "type" "callv")
271               (match_operand 1 "constant_call_address_operand" ""))
272              (const_int 0)
273          ]
274          (const_int 1)))
276 ;; The (bounding maximum) length of an instruction in bytes.
277 ;; ??? fistp is in fact fldcw/fistp/fldcw sequence.  Later we may want
278 ;; to split it and compute proper length as for other insns.
279 (define_attr "length" ""
280   (cond [(eq_attr "type" "other,multi,fistp")
281            (const_int 16)
282          (eq_attr "unit" "i387")
283            (plus (const_int 2)
284                  (plus (attr "prefix_data16")
285                        (attr "length_address")))]
286          (plus (plus (attr "modrm")
287                      (plus (attr "prefix_0f")
288                            (plus (attr "prefix_rex")
289                                  (const_int 1))))
290                (plus (attr "prefix_rep")
291                      (plus (attr "prefix_data16")
292                            (plus (attr "length_immediate")
293                                  (attr "length_address")))))))
295 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
296 ;; `store' if there is a simple memory reference therein, or `unknown'
297 ;; if the instruction is complex.
299 (define_attr "memory" "none,load,store,both,unknown"
300   (cond [(eq_attr "type" "other,multi,str")
301            (const_string "unknown")
302          (eq_attr "type" "lea,fcmov,fpspc,cld")
303            (const_string "none")
304          (eq_attr "type" "fistp,leave")
305            (const_string "both")
306          (eq_attr "type" "push")
307            (if_then_else (match_operand 1 "memory_operand" "")
308              (const_string "both")
309              (const_string "store"))
310          (eq_attr "type" "pop")
311            (if_then_else (match_operand 0 "memory_operand" "")
312              (const_string "both")
313              (const_string "load"))
314          (eq_attr "type" "setcc")
315            (if_then_else (match_operand 0 "memory_operand" "")
316              (const_string "store")
317              (const_string "none"))
318          (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
319            (if_then_else (ior (match_operand 0 "memory_operand" "")
320                               (match_operand 1 "memory_operand" ""))
321              (const_string "load")
322              (const_string "none"))
323          (eq_attr "type" "ibr")
324            (if_then_else (match_operand 0 "memory_operand" "")
325              (const_string "load")
326              (const_string "none"))
327          (eq_attr "type" "call")
328            (if_then_else (match_operand 0 "constant_call_address_operand" "")
329              (const_string "none")
330              (const_string "load"))
331          (eq_attr "type" "callv")
332            (if_then_else (match_operand 1 "constant_call_address_operand" "")
333              (const_string "none")
334              (const_string "load"))
335          (and (eq_attr "type" "alu1,negnot")
336               (match_operand 1 "memory_operand" ""))
337            (const_string "both")
338          (and (match_operand 0 "memory_operand" "")
339               (match_operand 1 "memory_operand" ""))
340            (const_string "both")
341          (match_operand 0 "memory_operand" "")
342            (const_string "store")
343          (match_operand 1 "memory_operand" "")
344            (const_string "load")
345          (and (eq_attr "type"
346                  "!alu1,negnot,
347                    imov,imovx,icmp,test,
348                    fmov,fcmp,fsgn,
349                    sse,ssemov,ssecmp,ssecomi,ssecvt,sseicvt,
350                    mmx,mmxmov,mmxcmp,mmxcvt")
351               (match_operand 2 "memory_operand" ""))
352            (const_string "load")
353          (and (eq_attr "type" "icmov")
354               (match_operand 3 "memory_operand" ""))
355            (const_string "load")
356         ]
357         (const_string "none")))
359 ;; Indicates if an instruction has both an immediate and a displacement.
361 (define_attr "imm_disp" "false,true,unknown"
362   (cond [(eq_attr "type" "other,multi")
363            (const_string "unknown")
364          (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
365               (and (match_operand 0 "memory_displacement_operand" "")
366                    (match_operand 1 "immediate_operand" "")))
367            (const_string "true")
368          (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
369               (and (match_operand 0 "memory_displacement_operand" "")
370                    (match_operand 2 "immediate_operand" "")))
371            (const_string "true")
372         ]
373         (const_string "false")))
375 ;; Indicates if an FP operation has an integer source.
377 (define_attr "fp_int_src" "false,true"
378   (const_string "false"))
380 ;; Describe a user's asm statement.
381 (define_asm_attributes
382   [(set_attr "length" "128")
383    (set_attr "type" "multi")])
385 (include "pentium.md")
386 (include "ppro.md")
387 (include "k6.md")
388 (include "athlon.md")
390 ;; Compare instructions.
392 ;; All compare insns have expanders that save the operands away without
393 ;; actually generating RTL.  The bCOND or sCOND (emitted immediately
394 ;; after the cmp) will actually emit the cmpM.
396 (define_expand "cmpdi"
397   [(set (reg:CC 17)
398         (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
399                     (match_operand:DI 1 "x86_64_general_operand" "")))]
400   ""
402   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
403     operands[0] = force_reg (DImode, operands[0]);
404   ix86_compare_op0 = operands[0];
405   ix86_compare_op1 = operands[1];
406   DONE;
409 (define_expand "cmpsi"
410   [(set (reg:CC 17)
411         (compare:CC (match_operand:SI 0 "cmpsi_operand" "")
412                     (match_operand:SI 1 "general_operand" "")))]
413   ""
415   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
416     operands[0] = force_reg (SImode, operands[0]);
417   ix86_compare_op0 = operands[0];
418   ix86_compare_op1 = operands[1];
419   DONE;
422 (define_expand "cmphi"
423   [(set (reg:CC 17)
424         (compare:CC (match_operand:HI 0 "nonimmediate_operand" "")
425                     (match_operand:HI 1 "general_operand" "")))]
426   ""
428   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
429     operands[0] = force_reg (HImode, operands[0]);
430   ix86_compare_op0 = operands[0];
431   ix86_compare_op1 = operands[1];
432   DONE;
435 (define_expand "cmpqi"
436   [(set (reg:CC 17)
437         (compare:CC (match_operand:QI 0 "nonimmediate_operand" "")
438                     (match_operand:QI 1 "general_operand" "")))]
439   "TARGET_QIMODE_MATH"
441   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
442     operands[0] = force_reg (QImode, operands[0]);
443   ix86_compare_op0 = operands[0];
444   ix86_compare_op1 = operands[1];
445   DONE;
448 (define_insn "cmpdi_ccno_1_rex64"
449   [(set (reg 17)
450         (compare (match_operand:DI 0 "nonimmediate_operand" "r,?mr")
451                  (match_operand:DI 1 "const0_operand" "n,n")))]
452   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
453   "@
454    test{q}\t{%0, %0|%0, %0}
455    cmp{q}\t{%1, %0|%0, %1}"
456   [(set_attr "type" "test,icmp")
457    (set_attr "length_immediate" "0,1")
458    (set_attr "mode" "DI")])
460 (define_insn "*cmpdi_minus_1_rex64"
461   [(set (reg 17)
462         (compare (minus:DI (match_operand:DI 0 "nonimmediate_operand" "rm,r")
463                            (match_operand:DI 1 "x86_64_general_operand" "re,mr"))
464                  (const_int 0)))]
465   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)"
466   "cmp{q}\t{%1, %0|%0, %1}"
467   [(set_attr "type" "icmp")
468    (set_attr "mode" "DI")])
470 (define_expand "cmpdi_1_rex64"
471   [(set (reg:CC 17)
472         (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
473                     (match_operand:DI 1 "general_operand" "")))]
474   "TARGET_64BIT"
475   "")
477 (define_insn "cmpdi_1_insn_rex64"
478   [(set (reg 17)
479         (compare (match_operand:DI 0 "nonimmediate_operand" "mr,r")
480                  (match_operand:DI 1 "x86_64_general_operand" "re,mr")))]
481   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
482   "cmp{q}\t{%1, %0|%0, %1}"
483   [(set_attr "type" "icmp")
484    (set_attr "mode" "DI")])
487 (define_insn "*cmpsi_ccno_1"
488   [(set (reg 17)
489         (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr")
490                  (match_operand:SI 1 "const0_operand" "n,n")))]
491   "ix86_match_ccmode (insn, CCNOmode)"
492   "@
493    test{l}\t{%0, %0|%0, %0}
494    cmp{l}\t{%1, %0|%0, %1}"
495   [(set_attr "type" "test,icmp")
496    (set_attr "length_immediate" "0,1")
497    (set_attr "mode" "SI")])
499 (define_insn "*cmpsi_minus_1"
500   [(set (reg 17)
501         (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r")
502                            (match_operand:SI 1 "general_operand" "ri,mr"))
503                  (const_int 0)))]
504   "ix86_match_ccmode (insn, CCGOCmode)"
505   "cmp{l}\t{%1, %0|%0, %1}"
506   [(set_attr "type" "icmp")
507    (set_attr "mode" "SI")])
509 (define_expand "cmpsi_1"
510   [(set (reg:CC 17)
511         (compare:CC (match_operand:SI 0 "nonimmediate_operand" "rm,r")
512                     (match_operand:SI 1 "general_operand" "ri,mr")))]
513   ""
514   "")
516 (define_insn "*cmpsi_1_insn"
517   [(set (reg 17)
518         (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r")
519                  (match_operand:SI 1 "general_operand" "ri,mr")))]
520   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
521     && ix86_match_ccmode (insn, CCmode)"
522   "cmp{l}\t{%1, %0|%0, %1}"
523   [(set_attr "type" "icmp")
524    (set_attr "mode" "SI")])
526 (define_insn "*cmphi_ccno_1"
527   [(set (reg 17)
528         (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr")
529                  (match_operand:HI 1 "const0_operand" "n,n")))]
530   "ix86_match_ccmode (insn, CCNOmode)"
531   "@
532    test{w}\t{%0, %0|%0, %0}
533    cmp{w}\t{%1, %0|%0, %1}"
534   [(set_attr "type" "test,icmp")
535    (set_attr "length_immediate" "0,1")
536    (set_attr "mode" "HI")])
538 (define_insn "*cmphi_minus_1"
539   [(set (reg 17)
540         (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r")
541                            (match_operand:HI 1 "general_operand" "ri,mr"))
542                  (const_int 0)))]
543   "ix86_match_ccmode (insn, CCGOCmode)"
544   "cmp{w}\t{%1, %0|%0, %1}"
545   [(set_attr "type" "icmp")
546    (set_attr "mode" "HI")])
548 (define_insn "*cmphi_1"
549   [(set (reg 17)
550         (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r")
551                  (match_operand:HI 1 "general_operand" "ri,mr")))]
552   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
553    && ix86_match_ccmode (insn, CCmode)"
554   "cmp{w}\t{%1, %0|%0, %1}"
555   [(set_attr "type" "icmp")
556    (set_attr "mode" "HI")])
558 (define_insn "*cmpqi_ccno_1"
559   [(set (reg 17)
560         (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq")
561                  (match_operand:QI 1 "const0_operand" "n,n")))]
562   "ix86_match_ccmode (insn, CCNOmode)"
563   "@
564    test{b}\t{%0, %0|%0, %0}
565    cmp{b}\t{$0, %0|%0, 0}"
566   [(set_attr "type" "test,icmp")
567    (set_attr "length_immediate" "0,1")
568    (set_attr "mode" "QI")])
570 (define_insn "*cmpqi_1"
571   [(set (reg 17)
572         (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q")
573                  (match_operand:QI 1 "general_operand" "qi,mq")))]
574   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
575     && ix86_match_ccmode (insn, CCmode)"
576   "cmp{b}\t{%1, %0|%0, %1}"
577   [(set_attr "type" "icmp")
578    (set_attr "mode" "QI")])
580 (define_insn "*cmpqi_minus_1"
581   [(set (reg 17)
582         (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q")
583                            (match_operand:QI 1 "general_operand" "qi,mq"))
584                  (const_int 0)))]
585   "ix86_match_ccmode (insn, CCGOCmode)"
586   "cmp{b}\t{%1, %0|%0, %1}"
587   [(set_attr "type" "icmp")
588    (set_attr "mode" "QI")])
590 (define_insn "*cmpqi_ext_1"
591   [(set (reg 17)
592         (compare
593           (match_operand:QI 0 "general_operand" "Qm")
594           (subreg:QI
595             (zero_extract:SI
596               (match_operand 1 "ext_register_operand" "Q")
597               (const_int 8)
598               (const_int 8)) 0)))]
599   "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
600   "cmp{b}\t{%h1, %0|%0, %h1}"
601   [(set_attr "type" "icmp")
602    (set_attr "mode" "QI")])
604 (define_insn "*cmpqi_ext_1_rex64"
605   [(set (reg 17)
606         (compare
607           (match_operand:QI 0 "register_operand" "Q")
608           (subreg:QI
609             (zero_extract:SI
610               (match_operand 1 "ext_register_operand" "Q")
611               (const_int 8)
612               (const_int 8)) 0)))]
613   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
614   "cmp{b}\t{%h1, %0|%0, %h1}"
615   [(set_attr "type" "icmp")
616    (set_attr "mode" "QI")])
618 (define_insn "*cmpqi_ext_2"
619   [(set (reg 17)
620         (compare
621           (subreg:QI
622             (zero_extract:SI
623               (match_operand 0 "ext_register_operand" "Q")
624               (const_int 8)
625               (const_int 8)) 0)
626           (match_operand:QI 1 "const0_operand" "n")))]
627   "ix86_match_ccmode (insn, CCNOmode)"
628   "test{b}\t%h0, %h0"
629   [(set_attr "type" "test")
630    (set_attr "length_immediate" "0")
631    (set_attr "mode" "QI")])
633 (define_expand "cmpqi_ext_3"
634   [(set (reg:CC 17)
635         (compare:CC
636           (subreg:QI
637             (zero_extract:SI
638               (match_operand 0 "ext_register_operand" "")
639               (const_int 8)
640               (const_int 8)) 0)
641           (match_operand:QI 1 "general_operand" "")))]
642   ""
643   "")
645 (define_insn "cmpqi_ext_3_insn"
646   [(set (reg 17)
647         (compare
648           (subreg:QI
649             (zero_extract:SI
650               (match_operand 0 "ext_register_operand" "Q")
651               (const_int 8)
652               (const_int 8)) 0)
653           (match_operand:QI 1 "general_operand" "Qmn")))]
654   "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
655   "cmp{b}\t{%1, %h0|%h0, %1}"
656   [(set_attr "type" "icmp")
657    (set_attr "mode" "QI")])
659 (define_insn "cmpqi_ext_3_insn_rex64"
660   [(set (reg 17)
661         (compare
662           (subreg:QI
663             (zero_extract:SI
664               (match_operand 0 "ext_register_operand" "Q")
665               (const_int 8)
666               (const_int 8)) 0)
667           (match_operand:QI 1 "nonmemory_operand" "Qn")))]
668   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
669   "cmp{b}\t{%1, %h0|%h0, %1}"
670   [(set_attr "type" "icmp")
671    (set_attr "mode" "QI")])
673 (define_insn "*cmpqi_ext_4"
674   [(set (reg 17)
675         (compare
676           (subreg:QI
677             (zero_extract:SI
678               (match_operand 0 "ext_register_operand" "Q")
679               (const_int 8)
680               (const_int 8)) 0)
681           (subreg:QI
682             (zero_extract:SI
683               (match_operand 1 "ext_register_operand" "Q")
684               (const_int 8)
685               (const_int 8)) 0)))]
686   "ix86_match_ccmode (insn, CCmode)"
687   "cmp{b}\t{%h1, %h0|%h0, %h1}"
688   [(set_attr "type" "icmp")
689    (set_attr "mode" "QI")])
691 ;; These implement float point compares.
692 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
693 ;; which would allow mix and match FP modes on the compares.  Which is what
694 ;; the old patterns did, but with many more of them.
696 (define_expand "cmpxf"
697   [(set (reg:CC 17)
698         (compare:CC (match_operand:XF 0 "cmp_fp_expander_operand" "")
699                     (match_operand:XF 1 "cmp_fp_expander_operand" "")))]
700   "!TARGET_64BIT && TARGET_80387"
702   ix86_compare_op0 = operands[0];
703   ix86_compare_op1 = operands[1];
704   DONE;
707 (define_expand "cmptf"
708   [(set (reg:CC 17)
709         (compare:CC (match_operand:TF 0 "cmp_fp_expander_operand" "")
710                     (match_operand:TF 1 "cmp_fp_expander_operand" "")))]
711   "TARGET_80387"
713   ix86_compare_op0 = operands[0];
714   ix86_compare_op1 = operands[1];
715   DONE;
718 (define_expand "cmpdf"
719   [(set (reg:CC 17)
720         (compare:CC (match_operand:DF 0 "cmp_fp_expander_operand" "")
721                     (match_operand:DF 1 "cmp_fp_expander_operand" "")))]
722   "TARGET_80387 || TARGET_SSE2"
724   ix86_compare_op0 = operands[0];
725   ix86_compare_op1 = operands[1];
726   DONE;
729 (define_expand "cmpsf"
730   [(set (reg:CC 17)
731         (compare:CC (match_operand:SF 0 "cmp_fp_expander_operand" "")
732                     (match_operand:SF 1 "cmp_fp_expander_operand" "")))]
733   "TARGET_80387 || TARGET_SSE"
735   ix86_compare_op0 = operands[0];
736   ix86_compare_op1 = operands[1];
737   DONE;
740 ;; FP compares, step 1:
741 ;; Set the FP condition codes.
743 ;; CCFPmode     compare with exceptions
744 ;; CCFPUmode    compare with no exceptions
746 ;; %%% It is an unfortunate fact that ftst has no non-popping variant,
747 ;; and that fp moves clobber the condition codes, and that there is
748 ;; currently no way to describe this fact to reg-stack.  So there are
749 ;; no splitters yet for this.
751 ;; %%% YIKES!  This scheme does not retain a strong connection between 
752 ;; the real compare and the ultimate cc0 user, so CC_REVERSE does not
753 ;; work!  Only allow tos/mem with tos in op 0.
755 ;; Hmm, of course, this is what the actual _hardware_ does.  Perhaps
756 ;; things aren't as bad as they sound...
758 (define_insn "*cmpfp_0"
759   [(set (match_operand:HI 0 "register_operand" "=a")
760         (unspec:HI
761           [(compare:CCFP (match_operand 1 "register_operand" "f")
762                          (match_operand 2 "const0_operand" "X"))]
763           UNSPEC_FNSTSW))]
764   "TARGET_80387
765    && FLOAT_MODE_P (GET_MODE (operands[1]))
766    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
768   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
769     return "ftst\;fnstsw\t%0\;fstp\t%y0";
770   else
771     return "ftst\;fnstsw\t%0";
773   [(set_attr "type" "multi")
774    (set (attr "mode")
775      (cond [(match_operand:SF 1 "" "")
776               (const_string "SF")
777             (match_operand:DF 1 "" "")
778               (const_string "DF")
779            ]
780            (const_string "XF")))])
782 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
783 ;; used to manage the reg stack popping would not be preserved.
785 (define_insn "*cmpfp_2_sf"
786   [(set (reg:CCFP 18)
787         (compare:CCFP
788           (match_operand:SF 0 "register_operand" "f")
789           (match_operand:SF 1 "nonimmediate_operand" "fm")))]
790   "TARGET_80387"
791   "* return output_fp_compare (insn, operands, 0, 0);"
792   [(set_attr "type" "fcmp")
793    (set_attr "mode" "SF")])
795 (define_insn "*cmpfp_2_sf_1"
796   [(set (match_operand:HI 0 "register_operand" "=a")
797         (unspec:HI
798           [(compare:CCFP
799              (match_operand:SF 1 "register_operand" "f")
800              (match_operand:SF 2 "nonimmediate_operand" "fm"))]
801           UNSPEC_FNSTSW))]
802   "TARGET_80387"
803   "* return output_fp_compare (insn, operands, 2, 0);"
804   [(set_attr "type" "fcmp")
805    (set_attr "mode" "SF")])
807 (define_insn "*cmpfp_2_df"
808   [(set (reg:CCFP 18)
809         (compare:CCFP
810           (match_operand:DF 0 "register_operand" "f")
811           (match_operand:DF 1 "nonimmediate_operand" "fm")))]
812   "TARGET_80387"
813   "* return output_fp_compare (insn, operands, 0, 0);"
814   [(set_attr "type" "fcmp")
815    (set_attr "mode" "DF")])
817 (define_insn "*cmpfp_2_df_1"
818   [(set (match_operand:HI 0 "register_operand" "=a")
819         (unspec:HI
820           [(compare:CCFP
821              (match_operand:DF 1 "register_operand" "f")
822              (match_operand:DF 2 "nonimmediate_operand" "fm"))]
823           UNSPEC_FNSTSW))]
824   "TARGET_80387"
825   "* return output_fp_compare (insn, operands, 2, 0);"
826   [(set_attr "type" "multi")
827    (set_attr "mode" "DF")])
829 (define_insn "*cmpfp_2_xf"
830   [(set (reg:CCFP 18)
831         (compare:CCFP
832           (match_operand:XF 0 "register_operand" "f")
833           (match_operand:XF 1 "register_operand" "f")))]
834   "!TARGET_64BIT && TARGET_80387"
835   "* return output_fp_compare (insn, operands, 0, 0);"
836   [(set_attr "type" "fcmp")
837    (set_attr "mode" "XF")])
839 (define_insn "*cmpfp_2_tf"
840   [(set (reg:CCFP 18)
841         (compare:CCFP
842           (match_operand:TF 0 "register_operand" "f")
843           (match_operand:TF 1 "register_operand" "f")))]
844   "TARGET_80387"
845   "* return output_fp_compare (insn, operands, 0, 0);"
846   [(set_attr "type" "fcmp")
847    (set_attr "mode" "XF")])
849 (define_insn "*cmpfp_2_xf_1"
850   [(set (match_operand:HI 0 "register_operand" "=a")
851         (unspec:HI
852           [(compare:CCFP
853              (match_operand:XF 1 "register_operand" "f")
854              (match_operand:XF 2 "register_operand" "f"))]
855           UNSPEC_FNSTSW))]
856   "!TARGET_64BIT && TARGET_80387"
857   "* return output_fp_compare (insn, operands, 2, 0);"
858   [(set_attr "type" "multi")
859    (set_attr "mode" "XF")])
861 (define_insn "*cmpfp_2_tf_1"
862   [(set (match_operand:HI 0 "register_operand" "=a")
863         (unspec:HI
864           [(compare:CCFP
865              (match_operand:TF 1 "register_operand" "f")
866              (match_operand:TF 2 "register_operand" "f"))]
867           UNSPEC_FNSTSW))]
868   "TARGET_80387"
869   "* return output_fp_compare (insn, operands, 2, 0);"
870   [(set_attr "type" "multi")
871    (set_attr "mode" "XF")])
873 (define_insn "*cmpfp_2u"
874   [(set (reg:CCFPU 18)
875         (compare:CCFPU
876           (match_operand 0 "register_operand" "f")
877           (match_operand 1 "register_operand" "f")))]
878   "TARGET_80387
879    && FLOAT_MODE_P (GET_MODE (operands[0]))
880    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
881   "* return output_fp_compare (insn, operands, 0, 1);"
882   [(set_attr "type" "fcmp")
883    (set (attr "mode")
884      (cond [(match_operand:SF 1 "" "")
885               (const_string "SF")
886             (match_operand:DF 1 "" "")
887               (const_string "DF")
888            ]
889            (const_string "XF")))])
891 (define_insn "*cmpfp_2u_1"
892   [(set (match_operand:HI 0 "register_operand" "=a")
893         (unspec:HI
894           [(compare:CCFPU
895              (match_operand 1 "register_operand" "f")
896              (match_operand 2 "register_operand" "f"))]
897           UNSPEC_FNSTSW))]
898   "TARGET_80387
899    && FLOAT_MODE_P (GET_MODE (operands[1]))
900    && GET_MODE (operands[1]) == GET_MODE (operands[2])"
901   "* return output_fp_compare (insn, operands, 2, 1);"
902   [(set_attr "type" "multi")
903    (set (attr "mode")
904      (cond [(match_operand:SF 1 "" "")
905               (const_string "SF")
906             (match_operand:DF 1 "" "")
907               (const_string "DF")
908            ]
909            (const_string "XF")))])
911 ;; Patterns to match the SImode-in-memory ficom instructions.
913 ;; %%% Play games with accepting gp registers, as otherwise we have to
914 ;; force them to memory during rtl generation, which is no good.  We
915 ;; can get rid of this once we teach reload to do memory input reloads 
916 ;; via pushes.
918 (define_insn "*ficom_1"
919   [(set (reg:CCFP 18)
920         (compare:CCFP
921           (match_operand 0 "register_operand" "f,f")
922           (float (match_operand:SI 1 "nonimmediate_operand" "m,?r"))))]
923   "0 && TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[0]))
924    && GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == GET_MODE (operands[0])"
925   "#")
927 ;; Split the not-really-implemented gp register case into a
928 ;; push-op-pop sequence.
930 ;; %%% This is most efficient, but am I gonna get in trouble
931 ;; for separating cc0_setter and cc0_user?
933 (define_split
934   [(set (reg:CCFP 18)
935         (compare:CCFP
936           (match_operand:SF 0 "register_operand" "")
937           (float (match_operand:SI 1 "register_operand" ""))))]
938   "0 && TARGET_80387 && reload_completed"
939   [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 1))
940    (set (reg:CCFP 18) (compare:CCFP (match_dup 0) (match_dup 2)))
941    (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
942               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
943   "operands[2] = gen_rtx_MEM (Pmode, stack_pointer_rtx);
944    operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);")
946 ;; FP compares, step 2
947 ;; Move the fpsw to ax.
949 (define_insn "*x86_fnstsw_1"
950   [(set (match_operand:HI 0 "register_operand" "=a")
951         (unspec:HI [(reg 18)] UNSPEC_FNSTSW))]
952   "TARGET_80387"
953   "fnstsw\t%0"
954   [(set_attr "length" "2")
955    (set_attr "mode" "SI")
956    (set_attr "unit" "i387")
957    (set_attr "ppro_uops" "few")])
959 ;; FP compares, step 3
960 ;; Get ax into flags, general case.
962 (define_insn "x86_sahf_1"
963   [(set (reg:CC 17)
964         (unspec:CC [(match_operand:HI 0 "register_operand" "a")] UNSPEC_SAHF))]
965   "!TARGET_64BIT"
966   "sahf"
967   [(set_attr "length" "1")
968    (set_attr "athlon_decode" "vector")
969    (set_attr "mode" "SI")
970    (set_attr "ppro_uops" "one")])
972 ;; Pentium Pro can do steps 1 through 3 in one go.
974 (define_insn "*cmpfp_i"
975   [(set (reg:CCFP 17)
976         (compare:CCFP (match_operand 0 "register_operand" "f")
977                       (match_operand 1 "register_operand" "f")))]
978   "TARGET_80387 && TARGET_CMOVE
979    && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
980    && FLOAT_MODE_P (GET_MODE (operands[0]))
981    && GET_MODE (operands[0]) == GET_MODE (operands[0])"
982   "* return output_fp_compare (insn, operands, 1, 0);"
983   [(set_attr "type" "fcmp")
984    (set (attr "mode")
985      (cond [(match_operand:SF 1 "" "")
986               (const_string "SF")
987             (match_operand:DF 1 "" "")
988               (const_string "DF")
989            ]
990            (const_string "XF")))
991    (set_attr "athlon_decode" "vector")])
993 (define_insn "*cmpfp_i_sse"
994   [(set (reg:CCFP 17)
995         (compare:CCFP (match_operand 0 "register_operand" "f#x,x#f")
996                       (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
997   "TARGET_80387
998    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
999    && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1000   "* return output_fp_compare (insn, operands, 1, 0);"
1001   [(set_attr "type" "fcmp,ssecomi")
1002    (set (attr "mode")
1003      (if_then_else (match_operand:SF 1 "" "")
1004         (const_string "SF")
1005         (const_string "DF")))
1006    (set_attr "athlon_decode" "vector")])
1008 (define_insn "*cmpfp_i_sse_only"
1009   [(set (reg:CCFP 17)
1010         (compare:CCFP (match_operand 0 "register_operand" "x")
1011                       (match_operand 1 "nonimmediate_operand" "xm")))]
1012   "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1013    && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1014   "* return output_fp_compare (insn, operands, 1, 0);"
1015   [(set_attr "type" "ssecomi")
1016    (set (attr "mode")
1017      (if_then_else (match_operand:SF 1 "" "")
1018         (const_string "SF")
1019         (const_string "DF")))
1020    (set_attr "athlon_decode" "vector")])
1022 (define_insn "*cmpfp_iu"
1023   [(set (reg:CCFPU 17)
1024         (compare:CCFPU (match_operand 0 "register_operand" "f")
1025                        (match_operand 1 "register_operand" "f")))]
1026   "TARGET_80387 && TARGET_CMOVE
1027    && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1028    && FLOAT_MODE_P (GET_MODE (operands[0]))
1029    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1030   "* return output_fp_compare (insn, operands, 1, 1);"
1031   [(set_attr "type" "fcmp")
1032    (set (attr "mode")
1033      (cond [(match_operand:SF 1 "" "")
1034               (const_string "SF")
1035             (match_operand:DF 1 "" "")
1036               (const_string "DF")
1037            ]
1038            (const_string "XF")))
1039    (set_attr "athlon_decode" "vector")])
1041 (define_insn "*cmpfp_iu_sse"
1042   [(set (reg:CCFPU 17)
1043         (compare:CCFPU (match_operand 0 "register_operand" "f#x,x#f")
1044                        (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
1045   "TARGET_80387
1046    && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1047    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1048   "* return output_fp_compare (insn, operands, 1, 1);"
1049   [(set_attr "type" "fcmp,ssecomi")
1050    (set (attr "mode")
1051      (if_then_else (match_operand:SF 1 "" "")
1052         (const_string "SF")
1053         (const_string "DF")))
1054    (set_attr "athlon_decode" "vector")])
1056 (define_insn "*cmpfp_iu_sse_only"
1057   [(set (reg:CCFPU 17)
1058         (compare:CCFPU (match_operand 0 "register_operand" "x")
1059                        (match_operand 1 "nonimmediate_operand" "xm")))]
1060   "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1061    && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1062   "* return output_fp_compare (insn, operands, 1, 1);"
1063   [(set_attr "type" "ssecomi")
1064    (set (attr "mode")
1065      (if_then_else (match_operand:SF 1 "" "")
1066         (const_string "SF")
1067         (const_string "DF")))
1068    (set_attr "athlon_decode" "vector")])
1070 ;; Move instructions.
1072 ;; General case of fullword move.
1074 (define_expand "movsi"
1075   [(set (match_operand:SI 0 "nonimmediate_operand" "")
1076         (match_operand:SI 1 "general_operand" ""))]
1077   ""
1078   "ix86_expand_move (SImode, operands); DONE;")
1080 ;; Push/pop instructions.  They are separate since autoinc/dec is not a
1081 ;; general_operand.
1083 ;; %%% We don't use a post-inc memory reference because x86 is not a 
1084 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1085 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1086 ;; targets without our curiosities, and it is just as easy to represent
1087 ;; this differently.
1089 (define_insn "*pushsi2"
1090   [(set (match_operand:SI 0 "push_operand" "=<")
1091         (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1092   "!TARGET_64BIT"
1093   "push{l}\t%1"
1094   [(set_attr "type" "push")
1095    (set_attr "mode" "SI")])
1097 ;; For 64BIT abi we always round up to 8 bytes.
1098 (define_insn "*pushsi2_rex64"
1099   [(set (match_operand:SI 0 "push_operand" "=X")
1100         (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1101   "TARGET_64BIT"
1102   "push{q}\t%q1"
1103   [(set_attr "type" "push")
1104    (set_attr "mode" "SI")])
1106 (define_insn "*pushsi2_prologue"
1107   [(set (match_operand:SI 0 "push_operand" "=<")
1108         (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1109    (clobber (mem:BLK (scratch)))]
1110   "!TARGET_64BIT"
1111   "push{l}\t%1"
1112   [(set_attr "type" "push")
1113    (set_attr "mode" "SI")])
1115 (define_insn "*popsi1_epilogue"
1116   [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1117         (mem:SI (reg:SI 7)))
1118    (set (reg:SI 7)
1119         (plus:SI (reg:SI 7) (const_int 4)))
1120    (clobber (mem:BLK (scratch)))]
1121   "!TARGET_64BIT"
1122   "pop{l}\t%0"
1123   [(set_attr "type" "pop")
1124    (set_attr "mode" "SI")])
1126 (define_insn "popsi1"
1127   [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1128         (mem:SI (reg:SI 7)))
1129    (set (reg:SI 7)
1130         (plus:SI (reg:SI 7) (const_int 4)))]
1131   "!TARGET_64BIT"
1132   "pop{l}\t%0"
1133   [(set_attr "type" "pop")
1134    (set_attr "mode" "SI")])
1136 (define_insn "*movsi_xor"
1137   [(set (match_operand:SI 0 "register_operand" "=r")
1138         (match_operand:SI 1 "const0_operand" "i"))
1139    (clobber (reg:CC 17))]
1140   "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1141   "xor{l}\t{%0, %0|%0, %0}"
1142   [(set_attr "type" "alu1")
1143    (set_attr "mode" "SI")
1144    (set_attr "length_immediate" "0")])
1146 (define_insn "*movsi_or"
1147   [(set (match_operand:SI 0 "register_operand" "=r")
1148         (match_operand:SI 1 "immediate_operand" "i"))
1149    (clobber (reg:CC 17))]
1150   "reload_completed && GET_CODE (operands[1]) == CONST_INT
1151    && INTVAL (operands[1]) == -1
1152    && (TARGET_PENTIUM || optimize_size)"
1154   operands[1] = constm1_rtx;
1155   return "or{l}\t{%1, %0|%0, %1}";
1157   [(set_attr "type" "alu1")
1158    (set_attr "mode" "SI")
1159    (set_attr "length_immediate" "1")])
1161 ; The first alternative is used only to compute proper length of instruction.
1162 ; Reload's algorithm does not take into account the cost of spill instructions
1163 ; needed to free register in given class, so avoid it from choosing the first
1164 ; alternative when eax is not available.
1166 (define_insn "*movsi_1"
1167   [(set (match_operand:SI 0 "nonimmediate_operand" "=*?a,r,*?a,m,!*y,!rm,!*y,!*Y,!rm,!*Y")
1168         (match_operand:SI 1 "general_operand" "im,rinm,rinm,rin,rm,*y,*y,rm,*Y,*Y"))]
1169   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1171   switch (get_attr_type (insn))
1172     {
1173     case TYPE_SSEMOV:
1174       if (get_attr_mode (insn) == TImode || which_alternative == 9)
1175         return "movdqa\t{%1, %0|%0, %1}";
1176       return "movd\t{%1, %0|%0, %1}";
1178     case TYPE_MMXMOV:
1179       if (get_attr_mode (insn) == DImode)
1180         return "movq\t{%1, %0|%0, %1}";
1181       return "movd\t{%1, %0|%0, %1}";
1183     case TYPE_LEA:
1184       return "lea{l}\t{%1, %0|%0, %1}";
1186     default:
1187       if (flag_pic && !LEGITIMATE_PIC_OPERAND_P (operands[1]))
1188         abort();
1189       return "mov{l}\t{%1, %0|%0, %1}";
1190     }
1192   [(set (attr "type")
1193      (cond [(eq_attr "alternative" "4,5,6")
1194               (const_string "mmxmov")
1195             (eq_attr "alternative" "7,8,9")
1196               (const_string "ssemov")
1197             (and (ne (symbol_ref "flag_pic") (const_int 0))
1198                  (match_operand:SI 1 "symbolic_operand" ""))
1199               (const_string "lea")
1200            ]
1201            (const_string "imov")))
1202    (set_attr "modrm" "0,*,0,*,*,*,*,*,*,*")
1203    (set_attr "mode" "SI,SI,SI,SI,SI,SI,DI,TI,SI,SI")])
1205 ;; Stores and loads of ax to arbitrary constant address.
1206 ;; We fake an second form of instruction to force reload to load address
1207 ;; into register when rax is not available
1208 (define_insn "*movabssi_1_rex64"
1209   [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1210         (match_operand:SI 1 "nonmemory_operand" "a,er,i"))]
1211   "TARGET_64BIT"
1212   "@
1213    movabs{l}\t{%1, %P0|%P0, %1}
1214    mov{l}\t{%1, %a0|%a0, %1}
1215    movabs{l}\t{%1, %a0|%a0, %1}"
1216   [(set_attr "type" "imov")
1217    (set_attr "modrm" "0,*,*")
1218    (set_attr "length_address" "8,0,0")
1219    (set_attr "length_immediate" "0,*,*")
1220    (set_attr "memory" "store")
1221    (set_attr "mode" "SI")])
1223 (define_insn "*movabssi_2_rex64"
1224   [(set (match_operand:SI 0 "register_operand" "=a,r")
1225         (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1226   "TARGET_64BIT"
1227   "@
1228    movabs{l}\t{%P1, %0|%0, %P1}
1229    mov{l}\t{%a1, %0|%0, %a1}"
1230   [(set_attr "type" "imov")
1231    (set_attr "modrm" "0,*")
1232    (set_attr "length_address" "8,0")
1233    (set_attr "length_immediate" "0")
1234    (set_attr "memory" "load")
1235    (set_attr "mode" "SI")])
1237 (define_insn "*swapsi"
1238   [(set (match_operand:SI 0 "register_operand" "+r")
1239         (match_operand:SI 1 "register_operand" "+r"))
1240    (set (match_dup 1)
1241         (match_dup 0))]
1242   ""
1243   "xchg{l}\t%1, %0"
1244   [(set_attr "type" "imov")
1245    (set_attr "pent_pair" "np")
1246    (set_attr "athlon_decode" "vector")
1247    (set_attr "mode" "SI")
1248    (set_attr "modrm" "0")
1249    (set_attr "ppro_uops" "few")])
1251 (define_expand "movhi"
1252   [(set (match_operand:HI 0 "nonimmediate_operand" "")
1253         (match_operand:HI 1 "general_operand" ""))]
1254   ""
1255   "ix86_expand_move (HImode, operands); DONE;")
1257 (define_insn "*pushhi2"
1258   [(set (match_operand:HI 0 "push_operand" "=<,<")
1259         (match_operand:HI 1 "general_no_elim_operand" "n,r*m"))]
1260   "!TARGET_64BIT"
1261   "@
1262    push{w}\t{|WORD PTR }%1
1263    push{w}\t%1"
1264   [(set_attr "type" "push")
1265    (set_attr "mode" "HI")])
1267 ;; For 64BIT abi we always round up to 8 bytes.
1268 (define_insn "*pushhi2_rex64"
1269   [(set (match_operand:HI 0 "push_operand" "=X")
1270         (match_operand:HI 1 "nonmemory_no_elim_operand" "ri"))]
1271   "TARGET_64BIT"
1272   "push{q}\t%q1"
1273   [(set_attr "type" "push")
1274    (set_attr "mode" "QI")])
1276 ; The first alternative is used only to compute proper length of instruction.
1277 ; Reload's algorithm does not take into account the cost of spill instructions
1278 ; needed to free register in given class, so avoid it from choosing the first
1279 ; alternative when eax is not available.
1281 (define_insn "*movhi_1"
1282   [(set (match_operand:HI 0 "nonimmediate_operand" "=*?a,r,r,*?a,r,m")
1283         (match_operand:HI 1 "general_operand" "i,r,rn,rm,rm,rn"))]
1284   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1286   switch (get_attr_type (insn))
1287     {
1288     case TYPE_IMOVX:
1289       /* movzwl is faster than movw on p2 due to partial word stalls,
1290          though not as fast as an aligned movl.  */
1291       return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1292     default:
1293       if (get_attr_mode (insn) == MODE_SI)
1294         return "mov{l}\t{%k1, %k0|%k0, %k1}";
1295       else
1296         return "mov{w}\t{%1, %0|%0, %1}";
1297     }
1299   [(set (attr "type")
1300      (cond [(and (eq_attr "alternative" "0,1")
1301                  (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1302                           (const_int 0))
1303                       (eq (symbol_ref "TARGET_HIMODE_MATH")
1304                           (const_int 0))))
1305               (const_string "imov")
1306             (and (eq_attr "alternative" "2,3,4")
1307                  (match_operand:HI 1 "aligned_operand" ""))
1308               (const_string "imov")
1309             (and (ne (symbol_ref "TARGET_MOVX")
1310                      (const_int 0))
1311                  (eq_attr "alternative" "0,1,3,4"))
1312               (const_string "imovx")
1313            ]
1314            (const_string "imov")))
1315     (set (attr "mode")
1316       (cond [(eq_attr "type" "imovx")
1317                (const_string "SI")
1318              (and (eq_attr "alternative" "2,3,4")
1319                   (match_operand:HI 1 "aligned_operand" ""))
1320                (const_string "SI")
1321              (and (eq_attr "alternative" "0,1")
1322                   (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1323                            (const_int 0))
1324                        (eq (symbol_ref "TARGET_HIMODE_MATH")
1325                            (const_int 0))))
1326                (const_string "SI")
1327             ]
1328             (const_string "HI")))
1329    (set_attr "modrm" "0,*,*,0,*,*")])
1331 ;; Stores and loads of ax to arbitrary constant address.
1332 ;; We fake an second form of instruction to force reload to load address
1333 ;; into register when rax is not available
1334 (define_insn "*movabshi_1_rex64"
1335   [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1336         (match_operand:HI 1 "nonmemory_operand" "a,er,i"))]
1337   "TARGET_64BIT"
1338   "@
1339    movabs{w}\t{%1, %P0|%P0, %1}
1340    mov{w}\t{%1, %a0|%a0, %1}
1341    movabs{w}\t{%1, %a0|%a0, %1}"
1342   [(set_attr "type" "imov")
1343    (set_attr "modrm" "0,*,*")
1344    (set_attr "length_address" "8,0,0")
1345    (set_attr "length_immediate" "0,*,*")
1346    (set_attr "memory" "store")
1347    (set_attr "mode" "HI")])
1349 (define_insn "*movabshi_2_rex64"
1350   [(set (match_operand:HI 0 "register_operand" "=a,r")
1351         (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1352   "TARGET_64BIT"
1353   "@
1354    movabs{w}\t{%P1, %0|%0, %P1}
1355    mov{w}\t{%a1, %0|%0, %a1}"
1356   [(set_attr "type" "imov")
1357    (set_attr "modrm" "0,*")
1358    (set_attr "length_address" "8,0")
1359    (set_attr "length_immediate" "0")
1360    (set_attr "memory" "load")
1361    (set_attr "mode" "HI")])
1363 (define_insn "*swaphi_1"
1364   [(set (match_operand:HI 0 "register_operand" "+r")
1365         (match_operand:HI 1 "register_operand" "+r"))
1366    (set (match_dup 1)
1367         (match_dup 0))]
1368   "TARGET_PARTIAL_REG_STALL"
1369   "xchg{w}\t%1, %0"
1370   [(set_attr "type" "imov")
1371    (set_attr "pent_pair" "np")
1372    (set_attr "mode" "HI")
1373    (set_attr "modrm" "0")
1374    (set_attr "ppro_uops" "few")])
1376 (define_insn "*swaphi_2"
1377   [(set (match_operand:HI 0 "register_operand" "+r")
1378         (match_operand:HI 1 "register_operand" "+r"))
1379    (set (match_dup 1)
1380         (match_dup 0))]
1381   "! TARGET_PARTIAL_REG_STALL"
1382   "xchg{l}\t%k1, %k0"
1383   [(set_attr "type" "imov")
1384    (set_attr "pent_pair" "np")
1385    (set_attr "mode" "SI")
1386    (set_attr "modrm" "0")
1387    (set_attr "ppro_uops" "few")])
1389 (define_expand "movstricthi"
1390   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1391         (match_operand:HI 1 "general_operand" ""))]
1392   "! TARGET_PARTIAL_REG_STALL || optimize_size"
1394   /* Don't generate memory->memory moves, go through a register */
1395   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1396     operands[1] = force_reg (HImode, operands[1]);
1399 (define_insn "*movstricthi_1"
1400   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1401         (match_operand:HI 1 "general_operand" "rn,m"))]
1402   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1403    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1404   "mov{w}\t{%1, %0|%0, %1}"
1405   [(set_attr "type" "imov")
1406    (set_attr "mode" "HI")])
1408 (define_insn "*movstricthi_xor"
1409   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1410         (match_operand:HI 1 "const0_operand" "i"))
1411    (clobber (reg:CC 17))]
1412   "reload_completed
1413    && ((!TARGET_USE_MOV0 && !TARGET_PARTIAL_REG_STALL) || optimize_size)"
1414   "xor{w}\t{%0, %0|%0, %0}"
1415   [(set_attr "type" "alu1")
1416    (set_attr "mode" "HI")
1417    (set_attr "length_immediate" "0")])
1419 (define_expand "movqi"
1420   [(set (match_operand:QI 0 "nonimmediate_operand" "")
1421         (match_operand:QI 1 "general_operand" ""))]
1422   ""
1423   "ix86_expand_move (QImode, operands); DONE;")
1425 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1426 ;; "push a byte".  But actually we use pushw, which has the effect
1427 ;; of rounding the amount pushed up to a halfword.
1429 (define_insn "*pushqi2"
1430   [(set (match_operand:QI 0 "push_operand" "=X,X")
1431         (match_operand:QI 1 "nonmemory_no_elim_operand" "n,r"))]
1432   "!TARGET_64BIT"
1433   "@
1434    push{w}\t{|word ptr }%1
1435    push{w}\t%w1"
1436   [(set_attr "type" "push")
1437    (set_attr "mode" "HI")])
1439 ;; For 64BIT abi we always round up to 8 bytes.
1440 (define_insn "*pushqi2_rex64"
1441   [(set (match_operand:QI 0 "push_operand" "=X")
1442         (match_operand:QI 1 "nonmemory_no_elim_operand" "qi"))]
1443   "TARGET_64BIT"
1444   "push{q}\t%q1"
1445   [(set_attr "type" "push")
1446    (set_attr "mode" "QI")])
1448 ;; Situation is quite tricky about when to choose full sized (SImode) move
1449 ;; over QImode moves.  For Q_REG -> Q_REG move we use full size only for
1450 ;; partial register dependency machines (such as AMD Athlon), where QImode
1451 ;; moves issue extra dependency and for partial register stalls machines
1452 ;; that don't use QImode patterns (and QImode move cause stall on the next
1453 ;; instruction).
1455 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
1456 ;; register stall machines with, where we use QImode instructions, since
1457 ;; partial register stall can be caused there.  Then we use movzx.
1458 (define_insn "*movqi_1"
1459   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
1460         (match_operand:QI 1 "general_operand"      " q,qn,qm,q,rn,qm,qn"))]
1461   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1463   switch (get_attr_type (insn))
1464     {
1465     case TYPE_IMOVX:
1466       if (!ANY_QI_REG_P (operands[1]) && GET_CODE (operands[1]) != MEM)
1467         abort ();
1468       return "movz{bl|x}\t{%1, %k0|%k0, %1}";
1469     default:
1470       if (get_attr_mode (insn) == MODE_SI)
1471         return "mov{l}\t{%k1, %k0|%k0, %k1}";
1472       else
1473         return "mov{b}\t{%1, %0|%0, %1}";
1474     }
1476   [(set (attr "type")
1477      (cond [(and (eq_attr "alternative" "3")
1478                  (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1479                           (const_int 0))
1480                       (eq (symbol_ref "TARGET_QIMODE_MATH")
1481                           (const_int 0))))
1482               (const_string "imov")
1483             (eq_attr "alternative" "3,5")
1484               (const_string "imovx")
1485             (and (ne (symbol_ref "TARGET_MOVX")
1486                      (const_int 0))
1487                  (eq_attr "alternative" "2"))
1488               (const_string "imovx")
1489            ]
1490            (const_string "imov")))
1491    (set (attr "mode")
1492       (cond [(eq_attr "alternative" "3,4,5")
1493                (const_string "SI")
1494              (eq_attr "alternative" "6")
1495                (const_string "QI")
1496              (eq_attr "type" "imovx")
1497                (const_string "SI")
1498              (and (eq_attr "type" "imov")
1499                   (and (eq_attr "alternative" "0,1,2")
1500                        (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
1501                            (const_int 0))))
1502                (const_string "SI")
1503              ;; Avoid partial register stalls when not using QImode arithmetic
1504              (and (eq_attr "type" "imov")
1505                   (and (eq_attr "alternative" "0,1,2")
1506                        (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
1507                                 (const_int 0))
1508                             (eq (symbol_ref "TARGET_QIMODE_MATH")
1509                                 (const_int 0)))))
1510                (const_string "SI")
1511            ]
1512            (const_string "QI")))])
1514 (define_expand "reload_outqi"
1515   [(parallel [(match_operand:QI 0 "" "=m")
1516               (match_operand:QI 1 "register_operand" "r")
1517               (match_operand:QI 2 "register_operand" "=&q")])]
1518   ""
1520   rtx op0, op1, op2;
1521   op0 = operands[0]; op1 = operands[1]; op2 = operands[2];
1523   if (reg_overlap_mentioned_p (op2, op0))
1524     abort ();
1525   if (! q_regs_operand (op1, QImode))
1526     {
1527       emit_insn (gen_movqi (op2, op1));
1528       op1 = op2;
1529     }
1530   emit_insn (gen_movqi (op0, op1));
1531   DONE;
1534 (define_insn "*swapqi"
1535   [(set (match_operand:QI 0 "register_operand" "+r")
1536         (match_operand:QI 1 "register_operand" "+r"))
1537    (set (match_dup 1)
1538         (match_dup 0))]
1539   ""
1540   "xchg{b}\t%1, %0"
1541   [(set_attr "type" "imov")
1542    (set_attr "pent_pair" "np")
1543    (set_attr "mode" "QI")
1544    (set_attr "modrm" "0")
1545    (set_attr "ppro_uops" "few")])
1547 (define_expand "movstrictqi"
1548   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
1549         (match_operand:QI 1 "general_operand" ""))]
1550   "! TARGET_PARTIAL_REG_STALL"
1552   /* Don't generate memory->memory moves, go through a register.  */
1553   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1554     operands[1] = force_reg (QImode, operands[1]);
1557 (define_insn "*movstrictqi_1"
1558   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
1559         (match_operand:QI 1 "general_operand" "*qn,m"))]
1560   "! TARGET_PARTIAL_REG_STALL
1561    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1562   "mov{b}\t{%1, %0|%0, %1}"
1563   [(set_attr "type" "imov")
1564    (set_attr "mode" "QI")])
1566 (define_insn "*movstrictqi_xor"
1567   [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
1568         (match_operand:QI 1 "const0_operand" "i"))
1569    (clobber (reg:CC 17))]
1570   "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1571   "xor{b}\t{%0, %0|%0, %0}"
1572   [(set_attr "type" "alu1")
1573    (set_attr "mode" "QI")
1574    (set_attr "length_immediate" "0")])
1576 (define_insn "*movsi_extv_1"
1577   [(set (match_operand:SI 0 "register_operand" "=R")
1578         (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
1579                          (const_int 8)
1580                          (const_int 8)))]
1581   ""
1582   "movs{bl|x}\t{%h1, %0|%0, %h1}"
1583   [(set_attr "type" "imovx")
1584    (set_attr "mode" "SI")])
1586 (define_insn "*movhi_extv_1"
1587   [(set (match_operand:HI 0 "register_operand" "=R")
1588         (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
1589                          (const_int 8)
1590                          (const_int 8)))]
1591   ""
1592   "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
1593   [(set_attr "type" "imovx")
1594    (set_attr "mode" "SI")])
1596 (define_insn "*movqi_extv_1"
1597   [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
1598         (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
1599                          (const_int 8)
1600                          (const_int 8)))]
1601   "!TARGET_64BIT"
1603   switch (get_attr_type (insn))
1604     {
1605     case TYPE_IMOVX:
1606       return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
1607     default:
1608       return "mov{b}\t{%h1, %0|%0, %h1}";
1609     }
1611   [(set (attr "type")
1612      (if_then_else (and (match_operand:QI 0 "register_operand" "")
1613                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1614                              (ne (symbol_ref "TARGET_MOVX")
1615                                  (const_int 0))))
1616         (const_string "imovx")
1617         (const_string "imov")))
1618    (set (attr "mode")
1619      (if_then_else (eq_attr "type" "imovx")
1620         (const_string "SI")
1621         (const_string "QI")))])
1623 (define_insn "*movqi_extv_1_rex64"
1624   [(set (match_operand:QI 0 "register_operand" "=Q,?R")
1625         (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
1626                          (const_int 8)
1627                          (const_int 8)))]
1628   "TARGET_64BIT"
1630   switch (get_attr_type (insn))
1631     {
1632     case TYPE_IMOVX:
1633       return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
1634     default:
1635       return "mov{b}\t{%h1, %0|%0, %h1}";
1636     }
1638   [(set (attr "type")
1639      (if_then_else (and (match_operand:QI 0 "register_operand" "")
1640                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1641                              (ne (symbol_ref "TARGET_MOVX")
1642                                  (const_int 0))))
1643         (const_string "imovx")
1644         (const_string "imov")))
1645    (set (attr "mode")
1646      (if_then_else (eq_attr "type" "imovx")
1647         (const_string "SI")
1648         (const_string "QI")))])
1650 ;; Stores and loads of ax to arbitrary constant address.
1651 ;; We fake an second form of instruction to force reload to load address
1652 ;; into register when rax is not available
1653 (define_insn "*movabsqi_1_rex64"
1654   [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1655         (match_operand:QI 1 "nonmemory_operand" "a,er,i"))]
1656   "TARGET_64BIT"
1657   "@
1658    movabs{b}\t{%1, %P0|%P0, %1}
1659    mov{b}\t{%1, %a0|%a0, %1}
1660    movabs{b}\t{%1, %a0|%a0, %1}"
1661   [(set_attr "type" "imov")
1662    (set_attr "modrm" "0,*,*")
1663    (set_attr "length_address" "8,0,0")
1664    (set_attr "length_immediate" "0,*,*")
1665    (set_attr "memory" "store")
1666    (set_attr "mode" "QI")])
1668 (define_insn "*movabsqi_2_rex64"
1669   [(set (match_operand:QI 0 "register_operand" "=a,r")
1670         (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1671   "TARGET_64BIT"
1672   "@
1673    movabs{b}\t{%P1, %0|%0, %P1}
1674    mov{b}\t{%a1, %0|%0, %a1}"
1675   [(set_attr "type" "imov")
1676    (set_attr "modrm" "0,*")
1677    (set_attr "length_address" "8,0")
1678    (set_attr "length_immediate" "0")
1679    (set_attr "memory" "load")
1680    (set_attr "mode" "QI")])
1682 (define_insn "*movsi_extzv_1"
1683   [(set (match_operand:SI 0 "register_operand" "=R")
1684         (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
1685                          (const_int 8)
1686                          (const_int 8)))]
1687   ""
1688   "movz{bl|x}\t{%h1, %0|%0, %h1}"
1689   [(set_attr "type" "imovx")
1690    (set_attr "mode" "SI")])
1692 (define_insn "*movqi_extzv_2"
1693   [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
1694         (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
1695                                     (const_int 8)
1696                                     (const_int 8)) 0))]
1697   "!TARGET_64BIT"
1699   switch (get_attr_type (insn))
1700     {
1701     case TYPE_IMOVX:
1702       return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
1703     default:
1704       return "mov{b}\t{%h1, %0|%0, %h1}";
1705     }
1707   [(set (attr "type")
1708      (if_then_else (and (match_operand:QI 0 "register_operand" "")
1709                         (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1710                              (ne (symbol_ref "TARGET_MOVX")
1711                                  (const_int 0))))
1712         (const_string "imovx")
1713         (const_string "imov")))
1714    (set (attr "mode")
1715      (if_then_else (eq_attr "type" "imovx")
1716         (const_string "SI")
1717         (const_string "QI")))])
1719 (define_insn "*movqi_extzv_2_rex64"
1720   [(set (match_operand:QI 0 "register_operand" "=Q,?R")
1721         (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
1722                                     (const_int 8)
1723                                     (const_int 8)) 0))]
1724   "TARGET_64BIT"
1726   switch (get_attr_type (insn))
1727     {
1728     case TYPE_IMOVX:
1729       return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
1730     default:
1731       return "mov{b}\t{%h1, %0|%0, %h1}";
1732     }
1734   [(set (attr "type")
1735      (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1736                         (ne (symbol_ref "TARGET_MOVX")
1737                             (const_int 0)))
1738         (const_string "imovx")
1739         (const_string "imov")))
1740    (set (attr "mode")
1741      (if_then_else (eq_attr "type" "imovx")
1742         (const_string "SI")
1743         (const_string "QI")))])
1745 (define_insn "movsi_insv_1"
1746   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
1747                          (const_int 8)
1748                          (const_int 8))
1749         (match_operand:SI 1 "general_operand" "Qmn"))]
1750   "!TARGET_64BIT"
1751   "mov{b}\t{%b1, %h0|%h0, %b1}"
1752   [(set_attr "type" "imov")
1753    (set_attr "mode" "QI")])
1755 (define_insn "*movsi_insv_1_rex64"
1756   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
1757                          (const_int 8)
1758                          (const_int 8))
1759         (match_operand:SI 1 "nonmemory_operand" "Qn"))]
1760   "TARGET_64BIT"
1761   "mov{b}\t{%b1, %h0|%h0, %b1}"
1762   [(set_attr "type" "imov")
1763    (set_attr "mode" "QI")])
1765 (define_insn "*movqi_insv_2"
1766   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
1767                          (const_int 8)
1768                          (const_int 8))
1769         (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
1770                              (const_int 8))
1771                 (const_int 255)))]
1772   ""
1773   "mov{b}\t{%h1, %h0|%h0, %h1}"
1774   [(set_attr "type" "imov")
1775    (set_attr "mode" "QI")])
1777 (define_expand "movdi"
1778   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1779         (match_operand:DI 1 "general_operand" ""))]
1780   ""
1781   "ix86_expand_move (DImode, operands); DONE;")
1783 (define_insn "*pushdi"
1784   [(set (match_operand:DI 0 "push_operand" "=<")
1785         (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
1786   "!TARGET_64BIT"
1787   "#")
1789 (define_insn "pushdi2_rex64"
1790   [(set (match_operand:DI 0 "push_operand" "=<,!<")
1791         (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
1792   "TARGET_64BIT"
1793   "@
1794    push{q}\t%1
1795    #"
1796   [(set_attr "type" "push,multi")
1797    (set_attr "mode" "DI")])
1799 ;; Convert impossible pushes of immediate to existing instructions.
1800 ;; First try to get scratch register and go through it.  In case this
1801 ;; fails, push sign extended lower part first and then overwrite
1802 ;; upper part by 32bit move.
1803 (define_peephole2
1804   [(match_scratch:DI 2 "r")
1805    (set (match_operand:DI 0 "push_operand" "")
1806         (match_operand:DI 1 "immediate_operand" ""))]
1807   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1808    && !x86_64_immediate_operand (operands[1], DImode)"
1809   [(set (match_dup 2) (match_dup 1))
1810    (set (match_dup 0) (match_dup 2))]
1811   "")
1813 ;; We need to define this as both peepholer and splitter for case
1814 ;; peephole2 pass is not run.
1815 (define_peephole2
1816   [(set (match_operand:DI 0 "push_operand" "")
1817         (match_operand:DI 1 "immediate_operand" ""))]
1818   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1819    && !x86_64_immediate_operand (operands[1], DImode) && 1"
1820   [(set (match_dup 0) (match_dup 1))
1821    (set (match_dup 2) (match_dup 3))]
1822   "split_di (operands + 1, 1, operands + 2, operands + 3);
1823    operands[1] = gen_lowpart (DImode, operands[2]);
1824    operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1825                                                     GEN_INT (4)));
1826   ")
1828 (define_split
1829   [(set (match_operand:DI 0 "push_operand" "")
1830         (match_operand:DI 1 "immediate_operand" ""))]
1831   "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2))
1832    && !symbolic_operand (operands[1], DImode)
1833    && !x86_64_immediate_operand (operands[1], DImode)"
1834   [(set (match_dup 0) (match_dup 1))
1835    (set (match_dup 2) (match_dup 3))]
1836   "split_di (operands + 1, 1, operands + 2, operands + 3);
1837    operands[1] = gen_lowpart (DImode, operands[2]);
1838    operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
1839                                                     GEN_INT (4)));
1840   ")
1842 (define_insn "*pushdi2_prologue_rex64"
1843   [(set (match_operand:DI 0 "push_operand" "=<")
1844         (match_operand:DI 1 "general_no_elim_operand" "re*m"))
1845    (clobber (mem:BLK (scratch)))]
1846   "TARGET_64BIT"
1847   "push{q}\t%1"
1848   [(set_attr "type" "push")
1849    (set_attr "mode" "DI")])
1851 (define_insn "*popdi1_epilogue_rex64"
1852   [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
1853         (mem:DI (reg:DI 7)))
1854    (set (reg:DI 7)
1855         (plus:DI (reg:DI 7) (const_int 8)))
1856    (clobber (mem:BLK (scratch)))]
1857   "TARGET_64BIT"
1858   "pop{q}\t%0"
1859   [(set_attr "type" "pop")
1860    (set_attr "mode" "DI")])
1862 (define_insn "popdi1"
1863   [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
1864         (mem:DI (reg:DI 7)))
1865    (set (reg:DI 7)
1866         (plus:DI (reg:DI 7) (const_int 8)))]
1867   "TARGET_64BIT"
1868   "pop{q}\t%0"
1869   [(set_attr "type" "pop")
1870    (set_attr "mode" "DI")])
1872 (define_insn "*movdi_xor_rex64"
1873   [(set (match_operand:DI 0 "register_operand" "=r")
1874         (match_operand:DI 1 "const0_operand" "i"))
1875    (clobber (reg:CC 17))]
1876   "TARGET_64BIT && (!TARGET_USE_MOV0 || optimize_size)
1877    && reload_completed"
1878   "xor{l}\t{%k0, %k0|%k0, %k0}"
1879   [(set_attr "type" "alu1")
1880    (set_attr "mode" "SI")
1881    (set_attr "length_immediate" "0")])
1883 (define_insn "*movdi_or_rex64"
1884   [(set (match_operand:DI 0 "register_operand" "=r")
1885         (match_operand:DI 1 "const_int_operand" "i"))
1886    (clobber (reg:CC 17))]
1887   "TARGET_64BIT && (TARGET_PENTIUM || optimize_size)
1888    && reload_completed
1889    && GET_CODE (operands[1]) == CONST_INT
1890    && INTVAL (operands[1]) == -1"
1892   operands[1] = constm1_rtx;
1893   return "or{q}\t{%1, %0|%0, %1}";
1895   [(set_attr "type" "alu1")
1896    (set_attr "mode" "DI")
1897    (set_attr "length_immediate" "1")])
1899 (define_insn "*movdi_2"
1900   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,!m*y,!*y,!m,!*Y,!*Y")
1901         (match_operand:DI 1 "general_operand" "riFo,riF,*y,m,*Y,*Y,m"))]
1902   "!TARGET_64BIT
1903    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1904   "@
1905    #
1906    #
1907    movq\t{%1, %0|%0, %1}
1908    movq\t{%1, %0|%0, %1}
1909    movq\t{%1, %0|%0, %1}
1910    movdqa\t{%1, %0|%0, %1}
1911    movq\t{%1, %0|%0, %1}"
1912   [(set_attr "type" "*,*,mmx,mmx,ssemov,ssemov,ssemov")
1913    (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI")])
1915 (define_split
1916   [(set (match_operand:DI 0 "push_operand" "")
1917         (match_operand:DI 1 "general_operand" ""))]
1918   "!TARGET_64BIT && reload_completed
1919    && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
1920   [(const_int 0)]
1921   "ix86_split_long_move (operands); DONE;")
1923 ;; %%% This multiword shite has got to go.
1924 (define_split
1925   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1926         (match_operand:DI 1 "general_operand" ""))]
1927   "!TARGET_64BIT && reload_completed
1928    && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
1929    && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
1930   [(const_int 0)]
1931   "ix86_split_long_move (operands); DONE;")
1933 (define_insn "*movdi_1_rex64"
1934   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,mr,!mr,!m*y,!*y,!*Y,!m,!*Y")
1935         (match_operand:DI 1 "general_operand" "Z,rem,i,re,n,*y,m,*Y,*Y,*m"))]
1936   "TARGET_64BIT
1937    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1939   switch (get_attr_type (insn))
1940     {
1941     case TYPE_SSEMOV:
1942       if (register_operand (operands[0], DImode)
1943           && register_operand (operands[1], DImode))
1944           return "movdqa\t{%1, %0|%0, %1}";
1945       /* FALLTHRU */
1946     case TYPE_MMXMOV:
1947       return "movq\t{%1, %0|%0, %1}";
1948     case TYPE_MULTI:
1949       return "#";
1950     case TYPE_LEA:
1951       return "lea{q}\t{%a1, %0|%0, %a1}";
1952     default:
1953       if (flag_pic && !LEGITIMATE_PIC_OPERAND_P (operands[1]))
1954         abort ();
1955       if (get_attr_mode (insn) == MODE_SI)
1956         return "mov{l}\t{%k1, %k0|%k0, %k1}";
1957       else if (which_alternative == 2)
1958         return "movabs{q}\t{%1, %0|%0, %1}";
1959       else
1960         return "mov{q}\t{%1, %0|%0, %1}";
1961     }
1963   [(set (attr "type")
1964      (cond [(eq_attr "alternative" "5,6")
1965               (const_string "mmxmov")
1966             (eq_attr "alternative" "7,8")
1967               (const_string "ssemov")
1968             (eq_attr "alternative" "4")
1969               (const_string "multi")
1970             (and (ne (symbol_ref "flag_pic") (const_int 0))
1971                  (match_operand:DI 1 "symbolic_operand" ""))
1972               (const_string "lea")
1973            ]
1974            (const_string "imov")))
1975    (set_attr "modrm" "*,0,0,*,*,*,*,*,*,*")
1976    (set_attr "length_immediate" "*,4,8,*,*,*,*,*,*,*")
1977    (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,TI,DI")])
1979 ;; Stores and loads of ax to arbitrary constant address.
1980 ;; We fake an second form of instruction to force reload to load address
1981 ;; into register when rax is not available
1982 (define_insn "*movabsdi_1_rex64"
1983   [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1984         (match_operand:DI 1 "nonmemory_operand" "a,er,i"))]
1985   "TARGET_64BIT"
1986   "@
1987    movabs{q}\t{%1, %P0|%P0, %1}
1988    mov{q}\t{%1, %a0|%a0, %1}
1989    movabs{q}\t{%1, %a0|%a0, %1}"
1990   [(set_attr "type" "imov")
1991    (set_attr "modrm" "0,*,*")
1992    (set_attr "length_address" "8,0,0")
1993    (set_attr "length_immediate" "0,*,*")
1994    (set_attr "memory" "store")
1995    (set_attr "mode" "DI")])
1997 (define_insn "*movabsdi_2_rex64"
1998   [(set (match_operand:DI 0 "register_operand" "=a,r")
1999         (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2000   "TARGET_64BIT"
2001   "@
2002    movabs{q}\t{%P1, %0|%0, %P1}
2003    mov{q}\t{%a1, %0|%0, %a1}"
2004   [(set_attr "type" "imov")
2005    (set_attr "modrm" "0,*")
2006    (set_attr "length_address" "8,0")
2007    (set_attr "length_immediate" "0")
2008    (set_attr "memory" "load")
2009    (set_attr "mode" "DI")])
2011 ;; Convert impossible stores of immediate to existing instructions.
2012 ;; First try to get scratch register and go through it.  In case this
2013 ;; fails, move by 32bit parts.
2014 (define_peephole2
2015   [(match_scratch:DI 2 "r")
2016    (set (match_operand:DI 0 "memory_operand" "")
2017         (match_operand:DI 1 "immediate_operand" ""))]
2018   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2019    && !x86_64_immediate_operand (operands[1], DImode)"
2020   [(set (match_dup 2) (match_dup 1))
2021    (set (match_dup 0) (match_dup 2))]
2022   "")
2024 ;; We need to define this as both peepholer and splitter for case
2025 ;; peephole2 pass is not run.
2026 (define_peephole2
2027   [(set (match_operand:DI 0 "memory_operand" "")
2028         (match_operand:DI 1 "immediate_operand" ""))]
2029   "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2030    && !x86_64_immediate_operand (operands[1], DImode) && 1"
2031   [(set (match_dup 2) (match_dup 3))
2032    (set (match_dup 4) (match_dup 5))]
2033   "split_di (operands, 2, operands + 2, operands + 4);")
2035 (define_split
2036   [(set (match_operand:DI 0 "memory_operand" "")
2037         (match_operand:DI 1 "immediate_operand" ""))]
2038   "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2))
2039    && !symbolic_operand (operands[1], DImode)
2040    && !x86_64_immediate_operand (operands[1], DImode)"
2041   [(set (match_dup 2) (match_dup 3))
2042    (set (match_dup 4) (match_dup 5))]
2043   "split_di (operands, 2, operands + 2, operands + 4);")
2045 (define_insn "*swapdi_rex64"
2046   [(set (match_operand:DI 0 "register_operand" "+r")
2047         (match_operand:DI 1 "register_operand" "+r"))
2048    (set (match_dup 1)
2049         (match_dup 0))]
2050   "TARGET_64BIT"
2051   "xchg{q}\t%1, %0"
2052   [(set_attr "type" "imov")
2053    (set_attr "pent_pair" "np")
2054    (set_attr "athlon_decode" "vector")
2055    (set_attr "mode" "DI")
2056    (set_attr "modrm" "0")
2057    (set_attr "ppro_uops" "few")])
2059   
2060 (define_expand "movsf"
2061   [(set (match_operand:SF 0 "nonimmediate_operand" "")
2062         (match_operand:SF 1 "general_operand" ""))]
2063   ""
2064   "ix86_expand_move (SFmode, operands); DONE;")
2066 (define_insn "*pushsf"
2067   [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2068         (match_operand:SF 1 "general_no_elim_operand" "f#rx,rFm#fx,x#rf"))]
2069   "!TARGET_64BIT"
2071   switch (which_alternative)
2072     {
2073     case 1:
2074       return "push{l}\t%1";
2076     default:
2077       /* This insn should be already splitted before reg-stack.  */
2078       abort ();
2079     }
2081   [(set_attr "type" "multi,push,multi")
2082    (set_attr "mode" "SF,SI,SF")])
2084 (define_insn "*pushsf_rex64"
2085   [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2086         (match_operand:SF 1 "nonmemory_no_elim_operand" "f#rx,rF#fx,x#rf"))]
2087   "TARGET_64BIT"
2089   switch (which_alternative)
2090     {
2091     case 1:
2092       return "push{q}\t%q1";
2094     default:
2095       /* This insn should be already splitted before reg-stack.  */
2096       abort ();
2097     }
2099   [(set_attr "type" "multi,push,multi")
2100    (set_attr "mode" "SF,DI,SF")])
2102 (define_split
2103   [(set (match_operand:SF 0 "push_operand" "")
2104         (match_operand:SF 1 "memory_operand" ""))]
2105   "reload_completed
2106    && GET_CODE (operands[1]) == MEM
2107    && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2108    && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))"
2109   [(set (match_dup 0)
2110         (match_dup 1))]
2111   "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
2114 ;; %%% Kill this when call knows how to work this out.
2115 (define_split
2116   [(set (match_operand:SF 0 "push_operand" "")
2117         (match_operand:SF 1 "any_fp_register_operand" ""))]
2118   "!TARGET_64BIT"
2119   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
2120    (set (mem:SF (reg:SI 7)) (match_dup 1))])
2122 (define_split
2123   [(set (match_operand:SF 0 "push_operand" "")
2124         (match_operand:SF 1 "any_fp_register_operand" ""))]
2125   "TARGET_64BIT"
2126   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
2127    (set (mem:SF (reg:DI 7)) (match_dup 1))])
2129 (define_insn "*movsf_1"
2130   [(set (match_operand:SF 0 "nonimmediate_operand" "=f#xr,m,f#xr,r#xf,m,x#rf,x#rf,x#rf,m,!*y,!rm,!*y")
2131         (match_operand:SF 1 "general_operand" "fm#rx,f#rx,G,rmF#fx,Fr#fx,C,x,xm#rf,x#rf,rm,*y,*y"))]
2132   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2133    && (reload_in_progress || reload_completed
2134        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2135        || GET_CODE (operands[1]) != CONST_DOUBLE
2136        || memory_operand (operands[0], SFmode))" 
2138   switch (which_alternative)
2139     {
2140     case 0:
2141       if (REG_P (operands[1])
2142           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2143         {
2144           if (REGNO (operands[0]) == FIRST_STACK_REG
2145               && TARGET_USE_FFREEP)
2146             return "ffreep\t%y0";
2147           return "fstp\t%y0";
2148         }
2149       else if (STACK_TOP_P (operands[0]))
2150         return "fld%z1\t%y1";
2151       else
2152         return "fst\t%y0";
2154     case 1:
2155       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2156         return "fstp%z0\t%y0";
2157       else
2158         return "fst%z0\t%y0";
2160     case 2:
2161       switch (standard_80387_constant_p (operands[1]))
2162         {
2163         case 1:
2164           return "fldz";
2165         case 2:
2166           return "fld1";
2167         }
2168       abort();
2170     case 3:
2171     case 4:
2172       return "mov{l}\t{%1, %0|%0, %1}";
2173     case 5:
2174       if (get_attr_mode (insn) == MODE_TI)
2175         return "pxor\t%0, %0";
2176       else
2177         return "xorps\t%0, %0";
2178     case 6:
2179       if (get_attr_mode (insn) == MODE_V4SF)
2180         return "movaps\t{%1, %0|%0, %1}";
2181       else
2182         return "movss\t{%1, %0|%0, %1}";
2183     case 7:
2184     case 8:
2185       return "movss\t{%1, %0|%0, %1}";
2187     case 9:
2188     case 10:
2189       return "movd\t{%1, %0|%0, %1}";
2191     case 11:
2192       return "movq\t{%1, %0|%0, %1}";
2194     default:
2195       abort();
2196     }
2198   [(set_attr "type" "fmov,fmov,fmov,imov,imov,ssemov,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov")
2199    (set (attr "mode")
2200         (cond [(eq_attr "alternative" "3,4,9,10")
2201                  (const_string "SI")
2202                (eq_attr "alternative" "5")
2203                  (if_then_else
2204                    (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2205                                  (const_int 0))
2206                              (ne (symbol_ref "TARGET_SSE2")
2207                                  (const_int 0)))
2208                         (eq (symbol_ref "optimize_size")
2209                             (const_int 0)))
2210                    (const_string "TI")
2211                    (const_string "V4SF"))
2212                /* For architectures resolving dependencies on
2213                   whole SSE registers use APS move to break dependency
2214                   chains, otherwise use short move to avoid extra work. 
2216                   Do the same for architectures resolving dependencies on
2217                   the parts.  While in DF mode it is better to always handle
2218                   just register parts, the SF mode is different due to lack
2219                   of instructions to load just part of the register.  It is
2220                   better to maintain the whole registers in single format
2221                   to avoid problems on using packed logical operations.  */
2222                (eq_attr "alternative" "6")
2223                  (if_then_else
2224                    (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2225                             (const_int 0))
2226                         (ne (symbol_ref "TARGET_SSE_PARTIAL_REGS")
2227                             (const_int 0)))
2228                    (const_string "V4SF")
2229                    (const_string "SF"))
2230                (eq_attr "alternative" "11")
2231                  (const_string "DI")]
2232                (const_string "SF")))])
2234 (define_insn "*swapsf"
2235   [(set (match_operand:SF 0 "register_operand" "+f")
2236         (match_operand:SF 1 "register_operand" "+f"))
2237    (set (match_dup 1)
2238         (match_dup 0))]
2239   "reload_completed || !TARGET_SSE"
2241   if (STACK_TOP_P (operands[0]))
2242     return "fxch\t%1";
2243   else
2244     return "fxch\t%0";
2246   [(set_attr "type" "fxch")
2247    (set_attr "mode" "SF")])
2249 (define_expand "movdf"
2250   [(set (match_operand:DF 0 "nonimmediate_operand" "")
2251         (match_operand:DF 1 "general_operand" ""))]
2252   ""
2253   "ix86_expand_move (DFmode, operands); DONE;")
2255 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2256 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2257 ;; On the average, pushdf using integers can be still shorter.  Allow this
2258 ;; pattern for optimize_size too.
2260 (define_insn "*pushdf_nointeger"
2261   [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2262         (match_operand:DF 1 "general_no_elim_operand" "f#Y,Fo#fY,*r#fY,Y#f"))]
2263   "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
2265   /* This insn should be already splitted before reg-stack.  */
2266   abort ();
2268   [(set_attr "type" "multi")
2269    (set_attr "mode" "DF,SI,SI,DF")])
2271 (define_insn "*pushdf_integer"
2272   [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2273         (match_operand:DF 1 "general_no_elim_operand" "f#rY,rFo#fY,Y#rf"))]
2274   "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2276   /* This insn should be already splitted before reg-stack.  */
2277   abort ();
2279   [(set_attr "type" "multi")
2280    (set_attr "mode" "DF,SI,DF")])
2282 ;; %%% Kill this when call knows how to work this out.
2283 (define_split
2284   [(set (match_operand:DF 0 "push_operand" "")
2285         (match_operand:DF 1 "any_fp_register_operand" ""))]
2286   "!TARGET_64BIT && reload_completed"
2287   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
2288    (set (mem:DF (reg:SI 7)) (match_dup 1))]
2289   "")
2291 (define_split
2292   [(set (match_operand:DF 0 "push_operand" "")
2293         (match_operand:DF 1 "any_fp_register_operand" ""))]
2294   "TARGET_64BIT && reload_completed"
2295   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
2296    (set (mem:DF (reg:DI 7)) (match_dup 1))]
2297   "")
2299 (define_split
2300   [(set (match_operand:DF 0 "push_operand" "")
2301         (match_operand:DF 1 "general_operand" ""))]
2302   "reload_completed"
2303   [(const_int 0)]
2304   "ix86_split_long_move (operands); DONE;")
2306 ;; Moving is usually shorter when only FP registers are used. This separate
2307 ;; movdf pattern avoids the use of integer registers for FP operations
2308 ;; when optimizing for size.
2310 (define_insn "*movdf_nointeger"
2311   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,m,f#Y,*r,o,Y#f,Y#f,Y#f,m")
2312         (match_operand:DF 1 "general_operand" "fm#Y,f#Y,G,*roF,F*r,C,Y#f,YHm#f,Y#f"))]
2313   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2314    && ((optimize_size || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
2315    && (reload_in_progress || reload_completed
2316        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2317        || GET_CODE (operands[1]) != CONST_DOUBLE
2318        || memory_operand (operands[0], DFmode))" 
2320   switch (which_alternative)
2321     {
2322     case 0:
2323       if (REG_P (operands[1])
2324           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2325         {
2326           if (REGNO (operands[0]) == FIRST_STACK_REG
2327               && TARGET_USE_FFREEP)
2328             return "ffreep\t%y0";
2329           return "fstp\t%y0";
2330         }
2331       else if (STACK_TOP_P (operands[0]))
2332         return "fld%z1\t%y1";
2333       else
2334         return "fst\t%y0";
2336     case 1:
2337       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2338         return "fstp%z0\t%y0";
2339       else
2340         return "fst%z0\t%y0";
2342     case 2:
2343       switch (standard_80387_constant_p (operands[1]))
2344         {
2345         case 1:
2346           return "fldz";
2347         case 2:
2348           return "fld1";
2349         }
2350       abort();
2352     case 3:
2353     case 4:
2354       return "#";
2355     case 5:
2356       switch (get_attr_mode (insn))
2357         {
2358         case MODE_V4SF:
2359           return "xorps\t%0, %0";
2360         case MODE_V2DF:
2361           return "xorpd\t%0, %0";
2362         case MODE_TI:
2363           return "pxor\t%0, %0";
2364         default:
2365           abort ();
2366         }
2367     case 6:
2368       switch (get_attr_mode (insn))
2369         {
2370         case MODE_V4SF:
2371           return "movaps\t{%1, %0|%0, %1}";
2372         case MODE_V2DF:
2373           return "movapd\t{%1, %0|%0, %1}";
2374         case MODE_DF:
2375           return "movsd\t{%1, %0|%0, %1}";
2376         default:
2377           abort ();
2378         }
2379     case 7:
2380       if (get_attr_mode (insn) == MODE_V2DF)
2381         return "movlpd\t{%1, %0|%0, %1}";
2382       else
2383         return "movsd\t{%1, %0|%0, %1}";
2384     case 8:
2385       return "movsd\t{%1, %0|%0, %1}";
2387     default:
2388       abort();
2389     }
2391   [(set_attr "type" "fmov,fmov,fmov,multi,multi,ssemov,ssemov,ssemov,ssemov")
2392    (set (attr "mode")
2393         (cond [(eq_attr "alternative" "3,4")
2394                  (const_string "SI")
2395                /* xorps is one byte shorter.  */
2396                (eq_attr "alternative" "5")
2397                  (cond [(ne (symbol_ref "optimize_size")
2398                             (const_int 0))
2399                           (const_string "V4SF")
2400                         (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2401                             (const_int 0))
2402                           (const_string "TI")]
2403                        (const_string "V2DF"))
2404                /* For architectures resolving dependencies on
2405                   whole SSE registers use APD move to break dependency
2406                   chains, otherwise use short move to avoid extra work.
2408                   movaps encodes one byte shorter.  */
2409                (eq_attr "alternative" "6")
2410                  (cond
2411                   [(ne (symbol_ref "optimize_size")
2412                        (const_int 0))
2413                      (const_string "V4SF")
2414                    (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2415                        (const_int 0))
2416                      (const_string "V2DF")]
2417                    (const_string "DF"))
2418                /* For architectures resolving dependencies on register
2419                   parts we may avoid extra work to zero out upper part
2420                   of register.  */
2421                (eq_attr "alternative" "7")
2422                  (if_then_else
2423                    (ne (symbol_ref "TARGET_SSE_PARTIAL_REGS")
2424                        (const_int 0))
2425                    (const_string "V2DF")
2426                    (const_string "DF"))]
2427                (const_string "DF")))])
2429 (define_insn "*movdf_integer"
2430   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Yr,m,f#Yr,r#Yf,o,Y#rf,Y#rf,Y#rf,m")
2431         (match_operand:DF 1 "general_operand" "fm#Yr,f#Yr,G,roF#Yf,Fr#Yf,C,Y#rf,Ym#rf,Y#rf"))]
2432   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2433    && ((!optimize_size && TARGET_INTEGER_DFMODE_MOVES) || TARGET_64BIT)
2434    && (reload_in_progress || reload_completed
2435        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2436        || GET_CODE (operands[1]) != CONST_DOUBLE
2437        || memory_operand (operands[0], DFmode))" 
2439   switch (which_alternative)
2440     {
2441     case 0:
2442       if (REG_P (operands[1])
2443           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2444         {
2445           if (REGNO (operands[0]) == FIRST_STACK_REG
2446               && TARGET_USE_FFREEP)
2447             return "ffreep\t%y0";
2448           return "fstp\t%y0";
2449         }
2450       else if (STACK_TOP_P (operands[0]))
2451         return "fld%z1\t%y1";
2452       else
2453         return "fst\t%y0";
2455     case 1:
2456       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2457         return "fstp%z0\t%y0";
2458       else
2459         return "fst%z0\t%y0";
2461     case 2:
2462       switch (standard_80387_constant_p (operands[1]))
2463         {
2464         case 1:
2465           return "fldz";
2466         case 2:
2467           return "fld1";
2468         }
2469       abort();
2471     case 3:
2472     case 4:
2473       return "#";
2475     case 5:
2476       switch (get_attr_mode (insn))
2477         {
2478         case MODE_V4SF:
2479           return "xorps\t%0, %0";
2480         case MODE_V2DF:
2481           return "xorpd\t%0, %0";
2482         case MODE_TI:
2483           return "pxor\t%0, %0";
2484         default:
2485           abort ();
2486         }
2487     case 6:
2488       switch (get_attr_mode (insn))
2489         {
2490         case MODE_V4SF:
2491           return "movaps\t{%1, %0|%0, %1}";
2492         case MODE_V2DF:
2493           return "movapd\t{%1, %0|%0, %1}";
2494         case MODE_DF:
2495           return "movsd\t{%1, %0|%0, %1}";
2496         default:
2497           abort ();
2498         }
2499     case 7:
2500       if (get_attr_mode (insn) == MODE_V2DF)
2501         return "movlpd\t{%1, %0|%0, %1}";
2502       else
2503         return "movsd\t{%1, %0|%0, %1}";
2504     case 8:
2505       return "movsd\t{%1, %0|%0, %1}";
2507     default:
2508       abort();
2509     }
2511   [(set_attr "type" "fmov,fmov,fmov,multi,multi,ssemov,ssemov,ssemov,ssemov")
2512    (set (attr "mode")
2513         (cond [(eq_attr "alternative" "3,4")
2514                  (const_string "SI")
2515                /* xorps is one byte shorter.  */
2516                (eq_attr "alternative" "5")
2517                  (cond [(ne (symbol_ref "optimize_size")
2518                             (const_int 0))
2519                           (const_string "V4SF")
2520                         (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2521                             (const_int 0))
2522                           (const_string "TI")]
2523                        (const_string "V2DF"))
2524                /* For architectures resolving dependencies on
2525                   whole SSE registers use APD move to break dependency
2526                   chains, otherwise use short move to avoid extra work.  
2528                   movaps encodes one byte shorter.  */
2529                (eq_attr "alternative" "6")
2530                  (cond
2531                   [(ne (symbol_ref "optimize_size")
2532                        (const_int 0))
2533                      (const_string "V4SF")
2534                    (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2535                        (const_int 0))
2536                      (const_string "V2DF")]
2537                    (const_string "DF"))
2538                /* For architectures resolving dependencies on register
2539                   parts we may avoid extra work to zero out upper part
2540                   of register.  */
2541                (eq_attr "alternative" "7")
2542                  (if_then_else
2543                    (ne (symbol_ref "TARGET_SSE_PARTIAL_REGS")
2544                        (const_int 0))
2545                    (const_string "V2DF")
2546                    (const_string "DF"))]
2547                (const_string "DF")))])
2549 (define_split
2550   [(set (match_operand:DF 0 "nonimmediate_operand" "")
2551         (match_operand:DF 1 "general_operand" ""))]
2552   "reload_completed
2553    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2554    && ! (ANY_FP_REG_P (operands[0]) || 
2555          (GET_CODE (operands[0]) == SUBREG
2556           && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
2557    && ! (ANY_FP_REG_P (operands[1]) || 
2558          (GET_CODE (operands[1]) == SUBREG
2559           && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
2560   [(const_int 0)]
2561   "ix86_split_long_move (operands); DONE;")
2563 (define_insn "*swapdf"
2564   [(set (match_operand:DF 0 "register_operand" "+f")
2565         (match_operand:DF 1 "register_operand" "+f"))
2566    (set (match_dup 1)
2567         (match_dup 0))]
2568   "reload_completed || !TARGET_SSE2"
2570   if (STACK_TOP_P (operands[0]))
2571     return "fxch\t%1";
2572   else
2573     return "fxch\t%0";
2575   [(set_attr "type" "fxch")
2576    (set_attr "mode" "DF")])
2578 (define_expand "movxf"
2579   [(set (match_operand:XF 0 "nonimmediate_operand" "")
2580         (match_operand:XF 1 "general_operand" ""))]
2581   "!TARGET_64BIT"
2582   "ix86_expand_move (XFmode, operands); DONE;")
2584 (define_expand "movtf"
2585   [(set (match_operand:TF 0 "nonimmediate_operand" "")
2586         (match_operand:TF 1 "general_operand" ""))]
2587   ""
2588   "ix86_expand_move (TFmode, operands); DONE;")
2590 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2591 ;; Size of pushdf using integer instructions is 3+3*memory operand size
2592 ;; Pushing using integer instructions is longer except for constants
2593 ;; and direct memory references.
2594 ;; (assuming that any given constant is pushed only once, but this ought to be
2595 ;;  handled elsewhere).
2597 (define_insn "*pushxf_nointeger"
2598   [(set (match_operand:XF 0 "push_operand" "=X,X,X")
2599         (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
2600   "!TARGET_64BIT && optimize_size"
2602   /* This insn should be already splitted before reg-stack.  */
2603   abort ();
2605   [(set_attr "type" "multi")
2606    (set_attr "mode" "XF,SI,SI")])
2608 (define_insn "*pushtf_nointeger"
2609   [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2610         (match_operand:TF 1 "general_no_elim_operand" "f,Fo,*r"))]
2611   "optimize_size"
2613   /* This insn should be already splitted before reg-stack.  */
2614   abort ();
2616   [(set_attr "type" "multi")
2617    (set_attr "mode" "XF,SI,SI")])
2619 (define_insn "*pushxf_integer"
2620   [(set (match_operand:XF 0 "push_operand" "=<,<")
2621         (match_operand:XF 1 "general_no_elim_operand" "f#r,ro#f"))]
2622   "!TARGET_64BIT && !optimize_size"
2624   /* This insn should be already splitted before reg-stack.  */
2625   abort ();
2627   [(set_attr "type" "multi")
2628    (set_attr "mode" "XF,SI")])
2630 (define_insn "*pushtf_integer"
2631   [(set (match_operand:TF 0 "push_operand" "=<,<")
2632         (match_operand:TF 1 "general_no_elim_operand" "f#r,rFo#f"))]
2633   "!optimize_size"
2635   /* This insn should be already splitted before reg-stack.  */
2636   abort ();
2638   [(set_attr "type" "multi")
2639    (set_attr "mode" "XF,SI")])
2641 (define_split
2642   [(set (match_operand 0 "push_operand" "")
2643         (match_operand 1 "general_operand" ""))]
2644   "reload_completed
2645    && (GET_MODE (operands[0]) == XFmode
2646        || GET_MODE (operands[0]) == TFmode
2647        || GET_MODE (operands[0]) == DFmode)
2648    && !ANY_FP_REG_P (operands[1])"
2649   [(const_int 0)]
2650   "ix86_split_long_move (operands); DONE;")
2652 (define_split
2653   [(set (match_operand:XF 0 "push_operand" "")
2654         (match_operand:XF 1 "any_fp_register_operand" ""))]
2655   "!TARGET_64BIT"
2656   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
2657    (set (mem:XF (reg:SI 7)) (match_dup 1))])
2659 (define_split
2660   [(set (match_operand:TF 0 "push_operand" "")
2661         (match_operand:TF 1 "any_fp_register_operand" ""))]
2662   "!TARGET_64BIT"
2663   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
2664    (set (mem:TF (reg:SI 7)) (match_dup 1))])
2666 (define_split
2667   [(set (match_operand:TF 0 "push_operand" "")
2668         (match_operand:TF 1 "any_fp_register_operand" ""))]
2669   "TARGET_64BIT"
2670   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
2671    (set (mem:TF (reg:DI 7)) (match_dup 1))])
2673 ;; Do not use integer registers when optimizing for size
2674 (define_insn "*movxf_nointeger"
2675   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2676         (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2677   "!TARGET_64BIT
2678    && optimize_size
2679    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2680    && (reload_in_progress || reload_completed
2681        || GET_CODE (operands[1]) != CONST_DOUBLE
2682        || memory_operand (operands[0], XFmode))" 
2684   switch (which_alternative)
2685     {
2686     case 0:
2687       if (REG_P (operands[1])
2688           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2689         {
2690           if (REGNO (operands[0]) == FIRST_STACK_REG
2691               && TARGET_USE_FFREEP)
2692             return "ffreep\t%y0";
2693           return "fstp\t%y0";
2694         }
2695       else if (STACK_TOP_P (operands[0]))
2696         return "fld%z1\t%y1";
2697       else
2698         return "fst\t%y0";
2700     case 1:
2701       /* There is no non-popping store to memory for XFmode.  So if
2702          we need one, follow the store with a load.  */
2703       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2704         return "fstp%z0\t%y0\;fld%z0\t%y0";
2705       else
2706         return "fstp%z0\t%y0";
2708     case 2:
2709       switch (standard_80387_constant_p (operands[1]))
2710         {
2711         case 1:
2712           return "fldz";
2713         case 2:
2714           return "fld1";
2715         }
2716       break;
2718     case 3: case 4:
2719       return "#";
2720     }
2721   abort();
2723   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2724    (set_attr "mode" "XF,XF,XF,SI,SI")])
2726 (define_insn "*movtf_nointeger"
2727   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m,f,*r,o")
2728         (match_operand:TF 1 "general_operand" "fm,f,G,*roF,F*r"))]
2729   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2730    && optimize_size
2731    && (reload_in_progress || reload_completed
2732        || GET_CODE (operands[1]) != CONST_DOUBLE
2733        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2734        || memory_operand (operands[0], TFmode))" 
2736   switch (which_alternative)
2737     {
2738     case 0:
2739       if (REG_P (operands[1])
2740           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2741         {
2742           if (REGNO (operands[0]) == FIRST_STACK_REG
2743               && TARGET_USE_FFREEP)
2744             return "ffreep\t%y0";
2745           return "fstp\t%y0";
2746         }
2747       else if (STACK_TOP_P (operands[0]))
2748         return "fld%z1\t%y1";
2749       else
2750         return "fst\t%y0";
2752     case 1:
2753       /* There is no non-popping store to memory for XFmode.  So if
2754          we need one, follow the store with a load.  */
2755       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2756         return "fstp%z0\t%y0\;fld%z0\t%y0";
2757       else
2758         return "fstp%z0\t%y0";
2760     case 2:
2761       switch (standard_80387_constant_p (operands[1]))
2762         {
2763         case 1:
2764           return "fldz";
2765         case 2:
2766           return "fld1";
2767         }
2768       break;
2770     case 3: case 4:
2771       return "#";
2772     }
2773   abort();
2775   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2776    (set_attr "mode" "XF,XF,XF,SI,SI")])
2778 (define_insn "*movxf_integer"
2779   [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
2780         (match_operand:XF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
2781   "!TARGET_64BIT
2782    && !optimize_size
2783    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2784    && (reload_in_progress || reload_completed
2785        || GET_CODE (operands[1]) != CONST_DOUBLE
2786        || memory_operand (operands[0], XFmode))" 
2788   switch (which_alternative)
2789     {
2790     case 0:
2791       if (REG_P (operands[1])
2792           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2793         {
2794           if (REGNO (operands[0]) == FIRST_STACK_REG
2795               && TARGET_USE_FFREEP)
2796             return "ffreep\t%y0";
2797           return "fstp\t%y0";
2798         }
2799       else if (STACK_TOP_P (operands[0]))
2800         return "fld%z1\t%y1";
2801       else
2802         return "fst\t%y0";
2804     case 1:
2805       /* There is no non-popping store to memory for XFmode.  So if
2806          we need one, follow the store with a load.  */
2807       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2808         return "fstp%z0\t%y0\;fld%z0\t%y0";
2809       else
2810         return "fstp%z0\t%y0";
2812     case 2:
2813       switch (standard_80387_constant_p (operands[1]))
2814         {
2815         case 1:
2816           return "fldz";
2817         case 2:
2818           return "fld1";
2819         }
2820       break;
2822     case 3: case 4:
2823       return "#";
2824     }
2825   abort();
2827   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2828    (set_attr "mode" "XF,XF,XF,SI,SI")])
2830 (define_insn "*movtf_integer"
2831   [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
2832         (match_operand:TF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
2833   "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2834    && !optimize_size
2835    && (reload_in_progress || reload_completed
2836        || GET_CODE (operands[1]) != CONST_DOUBLE
2837        || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2838        || memory_operand (operands[0], TFmode))" 
2840   switch (which_alternative)
2841     {
2842     case 0:
2843       if (REG_P (operands[1])
2844           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2845         {
2846           if (REGNO (operands[0]) == FIRST_STACK_REG
2847               && TARGET_USE_FFREEP)
2848             return "ffreep\t%y0";
2849           return "fstp\t%y0";
2850         }
2851       else if (STACK_TOP_P (operands[0]))
2852         return "fld%z1\t%y1";
2853       else
2854         return "fst\t%y0";
2856     case 1:
2857       /* There is no non-popping store to memory for XFmode.  So if
2858          we need one, follow the store with a load.  */
2859       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2860         return "fstp%z0\t%y0\;fld%z0\t%y0";
2861       else
2862         return "fstp%z0\t%y0";
2864     case 2:
2865       switch (standard_80387_constant_p (operands[1]))
2866         {
2867         case 1:
2868           return "fldz";
2869         case 2:
2870           return "fld1";
2871         }
2872       break;
2874     case 3: case 4:
2875       return "#";
2876     }
2877   abort();
2879   [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2880    (set_attr "mode" "XF,XF,XF,SI,SI")])
2882 (define_split
2883   [(set (match_operand 0 "nonimmediate_operand" "")
2884         (match_operand 1 "general_operand" ""))]
2885   "reload_completed
2886    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2887    && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode)
2888    && ! (ANY_FP_REG_P (operands[0]) || 
2889          (GET_CODE (operands[0]) == SUBREG
2890           && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
2891    && ! (ANY_FP_REG_P (operands[1]) || 
2892          (GET_CODE (operands[1]) == SUBREG
2893           && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
2894   [(const_int 0)]
2895   "ix86_split_long_move (operands); DONE;")
2897 (define_split
2898   [(set (match_operand 0 "register_operand" "")
2899         (match_operand 1 "memory_operand" ""))]
2900   "reload_completed
2901    && GET_CODE (operands[1]) == MEM
2902    && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode
2903        || GET_MODE (operands[0]) == SFmode || GET_MODE (operands[0]) == DFmode)
2904    && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2905    && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))
2906    && (!(SSE_REG_P (operands[0]) || 
2907          (GET_CODE (operands[0]) == SUBREG
2908           && SSE_REG_P (SUBREG_REG (operands[0]))))
2909        || standard_sse_constant_p (get_pool_constant (XEXP (operands[1], 0))))
2910    && (!(FP_REG_P (operands[0]) || 
2911          (GET_CODE (operands[0]) == SUBREG
2912           && FP_REG_P (SUBREG_REG (operands[0]))))
2913        || standard_80387_constant_p (get_pool_constant (XEXP (operands[1], 0))))"
2914   [(set (match_dup 0)
2915         (match_dup 1))]
2916   "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
2918 (define_insn "swapxf"
2919   [(set (match_operand:XF 0 "register_operand" "+f")
2920         (match_operand:XF 1 "register_operand" "+f"))
2921    (set (match_dup 1)
2922         (match_dup 0))]
2923   ""
2925   if (STACK_TOP_P (operands[0]))
2926     return "fxch\t%1";
2927   else
2928     return "fxch\t%0";
2930   [(set_attr "type" "fxch")
2931    (set_attr "mode" "XF")])
2933 (define_insn "swaptf"
2934   [(set (match_operand:TF 0 "register_operand" "+f")
2935         (match_operand:TF 1 "register_operand" "+f"))
2936    (set (match_dup 1)
2937         (match_dup 0))]
2938   ""
2940   if (STACK_TOP_P (operands[0]))
2941     return "fxch\t%1";
2942   else
2943     return "fxch\t%0";
2945   [(set_attr "type" "fxch")
2946    (set_attr "mode" "XF")])
2948 ;; Zero extension instructions
2950 (define_expand "zero_extendhisi2"
2951   [(set (match_operand:SI 0 "register_operand" "")
2952      (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "")))]
2953   ""
2955   if (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
2956     {
2957       operands[1] = force_reg (HImode, operands[1]);
2958       emit_insn (gen_zero_extendhisi2_and (operands[0], operands[1]));
2959       DONE;
2960     }
2963 (define_insn "zero_extendhisi2_and"
2964   [(set (match_operand:SI 0 "register_operand" "=r")
2965      (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))
2966    (clobber (reg:CC 17))]
2967   "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
2968   "#"
2969   [(set_attr "type" "alu1")
2970    (set_attr "mode" "SI")])
2972 (define_split
2973   [(set (match_operand:SI 0 "register_operand" "")
2974         (zero_extend:SI (match_operand:HI 1 "register_operand" "")))
2975    (clobber (reg:CC 17))]
2976   "reload_completed && TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
2977   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 65535)))
2978               (clobber (reg:CC 17))])]
2979   "")
2981 (define_insn "*zero_extendhisi2_movzwl"
2982   [(set (match_operand:SI 0 "register_operand" "=r")
2983      (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
2984   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
2985   "movz{wl|x}\t{%1, %0|%0, %1}"
2986   [(set_attr "type" "imovx")
2987    (set_attr "mode" "SI")])
2989 (define_expand "zero_extendqihi2"
2990   [(parallel
2991     [(set (match_operand:HI 0 "register_operand" "")
2992        (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
2993      (clobber (reg:CC 17))])]
2994   ""
2995   "")
2997 (define_insn "*zero_extendqihi2_and"
2998   [(set (match_operand:HI 0 "register_operand" "=r,?&q")
2999      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3000    (clobber (reg:CC 17))]
3001   "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3002   "#"
3003   [(set_attr "type" "alu1")
3004    (set_attr "mode" "HI")])
3006 (define_insn "*zero_extendqihi2_movzbw_and"
3007   [(set (match_operand:HI 0 "register_operand" "=r,r")
3008      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3009    (clobber (reg:CC 17))]
3010   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3011   "#"
3012   [(set_attr "type" "imovx,alu1")
3013    (set_attr "mode" "HI")])
3015 (define_insn "*zero_extendqihi2_movzbw"
3016   [(set (match_operand:HI 0 "register_operand" "=r")
3017      (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3018   "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
3019   "movz{bw|x}\t{%1, %0|%0, %1}"
3020   [(set_attr "type" "imovx")
3021    (set_attr "mode" "HI")])
3023 ;; For the movzbw case strip only the clobber
3024 (define_split
3025   [(set (match_operand:HI 0 "register_operand" "")
3026         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3027    (clobber (reg:CC 17))]
3028   "reload_completed 
3029    && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3030    && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3031   [(set (match_operand:HI 0 "register_operand" "")
3032         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))])
3034 ;; When source and destination does not overlap, clear destination
3035 ;; first and then do the movb
3036 (define_split
3037   [(set (match_operand:HI 0 "register_operand" "")
3038         (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "")))
3039    (clobber (reg:CC 17))]
3040   "reload_completed
3041    && ANY_QI_REG_P (operands[0])
3042    && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3043    && !reg_overlap_mentioned_p (operands[0], operands[1])"
3044   [(set (match_dup 0) (const_int 0))
3045    (set (strict_low_part (match_dup 2)) (match_dup 1))]
3046   "operands[2] = gen_lowpart (QImode, operands[0]);")
3048 ;; Rest is handled by single and.
3049 (define_split
3050   [(set (match_operand:HI 0 "register_operand" "")
3051         (zero_extend:HI (match_operand:QI 1 "register_operand" "")))
3052    (clobber (reg:CC 17))]
3053   "reload_completed
3054    && true_regnum (operands[0]) == true_regnum (operands[1])"
3055   [(parallel [(set (match_dup 0) (and:HI (match_dup 0) (const_int 255)))
3056               (clobber (reg:CC 17))])]
3057   "")
3059 (define_expand "zero_extendqisi2"
3060   [(parallel
3061     [(set (match_operand:SI 0 "register_operand" "")
3062        (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3063      (clobber (reg:CC 17))])]
3064   ""
3065   "")
3067 (define_insn "*zero_extendqisi2_and"
3068   [(set (match_operand:SI 0 "register_operand" "=r,?&q")
3069      (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0,qm")))
3070    (clobber (reg:CC 17))]
3071   "TARGET_ZERO_EXTEND_WITH_AND && !optimize_size"
3072   "#"
3073   [(set_attr "type" "alu1")
3074    (set_attr "mode" "SI")])
3076 (define_insn "*zero_extendqisi2_movzbw_and"
3077   [(set (match_operand:SI 0 "register_operand" "=r,r")
3078      (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm,0")))
3079    (clobber (reg:CC 17))]
3080   "!TARGET_ZERO_EXTEND_WITH_AND || optimize_size"
3081   "#"
3082   [(set_attr "type" "imovx,alu1")
3083    (set_attr "mode" "SI")])
3085 (define_insn "*zero_extendqisi2_movzbw"
3086   [(set (match_operand:SI 0 "register_operand" "=r")
3087      (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3088   "(!TARGET_ZERO_EXTEND_WITH_AND || optimize_size) && reload_completed"
3089   "movz{bl|x}\t{%1, %0|%0, %1}"
3090   [(set_attr "type" "imovx")
3091    (set_attr "mode" "SI")])
3093 ;; For the movzbl case strip only the clobber
3094 (define_split
3095   [(set (match_operand:SI 0 "register_operand" "")
3096         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3097    (clobber (reg:CC 17))]
3098   "reload_completed 
3099    && (!TARGET_ZERO_EXTEND_WITH_AND || optimize_size)
3100    && (!REG_P (operands[1]) || ANY_QI_REG_P (operands[1]))"
3101   [(set (match_dup 0)
3102         (zero_extend:SI (match_dup 1)))])
3104 ;; When source and destination does not overlap, clear destination
3105 ;; first and then do the movb
3106 (define_split
3107   [(set (match_operand:SI 0 "register_operand" "")
3108         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))
3109    (clobber (reg:CC 17))]
3110   "reload_completed
3111    && ANY_QI_REG_P (operands[0])
3112    && (ANY_QI_REG_P (operands[1]) || GET_CODE (operands[1]) == MEM)
3113    && (TARGET_ZERO_EXTEND_WITH_AND && !optimize_size)
3114    && !reg_overlap_mentioned_p (operands[0], operands[1])"
3115   [(set (match_dup 0) (const_int 0))
3116    (set (strict_low_part (match_dup 2)) (match_dup 1))]
3117   "operands[2] = gen_lowpart (QImode, operands[0]);")
3119 ;; Rest is handled by single and.
3120 (define_split
3121   [(set (match_operand:SI 0 "register_operand" "")
3122         (zero_extend:SI (match_operand:QI 1 "register_operand" "")))
3123    (clobber (reg:CC 17))]
3124   "reload_completed
3125    && true_regnum (operands[0]) == true_regnum (operands[1])"
3126   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (const_int 255)))
3127               (clobber (reg:CC 17))])]
3128   "")
3130 ;; %%% Kill me once multi-word ops are sane.
3131 (define_expand "zero_extendsidi2"
3132   [(set (match_operand:DI 0 "register_operand" "=r")
3133      (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm")))]
3134   ""
3135   "if (!TARGET_64BIT)
3136      {
3137        emit_insn (gen_zero_extendsidi2_32 (operands[0], operands[1]));
3138        DONE;
3139      }
3140   ")
3142 (define_insn "zero_extendsidi2_32"
3143   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,?r,?*o")
3144         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "0,rm,r")))
3145    (clobber (reg:CC 17))]
3146   "!TARGET_64BIT"
3147   "#"
3148   [(set_attr "mode" "SI")])
3150 (define_insn "zero_extendsidi2_rex64"
3151   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
3152      (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "rm,0")))]
3153   "TARGET_64BIT"
3154   "@
3155    mov\t{%k1, %k0|%k0, %k1}
3156    #"
3157   [(set_attr "type" "imovx,imov")
3158    (set_attr "mode" "SI,DI")])
3160 (define_split
3161   [(set (match_operand:DI 0 "memory_operand" "")
3162      (zero_extend:DI (match_dup 0)))]
3163   "TARGET_64BIT"
3164   [(set (match_dup 4) (const_int 0))]
3165   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3167 (define_split 
3168   [(set (match_operand:DI 0 "register_operand" "")
3169         (zero_extend:DI (match_operand:SI 1 "register_operand" "")))
3170    (clobber (reg:CC 17))]
3171   "!TARGET_64BIT && reload_completed
3172    && true_regnum (operands[0]) == true_regnum (operands[1])"
3173   [(set (match_dup 4) (const_int 0))]
3174   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3176 (define_split 
3177   [(set (match_operand:DI 0 "nonimmediate_operand" "")
3178         (zero_extend:DI (match_operand:SI 1 "general_operand" "")))
3179    (clobber (reg:CC 17))]
3180   "!TARGET_64BIT && reload_completed"
3181   [(set (match_dup 3) (match_dup 1))
3182    (set (match_dup 4) (const_int 0))]
3183   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3185 (define_insn "zero_extendhidi2"
3186   [(set (match_operand:DI 0 "register_operand" "=r,r")
3187      (zero_extend:DI (match_operand:HI 1 "nonimmediate_operand" "r,m")))]
3188   "TARGET_64BIT"
3189   "@
3190    movz{wl|x}\t{%1, %k0|%k0, %1} 
3191    movz{wq|x}\t{%1, %0|%0, %1}"
3192   [(set_attr "type" "imovx")
3193    (set_attr "mode" "SI,DI")])
3195 (define_insn "zero_extendqidi2"
3196   [(set (match_operand:DI 0 "register_operand" "=r,r")
3197      (zero_extend:DI (match_operand:QI 1 "nonimmediate_operand" "Q,m")))]
3198   "TARGET_64BIT"
3199   "@
3200    movz{bl|x}\t{%1, %k0|%k0, %1} 
3201    movz{bq|x}\t{%1, %0|%0, %1}"
3202   [(set_attr "type" "imovx")
3203    (set_attr "mode" "SI,DI")])
3205 ;; Sign extension instructions
3207 (define_expand "extendsidi2"
3208   [(parallel [(set (match_operand:DI 0 "register_operand" "")
3209                    (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3210               (clobber (reg:CC 17))
3211               (clobber (match_scratch:SI 2 ""))])]
3212   ""
3214   if (TARGET_64BIT)
3215     {
3216       emit_insn (gen_extendsidi2_rex64 (operands[0], operands[1]));
3217       DONE;
3218     }
3221 (define_insn "*extendsidi2_1"
3222   [(set (match_operand:DI 0 "nonimmediate_operand" "=*A,r,?r,?*o")
3223         (sign_extend:DI (match_operand:SI 1 "register_operand" "0,0,r,r")))
3224    (clobber (reg:CC 17))
3225    (clobber (match_scratch:SI 2 "=X,X,X,&r"))]
3226   "!TARGET_64BIT"
3227   "#")
3229 (define_insn "extendsidi2_rex64"
3230   [(set (match_operand:DI 0 "register_operand" "=*a,r")
3231         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "*0,rm")))]
3232   "TARGET_64BIT"
3233   "@
3234    {cltq|cdqe}
3235    movs{lq|x}\t{%1,%0|%0, %1}"
3236   [(set_attr "type" "imovx")
3237    (set_attr "mode" "DI")
3238    (set_attr "prefix_0f" "0")
3239    (set_attr "modrm" "0,1")])
3241 (define_insn "extendhidi2"
3242   [(set (match_operand:DI 0 "register_operand" "=r")
3243         (sign_extend:DI (match_operand:HI 1 "nonimmediate_operand" "rm")))]
3244   "TARGET_64BIT"
3245   "movs{wq|x}\t{%1,%0|%0, %1}"
3246   [(set_attr "type" "imovx")
3247    (set_attr "mode" "DI")])
3249 (define_insn "extendqidi2"
3250   [(set (match_operand:DI 0 "register_operand" "=r")
3251         (sign_extend:DI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3252   "TARGET_64BIT"
3253   "movs{bq|x}\t{%1,%0|%0, %1}"
3254    [(set_attr "type" "imovx")
3255     (set_attr "mode" "DI")])
3257 ;; Extend to memory case when source register does die.
3258 (define_split 
3259   [(set (match_operand:DI 0 "memory_operand" "")
3260         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3261    (clobber (reg:CC 17))
3262    (clobber (match_operand:SI 2 "register_operand" ""))]
3263   "(reload_completed
3264     && dead_or_set_p (insn, operands[1])
3265     && !reg_mentioned_p (operands[1], operands[0]))"
3266   [(set (match_dup 3) (match_dup 1))
3267    (parallel [(set (match_dup 1) (ashiftrt:SI (match_dup 1) (const_int 31)))
3268               (clobber (reg:CC 17))])
3269    (set (match_dup 4) (match_dup 1))]
3270   "split_di (&operands[0], 1, &operands[3], &operands[4]);")
3272 ;; Extend to memory case when source register does not die.
3273 (define_split 
3274   [(set (match_operand:DI 0 "memory_operand" "")
3275         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3276    (clobber (reg:CC 17))
3277    (clobber (match_operand:SI 2 "register_operand" ""))]
3278   "reload_completed"
3279   [(const_int 0)]
3281   split_di (&operands[0], 1, &operands[3], &operands[4]);
3283   emit_move_insn (operands[3], operands[1]);
3285   /* Generate a cltd if possible and doing so it profitable.  */
3286   if (true_regnum (operands[1]) == 0
3287       && true_regnum (operands[2]) == 1
3288       && (optimize_size || TARGET_USE_CLTD))
3289     {
3290       emit_insn (gen_ashrsi3_31 (operands[2], operands[1], GEN_INT (31)));
3291     }
3292   else
3293     {
3294       emit_move_insn (operands[2], operands[1]);
3295       emit_insn (gen_ashrsi3_31 (operands[2], operands[2], GEN_INT (31)));
3296     }
3297   emit_move_insn (operands[4], operands[2]);
3298   DONE;
3301 ;; Extend to register case.  Optimize case where source and destination
3302 ;; registers match and cases where we can use cltd.
3303 (define_split 
3304   [(set (match_operand:DI 0 "register_operand" "")
3305         (sign_extend:DI (match_operand:SI 1 "register_operand" "")))
3306    (clobber (reg:CC 17))
3307    (clobber (match_scratch:SI 2 ""))]
3308   "reload_completed"
3309   [(const_int 0)]
3311   split_di (&operands[0], 1, &operands[3], &operands[4]);
3313   if (true_regnum (operands[3]) != true_regnum (operands[1]))
3314     emit_move_insn (operands[3], operands[1]);
3316   /* Generate a cltd if possible and doing so it profitable.  */
3317   if (true_regnum (operands[3]) == 0
3318       && (optimize_size || TARGET_USE_CLTD))
3319     {
3320       emit_insn (gen_ashrsi3_31 (operands[4], operands[3], GEN_INT (31)));
3321       DONE;
3322     }
3324   if (true_regnum (operands[4]) != true_regnum (operands[1]))
3325     emit_move_insn (operands[4], operands[1]);
3327   emit_insn (gen_ashrsi3_31 (operands[4], operands[4], GEN_INT (31)));
3328   DONE;
3331 (define_insn "extendhisi2"
3332   [(set (match_operand:SI 0 "register_operand" "=*a,r")
3333         (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm")))]
3334   ""
3336   switch (get_attr_prefix_0f (insn))
3337     {
3338     case 0:
3339       return "{cwtl|cwde}";
3340     default:
3341       return "movs{wl|x}\t{%1,%0|%0, %1}";
3342     }
3344   [(set_attr "type" "imovx")
3345    (set_attr "mode" "SI")
3346    (set (attr "prefix_0f")
3347      ;; movsx is short decodable while cwtl is vector decoded.
3348      (if_then_else (and (eq_attr "cpu" "!k6")
3349                         (eq_attr "alternative" "0"))
3350         (const_string "0")
3351         (const_string "1")))
3352    (set (attr "modrm")
3353      (if_then_else (eq_attr "prefix_0f" "0")
3354         (const_string "0")
3355         (const_string "1")))])
3357 (define_insn "*extendhisi2_zext"
3358   [(set (match_operand:DI 0 "register_operand" "=*a,r")
3359         (zero_extend:DI
3360           (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "*0,rm"))))]
3361   "TARGET_64BIT"
3363   switch (get_attr_prefix_0f (insn))
3364     {
3365     case 0:
3366       return "{cwtl|cwde}";
3367     default:
3368       return "movs{wl|x}\t{%1,%k0|%k0, %1}";
3369     }
3371   [(set_attr "type" "imovx")
3372    (set_attr "mode" "SI")
3373    (set (attr "prefix_0f")
3374      ;; movsx is short decodable while cwtl is vector decoded.
3375      (if_then_else (and (eq_attr "cpu" "!k6")
3376                         (eq_attr "alternative" "0"))
3377         (const_string "0")
3378         (const_string "1")))
3379    (set (attr "modrm")
3380      (if_then_else (eq_attr "prefix_0f" "0")
3381         (const_string "0")
3382         (const_string "1")))])
3384 (define_insn "extendqihi2"
3385   [(set (match_operand:HI 0 "register_operand" "=*a,r")
3386         (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "*0,qm")))]
3387   ""
3389   switch (get_attr_prefix_0f (insn))
3390     {
3391     case 0:
3392       return "{cbtw|cbw}";
3393     default:
3394       return "movs{bw|x}\t{%1,%0|%0, %1}";
3395     }
3397   [(set_attr "type" "imovx")
3398    (set_attr "mode" "HI")
3399    (set (attr "prefix_0f")
3400      ;; movsx is short decodable while cwtl is vector decoded.
3401      (if_then_else (and (eq_attr "cpu" "!k6")
3402                         (eq_attr "alternative" "0"))
3403         (const_string "0")
3404         (const_string "1")))
3405    (set (attr "modrm")
3406      (if_then_else (eq_attr "prefix_0f" "0")
3407         (const_string "0")
3408         (const_string "1")))])
3410 (define_insn "extendqisi2"
3411   [(set (match_operand:SI 0 "register_operand" "=r")
3412         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm")))]
3413   ""
3414   "movs{bl|x}\t{%1,%0|%0, %1}"
3415    [(set_attr "type" "imovx")
3416     (set_attr "mode" "SI")])
3418 (define_insn "*extendqisi2_zext"
3419   [(set (match_operand:DI 0 "register_operand" "=r")
3420         (zero_extend:DI
3421           (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "qm"))))]
3422   "TARGET_64BIT"
3423   "movs{bl|x}\t{%1,%k0|%k0, %1}"
3424    [(set_attr "type" "imovx")
3425     (set_attr "mode" "SI")])
3427 ;; Conversions between float and double.
3429 ;; These are all no-ops in the model used for the 80387.  So just
3430 ;; emit moves.
3432 ;; %%% Kill these when call knows how to work out a DFmode push earlier. 
3433 (define_insn "*dummy_extendsfdf2"
3434   [(set (match_operand:DF 0 "push_operand" "=<")
3435         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fY")))]
3436   "0"
3437   "#")
3439 (define_split
3440   [(set (match_operand:DF 0 "push_operand" "")
3441         (float_extend:DF (match_operand:SF 1 "fp_register_operand" "")))]
3442   "!TARGET_64BIT"
3443   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
3444    (set (mem:DF (reg:SI 7)) (float_extend:DF (match_dup 1)))])
3446 (define_split
3447   [(set (match_operand:DF 0 "push_operand" "")
3448         (float_extend:DF (match_operand:SF 1 "fp_register_operand" "")))]
3449   "TARGET_64BIT"
3450   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
3451    (set (mem:DF (reg:DI 7)) (float_extend:DF (match_dup 1)))])
3453 (define_insn "*dummy_extendsfxf2"
3454   [(set (match_operand:XF 0 "push_operand" "=<")
3455         (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "f")))]
3456   "0"
3457   "#")
3459 (define_split
3460   [(set (match_operand:XF 0 "push_operand" "")
3461         (float_extend:XF (match_operand:SF 1 "fp_register_operand" "")))]
3462   "!TARGET_64BIT"
3463   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
3464    (set (mem:XF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3466 (define_insn "*dummy_extendsftf2"
3467   [(set (match_operand:TF 0 "push_operand" "=<")
3468         (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "f")))]
3469   "0"
3470   "#")
3472 (define_split
3473   [(set (match_operand:TF 0 "push_operand" "")
3474         (float_extend:TF (match_operand:SF 1 "fp_register_operand" "")))]
3475   "!TARGET_64BIT"
3476   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
3477    (set (mem:TF (reg:SI 7)) (float_extend:TF (match_dup 1)))])
3479 (define_split
3480   [(set (match_operand:TF 0 "push_operand" "")
3481         (float_extend:TF (match_operand:SF 1 "fp_register_operand" "")))]
3482   "TARGET_64BIT"
3483   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
3484    (set (mem:DF (reg:DI 7)) (float_extend:TF (match_dup 1)))])
3486 (define_insn "*dummy_extenddfxf2"
3487   [(set (match_operand:XF 0 "push_operand" "=<")
3488         (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "f")))]
3489   "0"
3490   "#")
3492 (define_split
3493   [(set (match_operand:XF 0 "push_operand" "")
3494         (float_extend:XF (match_operand:DF 1 "fp_register_operand" "")))]
3495   "!TARGET_64BIT"
3496   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
3497    (set (mem:DF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3499 (define_insn "*dummy_extenddftf2"
3500   [(set (match_operand:TF 0 "push_operand" "=<")
3501         (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "f")))]
3502   "0"
3503   "#")
3505 (define_split
3506   [(set (match_operand:TF 0 "push_operand" "")
3507         (float_extend:TF (match_operand:DF 1 "fp_register_operand" "")))]
3508   "!TARGET_64BIT"
3509   [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
3510    (set (mem:TF (reg:SI 7)) (float_extend:XF (match_dup 1)))])
3512 (define_split
3513   [(set (match_operand:TF 0 "push_operand" "")
3514         (float_extend:TF (match_operand:DF 1 "fp_register_operand" "")))]
3515   "TARGET_64BIT"
3516   [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
3517    (set (mem:TF (reg:DI 7)) (float_extend:TF (match_dup 1)))])
3519 (define_expand "extendsfdf2"
3520   [(set (match_operand:DF 0 "nonimmediate_operand" "")
3521         (float_extend:DF (match_operand:SF 1 "general_operand" "")))]
3522   "TARGET_80387 || TARGET_SSE2"
3524   /* ??? Needed for compress_float_constant since all fp constants
3525      are LEGITIMATE_CONSTANT_P.  */
3526   if (GET_CODE (operands[1]) == CONST_DOUBLE)
3527     operands[1] = validize_mem (force_const_mem (SFmode, operands[1]));
3528   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3529     operands[1] = force_reg (SFmode, operands[1]);
3532 (define_insn "*extendsfdf2_1"
3533   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,mf#Y,Y#f")
3534         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm#Y,f#Y,mY#f")))]
3535   "(TARGET_80387 || TARGET_SSE2)
3536    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3538   switch (which_alternative)
3539     {
3540     case 0:
3541       if (REG_P (operands[1])
3542           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3543         return "fstp\t%y0";
3544       else if (STACK_TOP_P (operands[0]))
3545         return "fld%z1\t%y1";
3546       else
3547         return "fst\t%y0";
3549     case 1:
3550       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3551         return "fstp%z0\t%y0";
3553       else
3554         return "fst%z0\t%y0";
3555     case 2:
3556       return "cvtss2sd\t{%1, %0|%0, %1}";
3558     default:
3559       abort ();
3560     }
3562   [(set_attr "type" "fmov,fmov,ssecvt")
3563    (set_attr "mode" "SF,XF,DF")])
3565 (define_insn "*extendsfdf2_1_sse_only"
3566   [(set (match_operand:DF 0 "register_operand" "=Y")
3567         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "mY")))]
3568   "!TARGET_80387 && TARGET_SSE2
3569    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3570   "cvtss2sd\t{%1, %0|%0, %1}"
3571   [(set_attr "type" "ssecvt")
3572    (set_attr "mode" "DF")])
3574 (define_expand "extendsfxf2"
3575   [(set (match_operand:XF 0 "nonimmediate_operand" "")
3576         (float_extend:XF (match_operand:SF 1 "general_operand" "")))]
3577   "!TARGET_64BIT && TARGET_80387"
3579   /* ??? Needed for compress_float_constant since all fp constants
3580      are LEGITIMATE_CONSTANT_P.  */
3581   if (GET_CODE (operands[1]) == CONST_DOUBLE)
3582     operands[1] = validize_mem (force_const_mem (SFmode, operands[1]));
3583   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3584     operands[1] = force_reg (SFmode, operands[1]);
3587 (define_insn "*extendsfxf2_1"
3588   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m")
3589         (float_extend:XF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))]
3590   "!TARGET_64BIT && TARGET_80387
3591    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3593   switch (which_alternative)
3594     {
3595     case 0:
3596       if (REG_P (operands[1])
3597           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3598         return "fstp\t%y0";
3599       else if (STACK_TOP_P (operands[0]))
3600         return "fld%z1\t%y1";
3601       else
3602         return "fst\t%y0";
3604     case 1:
3605       /* There is no non-popping store to memory for XFmode.  So if
3606          we need one, follow the store with a load.  */
3607       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3608         return "fstp%z0\t%y0\n\tfld%z0\t%y0";
3609       else
3610         return "fstp%z0\t%y0";
3612     default:
3613       abort ();
3614     }
3616   [(set_attr "type" "fmov")
3617    (set_attr "mode" "SF,XF")])
3619 (define_expand "extendsftf2"
3620   [(set (match_operand:TF 0 "nonimmediate_operand" "")
3621         (float_extend:TF (match_operand:SF 1 "general_operand" "")))]
3622   "TARGET_80387"
3624   /* ??? Needed for compress_float_constant since all fp constants
3625      are LEGITIMATE_CONSTANT_P.  */
3626   if (GET_CODE (operands[1]) == CONST_DOUBLE)
3627     operands[1] = validize_mem (force_const_mem (SFmode, operands[1]));
3628   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3629     operands[1] = force_reg (SFmode, operands[1]);
3632 (define_insn "*extendsftf2_1"
3633   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m")
3634         (float_extend:TF (match_operand:SF 1 "nonimmediate_operand" "fm,f")))]
3635   "TARGET_80387
3636    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3638   switch (which_alternative)
3639     {
3640     case 0:
3641       if (REG_P (operands[1])
3642           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3643         return "fstp\t%y0";
3644       else if (STACK_TOP_P (operands[0]))
3645         return "fld%z1\t%y1";
3646       else
3647         return "fst\t%y0";
3649     case 1:
3650       /* There is no non-popping store to memory for XFmode.  So if
3651          we need one, follow the store with a load.  */
3652       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3653         return "fstp%z0\t%y0\n\tfld%z0\t%y0";
3654       else
3655         return "fstp%z0\t%y0";
3657     default:
3658       abort ();
3659     }
3661   [(set_attr "type" "fmov")
3662    (set_attr "mode" "SF,XF")])
3664 (define_expand "extenddfxf2"
3665   [(set (match_operand:XF 0 "nonimmediate_operand" "")
3666         (float_extend:XF (match_operand:DF 1 "general_operand" "")))]
3667   "!TARGET_64BIT && TARGET_80387"
3669   /* ??? Needed for compress_float_constant since all fp constants
3670      are LEGITIMATE_CONSTANT_P.  */
3671   if (GET_CODE (operands[1]) == CONST_DOUBLE)
3672     operands[1] = validize_mem (force_const_mem (DFmode, operands[1]));
3673   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3674     operands[1] = force_reg (DFmode, operands[1]);
3677 (define_insn "*extenddfxf2_1"
3678   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m")
3679         (float_extend:XF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))]
3680   "!TARGET_64BIT && TARGET_80387
3681    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3683   switch (which_alternative)
3684     {
3685     case 0:
3686       if (REG_P (operands[1])
3687           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3688         return "fstp\t%y0";
3689       else if (STACK_TOP_P (operands[0]))
3690         return "fld%z1\t%y1";
3691       else
3692         return "fst\t%y0";
3694     case 1:
3695       /* There is no non-popping store to memory for XFmode.  So if
3696          we need one, follow the store with a load.  */
3697       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3698         return "fstp%z0\t%y0\n\tfld%z0\t%y0";
3699       else
3700         return "fstp%z0\t%y0";
3702     default:
3703       abort ();
3704     }
3706   [(set_attr "type" "fmov")
3707    (set_attr "mode" "DF,XF")])
3709 (define_expand "extenddftf2"
3710   [(set (match_operand:TF 0 "nonimmediate_operand" "")
3711         (float_extend:TF (match_operand:DF 1 "general_operand" "")))]
3712   "TARGET_80387"
3714   /* ??? Needed for compress_float_constant since all fp constants
3715      are LEGITIMATE_CONSTANT_P.  */
3716   if (GET_CODE (operands[1]) == CONST_DOUBLE)
3717     operands[1] = validize_mem (force_const_mem (DFmode, operands[1]));
3718   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
3719     operands[1] = force_reg (DFmode, operands[1]);
3722 (define_insn "*extenddftf2_1"
3723   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m")
3724         (float_extend:TF (match_operand:DF 1 "nonimmediate_operand" "fm,f")))]
3725   "TARGET_80387
3726    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3728   switch (which_alternative)
3729     {
3730     case 0:
3731       if (REG_P (operands[1])
3732           && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3733         return "fstp\t%y0";
3734       else if (STACK_TOP_P (operands[0]))
3735         return "fld%z1\t%y1";
3736       else
3737         return "fst\t%y0";
3739     case 1:
3740       /* There is no non-popping store to memory for XFmode.  So if
3741          we need one, follow the store with a load.  */
3742       if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3743         return "fstp%z0\t%y0\n\tfld%z0\t%y0";
3744       else
3745         return "fstp%z0\t%y0";
3747     default:
3748       abort ();
3749     }
3751   [(set_attr "type" "fmov")
3752    (set_attr "mode" "DF,XF")])
3754 ;; %%% This seems bad bad news.
3755 ;; This cannot output into an f-reg because there is no way to be sure
3756 ;; of truncating in that case.  Otherwise this is just like a simple move
3757 ;; insn.  So we pretend we can output to a reg in order to get better
3758 ;; register preferencing, but we really use a stack slot.
3760 (define_expand "truncdfsf2"
3761   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
3762                    (float_truncate:SF
3763                     (match_operand:DF 1 "register_operand" "")))
3764               (clobber (match_dup 2))])]
3765   "TARGET_80387 || TARGET_SSE2"
3766   "
3767    if (TARGET_80387)
3768      operands[2] = assign_386_stack_local (SFmode, 0);
3769    else
3770      {
3771         emit_insn (gen_truncdfsf2_sse_only (operands[0], operands[1]));
3772         DONE;
3773      }
3776 (define_insn "*truncdfsf2_1"
3777   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
3778         (float_truncate:SF
3779          (match_operand:DF 1 "register_operand" "f,f,f,f")))
3780    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
3781   "TARGET_80387 && !TARGET_SSE2"
3783   switch (which_alternative)
3784     {
3785     case 0:
3786       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3787         return "fstp%z0\t%y0";
3788       else
3789         return "fst%z0\t%y0";
3790     default:
3791       abort ();
3792     }
3794   [(set_attr "type" "fmov,multi,multi,multi")
3795    (set_attr "mode" "SF,SF,SF,SF")])
3797 (define_insn "*truncdfsf2_1_sse"
3798   [(set (match_operand:SF 0 "nonimmediate_operand" "=*!m#fxr,?f#xr,?r#fx,?x#fr,Y#fr")
3799         (float_truncate:SF
3800          (match_operand:DF 1 "nonimmediate_operand" "f#Y,f#Y,f#Y,f#Y,mY#f")))
3801    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m,X"))]
3802   "TARGET_80387 && TARGET_SSE2 && !TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS"
3804   switch (which_alternative)
3805     {
3806     case 0:
3807       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3808         return "fstp%z0\t%y0";
3809       else
3810         return "fst%z0\t%y0";
3811     case 4:
3812       return "#";
3813     default:
3814       abort ();
3815     }
3817   [(set_attr "type" "fmov,multi,multi,multi,ssecvt")
3818    (set_attr "mode" "SF,SF,SF,SF,DF")])
3820 (define_insn "*truncdfsf2_1_sse_nooverlap"
3821   [(set (match_operand:SF 0 "nonimmediate_operand" "=*!m,?f#rx,?r#fx,?x#rf,&Y")
3822         (float_truncate:SF
3823          (match_operand:DF 1 "nonimmediate_operand" "f#Y,f#Y,f#Y,f#Y,mY#f")))
3824    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m,X"))]
3825   "TARGET_80387 && TARGET_SSE2 && TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS"
3827   switch (which_alternative)
3828     {
3829     case 0:
3830       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3831         return "fstp%z0\t%y0";
3832       else
3833         return "fst%z0\t%y0";
3834     case 4:
3835       return "#";
3836     default:
3837       abort ();
3838     }
3840   [(set_attr "type" "fmov,multi,multi,multi,ssecvt")
3841    (set_attr "mode" "SF,SF,SF,SF,DF")])
3843 (define_insn "*truncdfsf2_2"
3844   [(set (match_operand:SF 0 "nonimmediate_operand" "=Y,Y,!m")
3845         (float_truncate:SF
3846          (match_operand:DF 1 "nonimmediate_operand" "Y,mY,f#Y")))]
3847   "TARGET_80387 && TARGET_SSE2 && !TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS
3848    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3850   switch (which_alternative)
3851     {
3852     case 0:
3853     case 1:
3854       return "cvtsd2ss\t{%1, %0|%0, %1}";
3855     case 2:
3856       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3857         return "fstp%z0\t%y0";
3858       else
3859         return "fst%z0\t%y0";
3860     default:
3861       abort ();
3862     }
3864   [(set_attr "type" "ssecvt,ssecvt,fmov")
3865    (set_attr "athlon_decode" "vector,double,*")
3866    (set_attr "mode" "DF,DF,SF")])
3868 (define_insn "*truncdfsf2_2_nooverlap"
3869   [(set (match_operand:SF 0 "nonimmediate_operand" "=&Y,!m")
3870         (float_truncate:SF
3871          (match_operand:DF 1 "nonimmediate_operand" "mY,f")))]
3872   "TARGET_80387 && TARGET_SSE2 && TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS
3873    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
3875   switch (which_alternative)
3876     {
3877     case 0:
3878       return "#";
3879     case 1:
3880       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3881         return "fstp%z0\t%y0";
3882       else
3883         return "fst%z0\t%y0";
3884     default:
3885       abort ();
3886     }
3888   [(set_attr "type" "ssecvt,fmov")
3889    (set_attr "mode" "DF,SF")])
3891 (define_insn "*truncdfsf2_3"
3892   [(set (match_operand:SF 0 "memory_operand" "=m")
3893         (float_truncate:SF
3894          (match_operand:DF 1 "register_operand" "f")))]
3895   "TARGET_80387"
3897   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3898     return "fstp%z0\t%y0";
3899   else
3900     return "fst%z0\t%y0";
3902   [(set_attr "type" "fmov")
3903    (set_attr "mode" "SF")])
3905 (define_insn "truncdfsf2_sse_only"
3906   [(set (match_operand:SF 0 "register_operand" "=Y,Y")
3907         (float_truncate:SF
3908          (match_operand:DF 1 "nonimmediate_operand" "Y,mY")))]
3909   "!TARGET_80387 && TARGET_SSE2 && !TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS"
3910   "cvtsd2ss\t{%1, %0|%0, %1}"
3911   [(set_attr "type" "ssecvt")
3912    (set_attr "athlon_decode" "vector,double")
3913    (set_attr "mode" "DF")])
3915 (define_insn "*truncdfsf2_sse_only_nooverlap"
3916   [(set (match_operand:SF 0 "register_operand" "=&Y")
3917         (float_truncate:SF
3918          (match_operand:DF 1 "nonimmediate_operand" "mY")))]
3919   "!TARGET_80387 && TARGET_SSE2 && TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS"
3920   "#"
3921   [(set_attr "type" "ssecvt")
3922    (set_attr "mode" "DF")])
3924 (define_split
3925   [(set (match_operand:SF 0 "memory_operand" "")
3926         (float_truncate:SF
3927          (match_operand:DF 1 "register_operand" "")))
3928    (clobber (match_operand:SF 2 "memory_operand" ""))]
3929   "TARGET_80387"
3930   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
3931   "")
3933 ; Avoid possible reformatting penalty on the destination by first
3934 ; zeroing it out
3935 (define_split
3936   [(set (match_operand:SF 0 "register_operand" "")
3937         (float_truncate:SF
3938          (match_operand:DF 1 "nonimmediate_operand" "")))
3939    (clobber (match_operand 2 "" ""))]
3940   "TARGET_80387 && reload_completed
3941    && SSE_REG_P (operands[0])
3942    && !STACK_REG_P (operands[1])"
3943   [(const_int 0)]
3945   rtx src, dest;
3946   if (!TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS)
3947     emit_insn (gen_truncdfsf2_sse_only (operands[0], operands[1]));
3948   else
3949     {
3950       dest = simplify_gen_subreg (V4SFmode, operands[0], SFmode, 0);
3951       src = simplify_gen_subreg (V2DFmode, operands[1], DFmode, 0);
3952       /* simplify_gen_subreg refuses to widen memory references.  */
3953       if (GET_CODE (src) == SUBREG)
3954         alter_subreg (&src);
3955       if (reg_overlap_mentioned_p (operands[0], operands[1]))
3956         abort ();
3957       emit_insn (gen_sse_clrv4sf (dest, CONST0_RTX (V4SFmode)));
3958       emit_insn (gen_cvtsd2ss (dest, dest, src));
3959     }
3960   DONE;
3963 (define_split
3964   [(set (match_operand:SF 0 "register_operand" "")
3965         (float_truncate:SF
3966          (match_operand:DF 1 "nonimmediate_operand" "")))]
3967   "TARGET_80387 && reload_completed
3968    && SSE_REG_P (operands[0]) && TARGET_SSE_PARTIAL_REGS_FOR_CVTSD2SS"
3969   [(const_int 0)]
3971   rtx src, dest;
3972   dest = simplify_gen_subreg (V4SFmode, operands[0], SFmode, 0);
3973   src = simplify_gen_subreg (V2DFmode, operands[1], DFmode, 0);
3974   /* simplify_gen_subreg refuses to widen memory references.  */
3975   if (GET_CODE (src) == SUBREG)
3976     alter_subreg (&src);
3977   if (reg_overlap_mentioned_p (operands[0], operands[1]))
3978     abort ();
3979   emit_insn (gen_sse_clrv4sf (dest, CONST0_RTX (V4SFmode)));
3980   emit_insn (gen_cvtsd2ss (dest, dest, src));
3981   DONE;
3984 (define_split
3985   [(set (match_operand:SF 0 "register_operand" "")
3986         (float_truncate:SF
3987          (match_operand:DF 1 "fp_register_operand" "")))
3988    (clobber (match_operand:SF 2 "memory_operand" ""))]
3989   "TARGET_80387 && reload_completed"
3990   [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
3991    (set (match_dup 0) (match_dup 2))]
3992   "")
3994 (define_expand "truncxfsf2"
3995   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
3996                    (float_truncate:SF
3997                     (match_operand:XF 1 "register_operand" "")))
3998               (clobber (match_dup 2))])]
3999   "!TARGET_64BIT && TARGET_80387"
4000   "operands[2] = assign_386_stack_local (SFmode, 0);")
4002 (define_insn "*truncxfsf2_1"
4003   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
4004         (float_truncate:SF
4005          (match_operand:XF 1 "register_operand" "f,f,f,f")))
4006    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
4007   "!TARGET_64BIT && TARGET_80387"
4009   switch (which_alternative)
4010     {
4011     case 0:
4012       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4013         return "fstp%z0\t%y0";
4014       else
4015         return "fst%z0\t%y0";
4016     default:
4017       abort();
4018     }
4020   [(set_attr "type" "fmov,multi,multi,multi")
4021    (set_attr "mode" "SF")])
4023 (define_insn "*truncxfsf2_2"
4024   [(set (match_operand:SF 0 "memory_operand" "=m")
4025         (float_truncate:SF
4026          (match_operand:XF 1 "register_operand" "f")))]
4027   "!TARGET_64BIT && TARGET_80387"
4029   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4030     return "fstp%z0\t%y0";
4031   else
4032     return "fst%z0\t%y0";
4034   [(set_attr "type" "fmov")
4035    (set_attr "mode" "SF")])
4037 (define_split
4038   [(set (match_operand:SF 0 "memory_operand" "")
4039         (float_truncate:SF
4040          (match_operand:XF 1 "register_operand" "")))
4041    (clobber (match_operand:SF 2 "memory_operand" ""))]
4042   "TARGET_80387"
4043   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
4044   "")
4046 (define_split
4047   [(set (match_operand:SF 0 "register_operand" "")
4048         (float_truncate:SF
4049          (match_operand:XF 1 "register_operand" "")))
4050    (clobber (match_operand:SF 2 "memory_operand" ""))]
4051   "TARGET_80387 && reload_completed"
4052   [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
4053    (set (match_dup 0) (match_dup 2))]
4054   "")
4056 (define_expand "trunctfsf2"
4057   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
4058                    (float_truncate:SF
4059                     (match_operand:TF 1 "register_operand" "")))
4060               (clobber (match_dup 2))])]
4061   "TARGET_80387"
4062   "operands[2] = assign_386_stack_local (SFmode, 0);")
4064 (define_insn "*trunctfsf2_1"
4065   [(set (match_operand:SF 0 "nonimmediate_operand" "=m,?f#rx,?r#fx,?x#rf")
4066         (float_truncate:SF
4067          (match_operand:TF 1 "register_operand" "f,f,f,f")))
4068    (clobber (match_operand:SF 2 "memory_operand" "=X,m,m,m"))]
4069   "TARGET_80387"
4071   switch (which_alternative)
4072     {
4073     case 0:
4074       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4075         return "fstp%z0\t%y0";
4076       else
4077         return "fst%z0\t%y0";
4078     default:
4079       abort();
4080     }
4082   [(set_attr "type" "fmov,multi,multi,multi")
4083    (set_attr "mode" "SF")])
4085 (define_insn "*trunctfsf2_2"
4086   [(set (match_operand:SF 0 "memory_operand" "=m")
4087         (float_truncate:SF
4088          (match_operand:TF 1 "register_operand" "f")))]
4089   "TARGET_80387"
4091   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4092     return "fstp%z0\t%y0";
4093   else
4094     return "fst%z0\t%y0";
4096   [(set_attr "type" "fmov")
4097    (set_attr "mode" "SF")])
4099 (define_split
4100   [(set (match_operand:SF 0 "memory_operand" "")
4101         (float_truncate:SF
4102          (match_operand:TF 1 "register_operand" "")))
4103    (clobber (match_operand:SF 2 "memory_operand" ""))]
4104   "TARGET_80387"
4105   [(set (match_dup 0) (float_truncate:SF (match_dup 1)))]
4106   "")
4108 (define_split
4109   [(set (match_operand:SF 0 "register_operand" "")
4110         (float_truncate:SF
4111          (match_operand:TF 1 "register_operand" "")))
4112    (clobber (match_operand:SF 2 "memory_operand" ""))]
4113   "TARGET_80387 && reload_completed"
4114   [(set (match_dup 2) (float_truncate:SF (match_dup 1)))
4115    (set (match_dup 0) (match_dup 2))]
4116   "")
4119 (define_expand "truncxfdf2"
4120   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
4121                    (float_truncate:DF
4122                     (match_operand:XF 1 "register_operand" "")))
4123               (clobber (match_dup 2))])]
4124   "!TARGET_64BIT && TARGET_80387"
4125   "operands[2] = assign_386_stack_local (DFmode, 0);")
4127 (define_insn "*truncxfdf2_1"
4128   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf")
4129         (float_truncate:DF
4130          (match_operand:XF 1 "register_operand" "f,f,f,f")))
4131    (clobber (match_operand:DF 2 "memory_operand" "=X,m,m,m"))]
4132   "!TARGET_64BIT && TARGET_80387"
4134   switch (which_alternative)
4135     {
4136     case 0:
4137       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4138         return "fstp%z0\t%y0";
4139       else
4140         return "fst%z0\t%y0";
4141     default:
4142       abort();
4143     }
4144   abort ();
4146   [(set_attr "type" "fmov,multi,multi,multi")
4147    (set_attr "mode" "DF")])
4149 (define_insn "*truncxfdf2_2"
4150   [(set (match_operand:DF 0 "memory_operand" "=m")
4151         (float_truncate:DF
4152           (match_operand:XF 1 "register_operand" "f")))]
4153   "!TARGET_64BIT && TARGET_80387"
4155   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4156     return "fstp%z0\t%y0";
4157   else
4158     return "fst%z0\t%y0";
4160   [(set_attr "type" "fmov")
4161    (set_attr "mode" "DF")])
4163 (define_split
4164   [(set (match_operand:DF 0 "memory_operand" "")
4165         (float_truncate:DF
4166          (match_operand:XF 1 "register_operand" "")))
4167    (clobber (match_operand:DF 2 "memory_operand" ""))]
4168   "TARGET_80387"
4169   [(set (match_dup 0) (float_truncate:DF (match_dup 1)))]
4170   "")
4172 (define_split
4173   [(set (match_operand:DF 0 "register_operand" "")
4174         (float_truncate:DF
4175          (match_operand:XF 1 "register_operand" "")))
4176    (clobber (match_operand:DF 2 "memory_operand" ""))]
4177   "TARGET_80387 && reload_completed"
4178   [(set (match_dup 2) (float_truncate:DF (match_dup 1)))
4179    (set (match_dup 0) (match_dup 2))]
4180   "")
4182 (define_expand "trunctfdf2"
4183   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
4184                    (float_truncate:DF
4185                     (match_operand:TF 1 "register_operand" "")))
4186               (clobber (match_dup 2))])]
4187   "TARGET_80387"
4188   "operands[2] = assign_386_stack_local (DFmode, 0);")
4190 (define_insn "*trunctfdf2_1"
4191   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,?f#rY,?r#fY,?Y#rf")
4192         (float_truncate:DF
4193          (match_operand:TF 1 "register_operand" "f,f,f,f")))
4194    (clobber (match_operand:DF 2 "memory_operand" "=X,m,m,m"))]
4195   "TARGET_80387"
4197   switch (which_alternative)
4198     {
4199     case 0:
4200       if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4201         return "fstp%z0\t%y0";
4202       else
4203         return "fst%z0\t%y0";
4204     default:
4205       abort();
4206     }
4207   abort ();
4209   [(set_attr "type" "fmov,multi,multi,multi")
4210    (set_attr "mode" "DF")])
4212         (define_insn "*trunctfdf2_2"
4213   [(set (match_operand:DF 0 "memory_operand" "=m")
4214         (float_truncate:DF
4215           (match_operand:TF 1 "register_operand" "f")))]
4216   "TARGET_80387"
4218   if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4219     return "fstp%z0\t%y0";
4220   else
4221     return "fst%z0\t%y0";
4223   [(set_attr "type" "fmov")
4224    (set_attr "mode" "DF")])
4226 (define_split
4227   [(set (match_operand:DF 0 "memory_operand" "")
4228         (float_truncate:DF
4229          (match_operand:TF 1 "register_operand" "")))
4230    (clobber (match_operand:DF 2 "memory_operand" ""))]
4231   "TARGET_80387"
4232   [(set (match_dup 0) (float_truncate:DF (match_dup 1)))]
4233   "")
4235 (define_split
4236   [(set (match_operand:DF 0 "register_operand" "")
4237         (float_truncate:DF
4238          (match_operand:TF 1 "register_operand" "")))
4239    (clobber (match_operand:DF 2 "memory_operand" ""))]
4240   "TARGET_80387 && reload_completed"
4241   [(set (match_dup 2) (float_truncate:DF (match_dup 1)))
4242    (set (match_dup 0) (match_dup 2))]
4243   "")
4246 ;; %%% Break up all these bad boys.
4248 ;; Signed conversion to DImode.
4250 (define_expand "fix_truncxfdi2"
4251   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4252         (fix:DI (match_operand:XF 1 "register_operand" "")))]
4253   "!TARGET_64BIT && TARGET_80387"
4254   "")
4256 (define_expand "fix_trunctfdi2"
4257   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4258         (fix:DI (match_operand:TF 1 "register_operand" "")))]
4259   "TARGET_80387"
4260   "")
4262 (define_expand "fix_truncdfdi2"
4263   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4264         (fix:DI (match_operand:DF 1 "register_operand" "")))]
4265   "TARGET_80387 || (TARGET_SSE2 && TARGET_64BIT)"
4267   if (TARGET_64BIT && TARGET_SSE2)
4268    {
4269      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (DImode);
4270      emit_insn (gen_fix_truncdfdi_sse (out, operands[1]));
4271      if (out != operands[0])
4272         emit_move_insn (operands[0], out);
4273      DONE;
4274    }
4277 (define_expand "fix_truncsfdi2"
4278   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4279         (fix:DI (match_operand:SF 1 "register_operand" "")))]
4280   "TARGET_80387 || (TARGET_SSE && TARGET_64BIT)"
4282   if (TARGET_SSE && TARGET_64BIT)
4283    {
4284      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (DImode);
4285      emit_insn (gen_fix_truncsfdi_sse (out, operands[1]));
4286      if (out != operands[0])
4287         emit_move_insn (operands[0], out);
4288      DONE;
4289    }
4292 ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4293 ;; of the machinery.
4294 (define_insn_and_split "*fix_truncdi_1"
4295   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r")
4296         (fix:DI (match_operand 1 "register_operand" "f,f")))]
4297   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4298    && !reload_completed && !reload_in_progress
4299    && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4300   "#"
4301   "&& 1"
4302   [(const_int 0)]
4304   operands[2] = assign_386_stack_local (HImode, 1);
4305   operands[3] = assign_386_stack_local (HImode, 2);
4306   if (memory_operand (operands[0], VOIDmode))
4307     emit_insn (gen_fix_truncdi_memory (operands[0], operands[1],
4308                                        operands[2], operands[3]));
4309   else
4310     {
4311       operands[4] = assign_386_stack_local (DImode, 0);
4312       emit_insn (gen_fix_truncdi_nomemory (operands[0], operands[1],
4313                                            operands[2], operands[3],
4314                                            operands[4]));
4315     }
4316   DONE;
4318   [(set_attr "type" "fistp")])
4320 (define_insn "fix_truncdi_nomemory"
4321   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,?r")
4322         (fix:DI (match_operand 1 "register_operand" "f,f")))
4323    (use (match_operand:HI 2 "memory_operand" "m,m"))
4324    (use (match_operand:HI 3 "memory_operand" "m,m"))
4325    (clobber (match_operand:DI 4 "memory_operand" "=m,m"))
4326    (clobber (match_scratch:DF 5 "=&1f,&1f"))]
4327   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4328    && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4329   "#"
4330   [(set_attr "type" "fistp")])
4332 (define_insn "fix_truncdi_memory"
4333   [(set (match_operand:DI 0 "memory_operand" "=m")
4334         (fix:DI (match_operand 1 "register_operand" "f")))
4335    (use (match_operand:HI 2 "memory_operand" "m"))
4336    (use (match_operand:HI 3 "memory_operand" "m"))
4337    (clobber (match_scratch:DF 4 "=&1f"))]
4338   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4339    && (!SSE_FLOAT_MODE_P (GET_MODE (operands[1])) || !TARGET_64BIT)"
4340   "* operands[5] = operands[4]; return output_fix_trunc (insn, operands);"
4341   [(set_attr "type" "fistp")])
4343 (define_split 
4344   [(set (match_operand:DI 0 "register_operand" "")
4345         (fix:DI (match_operand 1 "register_operand" "")))
4346    (use (match_operand:HI 2 "memory_operand" ""))
4347    (use (match_operand:HI 3 "memory_operand" ""))
4348    (clobber (match_operand:DI 4 "memory_operand" ""))
4349    (clobber (match_scratch 5 ""))]
4350   "reload_completed"
4351   [(parallel [(set (match_dup 4) (fix:DI (match_dup 1)))
4352               (use (match_dup 2))
4353               (use (match_dup 3))
4354               (clobber (match_dup 5))])
4355    (set (match_dup 0) (match_dup 4))]
4356   "")
4358 (define_split 
4359   [(set (match_operand:DI 0 "memory_operand" "")
4360         (fix:DI (match_operand 1 "register_operand" "")))
4361    (use (match_operand:HI 2 "memory_operand" ""))
4362    (use (match_operand:HI 3 "memory_operand" ""))
4363    (clobber (match_operand:DI 4 "memory_operand" ""))
4364    (clobber (match_scratch 5 ""))]
4365   "reload_completed"
4366   [(parallel [(set (match_dup 0) (fix:DI (match_dup 1)))
4367               (use (match_dup 2))
4368               (use (match_dup 3))
4369               (clobber (match_dup 5))])]
4370   "")
4372 ;; When SSE available, it is always faster to use it!
4373 (define_insn "fix_truncsfdi_sse"
4374   [(set (match_operand:DI 0 "register_operand" "=r,r")
4375         (fix:DI (match_operand:SF 1 "nonimmediate_operand" "x,xm")))]
4376   "TARGET_64BIT && TARGET_SSE"
4377   "cvttss2si{q}\t{%1, %0|%0, %1}"
4378   [(set_attr "type" "sseicvt")
4379    (set_attr "athlon_decode" "double,vector")])
4381 (define_insn "fix_truncdfdi_sse"
4382   [(set (match_operand:DI 0 "register_operand" "=r,r")
4383         (fix:DI (match_operand:DF 1 "nonimmediate_operand" "Y,Ym")))]
4384   "TARGET_64BIT && TARGET_SSE2"
4385   "cvttsd2si{q}\t{%1, %0|%0, %1}"
4386   [(set_attr "type" "sseicvt,sseicvt")
4387    (set_attr "athlon_decode" "double,vector")])
4389 ;; Signed conversion to SImode.
4391 (define_expand "fix_truncxfsi2"
4392   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4393         (fix:SI (match_operand:XF 1 "register_operand" "")))]
4394   "!TARGET_64BIT && TARGET_80387"
4395   "")
4397 (define_expand "fix_trunctfsi2"
4398   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4399         (fix:SI (match_operand:TF 1 "register_operand" "")))]
4400   "TARGET_80387"
4401   "")
4403 (define_expand "fix_truncdfsi2"
4404   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4405         (fix:SI (match_operand:DF 1 "register_operand" "")))]
4406   "TARGET_80387 || TARGET_SSE2"
4408   if (TARGET_SSE2)
4409    {
4410      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
4411      emit_insn (gen_fix_truncdfsi_sse (out, operands[1]));
4412      if (out != operands[0])
4413         emit_move_insn (operands[0], out);
4414      DONE;
4415    }
4418 (define_expand "fix_truncsfsi2"
4419   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4420         (fix:SI (match_operand:SF 1 "register_operand" "")))]
4421   "TARGET_80387 || TARGET_SSE"
4423   if (TARGET_SSE)
4424    {
4425      rtx out = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
4426      emit_insn (gen_fix_truncsfsi_sse (out, operands[1]));
4427      if (out != operands[0])
4428         emit_move_insn (operands[0], out);
4429      DONE;
4430    }
4433 ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4434 ;; of the machinery.
4435 (define_insn_and_split "*fix_truncsi_1"
4436   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r")
4437         (fix:SI (match_operand 1 "register_operand" "f,f")))]
4438   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4439    && !reload_completed && !reload_in_progress
4440    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4441   "#"
4442   "&& 1"
4443   [(const_int 0)]
4445   operands[2] = assign_386_stack_local (HImode, 1);
4446   operands[3] = assign_386_stack_local (HImode, 2);
4447   if (memory_operand (operands[0], VOIDmode))
4448     emit_insn (gen_fix_truncsi_memory (operands[0], operands[1],
4449                                        operands[2], operands[3]));
4450   else
4451     {
4452       operands[4] = assign_386_stack_local (SImode, 0);
4453       emit_insn (gen_fix_truncsi_nomemory (operands[0], operands[1],
4454                                            operands[2], operands[3],
4455                                            operands[4]));
4456     }
4457   DONE;
4459   [(set_attr "type" "fistp")])
4461 (define_insn "fix_truncsi_nomemory"
4462   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?r")
4463         (fix:SI (match_operand 1 "register_operand" "f,f")))
4464    (use (match_operand:HI 2 "memory_operand" "m,m"))
4465    (use (match_operand:HI 3 "memory_operand" "m,m"))
4466    (clobber (match_operand:SI 4 "memory_operand" "=m,m"))]
4467   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4468    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4469   "#"
4470   [(set_attr "type" "fistp")])
4472 (define_insn "fix_truncsi_memory"
4473   [(set (match_operand:SI 0 "memory_operand" "=m")
4474         (fix:SI (match_operand 1 "register_operand" "f")))
4475    (use (match_operand:HI 2 "memory_operand" "m"))
4476    (use (match_operand:HI 3 "memory_operand" "m"))]
4477   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4478    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4479   "* return output_fix_trunc (insn, operands);"
4480   [(set_attr "type" "fistp")])
4482 ;; When SSE available, it is always faster to use it!
4483 (define_insn "fix_truncsfsi_sse"
4484   [(set (match_operand:SI 0 "register_operand" "=r,r")
4485         (fix:SI (match_operand:SF 1 "nonimmediate_operand" "x,xm")))]
4486   "TARGET_SSE"
4487   "cvttss2si\t{%1, %0|%0, %1}"
4488   [(set_attr "type" "sseicvt")
4489    (set_attr "athlon_decode" "double,vector")])
4491 (define_insn "fix_truncdfsi_sse"
4492   [(set (match_operand:SI 0 "register_operand" "=r,r")
4493         (fix:SI (match_operand:DF 1 "nonimmediate_operand" "Y,Ym")))]
4494   "TARGET_SSE2"
4495   "cvttsd2si\t{%1, %0|%0, %1}"
4496   [(set_attr "type" "sseicvt")
4497    (set_attr "athlon_decode" "double,vector")])
4499 (define_split 
4500   [(set (match_operand:SI 0 "register_operand" "")
4501         (fix:SI (match_operand 1 "register_operand" "")))
4502    (use (match_operand:HI 2 "memory_operand" ""))
4503    (use (match_operand:HI 3 "memory_operand" ""))
4504    (clobber (match_operand:SI 4 "memory_operand" ""))]
4505   "reload_completed"
4506   [(parallel [(set (match_dup 4) (fix:SI (match_dup 1)))
4507               (use (match_dup 2))
4508               (use (match_dup 3))])
4509    (set (match_dup 0) (match_dup 4))]
4510   "")
4512 (define_split 
4513   [(set (match_operand:SI 0 "memory_operand" "")
4514         (fix:SI (match_operand 1 "register_operand" "")))
4515    (use (match_operand:HI 2 "memory_operand" ""))
4516    (use (match_operand:HI 3 "memory_operand" ""))
4517    (clobber (match_operand:SI 4 "memory_operand" ""))]
4518   "reload_completed"
4519   [(parallel [(set (match_dup 0) (fix:SI (match_dup 1)))
4520               (use (match_dup 2))
4521               (use (match_dup 3))])]
4522   "")
4524 ;; Signed conversion to HImode.
4526 (define_expand "fix_truncxfhi2"
4527   [(set (match_operand:HI 0 "nonimmediate_operand" "")
4528         (fix:HI (match_operand:XF 1 "register_operand" "")))]
4529   "!TARGET_64BIT && TARGET_80387"
4530   "")
4532 (define_expand "fix_trunctfhi2"
4533   [(set (match_operand:HI 0 "nonimmediate_operand" "")
4534         (fix:HI (match_operand:TF 1 "register_operand" "")))]
4535   "TARGET_80387"
4536   "")
4538 (define_expand "fix_truncdfhi2"
4539   [(set (match_operand:HI 0 "nonimmediate_operand" "")
4540         (fix:HI (match_operand:DF 1 "register_operand" "")))]
4541   "TARGET_80387 && !TARGET_SSE2"
4542   "")
4544 (define_expand "fix_truncsfhi2"
4545   [(set (match_operand:HI 0 "nonimmediate_operand" "")
4546         (fix:HI (match_operand:SF 1 "register_operand" "")))]
4547   "TARGET_80387 && !TARGET_SSE"
4548   "")
4550 ;; See the comments in i386.h near OPTIMIZE_MODE_SWITCHING for the description
4551 ;; of the machinery.
4552 (define_insn_and_split "*fix_trunchi_1"
4553   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r")
4554         (fix:HI (match_operand 1 "register_operand" "f,f")))]
4555   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4556    && !reload_completed && !reload_in_progress
4557    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4558   "#"
4559   ""
4560   [(const_int 0)]
4562   operands[2] = assign_386_stack_local (HImode, 1);
4563   operands[3] = assign_386_stack_local (HImode, 2);
4564   if (memory_operand (operands[0], VOIDmode))
4565     emit_insn (gen_fix_trunchi_memory (operands[0], operands[1],
4566                                        operands[2], operands[3]));
4567   else
4568     {
4569       operands[4] = assign_386_stack_local (HImode, 0);
4570       emit_insn (gen_fix_trunchi_nomemory (operands[0], operands[1],
4571                                            operands[2], operands[3],
4572                                            operands[4]));
4573     }
4574   DONE;
4576   [(set_attr "type" "fistp")])
4578 (define_insn "fix_trunchi_nomemory"
4579   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,?r")
4580         (fix:HI (match_operand 1 "register_operand" "f,f")))
4581    (use (match_operand:HI 2 "memory_operand" "m,m"))
4582    (use (match_operand:HI 3 "memory_operand" "m,m"))
4583    (clobber (match_operand:HI 4 "memory_operand" "=m,m"))]
4584   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4585    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4586   "#"
4587   [(set_attr "type" "fistp")])
4589 (define_insn "fix_trunchi_memory"
4590   [(set (match_operand:HI 0 "memory_operand" "=m")
4591         (fix:HI (match_operand 1 "register_operand" "f")))
4592    (use (match_operand:HI 2 "memory_operand" "m"))
4593    (use (match_operand:HI 3 "memory_operand" "m"))]
4594   "TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[1]))
4595    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))"
4596   "* return output_fix_trunc (insn, operands);"
4597   [(set_attr "type" "fistp")])
4599 (define_split 
4600   [(set (match_operand:HI 0 "memory_operand" "")
4601         (fix:HI (match_operand 1 "register_operand" "")))
4602    (use (match_operand:HI 2 "memory_operand" ""))
4603    (use (match_operand:HI 3 "memory_operand" ""))
4604    (clobber (match_operand:HI 4 "memory_operand" ""))]
4605   "reload_completed"
4606   [(parallel [(set (match_dup 0) (fix:HI (match_dup 1)))
4607               (use (match_dup 2))
4608               (use (match_dup 3))])]
4609   "")
4611 (define_split 
4612   [(set (match_operand:HI 0 "register_operand" "")
4613         (fix:HI (match_operand 1 "register_operand" "")))
4614    (use (match_operand:HI 2 "memory_operand" ""))
4615    (use (match_operand:HI 3 "memory_operand" ""))
4616    (clobber (match_operand:HI 4 "memory_operand" ""))]
4617   "reload_completed"
4618   [(parallel [(set (match_dup 4) (fix:HI (match_dup 1)))
4619               (use (match_dup 2))
4620               (use (match_dup 3))
4621               (clobber (match_dup 4))])
4622    (set (match_dup 0) (match_dup 4))]
4623   "")
4625 ;; %% Not used yet.
4626 (define_insn "x86_fnstcw_1"
4627   [(set (match_operand:HI 0 "memory_operand" "=m")
4628         (unspec:HI [(reg:HI 18)] UNSPEC_FSTCW))]
4629   "TARGET_80387"
4630   "fnstcw\t%0"
4631   [(set_attr "length" "2")
4632    (set_attr "mode" "HI")
4633    (set_attr "unit" "i387")
4634    (set_attr "ppro_uops" "few")])
4636 (define_insn "x86_fldcw_1"
4637   [(set (reg:HI 18)
4638         (unspec:HI [(match_operand:HI 0 "memory_operand" "m")] UNSPEC_FLDCW))]
4639   "TARGET_80387"
4640   "fldcw\t%0"
4641   [(set_attr "length" "2")
4642    (set_attr "mode" "HI")
4643    (set_attr "unit" "i387")
4644    (set_attr "athlon_decode" "vector")
4645    (set_attr "ppro_uops" "few")])
4647 ;; Conversion between fixed point and floating point.
4649 ;; Even though we only accept memory inputs, the backend _really_
4650 ;; wants to be able to do this between registers.
4652 (define_insn "floathisf2"
4653   [(set (match_operand:SF 0 "register_operand" "=f,f")
4654         (float:SF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
4655   "TARGET_80387 && !TARGET_SSE"
4656   "@
4657    fild%z1\t%1
4658    #"
4659   [(set_attr "type" "fmov,multi")
4660    (set_attr "mode" "SF")
4661    (set_attr "fp_int_src" "true")])
4663 (define_expand "floatsisf2"
4664   [(set (match_operand:SF 0 "register_operand" "")
4665         (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
4666   "TARGET_SSE || TARGET_80387"
4667   "")
4669 (define_insn "*floatsisf2_i387"
4670   [(set (match_operand:SF 0 "register_operand" "=f#x,?f#x,x#f,x#f")
4671         (float:SF (match_operand:SI 1 "nonimmediate_operand" "m,r,r,mr")))]
4672   "TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)"
4673   "@
4674    fild%z1\t%1
4675    #
4676    cvtsi2ss\t{%1, %0|%0, %1}
4677    cvtsi2ss\t{%1, %0|%0, %1}"
4678   [(set_attr "type" "fmov,multi,sseicvt,sseicvt")
4679    (set_attr "mode" "SF")
4680    (set_attr "athlon_decode" "*,*,vector,double")
4681    (set_attr "fp_int_src" "true")])
4683 (define_insn "*floatsisf2_sse"
4684   [(set (match_operand:SF 0 "register_operand" "=x,x")
4685         (float:SF (match_operand:SI 1 "nonimmediate_operand" "r,mr")))]
4686   "TARGET_SSE"
4687   "cvtsi2ss\t{%1, %0|%0, %1}"
4688   [(set_attr "type" "sseicvt")
4689    (set_attr "mode" "SF")
4690    (set_attr "athlon_decode" "vector,double")
4691    (set_attr "fp_int_src" "true")])
4693 ; Avoid possible reformatting penalty on the destination by first
4694 ; zeroing it out
4695 (define_split
4696   [(set (match_operand:SF 0 "register_operand" "")
4697         (float:SF (match_operand:SI 1 "nonimmediate_operand" "")))]
4698   "TARGET_80387 && reload_completed && TARGET_SSE_PARTIAL_REGS
4699    && SSE_REG_P (operands[0])"
4700   [(const_int 0)]
4702   rtx dest;
4703   dest = simplify_gen_subreg (V4SFmode, operands[0], SFmode, 0);
4704   emit_insn (gen_sse_clrv4sf (dest, CONST0_RTX (V4SFmode)));
4705   emit_insn (gen_cvtsi2ss (dest, dest, operands[1]));
4706   DONE;
4709 (define_expand "floatdisf2"
4710   [(set (match_operand:SF 0 "register_operand" "")
4711         (float:SF (match_operand:DI 1 "nonimmediate_operand" "")))]
4712   "(TARGET_64BIT && TARGET_SSE) || TARGET_80387"
4713   "")
4715 (define_insn "*floatdisf2_i387_only"
4716   [(set (match_operand:SF 0 "register_operand" "=f,?f")
4717         (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4718   "TARGET_80387 && (!TARGET_SSE || !TARGET_64BIT || TARGET_MIX_SSE_I387)"
4719   "@
4720    fild%z1\t%1
4721    #"
4722   [(set_attr "type" "fmov,multi")
4723    (set_attr "mode" "SF")
4724    (set_attr "fp_int_src" "true")])
4726 (define_insn "*floatdisf2_i387"
4727   [(set (match_operand:SF 0 "register_operand" "=f#x,?f#x,x#f,x#f")
4728         (float:SF (match_operand:DI 1 "nonimmediate_operand" "m,r,r,mr")))]
4729   "TARGET_64BIT && TARGET_80387 && (!TARGET_SSE || TARGET_MIX_SSE_I387)"
4730   "@
4731    fild%z1\t%1
4732    #
4733    cvtsi2ss{q}\t{%1, %0|%0, %1}
4734    cvtsi2ss{q}\t{%1, %0|%0, %1}"
4735   [(set_attr "type" "fmov,multi,sseicvt,sseicvt")
4736    (set_attr "mode" "SF")
4737    (set_attr "athlon_decode" "*,*,vector,double")
4738    (set_attr "fp_int_src" "true")])
4740 (define_insn "*floatdisf2_sse"
4741   [(set (match_operand:SF 0 "register_operand" "=x,x")
4742         (float:SF (match_operand:DI 1 "nonimmediate_operand" "r,mr")))]
4743   "TARGET_64BIT && TARGET_SSE"
4744   "cvtsi2ss{q}\t{%1, %0|%0, %1}"
4745   [(set_attr "type" "sseicvt")
4746    (set_attr "mode" "SF")
4747    (set_attr "athlon_decode" "vector,double")
4748    (set_attr "fp_int_src" "true")])
4750 ; Avoid possible reformatting penalty on the destination by first
4751 ; zeroing it out
4752 (define_split
4753   [(set (match_operand:SF 0 "register_operand" "")
4754         (float:SF (match_operand:DI 1 "nonimmediate_operand" "")))]
4755   "TARGET_80387 && reload_completed && TARGET_SSE_PARTIAL_REGS
4756    && SSE_REG_P (operands[0])"
4757   [(const_int 0)]
4759   rtx dest;
4760   dest = simplify_gen_subreg (V4SFmode, operands[0], SFmode, 0);
4761   emit_insn (gen_sse_clrv4sf (dest, CONST0_RTX (V4SFmode)));
4762   emit_insn (gen_cvtsi2ssq (dest, dest, operands[1]));
4763   DONE;
4766 (define_insn "floathidf2"
4767   [(set (match_operand:DF 0 "register_operand" "=f,f")
4768         (float:DF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
4769   "TARGET_80387 && !TARGET_SSE2"
4770   "@
4771    fild%z1\t%1
4772    #"
4773   [(set_attr "type" "fmov,multi")
4774    (set_attr "mode" "DF")
4775    (set_attr "fp_int_src" "true")])
4777 (define_expand "floatsidf2"
4778   [(set (match_operand:DF 0 "register_operand" "")
4779         (float:DF (match_operand:SI 1 "nonimmediate_operand" "")))]
4780   "TARGET_80387 || TARGET_SSE2"
4781   "")
4783 (define_insn "*floatsidf2_i387"
4784   [(set (match_operand:DF 0 "register_operand" "=f#Y,?f#Y,Y#f,Y#f")
4785         (float:DF (match_operand:SI 1 "nonimmediate_operand" "m,r,r,mr")))]
4786   "TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)"
4787   "@
4788    fild%z1\t%1
4789    #
4790    cvtsi2sd\t{%1, %0|%0, %1}
4791    cvtsi2sd\t{%1, %0|%0, %1}"
4792   [(set_attr "type" "fmov,multi,sseicvt,sseicvt")
4793    (set_attr "mode" "DF")
4794    (set_attr "athlon_decode" "*,*,double,direct")
4795    (set_attr "fp_int_src" "true")])
4797 (define_insn "*floatsidf2_sse"
4798   [(set (match_operand:DF 0 "register_operand" "=Y,Y")
4799         (float:DF (match_operand:SI 1 "nonimmediate_operand" "r,mr")))]
4800   "TARGET_SSE2"
4801   "cvtsi2sd\t{%1, %0|%0, %1}"
4802   [(set_attr "type" "sseicvt")
4803    (set_attr "mode" "DF")
4804    (set_attr "athlon_decode" "double,direct")
4805    (set_attr "fp_int_src" "true")])
4807 (define_expand "floatdidf2"
4808   [(set (match_operand:DF 0 "register_operand" "")
4809         (float:DF (match_operand:DI 1 "nonimmediate_operand" "")))]
4810   "(TARGET_64BIT && TARGET_SSE2) || TARGET_80387"
4811   "")
4813 (define_insn "*floatdidf2_i387_only"
4814   [(set (match_operand:DF 0 "register_operand" "=f,?f")
4815         (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4816   "TARGET_80387 && (!TARGET_SSE2 || !TARGET_64BIT)"
4817   "@
4818    fild%z1\t%1
4819    #"
4820   [(set_attr "type" "fmov,multi")
4821    (set_attr "mode" "DF")
4822    (set_attr "fp_int_src" "true")])
4824 (define_insn "*floatdidf2_i387"
4825   [(set (match_operand:DF 0 "register_operand" "=f#Y,?f#Y,Y#f,Y#f")
4826         (float:DF (match_operand:DI 1 "nonimmediate_operand" "m,r,r,mr")))]
4827   "TARGET_64BIT && TARGET_80387 && (!TARGET_SSE2 || TARGET_MIX_SSE_I387)"
4828   "@
4829    fild%z1\t%1
4830    #
4831    cvtsi2sd{q}\t{%1, %0|%0, %1}
4832    cvtsi2sd{q}\t{%1, %0|%0, %1}"
4833   [(set_attr "type" "fmov,multi,sseicvt,sseicvt")
4834    (set_attr "mode" "DF")
4835    (set_attr "athlon_decode" "*,*,double,direct")
4836    (set_attr "fp_int_src" "true")])
4838 (define_insn "*floatdidf2_sse"
4839   [(set (match_operand:DF 0 "register_operand" "=Y,Y")
4840         (float:DF (match_operand:DI 1 "nonimmediate_operand" "r,mr")))]
4841   "TARGET_SSE2"
4842   "cvtsi2sd{q}\t{%1, %0|%0, %1}"
4843   [(set_attr "type" "sseicvt")
4844    (set_attr "mode" "DF")
4845    (set_attr "athlon_decode" "double,direct")
4846    (set_attr "fp_int_src" "true")])
4848 (define_insn "floathixf2"
4849   [(set (match_operand:XF 0 "register_operand" "=f,f")
4850         (float:XF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
4851   "!TARGET_64BIT && TARGET_80387"
4852   "@
4853    fild%z1\t%1
4854    #"
4855   [(set_attr "type" "fmov,multi")
4856    (set_attr "mode" "XF")
4857    (set_attr "fp_int_src" "true")])
4859 (define_insn "floathitf2"
4860   [(set (match_operand:TF 0 "register_operand" "=f,f")
4861         (float:TF (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
4862   "TARGET_80387"
4863   "@
4864    fild%z1\t%1
4865    #"
4866   [(set_attr "type" "fmov,multi")
4867    (set_attr "mode" "XF")
4868    (set_attr "fp_int_src" "true")])
4870 (define_insn "floatsixf2"
4871   [(set (match_operand:XF 0 "register_operand" "=f,f")
4872         (float:XF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
4873   "!TARGET_64BIT && TARGET_80387"
4874   "@
4875    fild%z1\t%1
4876    #"
4877   [(set_attr "type" "fmov,multi")
4878    (set_attr "mode" "XF")
4879    (set_attr "fp_int_src" "true")])
4881 (define_insn "floatsitf2"
4882   [(set (match_operand:TF 0 "register_operand" "=f,f")
4883         (float:TF (match_operand:SI 1 "nonimmediate_operand" "m,r")))]
4884   "TARGET_80387"
4885   "@
4886    fild%z1\t%1
4887    #"
4888   [(set_attr "type" "fmov,multi")
4889    (set_attr "mode" "XF")
4890    (set_attr "fp_int_src" "true")])
4892 (define_insn "floatdixf2"
4893   [(set (match_operand:XF 0 "register_operand" "=f,f")
4894         (float:XF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4895   "!TARGET_64BIT && TARGET_80387"
4896   "@
4897    fild%z1\t%1
4898    #"
4899   [(set_attr "type" "fmov,multi")
4900    (set_attr "mode" "XF")
4901    (set_attr "fp_int_src" "true")])
4903 (define_insn "floatditf2"
4904   [(set (match_operand:TF 0 "register_operand" "=f,f")
4905         (float:TF (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
4906   "TARGET_80387"
4907   "@
4908    fild%z1\t%1
4909    #"
4910   [(set_attr "type" "fmov,multi")
4911    (set_attr "mode" "XF")
4912    (set_attr "fp_int_src" "true")])
4914 ;; %%% Kill these when reload knows how to do it.
4915 (define_split
4916   [(set (match_operand 0 "fp_register_operand" "")
4917         (float (match_operand 1 "register_operand" "")))]
4918   "reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
4919   [(const_int 0)]
4921   operands[2] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
4922   operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);
4923   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[2]));
4924   ix86_free_from_memory (GET_MODE (operands[1]));
4925   DONE;
4928 (define_expand "floatunssisf2"
4929   [(use (match_operand:SF 0 "register_operand" ""))
4930    (use (match_operand:SI 1 "register_operand" ""))]
4931   "TARGET_SSE && TARGET_SSE_MATH && !TARGET_64BIT"
4932   "x86_emit_floatuns (operands); DONE;")
4934 (define_expand "floatunsdisf2"
4935   [(use (match_operand:SF 0 "register_operand" ""))
4936    (use (match_operand:DI 1 "register_operand" ""))]
4937   "TARGET_SSE && TARGET_SSE_MATH && TARGET_64BIT"
4938   "x86_emit_floatuns (operands); DONE;")
4940 (define_expand "floatunsdidf2"
4941   [(use (match_operand:DF 0 "register_operand" ""))
4942    (use (match_operand:DI 1 "register_operand" ""))]
4943   "TARGET_SSE2 && TARGET_SSE_MATH && TARGET_64BIT"
4944   "x86_emit_floatuns (operands); DONE;")
4946 ;; Add instructions
4948 ;; %%% splits for addsidi3
4949 ;  [(set (match_operand:DI 0 "nonimmediate_operand" "")
4950 ;       (plus:DI (match_operand:DI 1 "general_operand" "")
4951 ;                (zero_extend:DI (match_operand:SI 2 "general_operand" ""))))]
4953 (define_expand "adddi3"
4954   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4955         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
4956                  (match_operand:DI 2 "x86_64_general_operand" "")))
4957    (clobber (reg:CC 17))]
4958   ""
4959   "ix86_expand_binary_operator (PLUS, DImode, operands); DONE;")
4961 (define_insn "*adddi3_1"
4962   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
4963         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4964                  (match_operand:DI 2 "general_operand" "roiF,riF")))
4965    (clobber (reg:CC 17))]
4966   "!TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
4967   "#")
4969 (define_split
4970   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4971         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
4972                  (match_operand:DI 2 "general_operand" "")))
4973    (clobber (reg:CC 17))]
4974   "!TARGET_64BIT && reload_completed"
4975   [(parallel [(set (reg:CC 17) (unspec:CC [(match_dup 1) (match_dup 2)]
4976                                           UNSPEC_ADD_CARRY))
4977               (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))])
4978    (parallel [(set (match_dup 3)
4979                    (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
4980                                      (match_dup 4))
4981                             (match_dup 5)))
4982               (clobber (reg:CC 17))])]
4983   "split_di (operands+0, 1, operands+0, operands+3);
4984    split_di (operands+1, 1, operands+1, operands+4);
4985    split_di (operands+2, 1, operands+2, operands+5);")
4987 (define_insn "adddi3_carry_rex64"
4988   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
4989           (plus:DI (plus:DI (match_operand:DI 3 "ix86_carry_flag_operator" "")
4990                             (match_operand:DI 1 "nonimmediate_operand" "%0,0"))
4991                    (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
4992    (clobber (reg:CC 17))]
4993   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
4994   "adc{q}\t{%2, %0|%0, %2}"
4995   [(set_attr "type" "alu")
4996    (set_attr "pent_pair" "pu")
4997    (set_attr "mode" "DI")
4998    (set_attr "ppro_uops" "few")])
5000 (define_insn "*adddi3_cc_rex64"
5001   [(set (reg:CC 17)
5002         (unspec:CC [(match_operand:DI 1 "nonimmediate_operand" "%0,0")
5003                     (match_operand:DI 2 "x86_64_general_operand" "re,rm")]
5004                    UNSPEC_ADD_CARRY))
5005    (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
5006         (plus:DI (match_dup 1) (match_dup 2)))]
5007   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
5008   "add{q}\t{%2, %0|%0, %2}"
5009   [(set_attr "type" "alu")
5010    (set_attr "mode" "DI")])
5012 (define_insn "addqi3_carry"
5013   [(set (match_operand:QI 0 "nonimmediate_operand" "=rm,r")
5014           (plus:QI (plus:QI (match_operand:QI 3 "ix86_carry_flag_operator" "")
5015                             (match_operand:QI 1 "nonimmediate_operand" "%0,0"))
5016                    (match_operand:QI 2 "general_operand" "ri,rm")))
5017    (clobber (reg:CC 17))]
5018   "ix86_binary_operator_ok (PLUS, QImode, operands)"
5019   "adc{b}\t{%2, %0|%0, %2}"
5020   [(set_attr "type" "alu")
5021    (set_attr "pent_pair" "pu")
5022    (set_attr "mode" "QI")
5023    (set_attr "ppro_uops" "few")])
5025 (define_insn "addhi3_carry"
5026   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
5027           (plus:HI (plus:HI (match_operand:HI 3 "ix86_carry_flag_operator" "")
5028                             (match_operand:HI 1 "nonimmediate_operand" "%0,0"))
5029                    (match_operand:HI 2 "general_operand" "ri,rm")))
5030    (clobber (reg:CC 17))]
5031   "ix86_binary_operator_ok (PLUS, HImode, operands)"
5032   "adc{w}\t{%2, %0|%0, %2}"
5033   [(set_attr "type" "alu")
5034    (set_attr "pent_pair" "pu")
5035    (set_attr "mode" "HI")
5036    (set_attr "ppro_uops" "few")])
5038 (define_insn "addsi3_carry"
5039   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
5040           (plus:SI (plus:SI (match_operand:SI 3 "ix86_carry_flag_operator" "")
5041                             (match_operand:SI 1 "nonimmediate_operand" "%0,0"))
5042                    (match_operand:SI 2 "general_operand" "ri,rm")))
5043    (clobber (reg:CC 17))]
5044   "ix86_binary_operator_ok (PLUS, SImode, operands)"
5045   "adc{l}\t{%2, %0|%0, %2}"
5046   [(set_attr "type" "alu")
5047    (set_attr "pent_pair" "pu")
5048    (set_attr "mode" "SI")
5049    (set_attr "ppro_uops" "few")])
5051 (define_insn "*addsi3_carry_zext"
5052   [(set (match_operand:DI 0 "register_operand" "=r")
5053           (zero_extend:DI 
5054             (plus:SI (plus:SI (match_operand:SI 3 "ix86_carry_flag_operator" "")
5055                               (match_operand:SI 1 "nonimmediate_operand" "%0"))
5056                      (match_operand:SI 2 "general_operand" "rim"))))
5057    (clobber (reg:CC 17))]
5058   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)"
5059   "adc{l}\t{%2, %k0|%k0, %2}"
5060   [(set_attr "type" "alu")
5061    (set_attr "pent_pair" "pu")
5062    (set_attr "mode" "SI")
5063    (set_attr "ppro_uops" "few")])
5065 (define_insn "*addsi3_cc"
5066   [(set (reg:CC 17)
5067         (unspec:CC [(match_operand:SI 1 "nonimmediate_operand" "%0,0")
5068                     (match_operand:SI 2 "general_operand" "ri,rm")]
5069                    UNSPEC_ADD_CARRY))
5070    (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
5071         (plus:SI (match_dup 1) (match_dup 2)))]
5072   "ix86_binary_operator_ok (PLUS, SImode, operands)"
5073   "add{l}\t{%2, %0|%0, %2}"
5074   [(set_attr "type" "alu")
5075    (set_attr "mode" "SI")])
5077 (define_insn "addqi3_cc"
5078   [(set (reg:CC 17)
5079         (unspec:CC [(match_operand:QI 1 "nonimmediate_operand" "%0,0")
5080                     (match_operand:QI 2 "general_operand" "qi,qm")]
5081                    UNSPEC_ADD_CARRY))
5082    (set (match_operand:QI 0 "nonimmediate_operand" "=qm,q")
5083         (plus:QI (match_dup 1) (match_dup 2)))]
5084   "ix86_binary_operator_ok (PLUS, QImode, operands)"
5085   "add{b}\t{%2, %0|%0, %2}"
5086   [(set_attr "type" "alu")
5087    (set_attr "mode" "QI")])
5089 (define_expand "addsi3"
5090   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
5091                    (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
5092                             (match_operand:SI 2 "general_operand" "")))
5093               (clobber (reg:CC 17))])]
5094   ""
5095   "ix86_expand_binary_operator (PLUS, SImode, operands); DONE;")
5097 (define_insn "*lea_1"
5098   [(set (match_operand:SI 0 "register_operand" "=r")
5099         (match_operand:SI 1 "address_operand" "p"))]
5100   "!TARGET_64BIT"
5101   "lea{l}\t{%a1, %0|%0, %a1}"
5102   [(set_attr "type" "lea")
5103    (set_attr "mode" "SI")])
5105 (define_insn "*lea_1_rex64"
5106   [(set (match_operand:SI 0 "register_operand" "=r")
5107         (subreg:SI (match_operand:DI 1 "address_operand" "p") 0))]
5108   "TARGET_64BIT"
5109   "lea{l}\t{%a1, %0|%0, %a1}"
5110   [(set_attr "type" "lea")
5111    (set_attr "mode" "SI")])
5113 (define_insn "*lea_1_zext"
5114   [(set (match_operand:DI 0 "register_operand" "=r")
5115         (zero_extend:DI (subreg:SI (match_operand:DI 1 "address_operand" "p") 0)))]
5116   "TARGET_64BIT"
5117   "lea{l}\t{%a1, %k0|%k0, %a1}"
5118   [(set_attr "type" "lea")
5119    (set_attr "mode" "SI")])
5121 (define_insn "*lea_2_rex64"
5122   [(set (match_operand:DI 0 "register_operand" "=r")
5123         (match_operand:DI 1 "address_operand" "p"))]
5124   "TARGET_64BIT"
5125   "lea{q}\t{%a1, %0|%0, %a1}"
5126   [(set_attr "type" "lea")
5127    (set_attr "mode" "DI")])
5129 ;; The lea patterns for non-Pmodes needs to be matched by several
5130 ;; insns converted to real lea by splitters.
5132 (define_insn_and_split "*lea_general_1"
5133   [(set (match_operand 0 "register_operand" "=r")
5134         (plus (plus (match_operand 1 "index_register_operand" "r")
5135                     (match_operand 2 "register_operand" "r"))
5136               (match_operand 3 "immediate_operand" "i")))]
5137   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
5138     || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
5139    && (!TARGET_PARTIAL_REG_STALL || optimize_size)
5140    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5141    && GET_MODE (operands[0]) == GET_MODE (operands[2])
5142    && (GET_MODE (operands[0]) == GET_MODE (operands[3])
5143        || GET_MODE (operands[3]) == VOIDmode)"
5144   "#"
5145   "&& reload_completed"
5146   [(const_int 0)]
5148   rtx pat;
5149   operands[0] = gen_lowpart (SImode, operands[0]);
5150   operands[1] = gen_lowpart (Pmode, operands[1]);
5151   operands[2] = gen_lowpart (Pmode, operands[2]);
5152   operands[3] = gen_lowpart (Pmode, operands[3]);
5153   pat = gen_rtx_PLUS (Pmode, gen_rtx_PLUS (Pmode, operands[1], operands[2]),
5154                       operands[3]);
5155   if (Pmode != SImode)
5156     pat = gen_rtx_SUBREG (SImode, pat, 0);
5157   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5158   DONE;
5160   [(set_attr "type" "lea")
5161    (set_attr "mode" "SI")])
5163 (define_insn_and_split "*lea_general_1_zext"
5164   [(set (match_operand:DI 0 "register_operand" "=r")
5165         (zero_extend:DI
5166           (plus:SI (plus:SI (match_operand:SI 1 "index_register_operand" "r")
5167                             (match_operand:SI 2 "register_operand" "r"))
5168                    (match_operand:SI 3 "immediate_operand" "i"))))]
5169   "TARGET_64BIT"
5170   "#"
5171   "&& reload_completed"
5172   [(set (match_dup 0)
5173         (zero_extend:DI (subreg:SI (plus:DI (plus:DI (match_dup 1)
5174                                                      (match_dup 2))
5175                                             (match_dup 3)) 0)))]
5177   operands[1] = gen_lowpart (Pmode, operands[1]);
5178   operands[2] = gen_lowpart (Pmode, operands[2]);
5179   operands[3] = gen_lowpart (Pmode, operands[3]);
5181   [(set_attr "type" "lea")
5182    (set_attr "mode" "SI")])
5184 (define_insn_and_split "*lea_general_2"
5185   [(set (match_operand 0 "register_operand" "=r")
5186         (plus (mult (match_operand 1 "index_register_operand" "r")
5187                     (match_operand 2 "const248_operand" "i"))
5188               (match_operand 3 "nonmemory_operand" "ri")))]
5189   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
5190     || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
5191    && (!TARGET_PARTIAL_REG_STALL || optimize_size)
5192    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5193    && (GET_MODE (operands[0]) == GET_MODE (operands[3])
5194        || GET_MODE (operands[3]) == VOIDmode)"
5195   "#"
5196   "&& reload_completed"
5197   [(const_int 0)]
5199   rtx pat;
5200   operands[0] = gen_lowpart (SImode, operands[0]);
5201   operands[1] = gen_lowpart (Pmode, operands[1]);
5202   operands[3] = gen_lowpart (Pmode, operands[3]);
5203   pat = gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1], operands[2]),
5204                       operands[3]);
5205   if (Pmode != SImode)
5206     pat = gen_rtx_SUBREG (SImode, pat, 0);
5207   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5208   DONE;
5210   [(set_attr "type" "lea")
5211    (set_attr "mode" "SI")])
5213 (define_insn_and_split "*lea_general_2_zext"
5214   [(set (match_operand:DI 0 "register_operand" "=r")
5215         (zero_extend:DI
5216           (plus:SI (mult:SI (match_operand:SI 1 "index_register_operand" "r")
5217                             (match_operand:SI 2 "const248_operand" "n"))
5218                    (match_operand:SI 3 "nonmemory_operand" "ri"))))]
5219   "TARGET_64BIT"
5220   "#"
5221   "&& reload_completed"
5222   [(set (match_dup 0)
5223         (zero_extend:DI (subreg:SI (plus:DI (mult:DI (match_dup 1)
5224                                                      (match_dup 2))
5225                                             (match_dup 3)) 0)))]
5227   operands[1] = gen_lowpart (Pmode, operands[1]);
5228   operands[3] = gen_lowpart (Pmode, operands[3]);
5230   [(set_attr "type" "lea")
5231    (set_attr "mode" "SI")])
5233 (define_insn_and_split "*lea_general_3"
5234   [(set (match_operand 0 "register_operand" "=r")
5235         (plus (plus (mult (match_operand 1 "index_register_operand" "r")
5236                           (match_operand 2 "const248_operand" "i"))
5237                     (match_operand 3 "register_operand" "r"))
5238               (match_operand 4 "immediate_operand" "i")))]
5239   "(GET_MODE (operands[0]) == QImode || GET_MODE (operands[0]) == HImode
5240     || (TARGET_64BIT && GET_MODE (operands[0]) == SImode))
5241    && (!TARGET_PARTIAL_REG_STALL || optimize_size)
5242    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5243    && GET_MODE (operands[0]) == GET_MODE (operands[3])"
5244   "#"
5245   "&& reload_completed"
5246   [(const_int 0)]
5248   rtx pat;
5249   operands[0] = gen_lowpart (SImode, operands[0]);
5250   operands[1] = gen_lowpart (Pmode, operands[1]);
5251   operands[3] = gen_lowpart (Pmode, operands[3]);
5252   operands[4] = gen_lowpart (Pmode, operands[4]);
5253   pat = gen_rtx_PLUS (Pmode,
5254                       gen_rtx_PLUS (Pmode, gen_rtx_MULT (Pmode, operands[1],
5255                                                          operands[2]),
5256                                     operands[3]),
5257                       operands[4]);
5258   if (Pmode != SImode)
5259     pat = gen_rtx_SUBREG (SImode, pat, 0);
5260   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5261   DONE;
5263   [(set_attr "type" "lea")
5264    (set_attr "mode" "SI")])
5266 (define_insn_and_split "*lea_general_3_zext"
5267   [(set (match_operand:DI 0 "register_operand" "=r")
5268         (zero_extend:DI
5269           (plus:SI (plus:SI (mult:SI (match_operand:SI 1 "index_register_operand" "r")
5270                                      (match_operand:SI 2 "const248_operand" "n"))
5271                             (match_operand:SI 3 "register_operand" "r"))
5272                    (match_operand:SI 4 "immediate_operand" "i"))))]
5273   "TARGET_64BIT"
5274   "#"
5275   "&& reload_completed"
5276   [(set (match_dup 0)
5277         (zero_extend:DI (subreg:SI (plus:DI (plus:DI (mult:DI (match_dup 1)
5278                                                               (match_dup 2))
5279                                                      (match_dup 3))
5280                                             (match_dup 4)) 0)))]
5282   operands[1] = gen_lowpart (Pmode, operands[1]);
5283   operands[3] = gen_lowpart (Pmode, operands[3]);
5284   operands[4] = gen_lowpart (Pmode, operands[4]);
5286   [(set_attr "type" "lea")
5287    (set_attr "mode" "SI")])
5289 (define_insn "*adddi_1_rex64"
5290   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r")
5291         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,r")
5292                  (match_operand:DI 2 "x86_64_general_operand" "rme,re,re")))
5293    (clobber (reg:CC 17))]
5294   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, DImode, operands)"
5296   switch (get_attr_type (insn))
5297     {
5298     case TYPE_LEA:
5299       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
5300       return "lea{q}\t{%a2, %0|%0, %a2}";
5302     case TYPE_INCDEC:
5303       if (! rtx_equal_p (operands[0], operands[1]))
5304         abort ();
5305       if (operands[2] == const1_rtx)
5306         return "inc{q}\t%0";
5307       else if (operands[2] == constm1_rtx)
5308         return "dec{q}\t%0";
5309       else
5310         abort ();
5312     default:
5313       if (! rtx_equal_p (operands[0], operands[1]))
5314         abort ();
5316       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5317          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5318       if (GET_CODE (operands[2]) == CONST_INT
5319           /* Avoid overflows.  */
5320           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5321           && (INTVAL (operands[2]) == 128
5322               || (INTVAL (operands[2]) < 0
5323                   && INTVAL (operands[2]) != -128)))
5324         {
5325           operands[2] = GEN_INT (-INTVAL (operands[2]));
5326           return "sub{q}\t{%2, %0|%0, %2}";
5327         }
5328       return "add{q}\t{%2, %0|%0, %2}";
5329     }
5331   [(set (attr "type")
5332      (cond [(eq_attr "alternative" "2")
5333               (const_string "lea")
5334             ; Current assemblers are broken and do not allow @GOTOFF in
5335             ; ought but a memory context.
5336             (match_operand:DI 2 "pic_symbolic_operand" "")
5337               (const_string "lea")
5338             (match_operand:DI 2 "incdec_operand" "")
5339               (const_string "incdec")
5340            ]
5341            (const_string "alu")))
5342    (set_attr "mode" "DI")])
5344 ;; Convert lea to the lea pattern to avoid flags dependency.
5345 (define_split
5346   [(set (match_operand:DI 0 "register_operand" "")
5347         (plus:DI (match_operand:DI 1 "register_operand" "")
5348                  (match_operand:DI 2 "x86_64_nonmemory_operand" "")))
5349    (clobber (reg:CC 17))]
5350   "TARGET_64BIT && reload_completed
5351    && true_regnum (operands[0]) != true_regnum (operands[1])"
5352   [(set (match_dup 0)
5353         (plus:DI (match_dup 1)
5354                  (match_dup 2)))]
5355   "")
5357 (define_insn "*adddi_2_rex64"
5358   [(set (reg 17)
5359         (compare
5360           (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5361                    (match_operand:DI 2 "x86_64_general_operand" "rme,re"))
5362           (const_int 0)))                       
5363    (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
5364         (plus:DI (match_dup 1) (match_dup 2)))]
5365   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
5366    && ix86_binary_operator_ok (PLUS, DImode, operands)
5367    /* Current assemblers are broken and do not allow @GOTOFF in
5368       ought but a memory context.  */
5369    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5371   switch (get_attr_type (insn))
5372     {
5373     case TYPE_INCDEC:
5374       if (! rtx_equal_p (operands[0], operands[1]))
5375         abort ();
5376       if (operands[2] == const1_rtx)
5377         return "inc{q}\t%0";
5378       else if (operands[2] == constm1_rtx)
5379         return "dec{q}\t%0";
5380       else
5381         abort ();
5383     default:
5384       if (! rtx_equal_p (operands[0], operands[1]))
5385         abort ();
5386       /* ???? We ought to handle there the 32bit case too
5387          - do we need new constraint?  */
5388       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5389          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5390       if (GET_CODE (operands[2]) == CONST_INT
5391           /* Avoid overflows.  */
5392           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5393           && (INTVAL (operands[2]) == 128
5394               || (INTVAL (operands[2]) < 0
5395                   && INTVAL (operands[2]) != -128)))
5396         {
5397           operands[2] = GEN_INT (-INTVAL (operands[2]));
5398           return "sub{q}\t{%2, %0|%0, %2}";
5399         }
5400       return "add{q}\t{%2, %0|%0, %2}";
5401     }
5403   [(set (attr "type")
5404      (if_then_else (match_operand:DI 2 "incdec_operand" "")
5405         (const_string "incdec")
5406         (const_string "alu")))
5407    (set_attr "mode" "DI")])
5409 (define_insn "*adddi_3_rex64"
5410   [(set (reg 17)
5411         (compare (neg:DI (match_operand:DI 2 "x86_64_general_operand" "rme"))
5412                  (match_operand:DI 1 "x86_64_general_operand" "%0")))
5413    (clobber (match_scratch:DI 0 "=r"))]
5414   "TARGET_64BIT
5415    && ix86_match_ccmode (insn, CCZmode)
5416    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5417    /* Current assemblers are broken and do not allow @GOTOFF in
5418       ought but a memory context.  */
5419    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5421   switch (get_attr_type (insn))
5422     {
5423     case TYPE_INCDEC:
5424       if (! rtx_equal_p (operands[0], operands[1]))
5425         abort ();
5426       if (operands[2] == const1_rtx)
5427         return "inc{q}\t%0";
5428       else if (operands[2] == constm1_rtx)
5429         return "dec{q}\t%0";
5430       else
5431         abort ();
5433     default:
5434       if (! rtx_equal_p (operands[0], operands[1]))
5435         abort ();
5436       /* ???? We ought to handle there the 32bit case too
5437          - do we need new constraint?  */
5438       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5439          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5440       if (GET_CODE (operands[2]) == CONST_INT
5441           /* Avoid overflows.  */
5442           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5443           && (INTVAL (operands[2]) == 128
5444               || (INTVAL (operands[2]) < 0
5445                   && INTVAL (operands[2]) != -128)))
5446         {
5447           operands[2] = GEN_INT (-INTVAL (operands[2]));
5448           return "sub{q}\t{%2, %0|%0, %2}";
5449         }
5450       return "add{q}\t{%2, %0|%0, %2}";
5451     }
5453   [(set (attr "type")
5454      (if_then_else (match_operand:DI 2 "incdec_operand" "")
5455         (const_string "incdec")
5456         (const_string "alu")))
5457    (set_attr "mode" "DI")])
5459 ; For comparisons against 1, -1 and 128, we may generate better code
5460 ; by converting cmp to add, inc or dec as done by peephole2.  This pattern
5461 ; is matched then.  We can't accept general immediate, because for
5462 ; case of overflows,  the result is messed up.
5463 ; This pattern also don't hold of 0x8000000000000000, since the value overflows
5464 ; when negated.
5465 ; Also carry flag is reversed compared to cmp, so this conversion is valid
5466 ; only for comparisons not depending on it.
5467 (define_insn "*adddi_4_rex64"
5468   [(set (reg 17)
5469         (compare (match_operand:DI 1 "nonimmediate_operand" "0")
5470                  (match_operand:DI 2 "x86_64_immediate_operand" "e")))
5471    (clobber (match_scratch:DI 0 "=rm"))]
5472   "TARGET_64BIT
5473    &&  ix86_match_ccmode (insn, CCGCmode)"
5475   switch (get_attr_type (insn))
5476     {
5477     case TYPE_INCDEC:
5478       if (operands[2] == constm1_rtx)
5479         return "inc{q}\t%0";
5480       else if (operands[2] == const1_rtx)
5481         return "dec{q}\t%0";
5482       else
5483         abort();
5485     default:
5486       if (! rtx_equal_p (operands[0], operands[1]))
5487         abort ();
5488       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5489          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5490       if ((INTVAL (operands[2]) == -128
5491            || (INTVAL (operands[2]) > 0
5492                && INTVAL (operands[2]) != 128))
5493           /* Avoid overflows.  */
5494           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1))))
5495         return "sub{q}\t{%2, %0|%0, %2}";
5496       operands[2] = GEN_INT (-INTVAL (operands[2]));
5497       return "add{q}\t{%2, %0|%0, %2}";
5498     }
5500   [(set (attr "type")
5501      (if_then_else (match_operand:DI 2 "incdec_operand" "")
5502         (const_string "incdec")
5503         (const_string "alu")))
5504    (set_attr "mode" "DI")])
5506 (define_insn "*adddi_5_rex64"
5507   [(set (reg 17)
5508         (compare
5509           (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
5510                    (match_operand:DI 2 "x86_64_general_operand" "rme"))
5511           (const_int 0)))                       
5512    (clobber (match_scratch:DI 0 "=r"))]
5513   "TARGET_64BIT
5514    && ix86_match_ccmode (insn, CCGOCmode)
5515    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5516    /* Current assemblers are broken and do not allow @GOTOFF in
5517       ought but a memory context.  */
5518    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5520   switch (get_attr_type (insn))
5521     {
5522     case TYPE_INCDEC:
5523       if (! rtx_equal_p (operands[0], operands[1]))
5524         abort ();
5525       if (operands[2] == const1_rtx)
5526         return "inc{q}\t%0";
5527       else if (operands[2] == constm1_rtx)
5528         return "dec{q}\t%0";
5529       else
5530         abort();
5532     default:
5533       if (! rtx_equal_p (operands[0], operands[1]))
5534         abort ();
5535       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5536          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5537       if (GET_CODE (operands[2]) == CONST_INT
5538           /* Avoid overflows.  */
5539           && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
5540           && (INTVAL (operands[2]) == 128
5541               || (INTVAL (operands[2]) < 0
5542                   && INTVAL (operands[2]) != -128)))
5543         {
5544           operands[2] = GEN_INT (-INTVAL (operands[2]));
5545           return "sub{q}\t{%2, %0|%0, %2}";
5546         }
5547       return "add{q}\t{%2, %0|%0, %2}";
5548     }
5550   [(set (attr "type")
5551      (if_then_else (match_operand:DI 2 "incdec_operand" "")
5552         (const_string "incdec")
5553         (const_string "alu")))
5554    (set_attr "mode" "DI")])
5557 (define_insn "*addsi_1"
5558   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,rm,r")
5559         (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,r")
5560                  (match_operand:SI 2 "general_operand" "rmni,rni,rni")))
5561    (clobber (reg:CC 17))]
5562   "ix86_binary_operator_ok (PLUS, SImode, operands)"
5564   switch (get_attr_type (insn))
5565     {
5566     case TYPE_LEA:
5567       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
5568       return "lea{l}\t{%a2, %0|%0, %a2}";
5570     case TYPE_INCDEC:
5571       if (! rtx_equal_p (operands[0], operands[1]))
5572         abort ();
5573       if (operands[2] == const1_rtx)
5574         return "inc{l}\t%0";
5575       else if (operands[2] == constm1_rtx)
5576         return "dec{l}\t%0";
5577       else
5578         abort();
5580     default:
5581       if (! rtx_equal_p (operands[0], operands[1]))
5582         abort ();
5584       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5585          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5586       if (GET_CODE (operands[2]) == CONST_INT
5587           && (INTVAL (operands[2]) == 128
5588               || (INTVAL (operands[2]) < 0
5589                   && INTVAL (operands[2]) != -128)))
5590         {
5591           operands[2] = GEN_INT (-INTVAL (operands[2]));
5592           return "sub{l}\t{%2, %0|%0, %2}";
5593         }
5594       return "add{l}\t{%2, %0|%0, %2}";
5595     }
5597   [(set (attr "type")
5598      (cond [(eq_attr "alternative" "2")
5599               (const_string "lea")
5600             ; Current assemblers are broken and do not allow @GOTOFF in
5601             ; ought but a memory context.
5602             (match_operand:SI 2 "pic_symbolic_operand" "")
5603               (const_string "lea")
5604             (match_operand:SI 2 "incdec_operand" "")
5605               (const_string "incdec")
5606            ]
5607            (const_string "alu")))
5608    (set_attr "mode" "SI")])
5610 ;; Convert lea to the lea pattern to avoid flags dependency.
5611 (define_split
5612   [(set (match_operand 0 "register_operand" "")
5613         (plus (match_operand 1 "register_operand" "")
5614               (match_operand 2 "nonmemory_operand" "")))
5615    (clobber (reg:CC 17))]
5616   "reload_completed
5617    && true_regnum (operands[0]) != true_regnum (operands[1])"
5618   [(const_int 0)]
5620   rtx pat;
5621   /* In -fPIC mode the constructs like (const (unspec [symbol_ref]))
5622      may confuse gen_lowpart.  */
5623   if (GET_MODE (operands[0]) != Pmode)
5624     {
5625       operands[1] = gen_lowpart (Pmode, operands[1]);
5626       operands[2] = gen_lowpart (Pmode, operands[2]);
5627     }
5628   operands[0] = gen_lowpart (SImode, operands[0]);
5629   pat = gen_rtx_PLUS (Pmode, operands[1], operands[2]);
5630   if (Pmode != SImode)
5631     pat = gen_rtx_SUBREG (SImode, pat, 0);
5632   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
5633   DONE;
5636 ;; It may seem that nonimmediate operand is proper one for operand 1.
5637 ;; The addsi_1 pattern allows nonimmediate operand at that place and
5638 ;; we take care in ix86_binary_operator_ok to not allow two memory
5639 ;; operands so proper swapping will be done in reload.  This allow
5640 ;; patterns constructed from addsi_1 to match.
5641 (define_insn "addsi_1_zext"
5642   [(set (match_operand:DI 0 "register_operand" "=r,r")
5643         (zero_extend:DI
5644           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,r")
5645                    (match_operand:SI 2 "general_operand" "rmni,rni"))))
5646    (clobber (reg:CC 17))]
5647   "TARGET_64BIT && ix86_binary_operator_ok (PLUS, SImode, operands)"
5649   switch (get_attr_type (insn))
5650     {
5651     case TYPE_LEA:
5652       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
5653       return "lea{l}\t{%a2, %k0|%k0, %a2}";
5655     case TYPE_INCDEC:
5656       if (operands[2] == const1_rtx)
5657         return "inc{l}\t%k0";
5658       else if (operands[2] == constm1_rtx)
5659         return "dec{l}\t%k0";
5660       else
5661         abort();
5663     default:
5664       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5665          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5666       if (GET_CODE (operands[2]) == CONST_INT
5667           && (INTVAL (operands[2]) == 128
5668               || (INTVAL (operands[2]) < 0
5669                   && INTVAL (operands[2]) != -128)))
5670         {
5671           operands[2] = GEN_INT (-INTVAL (operands[2]));
5672           return "sub{l}\t{%2, %k0|%k0, %2}";
5673         }
5674       return "add{l}\t{%2, %k0|%k0, %2}";
5675     }
5677   [(set (attr "type")
5678      (cond [(eq_attr "alternative" "1")
5679               (const_string "lea")
5680             ; Current assemblers are broken and do not allow @GOTOFF in
5681             ; ought but a memory context.
5682             (match_operand:SI 2 "pic_symbolic_operand" "")
5683               (const_string "lea")
5684             (match_operand:SI 2 "incdec_operand" "")
5685               (const_string "incdec")
5686            ]
5687            (const_string "alu")))
5688    (set_attr "mode" "SI")])
5690 ;; Convert lea to the lea pattern to avoid flags dependency.
5691 (define_split
5692   [(set (match_operand:DI 0 "register_operand" "")
5693         (zero_extend:DI
5694           (plus:SI (match_operand:SI 1 "register_operand" "")
5695                    (match_operand:SI 2 "nonmemory_operand" ""))))
5696    (clobber (reg:CC 17))]
5697   "TARGET_64BIT && reload_completed
5698    && true_regnum (operands[0]) != true_regnum (operands[1])"
5699   [(set (match_dup 0)
5700         (zero_extend:DI (subreg:SI (plus:DI (match_dup 1) (match_dup 2)) 0)))]
5702   operands[1] = gen_lowpart (Pmode, operands[1]);
5703   operands[2] = gen_lowpart (Pmode, operands[2]);
5706 (define_insn "*addsi_2"
5707   [(set (reg 17)
5708         (compare
5709           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
5710                    (match_operand:SI 2 "general_operand" "rmni,rni"))
5711           (const_int 0)))                       
5712    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
5713         (plus:SI (match_dup 1) (match_dup 2)))]
5714   "ix86_match_ccmode (insn, CCGOCmode)
5715    && ix86_binary_operator_ok (PLUS, SImode, operands)
5716    /* Current assemblers are broken and do not allow @GOTOFF in
5717       ought but a memory context.  */
5718    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5720   switch (get_attr_type (insn))
5721     {
5722     case TYPE_INCDEC:
5723       if (! rtx_equal_p (operands[0], operands[1]))
5724         abort ();
5725       if (operands[2] == const1_rtx)
5726         return "inc{l}\t%0";
5727       else if (operands[2] == constm1_rtx)
5728         return "dec{l}\t%0";
5729       else
5730         abort();
5732     default:
5733       if (! rtx_equal_p (operands[0], operands[1]))
5734         abort ();
5735       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5736          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5737       if (GET_CODE (operands[2]) == CONST_INT
5738           && (INTVAL (operands[2]) == 128
5739               || (INTVAL (operands[2]) < 0
5740                   && INTVAL (operands[2]) != -128)))
5741         {
5742           operands[2] = GEN_INT (-INTVAL (operands[2]));
5743           return "sub{l}\t{%2, %0|%0, %2}";
5744         }
5745       return "add{l}\t{%2, %0|%0, %2}";
5746     }
5748   [(set (attr "type")
5749      (if_then_else (match_operand:SI 2 "incdec_operand" "")
5750         (const_string "incdec")
5751         (const_string "alu")))
5752    (set_attr "mode" "SI")])
5754 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
5755 (define_insn "*addsi_2_zext"
5756   [(set (reg 17)
5757         (compare
5758           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
5759                    (match_operand:SI 2 "general_operand" "rmni"))
5760           (const_int 0)))                       
5761    (set (match_operand:DI 0 "register_operand" "=r")
5762         (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
5763   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
5764    && ix86_binary_operator_ok (PLUS, SImode, operands)
5765    /* Current assemblers are broken and do not allow @GOTOFF in
5766       ought but a memory context.  */
5767    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5769   switch (get_attr_type (insn))
5770     {
5771     case TYPE_INCDEC:
5772       if (operands[2] == const1_rtx)
5773         return "inc{l}\t%k0";
5774       else if (operands[2] == constm1_rtx)
5775         return "dec{l}\t%k0";
5776       else
5777         abort();
5779     default:
5780       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5781          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5782       if (GET_CODE (operands[2]) == CONST_INT
5783           && (INTVAL (operands[2]) == 128
5784               || (INTVAL (operands[2]) < 0
5785                   && INTVAL (operands[2]) != -128)))
5786         {
5787           operands[2] = GEN_INT (-INTVAL (operands[2]));
5788           return "sub{l}\t{%2, %k0|%k0, %2}";
5789         }
5790       return "add{l}\t{%2, %k0|%k0, %2}";
5791     }
5793   [(set (attr "type")
5794      (if_then_else (match_operand:SI 2 "incdec_operand" "")
5795         (const_string "incdec")
5796         (const_string "alu")))
5797    (set_attr "mode" "SI")])
5799 (define_insn "*addsi_3"
5800   [(set (reg 17)
5801         (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni"))
5802                  (match_operand:SI 1 "nonimmediate_operand" "%0")))
5803    (clobber (match_scratch:SI 0 "=r"))]
5804   "ix86_match_ccmode (insn, CCZmode)
5805    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5806    /* Current assemblers are broken and do not allow @GOTOFF in
5807       ought but a memory context.  */
5808    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5810   switch (get_attr_type (insn))
5811     {
5812     case TYPE_INCDEC:
5813       if (! rtx_equal_p (operands[0], operands[1]))
5814         abort ();
5815       if (operands[2] == const1_rtx)
5816         return "inc{l}\t%0";
5817       else if (operands[2] == constm1_rtx)
5818         return "dec{l}\t%0";
5819       else
5820         abort();
5822     default:
5823       if (! rtx_equal_p (operands[0], operands[1]))
5824         abort ();
5825       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5826          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5827       if (GET_CODE (operands[2]) == CONST_INT
5828           && (INTVAL (operands[2]) == 128
5829               || (INTVAL (operands[2]) < 0
5830                   && INTVAL (operands[2]) != -128)))
5831         {
5832           operands[2] = GEN_INT (-INTVAL (operands[2]));
5833           return "sub{l}\t{%2, %0|%0, %2}";
5834         }
5835       return "add{l}\t{%2, %0|%0, %2}";
5836     }
5838   [(set (attr "type")
5839      (if_then_else (match_operand:SI 2 "incdec_operand" "")
5840         (const_string "incdec")
5841         (const_string "alu")))
5842    (set_attr "mode" "SI")])
5844 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
5845 (define_insn "*addsi_3_zext"
5846   [(set (reg 17)
5847         (compare (neg:SI (match_operand:SI 2 "general_operand" "rmni"))
5848                  (match_operand:SI 1 "nonimmediate_operand" "%0")))
5849    (set (match_operand:DI 0 "register_operand" "=r")
5850         (zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))]
5851   "TARGET_64BIT && ix86_match_ccmode (insn, CCZmode)
5852    && ix86_binary_operator_ok (PLUS, SImode, operands)
5853    /* Current assemblers are broken and do not allow @GOTOFF in
5854       ought but a memory context.  */
5855    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5857   switch (get_attr_type (insn))
5858     {
5859     case TYPE_INCDEC:
5860       if (operands[2] == const1_rtx)
5861         return "inc{l}\t%k0";
5862       else if (operands[2] == constm1_rtx)
5863         return "dec{l}\t%k0";
5864       else
5865         abort();
5867     default:
5868       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5869          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5870       if (GET_CODE (operands[2]) == CONST_INT
5871           && (INTVAL (operands[2]) == 128
5872               || (INTVAL (operands[2]) < 0
5873                   && INTVAL (operands[2]) != -128)))
5874         {
5875           operands[2] = GEN_INT (-INTVAL (operands[2]));
5876           return "sub{l}\t{%2, %k0|%k0, %2}";
5877         }
5878       return "add{l}\t{%2, %k0|%k0, %2}";
5879     }
5881   [(set (attr "type")
5882      (if_then_else (match_operand:SI 2 "incdec_operand" "")
5883         (const_string "incdec")
5884         (const_string "alu")))
5885    (set_attr "mode" "SI")])
5887 ; For comparisons against 1, -1 and 128, we may generate better code
5888 ; by converting cmp to add, inc or dec as done by peephole2.  This pattern
5889 ; is matched then.  We can't accept general immediate, because for
5890 ; case of overflows,  the result is messed up.
5891 ; This pattern also don't hold of 0x80000000, since the value overflows
5892 ; when negated.
5893 ; Also carry flag is reversed compared to cmp, so this conversion is valid
5894 ; only for comparisons not depending on it.
5895 (define_insn "*addsi_4"
5896   [(set (reg 17)
5897         (compare (match_operand:SI 1 "nonimmediate_operand" "0")
5898                  (match_operand:SI 2 "const_int_operand" "n")))
5899    (clobber (match_scratch:SI 0 "=rm"))]
5900   "ix86_match_ccmode (insn, CCGCmode)
5901    && (INTVAL (operands[2]) & 0xffffffff) != 0x80000000"
5903   switch (get_attr_type (insn))
5904     {
5905     case TYPE_INCDEC:
5906       if (operands[2] == constm1_rtx)
5907         return "inc{l}\t%0";
5908       else if (operands[2] == const1_rtx)
5909         return "dec{l}\t%0";
5910       else
5911         abort();
5913     default:
5914       if (! rtx_equal_p (operands[0], operands[1]))
5915         abort ();
5916       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5917          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5918       if ((INTVAL (operands[2]) == -128
5919            || (INTVAL (operands[2]) > 0
5920                && INTVAL (operands[2]) != 128)))
5921         return "sub{l}\t{%2, %0|%0, %2}";
5922       operands[2] = GEN_INT (-INTVAL (operands[2]));
5923       return "add{l}\t{%2, %0|%0, %2}";
5924     }
5926   [(set (attr "type")
5927      (if_then_else (match_operand:SI 2 "incdec_operand" "")
5928         (const_string "incdec")
5929         (const_string "alu")))
5930    (set_attr "mode" "SI")])
5932 (define_insn "*addsi_5"
5933   [(set (reg 17)
5934         (compare
5935           (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
5936                    (match_operand:SI 2 "general_operand" "rmni"))
5937           (const_int 0)))                       
5938    (clobber (match_scratch:SI 0 "=r"))]
5939   "ix86_match_ccmode (insn, CCGOCmode)
5940    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)
5941    /* Current assemblers are broken and do not allow @GOTOFF in
5942       ought but a memory context.  */
5943    && ! pic_symbolic_operand (operands[2], VOIDmode)"
5945   switch (get_attr_type (insn))
5946     {
5947     case TYPE_INCDEC:
5948       if (! rtx_equal_p (operands[0], operands[1]))
5949         abort ();
5950       if (operands[2] == const1_rtx)
5951         return "inc{l}\t%0";
5952       else if (operands[2] == constm1_rtx)
5953         return "dec{l}\t%0";
5954       else
5955         abort();
5957     default:
5958       if (! rtx_equal_p (operands[0], operands[1]))
5959         abort ();
5960       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
5961          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
5962       if (GET_CODE (operands[2]) == CONST_INT
5963           && (INTVAL (operands[2]) == 128
5964               || (INTVAL (operands[2]) < 0
5965                   && INTVAL (operands[2]) != -128)))
5966         {
5967           operands[2] = GEN_INT (-INTVAL (operands[2]));
5968           return "sub{l}\t{%2, %0|%0, %2}";
5969         }
5970       return "add{l}\t{%2, %0|%0, %2}";
5971     }
5973   [(set (attr "type")
5974      (if_then_else (match_operand:SI 2 "incdec_operand" "")
5975         (const_string "incdec")
5976         (const_string "alu")))
5977    (set_attr "mode" "SI")])
5979 (define_expand "addhi3"
5980   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
5981                    (plus:HI (match_operand:HI 1 "nonimmediate_operand" "")
5982                             (match_operand:HI 2 "general_operand" "")))
5983               (clobber (reg:CC 17))])]
5984   "TARGET_HIMODE_MATH"
5985   "ix86_expand_binary_operator (PLUS, HImode, operands); DONE;")
5987 ;; %%% After Dave's SUBREG_BYTE stuff goes in, re-enable incb %ah
5988 ;; type optimizations enabled by define-splits.  This is not important
5989 ;; for PII, and in fact harmful because of partial register stalls.
5991 (define_insn "*addhi_1_lea"
5992   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r")
5993         (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,r")
5994                  (match_operand:HI 2 "general_operand" "ri,rm,rni")))
5995    (clobber (reg:CC 17))]
5996   "!TARGET_PARTIAL_REG_STALL
5997    && ix86_binary_operator_ok (PLUS, HImode, operands)"
5999   switch (get_attr_type (insn))
6000     {
6001     case TYPE_LEA:
6002       return "#";
6003     case TYPE_INCDEC:
6004       if (operands[2] == const1_rtx)
6005         return "inc{w}\t%0";
6006       else if (operands[2] == constm1_rtx)
6007         return "dec{w}\t%0";
6008       abort();
6010     default:
6011       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6012          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6013       if (GET_CODE (operands[2]) == CONST_INT
6014           && (INTVAL (operands[2]) == 128
6015               || (INTVAL (operands[2]) < 0
6016                   && INTVAL (operands[2]) != -128)))
6017         {
6018           operands[2] = GEN_INT (-INTVAL (operands[2]));
6019           return "sub{w}\t{%2, %0|%0, %2}";
6020         }
6021       return "add{w}\t{%2, %0|%0, %2}";
6022     }
6024   [(set (attr "type")
6025      (if_then_else (eq_attr "alternative" "2")
6026         (const_string "lea")
6027         (if_then_else (match_operand:HI 2 "incdec_operand" "")
6028            (const_string "incdec")
6029            (const_string "alu"))))
6030    (set_attr "mode" "HI,HI,SI")])
6032 (define_insn "*addhi_1"
6033   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
6034         (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6035                  (match_operand:HI 2 "general_operand" "ri,rm")))
6036    (clobber (reg:CC 17))]
6037   "TARGET_PARTIAL_REG_STALL
6038    && ix86_binary_operator_ok (PLUS, HImode, operands)"
6040   switch (get_attr_type (insn))
6041     {
6042     case TYPE_INCDEC:
6043       if (operands[2] == const1_rtx)
6044         return "inc{w}\t%0";
6045       else if (operands[2] == constm1_rtx)
6046         return "dec{w}\t%0";
6047       abort();
6049     default:
6050       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6051          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6052       if (GET_CODE (operands[2]) == CONST_INT
6053           && (INTVAL (operands[2]) == 128
6054               || (INTVAL (operands[2]) < 0
6055                   && INTVAL (operands[2]) != -128)))
6056         {
6057           operands[2] = GEN_INT (-INTVAL (operands[2]));
6058           return "sub{w}\t{%2, %0|%0, %2}";
6059         }
6060       return "add{w}\t{%2, %0|%0, %2}";
6061     }
6063   [(set (attr "type")
6064      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6065         (const_string "incdec")
6066         (const_string "alu")))
6067    (set_attr "mode" "HI")])
6069 (define_insn "*addhi_2"
6070   [(set (reg 17)
6071         (compare
6072           (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
6073                    (match_operand:HI 2 "general_operand" "rmni,rni"))
6074           (const_int 0)))                       
6075    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
6076         (plus:HI (match_dup 1) (match_dup 2)))]
6077   "ix86_match_ccmode (insn, CCGOCmode)
6078    && ix86_binary_operator_ok (PLUS, HImode, operands)"
6080   switch (get_attr_type (insn))
6081     {
6082     case TYPE_INCDEC:
6083       if (operands[2] == const1_rtx)
6084         return "inc{w}\t%0";
6085       else if (operands[2] == constm1_rtx)
6086         return "dec{w}\t%0";
6087       abort();
6089     default:
6090       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6091          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6092       if (GET_CODE (operands[2]) == CONST_INT
6093           && (INTVAL (operands[2]) == 128
6094               || (INTVAL (operands[2]) < 0
6095                   && INTVAL (operands[2]) != -128)))
6096         {
6097           operands[2] = GEN_INT (-INTVAL (operands[2]));
6098           return "sub{w}\t{%2, %0|%0, %2}";
6099         }
6100       return "add{w}\t{%2, %0|%0, %2}";
6101     }
6103   [(set (attr "type")
6104      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6105         (const_string "incdec")
6106         (const_string "alu")))
6107    (set_attr "mode" "HI")])
6109 (define_insn "*addhi_3"
6110   [(set (reg 17)
6111         (compare (neg:HI (match_operand:HI 2 "general_operand" "rmni"))
6112                  (match_operand:HI 1 "nonimmediate_operand" "%0")))
6113    (clobber (match_scratch:HI 0 "=r"))]
6114   "ix86_match_ccmode (insn, CCZmode)
6115    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6117   switch (get_attr_type (insn))
6118     {
6119     case TYPE_INCDEC:
6120       if (operands[2] == const1_rtx)
6121         return "inc{w}\t%0";
6122       else if (operands[2] == constm1_rtx)
6123         return "dec{w}\t%0";
6124       abort();
6126     default:
6127       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6128          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6129       if (GET_CODE (operands[2]) == CONST_INT
6130           && (INTVAL (operands[2]) == 128
6131               || (INTVAL (operands[2]) < 0
6132                   && INTVAL (operands[2]) != -128)))
6133         {
6134           operands[2] = GEN_INT (-INTVAL (operands[2]));
6135           return "sub{w}\t{%2, %0|%0, %2}";
6136         }
6137       return "add{w}\t{%2, %0|%0, %2}";
6138     }
6140   [(set (attr "type")
6141      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6142         (const_string "incdec")
6143         (const_string "alu")))
6144    (set_attr "mode" "HI")])
6146 ; See comments above addsi_3_imm for details.
6147 (define_insn "*addhi_4"
6148   [(set (reg 17)
6149         (compare (match_operand:HI 1 "nonimmediate_operand" "0")
6150                  (match_operand:HI 2 "const_int_operand" "n")))
6151    (clobber (match_scratch:HI 0 "=rm"))]
6152   "ix86_match_ccmode (insn, CCGCmode)
6153    && (INTVAL (operands[2]) & 0xffff) != 0x8000"
6155   switch (get_attr_type (insn))
6156     {
6157     case TYPE_INCDEC:
6158       if (operands[2] == constm1_rtx)
6159         return "inc{w}\t%0";
6160       else if (operands[2] == const1_rtx)
6161         return "dec{w}\t%0";
6162       else
6163         abort();
6165     default:
6166       if (! rtx_equal_p (operands[0], operands[1]))
6167         abort ();
6168       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6169          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6170       if ((INTVAL (operands[2]) == -128
6171            || (INTVAL (operands[2]) > 0
6172                && INTVAL (operands[2]) != 128)))
6173         return "sub{w}\t{%2, %0|%0, %2}";
6174       operands[2] = GEN_INT (-INTVAL (operands[2]));
6175       return "add{w}\t{%2, %0|%0, %2}";
6176     }
6178   [(set (attr "type")
6179      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6180         (const_string "incdec")
6181         (const_string "alu")))
6182    (set_attr "mode" "SI")])
6185 (define_insn "*addhi_5"
6186   [(set (reg 17)
6187         (compare
6188           (plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
6189                    (match_operand:HI 2 "general_operand" "rmni"))
6190           (const_int 0)))                       
6191    (clobber (match_scratch:HI 0 "=r"))]
6192   "ix86_match_ccmode (insn, CCGOCmode)
6193    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6195   switch (get_attr_type (insn))
6196     {
6197     case TYPE_INCDEC:
6198       if (operands[2] == const1_rtx)
6199         return "inc{w}\t%0";
6200       else if (operands[2] == constm1_rtx)
6201         return "dec{w}\t%0";
6202       abort();
6204     default:
6205       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6206          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6207       if (GET_CODE (operands[2]) == CONST_INT
6208           && (INTVAL (operands[2]) == 128
6209               || (INTVAL (operands[2]) < 0
6210                   && INTVAL (operands[2]) != -128)))
6211         {
6212           operands[2] = GEN_INT (-INTVAL (operands[2]));
6213           return "sub{w}\t{%2, %0|%0, %2}";
6214         }
6215       return "add{w}\t{%2, %0|%0, %2}";
6216     }
6218   [(set (attr "type")
6219      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6220         (const_string "incdec")
6221         (const_string "alu")))
6222    (set_attr "mode" "HI")])
6224 (define_expand "addqi3"
6225   [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
6226                    (plus:QI (match_operand:QI 1 "nonimmediate_operand" "")
6227                             (match_operand:QI 2 "general_operand" "")))
6228               (clobber (reg:CC 17))])]
6229   "TARGET_QIMODE_MATH"
6230   "ix86_expand_binary_operator (PLUS, QImode, operands); DONE;")
6232 ;; %%% Potential partial reg stall on alternative 2.  What to do?
6233 (define_insn "*addqi_1_lea"
6234   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r,r")
6235         (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,r")
6236                  (match_operand:QI 2 "general_operand" "qn,qmn,rn,rn")))
6237    (clobber (reg:CC 17))]
6238   "!TARGET_PARTIAL_REG_STALL
6239    && ix86_binary_operator_ok (PLUS, QImode, operands)"
6241   int widen = (which_alternative == 2);
6242   switch (get_attr_type (insn))
6243     {
6244     case TYPE_LEA:
6245       return "#";
6246     case TYPE_INCDEC:
6247       if (operands[2] == const1_rtx)
6248         return widen ? "inc{l}\t%k0" : "inc{b}\t%0";
6249       else if (operands[2] == constm1_rtx)
6250         return widen ? "dec{l}\t%k0" : "dec{b}\t%0";
6251       abort();
6253     default:
6254       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6255          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6256       if (GET_CODE (operands[2]) == CONST_INT
6257           && (INTVAL (operands[2]) == 128
6258               || (INTVAL (operands[2]) < 0
6259                   && INTVAL (operands[2]) != -128)))
6260         {
6261           operands[2] = GEN_INT (-INTVAL (operands[2]));
6262           if (widen)
6263             return "sub{l}\t{%2, %k0|%k0, %2}";
6264           else
6265             return "sub{b}\t{%2, %0|%0, %2}";
6266         }
6267       if (widen)
6268         return "add{l}\t{%k2, %k0|%k0, %k2}";
6269       else
6270         return "add{b}\t{%2, %0|%0, %2}";
6271     }
6273   [(set (attr "type")
6274      (if_then_else (eq_attr "alternative" "3")
6275         (const_string "lea")
6276         (if_then_else (match_operand:QI 2 "incdec_operand" "")
6277            (const_string "incdec")
6278            (const_string "alu"))))
6279    (set_attr "mode" "QI,QI,SI,SI")])
6281 (define_insn "*addqi_1"
6282   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
6283         (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6284                  (match_operand:QI 2 "general_operand" "qn,qmn,rn")))
6285    (clobber (reg:CC 17))]
6286   "TARGET_PARTIAL_REG_STALL
6287    && ix86_binary_operator_ok (PLUS, QImode, operands)"
6289   int widen = (which_alternative == 2);
6290   switch (get_attr_type (insn))
6291     {
6292     case TYPE_INCDEC:
6293       if (operands[2] == const1_rtx)
6294         return widen ? "inc{l}\t%k0" : "inc{b}\t%0";
6295       else if (operands[2] == constm1_rtx)
6296         return widen ? "dec{l}\t%k0" : "dec{b}\t%0";
6297       abort();
6299     default:
6300       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.
6301          Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
6302       if (GET_CODE (operands[2]) == CONST_INT
6303           && (INTVAL (operands[2]) == 128
6304               || (INTVAL (operands[2]) < 0
6305                   && INTVAL (operands[2]) != -128)))
6306         {
6307           operands[2] = GEN_INT (-INTVAL (operands[2]));
6308           if (widen)
6309             return "sub{l}\t{%2, %k0|%k0, %2}";
6310           else
6311             return "sub{b}\t{%2, %0|%0, %2}";
6312         }
6313       if (widen)
6314         return "add{l}\t{%k2, %k0|%k0, %k2}";
6315       else
6316         return "add{b}\t{%2, %0|%0, %2}";
6317     }
6319   [(set (attr "type")
6320      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6321         (const_string "incdec")
6322         (const_string "alu")))
6323    (set_attr "mode" "QI,QI,SI")])
6325 (define_insn "*addqi_1_slp"
6326   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
6327         (plus:QI (match_dup 0)
6328                  (match_operand:QI 1 "general_operand" "qn,qnm")))
6329    (clobber (reg:CC 17))]
6330   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
6331    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
6333   switch (get_attr_type (insn))
6334     {
6335     case TYPE_INCDEC:
6336       if (operands[1] == const1_rtx)
6337         return "inc{b}\t%0";
6338       else if (operands[1] == constm1_rtx)
6339         return "dec{b}\t%0";
6340       abort();
6342     default:
6343       /* Make things pretty and `subl $4,%eax' rather than `addl $-4, %eax'.  */
6344       if (GET_CODE (operands[1]) == CONST_INT
6345           && INTVAL (operands[1]) < 0)
6346         {
6347           operands[2] = GEN_INT (-INTVAL (operands[2]));
6348           return "sub{b}\t{%1, %0|%0, %1}";
6349         }
6350       return "add{b}\t{%1, %0|%0, %1}";
6351     }
6353   [(set (attr "type")
6354      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6355         (const_string "incdec")
6356         (const_string "alu1")))
6357    (set_attr "mode" "QI")])
6359 (define_insn "*addqi_2"
6360   [(set (reg 17)
6361         (compare
6362           (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
6363                    (match_operand:QI 2 "general_operand" "qmni,qni"))
6364           (const_int 0)))
6365    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
6366         (plus:QI (match_dup 1) (match_dup 2)))]
6367   "ix86_match_ccmode (insn, CCGOCmode)
6368    && ix86_binary_operator_ok (PLUS, QImode, operands)"
6370   switch (get_attr_type (insn))
6371     {
6372     case TYPE_INCDEC:
6373       if (operands[2] == const1_rtx)
6374         return "inc{b}\t%0";
6375       else if (operands[2] == constm1_rtx
6376                || (GET_CODE (operands[2]) == CONST_INT
6377                    && INTVAL (operands[2]) == 255))
6378         return "dec{b}\t%0";
6379       abort();
6381     default:
6382       /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'.  */
6383       if (GET_CODE (operands[2]) == CONST_INT
6384           && INTVAL (operands[2]) < 0)
6385         {
6386           operands[2] = GEN_INT (-INTVAL (operands[2]));
6387           return "sub{b}\t{%2, %0|%0, %2}";
6388         }
6389       return "add{b}\t{%2, %0|%0, %2}";
6390     }
6392   [(set (attr "type")
6393      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6394         (const_string "incdec")
6395         (const_string "alu")))
6396    (set_attr "mode" "QI")])
6398 (define_insn "*addqi_3"
6399   [(set (reg 17)
6400         (compare (neg:QI (match_operand:QI 2 "general_operand" "qmni"))
6401                  (match_operand:QI 1 "nonimmediate_operand" "%0")))
6402    (clobber (match_scratch:QI 0 "=q"))]
6403   "ix86_match_ccmode (insn, CCZmode)
6404    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6406   switch (get_attr_type (insn))
6407     {
6408     case TYPE_INCDEC:
6409       if (operands[2] == const1_rtx)
6410         return "inc{b}\t%0";
6411       else if (operands[2] == constm1_rtx
6412                || (GET_CODE (operands[2]) == CONST_INT
6413                    && INTVAL (operands[2]) == 255))
6414         return "dec{b}\t%0";
6415       abort();
6417     default:
6418       /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'.  */
6419       if (GET_CODE (operands[2]) == CONST_INT
6420           && INTVAL (operands[2]) < 0)
6421         {
6422           operands[2] = GEN_INT (-INTVAL (operands[2]));
6423           return "sub{b}\t{%2, %0|%0, %2}";
6424         }
6425       return "add{b}\t{%2, %0|%0, %2}";
6426     }
6428   [(set (attr "type")
6429      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6430         (const_string "incdec")
6431         (const_string "alu")))
6432    (set_attr "mode" "QI")])
6434 ; See comments above addsi_3_imm for details.
6435 (define_insn "*addqi_4"
6436   [(set (reg 17)
6437         (compare (match_operand:QI 1 "nonimmediate_operand" "0")
6438                  (match_operand:QI 2 "const_int_operand" "n")))
6439    (clobber (match_scratch:QI 0 "=qm"))]
6440   "ix86_match_ccmode (insn, CCGCmode)
6441    && (INTVAL (operands[2]) & 0xff) != 0x80"
6443   switch (get_attr_type (insn))
6444     {
6445     case TYPE_INCDEC:
6446       if (operands[2] == constm1_rtx
6447           || (GET_CODE (operands[2]) == CONST_INT
6448               && INTVAL (operands[2]) == 255))
6449         return "inc{b}\t%0";
6450       else if (operands[2] == const1_rtx)
6451         return "dec{b}\t%0";
6452       else
6453         abort();
6455     default:
6456       if (! rtx_equal_p (operands[0], operands[1]))
6457         abort ();
6458       if (INTVAL (operands[2]) < 0)
6459         {
6460           operands[2] = GEN_INT (-INTVAL (operands[2]));
6461           return "add{b}\t{%2, %0|%0, %2}";
6462         }
6463       return "sub{b}\t{%2, %0|%0, %2}";
6464     }
6466   [(set (attr "type")
6467      (if_then_else (match_operand:HI 2 "incdec_operand" "")
6468         (const_string "incdec")
6469         (const_string "alu")))
6470    (set_attr "mode" "QI")])
6473 (define_insn "*addqi_5"
6474   [(set (reg 17)
6475         (compare
6476           (plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
6477                    (match_operand:QI 2 "general_operand" "qmni"))
6478           (const_int 0)))
6479    (clobber (match_scratch:QI 0 "=q"))]
6480   "ix86_match_ccmode (insn, CCGOCmode)
6481    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6483   switch (get_attr_type (insn))
6484     {
6485     case TYPE_INCDEC:
6486       if (operands[2] == const1_rtx)
6487         return "inc{b}\t%0";
6488       else if (operands[2] == constm1_rtx
6489                || (GET_CODE (operands[2]) == CONST_INT
6490                    && INTVAL (operands[2]) == 255))
6491         return "dec{b}\t%0";
6492       abort();
6494     default:
6495       /* Make things pretty and `subb $4,%al' rather than `addb $-4, %al'.  */
6496       if (GET_CODE (operands[2]) == CONST_INT
6497           && INTVAL (operands[2]) < 0)
6498         {
6499           operands[2] = GEN_INT (-INTVAL (operands[2]));
6500           return "sub{b}\t{%2, %0|%0, %2}";
6501         }
6502       return "add{b}\t{%2, %0|%0, %2}";
6503     }
6505   [(set (attr "type")
6506      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6507         (const_string "incdec")
6508         (const_string "alu")))
6509    (set_attr "mode" "QI")])
6512 (define_insn "addqi_ext_1"
6513   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6514                          (const_int 8)
6515                          (const_int 8))
6516         (plus:SI
6517           (zero_extract:SI
6518             (match_operand 1 "ext_register_operand" "0")
6519             (const_int 8)
6520             (const_int 8))
6521           (match_operand:QI 2 "general_operand" "Qmn")))
6522    (clobber (reg:CC 17))]
6523   "!TARGET_64BIT"
6525   switch (get_attr_type (insn))
6526     {
6527     case TYPE_INCDEC:
6528       if (operands[2] == const1_rtx)
6529         return "inc{b}\t%h0";
6530       else if (operands[2] == constm1_rtx
6531                || (GET_CODE (operands[2]) == CONST_INT
6532                    && INTVAL (operands[2]) == 255))
6533         return "dec{b}\t%h0";
6534       abort();
6536     default:
6537       return "add{b}\t{%2, %h0|%h0, %2}";
6538     }
6540   [(set (attr "type")
6541      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6542         (const_string "incdec")
6543         (const_string "alu")))
6544    (set_attr "mode" "QI")])
6546 (define_insn "*addqi_ext_1_rex64"
6547   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6548                          (const_int 8)
6549                          (const_int 8))
6550         (plus:SI
6551           (zero_extract:SI
6552             (match_operand 1 "ext_register_operand" "0")
6553             (const_int 8)
6554             (const_int 8))
6555           (match_operand:QI 2 "nonmemory_operand" "Qn")))
6556    (clobber (reg:CC 17))]
6557   "TARGET_64BIT"
6559   switch (get_attr_type (insn))
6560     {
6561     case TYPE_INCDEC:
6562       if (operands[2] == const1_rtx)
6563         return "inc{b}\t%h0";
6564       else if (operands[2] == constm1_rtx
6565                || (GET_CODE (operands[2]) == CONST_INT
6566                    && INTVAL (operands[2]) == 255))
6567         return "dec{b}\t%h0";
6568       abort();
6570     default:
6571       return "add{b}\t{%2, %h0|%h0, %2}";
6572     }
6574   [(set (attr "type")
6575      (if_then_else (match_operand:QI 2 "incdec_operand" "")
6576         (const_string "incdec")
6577         (const_string "alu")))
6578    (set_attr "mode" "QI")])
6580 (define_insn "*addqi_ext_2"
6581   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
6582                          (const_int 8)
6583                          (const_int 8))
6584         (plus:SI
6585           (zero_extract:SI
6586             (match_operand 1 "ext_register_operand" "%0")
6587             (const_int 8)
6588             (const_int 8))
6589           (zero_extract:SI
6590             (match_operand 2 "ext_register_operand" "Q")
6591             (const_int 8)
6592             (const_int 8))))
6593    (clobber (reg:CC 17))]
6594   ""
6595   "add{b}\t{%h2, %h0|%h0, %h2}"
6596   [(set_attr "type" "alu")
6597    (set_attr "mode" "QI")])
6599 ;; The patterns that match these are at the end of this file.
6601 (define_expand "addxf3"
6602   [(set (match_operand:XF 0 "register_operand" "")
6603         (plus:XF (match_operand:XF 1 "register_operand" "")
6604                  (match_operand:XF 2 "register_operand" "")))]
6605   "!TARGET_64BIT && TARGET_80387"
6606   "")
6608 (define_expand "addtf3"
6609   [(set (match_operand:TF 0 "register_operand" "")
6610         (plus:TF (match_operand:TF 1 "register_operand" "")
6611                  (match_operand:TF 2 "register_operand" "")))]
6612   "TARGET_80387"
6613   "")
6615 (define_expand "adddf3"
6616   [(set (match_operand:DF 0 "register_operand" "")
6617         (plus:DF (match_operand:DF 1 "register_operand" "")
6618                  (match_operand:DF 2 "nonimmediate_operand" "")))]
6619   "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
6620   "")
6622 (define_expand "addsf3"
6623   [(set (match_operand:SF 0 "register_operand" "")
6624         (plus:SF (match_operand:SF 1 "register_operand" "")
6625                  (match_operand:SF 2 "nonimmediate_operand" "")))]
6626   "TARGET_80387 || TARGET_SSE_MATH"
6627   "")
6629 ;; Subtract instructions
6631 ;; %%% splits for subsidi3
6633 (define_expand "subdi3"
6634   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
6635                    (minus:DI (match_operand:DI 1 "nonimmediate_operand" "")
6636                              (match_operand:DI 2 "x86_64_general_operand" "")))
6637               (clobber (reg:CC 17))])]
6638   ""
6639   "ix86_expand_binary_operator (MINUS, DImode, operands); DONE;")
6641 (define_insn "*subdi3_1"
6642   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
6643         (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6644                   (match_operand:DI 2 "general_operand" "roiF,riF")))
6645    (clobber (reg:CC 17))]
6646   "!TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)"
6647   "#")
6649 (define_split
6650   [(set (match_operand:DI 0 "nonimmediate_operand" "")
6651         (minus:DI (match_operand:DI 1 "nonimmediate_operand" "")
6652                   (match_operand:DI 2 "general_operand" "")))
6653    (clobber (reg:CC 17))]
6654   "!TARGET_64BIT && reload_completed"
6655   [(parallel [(set (reg:CC 17) (compare:CC (match_dup 1) (match_dup 2)))
6656               (set (match_dup 0) (minus:SI (match_dup 1) (match_dup 2)))])
6657    (parallel [(set (match_dup 3)
6658                    (minus:SI (match_dup 4)
6659                              (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
6660                                       (match_dup 5))))
6661               (clobber (reg:CC 17))])]
6662   "split_di (operands+0, 1, operands+0, operands+3);
6663    split_di (operands+1, 1, operands+1, operands+4);
6664    split_di (operands+2, 1, operands+2, operands+5);")
6666 (define_insn "subdi3_carry_rex64"
6667   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6668           (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6669             (plus:DI (match_operand:DI 3 "ix86_carry_flag_operator" "")
6670                (match_operand:DI 2 "x86_64_general_operand" "re,rm"))))
6671    (clobber (reg:CC 17))]
6672   "TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)"
6673   "sbb{q}\t{%2, %0|%0, %2}"
6674   [(set_attr "type" "alu")
6675    (set_attr "pent_pair" "pu")
6676    (set_attr "ppro_uops" "few")
6677    (set_attr "mode" "DI")])
6679 (define_insn "*subdi_1_rex64"
6680   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6681         (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6682                   (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
6683    (clobber (reg:CC 17))]
6684   "TARGET_64BIT && ix86_binary_operator_ok (MINUS, DImode, operands)"
6685   "sub{q}\t{%2, %0|%0, %2}"
6686   [(set_attr "type" "alu")
6687    (set_attr "mode" "DI")])
6689 (define_insn "*subdi_2_rex64"
6690   [(set (reg 17)
6691         (compare
6692           (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
6693                     (match_operand:DI 2 "x86_64_general_operand" "re,rm"))
6694           (const_int 0)))
6695    (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6696         (minus:DI (match_dup 1) (match_dup 2)))]
6697   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
6698    && ix86_binary_operator_ok (MINUS, DImode, operands)"
6699   "sub{q}\t{%2, %0|%0, %2}"
6700   [(set_attr "type" "alu")
6701    (set_attr "mode" "DI")])
6703 (define_insn "*subdi_3_rex63"
6704   [(set (reg 17)
6705         (compare (match_operand:DI 1 "nonimmediate_operand" "0,0")
6706                  (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
6707    (set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
6708         (minus:DI (match_dup 1) (match_dup 2)))]
6709   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
6710    && ix86_binary_operator_ok (MINUS, SImode, operands)"
6711   "sub{q}\t{%2, %0|%0, %2}"
6712   [(set_attr "type" "alu")
6713    (set_attr "mode" "DI")])
6715 (define_insn "subqi3_carry"
6716   [(set (match_operand:QI 0 "nonimmediate_operand" "=rm,r")
6717           (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
6718             (plus:QI (match_operand:QI 3 "ix86_carry_flag_operator" "")
6719                (match_operand:QI 2 "general_operand" "ri,rm"))))
6720    (clobber (reg:CC 17))]
6721   "ix86_binary_operator_ok (MINUS, QImode, operands)"
6722   "sbb{b}\t{%2, %0|%0, %2}"
6723   [(set_attr "type" "alu")
6724    (set_attr "pent_pair" "pu")
6725    (set_attr "ppro_uops" "few")
6726    (set_attr "mode" "QI")])
6728 (define_insn "subhi3_carry"
6729   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
6730           (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
6731             (plus:HI (match_operand:HI 3 "ix86_carry_flag_operator" "")
6732                (match_operand:HI 2 "general_operand" "ri,rm"))))
6733    (clobber (reg:CC 17))]
6734   "ix86_binary_operator_ok (MINUS, HImode, operands)"
6735   "sbb{w}\t{%2, %0|%0, %2}"
6736   [(set_attr "type" "alu")
6737    (set_attr "pent_pair" "pu")
6738    (set_attr "ppro_uops" "few")
6739    (set_attr "mode" "HI")])
6741 (define_insn "subsi3_carry"
6742   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6743           (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
6744             (plus:SI (match_operand:SI 3 "ix86_carry_flag_operator" "")
6745                (match_operand:SI 2 "general_operand" "ri,rm"))))
6746    (clobber (reg:CC 17))]
6747   "ix86_binary_operator_ok (MINUS, SImode, operands)"
6748   "sbb{l}\t{%2, %0|%0, %2}"
6749   [(set_attr "type" "alu")
6750    (set_attr "pent_pair" "pu")
6751    (set_attr "ppro_uops" "few")
6752    (set_attr "mode" "SI")])
6754 (define_insn "subsi3_carry_zext"
6755   [(set (match_operand:DI 0 "register_operand" "=rm,r")
6756           (zero_extend:DI
6757             (minus:SI (match_operand:SI 1 "register_operand" "0,0")
6758               (plus:SI (match_operand:SI 3 "ix86_carry_flag_operator" "")
6759                  (match_operand:SI 2 "general_operand" "ri,rm")))))
6760    (clobber (reg:CC 17))]
6761   "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)"
6762   "sbb{l}\t{%2, %k0|%k0, %2}"
6763   [(set_attr "type" "alu")
6764    (set_attr "pent_pair" "pu")
6765    (set_attr "ppro_uops" "few")
6766    (set_attr "mode" "SI")])
6768 (define_expand "subsi3"
6769   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
6770                    (minus:SI (match_operand:SI 1 "nonimmediate_operand" "")
6771                              (match_operand:SI 2 "general_operand" "")))
6772               (clobber (reg:CC 17))])]
6773   ""
6774   "ix86_expand_binary_operator (MINUS, SImode, operands); DONE;")
6776 (define_insn "*subsi_1"
6777   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6778         (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
6779                   (match_operand:SI 2 "general_operand" "ri,rm")))
6780    (clobber (reg:CC 17))]
6781   "ix86_binary_operator_ok (MINUS, SImode, operands)"
6782   "sub{l}\t{%2, %0|%0, %2}"
6783   [(set_attr "type" "alu")
6784    (set_attr "mode" "SI")])
6786 (define_insn "*subsi_1_zext"
6787   [(set (match_operand:DI 0 "register_operand" "=r")
6788         (zero_extend:DI
6789           (minus:SI (match_operand:SI 1 "register_operand" "0")
6790                     (match_operand:SI 2 "general_operand" "rim"))))
6791    (clobber (reg:CC 17))]
6792   "TARGET_64BIT && ix86_binary_operator_ok (MINUS, SImode, operands)"
6793   "sub{l}\t{%2, %k0|%k0, %2}"
6794   [(set_attr "type" "alu")
6795    (set_attr "mode" "SI")])
6797 (define_insn "*subsi_2"
6798   [(set (reg 17)
6799         (compare
6800           (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
6801                     (match_operand:SI 2 "general_operand" "ri,rm"))
6802           (const_int 0)))
6803    (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6804         (minus:SI (match_dup 1) (match_dup 2)))]
6805   "ix86_match_ccmode (insn, CCGOCmode)
6806    && ix86_binary_operator_ok (MINUS, SImode, operands)"
6807   "sub{l}\t{%2, %0|%0, %2}"
6808   [(set_attr "type" "alu")
6809    (set_attr "mode" "SI")])
6811 (define_insn "*subsi_2_zext"
6812   [(set (reg 17)
6813         (compare
6814           (minus:SI (match_operand:SI 1 "register_operand" "0")
6815                     (match_operand:SI 2 "general_operand" "rim"))
6816           (const_int 0)))
6817    (set (match_operand:DI 0 "register_operand" "=r")
6818         (zero_extend:DI
6819           (minus:SI (match_dup 1)
6820                     (match_dup 2))))]
6821   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
6822    && ix86_binary_operator_ok (MINUS, SImode, operands)"
6823   "sub{l}\t{%2, %k0|%k0, %2}"
6824   [(set_attr "type" "alu")
6825    (set_attr "mode" "SI")])
6827 (define_insn "*subsi_3"
6828   [(set (reg 17)
6829         (compare (match_operand:SI 1 "nonimmediate_operand" "0,0")
6830                  (match_operand:SI 2 "general_operand" "ri,rm")))
6831    (set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
6832         (minus:SI (match_dup 1) (match_dup 2)))]
6833   "ix86_match_ccmode (insn, CCmode)
6834    && ix86_binary_operator_ok (MINUS, SImode, operands)"
6835   "sub{l}\t{%2, %0|%0, %2}"
6836   [(set_attr "type" "alu")
6837    (set_attr "mode" "SI")])
6839 (define_insn "*subsi_3_zext"
6840   [(set (reg 17)
6841         (compare (match_operand:SI 1 "nonimmediate_operand" "0")
6842                  (match_operand:SI 2 "general_operand" "rim")))
6843    (set (match_operand:DI 0 "register_operand" "=r")
6844         (zero_extend:DI
6845           (minus:SI (match_dup 1)
6846                     (match_dup 2))))]
6847   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
6848    && ix86_binary_operator_ok (MINUS, SImode, operands)"
6849   "sub{q}\t{%2, %0|%0, %2}"
6850   [(set_attr "type" "alu")
6851    (set_attr "mode" "DI")])
6853 (define_expand "subhi3"
6854   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
6855                    (minus:HI (match_operand:HI 1 "nonimmediate_operand" "")
6856                              (match_operand:HI 2 "general_operand" "")))
6857               (clobber (reg:CC 17))])]
6858   "TARGET_HIMODE_MATH"
6859   "ix86_expand_binary_operator (MINUS, HImode, operands); DONE;")
6861 (define_insn "*subhi_1"
6862   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
6863         (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
6864                   (match_operand:HI 2 "general_operand" "ri,rm")))
6865    (clobber (reg:CC 17))]
6866   "ix86_binary_operator_ok (MINUS, HImode, operands)"
6867   "sub{w}\t{%2, %0|%0, %2}"
6868   [(set_attr "type" "alu")
6869    (set_attr "mode" "HI")])
6871 (define_insn "*subhi_2"
6872   [(set (reg 17)
6873         (compare
6874           (minus:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
6875                     (match_operand:HI 2 "general_operand" "ri,rm"))
6876           (const_int 0)))
6877    (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
6878         (minus:HI (match_dup 1) (match_dup 2)))]
6879   "ix86_match_ccmode (insn, CCGOCmode)
6880    && ix86_binary_operator_ok (MINUS, HImode, operands)"
6881   "sub{w}\t{%2, %0|%0, %2}"
6882   [(set_attr "type" "alu")
6883    (set_attr "mode" "HI")])
6885 (define_insn "*subhi_3"
6886   [(set (reg 17)
6887         (compare (match_operand:HI 1 "nonimmediate_operand" "0,0")
6888                  (match_operand:HI 2 "general_operand" "ri,rm")))
6889    (set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
6890         (minus:HI (match_dup 1) (match_dup 2)))]
6891   "ix86_match_ccmode (insn, CCmode)
6892    && ix86_binary_operator_ok (MINUS, HImode, operands)"
6893   "sub{w}\t{%2, %0|%0, %2}"
6894   [(set_attr "type" "alu")
6895    (set_attr "mode" "HI")])
6897 (define_expand "subqi3"
6898   [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
6899                    (minus:QI (match_operand:QI 1 "nonimmediate_operand" "")
6900                              (match_operand:QI 2 "general_operand" "")))
6901               (clobber (reg:CC 17))])]
6902   "TARGET_QIMODE_MATH"
6903   "ix86_expand_binary_operator (MINUS, QImode, operands); DONE;")
6905 (define_insn "*subqi_1"
6906   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q")
6907         (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
6908                   (match_operand:QI 2 "general_operand" "qn,qmn")))
6909    (clobber (reg:CC 17))]
6910   "ix86_binary_operator_ok (MINUS, QImode, operands)"
6911   "sub{b}\t{%2, %0|%0, %2}"
6912   [(set_attr "type" "alu")
6913    (set_attr "mode" "QI")])
6915 (define_insn "*subqi_1_slp"
6916   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
6917         (minus:QI (match_dup 0)
6918                   (match_operand:QI 1 "general_operand" "qn,qmn")))
6919    (clobber (reg:CC 17))]
6920   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
6921    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
6922   "sub{b}\t{%1, %0|%0, %1}"
6923   [(set_attr "type" "alu1")
6924    (set_attr "mode" "QI")])
6926 (define_insn "*subqi_2"
6927   [(set (reg 17)
6928         (compare
6929           (minus:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
6930                     (match_operand:QI 2 "general_operand" "qi,qm"))
6931           (const_int 0)))
6932    (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q")
6933         (minus:HI (match_dup 1) (match_dup 2)))]
6934   "ix86_match_ccmode (insn, CCGOCmode)
6935    && ix86_binary_operator_ok (MINUS, QImode, operands)"
6936   "sub{b}\t{%2, %0|%0, %2}"
6937   [(set_attr "type" "alu")
6938    (set_attr "mode" "QI")])
6940 (define_insn "*subqi_3"
6941   [(set (reg 17)
6942         (compare (match_operand:QI 1 "nonimmediate_operand" "0,0")
6943                  (match_operand:QI 2 "general_operand" "qi,qm")))
6944    (set (match_operand:HI 0 "nonimmediate_operand" "=qm,q")
6945         (minus:HI (match_dup 1) (match_dup 2)))]
6946   "ix86_match_ccmode (insn, CCmode)
6947    && ix86_binary_operator_ok (MINUS, QImode, operands)"
6948   "sub{b}\t{%2, %0|%0, %2}"
6949   [(set_attr "type" "alu")
6950    (set_attr "mode" "QI")])
6952 ;; The patterns that match these are at the end of this file.
6954 (define_expand "subxf3"
6955   [(set (match_operand:XF 0 "register_operand" "")
6956         (minus:XF (match_operand:XF 1 "register_operand" "")
6957                   (match_operand:XF 2 "register_operand" "")))]
6958   "!TARGET_64BIT && TARGET_80387"
6959   "")
6961 (define_expand "subtf3"
6962   [(set (match_operand:TF 0 "register_operand" "")
6963         (minus:TF (match_operand:TF 1 "register_operand" "")
6964                   (match_operand:TF 2 "register_operand" "")))]
6965   "TARGET_80387"
6966   "")
6968 (define_expand "subdf3"
6969   [(set (match_operand:DF 0 "register_operand" "")
6970         (minus:DF (match_operand:DF 1 "register_operand" "")
6971                   (match_operand:DF 2 "nonimmediate_operand" "")))]
6972   "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
6973   "")
6975 (define_expand "subsf3"
6976   [(set (match_operand:SF 0 "register_operand" "")
6977         (minus:SF (match_operand:SF 1 "register_operand" "")
6978                   (match_operand:SF 2 "nonimmediate_operand" "")))]
6979   "TARGET_80387 || TARGET_SSE_MATH"
6980   "")
6982 ;; Multiply instructions
6984 (define_expand "muldi3"
6985   [(parallel [(set (match_operand:DI 0 "register_operand" "")
6986                    (mult:DI (match_operand:DI 1 "register_operand" "")
6987                             (match_operand:DI 2 "x86_64_general_operand" "")))
6988               (clobber (reg:CC 17))])]
6989   "TARGET_64BIT"
6990   "")
6992 (define_insn "*muldi3_1_rex64"
6993   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
6994         (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%rm,rm,0")
6995                  (match_operand:DI 2 "x86_64_general_operand" "K,e,mr")))
6996    (clobber (reg:CC 17))]
6997   "TARGET_64BIT
6998    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
6999   "@
7000    imul{q}\t{%2, %1, %0|%0, %1, %2}
7001    imul{q}\t{%2, %1, %0|%0, %1, %2}
7002    imul{q}\t{%2, %0|%0, %2}"
7003   [(set_attr "type" "imul")
7004    (set_attr "prefix_0f" "0,0,1")
7005    (set (attr "athlon_decode")
7006         (cond [(eq_attr "cpu" "athlon")
7007                   (const_string "vector")
7008                (eq_attr "alternative" "1")
7009                   (const_string "vector")
7010                (and (eq_attr "alternative" "2")
7011                     (match_operand 1 "memory_operand" ""))
7012                   (const_string "vector")]
7013               (const_string "direct")))
7014    (set_attr "mode" "DI")])
7016 (define_expand "mulsi3"
7017   [(parallel [(set (match_operand:SI 0 "register_operand" "")
7018                    (mult:SI (match_operand:SI 1 "register_operand" "")
7019                             (match_operand:SI 2 "general_operand" "")))
7020               (clobber (reg:CC 17))])]
7021   ""
7022   "")
7024 (define_insn "*mulsi3_1"
7025   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
7026         (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,rm,0")
7027                  (match_operand:SI 2 "general_operand" "K,i,mr")))
7028    (clobber (reg:CC 17))]
7029   "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
7030   "@
7031    imul{l}\t{%2, %1, %0|%0, %1, %2}
7032    imul{l}\t{%2, %1, %0|%0, %1, %2}
7033    imul{l}\t{%2, %0|%0, %2}"
7034   [(set_attr "type" "imul")
7035    (set_attr "prefix_0f" "0,0,1")
7036    (set (attr "athlon_decode")
7037         (cond [(eq_attr "cpu" "athlon")
7038                   (const_string "vector")
7039                (eq_attr "alternative" "1")
7040                   (const_string "vector")
7041                (and (eq_attr "alternative" "2")
7042                     (match_operand 1 "memory_operand" ""))
7043                   (const_string "vector")]
7044               (const_string "direct")))
7045    (set_attr "mode" "SI")])
7047 (define_insn "*mulsi3_1_zext"
7048   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
7049         (zero_extend:DI
7050           (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%rm,rm,0")
7051                    (match_operand:SI 2 "general_operand" "K,i,mr"))))
7052    (clobber (reg:CC 17))]
7053   "TARGET_64BIT
7054    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7055   "@
7056    imul{l}\t{%2, %1, %k0|%k0, %1, %2}
7057    imul{l}\t{%2, %1, %k0|%k0, %1, %2}
7058    imul{l}\t{%2, %k0|%k0, %2}"
7059   [(set_attr "type" "imul")
7060    (set_attr "prefix_0f" "0,0,1")
7061    (set (attr "athlon_decode")
7062         (cond [(eq_attr "cpu" "athlon")
7063                   (const_string "vector")
7064                (eq_attr "alternative" "1")
7065                   (const_string "vector")
7066                (and (eq_attr "alternative" "2")
7067                     (match_operand 1 "memory_operand" ""))
7068                   (const_string "vector")]
7069               (const_string "direct")))
7070    (set_attr "mode" "SI")])
7072 (define_expand "mulhi3"
7073   [(parallel [(set (match_operand:HI 0 "register_operand" "")
7074                    (mult:HI (match_operand:HI 1 "register_operand" "")
7075                             (match_operand:HI 2 "general_operand" "")))
7076               (clobber (reg:CC 17))])]
7077   "TARGET_HIMODE_MATH"
7078   "")
7080 (define_insn "*mulhi3_1"
7081   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
7082         (mult:HI (match_operand:HI 1 "nonimmediate_operand" "%rm,rm,0")
7083                  (match_operand:HI 2 "general_operand" "K,i,mr")))
7084    (clobber (reg:CC 17))]
7085   "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
7086   "@
7087    imul{w}\t{%2, %1, %0|%0, %1, %2}
7088    imul{w}\t{%2, %1, %0|%0, %1, %2}
7089    imul{w}\t{%2, %0|%0, %2}"
7090   [(set_attr "type" "imul")
7091    (set_attr "prefix_0f" "0,0,1")
7092    (set (attr "athlon_decode")
7093         (cond [(eq_attr "cpu" "athlon")
7094                   (const_string "vector")
7095                (eq_attr "alternative" "1,2")
7096                   (const_string "vector")]
7097               (const_string "direct")))
7098    (set_attr "mode" "HI")])
7100 (define_expand "mulqi3"
7101   [(parallel [(set (match_operand:QI 0 "register_operand" "")
7102                    (mult:QI (match_operand:QI 1 "nonimmediate_operand" "")
7103                             (match_operand:QI 2 "register_operand" "")))
7104               (clobber (reg:CC 17))])]
7105   "TARGET_QIMODE_MATH"
7106   "")
7108 (define_insn "*mulqi3_1"
7109   [(set (match_operand:QI 0 "register_operand" "=a")
7110         (mult:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
7111                  (match_operand:QI 2 "nonimmediate_operand" "qm")))
7112    (clobber (reg:CC 17))]
7113   "TARGET_QIMODE_MATH
7114    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7115   "mul{b}\t%2"
7116   [(set_attr "type" "imul")
7117    (set_attr "length_immediate" "0")
7118    (set (attr "athlon_decode")
7119      (if_then_else (eq_attr "cpu" "athlon")
7120         (const_string "vector")
7121         (const_string "direct")))
7122    (set_attr "mode" "QI")])
7124 (define_expand "umulqihi3"
7125   [(parallel [(set (match_operand:HI 0 "register_operand" "")
7126                    (mult:HI (zero_extend:HI
7127                               (match_operand:QI 1 "nonimmediate_operand" ""))
7128                             (zero_extend:HI
7129                               (match_operand:QI 2 "register_operand" ""))))
7130               (clobber (reg:CC 17))])]
7131   "TARGET_QIMODE_MATH"
7132   "")
7134 (define_insn "*umulqihi3_1"
7135   [(set (match_operand:HI 0 "register_operand" "=a")
7136         (mult:HI (zero_extend:HI (match_operand:QI 1 "nonimmediate_operand" "%0"))
7137                  (zero_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))
7138    (clobber (reg:CC 17))]
7139   "TARGET_QIMODE_MATH
7140    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7141   "mul{b}\t%2"
7142   [(set_attr "type" "imul")
7143    (set_attr "length_immediate" "0")
7144    (set (attr "athlon_decode")
7145      (if_then_else (eq_attr "cpu" "athlon")
7146         (const_string "vector")
7147         (const_string "direct")))
7148    (set_attr "mode" "QI")])
7150 (define_expand "mulqihi3"
7151   [(parallel [(set (match_operand:HI 0 "register_operand" "")
7152                    (mult:HI (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" ""))
7153                             (sign_extend:HI (match_operand:QI 2 "register_operand" ""))))
7154               (clobber (reg:CC 17))])]
7155   "TARGET_QIMODE_MATH"
7156   "")
7158 (define_insn "*mulqihi3_insn"
7159   [(set (match_operand:HI 0 "register_operand" "=a")
7160         (mult:HI (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "%0"))
7161                  (sign_extend:HI (match_operand:QI 2 "nonimmediate_operand" "qm"))))
7162    (clobber (reg:CC 17))]
7163   "TARGET_QIMODE_MATH
7164    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7165   "imul{b}\t%2"
7166   [(set_attr "type" "imul")
7167    (set_attr "length_immediate" "0")
7168    (set (attr "athlon_decode")
7169      (if_then_else (eq_attr "cpu" "athlon")
7170         (const_string "vector")
7171         (const_string "direct")))
7172    (set_attr "mode" "QI")])
7174 (define_expand "umulditi3"
7175   [(parallel [(set (match_operand:TI 0 "register_operand" "")
7176                    (mult:TI (zero_extend:TI
7177                               (match_operand:DI 1 "nonimmediate_operand" ""))
7178                             (zero_extend:TI
7179                               (match_operand:DI 2 "register_operand" ""))))
7180               (clobber (reg:CC 17))])]
7181   "TARGET_64BIT"
7182   "")
7184 (define_insn "*umulditi3_insn"
7185   [(set (match_operand:TI 0 "register_operand" "=A")
7186         (mult:TI (zero_extend:TI (match_operand:DI 1 "nonimmediate_operand" "%0"))
7187                  (zero_extend:TI (match_operand:DI 2 "nonimmediate_operand" "rm"))))
7188    (clobber (reg:CC 17))]
7189   "TARGET_64BIT
7190    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7191   "mul{q}\t%2"
7192   [(set_attr "type" "imul")
7193    (set_attr "ppro_uops" "few")
7194    (set_attr "length_immediate" "0")
7195    (set (attr "athlon_decode")
7196      (if_then_else (eq_attr "cpu" "athlon")
7197         (const_string "vector")
7198         (const_string "double")))
7199    (set_attr "mode" "DI")])
7201 ;; We can't use this pattern in 64bit mode, since it results in two separate 32bit registers
7202 (define_expand "umulsidi3"
7203   [(parallel [(set (match_operand:DI 0 "register_operand" "")
7204                    (mult:DI (zero_extend:DI
7205                               (match_operand:SI 1 "nonimmediate_operand" ""))
7206                             (zero_extend:DI
7207                               (match_operand:SI 2 "register_operand" ""))))
7208               (clobber (reg:CC 17))])]
7209   "!TARGET_64BIT"
7210   "")
7212 (define_insn "*umulsidi3_insn"
7213   [(set (match_operand:DI 0 "register_operand" "=A")
7214         (mult:DI (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "%0"))
7215                  (zero_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))
7216    (clobber (reg:CC 17))]
7217   "!TARGET_64BIT
7218    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7219   "mul{l}\t%2"
7220   [(set_attr "type" "imul")
7221    (set_attr "ppro_uops" "few")
7222    (set_attr "length_immediate" "0")
7223    (set (attr "athlon_decode")
7224      (if_then_else (eq_attr "cpu" "athlon")
7225         (const_string "vector")
7226         (const_string "double")))
7227    (set_attr "mode" "SI")])
7229 (define_expand "mulditi3"
7230   [(parallel [(set (match_operand:TI 0 "register_operand" "")
7231                    (mult:TI (sign_extend:TI
7232                               (match_operand:DI 1 "nonimmediate_operand" ""))
7233                             (sign_extend:TI
7234                               (match_operand:DI 2 "register_operand" ""))))
7235               (clobber (reg:CC 17))])]
7236   "TARGET_64BIT"
7237   "")
7239 (define_insn "*mulditi3_insn"
7240   [(set (match_operand:TI 0 "register_operand" "=A")
7241         (mult:TI (sign_extend:TI (match_operand:DI 1 "nonimmediate_operand" "%0"))
7242                  (sign_extend:TI (match_operand:DI 2 "nonimmediate_operand" "rm"))))
7243    (clobber (reg:CC 17))]
7244   "TARGET_64BIT
7245    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7246   "imul{q}\t%2"
7247   [(set_attr "type" "imul")
7248    (set_attr "length_immediate" "0")
7249    (set (attr "athlon_decode")
7250      (if_then_else (eq_attr "cpu" "athlon")
7251         (const_string "vector")
7252         (const_string "double")))
7253    (set_attr "mode" "DI")])
7255 (define_expand "mulsidi3"
7256   [(parallel [(set (match_operand:DI 0 "register_operand" "")
7257                    (mult:DI (sign_extend:DI
7258                               (match_operand:SI 1 "nonimmediate_operand" ""))
7259                             (sign_extend:DI
7260                               (match_operand:SI 2 "register_operand" ""))))
7261               (clobber (reg:CC 17))])]
7262   "!TARGET_64BIT"
7263   "")
7265 (define_insn "*mulsidi3_insn"
7266   [(set (match_operand:DI 0 "register_operand" "=A")
7267         (mult:DI (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "%0"))
7268                  (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "rm"))))
7269    (clobber (reg:CC 17))]
7270   "!TARGET_64BIT
7271    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7272   "imul{l}\t%2"
7273   [(set_attr "type" "imul")
7274    (set_attr "length_immediate" "0")
7275    (set (attr "athlon_decode")
7276      (if_then_else (eq_attr "cpu" "athlon")
7277         (const_string "vector")
7278         (const_string "double")))
7279    (set_attr "mode" "SI")])
7281 (define_expand "umuldi3_highpart"
7282   [(parallel [(set (match_operand:DI 0 "register_operand" "")
7283                    (truncate:DI
7284                      (lshiftrt:TI
7285                        (mult:TI (zero_extend:TI
7286                                   (match_operand:DI 1 "nonimmediate_operand" ""))
7287                                 (zero_extend:TI
7288                                   (match_operand:DI 2 "register_operand" "")))
7289                        (const_int 64))))
7290               (clobber (match_scratch:DI 3 ""))
7291               (clobber (reg:CC 17))])]
7292   "TARGET_64BIT"
7293   "")
7295 (define_insn "*umuldi3_highpart_rex64"
7296   [(set (match_operand:DI 0 "register_operand" "=d")
7297         (truncate:DI
7298           (lshiftrt:TI
7299             (mult:TI (zero_extend:TI
7300                        (match_operand:DI 1 "nonimmediate_operand" "%a"))
7301                      (zero_extend:TI
7302                        (match_operand:DI 2 "nonimmediate_operand" "rm")))
7303             (const_int 64))))
7304    (clobber (match_scratch:DI 3 "=1"))
7305    (clobber (reg:CC 17))]
7306   "TARGET_64BIT
7307    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7308   "mul{q}\t%2"
7309   [(set_attr "type" "imul")
7310    (set_attr "ppro_uops" "few")
7311    (set_attr "length_immediate" "0")
7312    (set (attr "athlon_decode")
7313      (if_then_else (eq_attr "cpu" "athlon")
7314         (const_string "vector")
7315         (const_string "double")))
7316    (set_attr "mode" "DI")])
7318 (define_expand "umulsi3_highpart"
7319   [(parallel [(set (match_operand:SI 0 "register_operand" "")
7320                    (truncate:SI
7321                      (lshiftrt:DI
7322                        (mult:DI (zero_extend:DI
7323                                   (match_operand:SI 1 "nonimmediate_operand" ""))
7324                                 (zero_extend:DI
7325                                   (match_operand:SI 2 "register_operand" "")))
7326                        (const_int 32))))
7327               (clobber (match_scratch:SI 3 ""))
7328               (clobber (reg:CC 17))])]
7329   ""
7330   "")
7332 (define_insn "*umulsi3_highpart_insn"
7333   [(set (match_operand:SI 0 "register_operand" "=d")
7334         (truncate:SI
7335           (lshiftrt:DI
7336             (mult:DI (zero_extend:DI
7337                        (match_operand:SI 1 "nonimmediate_operand" "%a"))
7338                      (zero_extend:DI
7339                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
7340             (const_int 32))))
7341    (clobber (match_scratch:SI 3 "=1"))
7342    (clobber (reg:CC 17))]
7343   "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
7344   "mul{l}\t%2"
7345   [(set_attr "type" "imul")
7346    (set_attr "ppro_uops" "few")
7347    (set_attr "length_immediate" "0")
7348    (set (attr "athlon_decode")
7349      (if_then_else (eq_attr "cpu" "athlon")
7350         (const_string "vector")
7351         (const_string "double")))
7352    (set_attr "mode" "SI")])
7354 (define_insn "*umulsi3_highpart_zext"
7355   [(set (match_operand:DI 0 "register_operand" "=d")
7356         (zero_extend:DI (truncate:SI
7357           (lshiftrt:DI
7358             (mult:DI (zero_extend:DI
7359                        (match_operand:SI 1 "nonimmediate_operand" "%a"))
7360                      (zero_extend:DI
7361                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
7362             (const_int 32)))))
7363    (clobber (match_scratch:SI 3 "=1"))
7364    (clobber (reg:CC 17))]
7365   "TARGET_64BIT
7366    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7367   "mul{l}\t%2"
7368   [(set_attr "type" "imul")
7369    (set_attr "ppro_uops" "few")
7370    (set_attr "length_immediate" "0")
7371    (set (attr "athlon_decode")
7372      (if_then_else (eq_attr "cpu" "athlon")
7373         (const_string "vector")
7374         (const_string "double")))
7375    (set_attr "mode" "SI")])
7377 (define_expand "smuldi3_highpart"
7378   [(parallel [(set (match_operand:DI 0 "register_operand" "=d")
7379                    (truncate:DI
7380                      (lshiftrt:TI
7381                        (mult:TI (sign_extend:TI
7382                                   (match_operand:DI 1 "nonimmediate_operand" ""))
7383                                 (sign_extend:TI
7384                                   (match_operand:DI 2 "register_operand" "")))
7385                        (const_int 64))))
7386               (clobber (match_scratch:DI 3 ""))
7387               (clobber (reg:CC 17))])]
7388   "TARGET_64BIT"
7389   "")
7391 (define_insn "*smuldi3_highpart_rex64"
7392   [(set (match_operand:DI 0 "register_operand" "=d")
7393         (truncate:DI
7394           (lshiftrt:TI
7395             (mult:TI (sign_extend:TI
7396                        (match_operand:DI 1 "nonimmediate_operand" "%a"))
7397                      (sign_extend:TI
7398                        (match_operand:DI 2 "nonimmediate_operand" "rm")))
7399             (const_int 64))))
7400    (clobber (match_scratch:DI 3 "=1"))
7401    (clobber (reg:CC 17))]
7402   "TARGET_64BIT
7403    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7404   "imul{q}\t%2"
7405   [(set_attr "type" "imul")
7406    (set_attr "ppro_uops" "few")
7407    (set (attr "athlon_decode")
7408      (if_then_else (eq_attr "cpu" "athlon")
7409         (const_string "vector")
7410         (const_string "double")))
7411    (set_attr "mode" "DI")])
7413 (define_expand "smulsi3_highpart"
7414   [(parallel [(set (match_operand:SI 0 "register_operand" "")
7415                    (truncate:SI
7416                      (lshiftrt:DI
7417                        (mult:DI (sign_extend:DI
7418                                   (match_operand:SI 1 "nonimmediate_operand" ""))
7419                                 (sign_extend:DI
7420                                   (match_operand:SI 2 "register_operand" "")))
7421                        (const_int 32))))
7422               (clobber (match_scratch:SI 3 ""))
7423               (clobber (reg:CC 17))])]
7424   ""
7425   "")
7427 (define_insn "*smulsi3_highpart_insn"
7428   [(set (match_operand:SI 0 "register_operand" "=d")
7429         (truncate:SI
7430           (lshiftrt:DI
7431             (mult:DI (sign_extend:DI
7432                        (match_operand:SI 1 "nonimmediate_operand" "%a"))
7433                      (sign_extend:DI
7434                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
7435             (const_int 32))))
7436    (clobber (match_scratch:SI 3 "=1"))
7437    (clobber (reg:CC 17))]
7438   "GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM"
7439   "imul{l}\t%2"
7440   [(set_attr "type" "imul")
7441    (set_attr "ppro_uops" "few")
7442    (set (attr "athlon_decode")
7443      (if_then_else (eq_attr "cpu" "athlon")
7444         (const_string "vector")
7445         (const_string "double")))
7446    (set_attr "mode" "SI")])
7448 (define_insn "*smulsi3_highpart_zext"
7449   [(set (match_operand:DI 0 "register_operand" "=d")
7450         (zero_extend:DI (truncate:SI
7451           (lshiftrt:DI
7452             (mult:DI (sign_extend:DI
7453                        (match_operand:SI 1 "nonimmediate_operand" "%a"))
7454                      (sign_extend:DI
7455                        (match_operand:SI 2 "nonimmediate_operand" "rm")))
7456             (const_int 32)))))
7457    (clobber (match_scratch:SI 3 "=1"))
7458    (clobber (reg:CC 17))]
7459   "TARGET_64BIT
7460    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
7461   "imul{l}\t%2"
7462   [(set_attr "type" "imul")
7463    (set_attr "ppro_uops" "few")
7464    (set (attr "athlon_decode")
7465      (if_then_else (eq_attr "cpu" "athlon")
7466         (const_string "vector")
7467         (const_string "double")))
7468    (set_attr "mode" "SI")])
7470 ;; The patterns that match these are at the end of this file.
7472 (define_expand "mulxf3"
7473   [(set (match_operand:XF 0 "register_operand" "")
7474         (mult:XF (match_operand:XF 1 "register_operand" "")
7475                  (match_operand:XF 2 "register_operand" "")))]
7476   "!TARGET_64BIT && TARGET_80387"
7477   "")
7479 (define_expand "multf3"
7480   [(set (match_operand:TF 0 "register_operand" "")
7481         (mult:TF (match_operand:TF 1 "register_operand" "")
7482                  (match_operand:TF 2 "register_operand" "")))]
7483   "TARGET_80387"
7484   "")
7486 (define_expand "muldf3"
7487   [(set (match_operand:DF 0 "register_operand" "")
7488         (mult:DF (match_operand:DF 1 "register_operand" "")
7489                  (match_operand:DF 2 "nonimmediate_operand" "")))]
7490   "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
7491   "")
7493 (define_expand "mulsf3"
7494   [(set (match_operand:SF 0 "register_operand" "")
7495         (mult:SF (match_operand:SF 1 "register_operand" "")
7496                  (match_operand:SF 2 "nonimmediate_operand" "")))]
7497   "TARGET_80387 || TARGET_SSE_MATH"
7498   "")
7500 ;; Divide instructions
7502 (define_insn "divqi3"
7503   [(set (match_operand:QI 0 "register_operand" "=a")
7504         (div:QI (match_operand:HI 1 "register_operand" "0")
7505                 (match_operand:QI 2 "nonimmediate_operand" "qm")))
7506    (clobber (reg:CC 17))]
7507   "TARGET_QIMODE_MATH"
7508   "idiv{b}\t%2"
7509   [(set_attr "type" "idiv")
7510    (set_attr "mode" "QI")
7511    (set_attr "ppro_uops" "few")])
7513 (define_insn "udivqi3"
7514   [(set (match_operand:QI 0 "register_operand" "=a")
7515         (udiv:QI (match_operand:HI 1 "register_operand" "0")
7516                  (match_operand:QI 2 "nonimmediate_operand" "qm")))
7517    (clobber (reg:CC 17))]
7518   "TARGET_QIMODE_MATH"
7519   "div{b}\t%2"
7520   [(set_attr "type" "idiv")
7521    (set_attr "mode" "QI")
7522    (set_attr "ppro_uops" "few")])
7524 ;; The patterns that match these are at the end of this file.
7526 (define_expand "divxf3"
7527   [(set (match_operand:XF 0 "register_operand" "")
7528         (div:XF (match_operand:XF 1 "register_operand" "")
7529                 (match_operand:XF 2 "register_operand" "")))]
7530   "!TARGET_64BIT && TARGET_80387"
7531   "")
7533 (define_expand "divtf3"
7534   [(set (match_operand:TF 0 "register_operand" "")
7535         (div:TF (match_operand:TF 1 "register_operand" "")
7536                 (match_operand:TF 2 "register_operand" "")))]
7537   "TARGET_80387"
7538   "")
7540 (define_expand "divdf3"
7541   [(set (match_operand:DF 0 "register_operand" "")
7542         (div:DF (match_operand:DF 1 "register_operand" "")
7543                 (match_operand:DF 2 "nonimmediate_operand" "")))]
7544    "TARGET_80387 || (TARGET_SSE2 && TARGET_SSE_MATH)"
7545    "")
7547 (define_expand "divsf3"
7548   [(set (match_operand:SF 0 "register_operand" "")
7549         (div:SF (match_operand:SF 1 "register_operand" "")
7550                 (match_operand:SF 2 "nonimmediate_operand" "")))]
7551   "TARGET_80387 || TARGET_SSE_MATH"
7552   "")
7554 ;; Remainder instructions.
7556 (define_expand "divmoddi4"
7557   [(parallel [(set (match_operand:DI 0 "register_operand" "")
7558                    (div:DI (match_operand:DI 1 "register_operand" "")
7559                            (match_operand:DI 2 "nonimmediate_operand" "")))
7560               (set (match_operand:DI 3 "register_operand" "")
7561                    (mod:DI (match_dup 1) (match_dup 2)))
7562               (clobber (reg:CC 17))])]
7563   "TARGET_64BIT"
7564   "")
7566 ;; Allow to come the parameter in eax or edx to avoid extra moves.
7567 ;; Penalize eax case slightly because it results in worse scheduling
7568 ;; of code.
7569 (define_insn "*divmoddi4_nocltd_rex64"
7570   [(set (match_operand:DI 0 "register_operand" "=&a,?a")
7571         (div:DI (match_operand:DI 2 "register_operand" "1,0")
7572                 (match_operand:DI 3 "nonimmediate_operand" "rm,rm")))
7573    (set (match_operand:DI 1 "register_operand" "=&d,&d")
7574         (mod:DI (match_dup 2) (match_dup 3)))
7575    (clobber (reg:CC 17))]
7576   "TARGET_64BIT && !optimize_size && !TARGET_USE_CLTD"
7577   "#"
7578   [(set_attr "type" "multi")])
7580 (define_insn "*divmoddi4_cltd_rex64"
7581   [(set (match_operand:DI 0 "register_operand" "=a")
7582         (div:DI (match_operand:DI 2 "register_operand" "a")
7583                 (match_operand:DI 3 "nonimmediate_operand" "rm")))
7584    (set (match_operand:DI 1 "register_operand" "=&d")
7585         (mod:DI (match_dup 2) (match_dup 3)))
7586    (clobber (reg:CC 17))]
7587   "TARGET_64BIT && (optimize_size || TARGET_USE_CLTD)"
7588   "#"
7589   [(set_attr "type" "multi")])
7591 (define_insn "*divmoddi_noext_rex64"
7592   [(set (match_operand:DI 0 "register_operand" "=a")
7593         (div:DI (match_operand:DI 1 "register_operand" "0")
7594                 (match_operand:DI 2 "nonimmediate_operand" "rm")))
7595    (set (match_operand:DI 3 "register_operand" "=d")
7596         (mod:DI (match_dup 1) (match_dup 2)))
7597    (use (match_operand:DI 4 "register_operand" "3"))
7598    (clobber (reg:CC 17))]
7599   "TARGET_64BIT"
7600   "idiv{q}\t%2"
7601   [(set_attr "type" "idiv")
7602    (set_attr "mode" "DI")
7603    (set_attr "ppro_uops" "few")])
7605 (define_split
7606   [(set (match_operand:DI 0 "register_operand" "")
7607         (div:DI (match_operand:DI 1 "register_operand" "")
7608                 (match_operand:DI 2 "nonimmediate_operand" "")))
7609    (set (match_operand:DI 3 "register_operand" "")
7610         (mod:DI (match_dup 1) (match_dup 2)))
7611    (clobber (reg:CC 17))]
7612   "TARGET_64BIT && reload_completed"
7613   [(parallel [(set (match_dup 3)
7614                    (ashiftrt:DI (match_dup 4) (const_int 63)))
7615               (clobber (reg:CC 17))])
7616    (parallel [(set (match_dup 0)
7617                    (div:DI (reg:DI 0) (match_dup 2)))
7618               (set (match_dup 3)
7619                    (mod:DI (reg:DI 0) (match_dup 2)))
7620               (use (match_dup 3))
7621               (clobber (reg:CC 17))])]
7623   /* Avoid use of cltd in favor of a mov+shift.  */
7624   if (!TARGET_USE_CLTD && !optimize_size)
7625     {
7626       if (true_regnum (operands[1]))
7627         emit_move_insn (operands[0], operands[1]);
7628       else
7629         emit_move_insn (operands[3], operands[1]);
7630       operands[4] = operands[3];
7631     }
7632   else
7633     {
7634       if (true_regnum (operands[1]))
7635         abort();
7636       operands[4] = operands[1];
7637     }
7641 (define_expand "divmodsi4"
7642   [(parallel [(set (match_operand:SI 0 "register_operand" "")
7643                    (div:SI (match_operand:SI 1 "register_operand" "")
7644                            (match_operand:SI 2 "nonimmediate_operand" "")))
7645               (set (match_operand:SI 3 "register_operand" "")
7646                    (mod:SI (match_dup 1) (match_dup 2)))
7647               (clobber (reg:CC 17))])]
7648   ""
7649   "")
7651 ;; Allow to come the parameter in eax or edx to avoid extra moves.
7652 ;; Penalize eax case slightly because it results in worse scheduling
7653 ;; of code.
7654 (define_insn "*divmodsi4_nocltd"
7655   [(set (match_operand:SI 0 "register_operand" "=&a,?a")
7656         (div:SI (match_operand:SI 2 "register_operand" "1,0")
7657                 (match_operand:SI 3 "nonimmediate_operand" "rm,rm")))
7658    (set (match_operand:SI 1 "register_operand" "=&d,&d")
7659         (mod:SI (match_dup 2) (match_dup 3)))
7660    (clobber (reg:CC 17))]
7661   "!optimize_size && !TARGET_USE_CLTD"
7662   "#"
7663   [(set_attr "type" "multi")])
7665 (define_insn "*divmodsi4_cltd"
7666   [(set (match_operand:SI 0 "register_operand" "=a")
7667         (div:SI (match_operand:SI 2 "register_operand" "a")
7668                 (match_operand:SI 3 "nonimmediate_operand" "rm")))
7669    (set (match_operand:SI 1 "register_operand" "=&d")
7670         (mod:SI (match_dup 2) (match_dup 3)))
7671    (clobber (reg:CC 17))]
7672   "optimize_size || TARGET_USE_CLTD"
7673   "#"
7674   [(set_attr "type" "multi")])
7676 (define_insn "*divmodsi_noext"
7677   [(set (match_operand:SI 0 "register_operand" "=a")
7678         (div:SI (match_operand:SI 1 "register_operand" "0")
7679                 (match_operand:SI 2 "nonimmediate_operand" "rm")))
7680    (set (match_operand:SI 3 "register_operand" "=d")
7681         (mod:SI (match_dup 1) (match_dup 2)))
7682    (use (match_operand:SI 4 "register_operand" "3"))
7683    (clobber (reg:CC 17))]
7684   ""
7685   "idiv{l}\t%2"
7686   [(set_attr "type" "idiv")
7687    (set_attr "mode" "SI")
7688    (set_attr "ppro_uops" "few")])
7690 (define_split
7691   [(set (match_operand:SI 0 "register_operand" "")
7692         (div:SI (match_operand:SI 1 "register_operand" "")
7693                 (match_operand:SI 2 "nonimmediate_operand" "")))
7694    (set (match_operand:SI 3 "register_operand" "")
7695         (mod:SI (match_dup 1) (match_dup 2)))
7696    (clobber (reg:CC 17))]
7697   "reload_completed"
7698   [(parallel [(set (match_dup 3)
7699                    (ashiftrt:SI (match_dup 4) (const_int 31)))
7700               (clobber (reg:CC 17))])
7701    (parallel [(set (match_dup 0)
7702                    (div:SI (reg:SI 0) (match_dup 2)))
7703               (set (match_dup 3)
7704                    (mod:SI (reg:SI 0) (match_dup 2)))
7705               (use (match_dup 3))
7706               (clobber (reg:CC 17))])]
7708   /* Avoid use of cltd in favor of a mov+shift.  */
7709   if (!TARGET_USE_CLTD && !optimize_size)
7710     {
7711       if (true_regnum (operands[1]))
7712         emit_move_insn (operands[0], operands[1]);
7713       else
7714         emit_move_insn (operands[3], operands[1]);
7715       operands[4] = operands[3];
7716     }
7717   else
7718     {
7719       if (true_regnum (operands[1]))
7720         abort();
7721       operands[4] = operands[1];
7722     }
7724 ;; %%% Split me.
7725 (define_insn "divmodhi4"
7726   [(set (match_operand:HI 0 "register_operand" "=a")
7727         (div:HI (match_operand:HI 1 "register_operand" "0")
7728                 (match_operand:HI 2 "nonimmediate_operand" "rm")))
7729    (set (match_operand:HI 3 "register_operand" "=&d")
7730         (mod:HI (match_dup 1) (match_dup 2)))
7731    (clobber (reg:CC 17))]
7732   "TARGET_HIMODE_MATH"
7733   "cwtd\;idiv{w}\t%2"
7734   [(set_attr "type" "multi")
7735    (set_attr "length_immediate" "0")
7736    (set_attr "mode" "SI")])
7738 (define_insn "udivmoddi4"
7739   [(set (match_operand:DI 0 "register_operand" "=a")
7740         (udiv:DI (match_operand:DI 1 "register_operand" "0")
7741                  (match_operand:DI 2 "nonimmediate_operand" "rm")))
7742    (set (match_operand:DI 3 "register_operand" "=&d")
7743         (umod:DI (match_dup 1) (match_dup 2)))
7744    (clobber (reg:CC 17))]
7745   "TARGET_64BIT"
7746   "xor{q}\t%3, %3\;div{q}\t%2"
7747   [(set_attr "type" "multi")
7748    (set_attr "length_immediate" "0")
7749    (set_attr "mode" "DI")])
7751 (define_insn "*udivmoddi4_noext"
7752   [(set (match_operand:DI 0 "register_operand" "=a")
7753         (udiv:DI (match_operand:DI 1 "register_operand" "0")
7754                  (match_operand:DI 2 "nonimmediate_operand" "rm")))
7755    (set (match_operand:DI 3 "register_operand" "=d")
7756         (umod:DI (match_dup 1) (match_dup 2)))
7757    (use (match_dup 3))
7758    (clobber (reg:CC 17))]
7759   "TARGET_64BIT"
7760   "div{q}\t%2"
7761   [(set_attr "type" "idiv")
7762    (set_attr "ppro_uops" "few")
7763    (set_attr "mode" "DI")])
7765 (define_split
7766   [(set (match_operand:DI 0 "register_operand" "")
7767         (udiv:DI (match_operand:DI 1 "register_operand" "")
7768                  (match_operand:DI 2 "nonimmediate_operand" "")))
7769    (set (match_operand:DI 3 "register_operand" "")
7770         (umod:DI (match_dup 1) (match_dup 2)))
7771    (clobber (reg:CC 17))]
7772   "TARGET_64BIT && reload_completed"
7773   [(set (match_dup 3) (const_int 0))
7774    (parallel [(set (match_dup 0)
7775                    (udiv:DI (match_dup 1) (match_dup 2)))
7776               (set (match_dup 3)
7777                    (umod:DI (match_dup 1) (match_dup 2)))
7778               (use (match_dup 3))
7779               (clobber (reg:CC 17))])]
7780   "")
7782 (define_insn "udivmodsi4"
7783   [(set (match_operand:SI 0 "register_operand" "=a")
7784         (udiv:SI (match_operand:SI 1 "register_operand" "0")
7785                  (match_operand:SI 2 "nonimmediate_operand" "rm")))
7786    (set (match_operand:SI 3 "register_operand" "=&d")
7787         (umod:SI (match_dup 1) (match_dup 2)))
7788    (clobber (reg:CC 17))]
7789   ""
7790   "xor{l}\t%3, %3\;div{l}\t%2"
7791   [(set_attr "type" "multi")
7792    (set_attr "length_immediate" "0")
7793    (set_attr "mode" "SI")])
7795 (define_insn "*udivmodsi4_noext"
7796   [(set (match_operand:SI 0 "register_operand" "=a")
7797         (udiv:SI (match_operand:SI 1 "register_operand" "0")
7798                  (match_operand:SI 2 "nonimmediate_operand" "rm")))
7799    (set (match_operand:SI 3 "register_operand" "=d")
7800         (umod:SI (match_dup 1) (match_dup 2)))
7801    (use (match_dup 3))
7802    (clobber (reg:CC 17))]
7803   ""
7804   "div{l}\t%2"
7805   [(set_attr "type" "idiv")
7806    (set_attr "ppro_uops" "few")
7807    (set_attr "mode" "SI")])
7809 (define_split
7810   [(set (match_operand:SI 0 "register_operand" "")
7811         (udiv:SI (match_operand:SI 1 "register_operand" "")
7812                  (match_operand:SI 2 "nonimmediate_operand" "")))
7813    (set (match_operand:SI 3 "register_operand" "")
7814         (umod:SI (match_dup 1) (match_dup 2)))
7815    (clobber (reg:CC 17))]
7816   "reload_completed"
7817   [(set (match_dup 3) (const_int 0))
7818    (parallel [(set (match_dup 0)
7819                    (udiv:SI (match_dup 1) (match_dup 2)))
7820               (set (match_dup 3)
7821                    (umod:SI (match_dup 1) (match_dup 2)))
7822               (use (match_dup 3))
7823               (clobber (reg:CC 17))])]
7824   "")
7826 (define_expand "udivmodhi4"
7827   [(set (match_dup 4) (const_int 0))
7828    (parallel [(set (match_operand:HI 0 "register_operand" "")
7829                    (udiv:HI (match_operand:HI 1 "register_operand" "")
7830                             (match_operand:HI 2 "nonimmediate_operand" "")))
7831               (set (match_operand:HI 3 "register_operand" "")
7832                    (umod:HI (match_dup 1) (match_dup 2)))
7833               (use (match_dup 4))
7834               (clobber (reg:CC 17))])]
7835   "TARGET_HIMODE_MATH"
7836   "operands[4] = gen_reg_rtx (HImode);")
7838 (define_insn "*udivmodhi_noext"
7839   [(set (match_operand:HI 0 "register_operand" "=a")
7840         (udiv:HI (match_operand:HI 1 "register_operand" "0")
7841                  (match_operand:HI 2 "nonimmediate_operand" "rm")))
7842    (set (match_operand:HI 3 "register_operand" "=d")
7843         (umod:HI (match_dup 1) (match_dup 2)))
7844    (use (match_operand:HI 4 "register_operand" "3"))
7845    (clobber (reg:CC 17))]
7846   ""
7847   "div{w}\t%2"
7848   [(set_attr "type" "idiv")
7849    (set_attr "mode" "HI")
7850    (set_attr "ppro_uops" "few")])
7852 ;; We can not use div/idiv for double division, because it causes
7853 ;; "division by zero" on the overflow and that's not what we expect
7854 ;; from truncate.  Because true (non truncating) double division is
7855 ;; never generated, we can't create this insn anyway.
7857 ;(define_insn ""
7858 ;  [(set (match_operand:SI 0 "register_operand" "=a")
7859 ;       (truncate:SI
7860 ;         (udiv:DI (match_operand:DI 1 "register_operand" "A")
7861 ;                  (zero_extend:DI
7862 ;                    (match_operand:SI 2 "nonimmediate_operand" "rm")))))
7863 ;   (set (match_operand:SI 3 "register_operand" "=d")
7864 ;       (truncate:SI
7865 ;         (umod:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))
7866 ;   (clobber (reg:CC 17))]
7867 ;  ""
7868 ;  "div{l}\t{%2, %0|%0, %2}"
7869 ;  [(set_attr "type" "idiv")
7870 ;   (set_attr "ppro_uops" "few")])
7872 ;;- Logical AND instructions
7874 ;; On Pentium, "test imm, reg" is pairable only with eax, ax, and al.
7875 ;; Note that this excludes ah.
7877 (define_insn "*testdi_1_rex64"
7878   [(set (reg 17)
7879         (compare
7880           (and:DI (match_operand:DI 0 "nonimmediate_operand" "%*a,r,*a,r,rm")
7881                   (match_operand:DI 1 "x86_64_szext_nonmemory_operand" "Z,Z,e,e,re"))
7882           (const_int 0)))]
7883   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
7884   "@
7885    test{l}\t{%k1, %k0|%k0, %k1} 
7886    test{l}\t{%k1, %k0|%k0, %k1} 
7887    test{q}\t{%1, %0|%0, %1} 
7888    test{q}\t{%1, %0|%0, %1} 
7889    test{q}\t{%1, %0|%0, %1}"
7890   [(set_attr "type" "test")
7891    (set_attr "modrm" "0,1,0,1,1")
7892    (set_attr "mode" "SI,SI,DI,DI,DI")
7893    (set_attr "pent_pair" "uv,np,uv,np,uv")])
7895 (define_insn "testsi_1"
7896   [(set (reg 17)
7897         (compare
7898           (and:SI (match_operand:SI 0 "nonimmediate_operand" "%*a,r,rm")
7899                   (match_operand:SI 1 "nonmemory_operand" "in,in,rin"))
7900           (const_int 0)))]
7901   "ix86_match_ccmode (insn, CCNOmode)"
7902   "test{l}\t{%1, %0|%0, %1}"
7903   [(set_attr "type" "test")
7904    (set_attr "modrm" "0,1,1")
7905    (set_attr "mode" "SI")
7906    (set_attr "pent_pair" "uv,np,uv")])
7908 (define_expand "testsi_ccno_1"
7909   [(set (reg:CCNO 17)
7910         (compare:CCNO
7911           (and:SI (match_operand:SI 0 "nonimmediate_operand" "")
7912                   (match_operand:SI 1 "nonmemory_operand" ""))
7913           (const_int 0)))]
7914   ""
7915   "")
7917 (define_insn "*testhi_1"
7918   [(set (reg 17)
7919         (compare (and:HI (match_operand:HI 0 "nonimmediate_operand" "%*a,r,rm")
7920                          (match_operand:HI 1 "nonmemory_operand" "n,n,rn"))
7921                  (const_int 0)))]
7922   "ix86_match_ccmode (insn, CCNOmode)"
7923   "test{w}\t{%1, %0|%0, %1}"
7924   [(set_attr "type" "test")
7925    (set_attr "modrm" "0,1,1")
7926    (set_attr "mode" "HI")
7927    (set_attr "pent_pair" "uv,np,uv")])
7929 (define_expand "testqi_ccz_1"
7930   [(set (reg:CCZ 17)
7931         (compare:CCZ (and:QI (match_operand:QI 0 "nonimmediate_operand" "")
7932                              (match_operand:QI 1 "nonmemory_operand" ""))
7933                  (const_int 0)))]
7934   ""
7935   "")
7937 (define_insn "*testqi_1"
7938   [(set (reg 17)
7939         (compare (and:QI (match_operand:QI 0 "nonimmediate_operand" "%*a,q,qm,r")
7940                          (match_operand:QI 1 "nonmemory_operand" "n,n,qn,n"))
7941                  (const_int 0)))]
7942   "ix86_match_ccmode (insn, CCNOmode)"
7944   if (which_alternative == 3)
7945     {
7946       if (GET_CODE (operands[1]) == CONST_INT
7947           && (INTVAL (operands[1]) & 0xffffff00))
7948         operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff);
7949       return "test{l}\t{%1, %k0|%k0, %1}";
7950     }
7951   return "test{b}\t{%1, %0|%0, %1}";
7953   [(set_attr "type" "test")
7954    (set_attr "modrm" "0,1,1,1")
7955    (set_attr "mode" "QI,QI,QI,SI")
7956    (set_attr "pent_pair" "uv,np,uv,np")])
7958 (define_expand "testqi_ext_ccno_0"
7959   [(set (reg:CCNO 17)
7960         (compare:CCNO
7961           (and:SI
7962             (zero_extract:SI
7963               (match_operand 0 "ext_register_operand" "")
7964               (const_int 8)
7965               (const_int 8))
7966             (match_operand 1 "const_int_operand" ""))
7967           (const_int 0)))]
7968   ""
7969   "")
7971 (define_insn "*testqi_ext_0"
7972   [(set (reg 17)
7973         (compare
7974           (and:SI
7975             (zero_extract:SI
7976               (match_operand 0 "ext_register_operand" "Q")
7977               (const_int 8)
7978               (const_int 8))
7979             (match_operand 1 "const_int_operand" "n"))
7980           (const_int 0)))]
7981   "ix86_match_ccmode (insn, CCNOmode)"
7982   "test{b}\t{%1, %h0|%h0, %1}"
7983   [(set_attr "type" "test")
7984    (set_attr "mode" "QI")
7985    (set_attr "length_immediate" "1")
7986    (set_attr "pent_pair" "np")])
7988 (define_insn "*testqi_ext_1"
7989   [(set (reg 17)
7990         (compare
7991           (and:SI
7992             (zero_extract:SI
7993               (match_operand 0 "ext_register_operand" "Q")
7994               (const_int 8)
7995               (const_int 8))
7996             (zero_extend:SI
7997               (match_operand:QI 1 "nonimmediate_operand" "Qm")))
7998           (const_int 0)))]
7999   "!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
8000   "test{b}\t{%1, %h0|%h0, %1}"
8001   [(set_attr "type" "test")
8002    (set_attr "mode" "QI")])
8004 (define_insn "*testqi_ext_1_rex64"
8005   [(set (reg 17)
8006         (compare
8007           (and:SI
8008             (zero_extract:SI
8009               (match_operand 0 "ext_register_operand" "Q")
8010               (const_int 8)
8011               (const_int 8))
8012             (zero_extend:SI
8013               (match_operand:QI 1 "register_operand" "Q")))
8014           (const_int 0)))]
8015   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
8016   "test{b}\t{%1, %h0|%h0, %1}"
8017   [(set_attr "type" "test")
8018    (set_attr "mode" "QI")])
8020 (define_insn "*testqi_ext_2"
8021   [(set (reg 17)
8022         (compare
8023           (and:SI
8024             (zero_extract:SI
8025               (match_operand 0 "ext_register_operand" "Q")
8026               (const_int 8)
8027               (const_int 8))
8028             (zero_extract:SI
8029               (match_operand 1 "ext_register_operand" "Q")
8030               (const_int 8)
8031               (const_int 8)))
8032           (const_int 0)))]
8033   "ix86_match_ccmode (insn, CCNOmode)"
8034   "test{b}\t{%h1, %h0|%h0, %h1}"
8035   [(set_attr "type" "test")
8036    (set_attr "mode" "QI")])
8038 ;; Combine likes to form bit extractions for some tests.  Humor it.
8039 (define_insn "*testqi_ext_3"
8040   [(set (reg 17)
8041         (compare (zero_extract:SI
8042                    (match_operand 0 "nonimmediate_operand" "rm")
8043                    (match_operand:SI 1 "const_int_operand" "")
8044                    (match_operand:SI 2 "const_int_operand" ""))
8045                  (const_int 0)))]
8046   "ix86_match_ccmode (insn, CCNOmode)
8047    && (GET_MODE (operands[0]) == SImode
8048        || (TARGET_64BIT && GET_MODE (operands[0]) == DImode)
8049        || GET_MODE (operands[0]) == HImode
8050        || GET_MODE (operands[0]) == QImode)"
8051   "#")
8053 (define_insn "*testqi_ext_3_rex64"
8054   [(set (reg 17)
8055         (compare (zero_extract:DI
8056                    (match_operand 0 "nonimmediate_operand" "rm")
8057                    (match_operand:DI 1 "const_int_operand" "")
8058                    (match_operand:DI 2 "const_int_operand" ""))
8059                  (const_int 0)))]
8060   "TARGET_64BIT
8061    && ix86_match_ccmode (insn, CCNOmode)
8062    /* The code below cannot deal with constants outside HOST_WIDE_INT.  */
8063    && INTVAL (operands[1]) + INTVAL (operands[2]) < HOST_BITS_PER_WIDE_INT
8064    /* Ensure that resulting mask is zero or sign extended operand.  */
8065    && (INTVAL (operands[1]) + INTVAL (operands[2]) <= 32
8066        || (INTVAL (operands[1]) + INTVAL (operands[2]) == 64
8067            && INTVAL (operands[1]) > 32))
8068    && (GET_MODE (operands[0]) == SImode
8069        || GET_MODE (operands[0]) == DImode
8070        || GET_MODE (operands[0]) == HImode
8071        || GET_MODE (operands[0]) == QImode)"
8072   "#")
8074 (define_split
8075   [(set (reg 17)
8076         (compare (zero_extract
8077                    (match_operand 0 "nonimmediate_operand" "")
8078                    (match_operand 1 "const_int_operand" "")
8079                    (match_operand 2 "const_int_operand" ""))
8080                  (const_int 0)))]
8081   "ix86_match_ccmode (insn, CCNOmode)"
8082   [(set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))]
8084   HOST_WIDE_INT len = INTVAL (operands[1]);
8085   HOST_WIDE_INT pos = INTVAL (operands[2]);
8086   HOST_WIDE_INT mask;
8087   enum machine_mode mode, submode;
8089   mode = GET_MODE (operands[0]);
8090   if (GET_CODE (operands[0]) == MEM)
8091     {
8092       /* ??? Combine likes to put non-volatile mem extractions in QImode
8093          no matter the size of the test.  So find a mode that works.  */
8094       if (! MEM_VOLATILE_P (operands[0]))
8095         {
8096           mode = smallest_mode_for_size (pos + len, MODE_INT);
8097           operands[0] = adjust_address (operands[0], mode, 0);
8098         }
8099     }
8100   else if (GET_CODE (operands[0]) == SUBREG
8101            && (submode = GET_MODE (SUBREG_REG (operands[0])),
8102                GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (submode))
8103            && pos + len <= GET_MODE_BITSIZE (submode))
8104     {
8105       /* Narrow a paradoxical subreg to prevent partial register stalls.  */
8106       mode = submode;
8107       operands[0] = SUBREG_REG (operands[0]);
8108     }
8109   else if (mode == HImode && pos + len <= 8)
8110     {
8111       /* Small HImode tests can be converted to QImode.  */
8112       mode = QImode;
8113       operands[0] = gen_lowpart (QImode, operands[0]);
8114     }
8116   mask  = ((HOST_WIDE_INT)1 << (pos + len)) - 1;
8117   mask &= ~(((HOST_WIDE_INT)1 << pos) - 1);
8119   operands[3] = gen_rtx_AND (mode, operands[0], gen_int_mode (mask, mode));
8122 ;; Convert HImode/SImode test instructions with immediate to QImode ones.
8123 ;; i386 does not allow to encode test with 8bit sign extended immediate, so
8124 ;; this is relatively important trick.
8125 ;; Do the conversion only post-reload to avoid limiting of the register class
8126 ;; to QI regs.
8127 (define_split
8128   [(set (reg 17)
8129         (compare
8130           (and (match_operand 0 "register_operand" "")
8131                (match_operand 1 "const_int_operand" ""))
8132           (const_int 0)))]
8133    "reload_completed
8134     && QI_REG_P (operands[0])
8135     && ((ix86_match_ccmode (insn, CCZmode)
8136          && !(INTVAL (operands[1]) & ~(255 << 8)))
8137         || (ix86_match_ccmode (insn, CCNOmode)
8138             && !(INTVAL (operands[1]) & ~(127 << 8))))
8139     && GET_MODE (operands[0]) != QImode"
8140   [(set (reg:CCNO 17)
8141         (compare:CCNO
8142           (and:SI (zero_extract:SI (match_dup 0) (const_int 8) (const_int 8))
8143                   (match_dup 1))
8144           (const_int 0)))]
8145   "operands[0] = gen_lowpart (SImode, operands[0]);
8146    operands[1] = gen_int_mode (INTVAL (operands[1]) >> 8, SImode);")
8148 (define_split
8149   [(set (reg 17)
8150         (compare
8151           (and (match_operand 0 "nonimmediate_operand" "")
8152                (match_operand 1 "const_int_operand" ""))
8153           (const_int 0)))]
8154    "reload_completed
8155     && (!REG_P (operands[0]) || ANY_QI_REG_P (operands[0]))
8156     && ((ix86_match_ccmode (insn, CCZmode)
8157          && !(INTVAL (operands[1]) & ~255))
8158         || (ix86_match_ccmode (insn, CCNOmode)
8159             && !(INTVAL (operands[1]) & ~127)))
8160     && GET_MODE (operands[0]) != QImode"
8161   [(set (reg:CCNO 17)
8162         (compare:CCNO
8163           (and:QI (match_dup 0)
8164                   (match_dup 1))
8165           (const_int 0)))]
8166   "operands[0] = gen_lowpart (QImode, operands[0]);
8167    operands[1] = gen_lowpart (QImode, operands[1]);")
8170 ;; %%% This used to optimize known byte-wide and operations to memory,
8171 ;; and sometimes to QImode registers.  If this is considered useful,
8172 ;; it should be done with splitters.
8174 (define_expand "anddi3"
8175   [(set (match_operand:DI 0 "nonimmediate_operand" "")
8176         (and:DI (match_operand:DI 1 "nonimmediate_operand" "")
8177                 (match_operand:DI 2 "x86_64_szext_general_operand" "")))
8178    (clobber (reg:CC 17))]
8179   "TARGET_64BIT"
8180   "ix86_expand_binary_operator (AND, DImode, operands); DONE;")
8182 (define_insn "*anddi_1_rex64"
8183   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,rm,r,r")
8184         (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,qm")
8185                 (match_operand:DI 2 "x86_64_szext_general_operand" "Z,re,rm,L")))
8186    (clobber (reg:CC 17))]
8187   "TARGET_64BIT && ix86_binary_operator_ok (AND, DImode, operands)"
8189   switch (get_attr_type (insn))
8190     {
8191     case TYPE_IMOVX:
8192       {
8193         enum machine_mode mode;
8195         if (GET_CODE (operands[2]) != CONST_INT)
8196           abort ();
8197         if (INTVAL (operands[2]) == 0xff)
8198           mode = QImode;
8199         else if (INTVAL (operands[2]) == 0xffff)
8200           mode = HImode;
8201         else
8202           abort ();
8203         
8204         operands[1] = gen_lowpart (mode, operands[1]);
8205         if (mode == QImode)
8206           return "movz{bq|x}\t{%1,%0|%0, %1}";
8207         else
8208           return "movz{wq|x}\t{%1,%0|%0, %1}";
8209       }
8211     default:
8212       if (! rtx_equal_p (operands[0], operands[1]))
8213         abort ();
8214       if (get_attr_mode (insn) == MODE_SI)
8215         return "and{l}\t{%k2, %k0|%k0, %k2}";
8216       else
8217         return "and{q}\t{%2, %0|%0, %2}";
8218     }
8220   [(set_attr "type" "alu,alu,alu,imovx")
8221    (set_attr "length_immediate" "*,*,*,0")
8222    (set_attr "mode" "SI,DI,DI,DI")])
8224 (define_insn "*anddi_2"
8225   [(set (reg 17)
8226         (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
8227                          (match_operand:DI 2 "x86_64_szext_general_operand" "Z,rem,re"))
8228                  (const_int 0)))
8229    (set (match_operand:DI 0 "nonimmediate_operand" "=r,r,rm")
8230         (and:DI (match_dup 1) (match_dup 2)))]
8231   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8232    && ix86_binary_operator_ok (AND, DImode, operands)"
8233   "@
8234    and{l}\t{%k2, %k0|%k0, %k2} 
8235    and{q}\t{%2, %0|%0, %2} 
8236    and{q}\t{%2, %0|%0, %2}"
8237   [(set_attr "type" "alu")
8238    (set_attr "mode" "SI,DI,DI")])
8240 (define_expand "andsi3"
8241   [(set (match_operand:SI 0 "nonimmediate_operand" "")
8242         (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
8243                 (match_operand:SI 2 "general_operand" "")))
8244    (clobber (reg:CC 17))]
8245   ""
8246   "ix86_expand_binary_operator (AND, SImode, operands); DONE;")
8248 (define_insn "*andsi_1"
8249   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r,r")
8250         (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,qm")
8251                 (match_operand:SI 2 "general_operand" "ri,rm,L")))
8252    (clobber (reg:CC 17))]
8253   "ix86_binary_operator_ok (AND, SImode, operands)"
8255   switch (get_attr_type (insn))
8256     {
8257     case TYPE_IMOVX:
8258       {
8259         enum machine_mode mode;
8261         if (GET_CODE (operands[2]) != CONST_INT)
8262           abort ();
8263         if (INTVAL (operands[2]) == 0xff)
8264           mode = QImode;
8265         else if (INTVAL (operands[2]) == 0xffff)
8266           mode = HImode;
8267         else
8268           abort ();
8269         
8270         operands[1] = gen_lowpart (mode, operands[1]);
8271         if (mode == QImode)
8272           return "movz{bl|x}\t{%1,%0|%0, %1}";
8273         else
8274           return "movz{wl|x}\t{%1,%0|%0, %1}";
8275       }
8277     default:
8278       if (! rtx_equal_p (operands[0], operands[1]))
8279         abort ();
8280       return "and{l}\t{%2, %0|%0, %2}";
8281     }
8283   [(set_attr "type" "alu,alu,imovx")
8284    (set_attr "length_immediate" "*,*,0")
8285    (set_attr "mode" "SI")])
8287 (define_split
8288   [(set (match_operand 0 "register_operand" "")
8289         (and (match_dup 0)
8290              (const_int -65536)))
8291    (clobber (reg:CC 17))]
8292   "optimize_size || (TARGET_FAST_PREFIX && !TARGET_PARTIAL_REG_STALL)"
8293   [(set (strict_low_part (match_dup 1)) (const_int 0))]
8294   "operands[1] = gen_lowpart (HImode, operands[0]);")
8296 (define_split
8297   [(set (match_operand 0 "ext_register_operand" "")
8298         (and (match_dup 0)
8299              (const_int -256)))
8300    (clobber (reg:CC 17))]
8301   "(optimize_size || !TARGET_PARTIAL_REG_STALL) && reload_completed"
8302   [(set (strict_low_part (match_dup 1)) (const_int 0))]
8303   "operands[1] = gen_lowpart (QImode, operands[0]);")
8305 (define_split
8306   [(set (match_operand 0 "ext_register_operand" "")
8307         (and (match_dup 0)
8308              (const_int -65281)))
8309    (clobber (reg:CC 17))]
8310   "(optimize_size || !TARGET_PARTIAL_REG_STALL) && reload_completed"
8311   [(parallel [(set (zero_extract:SI (match_dup 0)
8312                                     (const_int 8)
8313                                     (const_int 8))
8314                    (xor:SI 
8315                      (zero_extract:SI (match_dup 0)
8316                                       (const_int 8)
8317                                       (const_int 8))
8318                      (zero_extract:SI (match_dup 0)
8319                                       (const_int 8)
8320                                       (const_int 8))))
8321               (clobber (reg:CC 17))])]
8322   "operands[0] = gen_lowpart (SImode, operands[0]);")
8324 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8325 (define_insn "*andsi_1_zext"
8326   [(set (match_operand:DI 0 "register_operand" "=r")
8327         (zero_extend:DI
8328           (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8329                   (match_operand:SI 2 "general_operand" "rim"))))
8330    (clobber (reg:CC 17))]
8331   "TARGET_64BIT && ix86_binary_operator_ok (AND, SImode, operands)"
8332   "and{l}\t{%2, %k0|%k0, %2}"
8333   [(set_attr "type" "alu")
8334    (set_attr "mode" "SI")])
8336 (define_insn "*andsi_2"
8337   [(set (reg 17)
8338         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8339                          (match_operand:SI 2 "general_operand" "rim,ri"))
8340                  (const_int 0)))
8341    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
8342         (and:SI (match_dup 1) (match_dup 2)))]
8343   "ix86_match_ccmode (insn, CCNOmode)
8344    && ix86_binary_operator_ok (AND, SImode, operands)"
8345   "and{l}\t{%2, %0|%0, %2}"
8346   [(set_attr "type" "alu")
8347    (set_attr "mode" "SI")])
8349 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8350 (define_insn "*andsi_2_zext"
8351   [(set (reg 17)
8352         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8353                          (match_operand:SI 2 "general_operand" "rim"))
8354                  (const_int 0)))
8355    (set (match_operand:DI 0 "register_operand" "=r")
8356         (zero_extend:DI (and:SI (match_dup 1) (match_dup 2))))]
8357   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8358    && ix86_binary_operator_ok (AND, SImode, operands)"
8359   "and{l}\t{%2, %k0|%k0, %2}"
8360   [(set_attr "type" "alu")
8361    (set_attr "mode" "SI")])
8363 (define_expand "andhi3"
8364   [(set (match_operand:HI 0 "nonimmediate_operand" "")
8365         (and:HI (match_operand:HI 1 "nonimmediate_operand" "")
8366                 (match_operand:HI 2 "general_operand" "")))
8367    (clobber (reg:CC 17))]
8368   "TARGET_HIMODE_MATH"
8369   "ix86_expand_binary_operator (AND, HImode, operands); DONE;")
8371 (define_insn "*andhi_1"
8372   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r,r")
8373         (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,qm")
8374                 (match_operand:HI 2 "general_operand" "ri,rm,L")))
8375    (clobber (reg:CC 17))]
8376   "ix86_binary_operator_ok (AND, HImode, operands)"
8378   switch (get_attr_type (insn))
8379     {
8380     case TYPE_IMOVX:
8381       if (GET_CODE (operands[2]) != CONST_INT)
8382         abort ();
8383       if (INTVAL (operands[2]) == 0xff)
8384         return "movz{bl|x}\t{%b1, %k0|%k0, %b1}";
8385       abort ();
8387     default:
8388       if (! rtx_equal_p (operands[0], operands[1]))
8389         abort ();
8391       return "and{w}\t{%2, %0|%0, %2}";
8392     }
8394   [(set_attr "type" "alu,alu,imovx")
8395    (set_attr "length_immediate" "*,*,0")
8396    (set_attr "mode" "HI,HI,SI")])
8398 (define_insn "*andhi_2"
8399   [(set (reg 17)
8400         (compare (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8401                          (match_operand:HI 2 "general_operand" "rim,ri"))
8402                  (const_int 0)))
8403    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
8404         (and:HI (match_dup 1) (match_dup 2)))]
8405   "ix86_match_ccmode (insn, CCNOmode)
8406    && ix86_binary_operator_ok (AND, HImode, operands)"
8407   "and{w}\t{%2, %0|%0, %2}"
8408   [(set_attr "type" "alu")
8409    (set_attr "mode" "HI")])
8411 (define_expand "andqi3"
8412   [(set (match_operand:QI 0 "nonimmediate_operand" "")
8413         (and:QI (match_operand:QI 1 "nonimmediate_operand" "")
8414                 (match_operand:QI 2 "general_operand" "")))
8415    (clobber (reg:CC 17))]
8416   "TARGET_QIMODE_MATH"
8417   "ix86_expand_binary_operator (AND, QImode, operands); DONE;")
8419 ;; %%% Potential partial reg stall on alternative 2.  What to do?
8420 (define_insn "*andqi_1"
8421   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
8422         (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8423                 (match_operand:QI 2 "general_operand" "qi,qmi,ri")))
8424    (clobber (reg:CC 17))]
8425   "ix86_binary_operator_ok (AND, QImode, operands)"
8426   "@
8427    and{b}\t{%2, %0|%0, %2}
8428    and{b}\t{%2, %0|%0, %2}
8429    and{l}\t{%k2, %k0|%k0, %k2}"
8430   [(set_attr "type" "alu")
8431    (set_attr "mode" "QI,QI,SI")])
8433 (define_insn "*andqi_1_slp"
8434   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
8435         (and:QI (match_dup 0)
8436                 (match_operand:QI 1 "general_operand" "qi,qmi")))
8437    (clobber (reg:CC 17))]
8438   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
8439    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
8440   "and{b}\t{%1, %0|%0, %1}"
8441   [(set_attr "type" "alu1")
8442    (set_attr "mode" "QI")])
8444 (define_insn "*andqi_2"
8445   [(set (reg 17)
8446         (compare (and:QI
8447                    (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8448                    (match_operand:QI 2 "general_operand" "qim,qi,i"))
8449                  (const_int 0)))
8450    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm,*r")
8451         (and:QI (match_dup 1) (match_dup 2)))]
8452   "ix86_match_ccmode (insn, CCNOmode)
8453    && ix86_binary_operator_ok (AND, QImode, operands)"
8455   if (which_alternative == 2)
8456     {
8457       if (GET_CODE (operands[2]) == CONST_INT
8458           && (INTVAL (operands[2]) & 0xffffff00))
8459         operands[2] = GEN_INT (INTVAL (operands[2]) & 0xff);
8460       return "and{l}\t{%2, %k0|%k0, %2}";
8461     }
8462   return "and{b}\t{%2, %0|%0, %2}";
8464   [(set_attr "type" "alu")
8465    (set_attr "mode" "QI,QI,SI")])
8467 (define_insn "*andqi_2_slp"
8468   [(set (reg 17)
8469         (compare (and:QI
8470                    (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
8471                    (match_operand:QI 1 "nonimmediate_operand" "qmi,qi"))
8472                  (const_int 0)))
8473    (set (strict_low_part (match_dup 0))
8474         (and:QI (match_dup 0) (match_dup 1)))]
8475   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
8476    && ix86_match_ccmode (insn, CCNOmode)
8477    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
8478   "and{b}\t{%1, %0|%0, %1}"
8479   [(set_attr "type" "alu1")
8480    (set_attr "mode" "QI")])
8482 ;; ??? A bug in recog prevents it from recognizing a const_int as an
8483 ;; operand to zero_extend in andqi_ext_1.  It was checking explicitly
8484 ;; for a QImode operand, which of course failed.
8486 (define_insn "andqi_ext_0"
8487   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8488                          (const_int 8)
8489                          (const_int 8))
8490         (and:SI 
8491           (zero_extract:SI
8492             (match_operand 1 "ext_register_operand" "0")
8493             (const_int 8)
8494             (const_int 8))
8495           (match_operand 2 "const_int_operand" "n")))
8496    (clobber (reg:CC 17))]
8497   ""
8498   "and{b}\t{%2, %h0|%h0, %2}"
8499   [(set_attr "type" "alu")
8500    (set_attr "length_immediate" "1")
8501    (set_attr "mode" "QI")])
8503 ;; Generated by peephole translating test to and.  This shows up
8504 ;; often in fp comparisons.
8506 (define_insn "*andqi_ext_0_cc"
8507   [(set (reg 17)
8508         (compare
8509           (and:SI
8510             (zero_extract:SI
8511               (match_operand 1 "ext_register_operand" "0")
8512               (const_int 8)
8513               (const_int 8))
8514             (match_operand 2 "const_int_operand" "n"))
8515           (const_int 0)))
8516    (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8517                          (const_int 8)
8518                          (const_int 8))
8519         (and:SI 
8520           (zero_extract:SI
8521             (match_dup 1)
8522             (const_int 8)
8523             (const_int 8))
8524           (match_dup 2)))]
8525   "ix86_match_ccmode (insn, CCNOmode)"
8526   "and{b}\t{%2, %h0|%h0, %2}"
8527   [(set_attr "type" "alu")
8528    (set_attr "length_immediate" "1")
8529    (set_attr "mode" "QI")])
8531 (define_insn "*andqi_ext_1"
8532   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8533                          (const_int 8)
8534                          (const_int 8))
8535         (and:SI 
8536           (zero_extract:SI
8537             (match_operand 1 "ext_register_operand" "0")
8538             (const_int 8)
8539             (const_int 8))
8540           (zero_extend:SI
8541             (match_operand:QI 2 "general_operand" "Qm"))))
8542    (clobber (reg:CC 17))]
8543   "!TARGET_64BIT"
8544   "and{b}\t{%2, %h0|%h0, %2}"
8545   [(set_attr "type" "alu")
8546    (set_attr "length_immediate" "0")
8547    (set_attr "mode" "QI")])
8549 (define_insn "*andqi_ext_1_rex64"
8550   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8551                          (const_int 8)
8552                          (const_int 8))
8553         (and:SI 
8554           (zero_extract:SI
8555             (match_operand 1 "ext_register_operand" "0")
8556             (const_int 8)
8557             (const_int 8))
8558           (zero_extend:SI
8559             (match_operand 2 "ext_register_operand" "Q"))))
8560    (clobber (reg:CC 17))]
8561   "TARGET_64BIT"
8562   "and{b}\t{%2, %h0|%h0, %2}"
8563   [(set_attr "type" "alu")
8564    (set_attr "length_immediate" "0")
8565    (set_attr "mode" "QI")])
8567 (define_insn "*andqi_ext_2"
8568   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8569                          (const_int 8)
8570                          (const_int 8))
8571         (and:SI
8572           (zero_extract:SI
8573             (match_operand 1 "ext_register_operand" "%0")
8574             (const_int 8)
8575             (const_int 8))
8576           (zero_extract:SI
8577             (match_operand 2 "ext_register_operand" "Q")
8578             (const_int 8)
8579             (const_int 8))))
8580    (clobber (reg:CC 17))]
8581   ""
8582   "and{b}\t{%h2, %h0|%h0, %h2}"
8583   [(set_attr "type" "alu")
8584    (set_attr "length_immediate" "0")
8585    (set_attr "mode" "QI")])
8587 ;; Convert wide AND instructions with immediate operand to shorter QImode
8588 ;; equivalents when possible.
8589 ;; Don't do the splitting with memory operands, since it introduces risk
8590 ;; of memory mismatch stalls.  We may want to do the splitting for optimizing
8591 ;; for size, but that can (should?) be handled by generic code instead.
8592 (define_split
8593   [(set (match_operand 0 "register_operand" "")
8594         (and (match_operand 1 "register_operand" "")
8595              (match_operand 2 "const_int_operand" "")))
8596    (clobber (reg:CC 17))]
8597    "reload_completed
8598     && QI_REG_P (operands[0])
8599     && (!TARGET_PARTIAL_REG_STALL || optimize_size)
8600     && !(~INTVAL (operands[2]) & ~(255 << 8))
8601     && GET_MODE (operands[0]) != QImode"
8602   [(parallel [(set (zero_extract:SI (match_dup 0) (const_int 8) (const_int 8))
8603                    (and:SI (zero_extract:SI (match_dup 1)
8604                                             (const_int 8) (const_int 8))
8605                            (match_dup 2)))
8606               (clobber (reg:CC 17))])]
8607   "operands[0] = gen_lowpart (SImode, operands[0]);
8608    operands[1] = gen_lowpart (SImode, operands[1]);
8609    operands[2] = gen_int_mode ((INTVAL (operands[2]) >> 8) & 0xff, SImode);")
8611 ;; Since AND can be encoded with sign extended immediate, this is only
8612 ;; profitable when 7th bit is not set.
8613 (define_split
8614   [(set (match_operand 0 "register_operand" "")
8615         (and (match_operand 1 "general_operand" "")
8616              (match_operand 2 "const_int_operand" "")))
8617    (clobber (reg:CC 17))]
8618    "reload_completed
8619     && ANY_QI_REG_P (operands[0])
8620     && (!TARGET_PARTIAL_REG_STALL || optimize_size)
8621     && !(~INTVAL (operands[2]) & ~255)
8622     && !(INTVAL (operands[2]) & 128)
8623     && GET_MODE (operands[0]) != QImode"
8624   [(parallel [(set (strict_low_part (match_dup 0))
8625                    (and:QI (match_dup 1)
8626                            (match_dup 2)))
8627               (clobber (reg:CC 17))])]
8628   "operands[0] = gen_lowpart (QImode, operands[0]);
8629    operands[1] = gen_lowpart (QImode, operands[1]);
8630    operands[2] = gen_lowpart (QImode, operands[2]);")
8632 ;; Logical inclusive OR instructions
8634 ;; %%% This used to optimize known byte-wide and operations to memory.
8635 ;; If this is considered useful, it should be done with splitters.
8637 (define_expand "iordi3"
8638   [(set (match_operand:DI 0 "nonimmediate_operand" "")
8639         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "")
8640                 (match_operand:DI 2 "x86_64_general_operand" "")))
8641    (clobber (reg:CC 17))]
8642   "TARGET_64BIT"
8643   "ix86_expand_binary_operator (IOR, DImode, operands); DONE;")
8645 (define_insn "*iordi_1_rex64"
8646   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
8647         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8648                 (match_operand:DI 2 "x86_64_general_operand" "re,rme")))
8649    (clobber (reg:CC 17))]
8650   "TARGET_64BIT
8651    && ix86_binary_operator_ok (IOR, DImode, operands)"
8652   "or{q}\t{%2, %0|%0, %2}"
8653   [(set_attr "type" "alu")
8654    (set_attr "mode" "DI")])
8656 (define_insn "*iordi_2_rex64"
8657   [(set (reg 17)
8658         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
8659                          (match_operand:DI 2 "x86_64_general_operand" "rem,re"))
8660                  (const_int 0)))
8661    (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
8662         (ior:DI (match_dup 1) (match_dup 2)))]
8663   "TARGET_64BIT
8664    && ix86_match_ccmode (insn, CCNOmode)
8665    && ix86_binary_operator_ok (IOR, DImode, operands)"
8666   "or{q}\t{%2, %0|%0, %2}"
8667   [(set_attr "type" "alu")
8668    (set_attr "mode" "DI")])
8670 (define_insn "*iordi_3_rex64"
8671   [(set (reg 17)
8672         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
8673                          (match_operand:DI 2 "x86_64_general_operand" "rem"))
8674                  (const_int 0)))
8675    (clobber (match_scratch:DI 0 "=r"))]
8676   "TARGET_64BIT
8677    && ix86_match_ccmode (insn, CCNOmode)
8678    && ix86_binary_operator_ok (IOR, DImode, operands)"
8679   "or{q}\t{%2, %0|%0, %2}"
8680   [(set_attr "type" "alu")
8681    (set_attr "mode" "DI")])
8684 (define_expand "iorsi3"
8685   [(set (match_operand:SI 0 "nonimmediate_operand" "")
8686         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "")
8687                 (match_operand:SI 2 "general_operand" "")))
8688    (clobber (reg:CC 17))]
8689   ""
8690   "ix86_expand_binary_operator (IOR, SImode, operands); DONE;")
8692 (define_insn "*iorsi_1"
8693   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
8694         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8695                 (match_operand:SI 2 "general_operand" "ri,rmi")))
8696    (clobber (reg:CC 17))]
8697   "ix86_binary_operator_ok (IOR, SImode, operands)"
8698   "or{l}\t{%2, %0|%0, %2}"
8699   [(set_attr "type" "alu")
8700    (set_attr "mode" "SI")])
8702 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8703 (define_insn "*iorsi_1_zext"
8704   [(set (match_operand:DI 0 "register_operand" "=rm")
8705         (zero_extend:DI
8706           (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8707                   (match_operand:SI 2 "general_operand" "rim"))))
8708    (clobber (reg:CC 17))]
8709   "TARGET_64BIT && ix86_binary_operator_ok (IOR, SImode, operands)"
8710   "or{l}\t{%2, %k0|%k0, %2}"
8711   [(set_attr "type" "alu")
8712    (set_attr "mode" "SI")])
8714 (define_insn "*iorsi_1_zext_imm"
8715   [(set (match_operand:DI 0 "register_operand" "=rm")
8716         (ior:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
8717                 (match_operand:DI 2 "x86_64_zext_immediate_operand" "Z")))
8718    (clobber (reg:CC 17))]
8719   "TARGET_64BIT"
8720   "or{l}\t{%2, %k0|%k0, %2}"
8721   [(set_attr "type" "alu")
8722    (set_attr "mode" "SI")])
8724 (define_insn "*iorsi_2"
8725   [(set (reg 17)
8726         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
8727                          (match_operand:SI 2 "general_operand" "rim,ri"))
8728                  (const_int 0)))
8729    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
8730         (ior:SI (match_dup 1) (match_dup 2)))]
8731   "ix86_match_ccmode (insn, CCNOmode)
8732    && ix86_binary_operator_ok (IOR, SImode, operands)"
8733   "or{l}\t{%2, %0|%0, %2}"
8734   [(set_attr "type" "alu")
8735    (set_attr "mode" "SI")])
8737 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
8738 ;; ??? Special case for immediate operand is missing - it is tricky.
8739 (define_insn "*iorsi_2_zext"
8740   [(set (reg 17)
8741         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8742                          (match_operand:SI 2 "general_operand" "rim"))
8743                  (const_int 0)))
8744    (set (match_operand:DI 0 "register_operand" "=r")
8745         (zero_extend:DI (ior:SI (match_dup 1) (match_dup 2))))]
8746   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8747    && ix86_binary_operator_ok (IOR, SImode, operands)"
8748   "or{l}\t{%2, %k0|%k0, %2}"
8749   [(set_attr "type" "alu")
8750    (set_attr "mode" "SI")])
8752 (define_insn "*iorsi_2_zext_imm"
8753   [(set (reg 17)
8754         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8755                          (match_operand 2 "x86_64_zext_immediate_operand" "Z"))
8756                  (const_int 0)))
8757    (set (match_operand:DI 0 "register_operand" "=r")
8758         (ior:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
8759   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
8760    && ix86_binary_operator_ok (IOR, SImode, operands)"
8761   "or{l}\t{%2, %k0|%k0, %2}"
8762   [(set_attr "type" "alu")
8763    (set_attr "mode" "SI")])
8765 (define_insn "*iorsi_3"
8766   [(set (reg 17)
8767         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
8768                          (match_operand:SI 2 "general_operand" "rim"))
8769                  (const_int 0)))
8770    (clobber (match_scratch:SI 0 "=r"))]
8771   "ix86_match_ccmode (insn, CCNOmode)
8772    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8773   "or{l}\t{%2, %0|%0, %2}"
8774   [(set_attr "type" "alu")
8775    (set_attr "mode" "SI")])
8777 (define_expand "iorhi3"
8778   [(set (match_operand:HI 0 "nonimmediate_operand" "")
8779         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "")
8780                 (match_operand:HI 2 "general_operand" "")))
8781    (clobber (reg:CC 17))]
8782   "TARGET_HIMODE_MATH"
8783   "ix86_expand_binary_operator (IOR, HImode, operands); DONE;")
8785 (define_insn "*iorhi_1"
8786   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
8787         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8788                 (match_operand:HI 2 "general_operand" "rmi,ri")))
8789    (clobber (reg:CC 17))]
8790   "ix86_binary_operator_ok (IOR, HImode, operands)"
8791   "or{w}\t{%2, %0|%0, %2}"
8792   [(set_attr "type" "alu")
8793    (set_attr "mode" "HI")])
8795 (define_insn "*iorhi_2"
8796   [(set (reg 17)
8797         (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
8798                          (match_operand:HI 2 "general_operand" "rim,ri"))
8799                  (const_int 0)))
8800    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
8801         (ior:HI (match_dup 1) (match_dup 2)))]
8802   "ix86_match_ccmode (insn, CCNOmode)
8803    && ix86_binary_operator_ok (IOR, HImode, operands)"
8804   "or{w}\t{%2, %0|%0, %2}"
8805   [(set_attr "type" "alu")
8806    (set_attr "mode" "HI")])
8808 (define_insn "*iorhi_3"
8809   [(set (reg 17)
8810         (compare (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
8811                          (match_operand:HI 2 "general_operand" "rim"))
8812                  (const_int 0)))
8813    (clobber (match_scratch:HI 0 "=r"))]
8814   "ix86_match_ccmode (insn, CCNOmode)
8815    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8816   "or{w}\t{%2, %0|%0, %2}"
8817   [(set_attr "type" "alu")
8818    (set_attr "mode" "HI")])
8820 (define_expand "iorqi3"
8821   [(set (match_operand:QI 0 "nonimmediate_operand" "")
8822         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "")
8823                 (match_operand:QI 2 "general_operand" "")))
8824    (clobber (reg:CC 17))]
8825   "TARGET_QIMODE_MATH"
8826   "ix86_expand_binary_operator (IOR, QImode, operands); DONE;")
8828 ;; %%% Potential partial reg stall on alternative 2.  What to do?
8829 (define_insn "*iorqi_1"
8830   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r")
8831         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8832                 (match_operand:QI 2 "general_operand" "qmi,qi,ri")))
8833    (clobber (reg:CC 17))]
8834   "ix86_binary_operator_ok (IOR, QImode, operands)"
8835   "@
8836    or{b}\t{%2, %0|%0, %2}
8837    or{b}\t{%2, %0|%0, %2}
8838    or{l}\t{%k2, %k0|%k0, %k2}"
8839   [(set_attr "type" "alu")
8840    (set_attr "mode" "QI,QI,SI")])
8842 (define_insn "*iorqi_1_slp"
8843   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+q,m"))
8844         (ior:QI (match_dup 0)
8845                 (match_operand:QI 1 "general_operand" "qmi,qi")))
8846    (clobber (reg:CC 17))]
8847   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
8848    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
8849   "or{b}\t{%1, %0|%0, %1}"
8850   [(set_attr "type" "alu1")
8851    (set_attr "mode" "QI")])
8853 (define_insn "*iorqi_2"
8854   [(set (reg 17)
8855         (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
8856                          (match_operand:QI 2 "general_operand" "qim,qi"))
8857                  (const_int 0)))
8858    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
8859         (ior:QI (match_dup 1) (match_dup 2)))]
8860   "ix86_match_ccmode (insn, CCNOmode)
8861    && ix86_binary_operator_ok (IOR, QImode, operands)"
8862   "or{b}\t{%2, %0|%0, %2}"
8863   [(set_attr "type" "alu")
8864    (set_attr "mode" "QI")])
8866 (define_insn "*iorqi_2_slp"
8867   [(set (reg 17)
8868         (compare (ior:QI (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
8869                          (match_operand:QI 1 "general_operand" "qim,qi"))
8870                  (const_int 0)))
8871    (set (strict_low_part (match_dup 0))
8872         (ior:QI (match_dup 0) (match_dup 1)))]
8873   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
8874    && ix86_match_ccmode (insn, CCNOmode)
8875    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
8876   "or{b}\t{%1, %0|%0, %1}"
8877   [(set_attr "type" "alu1")
8878    (set_attr "mode" "QI")])
8880 (define_insn "*iorqi_3"
8881   [(set (reg 17)
8882         (compare (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
8883                          (match_operand:QI 2 "general_operand" "qim"))
8884                  (const_int 0)))
8885    (clobber (match_scratch:QI 0 "=q"))]
8886   "ix86_match_ccmode (insn, CCNOmode)
8887    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
8888   "or{b}\t{%2, %0|%0, %2}"
8889   [(set_attr "type" "alu")
8890    (set_attr "mode" "QI")])
8892 (define_insn "iorqi_ext_0"
8893   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8894                          (const_int 8)
8895                          (const_int 8))
8896         (ior:SI 
8897           (zero_extract:SI
8898             (match_operand 1 "ext_register_operand" "0")
8899             (const_int 8)
8900             (const_int 8))
8901           (match_operand 2 "const_int_operand" "n")))
8902    (clobber (reg:CC 17))]
8903   "(!TARGET_PARTIAL_REG_STALL || optimize_size)"
8904   "or{b}\t{%2, %h0|%h0, %2}"
8905   [(set_attr "type" "alu")
8906    (set_attr "length_immediate" "1")
8907    (set_attr "mode" "QI")])
8909 (define_insn "*iorqi_ext_1"
8910   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8911                          (const_int 8)
8912                          (const_int 8))
8913         (ior:SI 
8914           (zero_extract:SI
8915             (match_operand 1 "ext_register_operand" "0")
8916             (const_int 8)
8917             (const_int 8))
8918           (zero_extend:SI
8919             (match_operand:QI 2 "general_operand" "Qm"))))
8920    (clobber (reg:CC 17))]
8921   "!TARGET_64BIT
8922    && (!TARGET_PARTIAL_REG_STALL || optimize_size)"
8923   "or{b}\t{%2, %h0|%h0, %2}"
8924   [(set_attr "type" "alu")
8925    (set_attr "length_immediate" "0")
8926    (set_attr "mode" "QI")])
8928 (define_insn "*iorqi_ext_1_rex64"
8929   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8930                          (const_int 8)
8931                          (const_int 8))
8932         (ior:SI 
8933           (zero_extract:SI
8934             (match_operand 1 "ext_register_operand" "0")
8935             (const_int 8)
8936             (const_int 8))
8937           (zero_extend:SI
8938             (match_operand 2 "ext_register_operand" "Q"))))
8939    (clobber (reg:CC 17))]
8940   "TARGET_64BIT
8941    && (!TARGET_PARTIAL_REG_STALL || optimize_size)"
8942   "or{b}\t{%2, %h0|%h0, %2}"
8943   [(set_attr "type" "alu")
8944    (set_attr "length_immediate" "0")
8945    (set_attr "mode" "QI")])
8947 (define_insn "*iorqi_ext_2"
8948   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
8949                          (const_int 8)
8950                          (const_int 8))
8951         (ior:SI 
8952           (zero_extract:SI (match_operand 1 "ext_register_operand" "0")
8953                            (const_int 8)
8954                            (const_int 8))
8955           (zero_extract:SI (match_operand 2 "ext_register_operand" "Q")
8956                            (const_int 8)
8957                            (const_int 8))))
8958    (clobber (reg:CC 17))]
8959   "(!TARGET_PARTIAL_REG_STALL || optimize_size)"
8960   "ior{b}\t{%h2, %h0|%h0, %h2}"
8961   [(set_attr "type" "alu")
8962    (set_attr "length_immediate" "0")
8963    (set_attr "mode" "QI")])
8965 (define_split
8966   [(set (match_operand 0 "register_operand" "")
8967         (ior (match_operand 1 "register_operand" "")
8968              (match_operand 2 "const_int_operand" "")))
8969    (clobber (reg:CC 17))]
8970    "reload_completed
8971     && QI_REG_P (operands[0])
8972     && (!TARGET_PARTIAL_REG_STALL || optimize_size)
8973     && !(INTVAL (operands[2]) & ~(255 << 8))
8974     && GET_MODE (operands[0]) != QImode"
8975   [(parallel [(set (zero_extract:SI (match_dup 0) (const_int 8) (const_int 8))
8976                    (ior:SI (zero_extract:SI (match_dup 1)
8977                                             (const_int 8) (const_int 8))
8978                            (match_dup 2)))
8979               (clobber (reg:CC 17))])]
8980   "operands[0] = gen_lowpart (SImode, operands[0]);
8981    operands[1] = gen_lowpart (SImode, operands[1]);
8982    operands[2] = gen_int_mode ((INTVAL (operands[2]) >> 8) & 0xff, SImode);")
8984 ;; Since OR can be encoded with sign extended immediate, this is only
8985 ;; profitable when 7th bit is set.
8986 (define_split
8987   [(set (match_operand 0 "register_operand" "")
8988         (ior (match_operand 1 "general_operand" "")
8989              (match_operand 2 "const_int_operand" "")))
8990    (clobber (reg:CC 17))]
8991    "reload_completed
8992     && ANY_QI_REG_P (operands[0])
8993     && (!TARGET_PARTIAL_REG_STALL || optimize_size)
8994     && !(INTVAL (operands[2]) & ~255)
8995     && (INTVAL (operands[2]) & 128)
8996     && GET_MODE (operands[0]) != QImode"
8997   [(parallel [(set (strict_low_part (match_dup 0))
8998                    (ior:QI (match_dup 1)
8999                            (match_dup 2)))
9000               (clobber (reg:CC 17))])]
9001   "operands[0] = gen_lowpart (QImode, operands[0]);
9002    operands[1] = gen_lowpart (QImode, operands[1]);
9003    operands[2] = gen_lowpart (QImode, operands[2]);")
9005 ;; Logical XOR instructions
9007 ;; %%% This used to optimize known byte-wide and operations to memory.
9008 ;; If this is considered useful, it should be done with splitters.
9010 (define_expand "xordi3"
9011   [(set (match_operand:DI 0 "nonimmediate_operand" "")
9012         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "")
9013                 (match_operand:DI 2 "x86_64_general_operand" "")))
9014    (clobber (reg:CC 17))]
9015   "TARGET_64BIT"
9016   "ix86_expand_binary_operator (XOR, DImode, operands); DONE;")
9018 (define_insn "*xordi_1_rex64"
9019   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
9020         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
9021                 (match_operand:DI 2 "x86_64_general_operand" "re,rm")))
9022    (clobber (reg:CC 17))]
9023   "TARGET_64BIT
9024    && ix86_binary_operator_ok (XOR, DImode, operands)"
9025   "@
9026    xor{q}\t{%2, %0|%0, %2} 
9027    xor{q}\t{%2, %0|%0, %2}"
9028   [(set_attr "type" "alu")
9029    (set_attr "mode" "DI,DI")])
9031 (define_insn "*xordi_2_rex64"
9032   [(set (reg 17)
9033         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
9034                          (match_operand:DI 2 "x86_64_general_operand" "rem,re"))
9035                  (const_int 0)))
9036    (set (match_operand:DI 0 "nonimmediate_operand" "=r,rm")
9037         (xor:DI (match_dup 1) (match_dup 2)))]
9038   "TARGET_64BIT
9039    && ix86_match_ccmode (insn, CCNOmode)
9040    && ix86_binary_operator_ok (XOR, DImode, operands)"
9041   "@
9042    xor{q}\t{%2, %0|%0, %2} 
9043    xor{q}\t{%2, %0|%0, %2}"
9044   [(set_attr "type" "alu")
9045    (set_attr "mode" "DI,DI")])
9047 (define_insn "*xordi_3_rex64"
9048   [(set (reg 17)
9049         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
9050                          (match_operand:DI 2 "x86_64_general_operand" "rem"))
9051                  (const_int 0)))
9052    (clobber (match_scratch:DI 0 "=r"))]
9053   "TARGET_64BIT
9054    && ix86_match_ccmode (insn, CCNOmode)
9055    && ix86_binary_operator_ok (XOR, DImode, operands)"
9056   "xor{q}\t{%2, %0|%0, %2}"
9057   [(set_attr "type" "alu")
9058    (set_attr "mode" "DI")])
9060 (define_expand "xorsi3"
9061   [(set (match_operand:SI 0 "nonimmediate_operand" "")
9062         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "")
9063                 (match_operand:SI 2 "general_operand" "")))
9064    (clobber (reg:CC 17))]
9065   ""
9066   "ix86_expand_binary_operator (XOR, SImode, operands); DONE;")
9068 (define_insn "*xorsi_1"
9069   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
9070         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
9071                 (match_operand:SI 2 "general_operand" "ri,rm")))
9072    (clobber (reg:CC 17))]
9073   "ix86_binary_operator_ok (XOR, SImode, operands)"
9074   "xor{l}\t{%2, %0|%0, %2}"
9075   [(set_attr "type" "alu")
9076    (set_attr "mode" "SI")])
9078 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
9079 ;; Add speccase for immediates
9080 (define_insn "*xorsi_1_zext"
9081   [(set (match_operand:DI 0 "register_operand" "=r")
9082         (zero_extend:DI
9083           (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
9084                   (match_operand:SI 2 "general_operand" "rim"))))
9085    (clobber (reg:CC 17))]
9086   "TARGET_64BIT && ix86_binary_operator_ok (XOR, SImode, operands)"
9087   "xor{l}\t{%2, %k0|%k0, %2}"
9088   [(set_attr "type" "alu")
9089    (set_attr "mode" "SI")])
9091 (define_insn "*xorsi_1_zext_imm"
9092   [(set (match_operand:DI 0 "register_operand" "=r")
9093         (xor:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
9094                 (match_operand:DI 2 "x86_64_zext_immediate_operand" "Z")))
9095    (clobber (reg:CC 17))]
9096   "TARGET_64BIT && ix86_binary_operator_ok (XOR, SImode, operands)"
9097   "xor{l}\t{%2, %k0|%k0, %2}"
9098   [(set_attr "type" "alu")
9099    (set_attr "mode" "SI")])
9101 (define_insn "*xorsi_2"
9102   [(set (reg 17)
9103         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
9104                          (match_operand:SI 2 "general_operand" "rim,ri"))
9105                  (const_int 0)))
9106    (set (match_operand:SI 0 "nonimmediate_operand" "=r,rm")
9107         (xor:SI (match_dup 1) (match_dup 2)))]
9108   "ix86_match_ccmode (insn, CCNOmode)
9109    && ix86_binary_operator_ok (XOR, SImode, operands)"
9110   "xor{l}\t{%2, %0|%0, %2}"
9111   [(set_attr "type" "alu")
9112    (set_attr "mode" "SI")])
9114 ;; See comment for addsi_1_zext why we do use nonimmediate_operand
9115 ;; ??? Special case for immediate operand is missing - it is tricky.
9116 (define_insn "*xorsi_2_zext"
9117   [(set (reg 17)
9118         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
9119                          (match_operand:SI 2 "general_operand" "rim"))
9120                  (const_int 0)))
9121    (set (match_operand:DI 0 "register_operand" "=r")
9122         (zero_extend:DI (xor:SI (match_dup 1) (match_dup 2))))]
9123   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
9124    && ix86_binary_operator_ok (XOR, SImode, operands)"
9125   "xor{l}\t{%2, %k0|%k0, %2}"
9126   [(set_attr "type" "alu")
9127    (set_attr "mode" "SI")])
9129 (define_insn "*xorsi_2_zext_imm"
9130   [(set (reg 17)
9131         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
9132                          (match_operand 2 "x86_64_zext_immediate_operand" "Z"))
9133                  (const_int 0)))
9134    (set (match_operand:DI 0 "register_operand" "=r")
9135         (xor:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
9136   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
9137    && ix86_binary_operator_ok (XOR, SImode, operands)"
9138   "xor{l}\t{%2, %k0|%k0, %2}"
9139   [(set_attr "type" "alu")
9140    (set_attr "mode" "SI")])
9142 (define_insn "*xorsi_3"
9143   [(set (reg 17)
9144         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0")
9145                          (match_operand:SI 2 "general_operand" "rim"))
9146                  (const_int 0)))
9147    (clobber (match_scratch:SI 0 "=r"))]
9148   "ix86_match_ccmode (insn, CCNOmode)
9149    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
9150   "xor{l}\t{%2, %0|%0, %2}"
9151   [(set_attr "type" "alu")
9152    (set_attr "mode" "SI")])
9154 (define_expand "xorhi3"
9155   [(set (match_operand:HI 0 "nonimmediate_operand" "")
9156         (xor:HI (match_operand:HI 1 "nonimmediate_operand" "")
9157                 (match_operand:HI 2 "general_operand" "")))
9158    (clobber (reg:CC 17))]
9159   "TARGET_HIMODE_MATH"
9160   "ix86_expand_binary_operator (XOR, HImode, operands); DONE;")
9162 (define_insn "*xorhi_1"
9163   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
9164         (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
9165                 (match_operand:HI 2 "general_operand" "rmi,ri")))
9166    (clobber (reg:CC 17))]
9167   "ix86_binary_operator_ok (XOR, HImode, operands)"
9168   "xor{w}\t{%2, %0|%0, %2}"
9169   [(set_attr "type" "alu")
9170    (set_attr "mode" "HI")])
9172 (define_insn "*xorhi_2"
9173   [(set (reg 17)
9174         (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
9175                          (match_operand:HI 2 "general_operand" "rim,ri"))
9176                  (const_int 0)))
9177    (set (match_operand:HI 0 "nonimmediate_operand" "=r,rm")
9178         (xor:HI (match_dup 1) (match_dup 2)))]
9179   "ix86_match_ccmode (insn, CCNOmode)
9180    && ix86_binary_operator_ok (XOR, HImode, operands)"
9181   "xor{w}\t{%2, %0|%0, %2}"
9182   [(set_attr "type" "alu")
9183    (set_attr "mode" "HI")])
9185 (define_insn "*xorhi_3"
9186   [(set (reg 17)
9187         (compare (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0")
9188                          (match_operand:HI 2 "general_operand" "rim"))
9189                  (const_int 0)))
9190    (clobber (match_scratch:HI 0 "=r"))]
9191   "ix86_match_ccmode (insn, CCNOmode)
9192    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
9193   "xor{w}\t{%2, %0|%0, %2}"
9194   [(set_attr "type" "alu")
9195    (set_attr "mode" "HI")])
9197 (define_expand "xorqi3"
9198   [(set (match_operand:QI 0 "nonimmediate_operand" "")
9199         (xor:QI (match_operand:QI 1 "nonimmediate_operand" "")
9200                 (match_operand:QI 2 "general_operand" "")))
9201    (clobber (reg:CC 17))]
9202   "TARGET_QIMODE_MATH"
9203   "ix86_expand_binary_operator (XOR, QImode, operands); DONE;")
9205 ;; %%% Potential partial reg stall on alternative 2.  What to do?
9206 (define_insn "*xorqi_1"
9207   [(set (match_operand:QI 0 "nonimmediate_operand" "=q,m,r")
9208         (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
9209                 (match_operand:QI 2 "general_operand" "qmi,qi,ri")))
9210    (clobber (reg:CC 17))]
9211   "ix86_binary_operator_ok (XOR, QImode, operands)"
9212   "@
9213    xor{b}\t{%2, %0|%0, %2}
9214    xor{b}\t{%2, %0|%0, %2}
9215    xor{l}\t{%k2, %k0|%k0, %k2}"
9216   [(set_attr "type" "alu")
9217    (set_attr "mode" "QI,QI,SI")])
9219 (define_insn "*xorqi_1_slp"
9220   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
9221         (xor:QI (match_dup 0)
9222                 (match_operand:QI 1 "general_operand" "qi,qmi")))
9223    (clobber (reg:CC 17))]
9224   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
9225    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
9226   "xor{b}\t{%1, %0|%0, %1}"
9227   [(set_attr "type" "alu1")
9228    (set_attr "mode" "QI")])
9230 (define_insn "xorqi_ext_0"
9231   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9232                          (const_int 8)
9233                          (const_int 8))
9234         (xor:SI 
9235           (zero_extract:SI
9236             (match_operand 1 "ext_register_operand" "0")
9237             (const_int 8)
9238             (const_int 8))
9239           (match_operand 2 "const_int_operand" "n")))
9240    (clobber (reg:CC 17))]
9241   "(!TARGET_PARTIAL_REG_STALL || optimize_size)"
9242   "xor{b}\t{%2, %h0|%h0, %2}"
9243   [(set_attr "type" "alu")
9244    (set_attr "length_immediate" "1")
9245    (set_attr "mode" "QI")])
9247 (define_insn "*xorqi_ext_1"
9248   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9249                          (const_int 8)
9250                          (const_int 8))
9251         (xor:SI 
9252           (zero_extract:SI
9253             (match_operand 1 "ext_register_operand" "0")
9254             (const_int 8)
9255             (const_int 8))
9256           (zero_extend:SI
9257             (match_operand:QI 2 "general_operand" "Qm"))))
9258    (clobber (reg:CC 17))]
9259   "!TARGET_64BIT
9260    && (!TARGET_PARTIAL_REG_STALL || optimize_size)"
9261   "xor{b}\t{%2, %h0|%h0, %2}"
9262   [(set_attr "type" "alu")
9263    (set_attr "length_immediate" "0")
9264    (set_attr "mode" "QI")])
9266 (define_insn "*xorqi_ext_1_rex64"
9267   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9268                          (const_int 8)
9269                          (const_int 8))
9270         (xor:SI 
9271           (zero_extract:SI
9272             (match_operand 1 "ext_register_operand" "0")
9273             (const_int 8)
9274             (const_int 8))
9275           (zero_extend:SI
9276             (match_operand 2 "ext_register_operand" "Q"))))
9277    (clobber (reg:CC 17))]
9278   "TARGET_64BIT
9279    && (!TARGET_PARTIAL_REG_STALL || optimize_size)"
9280   "xor{b}\t{%2, %h0|%h0, %2}"
9281   [(set_attr "type" "alu")
9282    (set_attr "length_immediate" "0")
9283    (set_attr "mode" "QI")])
9285 (define_insn "*xorqi_ext_2"
9286   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9287                          (const_int 8)
9288                          (const_int 8))
9289         (xor:SI 
9290           (zero_extract:SI (match_operand 1 "ext_register_operand" "0")
9291                            (const_int 8)
9292                            (const_int 8))
9293           (zero_extract:SI (match_operand 2 "ext_register_operand" "Q")
9294                            (const_int 8)
9295                            (const_int 8))))
9296    (clobber (reg:CC 17))]
9297   "(!TARGET_PARTIAL_REG_STALL || optimize_size)"
9298   "xor{b}\t{%h2, %h0|%h0, %h2}"
9299   [(set_attr "type" "alu")
9300    (set_attr "length_immediate" "0")
9301    (set_attr "mode" "QI")])
9303 (define_insn "*xorqi_cc_1"
9304   [(set (reg 17)
9305         (compare
9306           (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0")
9307                   (match_operand:QI 2 "general_operand" "qim,qi"))
9308           (const_int 0)))
9309    (set (match_operand:QI 0 "nonimmediate_operand" "=q,qm")
9310         (xor:QI (match_dup 1) (match_dup 2)))]
9311   "ix86_match_ccmode (insn, CCNOmode)
9312    && ix86_binary_operator_ok (XOR, QImode, operands)"
9313   "xor{b}\t{%2, %0|%0, %2}"
9314   [(set_attr "type" "alu")
9315    (set_attr "mode" "QI")])
9317 (define_insn "*xorqi_2_slp"
9318   [(set (reg 17)
9319         (compare (xor:QI (match_operand:QI 0 "nonimmediate_operand" "+q,qm")
9320                          (match_operand:QI 1 "general_operand" "qim,qi"))
9321                  (const_int 0)))
9322    (set (strict_low_part (match_dup 0))
9323         (xor:QI (match_dup 0) (match_dup 1)))]
9324   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
9325    && ix86_match_ccmode (insn, CCNOmode)
9326    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
9327   "xor{b}\t{%1, %0|%0, %1}"
9328   [(set_attr "type" "alu1")
9329    (set_attr "mode" "QI")])
9331 (define_insn "*xorqi_cc_2"
9332   [(set (reg 17)
9333         (compare
9334           (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
9335                   (match_operand:QI 2 "general_operand" "qim"))
9336           (const_int 0)))
9337    (clobber (match_scratch:QI 0 "=q"))]
9338   "ix86_match_ccmode (insn, CCNOmode)
9339    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
9340   "xor{b}\t{%2, %0|%0, %2}"
9341   [(set_attr "type" "alu")
9342    (set_attr "mode" "QI")])
9344 (define_insn "*xorqi_cc_ext_1"
9345   [(set (reg 17)
9346         (compare
9347           (xor:SI
9348             (zero_extract:SI
9349               (match_operand 1 "ext_register_operand" "0")
9350               (const_int 8)
9351               (const_int 8))
9352             (match_operand:QI 2 "general_operand" "qmn"))
9353           (const_int 0)))
9354    (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=q")
9355                          (const_int 8)
9356                          (const_int 8))
9357         (xor:SI 
9358           (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9359           (match_dup 2)))]
9360   "!TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
9361   "xor{b}\t{%2, %h0|%h0, %2}"
9362   [(set_attr "type" "alu")
9363    (set_attr "mode" "QI")])
9365 (define_insn "*xorqi_cc_ext_1_rex64"
9366   [(set (reg 17)
9367         (compare
9368           (xor:SI
9369             (zero_extract:SI
9370               (match_operand 1 "ext_register_operand" "0")
9371               (const_int 8)
9372               (const_int 8))
9373             (match_operand:QI 2 "nonmemory_operand" "Qn"))
9374           (const_int 0)))
9375    (set (zero_extract:SI (match_operand 0 "ext_register_operand" "=Q")
9376                          (const_int 8)
9377                          (const_int 8))
9378         (xor:SI 
9379           (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9380           (match_dup 2)))]
9381   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
9382   "xor{b}\t{%2, %h0|%h0, %2}"
9383   [(set_attr "type" "alu")
9384    (set_attr "mode" "QI")])
9386 (define_expand "xorqi_cc_ext_1"
9387   [(parallel [
9388      (set (reg:CCNO 17)
9389           (compare:CCNO
9390             (xor:SI
9391               (zero_extract:SI
9392                 (match_operand 1 "ext_register_operand" "")
9393                 (const_int 8)
9394                 (const_int 8))
9395               (match_operand:QI 2 "general_operand" ""))
9396             (const_int 0)))
9397      (set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
9398                            (const_int 8)
9399                            (const_int 8))
9400           (xor:SI 
9401             (zero_extract:SI (match_dup 1) (const_int 8) (const_int 8))
9402             (match_dup 2)))])]
9403   ""
9404   "")
9406 (define_split
9407   [(set (match_operand 0 "register_operand" "")
9408         (xor (match_operand 1 "register_operand" "")
9409              (match_operand 2 "const_int_operand" "")))
9410    (clobber (reg:CC 17))]
9411    "reload_completed
9412     && QI_REG_P (operands[0])
9413     && (!TARGET_PARTIAL_REG_STALL || optimize_size)
9414     && !(INTVAL (operands[2]) & ~(255 << 8))
9415     && GET_MODE (operands[0]) != QImode"
9416   [(parallel [(set (zero_extract:SI (match_dup 0) (const_int 8) (const_int 8))
9417                    (xor:SI (zero_extract:SI (match_dup 1)
9418                                             (const_int 8) (const_int 8))
9419                            (match_dup 2)))
9420               (clobber (reg:CC 17))])]
9421   "operands[0] = gen_lowpart (SImode, operands[0]);
9422    operands[1] = gen_lowpart (SImode, operands[1]);
9423    operands[2] = gen_int_mode ((INTVAL (operands[2]) >> 8) & 0xff, SImode);")
9425 ;; Since XOR can be encoded with sign extended immediate, this is only
9426 ;; profitable when 7th bit is set.
9427 (define_split
9428   [(set (match_operand 0 "register_operand" "")
9429         (xor (match_operand 1 "general_operand" "")
9430              (match_operand 2 "const_int_operand" "")))
9431    (clobber (reg:CC 17))]
9432    "reload_completed
9433     && ANY_QI_REG_P (operands[0])
9434     && (!TARGET_PARTIAL_REG_STALL || optimize_size)
9435     && !(INTVAL (operands[2]) & ~255)
9436     && (INTVAL (operands[2]) & 128)
9437     && GET_MODE (operands[0]) != QImode"
9438   [(parallel [(set (strict_low_part (match_dup 0))
9439                    (xor:QI (match_dup 1)
9440                            (match_dup 2)))
9441               (clobber (reg:CC 17))])]
9442   "operands[0] = gen_lowpart (QImode, operands[0]);
9443    operands[1] = gen_lowpart (QImode, operands[1]);
9444    operands[2] = gen_lowpart (QImode, operands[2]);")
9446 ;; Negation instructions
9448 (define_expand "negdi2"
9449   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
9450                    (neg:DI (match_operand:DI 1 "nonimmediate_operand" "")))
9451               (clobber (reg:CC 17))])]
9452   ""
9453   "ix86_expand_unary_operator (NEG, DImode, operands); DONE;")
9455 (define_insn "*negdi2_1"
9456   [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
9457         (neg:DI (match_operand:DI 1 "general_operand" "0")))
9458    (clobber (reg:CC 17))]
9459   "!TARGET_64BIT
9460    && ix86_unary_operator_ok (NEG, DImode, operands)"
9461   "#")
9463 (define_split
9464   [(set (match_operand:DI 0 "nonimmediate_operand" "")
9465         (neg:DI (match_operand:DI 1 "general_operand" "")))
9466    (clobber (reg:CC 17))]
9467   "!TARGET_64BIT && reload_completed"
9468   [(parallel
9469     [(set (reg:CCZ 17)
9470           (compare:CCZ (neg:SI (match_dup 2)) (const_int 0)))
9471      (set (match_dup 0) (neg:SI (match_dup 2)))])
9472    (parallel
9473     [(set (match_dup 1)
9474           (plus:SI (plus:SI (ltu:SI (reg:CC 17) (const_int 0))
9475                             (match_dup 3))
9476                    (const_int 0)))
9477      (clobber (reg:CC 17))])
9478    (parallel
9479     [(set (match_dup 1)
9480           (neg:SI (match_dup 1)))
9481      (clobber (reg:CC 17))])]
9482   "split_di (operands+1, 1, operands+2, operands+3);
9483    split_di (operands+0, 1, operands+0, operands+1);")
9485 (define_insn "*negdi2_1_rex64"
9486   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
9487         (neg:DI (match_operand:DI 1 "nonimmediate_operand" "0")))
9488    (clobber (reg:CC 17))]
9489   "TARGET_64BIT && ix86_unary_operator_ok (NEG, DImode, operands)"
9490   "neg{q}\t%0"
9491   [(set_attr "type" "negnot")
9492    (set_attr "mode" "DI")])
9494 ;; The problem with neg is that it does not perform (compare x 0),
9495 ;; it really performs (compare 0 x), which leaves us with the zero
9496 ;; flag being the only useful item.
9498 (define_insn "*negdi2_cmpz_rex64"
9499   [(set (reg:CCZ 17)
9500         (compare:CCZ (neg:DI (match_operand:DI 1 "nonimmediate_operand" "0"))
9501                      (const_int 0)))
9502    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
9503         (neg:DI (match_dup 1)))]
9504   "TARGET_64BIT && ix86_unary_operator_ok (NEG, DImode, operands)"
9505   "neg{q}\t%0"
9506   [(set_attr "type" "negnot")
9507    (set_attr "mode" "DI")])
9510 (define_expand "negsi2"
9511   [(parallel [(set (match_operand:SI 0 "nonimmediate_operand" "")
9512                    (neg:SI (match_operand:SI 1 "nonimmediate_operand" "")))
9513               (clobber (reg:CC 17))])]
9514   ""
9515   "ix86_expand_unary_operator (NEG, SImode, operands); DONE;")
9517 (define_insn "*negsi2_1"
9518   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
9519         (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0")))
9520    (clobber (reg:CC 17))]
9521   "ix86_unary_operator_ok (NEG, SImode, operands)"
9522   "neg{l}\t%0"
9523   [(set_attr "type" "negnot")
9524    (set_attr "mode" "SI")])
9526 ;; Combine is quite creative about this pattern.
9527 (define_insn "*negsi2_1_zext"
9528   [(set (match_operand:DI 0 "register_operand" "=r")
9529         (lshiftrt:DI (neg:DI (ashift:DI (match_operand:DI 1 "register_operand" "0")
9530                                         (const_int 32)))
9531                      (const_int 32)))
9532    (clobber (reg:CC 17))]
9533   "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
9534   "neg{l}\t%k0"
9535   [(set_attr "type" "negnot")
9536    (set_attr "mode" "SI")])
9538 ;; The problem with neg is that it does not perform (compare x 0),
9539 ;; it really performs (compare 0 x), which leaves us with the zero
9540 ;; flag being the only useful item.
9542 (define_insn "*negsi2_cmpz"
9543   [(set (reg:CCZ 17)
9544         (compare:CCZ (neg:SI (match_operand:SI 1 "nonimmediate_operand" "0"))
9545                      (const_int 0)))
9546    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
9547         (neg:SI (match_dup 1)))]
9548   "ix86_unary_operator_ok (NEG, SImode, operands)"
9549   "neg{l}\t%0"
9550   [(set_attr "type" "negnot")
9551    (set_attr "mode" "SI")])
9553 (define_insn "*negsi2_cmpz_zext"
9554   [(set (reg:CCZ 17)
9555         (compare:CCZ (lshiftrt:DI
9556                        (neg:DI (ashift:DI
9557                                  (match_operand:DI 1 "register_operand" "0")
9558                                  (const_int 32)))
9559                        (const_int 32))
9560                      (const_int 0)))
9561    (set (match_operand:DI 0 "register_operand" "=r")
9562         (lshiftrt:DI (neg:DI (ashift:DI (match_dup 1)
9563                                         (const_int 32)))
9564                      (const_int 32)))]
9565   "TARGET_64BIT && ix86_unary_operator_ok (NEG, SImode, operands)"
9566   "neg{l}\t%k0"
9567   [(set_attr "type" "negnot")
9568    (set_attr "mode" "SI")])
9570 (define_expand "neghi2"
9571   [(parallel [(set (match_operand:HI 0 "nonimmediate_operand" "")
9572                    (neg:HI (match_operand:HI 1 "nonimmediate_operand" "")))
9573               (clobber (reg:CC 17))])]
9574   "TARGET_HIMODE_MATH"
9575   "ix86_expand_unary_operator (NEG, HImode, operands); DONE;")
9577 (define_insn "*neghi2_1"
9578   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
9579         (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0")))
9580    (clobber (reg:CC 17))]
9581   "ix86_unary_operator_ok (NEG, HImode, operands)"
9582   "neg{w}\t%0"
9583   [(set_attr "type" "negnot")
9584    (set_attr "mode" "HI")])
9586 (define_insn "*neghi2_cmpz"
9587   [(set (reg:CCZ 17)
9588         (compare:CCZ (neg:HI (match_operand:HI 1 "nonimmediate_operand" "0"))
9589                      (const_int 0)))
9590    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
9591         (neg:HI (match_dup 1)))]
9592   "ix86_unary_operator_ok (NEG, HImode, operands)"
9593   "neg{w}\t%0"
9594   [(set_attr "type" "negnot")
9595    (set_attr "mode" "HI")])
9597 (define_expand "negqi2"
9598   [(parallel [(set (match_operand:QI 0 "nonimmediate_operand" "")
9599                    (neg:QI (match_operand:QI 1 "nonimmediate_operand" "")))
9600               (clobber (reg:CC 17))])]
9601   "TARGET_QIMODE_MATH"
9602   "ix86_expand_unary_operator (NEG, QImode, operands); DONE;")
9604 (define_insn "*negqi2_1"
9605   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
9606         (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0")))
9607    (clobber (reg:CC 17))]
9608   "ix86_unary_operator_ok (NEG, QImode, operands)"
9609   "neg{b}\t%0"
9610   [(set_attr "type" "negnot")
9611    (set_attr "mode" "QI")])
9613 (define_insn "*negqi2_cmpz"
9614   [(set (reg:CCZ 17)
9615         (compare:CCZ (neg:QI (match_operand:QI 1 "nonimmediate_operand" "0"))
9616                      (const_int 0)))
9617    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
9618         (neg:QI (match_dup 1)))]
9619   "ix86_unary_operator_ok (NEG, QImode, operands)"
9620   "neg{b}\t%0"
9621   [(set_attr "type" "negnot")
9622    (set_attr "mode" "QI")])
9624 ;; Changing of sign for FP values is doable using integer unit too.
9626 (define_expand "negsf2"
9627   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
9628                    (neg:SF (match_operand:SF 1 "nonimmediate_operand" "")))
9629               (clobber (reg:CC 17))])]
9630   "TARGET_80387"
9631   "if (TARGET_SSE)
9632      {
9633        /* In case operand is in memory,  we will not use SSE.  */
9634        if (memory_operand (operands[0], VOIDmode)
9635            && rtx_equal_p (operands[0], operands[1]))
9636          emit_insn (gen_negsf2_memory (operands[0], operands[1]));
9637        else
9638         {
9639           /* Using SSE is tricky, since we need bitwise negation of -0
9640              in register.  */
9641           rtx reg = gen_reg_rtx (SFmode);
9642           rtx dest = operands[0];
9643           rtx imm = gen_lowpart (SFmode, gen_int_mode (0x80000000, SImode));
9645           operands[1] = force_reg (SFmode, operands[1]);
9646           operands[0] = force_reg (SFmode, operands[0]);
9647           reg = force_reg (V4SFmode,
9648                            gen_rtx_CONST_VECTOR (V4SFmode,
9649                              gen_rtvec (4, imm, CONST0_RTX (SFmode),
9650                                         CONST0_RTX (SFmode),
9651                                         CONST0_RTX (SFmode))));
9652           emit_insn (gen_negsf2_ifs (operands[0], operands[1], reg));
9653           if (dest != operands[0])
9654             emit_move_insn (dest, operands[0]);
9655         }
9656        DONE;
9657      }
9658    ix86_expand_unary_operator (NEG, SFmode, operands); DONE;")
9660 (define_insn "negsf2_memory"
9661   [(set (match_operand:SF 0 "memory_operand" "=m")
9662         (neg:SF (match_operand:SF 1 "memory_operand" "0")))
9663    (clobber (reg:CC 17))]
9664   "ix86_unary_operator_ok (NEG, SFmode, operands)"
9665   "#")
9667 (define_insn "negsf2_ifs"
9668   [(set (match_operand:SF 0 "nonimmediate_operand" "=x#fr,x#fr,f#xr,rm#xf")
9669         (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,x#fr,0,0")))
9670    (use (match_operand:V4SF 2 "nonimmediate_operand" "xm,0,xm*r,xm*r"))
9671    (clobber (reg:CC 17))]
9672   "TARGET_SSE
9673    && (reload_in_progress || reload_completed
9674        || (register_operand (operands[0], VOIDmode)
9675            && register_operand (operands[1], VOIDmode)))"
9676   "#")
9678 (define_split
9679   [(set (match_operand:SF 0 "memory_operand" "")
9680         (neg:SF (match_operand:SF 1 "memory_operand" "")))
9681    (use (match_operand:SF 2 "" ""))
9682    (clobber (reg:CC 17))]
9683   ""
9684   [(parallel [(set (match_dup 0)
9685                    (neg:SF (match_dup 1)))
9686               (clobber (reg:CC 17))])])
9688 (define_split
9689   [(set (match_operand:SF 0 "register_operand" "")
9690         (neg:SF (match_operand:SF 1 "register_operand" "")))
9691    (use (match_operand:V4SF 2 "" ""))
9692    (clobber (reg:CC 17))]
9693   "reload_completed && !SSE_REG_P (operands[0])"
9694   [(parallel [(set (match_dup 0)
9695                    (neg:SF (match_dup 1)))
9696               (clobber (reg:CC 17))])])
9698 (define_split
9699   [(set (match_operand:SF 0 "register_operand" "")
9700         (neg:SF (match_operand:SF 1 "register_operand" "")))
9701    (use (match_operand:V4SF 2 "nonimmediate_operand" ""))
9702    (clobber (reg:CC 17))]
9703   "reload_completed && SSE_REG_P (operands[0])"
9704   [(set (subreg:TI (match_dup 0) 0)
9705         (xor:TI (match_dup 1)
9706                 (match_dup 2)))]
9708   operands[1] = simplify_gen_subreg (TImode, operands[1], SFmode, 0);
9709   operands[2] = simplify_gen_subreg (TImode, operands[2], V4SFmode, 0);
9710   if (operands_match_p (operands[0], operands[2]))
9711     {
9712       rtx tmp;
9713       tmp = operands[1];
9714       operands[1] = operands[2];
9715       operands[2] = tmp;
9716     }
9720 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9721 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9722 ;; to itself.
9723 (define_insn "*negsf2_if"
9724   [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f")
9725         (neg:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")))
9726    (clobber (reg:CC 17))]
9727   "TARGET_80387 && !TARGET_SSE
9728    && ix86_unary_operator_ok (NEG, SFmode, operands)"
9729   "#")
9731 (define_split
9732   [(set (match_operand:SF 0 "fp_register_operand" "")
9733         (neg:SF (match_operand:SF 1 "register_operand" "")))
9734    (clobber (reg:CC 17))]
9735   "TARGET_80387 && reload_completed"
9736   [(set (match_dup 0)
9737         (neg:SF (match_dup 1)))]
9738   "")
9740 (define_split
9741   [(set (match_operand:SF 0 "register_and_not_fp_reg_operand" "")
9742         (neg:SF (match_operand:SF 1 "register_operand" "")))
9743    (clobber (reg:CC 17))]
9744   "TARGET_80387 && reload_completed"
9745   [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
9746               (clobber (reg:CC 17))])]
9747   "operands[1] = gen_int_mode (0x80000000, SImode);
9748    operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
9750 (define_split
9751   [(set (match_operand 0 "memory_operand" "")
9752         (neg (match_operand 1 "memory_operand" "")))
9753    (clobber (reg:CC 17))]
9754   "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
9755   [(parallel [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
9756               (clobber (reg:CC 17))])]
9758   int size = GET_MODE_SIZE (GET_MODE (operands[1]));
9760   /* XFmode's size is 12, TFmode 16, but only 10 bytes are used.  */
9761   if (size >= 12)
9762     size = 10;
9763   operands[0] = adjust_address (operands[0], QImode, size - 1);
9764   operands[1] = gen_int_mode (0x80, QImode);
9767 (define_expand "negdf2"
9768   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
9769                    (neg:DF (match_operand:DF 1 "nonimmediate_operand" "")))
9770               (clobber (reg:CC 17))])]
9771   "TARGET_80387"
9772   "if (TARGET_SSE2)
9773      {
9774        /* In case operand is in memory,  we will not use SSE.  */
9775        if (memory_operand (operands[0], VOIDmode)
9776            && rtx_equal_p (operands[0], operands[1]))
9777          emit_insn (gen_negdf2_memory (operands[0], operands[1]));
9778        else
9779         {
9780           /* Using SSE is tricky, since we need bitwise negation of -0
9781              in register.  */
9782           rtx reg;
9783 #if HOST_BITS_PER_WIDE_INT >= 64
9784           rtx imm = gen_int_mode (((HOST_WIDE_INT)1) << 63, DImode);
9785 #else
9786           rtx imm = immed_double_const (0, 0x80000000, DImode);
9787 #endif
9788           rtx dest = operands[0];
9790           operands[1] = force_reg (DFmode, operands[1]);
9791           operands[0] = force_reg (DFmode, operands[0]);
9792           imm = gen_lowpart (DFmode, imm);
9793           reg = force_reg (V2DFmode,
9794                            gen_rtx_CONST_VECTOR (V2DFmode,
9795                              gen_rtvec (2, imm, CONST0_RTX (DFmode))));
9796           emit_insn (gen_negdf2_ifs (operands[0], operands[1], reg));
9797           if (dest != operands[0])
9798             emit_move_insn (dest, operands[0]);
9799         }
9800        DONE;
9801      }
9802    ix86_expand_unary_operator (NEG, DFmode, operands); DONE;")
9804 (define_insn "negdf2_memory"
9805   [(set (match_operand:DF 0 "memory_operand" "=m")
9806         (neg:DF (match_operand:DF 1 "memory_operand" "0")))
9807    (clobber (reg:CC 17))]
9808   "ix86_unary_operator_ok (NEG, DFmode, operands)"
9809   "#")
9811 (define_insn "negdf2_ifs"
9812   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,f#Yr,rm#Yf")
9813         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0,0")))
9814    (use (match_operand:V2DF 2 "nonimmediate_operand" "Ym,0,Ym*r,Ym*r"))
9815    (clobber (reg:CC 17))]
9816   "!TARGET_64BIT && TARGET_SSE2
9817    && (reload_in_progress || reload_completed
9818        || (register_operand (operands[0], VOIDmode)
9819            && register_operand (operands[1], VOIDmode)))"
9820   "#")
9822 (define_insn "*negdf2_ifs_rex64"
9823   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#f,Y#f,fm#Y")
9824         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0")))
9825    (use (match_operand:V2DF 2 "nonimmediate_operand" "Ym,0,Ym*r"))
9826    (clobber (reg:CC 17))]
9827   "TARGET_64BIT && TARGET_SSE2
9828    && (reload_in_progress || reload_completed
9829        || (register_operand (operands[0], VOIDmode)
9830            && register_operand (operands[1], VOIDmode)))"
9831   "#")
9833 (define_split
9834   [(set (match_operand:DF 0 "memory_operand" "")
9835         (neg:DF (match_operand:DF 1 "memory_operand" "")))
9836    (use (match_operand:V2DF 2 "" ""))
9837    (clobber (reg:CC 17))]
9838   ""
9839   [(parallel [(set (match_dup 0)
9840                    (neg:DF (match_dup 1)))
9841               (clobber (reg:CC 17))])])
9843 (define_split
9844   [(set (match_operand:DF 0 "register_operand" "")
9845         (neg:DF (match_operand:DF 1 "register_operand" "")))
9846    (use (match_operand:V2DF 2 "" ""))
9847    (clobber (reg:CC 17))]
9848   "reload_completed && !SSE_REG_P (operands[0])
9849    && (!TARGET_64BIT || FP_REG_P (operands[0]))"
9850   [(parallel [(set (match_dup 0)
9851                    (neg:DF (match_dup 1)))
9852               (clobber (reg:CC 17))])])
9854 (define_split
9855   [(set (match_operand:DF 0 "register_operand" "")
9856         (neg:DF (match_operand:DF 1 "register_operand" "")))
9857    (use (match_operand:V2DF 2 "" ""))
9858    (clobber (reg:CC 17))]
9859   "TARGET_64BIT && reload_completed && GENERAL_REG_P (operands[0])"
9860   [(parallel [(set (match_dup 0)
9861                    (xor:DI (match_dup 1) (match_dup 2)))
9862               (clobber (reg:CC 17))])]
9863    "operands[0] = gen_lowpart (DImode, operands[0]);
9864     operands[1] = gen_lowpart (DImode, operands[1]);
9865     operands[2] = gen_lowpart (DImode, operands[2]);")
9867 (define_split
9868   [(set (match_operand:DF 0 "register_operand" "")
9869         (neg:DF (match_operand:DF 1 "register_operand" "")))
9870    (use (match_operand:V2DF 2 "nonimmediate_operand" ""))
9871    (clobber (reg:CC 17))]
9872   "reload_completed && SSE_REG_P (operands[0])"
9873   [(set (subreg:TI (match_dup 0) 0)
9874         (xor:TI (match_dup 1)
9875                 (match_dup 2)))]
9877   operands[0] = simplify_gen_subreg (V2DFmode, operands[0], DFmode, 0);
9878   operands[1] = simplify_gen_subreg (TImode, operands[1], DFmode, 0);
9879   operands[2] = simplify_gen_subreg (TImode, operands[2], V2DFmode, 0);
9880   /* Avoid possible reformatting on the operands.  */
9881   if (TARGET_SSE_PARTIAL_REGS && !optimize_size)
9882     emit_insn (gen_sse2_unpcklpd (operands[0], operands[0], operands[0]));
9883   if (operands_match_p (operands[0], operands[2]))
9884     {
9885       rtx tmp;
9886       tmp = operands[1];
9887       operands[1] = operands[2];
9888       operands[2] = tmp;
9889     }
9892 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9893 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9894 ;; to itself.
9895 (define_insn "*negdf2_if"
9896   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f")
9897         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
9898    (clobber (reg:CC 17))]
9899   "!TARGET_64BIT && TARGET_80387
9900    && ix86_unary_operator_ok (NEG, DFmode, operands)"
9901   "#")
9903 ;; FIXME: We should to allow integer registers here.  Problem is that
9904 ;; we need another scratch register to get constant from.
9905 ;; Forcing constant to mem if no register available in peep2 should be
9906 ;; safe even for PIC mode, because of RIP relative addressing.
9907 (define_insn "*negdf2_if_rex64"
9908   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,mf")
9909         (neg:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
9910    (clobber (reg:CC 17))]
9911   "TARGET_64BIT && TARGET_80387
9912    && ix86_unary_operator_ok (NEG, DFmode, operands)"
9913   "#")
9915 (define_split
9916   [(set (match_operand:DF 0 "fp_register_operand" "")
9917         (neg:DF (match_operand:DF 1 "register_operand" "")))
9918    (clobber (reg:CC 17))]
9919   "TARGET_80387 && reload_completed"
9920   [(set (match_dup 0)
9921         (neg:DF (match_dup 1)))]
9922   "")
9924 (define_split
9925   [(set (match_operand:DF 0 "register_and_not_fp_reg_operand" "")
9926         (neg:DF (match_operand:DF 1 "register_operand" "")))
9927    (clobber (reg:CC 17))]
9928   "!TARGET_64BIT && TARGET_80387 && reload_completed"
9929   [(parallel [(set (match_dup 3) (xor:SI (match_dup 3) (match_dup 4)))
9930               (clobber (reg:CC 17))])]
9931   "operands[4] = gen_int_mode (0x80000000, SImode);
9932    split_di (operands+0, 1, operands+2, operands+3);")
9934 (define_expand "negxf2"
9935   [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "")
9936                    (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))
9937               (clobber (reg:CC 17))])]
9938   "!TARGET_64BIT && TARGET_80387"
9939   "ix86_expand_unary_operator (NEG, XFmode, operands); DONE;")
9941 (define_expand "negtf2"
9942   [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
9943                    (neg:TF (match_operand:TF 1 "nonimmediate_operand" "")))
9944               (clobber (reg:CC 17))])]
9945   "TARGET_80387"
9946   "ix86_expand_unary_operator (NEG, TFmode, operands); DONE;")
9948 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9949 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9950 ;; to itself.
9951 (define_insn "*negxf2_if"
9952   [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f")
9953         (neg:XF (match_operand:XF 1 "nonimmediate_operand" "0,0")))
9954    (clobber (reg:CC 17))]
9955   "!TARGET_64BIT && TARGET_80387
9956    && ix86_unary_operator_ok (NEG, XFmode, operands)"
9957   "#")
9959 (define_split
9960   [(set (match_operand:XF 0 "fp_register_operand" "")
9961         (neg:XF (match_operand:XF 1 "register_operand" "")))
9962    (clobber (reg:CC 17))]
9963   "TARGET_80387 && reload_completed"
9964   [(set (match_dup 0)
9965         (neg:XF (match_dup 1)))]
9966   "")
9968 (define_split
9969   [(set (match_operand:XF 0 "register_and_not_fp_reg_operand" "")
9970         (neg:XF (match_operand:XF 1 "register_operand" "")))
9971    (clobber (reg:CC 17))]
9972   "TARGET_80387 && reload_completed"
9973   [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
9974               (clobber (reg:CC 17))])]
9975   "operands[1] = GEN_INT (0x8000);
9976    operands[0] = gen_rtx_REG (SImode,
9977                               true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
9979 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
9980 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
9981 ;; to itself.
9982 (define_insn "*negtf2_if"
9983   [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f")
9984         (neg:TF (match_operand:TF 1 "nonimmediate_operand" "0,0")))
9985    (clobber (reg:CC 17))]
9986   "TARGET_80387 && ix86_unary_operator_ok (NEG, TFmode, operands)"
9987   "#")
9989 (define_split
9990   [(set (match_operand:TF 0 "fp_register_operand" "")
9991         (neg:TF (match_operand:TF 1 "register_operand" "")))
9992    (clobber (reg:CC 17))]
9993   "TARGET_80387 && reload_completed"
9994   [(set (match_dup 0)
9995         (neg:TF (match_dup 1)))]
9996   "")
9998 (define_split
9999   [(set (match_operand:TF 0 "register_and_not_fp_reg_operand" "")
10000         (neg:TF (match_operand:TF 1 "register_operand" "")))
10001    (clobber (reg:CC 17))]
10002   "TARGET_80387 && reload_completed"
10003   [(parallel [(set (match_dup 0) (xor:SI (match_dup 0) (match_dup 1)))
10004               (clobber (reg:CC 17))])]
10005   "operands[1] = GEN_INT (0x8000);
10006    operands[0] = gen_rtx_REG (SImode,
10007                               true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
10009 ;; Conditionalize these after reload. If they matches before reload, we 
10010 ;; lose the clobber and ability to use integer instructions.
10012 (define_insn "*negsf2_1"
10013   [(set (match_operand:SF 0 "register_operand" "=f")
10014         (neg:SF (match_operand:SF 1 "register_operand" "0")))]
10015   "TARGET_80387 && reload_completed"
10016   "fchs"
10017   [(set_attr "type" "fsgn")
10018    (set_attr "mode" "SF")
10019    (set_attr "ppro_uops" "few")])
10021 (define_insn "*negdf2_1"
10022   [(set (match_operand:DF 0 "register_operand" "=f")
10023         (neg:DF (match_operand:DF 1 "register_operand" "0")))]
10024   "TARGET_80387 && reload_completed"
10025   "fchs"
10026   [(set_attr "type" "fsgn")
10027    (set_attr "mode" "DF")
10028    (set_attr "ppro_uops" "few")])
10030 (define_insn "*negextendsfdf2"
10031   [(set (match_operand:DF 0 "register_operand" "=f")
10032         (neg:DF (float_extend:DF
10033                   (match_operand:SF 1 "register_operand" "0"))))]
10034   "TARGET_80387"
10035   "fchs"
10036   [(set_attr "type" "fsgn")
10037    (set_attr "mode" "DF")
10038    (set_attr "ppro_uops" "few")])
10040 (define_insn "*negxf2_1"
10041   [(set (match_operand:XF 0 "register_operand" "=f")
10042         (neg:XF (match_operand:XF 1 "register_operand" "0")))]
10043   "!TARGET_64BIT && TARGET_80387 && reload_completed"
10044   "fchs"
10045   [(set_attr "type" "fsgn")
10046    (set_attr "mode" "XF")
10047    (set_attr "ppro_uops" "few")])
10049 (define_insn "*negextenddfxf2"
10050   [(set (match_operand:XF 0 "register_operand" "=f")
10051         (neg:XF (float_extend:XF
10052                   (match_operand:DF 1 "register_operand" "0"))))]
10053   "!TARGET_64BIT && TARGET_80387"
10054   "fchs"
10055   [(set_attr "type" "fsgn")
10056    (set_attr "mode" "XF")
10057    (set_attr "ppro_uops" "few")])
10059 (define_insn "*negextendsfxf2"
10060   [(set (match_operand:XF 0 "register_operand" "=f")
10061         (neg:XF (float_extend:XF
10062                   (match_operand:SF 1 "register_operand" "0"))))]
10063   "!TARGET_64BIT && TARGET_80387"
10064   "fchs"
10065   [(set_attr "type" "fsgn")
10066    (set_attr "mode" "XF")
10067    (set_attr "ppro_uops" "few")])
10069 (define_insn "*negtf2_1"
10070   [(set (match_operand:TF 0 "register_operand" "=f")
10071         (neg:TF (match_operand:TF 1 "register_operand" "0")))]
10072   "TARGET_80387 && reload_completed"
10073   "fchs"
10074   [(set_attr "type" "fsgn")
10075    (set_attr "mode" "XF")
10076    (set_attr "ppro_uops" "few")])
10078 (define_insn "*negextenddftf2"
10079   [(set (match_operand:TF 0 "register_operand" "=f")
10080         (neg:TF (float_extend:TF
10081                   (match_operand:DF 1 "register_operand" "0"))))]
10082   "TARGET_80387"
10083   "fchs"
10084   [(set_attr "type" "fsgn")
10085    (set_attr "mode" "XF")
10086    (set_attr "ppro_uops" "few")])
10088 (define_insn "*negextendsftf2"
10089   [(set (match_operand:TF 0 "register_operand" "=f")
10090         (neg:TF (float_extend:TF
10091                   (match_operand:SF 1 "register_operand" "0"))))]
10092   "TARGET_80387"
10093   "fchs"
10094   [(set_attr "type" "fsgn")
10095    (set_attr "mode" "XF")
10096    (set_attr "ppro_uops" "few")])
10098 ;; Absolute value instructions
10100 (define_expand "abssf2"
10101   [(parallel [(set (match_operand:SF 0 "nonimmediate_operand" "")
10102                    (neg:SF (match_operand:SF 1 "nonimmediate_operand" "")))
10103               (clobber (reg:CC 17))])]
10104   "TARGET_80387"
10105   "if (TARGET_SSE)
10106      {
10107        /* In case operand is in memory,  we will not use SSE.  */
10108        if (memory_operand (operands[0], VOIDmode)
10109            && rtx_equal_p (operands[0], operands[1]))
10110          emit_insn (gen_abssf2_memory (operands[0], operands[1]));
10111        else
10112         {
10113           /* Using SSE is tricky, since we need bitwise negation of -0
10114              in register.  */
10115           rtx reg = gen_reg_rtx (V4SFmode);
10116           rtx dest = operands[0];
10117           rtx imm;
10119           operands[1] = force_reg (SFmode, operands[1]);
10120           operands[0] = force_reg (SFmode, operands[0]);
10121           imm = gen_lowpart (SFmode, gen_int_mode(~0x80000000, SImode));
10122           reg = force_reg (V4SFmode,
10123                            gen_rtx_CONST_VECTOR (V4SFmode,
10124                            gen_rtvec (4, imm, CONST0_RTX (SFmode),
10125                                       CONST0_RTX (SFmode),
10126                                       CONST0_RTX (SFmode))));
10127           emit_insn (gen_abssf2_ifs (operands[0], operands[1], reg));
10128           if (dest != operands[0])
10129             emit_move_insn (dest, operands[0]);
10130         }
10131        DONE;
10132      }
10133    ix86_expand_unary_operator (ABS, SFmode, operands); DONE;")
10135 (define_insn "abssf2_memory"
10136   [(set (match_operand:SF 0 "memory_operand" "=m")
10137         (abs:SF (match_operand:SF 1 "memory_operand" "0")))
10138    (clobber (reg:CC 17))]
10139   "ix86_unary_operator_ok (ABS, SFmode, operands)"
10140   "#")
10142 (define_insn "abssf2_ifs"
10143   [(set (match_operand:SF 0 "nonimmediate_operand" "=x#fr,x#fr,f#xr,rm#xf")
10144         (abs:SF (match_operand:SF 1 "nonimmediate_operand" "0,x#fr,0,0")))
10145    (use (match_operand:V4SF 2 "nonimmediate_operand" "xm,0,xm*r,xm*r"))
10146    (clobber (reg:CC 17))]
10147   "TARGET_SSE
10148    && (reload_in_progress || reload_completed
10149        || (register_operand (operands[0], VOIDmode)
10150             && register_operand (operands[1], VOIDmode)))"
10151   "#")
10153 (define_split
10154   [(set (match_operand:SF 0 "memory_operand" "")
10155         (abs:SF (match_operand:SF 1 "memory_operand" "")))
10156    (use (match_operand:V4SF 2 "" ""))
10157    (clobber (reg:CC 17))]
10158   ""
10159   [(parallel [(set (match_dup 0)
10160                    (abs:SF (match_dup 1)))
10161               (clobber (reg:CC 17))])])
10163 (define_split
10164   [(set (match_operand:SF 0 "register_operand" "")
10165         (abs:SF (match_operand:SF 1 "register_operand" "")))
10166    (use (match_operand:V4SF 2 "" ""))
10167    (clobber (reg:CC 17))]
10168   "reload_completed && !SSE_REG_P (operands[0])"
10169   [(parallel [(set (match_dup 0)
10170                    (abs:SF (match_dup 1)))
10171               (clobber (reg:CC 17))])])
10173 (define_split
10174   [(set (match_operand:SF 0 "register_operand" "")
10175         (abs:SF (match_operand:SF 1 "register_operand" "")))
10176    (use (match_operand:V4SF 2 "nonimmediate_operand" ""))
10177    (clobber (reg:CC 17))]
10178   "reload_completed && SSE_REG_P (operands[0])"
10179   [(set (subreg:TI (match_dup 0) 0)
10180         (and:TI (match_dup 1)
10181                 (match_dup 2)))]
10183   operands[1] = simplify_gen_subreg (TImode, operands[1], SFmode, 0);
10184   operands[2] = simplify_gen_subreg (TImode, operands[2], V4SFmode, 0);
10185   if (operands_match_p (operands[0], operands[2]))
10186     {
10187       rtx tmp;
10188       tmp = operands[1];
10189       operands[1] = operands[2];
10190       operands[2] = tmp;
10191     }
10194 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10195 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10196 ;; to itself.
10197 (define_insn "*abssf2_if"
10198   [(set (match_operand:SF 0 "nonimmediate_operand" "=f#r,rm#f")
10199         (abs:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")))
10200    (clobber (reg:CC 17))]
10201   "TARGET_80387 && ix86_unary_operator_ok (ABS, SFmode, operands) && !TARGET_SSE"
10202   "#")
10204 (define_split
10205   [(set (match_operand:SF 0 "fp_register_operand" "")
10206         (abs:SF (match_operand:SF 1 "register_operand" "")))
10207    (clobber (reg:CC 17))]
10208   "TARGET_80387"
10209   [(set (match_dup 0)
10210         (abs:SF (match_dup 1)))]
10211   "")
10213 (define_split
10214   [(set (match_operand:SF 0 "register_and_not_fp_reg_operand" "")
10215         (abs:SF (match_operand:SF 1 "register_operand" "")))
10216    (clobber (reg:CC 17))]
10217   "TARGET_80387 && reload_completed"
10218   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
10219               (clobber (reg:CC 17))])]
10220   "operands[1] = gen_int_mode (~0x80000000, SImode);
10221    operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
10223 (define_split
10224   [(set (match_operand 0 "memory_operand" "")
10225         (abs (match_operand 1 "memory_operand" "")))
10226    (clobber (reg:CC 17))]
10227   "TARGET_80387 && reload_completed && FLOAT_MODE_P (GET_MODE (operands[0]))"
10228   [(parallel [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
10229               (clobber (reg:CC 17))])]
10231   int size = GET_MODE_SIZE (GET_MODE (operands[1]));
10233   /* XFmode's size is 12, TFmode 16, but only 10 bytes are used.  */
10234   if (size >= 12)
10235     size = 10;
10236   operands[0] = adjust_address (operands[0], QImode, size - 1);
10237   operands[1] = gen_int_mode (~0x80, QImode);
10240 (define_expand "absdf2"
10241   [(parallel [(set (match_operand:DF 0 "nonimmediate_operand" "")
10242                    (neg:DF (match_operand:DF 1 "nonimmediate_operand" "")))
10243               (clobber (reg:CC 17))])]
10244   "TARGET_80387"
10245   "if (TARGET_SSE2)
10246      {
10247        /* In case operand is in memory,  we will not use SSE.  */
10248        if (memory_operand (operands[0], VOIDmode)
10249            && rtx_equal_p (operands[0], operands[1]))
10250          emit_insn (gen_absdf2_memory (operands[0], operands[1]));
10251        else
10252         {
10253           /* Using SSE is tricky, since we need bitwise negation of -0
10254              in register.  */
10255           rtx reg = gen_reg_rtx (V2DFmode);
10256 #if HOST_BITS_PER_WIDE_INT >= 64
10257           rtx imm = gen_int_mode (~(((HOST_WIDE_INT)1) << 63), DImode);
10258 #else
10259           rtx imm = immed_double_const (~0, ~0x80000000, DImode);
10260 #endif
10261           rtx dest = operands[0];
10263           operands[1] = force_reg (DFmode, operands[1]);
10264           operands[0] = force_reg (DFmode, operands[0]);
10266           /* Produce LONG_DOUBLE with the proper immediate argument.  */
10267           imm = gen_lowpart (DFmode, imm);
10268           reg = force_reg (V2DFmode,
10269                            gen_rtx_CONST_VECTOR (V2DFmode,
10270                            gen_rtvec (2, imm, CONST0_RTX (DFmode))));
10271           emit_insn (gen_absdf2_ifs (operands[0], operands[1], reg));
10272           if (dest != operands[0])
10273             emit_move_insn (dest, operands[0]);
10274         }
10275        DONE;
10276      }
10277    ix86_expand_unary_operator (ABS, DFmode, operands); DONE;")
10279 (define_insn "absdf2_memory"
10280   [(set (match_operand:DF 0 "memory_operand" "=m")
10281         (abs:DF (match_operand:DF 1 "memory_operand" "0")))
10282    (clobber (reg:CC 17))]
10283   "ix86_unary_operator_ok (ABS, DFmode, operands)"
10284   "#")
10286 (define_insn "absdf2_ifs"
10287   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,mf#Yr,mr#Yf")
10288         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0,0")))
10289    (use (match_operand:V2DF 2 "nonimmediate_operand" "Ym,0,Ym*r,Ym*r"))
10290    (clobber (reg:CC 17))]
10291   "!TARGET_64BIT && TARGET_SSE2
10292    && (reload_in_progress || reload_completed
10293        || (register_operand (operands[0], VOIDmode)
10294            && register_operand (operands[1], VOIDmode)))"
10295   "#")
10297 (define_insn "*absdf2_ifs_rex64"
10298   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y#fr,Y#fr,mf#Yr")
10299         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,Y#fr,0")))
10300    (use (match_operand:V2DF 2 "nonimmediate_operand" "Ym,0,Ym*r"))
10301    (clobber (reg:CC 17))]
10302   "TARGET_64BIT && TARGET_SSE2
10303    && (reload_in_progress || reload_completed
10304        || (register_operand (operands[0], VOIDmode)
10305            && register_operand (operands[1], VOIDmode)))"
10306   "#")
10308 (define_split
10309   [(set (match_operand:DF 0 "memory_operand" "")
10310         (abs:DF (match_operand:DF 1 "memory_operand" "")))
10311    (use (match_operand:V2DF 2 "" ""))
10312    (clobber (reg:CC 17))]
10313   ""
10314   [(parallel [(set (match_dup 0)
10315                    (abs:DF (match_dup 1)))
10316               (clobber (reg:CC 17))])])
10318 (define_split
10319   [(set (match_operand:DF 0 "register_operand" "")
10320         (abs:DF (match_operand:DF 1 "register_operand" "")))
10321    (use (match_operand:V2DF 2 "" ""))
10322    (clobber (reg:CC 17))]
10323   "reload_completed && !SSE_REG_P (operands[0])"
10324   [(parallel [(set (match_dup 0)
10325                    (abs:DF (match_dup 1)))
10326               (clobber (reg:CC 17))])])
10328 (define_split
10329   [(set (match_operand:DF 0 "register_operand" "")
10330         (abs:DF (match_operand:DF 1 "register_operand" "")))
10331    (use (match_operand:V2DF 2 "nonimmediate_operand" ""))
10332    (clobber (reg:CC 17))]
10333   "reload_completed && SSE_REG_P (operands[0])"
10334   [(set (subreg:TI (match_dup 0) 0)
10335         (and:TI (match_dup 1)
10336                 (match_dup 2)))]
10338   operands[0] = simplify_gen_subreg (V2DFmode, operands[0], DFmode, 0);
10339   operands[1] = simplify_gen_subreg (TImode, operands[1], DFmode, 0);
10340   operands[2] = simplify_gen_subreg (TImode, operands[2], V2DFmode, 0);
10341   /* Avoid possible reformatting on the operands.  */
10342   if (TARGET_SSE_PARTIAL_REGS && !optimize_size)
10343     emit_insn (gen_sse2_unpcklpd (operands[0], operands[0], operands[0]));
10344   if (operands_match_p (operands[0], operands[2]))
10345     {
10346       rtx tmp;
10347       tmp = operands[1];
10348       operands[1] = operands[2];
10349       operands[2] = tmp;
10350     }
10354 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10355 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10356 ;; to itself.
10357 (define_insn "*absdf2_if"
10358   [(set (match_operand:DF 0 "nonimmediate_operand" "=f#r,rm#f")
10359         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
10360    (clobber (reg:CC 17))]
10361   "!TARGET_64BIT && TARGET_80387
10362    && ix86_unary_operator_ok (ABS, DFmode, operands)"
10363   "#")
10365 ;; FIXME: We should to allow integer registers here.  Problem is that
10366 ;; we need another scratch register to get constant from.
10367 ;; Forcing constant to mem if no register available in peep2 should be
10368 ;; safe even for PIC mode, because of RIP relative addressing.
10369 (define_insn "*absdf2_if_rex64"
10370   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,mf")
10371         (abs:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")))
10372    (clobber (reg:CC 17))]
10373   "TARGET_64BIT && TARGET_80387
10374    && ix86_unary_operator_ok (ABS, DFmode, operands)"
10375   "#")
10377 (define_split
10378   [(set (match_operand:DF 0 "fp_register_operand" "")
10379         (abs:DF (match_operand:DF 1 "register_operand" "")))
10380    (clobber (reg:CC 17))]
10381   "TARGET_80387 && reload_completed"
10382   [(set (match_dup 0)
10383         (abs:DF (match_dup 1)))]
10384   "")
10386 (define_split
10387   [(set (match_operand:DF 0 "register_and_not_fp_reg_operand" "")
10388         (abs:DF (match_operand:DF 1 "register_operand" "")))
10389    (clobber (reg:CC 17))]
10390   "!TARGET_64BIT && TARGET_80387 && reload_completed"
10391   [(parallel [(set (match_dup 3) (and:SI (match_dup 3) (match_dup 4)))
10392               (clobber (reg:CC 17))])]
10393   "operands[4] = gen_int_mode (~0x80000000, SImode);
10394    split_di (operands+0, 1, operands+2, operands+3);")
10396 (define_expand "absxf2"
10397   [(parallel [(set (match_operand:XF 0 "nonimmediate_operand" "")
10398                    (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))
10399               (clobber (reg:CC 17))])]
10400   "!TARGET_64BIT && TARGET_80387"
10401   "ix86_expand_unary_operator (ABS, XFmode, operands); DONE;")
10403 (define_expand "abstf2"
10404   [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
10405                    (neg:TF (match_operand:TF 1 "nonimmediate_operand" "")))
10406               (clobber (reg:CC 17))])]
10407   "TARGET_80387"
10408   "ix86_expand_unary_operator (ABS, TFmode, operands); DONE;")
10410 ;; Keep 'f' and 'r' in separate alternatives to avoid reload problems
10411 ;; because of secondary memory needed to reload from class FLOAT_INT_REGS
10412 ;; to itself.
10413 (define_insn "*absxf2_if"
10414   [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,rm#f")
10415         (abs:XF (match_operand:XF 1 "nonimmediate_operand" "0,0")))
10416    (clobber (reg:CC 17))]
10417   "!TARGET_64BIT && TARGET_80387
10418    && ix86_unary_operator_ok (ABS, XFmode, operands)"
10419   "#")
10421 (define_split
10422   [(set (match_operand:XF 0 "fp_register_operand" "")
10423         (abs:XF (match_operand:XF 1 "register_operand" "")))
10424    (clobber (reg:CC 17))]
10425   "TARGET_80387 && reload_completed"
10426   [(set (match_dup 0)
10427         (abs:XF (match_dup 1)))]
10428   "")
10430 (define_split
10431   [(set (match_operand:XF 0 "register_and_not_fp_reg_operand" "")
10432         (abs:XF (match_operand:XF 1 "register_operand" "")))
10433    (clobber (reg:CC 17))]
10434   "TARGET_80387 && reload_completed"
10435   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
10436               (clobber (reg:CC 17))])]
10437   "operands[1] = GEN_INT (~0x8000);
10438    operands[0] = gen_rtx_REG (SImode,
10439                               true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
10441 (define_insn "*abstf2_if"
10442   [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,rm#f")
10443         (abs:TF (match_operand:TF 1 "nonimmediate_operand" "0,0")))
10444    (clobber (reg:CC 17))]
10445   "TARGET_80387 && ix86_unary_operator_ok (ABS, TFmode, operands)"
10446   "#")
10448 (define_split
10449   [(set (match_operand:TF 0 "fp_register_operand" "")
10450         (abs:TF (match_operand:TF 1 "register_operand" "")))
10451    (clobber (reg:CC 17))]
10452   "TARGET_80387 && reload_completed"
10453   [(set (match_dup 0)
10454         (abs:TF (match_dup 1)))]
10455   "")
10457 (define_split
10458   [(set (match_operand:TF 0 "register_and_not_any_fp_reg_operand" "")
10459         (abs:TF (match_operand:TF 1 "register_operand" "")))
10460    (clobber (reg:CC 17))]
10461   "TARGET_80387 && reload_completed"
10462   [(parallel [(set (match_dup 0) (and:SI (match_dup 0) (match_dup 1)))
10463               (clobber (reg:CC 17))])]
10464   "operands[1] = GEN_INT (~0x8000);
10465    operands[0] = gen_rtx_REG (SImode,
10466                               true_regnum (operands[0]) + (TARGET_64BIT ? 1 : 2));")
10468 (define_insn "*abssf2_1"
10469   [(set (match_operand:SF 0 "register_operand" "=f")
10470         (abs:SF (match_operand:SF 1 "register_operand" "0")))]
10471   "TARGET_80387 && reload_completed"
10472   "fabs"
10473   [(set_attr "type" "fsgn")
10474    (set_attr "mode" "SF")])
10476 (define_insn "*absdf2_1"
10477   [(set (match_operand:DF 0 "register_operand" "=f")
10478         (abs:DF (match_operand:DF 1 "register_operand" "0")))]
10479   "TARGET_80387 && reload_completed"
10480   "fabs"
10481   [(set_attr "type" "fsgn")
10482    (set_attr "mode" "DF")])
10484 (define_insn "*absextendsfdf2"
10485   [(set (match_operand:DF 0 "register_operand" "=f")
10486         (abs:DF (float_extend:DF
10487                   (match_operand:SF 1 "register_operand" "0"))))]
10488   "TARGET_80387"
10489   "fabs"
10490   [(set_attr "type" "fsgn")
10491    (set_attr "mode" "DF")])
10493 (define_insn "*absxf2_1"
10494   [(set (match_operand:XF 0 "register_operand" "=f")
10495         (abs:XF (match_operand:XF 1 "register_operand" "0")))]
10496   "!TARGET_64BIT && TARGET_80387 && reload_completed"
10497   "fabs"
10498   [(set_attr "type" "fsgn")
10499    (set_attr "mode" "DF")])
10501 (define_insn "*absextenddfxf2"
10502   [(set (match_operand:XF 0 "register_operand" "=f")
10503         (abs:XF (float_extend:XF
10504           (match_operand:DF 1 "register_operand" "0"))))]
10505   "!TARGET_64BIT && TARGET_80387"
10506   "fabs"
10507   [(set_attr "type" "fsgn")
10508    (set_attr "mode" "XF")])
10510 (define_insn "*absextendsfxf2"
10511   [(set (match_operand:XF 0 "register_operand" "=f")
10512         (abs:XF (float_extend:XF
10513           (match_operand:SF 1 "register_operand" "0"))))]
10514   "!TARGET_64BIT && TARGET_80387"
10515   "fabs"
10516   [(set_attr "type" "fsgn")
10517    (set_attr "mode" "XF")])
10519 (define_insn "*abstf2_1"
10520   [(set (match_operand:TF 0 "register_operand" "=f")
10521         (abs:TF (match_operand:TF 1 "register_operand" "0")))]
10522   "TARGET_80387 && reload_completed"
10523   "fabs"
10524   [(set_attr "type" "fsgn")
10525    (set_attr "mode" "DF")])
10527 (define_insn "*absextenddftf2"
10528   [(set (match_operand:TF 0 "register_operand" "=f")
10529         (abs:TF (float_extend:TF
10530           (match_operand:DF 1 "register_operand" "0"))))]
10531   "TARGET_80387"
10532   "fabs"
10533   [(set_attr "type" "fsgn")
10534    (set_attr "mode" "XF")])
10536 (define_insn "*absextendsftf2"
10537   [(set (match_operand:TF 0 "register_operand" "=f")
10538         (abs:TF (float_extend:TF
10539           (match_operand:SF 1 "register_operand" "0"))))]
10540   "TARGET_80387"
10541   "fabs"
10542   [(set_attr "type" "fsgn")
10543    (set_attr "mode" "XF")])
10545 ;; One complement instructions
10547 (define_expand "one_cmpldi2"
10548   [(set (match_operand:DI 0 "nonimmediate_operand" "")
10549         (not:DI (match_operand:DI 1 "nonimmediate_operand" "")))]
10550   "TARGET_64BIT"
10551   "ix86_expand_unary_operator (NOT, DImode, operands); DONE;")
10553 (define_insn "*one_cmpldi2_1_rex64"
10554   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10555         (not:DI (match_operand:DI 1 "nonimmediate_operand" "0")))]
10556   "TARGET_64BIT && ix86_unary_operator_ok (NOT, DImode, operands)"
10557   "not{q}\t%0"
10558   [(set_attr "type" "negnot")
10559    (set_attr "mode" "DI")])
10561 (define_insn "*one_cmpldi2_2_rex64"
10562   [(set (reg 17)
10563         (compare (not:DI (match_operand:DI 1 "nonimmediate_operand" "0"))
10564                  (const_int 0)))
10565    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10566         (not:DI (match_dup 1)))]
10567   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
10568    && ix86_unary_operator_ok (NOT, DImode, operands)"
10569   "#"
10570   [(set_attr "type" "alu1")
10571    (set_attr "mode" "DI")])
10573 (define_split
10574   [(set (reg 17)
10575         (compare (not:DI (match_operand:DI 1 "nonimmediate_operand" ""))
10576                  (const_int 0)))
10577    (set (match_operand:DI 0 "nonimmediate_operand" "")
10578         (not:DI (match_dup 1)))]
10579   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
10580   [(parallel [(set (reg:CCNO 17)
10581                    (compare:CCNO (xor:DI (match_dup 1) (const_int -1))
10582                                  (const_int 0)))
10583               (set (match_dup 0)
10584                    (xor:DI (match_dup 1) (const_int -1)))])]
10585   "")
10587 (define_expand "one_cmplsi2"
10588   [(set (match_operand:SI 0 "nonimmediate_operand" "")
10589         (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
10590   ""
10591   "ix86_expand_unary_operator (NOT, SImode, operands); DONE;")
10593 (define_insn "*one_cmplsi2_1"
10594   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10595         (not:SI (match_operand:SI 1 "nonimmediate_operand" "0")))]
10596   "ix86_unary_operator_ok (NOT, SImode, operands)"
10597   "not{l}\t%0"
10598   [(set_attr "type" "negnot")
10599    (set_attr "mode" "SI")])
10601 ;; ??? Currently never generated - xor is used instead.
10602 (define_insn "*one_cmplsi2_1_zext"
10603   [(set (match_operand:DI 0 "register_operand" "=r")
10604         (zero_extend:DI (not:SI (match_operand:SI 1 "register_operand" "0"))))]
10605   "TARGET_64BIT && ix86_unary_operator_ok (NOT, SImode, operands)"
10606   "not{l}\t%k0"
10607   [(set_attr "type" "negnot")
10608    (set_attr "mode" "SI")])
10610 (define_insn "*one_cmplsi2_2"
10611   [(set (reg 17)
10612         (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" "0"))
10613                  (const_int 0)))
10614    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
10615         (not:SI (match_dup 1)))]
10616   "ix86_match_ccmode (insn, CCNOmode)
10617    && ix86_unary_operator_ok (NOT, SImode, operands)"
10618   "#"
10619   [(set_attr "type" "alu1")
10620    (set_attr "mode" "SI")])
10622 (define_split
10623   [(set (reg 17)
10624         (compare (not:SI (match_operand:SI 1 "nonimmediate_operand" ""))
10625                  (const_int 0)))
10626    (set (match_operand:SI 0 "nonimmediate_operand" "")
10627         (not:SI (match_dup 1)))]
10628   "ix86_match_ccmode (insn, CCNOmode)"
10629   [(parallel [(set (reg:CCNO 17)
10630                    (compare:CCNO (xor:SI (match_dup 1) (const_int -1))
10631                                  (const_int 0)))
10632               (set (match_dup 0)
10633                    (xor:SI (match_dup 1) (const_int -1)))])]
10634   "")
10636 ;; ??? Currently never generated - xor is used instead.
10637 (define_insn "*one_cmplsi2_2_zext"
10638   [(set (reg 17)
10639         (compare (not:SI (match_operand:SI 1 "register_operand" "0"))
10640                  (const_int 0)))
10641    (set (match_operand:DI 0 "register_operand" "=r")
10642         (zero_extend:DI (not:SI (match_dup 1))))]
10643   "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
10644    && ix86_unary_operator_ok (NOT, SImode, operands)"
10645   "#"
10646   [(set_attr "type" "alu1")
10647    (set_attr "mode" "SI")])
10649 (define_split
10650   [(set (reg 17)
10651         (compare (not:SI (match_operand:SI 1 "register_operand" ""))
10652                  (const_int 0)))
10653    (set (match_operand:DI 0 "register_operand" "")
10654         (zero_extend:DI (not:SI (match_dup 1))))]
10655   "ix86_match_ccmode (insn, CCNOmode)"
10656   [(parallel [(set (reg:CCNO 17)
10657                    (compare:CCNO (xor:SI (match_dup 1) (const_int -1))
10658                                  (const_int 0)))
10659               (set (match_dup 0)
10660                    (zero_extend:DI (xor:SI (match_dup 1) (const_int -1))))])]
10661   "")
10663 (define_expand "one_cmplhi2"
10664   [(set (match_operand:HI 0 "nonimmediate_operand" "")
10665         (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))]
10666   "TARGET_HIMODE_MATH"
10667   "ix86_expand_unary_operator (NOT, HImode, operands); DONE;")
10669 (define_insn "*one_cmplhi2_1"
10670   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10671         (not:HI (match_operand:HI 1 "nonimmediate_operand" "0")))]
10672   "ix86_unary_operator_ok (NOT, HImode, operands)"
10673   "not{w}\t%0"
10674   [(set_attr "type" "negnot")
10675    (set_attr "mode" "HI")])
10677 (define_insn "*one_cmplhi2_2"
10678   [(set (reg 17)
10679         (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" "0"))
10680                  (const_int 0)))
10681    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
10682         (not:HI (match_dup 1)))]
10683   "ix86_match_ccmode (insn, CCNOmode)
10684    && ix86_unary_operator_ok (NEG, HImode, operands)"
10685   "#"
10686   [(set_attr "type" "alu1")
10687    (set_attr "mode" "HI")])
10689 (define_split
10690   [(set (reg 17)
10691         (compare (not:HI (match_operand:HI 1 "nonimmediate_operand" ""))
10692                  (const_int 0)))
10693    (set (match_operand:HI 0 "nonimmediate_operand" "")
10694         (not:HI (match_dup 1)))]
10695   "ix86_match_ccmode (insn, CCNOmode)"
10696   [(parallel [(set (reg:CCNO 17)
10697                    (compare:CCNO (xor:HI (match_dup 1) (const_int -1))
10698                                  (const_int 0)))
10699               (set (match_dup 0)
10700                    (xor:HI (match_dup 1) (const_int -1)))])]
10701   "")
10703 ;; %%% Potential partial reg stall on alternative 1.  What to do?
10704 (define_expand "one_cmplqi2"
10705   [(set (match_operand:QI 0 "nonimmediate_operand" "")
10706         (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))]
10707   "TARGET_QIMODE_MATH"
10708   "ix86_expand_unary_operator (NOT, QImode, operands); DONE;")
10710 (define_insn "*one_cmplqi2_1"
10711   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r")
10712         (not:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")))]
10713   "ix86_unary_operator_ok (NOT, QImode, operands)"
10714   "@
10715    not{b}\t%0
10716    not{l}\t%k0"
10717   [(set_attr "type" "negnot")
10718    (set_attr "mode" "QI,SI")])
10720 (define_insn "*one_cmplqi2_2"
10721   [(set (reg 17)
10722         (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" "0"))
10723                  (const_int 0)))
10724    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
10725         (not:QI (match_dup 1)))]
10726   "ix86_match_ccmode (insn, CCNOmode)
10727    && ix86_unary_operator_ok (NOT, QImode, operands)"
10728   "#"
10729   [(set_attr "type" "alu1")
10730    (set_attr "mode" "QI")])
10732 (define_split
10733   [(set (reg 17)
10734         (compare (not:QI (match_operand:QI 1 "nonimmediate_operand" ""))
10735                  (const_int 0)))
10736    (set (match_operand:QI 0 "nonimmediate_operand" "")
10737         (not:QI (match_dup 1)))]
10738   "ix86_match_ccmode (insn, CCNOmode)"
10739   [(parallel [(set (reg:CCNO 17)
10740                    (compare:CCNO (xor:QI (match_dup 1) (const_int -1))
10741                                  (const_int 0)))
10742               (set (match_dup 0)
10743                    (xor:QI (match_dup 1) (const_int -1)))])]
10744   "")
10746 ;; Arithmetic shift instructions
10748 ;; DImode shifts are implemented using the i386 "shift double" opcode,
10749 ;; which is written as "sh[lr]d[lw] imm,reg,reg/mem".  If the shift count
10750 ;; is variable, then the count is in %cl and the "imm" operand is dropped
10751 ;; from the assembler input.
10753 ;; This instruction shifts the target reg/mem as usual, but instead of
10754 ;; shifting in zeros, bits are shifted in from reg operand.  If the insn
10755 ;; is a left shift double, bits are taken from the high order bits of
10756 ;; reg, else if the insn is a shift right double, bits are taken from the
10757 ;; low order bits of reg.  So if %eax is "1234" and %edx is "5678",
10758 ;; "shldl $8,%edx,%eax" leaves %edx unchanged and sets %eax to "2345".
10760 ;; Since sh[lr]d does not change the `reg' operand, that is done
10761 ;; separately, making all shifts emit pairs of shift double and normal
10762 ;; shift.  Since sh[lr]d does not shift more than 31 bits, and we wish to
10763 ;; support a 63 bit shift, each shift where the count is in a reg expands
10764 ;; to a pair of shifts, a branch, a shift by 32 and a label.
10766 ;; If the shift count is a constant, we need never emit more than one
10767 ;; shift pair, instead using moves and sign extension for counts greater
10768 ;; than 31.
10770 (define_expand "ashldi3"
10771   [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
10772                    (ashift:DI (match_operand:DI 1 "shiftdi_operand" "")
10773                               (match_operand:QI 2 "nonmemory_operand" "")))
10774               (clobber (reg:CC 17))])]
10775   ""
10777   if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
10778     {
10779       emit_insn (gen_ashldi3_1 (operands[0], operands[1], operands[2]));
10780       DONE;
10781     }
10782   ix86_expand_binary_operator (ASHIFT, DImode, operands);
10783   DONE;
10786 (define_insn "*ashldi3_1_rex64"
10787   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r")
10788         (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "0,r")
10789                    (match_operand:QI 2 "nonmemory_operand" "cJ,M")))
10790    (clobber (reg:CC 17))]
10791   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFT, DImode, operands)"
10793   switch (get_attr_type (insn))
10794     {
10795     case TYPE_ALU:
10796       if (operands[2] != const1_rtx)
10797         abort ();
10798       if (!rtx_equal_p (operands[0], operands[1]))
10799         abort ();
10800       return "add{q}\t{%0, %0|%0, %0}";
10802     case TYPE_LEA:
10803       if (GET_CODE (operands[2]) != CONST_INT
10804           || (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 3)
10805         abort ();
10806       operands[1] = gen_rtx_MULT (DImode, operands[1],
10807                                   GEN_INT (1 << INTVAL (operands[2])));
10808       return "lea{q}\t{%a1, %0|%0, %a1}";
10810     default:
10811       if (REG_P (operands[2]))
10812         return "sal{q}\t{%b2, %0|%0, %b2}";
10813       else if (GET_CODE (operands[2]) == CONST_INT
10814                && INTVAL (operands[2]) == 1
10815                && (TARGET_SHIFT1 || optimize_size))
10816         return "sal{q}\t%0";
10817       else
10818         return "sal{q}\t{%2, %0|%0, %2}";
10819     }
10821   [(set (attr "type")
10822      (cond [(eq_attr "alternative" "1")
10823               (const_string "lea")
10824             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10825                           (const_int 0))
10826                       (match_operand 0 "register_operand" ""))
10827                  (match_operand 2 "const1_operand" ""))
10828               (const_string "alu")
10829            ]
10830            (const_string "ishift")))
10831    (set_attr "mode" "DI")])
10833 ;; Convert lea to the lea pattern to avoid flags dependency.
10834 (define_split
10835   [(set (match_operand:DI 0 "register_operand" "")
10836         (ashift:DI (match_operand:DI 1 "register_operand" "")
10837                    (match_operand:QI 2 "immediate_operand" "")))
10838    (clobber (reg:CC 17))]
10839   "TARGET_64BIT && reload_completed
10840    && true_regnum (operands[0]) != true_regnum (operands[1])"
10841   [(set (match_dup 0)
10842         (mult:DI (match_dup 1)
10843                  (match_dup 2)))]
10844   "operands[2] = gen_int_mode (1 << INTVAL (operands[2]), DImode);")
10846 ;; This pattern can't accept a variable shift count, since shifts by
10847 ;; zero don't affect the flags.  We assume that shifts by constant
10848 ;; zero are optimized away.
10849 (define_insn "*ashldi3_cmp_rex64"
10850   [(set (reg 17)
10851         (compare
10852           (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "0")
10853                      (match_operand:QI 2 "immediate_operand" "e"))
10854           (const_int 0)))
10855    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
10856         (ashift:DI (match_dup 1) (match_dup 2)))]
10857   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
10858    && ix86_binary_operator_ok (ASHIFT, DImode, operands)"
10860   switch (get_attr_type (insn))
10861     {
10862     case TYPE_ALU:
10863       if (operands[2] != const1_rtx)
10864         abort ();
10865       return "add{q}\t{%0, %0|%0, %0}";
10867     default:
10868       if (REG_P (operands[2]))
10869         return "sal{q}\t{%b2, %0|%0, %b2}";
10870       else if (GET_CODE (operands[2]) == CONST_INT
10871                && INTVAL (operands[2]) == 1
10872                && (TARGET_SHIFT1 || optimize_size))
10873         return "sal{q}\t%0";
10874       else
10875         return "sal{q}\t{%2, %0|%0, %2}";
10876     }
10878   [(set (attr "type")
10879      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
10880                           (const_int 0))
10881                       (match_operand 0 "register_operand" ""))
10882                  (match_operand 2 "const1_operand" ""))
10883               (const_string "alu")
10884            ]
10885            (const_string "ishift")))
10886    (set_attr "mode" "DI")])
10888 (define_insn "ashldi3_1"
10889   [(set (match_operand:DI 0 "register_operand" "=r")
10890         (ashift:DI (match_operand:DI 1 "register_operand" "0")
10891                    (match_operand:QI 2 "nonmemory_operand" "Jc")))
10892    (clobber (match_scratch:SI 3 "=&r"))
10893    (clobber (reg:CC 17))]
10894   "!TARGET_64BIT && TARGET_CMOVE"
10895   "#"
10896   [(set_attr "type" "multi")])
10898 (define_insn "*ashldi3_2"
10899   [(set (match_operand:DI 0 "register_operand" "=r")
10900         (ashift:DI (match_operand:DI 1 "register_operand" "0")
10901                    (match_operand:QI 2 "nonmemory_operand" "Jc")))
10902    (clobber (reg:CC 17))]
10903   "!TARGET_64BIT"
10904   "#"
10905   [(set_attr "type" "multi")])
10907 (define_split
10908   [(set (match_operand:DI 0 "register_operand" "")
10909         (ashift:DI (match_operand:DI 1 "register_operand" "")
10910                    (match_operand:QI 2 "nonmemory_operand" "")))
10911    (clobber (match_scratch:SI 3 ""))
10912    (clobber (reg:CC 17))]
10913   "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
10914   [(const_int 0)]
10915   "ix86_split_ashldi (operands, operands[3]); DONE;")
10917 (define_split
10918   [(set (match_operand:DI 0 "register_operand" "")
10919         (ashift:DI (match_operand:DI 1 "register_operand" "")
10920                    (match_operand:QI 2 "nonmemory_operand" "")))
10921    (clobber (reg:CC 17))]
10922   "!TARGET_64BIT && reload_completed"
10923   [(const_int 0)]
10924   "ix86_split_ashldi (operands, NULL_RTX); DONE;")
10926 (define_insn "x86_shld_1"
10927   [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m")
10928         (ior:SI (ashift:SI (match_dup 0)
10929                   (match_operand:QI 2 "nonmemory_operand" "I,c"))
10930                 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r")
10931                   (minus:QI (const_int 32) (match_dup 2)))))
10932    (clobber (reg:CC 17))]
10933   ""
10934   "@
10935    shld{l}\t{%2, %1, %0|%0, %1, %2}
10936    shld{l}\t{%s2%1, %0|%0, %1, %2}"
10937   [(set_attr "type" "ishift")
10938    (set_attr "prefix_0f" "1")
10939    (set_attr "mode" "SI")
10940    (set_attr "pent_pair" "np")
10941    (set_attr "athlon_decode" "vector")
10942    (set_attr "ppro_uops" "few")])
10944 (define_expand "x86_shift_adj_1"
10945   [(set (reg:CCZ 17)
10946         (compare:CCZ (and:QI (match_operand:QI 2 "register_operand" "")
10947                              (const_int 32))
10948                      (const_int 0)))
10949    (set (match_operand:SI 0 "register_operand" "")
10950         (if_then_else:SI (ne (reg:CCZ 17) (const_int 0))
10951                          (match_operand:SI 1 "register_operand" "")
10952                          (match_dup 0)))
10953    (set (match_dup 1)
10954         (if_then_else:SI (ne (reg:CCZ 17) (const_int 0))
10955                          (match_operand:SI 3 "register_operand" "r")
10956                          (match_dup 1)))]
10957   "TARGET_CMOVE"
10958   "")
10960 (define_expand "x86_shift_adj_2"
10961   [(use (match_operand:SI 0 "register_operand" ""))
10962    (use (match_operand:SI 1 "register_operand" ""))
10963    (use (match_operand:QI 2 "register_operand" ""))]
10964   ""
10966   rtx label = gen_label_rtx ();
10967   rtx tmp;
10969   emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32)));
10971   tmp = gen_rtx_REG (CCZmode, FLAGS_REG);
10972   tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
10973   tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
10974                               gen_rtx_LABEL_REF (VOIDmode, label),
10975                               pc_rtx);
10976   tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
10977   JUMP_LABEL (tmp) = label;
10979   emit_move_insn (operands[0], operands[1]);
10980   emit_move_insn (operands[1], const0_rtx);
10982   emit_label (label);
10983   LABEL_NUSES (label) = 1;
10985   DONE;
10988 (define_expand "ashlsi3"
10989   [(set (match_operand:SI 0 "nonimmediate_operand" "")
10990         (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "")
10991                    (match_operand:QI 2 "nonmemory_operand" "")))
10992    (clobber (reg:CC 17))]
10993   ""
10994   "ix86_expand_binary_operator (ASHIFT, SImode, operands); DONE;")
10996 (define_insn "*ashlsi3_1"
10997   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
10998         (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0,r")
10999                    (match_operand:QI 2 "nonmemory_operand" "cI,M")))
11000    (clobber (reg:CC 17))]
11001   "ix86_binary_operator_ok (ASHIFT, SImode, operands)"
11003   switch (get_attr_type (insn))
11004     {
11005     case TYPE_ALU:
11006       if (operands[2] != const1_rtx)
11007         abort ();
11008       if (!rtx_equal_p (operands[0], operands[1]))
11009         abort ();
11010       return "add{l}\t{%0, %0|%0, %0}";
11012     case TYPE_LEA:
11013       return "#";
11015     default:
11016       if (REG_P (operands[2]))
11017         return "sal{l}\t{%b2, %0|%0, %b2}";
11018       else if (GET_CODE (operands[2]) == CONST_INT
11019                && INTVAL (operands[2]) == 1
11020                && (TARGET_SHIFT1 || optimize_size))
11021         return "sal{l}\t%0";
11022       else
11023         return "sal{l}\t{%2, %0|%0, %2}";
11024     }
11026   [(set (attr "type")
11027      (cond [(eq_attr "alternative" "1")
11028               (const_string "lea")
11029             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11030                           (const_int 0))
11031                       (match_operand 0 "register_operand" ""))
11032                  (match_operand 2 "const1_operand" ""))
11033               (const_string "alu")
11034            ]
11035            (const_string "ishift")))
11036    (set_attr "mode" "SI")])
11038 ;; Convert lea to the lea pattern to avoid flags dependency.
11039 (define_split
11040   [(set (match_operand 0 "register_operand" "")
11041         (ashift (match_operand 1 "index_register_operand" "")
11042                 (match_operand:QI 2 "const_int_operand" "")))
11043    (clobber (reg:CC 17))]
11044   "reload_completed
11045    && true_regnum (operands[0]) != true_regnum (operands[1])"
11046   [(const_int 0)]
11048   rtx pat;
11049   operands[0] = gen_lowpart (SImode, operands[0]);
11050   operands[1] = gen_lowpart (Pmode, operands[1]);
11051   operands[2] = gen_int_mode (1 << INTVAL (operands[2]), Pmode);
11052   pat = gen_rtx_MULT (Pmode, operands[1], operands[2]);
11053   if (Pmode != SImode)
11054     pat = gen_rtx_SUBREG (SImode, pat, 0);
11055   emit_insn (gen_rtx_SET (VOIDmode, operands[0], pat));
11056   DONE;
11059 ;; Rare case of shifting RSP is handled by generating move and shift
11060 (define_split
11061   [(set (match_operand 0 "register_operand" "")
11062         (ashift (match_operand 1 "register_operand" "")
11063                 (match_operand:QI 2 "const_int_operand" "")))
11064    (clobber (reg:CC 17))]
11065   "reload_completed
11066    && true_regnum (operands[0]) != true_regnum (operands[1])"
11067   [(const_int 0)]
11069   rtx pat, clob;
11070   emit_move_insn (operands[1], operands[0]);
11071   pat = gen_rtx_SET (VOIDmode, operands[0],
11072                      gen_rtx_ASHIFT (GET_MODE (operands[0]),
11073                                      operands[0], operands[2]));
11074   clob = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
11075   emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, pat, clob)));
11076   DONE;
11079 (define_insn "*ashlsi3_1_zext"
11080   [(set (match_operand:DI 0 "register_operand" "=r,r")
11081         (zero_extend:DI (ashift:SI (match_operand:SI 1 "register_operand" "0,r")
11082                         (match_operand:QI 2 "nonmemory_operand" "cI,M"))))
11083    (clobber (reg:CC 17))]
11084   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
11086   switch (get_attr_type (insn))
11087     {
11088     case TYPE_ALU:
11089       if (operands[2] != const1_rtx)
11090         abort ();
11091       return "add{l}\t{%k0, %k0|%k0, %k0}";
11093     case TYPE_LEA:
11094       return "#";
11096     default:
11097       if (REG_P (operands[2]))
11098         return "sal{l}\t{%b2, %k0|%k0, %b2}";
11099       else if (GET_CODE (operands[2]) == CONST_INT
11100                && INTVAL (operands[2]) == 1
11101                && (TARGET_SHIFT1 || optimize_size))
11102         return "sal{l}\t%k0";
11103       else
11104         return "sal{l}\t{%2, %k0|%k0, %2}";
11105     }
11107   [(set (attr "type")
11108      (cond [(eq_attr "alternative" "1")
11109               (const_string "lea")
11110             (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11111                      (const_int 0))
11112                  (match_operand 2 "const1_operand" ""))
11113               (const_string "alu")
11114            ]
11115            (const_string "ishift")))
11116    (set_attr "mode" "SI")])
11118 ;; Convert lea to the lea pattern to avoid flags dependency.
11119 (define_split
11120   [(set (match_operand:DI 0 "register_operand" "")
11121         (zero_extend:DI (ashift (match_operand 1 "register_operand" "")
11122                                 (match_operand:QI 2 "const_int_operand" ""))))
11123    (clobber (reg:CC 17))]
11124   "TARGET_64BIT && reload_completed
11125    && true_regnum (operands[0]) != true_regnum (operands[1])"
11126   [(set (match_dup 0) (zero_extend:DI
11127                         (subreg:SI (mult:SI (match_dup 1)
11128                                             (match_dup 2)) 0)))]
11130   operands[1] = gen_lowpart (Pmode, operands[1]);
11131   operands[2] = gen_int_mode (1 << INTVAL (operands[2]), Pmode);
11134 ;; This pattern can't accept a variable shift count, since shifts by
11135 ;; zero don't affect the flags.  We assume that shifts by constant
11136 ;; zero are optimized away.
11137 (define_insn "*ashlsi3_cmp"
11138   [(set (reg 17)
11139         (compare
11140           (ashift:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11141                      (match_operand:QI 2 "const_int_1_31_operand" "I"))
11142           (const_int 0)))
11143    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11144         (ashift:SI (match_dup 1) (match_dup 2)))]
11145   "ix86_match_ccmode (insn, CCGOCmode)
11146    && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
11148   switch (get_attr_type (insn))
11149     {
11150     case TYPE_ALU:
11151       if (operands[2] != const1_rtx)
11152         abort ();
11153       return "add{l}\t{%0, %0|%0, %0}";
11155     default:
11156       if (REG_P (operands[2]))
11157         return "sal{l}\t{%b2, %0|%0, %b2}";
11158       else if (GET_CODE (operands[2]) == CONST_INT
11159                && INTVAL (operands[2]) == 1
11160                && (TARGET_SHIFT1 || optimize_size))
11161         return "sal{l}\t%0";
11162       else
11163         return "sal{l}\t{%2, %0|%0, %2}";
11164     }
11166   [(set (attr "type")
11167      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11168                           (const_int 0))
11169                       (match_operand 0 "register_operand" ""))
11170                  (match_operand 2 "const1_operand" ""))
11171               (const_string "alu")
11172            ]
11173            (const_string "ishift")))
11174    (set_attr "mode" "SI")])
11176 (define_insn "*ashlsi3_cmp_zext"
11177   [(set (reg 17)
11178         (compare
11179           (ashift:SI (match_operand:SI 1 "register_operand" "0")
11180                      (match_operand:QI 2 "const_int_1_31_operand" "I"))
11181           (const_int 0)))
11182    (set (match_operand:DI 0 "register_operand" "=r")
11183         (zero_extend:DI (ashift:SI (match_dup 1) (match_dup 2))))]
11184   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11185    && ix86_binary_operator_ok (ASHIFT, SImode, operands)"
11187   switch (get_attr_type (insn))
11188     {
11189     case TYPE_ALU:
11190       if (operands[2] != const1_rtx)
11191         abort ();
11192       return "add{l}\t{%k0, %k0|%k0, %k0}";
11194     default:
11195       if (REG_P (operands[2]))
11196         return "sal{l}\t{%b2, %k0|%k0, %b2}";
11197       else if (GET_CODE (operands[2]) == CONST_INT
11198                && INTVAL (operands[2]) == 1
11199                && (TARGET_SHIFT1 || optimize_size))
11200         return "sal{l}\t%k0";
11201       else
11202         return "sal{l}\t{%2, %k0|%k0, %2}";
11203     }
11205   [(set (attr "type")
11206      (cond [(and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11207                      (const_int 0))
11208                  (match_operand 2 "const1_operand" ""))
11209               (const_string "alu")
11210            ]
11211            (const_string "ishift")))
11212    (set_attr "mode" "SI")])
11214 (define_expand "ashlhi3"
11215   [(set (match_operand:HI 0 "nonimmediate_operand" "")
11216         (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "")
11217                    (match_operand:QI 2 "nonmemory_operand" "")))
11218    (clobber (reg:CC 17))]
11219   "TARGET_HIMODE_MATH"
11220   "ix86_expand_binary_operator (ASHIFT, HImode, operands); DONE;")
11222 (define_insn "*ashlhi3_1_lea"
11223   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
11224         (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0,r")
11225                    (match_operand:QI 2 "nonmemory_operand" "cI,M")))
11226    (clobber (reg:CC 17))]
11227   "!TARGET_PARTIAL_REG_STALL
11228    && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
11230   switch (get_attr_type (insn))
11231     {
11232     case TYPE_LEA:
11233       return "#";
11234     case TYPE_ALU:
11235       if (operands[2] != const1_rtx)
11236         abort ();
11237       return "add{w}\t{%0, %0|%0, %0}";
11239     default:
11240       if (REG_P (operands[2]))
11241         return "sal{w}\t{%b2, %0|%0, %b2}";
11242       else if (GET_CODE (operands[2]) == CONST_INT
11243                && INTVAL (operands[2]) == 1
11244                && (TARGET_SHIFT1 || optimize_size))
11245         return "sal{w}\t%0";
11246       else
11247         return "sal{w}\t{%2, %0|%0, %2}";
11248     }
11250   [(set (attr "type")
11251      (cond [(eq_attr "alternative" "1")
11252               (const_string "lea")
11253             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11254                           (const_int 0))
11255                       (match_operand 0 "register_operand" ""))
11256                  (match_operand 2 "const1_operand" ""))
11257               (const_string "alu")
11258            ]
11259            (const_string "ishift")))
11260    (set_attr "mode" "HI,SI")])
11262 (define_insn "*ashlhi3_1"
11263   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11264         (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11265                    (match_operand:QI 2 "nonmemory_operand" "cI")))
11266    (clobber (reg:CC 17))]
11267   "TARGET_PARTIAL_REG_STALL
11268    && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
11270   switch (get_attr_type (insn))
11271     {
11272     case TYPE_ALU:
11273       if (operands[2] != const1_rtx)
11274         abort ();
11275       return "add{w}\t{%0, %0|%0, %0}";
11277     default:
11278       if (REG_P (operands[2]))
11279         return "sal{w}\t{%b2, %0|%0, %b2}";
11280       else if (GET_CODE (operands[2]) == CONST_INT
11281                && INTVAL (operands[2]) == 1
11282                && (TARGET_SHIFT1 || optimize_size))
11283         return "sal{w}\t%0";
11284       else
11285         return "sal{w}\t{%2, %0|%0, %2}";
11286     }
11288   [(set (attr "type")
11289      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11290                           (const_int 0))
11291                       (match_operand 0 "register_operand" ""))
11292                  (match_operand 2 "const1_operand" ""))
11293               (const_string "alu")
11294            ]
11295            (const_string "ishift")))
11296    (set_attr "mode" "HI")])
11298 ;; This pattern can't accept a variable shift count, since shifts by
11299 ;; zero don't affect the flags.  We assume that shifts by constant
11300 ;; zero are optimized away.
11301 (define_insn "*ashlhi3_cmp"
11302   [(set (reg 17)
11303         (compare
11304           (ashift:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11305                      (match_operand:QI 2 "const_int_1_31_operand" "I"))
11306           (const_int 0)))
11307    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11308         (ashift:HI (match_dup 1) (match_dup 2)))]
11309   "ix86_match_ccmode (insn, CCGOCmode)
11310    && ix86_binary_operator_ok (ASHIFT, HImode, operands)"
11312   switch (get_attr_type (insn))
11313     {
11314     case TYPE_ALU:
11315       if (operands[2] != const1_rtx)
11316         abort ();
11317       return "add{w}\t{%0, %0|%0, %0}";
11319     default:
11320       if (REG_P (operands[2]))
11321         return "sal{w}\t{%b2, %0|%0, %b2}";
11322       else if (GET_CODE (operands[2]) == CONST_INT
11323                && INTVAL (operands[2]) == 1
11324                && (TARGET_SHIFT1 || optimize_size))
11325         return "sal{w}\t%0";
11326       else
11327         return "sal{w}\t{%2, %0|%0, %2}";
11328     }
11330   [(set (attr "type")
11331      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11332                           (const_int 0))
11333                       (match_operand 0 "register_operand" ""))
11334                  (match_operand 2 "const1_operand" ""))
11335               (const_string "alu")
11336            ]
11337            (const_string "ishift")))
11338    (set_attr "mode" "HI")])
11340 (define_expand "ashlqi3"
11341   [(set (match_operand:QI 0 "nonimmediate_operand" "")
11342         (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "")
11343                    (match_operand:QI 2 "nonmemory_operand" "")))
11344    (clobber (reg:CC 17))]
11345   "TARGET_QIMODE_MATH"
11346   "ix86_expand_binary_operator (ASHIFT, QImode, operands); DONE;")
11348 ;; %%% Potential partial reg stall on alternative 2.  What to do?
11350 (define_insn "*ashlqi3_1_lea"
11351   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r,r")
11352         (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0,r")
11353                    (match_operand:QI 2 "nonmemory_operand" "cI,cI,M")))
11354    (clobber (reg:CC 17))]
11355   "!TARGET_PARTIAL_REG_STALL
11356    && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
11358   switch (get_attr_type (insn))
11359     {
11360     case TYPE_LEA:
11361       return "#";
11362     case TYPE_ALU:
11363       if (operands[2] != const1_rtx)
11364         abort ();
11365       if (REG_P (operands[1]) && !ANY_QI_REG_P (operands[1]))
11366         return "add{l}\t{%k0, %k0|%k0, %k0}";
11367       else
11368         return "add{b}\t{%0, %0|%0, %0}";
11370     default:
11371       if (REG_P (operands[2]))
11372         {
11373           if (get_attr_mode (insn) == MODE_SI)
11374             return "sal{l}\t{%b2, %k0|%k0, %b2}";
11375           else
11376             return "sal{b}\t{%b2, %0|%0, %b2}";
11377         }
11378       else if (GET_CODE (operands[2]) == CONST_INT
11379                && INTVAL (operands[2]) == 1
11380                && (TARGET_SHIFT1 || optimize_size))
11381         {
11382           if (get_attr_mode (insn) == MODE_SI)
11383             return "sal{l}\t%0";
11384           else
11385             return "sal{b}\t%0";
11386         }
11387       else
11388         {
11389           if (get_attr_mode (insn) == MODE_SI)
11390             return "sal{l}\t{%2, %k0|%k0, %2}";
11391           else
11392             return "sal{b}\t{%2, %0|%0, %2}";
11393         }
11394     }
11396   [(set (attr "type")
11397      (cond [(eq_attr "alternative" "2")
11398               (const_string "lea")
11399             (and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11400                           (const_int 0))
11401                       (match_operand 0 "register_operand" ""))
11402                  (match_operand 2 "const1_operand" ""))
11403               (const_string "alu")
11404            ]
11405            (const_string "ishift")))
11406    (set_attr "mode" "QI,SI,SI")])
11408 (define_insn "*ashlqi3_1"
11409   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,r")
11410         (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11411                    (match_operand:QI 2 "nonmemory_operand" "cI,cI")))
11412    (clobber (reg:CC 17))]
11413   "TARGET_PARTIAL_REG_STALL
11414    && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
11416   switch (get_attr_type (insn))
11417     {
11418     case TYPE_ALU:
11419       if (operands[2] != const1_rtx)
11420         abort ();
11421       if (REG_P (operands[1]) && !ANY_QI_REG_P (operands[1]))
11422         return "add{l}\t{%k0, %k0|%k0, %k0}";
11423       else
11424         return "add{b}\t{%0, %0|%0, %0}";
11426     default:
11427       if (REG_P (operands[2]))
11428         {
11429           if (get_attr_mode (insn) == MODE_SI)
11430             return "sal{l}\t{%b2, %k0|%k0, %b2}";
11431           else
11432             return "sal{b}\t{%b2, %0|%0, %b2}";
11433         }
11434       else if (GET_CODE (operands[2]) == CONST_INT
11435                && INTVAL (operands[2]) == 1
11436                && (TARGET_SHIFT1 || optimize_size))
11437         {
11438           if (get_attr_mode (insn) == MODE_SI)
11439             return "sal{l}\t%0";
11440           else
11441             return "sal{b}\t%0";
11442         }
11443       else
11444         {
11445           if (get_attr_mode (insn) == MODE_SI)
11446             return "sal{l}\t{%2, %k0|%k0, %2}";
11447           else
11448             return "sal{b}\t{%2, %0|%0, %2}";
11449         }
11450     }
11452   [(set (attr "type")
11453      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11454                           (const_int 0))
11455                       (match_operand 0 "register_operand" ""))
11456                  (match_operand 2 "const1_operand" ""))
11457               (const_string "alu")
11458            ]
11459            (const_string "ishift")))
11460    (set_attr "mode" "QI,SI")])
11462 ;; This pattern can't accept a variable shift count, since shifts by
11463 ;; zero don't affect the flags.  We assume that shifts by constant
11464 ;; zero are optimized away.
11465 (define_insn "*ashlqi3_cmp"
11466   [(set (reg 17)
11467         (compare
11468           (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11469                      (match_operand:QI 2 "const_int_1_31_operand" "I"))
11470           (const_int 0)))
11471    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11472         (ashift:QI (match_dup 1) (match_dup 2)))]
11473   "ix86_match_ccmode (insn, CCGOCmode)
11474    && ix86_binary_operator_ok (ASHIFT, QImode, operands)"
11476   switch (get_attr_type (insn))
11477     {
11478     case TYPE_ALU:
11479       if (operands[2] != const1_rtx)
11480         abort ();
11481       return "add{b}\t{%0, %0|%0, %0}";
11483     default:
11484       if (REG_P (operands[2]))
11485         return "sal{b}\t{%b2, %0|%0, %b2}";
11486       else if (GET_CODE (operands[2]) == CONST_INT
11487                && INTVAL (operands[2]) == 1
11488                && (TARGET_SHIFT1 || optimize_size))
11489         return "sal{b}\t%0";
11490       else
11491         return "sal{b}\t{%2, %0|%0, %2}";
11492     }
11494   [(set (attr "type")
11495      (cond [(and (and (ne (symbol_ref "TARGET_DOUBLE_WITH_ADD")
11496                           (const_int 0))
11497                       (match_operand 0 "register_operand" ""))
11498                  (match_operand 2 "const1_operand" ""))
11499               (const_string "alu")
11500            ]
11501            (const_string "ishift")))
11502    (set_attr "mode" "QI")])
11504 ;; See comment above `ashldi3' about how this works.
11506 (define_expand "ashrdi3"
11507   [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
11508                    (ashiftrt:DI (match_operand:DI 1 "shiftdi_operand" "")
11509                                 (match_operand:QI 2 "nonmemory_operand" "")))
11510               (clobber (reg:CC 17))])]
11511   ""
11513   if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
11514     {
11515       emit_insn (gen_ashrdi3_1 (operands[0], operands[1], operands[2]));
11516       DONE;
11517     }
11518   ix86_expand_binary_operator (ASHIFTRT, DImode, operands);
11519   DONE;
11522 (define_insn "ashrdi3_63_rex64"
11523   [(set (match_operand:DI 0 "nonimmediate_operand" "=*d,rm")
11524         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "*a,0")
11525                      (match_operand:DI 2 "const_int_operand" "i,i")))
11526    (clobber (reg:CC 17))]
11527   "TARGET_64BIT && INTVAL (operands[2]) == 63 && (TARGET_USE_CLTD || optimize_size)
11528    && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11529   "@
11530    {cqto|cqo}
11531    sar{q}\t{%2, %0|%0, %2}"
11532   [(set_attr "type" "imovx,ishift")
11533    (set_attr "prefix_0f" "0,*")
11534    (set_attr "length_immediate" "0,*")
11535    (set_attr "modrm" "0,1")
11536    (set_attr "mode" "DI")])
11538 (define_insn "*ashrdi3_1_one_bit_rex64"
11539   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11540         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11541                      (match_operand:QI 2 "const_int_1_operand" "")))
11542    (clobber (reg:CC 17))]
11543   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)
11544    && (TARGET_SHIFT1 || optimize_size)"
11545   "sar{q}\t%0"
11546   [(set_attr "type" "ishift")
11547    (set (attr "length") 
11548      (if_then_else (match_operand:DI 0 "register_operand" "") 
11549         (const_string "2")
11550         (const_string "*")))])
11552 (define_insn "*ashrdi3_1_rex64"
11553   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
11554         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
11555                      (match_operand:QI 2 "nonmemory_operand" "J,c")))
11556    (clobber (reg:CC 17))]
11557   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11558   "@
11559    sar{q}\t{%2, %0|%0, %2}
11560    sar{q}\t{%b2, %0|%0, %b2}"
11561   [(set_attr "type" "ishift")
11562    (set_attr "mode" "DI")])
11564 ;; This pattern can't accept a variable shift count, since shifts by
11565 ;; zero don't affect the flags.  We assume that shifts by constant
11566 ;; zero are optimized away.
11567 (define_insn "*ashrdi3_one_bit_cmp_rex64"
11568   [(set (reg 17)
11569         (compare
11570           (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11571                        (match_operand:QI 2 "const_int_1_operand" ""))
11572           (const_int 0)))
11573    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11574         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
11575   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11576    && (TARGET_SHIFT1 || optimize_size)
11577    && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11578   "sar{q}\t%0"
11579   [(set_attr "type" "ishift")
11580    (set (attr "length") 
11581      (if_then_else (match_operand:DI 0 "register_operand" "") 
11582         (const_string "2")
11583         (const_string "*")))])
11585 ;; This pattern can't accept a variable shift count, since shifts by
11586 ;; zero don't affect the flags.  We assume that shifts by constant
11587 ;; zero are optimized away.
11588 (define_insn "*ashrdi3_cmp_rex64"
11589   [(set (reg 17)
11590         (compare
11591           (ashiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
11592                        (match_operand:QI 2 "const_int_operand" "n"))
11593           (const_int 0)))
11594    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
11595         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
11596   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11597    && ix86_binary_operator_ok (ASHIFTRT, DImode, operands)"
11598   "sar{q}\t{%2, %0|%0, %2}"
11599   [(set_attr "type" "ishift")
11600    (set_attr "mode" "DI")])
11603 (define_insn "ashrdi3_1"
11604   [(set (match_operand:DI 0 "register_operand" "=r")
11605         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
11606                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
11607    (clobber (match_scratch:SI 3 "=&r"))
11608    (clobber (reg:CC 17))]
11609   "!TARGET_64BIT && TARGET_CMOVE"
11610   "#"
11611   [(set_attr "type" "multi")])
11613 (define_insn "*ashrdi3_2"
11614   [(set (match_operand:DI 0 "register_operand" "=r")
11615         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
11616                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
11617    (clobber (reg:CC 17))]
11618   "!TARGET_64BIT"
11619   "#"
11620   [(set_attr "type" "multi")])
11622 (define_split
11623   [(set (match_operand:DI 0 "register_operand" "")
11624         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
11625                      (match_operand:QI 2 "nonmemory_operand" "")))
11626    (clobber (match_scratch:SI 3 ""))
11627    (clobber (reg:CC 17))]
11628   "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
11629   [(const_int 0)]
11630   "ix86_split_ashrdi (operands, operands[3]); DONE;")
11632 (define_split
11633   [(set (match_operand:DI 0 "register_operand" "")
11634         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
11635                      (match_operand:QI 2 "nonmemory_operand" "")))
11636    (clobber (reg:CC 17))]
11637   "!TARGET_64BIT && reload_completed"
11638   [(const_int 0)]
11639   "ix86_split_ashrdi (operands, NULL_RTX); DONE;")
11641 (define_insn "x86_shrd_1"
11642   [(set (match_operand:SI 0 "nonimmediate_operand" "+r*m,r*m")
11643         (ior:SI (ashiftrt:SI (match_dup 0)
11644                   (match_operand:QI 2 "nonmemory_operand" "I,c"))
11645                 (ashift:SI (match_operand:SI 1 "register_operand" "r,r")
11646                   (minus:QI (const_int 32) (match_dup 2)))))
11647    (clobber (reg:CC 17))]
11648   ""
11649   "@
11650    shrd{l}\t{%2, %1, %0|%0, %1, %2}
11651    shrd{l}\t{%s2%1, %0|%0, %1, %2}"
11652   [(set_attr "type" "ishift")
11653    (set_attr "prefix_0f" "1")
11654    (set_attr "pent_pair" "np")
11655    (set_attr "ppro_uops" "few")
11656    (set_attr "mode" "SI")])
11658 (define_expand "x86_shift_adj_3"
11659   [(use (match_operand:SI 0 "register_operand" ""))
11660    (use (match_operand:SI 1 "register_operand" ""))
11661    (use (match_operand:QI 2 "register_operand" ""))]
11662   ""
11664   rtx label = gen_label_rtx ();
11665   rtx tmp;
11667   emit_insn (gen_testqi_ccz_1 (operands[2], GEN_INT (32)));
11669   tmp = gen_rtx_REG (CCZmode, FLAGS_REG);
11670   tmp = gen_rtx_EQ (VOIDmode, tmp, const0_rtx);
11671   tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp,
11672                               gen_rtx_LABEL_REF (VOIDmode, label),
11673                               pc_rtx);
11674   tmp = emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp));
11675   JUMP_LABEL (tmp) = label;
11677   emit_move_insn (operands[0], operands[1]);
11678   emit_insn (gen_ashrsi3_31 (operands[1], operands[1], GEN_INT (31)));
11680   emit_label (label);
11681   LABEL_NUSES (label) = 1;
11683   DONE;
11686 (define_insn "ashrsi3_31"
11687   [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,rm")
11688         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "*a,0")
11689                      (match_operand:SI 2 "const_int_operand" "i,i")))
11690    (clobber (reg:CC 17))]
11691   "INTVAL (operands[2]) == 31 && (TARGET_USE_CLTD || optimize_size)
11692    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11693   "@
11694    {cltd|cdq}
11695    sar{l}\t{%2, %0|%0, %2}"
11696   [(set_attr "type" "imovx,ishift")
11697    (set_attr "prefix_0f" "0,*")
11698    (set_attr "length_immediate" "0,*")
11699    (set_attr "modrm" "0,1")
11700    (set_attr "mode" "SI")])
11702 (define_insn "*ashrsi3_31_zext"
11703   [(set (match_operand:DI 0 "register_operand" "=*d,r")
11704         (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "*a,0")
11705                                      (match_operand:SI 2 "const_int_operand" "i,i"))))
11706    (clobber (reg:CC 17))]
11707   "TARGET_64BIT && (TARGET_USE_CLTD || optimize_size)
11708    && INTVAL (operands[2]) == 31
11709    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11710   "@
11711    {cltd|cdq}
11712    sar{l}\t{%2, %k0|%k0, %2}"
11713   [(set_attr "type" "imovx,ishift")
11714    (set_attr "prefix_0f" "0,*")
11715    (set_attr "length_immediate" "0,*")
11716    (set_attr "modrm" "0,1")
11717    (set_attr "mode" "SI")])
11719 (define_expand "ashrsi3"
11720   [(set (match_operand:SI 0 "nonimmediate_operand" "")
11721         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "")
11722                      (match_operand:QI 2 "nonmemory_operand" "")))
11723    (clobber (reg:CC 17))]
11724   ""
11725   "ix86_expand_binary_operator (ASHIFTRT, SImode, operands); DONE;")
11727 (define_insn "*ashrsi3_1_one_bit"
11728   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11729         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11730                      (match_operand:QI 2 "const_int_1_operand" "")))
11731    (clobber (reg:CC 17))]
11732   "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)
11733    && (TARGET_SHIFT1 || optimize_size)"
11734   "sar{l}\t%0"
11735   [(set_attr "type" "ishift")
11736    (set (attr "length") 
11737      (if_then_else (match_operand:SI 0 "register_operand" "") 
11738         (const_string "2")
11739         (const_string "*")))])
11741 (define_insn "*ashrsi3_1_one_bit_zext"
11742   [(set (match_operand:DI 0 "register_operand" "=r")
11743         (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11744                                      (match_operand:QI 2 "const_int_1_operand" ""))))
11745    (clobber (reg:CC 17))]
11746   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)
11747    && (TARGET_SHIFT1 || optimize_size)"
11748   "sar{l}\t%k0"
11749   [(set_attr "type" "ishift")
11750    (set_attr "length" "2")])
11752 (define_insn "*ashrsi3_1"
11753   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
11754         (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
11755                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11756    (clobber (reg:CC 17))]
11757   "ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11758   "@
11759    sar{l}\t{%2, %0|%0, %2}
11760    sar{l}\t{%b2, %0|%0, %b2}"
11761   [(set_attr "type" "ishift")
11762    (set_attr "mode" "SI")])
11764 (define_insn "*ashrsi3_1_zext"
11765   [(set (match_operand:DI 0 "register_operand" "=r,r")
11766         (zero_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0")
11767                                      (match_operand:QI 2 "nonmemory_operand" "I,c"))))
11768    (clobber (reg:CC 17))]
11769   "TARGET_64BIT && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11770   "@
11771    sar{l}\t{%2, %k0|%k0, %2}
11772    sar{l}\t{%b2, %k0|%k0, %b2}"
11773   [(set_attr "type" "ishift")
11774    (set_attr "mode" "SI")])
11776 ;; This pattern can't accept a variable shift count, since shifts by
11777 ;; zero don't affect the flags.  We assume that shifts by constant
11778 ;; zero are optimized away.
11779 (define_insn "*ashrsi3_one_bit_cmp"
11780   [(set (reg 17)
11781         (compare
11782           (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11783                        (match_operand:QI 2 "const_int_1_operand" ""))
11784           (const_int 0)))
11785    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11786         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
11787   "ix86_match_ccmode (insn, CCGOCmode)
11788    && (TARGET_SHIFT1 || optimize_size)
11789    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11790   "sar{l}\t%0"
11791   [(set_attr "type" "ishift")
11792    (set (attr "length") 
11793      (if_then_else (match_operand:SI 0 "register_operand" "") 
11794         (const_string "2")
11795         (const_string "*")))])
11797 (define_insn "*ashrsi3_one_bit_cmp_zext"
11798   [(set (reg 17)
11799         (compare
11800           (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11801                        (match_operand:QI 2 "const_int_1_operand" ""))
11802           (const_int 0)))
11803    (set (match_operand:DI 0 "register_operand" "=r")
11804         (zero_extend:DI (ashiftrt:SI (match_dup 1) (match_dup 2))))]
11805   "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)
11806    && (TARGET_SHIFT1 || optimize_size)
11807    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11808   "sar{l}\t%k0"
11809   [(set_attr "type" "ishift")
11810    (set_attr "length" "2")])
11812 ;; This pattern can't accept a variable shift count, since shifts by
11813 ;; zero don't affect the flags.  We assume that shifts by constant
11814 ;; zero are optimized away.
11815 (define_insn "*ashrsi3_cmp"
11816   [(set (reg 17)
11817         (compare
11818           (ashiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
11819                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
11820           (const_int 0)))
11821    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
11822         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
11823   "ix86_match_ccmode (insn, CCGOCmode)
11824    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11825   "sar{l}\t{%2, %0|%0, %2}"
11826   [(set_attr "type" "ishift")
11827    (set_attr "mode" "SI")])
11829 (define_insn "*ashrsi3_cmp_zext"
11830   [(set (reg 17)
11831         (compare
11832           (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
11833                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
11834           (const_int 0)))
11835    (set (match_operand:DI 0 "register_operand" "=r")
11836         (zero_extend:DI (ashiftrt:SI (match_dup 1) (match_dup 2))))]
11837   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
11838    && ix86_binary_operator_ok (ASHIFTRT, SImode, operands)"
11839   "sar{l}\t{%2, %k0|%k0, %2}"
11840   [(set_attr "type" "ishift")
11841    (set_attr "mode" "SI")])
11843 (define_expand "ashrhi3"
11844   [(set (match_operand:HI 0 "nonimmediate_operand" "")
11845         (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "")
11846                      (match_operand:QI 2 "nonmemory_operand" "")))
11847    (clobber (reg:CC 17))]
11848   "TARGET_HIMODE_MATH"
11849   "ix86_expand_binary_operator (ASHIFTRT, HImode, operands); DONE;")
11851 (define_insn "*ashrhi3_1_one_bit"
11852   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11853         (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11854                      (match_operand:QI 2 "const_int_1_operand" "")))
11855    (clobber (reg:CC 17))]
11856   "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)
11857    && (TARGET_SHIFT1 || optimize_size)"
11858   "sar{w}\t%0"
11859   [(set_attr "type" "ishift")
11860    (set (attr "length") 
11861      (if_then_else (match_operand 0 "register_operand" "") 
11862         (const_string "2")
11863         (const_string "*")))])
11865 (define_insn "*ashrhi3_1"
11866   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
11867         (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
11868                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11869    (clobber (reg:CC 17))]
11870   "ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
11871   "@
11872    sar{w}\t{%2, %0|%0, %2}
11873    sar{w}\t{%b2, %0|%0, %b2}"
11874   [(set_attr "type" "ishift")
11875    (set_attr "mode" "HI")])
11877 ;; This pattern can't accept a variable shift count, since shifts by
11878 ;; zero don't affect the flags.  We assume that shifts by constant
11879 ;; zero are optimized away.
11880 (define_insn "*ashrhi3_one_bit_cmp"
11881   [(set (reg 17)
11882         (compare
11883           (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11884                        (match_operand:QI 2 "const_int_1_operand" ""))
11885           (const_int 0)))
11886    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11887         (ashiftrt:HI (match_dup 1) (match_dup 2)))]
11888   "ix86_match_ccmode (insn, CCGOCmode)
11889    && (TARGET_SHIFT1 || optimize_size)
11890    && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
11891   "sar{w}\t%0"
11892   [(set_attr "type" "ishift")
11893    (set (attr "length") 
11894      (if_then_else (match_operand 0 "register_operand" "") 
11895         (const_string "2")
11896         (const_string "*")))])
11898 ;; This pattern can't accept a variable shift count, since shifts by
11899 ;; zero don't affect the flags.  We assume that shifts by constant
11900 ;; zero are optimized away.
11901 (define_insn "*ashrhi3_cmp"
11902   [(set (reg 17)
11903         (compare
11904           (ashiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
11905                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
11906           (const_int 0)))
11907    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
11908         (ashiftrt:HI (match_dup 1) (match_dup 2)))]
11909   "ix86_match_ccmode (insn, CCGOCmode)
11910    && ix86_binary_operator_ok (ASHIFTRT, HImode, operands)"
11911   "sar{w}\t{%2, %0|%0, %2}"
11912   [(set_attr "type" "ishift")
11913    (set_attr "mode" "HI")])
11915 (define_expand "ashrqi3"
11916   [(set (match_operand:QI 0 "nonimmediate_operand" "")
11917         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "")
11918                      (match_operand:QI 2 "nonmemory_operand" "")))
11919    (clobber (reg:CC 17))]
11920   "TARGET_QIMODE_MATH"
11921   "ix86_expand_binary_operator (ASHIFTRT, QImode, operands); DONE;")
11923 (define_insn "*ashrqi3_1_one_bit"
11924   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11925         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11926                      (match_operand:QI 2 "const_int_1_operand" "")))
11927    (clobber (reg:CC 17))]
11928   "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)
11929    && (TARGET_SHIFT1 || optimize_size)"
11930   "sar{b}\t%0"
11931   [(set_attr "type" "ishift")
11932    (set (attr "length") 
11933      (if_then_else (match_operand 0 "register_operand" "") 
11934         (const_string "2")
11935         (const_string "*")))])
11937 (define_insn "*ashrqi3_1_one_bit_slp"
11938   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
11939         (ashiftrt:QI (match_dup 0)
11940                      (match_operand:QI 1 "const_int_1_operand" "")))
11941    (clobber (reg:CC 17))]
11942   "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)
11943    && (! TARGET_PARTIAL_REG_STALL || optimize_size)
11944    && (TARGET_SHIFT1 || optimize_size)"
11945   "sar{b}\t%0"
11946   [(set_attr "type" "ishift1")
11947    (set (attr "length") 
11948      (if_then_else (match_operand 0 "register_operand" "") 
11949         (const_string "2")
11950         (const_string "*")))])
11952 (define_insn "*ashrqi3_1"
11953   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
11954         (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
11955                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
11956    (clobber (reg:CC 17))]
11957   "ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
11958   "@
11959    sar{b}\t{%2, %0|%0, %2}
11960    sar{b}\t{%b2, %0|%0, %b2}"
11961   [(set_attr "type" "ishift")
11962    (set_attr "mode" "QI")])
11964 (define_insn "*ashrqi3_1_slp"
11965   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,qm"))
11966         (ashiftrt:QI (match_dup 0)
11967                      (match_operand:QI 1 "nonmemory_operand" "I,c")))
11968    (clobber (reg:CC 17))]
11969   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
11970    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
11971   "@
11972    sar{b}\t{%1, %0|%0, %1}
11973    sar{b}\t{%b1, %0|%0, %b1}"
11974   [(set_attr "type" "ishift1")
11975    (set_attr "mode" "QI")])
11977 ;; This pattern can't accept a variable shift count, since shifts by
11978 ;; zero don't affect the flags.  We assume that shifts by constant
11979 ;; zero are optimized away.
11980 (define_insn "*ashrqi3_one_bit_cmp"
11981   [(set (reg 17)
11982         (compare
11983           (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
11984                        (match_operand:QI 2 "const_int_1_operand" "I"))
11985           (const_int 0)))
11986    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
11987         (ashiftrt:QI (match_dup 1) (match_dup 2)))]
11988   "ix86_match_ccmode (insn, CCGOCmode)
11989    && (TARGET_SHIFT1 || optimize_size)
11990    && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
11991   "sar{b}\t%0"
11992   [(set_attr "type" "ishift")
11993    (set (attr "length") 
11994      (if_then_else (match_operand 0 "register_operand" "") 
11995         (const_string "2")
11996         (const_string "*")))])
11998 ;; This pattern can't accept a variable shift count, since shifts by
11999 ;; zero don't affect the flags.  We assume that shifts by constant
12000 ;; zero are optimized away.
12001 (define_insn "*ashrqi3_cmp"
12002   [(set (reg 17)
12003         (compare
12004           (ashiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12005                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
12006           (const_int 0)))
12007    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12008         (ashiftrt:QI (match_dup 1) (match_dup 2)))]
12009   "ix86_match_ccmode (insn, CCGOCmode)
12010    && ix86_binary_operator_ok (ASHIFTRT, QImode, operands)"
12011   "sar{b}\t{%2, %0|%0, %2}"
12012   [(set_attr "type" "ishift")
12013    (set_attr "mode" "QI")])
12015 ;; Logical shift instructions
12017 ;; See comment above `ashldi3' about how this works.
12019 (define_expand "lshrdi3"
12020   [(parallel [(set (match_operand:DI 0 "shiftdi_operand" "")
12021                    (lshiftrt:DI (match_operand:DI 1 "shiftdi_operand" "")
12022                                 (match_operand:QI 2 "nonmemory_operand" "")))
12023               (clobber (reg:CC 17))])]
12024   ""
12026   if (!TARGET_64BIT && TARGET_CMOVE && ! immediate_operand (operands[2], QImode))
12027     {
12028       emit_insn (gen_lshrdi3_1 (operands[0], operands[1], operands[2]));
12029       DONE;
12030     }
12031   ix86_expand_binary_operator (LSHIFTRT, DImode, operands);
12032   DONE;
12035 (define_insn "*lshrdi3_1_one_bit_rex64"
12036   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12037         (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12038                      (match_operand:QI 2 "const_int_1_operand" "")))
12039    (clobber (reg:CC 17))]
12040   "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
12041    && (TARGET_SHIFT1 || optimize_size)"
12042   "shr{q}\t%0"
12043   [(set_attr "type" "ishift")
12044    (set (attr "length") 
12045      (if_then_else (match_operand:DI 0 "register_operand" "") 
12046         (const_string "2")
12047         (const_string "*")))])
12049 (define_insn "*lshrdi3_1_rex64"
12050   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
12051         (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
12052                      (match_operand:QI 2 "nonmemory_operand" "J,c")))
12053    (clobber (reg:CC 17))]
12054   "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12055   "@
12056    shr{q}\t{%2, %0|%0, %2}
12057    shr{q}\t{%b2, %0|%0, %b2}"
12058   [(set_attr "type" "ishift")
12059    (set_attr "mode" "DI")])
12061 ;; This pattern can't accept a variable shift count, since shifts by
12062 ;; zero don't affect the flags.  We assume that shifts by constant
12063 ;; zero are optimized away.
12064 (define_insn "*lshrdi3_cmp_one_bit_rex64"
12065   [(set (reg 17)
12066         (compare
12067           (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12068                        (match_operand:QI 2 "const_int_1_operand" ""))
12069           (const_int 0)))
12070    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12071         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
12072   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
12073    && (TARGET_SHIFT1 || optimize_size)
12074    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12075   "shr{q}\t%0"
12076   [(set_attr "type" "ishift")
12077    (set (attr "length") 
12078      (if_then_else (match_operand:DI 0 "register_operand" "") 
12079         (const_string "2")
12080         (const_string "*")))])
12082 ;; This pattern can't accept a variable shift count, since shifts by
12083 ;; zero don't affect the flags.  We assume that shifts by constant
12084 ;; zero are optimized away.
12085 (define_insn "*lshrdi3_cmp_rex64"
12086   [(set (reg 17)
12087         (compare
12088           (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12089                        (match_operand:QI 2 "const_int_operand" "e"))
12090           (const_int 0)))
12091    (set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12092         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
12093   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
12094    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12095   "shr{q}\t{%2, %0|%0, %2}"
12096   [(set_attr "type" "ishift")
12097    (set_attr "mode" "DI")])
12099 (define_insn "lshrdi3_1"
12100   [(set (match_operand:DI 0 "register_operand" "=r")
12101         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
12102                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
12103    (clobber (match_scratch:SI 3 "=&r"))
12104    (clobber (reg:CC 17))]
12105   "!TARGET_64BIT && TARGET_CMOVE"
12106   "#"
12107   [(set_attr "type" "multi")])
12109 (define_insn "*lshrdi3_2"
12110   [(set (match_operand:DI 0 "register_operand" "=r")
12111         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
12112                      (match_operand:QI 2 "nonmemory_operand" "Jc")))
12113    (clobber (reg:CC 17))]
12114   "!TARGET_64BIT"
12115   "#"
12116   [(set_attr "type" "multi")])
12118 (define_split 
12119   [(set (match_operand:DI 0 "register_operand" "")
12120         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
12121                      (match_operand:QI 2 "nonmemory_operand" "")))
12122    (clobber (match_scratch:SI 3 ""))
12123    (clobber (reg:CC 17))]
12124   "!TARGET_64BIT && TARGET_CMOVE && reload_completed"
12125   [(const_int 0)]
12126   "ix86_split_lshrdi (operands, operands[3]); DONE;")
12128 (define_split 
12129   [(set (match_operand:DI 0 "register_operand" "")
12130         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
12131                      (match_operand:QI 2 "nonmemory_operand" "")))
12132    (clobber (reg:CC 17))]
12133   "!TARGET_64BIT && reload_completed"
12134   [(const_int 0)]
12135   "ix86_split_lshrdi (operands, NULL_RTX); DONE;")
12137 (define_expand "lshrsi3"
12138   [(set (match_operand:SI 0 "nonimmediate_operand" "")
12139         (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "")
12140                      (match_operand:QI 2 "nonmemory_operand" "")))
12141    (clobber (reg:CC 17))]
12142   ""
12143   "ix86_expand_binary_operator (LSHIFTRT, SImode, operands); DONE;")
12145 (define_insn "*lshrsi3_1_one_bit"
12146   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12147         (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12148                      (match_operand:QI 2 "const_int_1_operand" "")))
12149    (clobber (reg:CC 17))]
12150   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
12151    && (TARGET_SHIFT1 || optimize_size)"
12152   "shr{l}\t%0"
12153   [(set_attr "type" "ishift")
12154    (set (attr "length") 
12155      (if_then_else (match_operand:SI 0 "register_operand" "") 
12156         (const_string "2")
12157         (const_string "*")))])
12159 (define_insn "*lshrsi3_1_one_bit_zext"
12160   [(set (match_operand:DI 0 "register_operand" "=r")
12161         (lshiftrt:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "0"))
12162                      (match_operand:QI 2 "const_int_1_operand" "")))
12163    (clobber (reg:CC 17))]
12164   "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
12165    && (TARGET_SHIFT1 || optimize_size)"
12166   "shr{l}\t%k0"
12167   [(set_attr "type" "ishift")
12168    (set_attr "length" "2")])
12170 (define_insn "*lshrsi3_1"
12171   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
12172         (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12173                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12174    (clobber (reg:CC 17))]
12175   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12176   "@
12177    shr{l}\t{%2, %0|%0, %2}
12178    shr{l}\t{%b2, %0|%0, %b2}"
12179   [(set_attr "type" "ishift")
12180    (set_attr "mode" "SI")])
12182 (define_insn "*lshrsi3_1_zext"
12183   [(set (match_operand:DI 0 "register_operand" "=r,r")
12184         (zero_extend:DI
12185           (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12186                        (match_operand:QI 2 "nonmemory_operand" "I,c"))))
12187    (clobber (reg:CC 17))]
12188   "TARGET_64BIT && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12189   "@
12190    shr{l}\t{%2, %k0|%k0, %2}
12191    shr{l}\t{%b2, %k0|%k0, %b2}"
12192   [(set_attr "type" "ishift")
12193    (set_attr "mode" "SI")])
12195 ;; This pattern can't accept a variable shift count, since shifts by
12196 ;; zero don't affect the flags.  We assume that shifts by constant
12197 ;; zero are optimized away.
12198 (define_insn "*lshrsi3_one_bit_cmp"
12199   [(set (reg 17)
12200         (compare
12201           (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12202                        (match_operand:QI 2 "const_int_1_operand" ""))
12203           (const_int 0)))
12204    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12205         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
12206   "ix86_match_ccmode (insn, CCGOCmode)
12207    && (TARGET_SHIFT1 || optimize_size)
12208    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12209   "shr{l}\t%0"
12210   [(set_attr "type" "ishift")
12211    (set (attr "length") 
12212      (if_then_else (match_operand:SI 0 "register_operand" "") 
12213         (const_string "2")
12214         (const_string "*")))])
12216 (define_insn "*lshrsi3_cmp_one_bit_zext"
12217   [(set (reg 17)
12218         (compare
12219           (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
12220                        (match_operand:QI 2 "const_int_1_operand" ""))
12221           (const_int 0)))
12222    (set (match_operand:DI 0 "register_operand" "=r")
12223         (lshiftrt:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
12224   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
12225    && (TARGET_SHIFT1 || optimize_size)
12226    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12227   "shr{l}\t%k0"
12228   [(set_attr "type" "ishift")
12229    (set_attr "length" "2")])
12231 ;; This pattern can't accept a variable shift count, since shifts by
12232 ;; zero don't affect the flags.  We assume that shifts by constant
12233 ;; zero are optimized away.
12234 (define_insn "*lshrsi3_cmp"
12235   [(set (reg 17)
12236         (compare
12237           (lshiftrt:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12238                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
12239           (const_int 0)))
12240    (set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12241         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
12242   "ix86_match_ccmode (insn, CCGOCmode)
12243    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12244   "shr{l}\t{%2, %0|%0, %2}"
12245   [(set_attr "type" "ishift")
12246    (set_attr "mode" "SI")])
12248 (define_insn "*lshrsi3_cmp_zext"
12249   [(set (reg 17)
12250         (compare
12251           (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
12252                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
12253           (const_int 0)))
12254    (set (match_operand:DI 0 "register_operand" "=r")
12255         (lshiftrt:DI (zero_extend:DI (match_dup 1)) (match_dup 2)))]
12256   "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)
12257    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12258   "shr{l}\t{%2, %k0|%k0, %2}"
12259   [(set_attr "type" "ishift")
12260    (set_attr "mode" "SI")])
12262 (define_expand "lshrhi3"
12263   [(set (match_operand:HI 0 "nonimmediate_operand" "")
12264         (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "")
12265                      (match_operand:QI 2 "nonmemory_operand" "")))
12266    (clobber (reg:CC 17))]
12267   "TARGET_HIMODE_MATH"
12268   "ix86_expand_binary_operator (LSHIFTRT, HImode, operands); DONE;")
12270 (define_insn "*lshrhi3_1_one_bit"
12271   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12272         (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12273                      (match_operand:QI 2 "const_int_1_operand" "")))
12274    (clobber (reg:CC 17))]
12275   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)
12276    && (TARGET_SHIFT1 || optimize_size)"
12277   "shr{w}\t%0"
12278   [(set_attr "type" "ishift")
12279    (set (attr "length") 
12280      (if_then_else (match_operand 0 "register_operand" "") 
12281         (const_string "2")
12282         (const_string "*")))])
12284 (define_insn "*lshrhi3_1"
12285   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12286         (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12287                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12288    (clobber (reg:CC 17))]
12289   "ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12290   "@
12291    shr{w}\t{%2, %0|%0, %2}
12292    shr{w}\t{%b2, %0|%0, %b2}"
12293   [(set_attr "type" "ishift")
12294    (set_attr "mode" "HI")])
12296 ;; This pattern can't accept a variable shift count, since shifts by
12297 ;; zero don't affect the flags.  We assume that shifts by constant
12298 ;; zero are optimized away.
12299 (define_insn "*lshrhi3_one_bit_cmp"
12300   [(set (reg 17)
12301         (compare
12302           (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12303                        (match_operand:QI 2 "const_int_1_operand" ""))
12304           (const_int 0)))
12305    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12306         (lshiftrt:HI (match_dup 1) (match_dup 2)))]
12307   "ix86_match_ccmode (insn, CCGOCmode)
12308    && (TARGET_SHIFT1 || optimize_size)
12309    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12310   "shr{w}\t%0"
12311   [(set_attr "type" "ishift")
12312    (set (attr "length") 
12313      (if_then_else (match_operand:SI 0 "register_operand" "") 
12314         (const_string "2")
12315         (const_string "*")))])
12317 ;; This pattern can't accept a variable shift count, since shifts by
12318 ;; zero don't affect the flags.  We assume that shifts by constant
12319 ;; zero are optimized away.
12320 (define_insn "*lshrhi3_cmp"
12321   [(set (reg 17)
12322         (compare
12323           (lshiftrt:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12324                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
12325           (const_int 0)))
12326    (set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12327         (lshiftrt:HI (match_dup 1) (match_dup 2)))]
12328   "ix86_match_ccmode (insn, CCGOCmode)
12329    && ix86_binary_operator_ok (LSHIFTRT, HImode, operands)"
12330   "shr{w}\t{%2, %0|%0, %2}"
12331   [(set_attr "type" "ishift")
12332    (set_attr "mode" "HI")])
12334 (define_expand "lshrqi3"
12335   [(set (match_operand:QI 0 "nonimmediate_operand" "")
12336         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "")
12337                      (match_operand:QI 2 "nonmemory_operand" "")))
12338    (clobber (reg:CC 17))]
12339   "TARGET_QIMODE_MATH"
12340   "ix86_expand_binary_operator (LSHIFTRT, QImode, operands); DONE;")
12342 (define_insn "*lshrqi3_1_one_bit"
12343   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12344         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12345                      (match_operand:QI 2 "const_int_1_operand" "")))
12346    (clobber (reg:CC 17))]
12347   "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)
12348    && (TARGET_SHIFT1 || optimize_size)"
12349   "shr{b}\t%0"
12350   [(set_attr "type" "ishift")
12351    (set (attr "length") 
12352      (if_then_else (match_operand 0 "register_operand" "") 
12353         (const_string "2")
12354         (const_string "*")))])
12356 (define_insn "*lshrqi3_1_one_bit_slp"
12357   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
12358         (lshiftrt:QI (match_dup 0)
12359                      (match_operand:QI 1 "const_int_1_operand" "")))
12360    (clobber (reg:CC 17))]
12361   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
12362    && (TARGET_SHIFT1 || optimize_size)"
12363   "shr{b}\t%0"
12364   [(set_attr "type" "ishift1")
12365    (set (attr "length") 
12366      (if_then_else (match_operand 0 "register_operand" "") 
12367         (const_string "2")
12368         (const_string "*")))])
12370 (define_insn "*lshrqi3_1"
12371   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12372         (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12373                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12374    (clobber (reg:CC 17))]
12375   "ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
12376   "@
12377    shr{b}\t{%2, %0|%0, %2}
12378    shr{b}\t{%b2, %0|%0, %b2}"
12379   [(set_attr "type" "ishift")
12380    (set_attr "mode" "QI")])
12382 (define_insn "*lshrqi3_1_slp"
12383   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,qm"))
12384         (lshiftrt:QI (match_dup 0)
12385                      (match_operand:QI 1 "nonmemory_operand" "I,c")))
12386    (clobber (reg:CC 17))]
12387   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
12388    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
12389   "@
12390    shr{b}\t{%1, %0|%0, %1}
12391    shr{b}\t{%b1, %0|%0, %b1}"
12392   [(set_attr "type" "ishift1")
12393    (set_attr "mode" "QI")])
12395 ;; This pattern can't accept a variable shift count, since shifts by
12396 ;; zero don't affect the flags.  We assume that shifts by constant
12397 ;; zero are optimized away.
12398 (define_insn "*lshrqi2_one_bit_cmp"
12399   [(set (reg 17)
12400         (compare
12401           (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12402                        (match_operand:QI 2 "const_int_1_operand" ""))
12403           (const_int 0)))
12404    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12405         (lshiftrt:QI (match_dup 1) (match_dup 2)))]
12406   "ix86_match_ccmode (insn, CCGOCmode)
12407    && (TARGET_SHIFT1 || optimize_size)
12408    && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
12409   "shr{b}\t%0"
12410   [(set_attr "type" "ishift")
12411    (set (attr "length") 
12412      (if_then_else (match_operand:SI 0 "register_operand" "") 
12413         (const_string "2")
12414         (const_string "*")))])
12416 ;; This pattern can't accept a variable shift count, since shifts by
12417 ;; zero don't affect the flags.  We assume that shifts by constant
12418 ;; zero are optimized away.
12419 (define_insn "*lshrqi2_cmp"
12420   [(set (reg 17)
12421         (compare
12422           (lshiftrt:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12423                        (match_operand:QI 2 "const_int_1_31_operand" "I"))
12424           (const_int 0)))
12425    (set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12426         (lshiftrt:QI (match_dup 1) (match_dup 2)))]
12427   "ix86_match_ccmode (insn, CCGOCmode)
12428    && ix86_binary_operator_ok (LSHIFTRT, QImode, operands)"
12429   "shr{b}\t{%2, %0|%0, %2}"
12430   [(set_attr "type" "ishift")
12431    (set_attr "mode" "QI")])
12433 ;; Rotate instructions
12435 (define_expand "rotldi3"
12436   [(set (match_operand:DI 0 "nonimmediate_operand" "")
12437         (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "")
12438                    (match_operand:QI 2 "nonmemory_operand" "")))
12439    (clobber (reg:CC 17))]
12440   "TARGET_64BIT"
12441   "ix86_expand_binary_operator (ROTATE, DImode, operands); DONE;")
12443 (define_insn "*rotlsi3_1_one_bit_rex64"
12444   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12445         (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12446                    (match_operand:QI 2 "const_int_1_operand" "")))
12447    (clobber (reg:CC 17))]
12448   "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, DImode, operands)
12449    && (TARGET_SHIFT1 || optimize_size)"
12450   "rol{q}\t%0"
12451   [(set_attr "type" "rotate")
12452    (set (attr "length") 
12453      (if_then_else (match_operand:DI 0 "register_operand" "") 
12454         (const_string "2")
12455         (const_string "*")))])
12457 (define_insn "*rotldi3_1_rex64"
12458   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
12459         (rotate:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
12460                    (match_operand:QI 2 "nonmemory_operand" "e,c")))
12461    (clobber (reg:CC 17))]
12462   "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, DImode, operands)"
12463   "@
12464    rol{q}\t{%2, %0|%0, %2}
12465    rol{q}\t{%b2, %0|%0, %b2}"
12466   [(set_attr "type" "rotate")
12467    (set_attr "mode" "DI")])
12469 (define_expand "rotlsi3"
12470   [(set (match_operand:SI 0 "nonimmediate_operand" "")
12471         (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "")
12472                    (match_operand:QI 2 "nonmemory_operand" "")))
12473    (clobber (reg:CC 17))]
12474   ""
12475   "ix86_expand_binary_operator (ROTATE, SImode, operands); DONE;")
12477 (define_insn "*rotlsi3_1_one_bit"
12478   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12479         (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12480                    (match_operand:QI 2 "const_int_1_operand" "")))
12481    (clobber (reg:CC 17))]
12482   "ix86_binary_operator_ok (ROTATE, SImode, operands)
12483    && (TARGET_SHIFT1 || optimize_size)"
12484   "rol{l}\t%0"
12485   [(set_attr "type" "rotate")
12486    (set (attr "length") 
12487      (if_then_else (match_operand:SI 0 "register_operand" "") 
12488         (const_string "2")
12489         (const_string "*")))])
12491 (define_insn "*rotlsi3_1_one_bit_zext"
12492   [(set (match_operand:DI 0 "register_operand" "=r")
12493         (zero_extend:DI
12494           (rotate:SI (match_operand:SI 1 "register_operand" "0")
12495                      (match_operand:QI 2 "const_int_1_operand" ""))))
12496    (clobber (reg:CC 17))]
12497   "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, SImode, operands)
12498    && (TARGET_SHIFT1 || optimize_size)"
12499   "rol{l}\t%k0"
12500   [(set_attr "type" "rotate")
12501    (set_attr "length" "2")])
12503 (define_insn "*rotlsi3_1"
12504   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
12505         (rotate:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12506                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
12507    (clobber (reg:CC 17))]
12508   "ix86_binary_operator_ok (ROTATE, SImode, operands)"
12509   "@
12510    rol{l}\t{%2, %0|%0, %2}
12511    rol{l}\t{%b2, %0|%0, %b2}"
12512   [(set_attr "type" "rotate")
12513    (set_attr "mode" "SI")])
12515 (define_insn "*rotlsi3_1_zext"
12516   [(set (match_operand:DI 0 "register_operand" "=r,r")
12517         (zero_extend:DI
12518           (rotate:SI (match_operand:SI 1 "register_operand" "0,0")
12519                      (match_operand:QI 2 "nonmemory_operand" "I,c"))))
12520    (clobber (reg:CC 17))]
12521   "TARGET_64BIT && ix86_binary_operator_ok (ROTATE, SImode, operands)"
12522   "@
12523    rol{l}\t{%2, %k0|%k0, %2}
12524    rol{l}\t{%b2, %k0|%k0, %b2}"
12525   [(set_attr "type" "rotate")
12526    (set_attr "mode" "SI")])
12528 (define_expand "rotlhi3"
12529   [(set (match_operand:HI 0 "nonimmediate_operand" "")
12530         (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "")
12531                    (match_operand:QI 2 "nonmemory_operand" "")))
12532    (clobber (reg:CC 17))]
12533   "TARGET_HIMODE_MATH"
12534   "ix86_expand_binary_operator (ROTATE, HImode, operands); DONE;")
12536 (define_insn "*rotlhi3_1_one_bit"
12537   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12538         (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12539                    (match_operand:QI 2 "const_int_1_operand" "")))
12540    (clobber (reg:CC 17))]
12541   "ix86_binary_operator_ok (ROTATE, HImode, operands)
12542    && (TARGET_SHIFT1 || optimize_size)"
12543   "rol{w}\t%0"
12544   [(set_attr "type" "rotate")
12545    (set (attr "length") 
12546      (if_then_else (match_operand 0 "register_operand" "") 
12547         (const_string "2")
12548         (const_string "*")))])
12550 (define_insn "*rotlhi3_1"
12551   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12552         (rotate:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12553                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
12554    (clobber (reg:CC 17))]
12555   "ix86_binary_operator_ok (ROTATE, HImode, operands)"
12556   "@
12557    rol{w}\t{%2, %0|%0, %2}
12558    rol{w}\t{%b2, %0|%0, %b2}"
12559   [(set_attr "type" "rotate")
12560    (set_attr "mode" "HI")])
12562 (define_expand "rotlqi3"
12563   [(set (match_operand:QI 0 "nonimmediate_operand" "")
12564         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "")
12565                    (match_operand:QI 2 "nonmemory_operand" "")))
12566    (clobber (reg:CC 17))]
12567   "TARGET_QIMODE_MATH"
12568   "ix86_expand_binary_operator (ROTATE, QImode, operands); DONE;")
12570 (define_insn "*rotlqi3_1_one_bit_slp"
12571   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
12572         (rotate:QI (match_dup 0)
12573                    (match_operand:QI 1 "const_int_1_operand" "")))
12574    (clobber (reg:CC 17))]
12575   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
12576    && (TARGET_SHIFT1 || optimize_size)"
12577   "rol{b}\t%0"
12578   [(set_attr "type" "rotate1")
12579    (set (attr "length") 
12580      (if_then_else (match_operand 0 "register_operand" "") 
12581         (const_string "2")
12582         (const_string "*")))])
12584 (define_insn "*rotlqi3_1_one_bit"
12585   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12586         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12587                    (match_operand:QI 2 "const_int_1_operand" "")))
12588    (clobber (reg:CC 17))]
12589   "ix86_binary_operator_ok (ROTATE, QImode, operands)
12590    && (TARGET_SHIFT1 || optimize_size)"
12591   "rol{b}\t%0"
12592   [(set_attr "type" "rotate")
12593    (set (attr "length") 
12594      (if_then_else (match_operand 0 "register_operand" "") 
12595         (const_string "2")
12596         (const_string "*")))])
12598 (define_insn "*rotlqi3_1_slp"
12599   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,qm"))
12600         (rotate:QI (match_dup 0)
12601                    (match_operand:QI 1 "nonmemory_operand" "I,c")))
12602    (clobber (reg:CC 17))]
12603   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
12604    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
12605   "@
12606    rol{b}\t{%1, %0|%0, %1}
12607    rol{b}\t{%b1, %0|%0, %b1}"
12608   [(set_attr "type" "rotate1")
12609    (set_attr "mode" "QI")])
12611 (define_insn "*rotlqi3_1"
12612   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12613         (rotate:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12614                    (match_operand:QI 2 "nonmemory_operand" "I,c")))
12615    (clobber (reg:CC 17))]
12616   "ix86_binary_operator_ok (ROTATE, QImode, operands)"
12617   "@
12618    rol{b}\t{%2, %0|%0, %2}
12619    rol{b}\t{%b2, %0|%0, %b2}"
12620   [(set_attr "type" "rotate")
12621    (set_attr "mode" "QI")])
12623 (define_expand "rotrdi3"
12624   [(set (match_operand:DI 0 "nonimmediate_operand" "")
12625         (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "")
12626                      (match_operand:QI 2 "nonmemory_operand" "")))
12627    (clobber (reg:CC 17))]
12628   "TARGET_64BIT"
12629   "ix86_expand_binary_operator (ROTATERT, DImode, operands); DONE;")
12631 (define_insn "*rotrdi3_1_one_bit_rex64"
12632   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
12633         (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "0")
12634                      (match_operand:QI 2 "const_int_1_operand" "")))
12635    (clobber (reg:CC 17))]
12636   "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, DImode, operands)
12637    && (TARGET_SHIFT1 || optimize_size)"
12638   "ror{q}\t%0"
12639   [(set_attr "type" "rotate")
12640    (set (attr "length") 
12641      (if_then_else (match_operand:DI 0 "register_operand" "") 
12642         (const_string "2")
12643         (const_string "*")))])
12645 (define_insn "*rotrdi3_1_rex64"
12646   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,rm")
12647         (rotatert:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
12648                      (match_operand:QI 2 "nonmemory_operand" "J,c")))
12649    (clobber (reg:CC 17))]
12650   "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, DImode, operands)"
12651   "@
12652    ror{q}\t{%2, %0|%0, %2}
12653    ror{q}\t{%b2, %0|%0, %b2}"
12654   [(set_attr "type" "rotate")
12655    (set_attr "mode" "DI")])
12657 (define_expand "rotrsi3"
12658   [(set (match_operand:SI 0 "nonimmediate_operand" "")
12659         (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "")
12660                      (match_operand:QI 2 "nonmemory_operand" "")))
12661    (clobber (reg:CC 17))]
12662   ""
12663   "ix86_expand_binary_operator (ROTATERT, SImode, operands); DONE;")
12665 (define_insn "*rotrsi3_1_one_bit"
12666   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
12667         (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0")
12668                      (match_operand:QI 2 "const_int_1_operand" "")))
12669    (clobber (reg:CC 17))]
12670   "ix86_binary_operator_ok (ROTATERT, SImode, operands)
12671    && (TARGET_SHIFT1 || optimize_size)"
12672   "ror{l}\t%0"
12673   [(set_attr "type" "rotate")
12674    (set (attr "length") 
12675      (if_then_else (match_operand:SI 0 "register_operand" "") 
12676         (const_string "2")
12677         (const_string "*")))])
12679 (define_insn "*rotrsi3_1_one_bit_zext"
12680   [(set (match_operand:DI 0 "register_operand" "=r")
12681         (zero_extend:DI
12682           (rotatert:SI (match_operand:SI 1 "register_operand" "0")
12683                        (match_operand:QI 2 "const_int_1_operand" ""))))
12684    (clobber (reg:CC 17))]
12685   "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, SImode, operands)
12686    && (TARGET_SHIFT1 || optimize_size)"
12687   "ror{l}\t%k0"
12688   [(set_attr "type" "rotate")
12689    (set (attr "length") 
12690      (if_then_else (match_operand:SI 0 "register_operand" "") 
12691         (const_string "2")
12692         (const_string "*")))])
12694 (define_insn "*rotrsi3_1"
12695   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,rm")
12696         (rotatert:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
12697                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12698    (clobber (reg:CC 17))]
12699   "ix86_binary_operator_ok (ROTATERT, SImode, operands)"
12700   "@
12701    ror{l}\t{%2, %0|%0, %2}
12702    ror{l}\t{%b2, %0|%0, %b2}"
12703   [(set_attr "type" "rotate")
12704    (set_attr "mode" "SI")])
12706 (define_insn "*rotrsi3_1_zext"
12707   [(set (match_operand:DI 0 "register_operand" "=r,r")
12708         (zero_extend:DI
12709           (rotatert:SI (match_operand:SI 1 "register_operand" "0,0")
12710                        (match_operand:QI 2 "nonmemory_operand" "I,c"))))
12711    (clobber (reg:CC 17))]
12712   "TARGET_64BIT && ix86_binary_operator_ok (ROTATERT, SImode, operands)"
12713   "@
12714    ror{l}\t{%2, %k0|%k0, %2}
12715    ror{l}\t{%b2, %k0|%k0, %b2}"
12716   [(set_attr "type" "rotate")
12717    (set_attr "mode" "SI")])
12719 (define_expand "rotrhi3"
12720   [(set (match_operand:HI 0 "nonimmediate_operand" "")
12721         (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "")
12722                      (match_operand:QI 2 "nonmemory_operand" "")))
12723    (clobber (reg:CC 17))]
12724   "TARGET_HIMODE_MATH"
12725   "ix86_expand_binary_operator (ROTATERT, HImode, operands); DONE;")
12727 (define_insn "*rotrhi3_one_bit"
12728   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
12729         (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0")
12730                      (match_operand:QI 2 "const_int_1_operand" "")))
12731    (clobber (reg:CC 17))]
12732   "ix86_binary_operator_ok (ROTATERT, HImode, operands)
12733    && (TARGET_SHIFT1 || optimize_size)"
12734   "ror{w}\t%0"
12735   [(set_attr "type" "rotate")
12736    (set (attr "length") 
12737      (if_then_else (match_operand 0 "register_operand" "") 
12738         (const_string "2")
12739         (const_string "*")))])
12741 (define_insn "*rotrhi3"
12742   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,rm")
12743         (rotatert:HI (match_operand:HI 1 "nonimmediate_operand" "0,0")
12744                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12745    (clobber (reg:CC 17))]
12746   "ix86_binary_operator_ok (ROTATERT, HImode, operands)"
12747   "@
12748    ror{w}\t{%2, %0|%0, %2}
12749    ror{w}\t{%b2, %0|%0, %b2}"
12750   [(set_attr "type" "rotate")
12751    (set_attr "mode" "HI")])
12753 (define_expand "rotrqi3"
12754   [(set (match_operand:QI 0 "nonimmediate_operand" "")
12755         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "")
12756                      (match_operand:QI 2 "nonmemory_operand" "")))
12757    (clobber (reg:CC 17))]
12758   "TARGET_QIMODE_MATH"
12759   "ix86_expand_binary_operator (ROTATERT, QImode, operands); DONE;")
12761 (define_insn "*rotrqi3_1_one_bit"
12762   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12763         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0")
12764                      (match_operand:QI 2 "const_int_1_operand" "")))
12765    (clobber (reg:CC 17))]
12766   "ix86_binary_operator_ok (ROTATERT, QImode, operands)
12767    && (TARGET_SHIFT1 || optimize_size)"
12768   "ror{b}\t%0"
12769   [(set_attr "type" "rotate")
12770    (set (attr "length") 
12771      (if_then_else (match_operand 0 "register_operand" "") 
12772         (const_string "2")
12773         (const_string "*")))])
12775 (define_insn "*rotrqi3_1_one_bit_slp"
12776   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
12777         (rotatert:QI (match_dup 0)
12778                      (match_operand:QI 1 "const_int_1_operand" "")))
12779    (clobber (reg:CC 17))]
12780   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
12781    && (TARGET_SHIFT1 || optimize_size)"
12782   "ror{b}\t%0"
12783   [(set_attr "type" "rotate1")
12784    (set (attr "length") 
12785      (if_then_else (match_operand 0 "register_operand" "") 
12786         (const_string "2")
12787         (const_string "*")))])
12789 (define_insn "*rotrqi3_1"
12790   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,qm")
12791         (rotatert:QI (match_operand:QI 1 "nonimmediate_operand" "0,0")
12792                      (match_operand:QI 2 "nonmemory_operand" "I,c")))
12793    (clobber (reg:CC 17))]
12794   "ix86_binary_operator_ok (ROTATERT, QImode, operands)"
12795   "@
12796    ror{b}\t{%2, %0|%0, %2}
12797    ror{b}\t{%b2, %0|%0, %b2}"
12798   [(set_attr "type" "rotate")
12799    (set_attr "mode" "QI")])
12801 (define_insn "*rotrqi3_1_slp"
12802   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,qm"))
12803         (rotatert:QI (match_dup 0)
12804                      (match_operand:QI 1 "nonmemory_operand" "I,c")))
12805    (clobber (reg:CC 17))]
12806   "(! TARGET_PARTIAL_REG_STALL || optimize_size)
12807    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
12808   "@
12809    ror{b}\t{%1, %0|%0, %1}
12810    ror{b}\t{%b1, %0|%0, %b1}"
12811   [(set_attr "type" "rotate1")
12812    (set_attr "mode" "QI")])
12814 ;; Bit set / bit test instructions
12816 (define_expand "extv"
12817   [(set (match_operand:SI 0 "register_operand" "")
12818         (sign_extract:SI (match_operand:SI 1 "register_operand" "")
12819                          (match_operand:SI 2 "immediate_operand" "")
12820                          (match_operand:SI 3 "immediate_operand" "")))]
12821   ""
12823   /* Handle extractions from %ah et al.  */
12824   if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8)
12825     FAIL;
12827   /* From mips.md: extract_bit_field doesn't verify that our source
12828      matches the predicate, so check it again here.  */
12829   if (! register_operand (operands[1], VOIDmode))
12830     FAIL;
12833 (define_expand "extzv"
12834   [(set (match_operand:SI 0 "register_operand" "")
12835         (zero_extract:SI (match_operand 1 "ext_register_operand" "")
12836                          (match_operand:SI 2 "immediate_operand" "")
12837                          (match_operand:SI 3 "immediate_operand" "")))]
12838   ""
12840   /* Handle extractions from %ah et al.  */
12841   if (INTVAL (operands[2]) != 8 || INTVAL (operands[3]) != 8)
12842     FAIL;
12844   /* From mips.md: extract_bit_field doesn't verify that our source
12845      matches the predicate, so check it again here.  */
12846   if (! register_operand (operands[1], VOIDmode))
12847     FAIL;
12850 (define_expand "insv"
12851   [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "")
12852                          (match_operand:SI 1 "immediate_operand" "")
12853                          (match_operand:SI 2 "immediate_operand" ""))
12854         (match_operand:SI 3 "register_operand" ""))]
12855   ""
12857   /* Handle extractions from %ah et al.  */
12858   if (INTVAL (operands[1]) != 8 || INTVAL (operands[2]) != 8)
12859     FAIL;
12861   /* From mips.md: insert_bit_field doesn't verify that our source
12862      matches the predicate, so check it again here.  */
12863   if (! register_operand (operands[0], VOIDmode))
12864     FAIL;
12867 ;; %%% bts, btr, btc, bt.
12869 ;; Store-flag instructions.
12871 ;; For all sCOND expanders, also expand the compare or test insn that
12872 ;; generates cc0.  Generate an equality comparison if `seq' or `sne'.
12874 ;; %%% Do the expansion to SImode.  If PII, do things the xor+setcc way
12875 ;; to avoid partial register stalls.  Otherwise do things the setcc+movzx
12876 ;; way, which can later delete the movzx if only QImode is needed.
12878 (define_expand "seq"
12879   [(set (match_operand:QI 0 "register_operand" "")
12880         (eq:QI (reg:CC 17) (const_int 0)))]
12881   ""
12882   "if (ix86_expand_setcc (EQ, operands[0])) DONE; else FAIL;")
12884 (define_expand "sne"
12885   [(set (match_operand:QI 0 "register_operand" "")
12886         (ne:QI (reg:CC 17) (const_int 0)))]
12887   ""
12888   "if (ix86_expand_setcc (NE, operands[0])) DONE; else FAIL;")
12890 (define_expand "sgt"
12891   [(set (match_operand:QI 0 "register_operand" "")
12892         (gt:QI (reg:CC 17) (const_int 0)))]
12893   ""
12894   "if (ix86_expand_setcc (GT, operands[0])) DONE; else FAIL;")
12896 (define_expand "sgtu"
12897   [(set (match_operand:QI 0 "register_operand" "")
12898         (gtu:QI (reg:CC 17) (const_int 0)))]
12899   ""
12900   "if (ix86_expand_setcc (GTU, operands[0])) DONE; else FAIL;")
12902 (define_expand "slt"
12903   [(set (match_operand:QI 0 "register_operand" "")
12904         (lt:QI (reg:CC 17) (const_int 0)))]
12905   ""
12906   "if (ix86_expand_setcc (LT, operands[0])) DONE; else FAIL;")
12908 (define_expand "sltu"
12909   [(set (match_operand:QI 0 "register_operand" "")
12910         (ltu:QI (reg:CC 17) (const_int 0)))]
12911   ""
12912   "if (ix86_expand_setcc (LTU, operands[0])) DONE; else FAIL;")
12914 (define_expand "sge"
12915   [(set (match_operand:QI 0 "register_operand" "")
12916         (ge:QI (reg:CC 17) (const_int 0)))]
12917   ""
12918   "if (ix86_expand_setcc (GE, operands[0])) DONE; else FAIL;")
12920 (define_expand "sgeu"
12921   [(set (match_operand:QI 0 "register_operand" "")
12922         (geu:QI (reg:CC 17) (const_int 0)))]
12923   ""
12924   "if (ix86_expand_setcc (GEU, operands[0])) DONE; else FAIL;")
12926 (define_expand "sle"
12927   [(set (match_operand:QI 0 "register_operand" "")
12928         (le:QI (reg:CC 17) (const_int 0)))]
12929   ""
12930   "if (ix86_expand_setcc (LE, operands[0])) DONE; else FAIL;")
12932 (define_expand "sleu"
12933   [(set (match_operand:QI 0 "register_operand" "")
12934         (leu:QI (reg:CC 17) (const_int 0)))]
12935   ""
12936   "if (ix86_expand_setcc (LEU, operands[0])) DONE; else FAIL;")
12938 (define_expand "sunordered"
12939   [(set (match_operand:QI 0 "register_operand" "")
12940         (unordered:QI (reg:CC 17) (const_int 0)))]
12941   "TARGET_80387 || TARGET_SSE"
12942   "if (ix86_expand_setcc (UNORDERED, operands[0])) DONE; else FAIL;")
12944 (define_expand "sordered"
12945   [(set (match_operand:QI 0 "register_operand" "")
12946         (ordered:QI (reg:CC 17) (const_int 0)))]
12947   "TARGET_80387"
12948   "if (ix86_expand_setcc (ORDERED, operands[0])) DONE; else FAIL;")
12950 (define_expand "suneq"
12951   [(set (match_operand:QI 0 "register_operand" "")
12952         (uneq:QI (reg:CC 17) (const_int 0)))]
12953   "TARGET_80387 || TARGET_SSE"
12954   "if (ix86_expand_setcc (UNEQ, operands[0])) DONE; else FAIL;")
12956 (define_expand "sunge"
12957   [(set (match_operand:QI 0 "register_operand" "")
12958         (unge:QI (reg:CC 17) (const_int 0)))]
12959   "TARGET_80387 || TARGET_SSE"
12960   "if (ix86_expand_setcc (UNGE, operands[0])) DONE; else FAIL;")
12962 (define_expand "sungt"
12963   [(set (match_operand:QI 0 "register_operand" "")
12964         (ungt:QI (reg:CC 17) (const_int 0)))]
12965   "TARGET_80387 || TARGET_SSE"
12966   "if (ix86_expand_setcc (UNGT, operands[0])) DONE; else FAIL;")
12968 (define_expand "sunle"
12969   [(set (match_operand:QI 0 "register_operand" "")
12970         (unle:QI (reg:CC 17) (const_int 0)))]
12971   "TARGET_80387 || TARGET_SSE"
12972   "if (ix86_expand_setcc (UNLE, operands[0])) DONE; else FAIL;")
12974 (define_expand "sunlt"
12975   [(set (match_operand:QI 0 "register_operand" "")
12976         (unlt:QI (reg:CC 17) (const_int 0)))]
12977   "TARGET_80387 || TARGET_SSE"
12978   "if (ix86_expand_setcc (UNLT, operands[0])) DONE; else FAIL;")
12980 (define_expand "sltgt"
12981   [(set (match_operand:QI 0 "register_operand" "")
12982         (ltgt:QI (reg:CC 17) (const_int 0)))]
12983   "TARGET_80387 || TARGET_SSE"
12984   "if (ix86_expand_setcc (LTGT, operands[0])) DONE; else FAIL;")
12986 (define_insn "*setcc_1"
12987   [(set (match_operand:QI 0 "nonimmediate_operand" "=qm")
12988         (match_operator:QI 1 "ix86_comparison_operator"
12989           [(reg 17) (const_int 0)]))]
12990   ""
12991   "set%C1\t%0"
12992   [(set_attr "type" "setcc")
12993    (set_attr "mode" "QI")])
12995 (define_insn "setcc_2"
12996   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm"))
12997         (match_operator:QI 1 "ix86_comparison_operator"
12998           [(reg 17) (const_int 0)]))]
12999   ""
13000   "set%C1\t%0"
13001   [(set_attr "type" "setcc")
13002    (set_attr "mode" "QI")])
13004 ;; In general it is not safe to assume too much about CCmode registers,
13005 ;; so simplify-rtx stops when it sees a second one.  Under certain 
13006 ;; conditions this is safe on x86, so help combine not create
13008 ;;      seta    %al
13009 ;;      testb   %al, %al
13010 ;;      sete    %al
13012 (define_split 
13013   [(set (match_operand:QI 0 "nonimmediate_operand" "")
13014         (ne:QI (match_operator 1 "ix86_comparison_operator"
13015                  [(reg 17) (const_int 0)])
13016             (const_int 0)))]
13017   ""
13018   [(set (match_dup 0) (match_dup 1))]
13020   PUT_MODE (operands[1], QImode);
13023 (define_split 
13024   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
13025         (ne:QI (match_operator 1 "ix86_comparison_operator"
13026                  [(reg 17) (const_int 0)])
13027             (const_int 0)))]
13028   ""
13029   [(set (match_dup 0) (match_dup 1))]
13031   PUT_MODE (operands[1], QImode);
13034 (define_split 
13035   [(set (match_operand:QI 0 "nonimmediate_operand" "")
13036         (eq:QI (match_operator 1 "ix86_comparison_operator"
13037                  [(reg 17) (const_int 0)])
13038             (const_int 0)))]
13039   ""
13040   [(set (match_dup 0) (match_dup 1))]
13042   rtx new_op1 = copy_rtx (operands[1]);
13043   operands[1] = new_op1;
13044   PUT_MODE (new_op1, QImode);
13045   PUT_CODE (new_op1, REVERSE_CONDITION (GET_CODE (new_op1),
13046                                         GET_MODE (XEXP (new_op1, 0))));
13048   /* Make sure that (a) the CCmode we have for the flags is strong
13049      enough for the reversed compare or (b) we have a valid FP compare.  */
13050   if (! ix86_comparison_operator (new_op1, VOIDmode))
13051     FAIL;
13054 (define_split 
13055   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
13056         (eq:QI (match_operator 1 "ix86_comparison_operator"
13057                  [(reg 17) (const_int 0)])
13058             (const_int 0)))]
13059   ""
13060   [(set (match_dup 0) (match_dup 1))]
13062   rtx new_op1 = copy_rtx (operands[1]);
13063   operands[1] = new_op1;
13064   PUT_MODE (new_op1, QImode);
13065   PUT_CODE (new_op1, REVERSE_CONDITION (GET_CODE (new_op1),
13066                                         GET_MODE (XEXP (new_op1, 0))));
13068   /* Make sure that (a) the CCmode we have for the flags is strong
13069      enough for the reversed compare or (b) we have a valid FP compare.  */
13070   if (! ix86_comparison_operator (new_op1, VOIDmode))
13071     FAIL;
13074 ;; The SSE store flag instructions saves 0 or 0xffffffff to the result.
13075 ;; subsequent logical operations are used to imitate conditional moves.
13076 ;; 0xffffffff is NaN, but not in normalized form, so we can't represent
13077 ;; it directly.  Further holding this value in pseudo register might bring
13078 ;; problem in implicit normalization in spill code.
13079 ;; So we don't define FLOAT_STORE_FLAG_VALUE and create these
13080 ;; instructions after reload by splitting the conditional move patterns.
13082 (define_insn "*sse_setccsf"
13083   [(set (match_operand:SF 0 "register_operand" "=x")
13084         (match_operator:SF 1 "sse_comparison_operator"
13085           [(match_operand:SF 2 "register_operand" "0")
13086            (match_operand:SF 3 "nonimmediate_operand" "xm")]))]
13087   "TARGET_SSE && reload_completed"
13088   "cmp%D1ss\t{%3, %0|%0, %3}"
13089   [(set_attr "type" "ssecmp")
13090    (set_attr "mode" "SF")])
13092 (define_insn "*sse_setccdf"
13093   [(set (match_operand:DF 0 "register_operand" "=Y")
13094         (match_operator:DF 1 "sse_comparison_operator"
13095           [(match_operand:DF 2 "register_operand" "0")
13096            (match_operand:DF 3 "nonimmediate_operand" "Ym")]))]
13097   "TARGET_SSE2 && reload_completed"
13098   "cmp%D1sd\t{%3, %0|%0, %3}"
13099   [(set_attr "type" "ssecmp")
13100    (set_attr "mode" "DF")])
13102 ;; Basic conditional jump instructions.
13103 ;; We ignore the overflow flag for signed branch instructions.
13105 ;; For all bCOND expanders, also expand the compare or test insn that
13106 ;; generates reg 17.  Generate an equality comparison if `beq' or `bne'.
13108 (define_expand "beq"
13109   [(set (pc)
13110         (if_then_else (match_dup 1)
13111                       (label_ref (match_operand 0 "" ""))
13112                       (pc)))]
13113   ""
13114   "ix86_expand_branch (EQ, operands[0]); DONE;")
13116 (define_expand "bne"
13117   [(set (pc)
13118         (if_then_else (match_dup 1)
13119                       (label_ref (match_operand 0 "" ""))
13120                       (pc)))]
13121   ""
13122   "ix86_expand_branch (NE, operands[0]); DONE;")
13124 (define_expand "bgt"
13125   [(set (pc)
13126         (if_then_else (match_dup 1)
13127                       (label_ref (match_operand 0 "" ""))
13128                       (pc)))]
13129   ""
13130   "ix86_expand_branch (GT, operands[0]); DONE;")
13132 (define_expand "bgtu"
13133   [(set (pc)
13134         (if_then_else (match_dup 1)
13135                       (label_ref (match_operand 0 "" ""))
13136                       (pc)))]
13137   ""
13138   "ix86_expand_branch (GTU, operands[0]); DONE;")
13140 (define_expand "blt"
13141   [(set (pc)
13142         (if_then_else (match_dup 1)
13143                       (label_ref (match_operand 0 "" ""))
13144                       (pc)))]
13145   ""
13146   "ix86_expand_branch (LT, operands[0]); DONE;")
13148 (define_expand "bltu"
13149   [(set (pc)
13150         (if_then_else (match_dup 1)
13151                       (label_ref (match_operand 0 "" ""))
13152                       (pc)))]
13153   ""
13154   "ix86_expand_branch (LTU, operands[0]); DONE;")
13156 (define_expand "bge"
13157   [(set (pc)
13158         (if_then_else (match_dup 1)
13159                       (label_ref (match_operand 0 "" ""))
13160                       (pc)))]
13161   ""
13162   "ix86_expand_branch (GE, operands[0]); DONE;")
13164 (define_expand "bgeu"
13165   [(set (pc)
13166         (if_then_else (match_dup 1)
13167                       (label_ref (match_operand 0 "" ""))
13168                       (pc)))]
13169   ""
13170   "ix86_expand_branch (GEU, operands[0]); DONE;")
13172 (define_expand "ble"
13173   [(set (pc)
13174         (if_then_else (match_dup 1)
13175                       (label_ref (match_operand 0 "" ""))
13176                       (pc)))]
13177   ""
13178   "ix86_expand_branch (LE, operands[0]); DONE;")
13180 (define_expand "bleu"
13181   [(set (pc)
13182         (if_then_else (match_dup 1)
13183                       (label_ref (match_operand 0 "" ""))
13184                       (pc)))]
13185   ""
13186   "ix86_expand_branch (LEU, operands[0]); DONE;")
13188 (define_expand "bunordered"
13189   [(set (pc)
13190         (if_then_else (match_dup 1)
13191                       (label_ref (match_operand 0 "" ""))
13192                       (pc)))]
13193   "TARGET_80387 || TARGET_SSE"
13194   "ix86_expand_branch (UNORDERED, operands[0]); DONE;")
13196 (define_expand "bordered"
13197   [(set (pc)
13198         (if_then_else (match_dup 1)
13199                       (label_ref (match_operand 0 "" ""))
13200                       (pc)))]
13201   "TARGET_80387 || TARGET_SSE"
13202   "ix86_expand_branch (ORDERED, operands[0]); DONE;")
13204 (define_expand "buneq"
13205   [(set (pc)
13206         (if_then_else (match_dup 1)
13207                       (label_ref (match_operand 0 "" ""))
13208                       (pc)))]
13209   "TARGET_80387 || TARGET_SSE"
13210   "ix86_expand_branch (UNEQ, operands[0]); DONE;")
13212 (define_expand "bunge"
13213   [(set (pc)
13214         (if_then_else (match_dup 1)
13215                       (label_ref (match_operand 0 "" ""))
13216                       (pc)))]
13217   "TARGET_80387 || TARGET_SSE"
13218   "ix86_expand_branch (UNGE, operands[0]); DONE;")
13220 (define_expand "bungt"
13221   [(set (pc)
13222         (if_then_else (match_dup 1)
13223                       (label_ref (match_operand 0 "" ""))
13224                       (pc)))]
13225   "TARGET_80387 || TARGET_SSE"
13226   "ix86_expand_branch (UNGT, operands[0]); DONE;")
13228 (define_expand "bunle"
13229   [(set (pc)
13230         (if_then_else (match_dup 1)
13231                       (label_ref (match_operand 0 "" ""))
13232                       (pc)))]
13233   "TARGET_80387 || TARGET_SSE"
13234   "ix86_expand_branch (UNLE, operands[0]); DONE;")
13236 (define_expand "bunlt"
13237   [(set (pc)
13238         (if_then_else (match_dup 1)
13239                       (label_ref (match_operand 0 "" ""))
13240                       (pc)))]
13241   "TARGET_80387 || TARGET_SSE"
13242   "ix86_expand_branch (UNLT, operands[0]); DONE;")
13244 (define_expand "bltgt"
13245   [(set (pc)
13246         (if_then_else (match_dup 1)
13247                       (label_ref (match_operand 0 "" ""))
13248                       (pc)))]
13249   "TARGET_80387 || TARGET_SSE"
13250   "ix86_expand_branch (LTGT, operands[0]); DONE;")
13252 (define_insn "*jcc_1"
13253   [(set (pc)
13254         (if_then_else (match_operator 1 "ix86_comparison_operator"
13255                                       [(reg 17) (const_int 0)])
13256                       (label_ref (match_operand 0 "" ""))
13257                       (pc)))]
13258   ""
13259   "%+j%C1\t%l0"
13260   [(set_attr "type" "ibr")
13261    (set_attr "modrm" "0")
13262    (set (attr "length")
13263            (if_then_else (and (ge (minus (match_dup 0) (pc))
13264                                   (const_int -128))
13265                               (lt (minus (match_dup 0) (pc))
13266                                   (const_int 124)))
13267              (const_int 2)
13268              (const_int 6)))])
13270 (define_insn "*jcc_2"
13271   [(set (pc)
13272         (if_then_else (match_operator 1 "ix86_comparison_operator"
13273                                       [(reg 17) (const_int 0)])
13274                       (pc)
13275                       (label_ref (match_operand 0 "" ""))))]
13276   ""
13277   "%+j%c1\t%l0"
13278   [(set_attr "type" "ibr")
13279    (set_attr "modrm" "0")
13280    (set (attr "length")
13281            (if_then_else (and (ge (minus (match_dup 0) (pc))
13282                                   (const_int -128))
13283                               (lt (minus (match_dup 0) (pc))
13284                                   (const_int 124)))
13285              (const_int 2)
13286              (const_int 6)))])
13288 ;; In general it is not safe to assume too much about CCmode registers,
13289 ;; so simplify-rtx stops when it sees a second one.  Under certain 
13290 ;; conditions this is safe on x86, so help combine not create
13292 ;;      seta    %al
13293 ;;      testb   %al, %al
13294 ;;      je      Lfoo
13296 (define_split 
13297   [(set (pc)
13298         (if_then_else (ne (match_operator 0 "ix86_comparison_operator"
13299                                       [(reg 17) (const_int 0)])
13300                           (const_int 0))
13301                       (label_ref (match_operand 1 "" ""))
13302                       (pc)))]
13303   ""
13304   [(set (pc)
13305         (if_then_else (match_dup 0)
13306                       (label_ref (match_dup 1))
13307                       (pc)))]
13309   PUT_MODE (operands[0], VOIDmode);
13311   
13312 (define_split 
13313   [(set (pc)
13314         (if_then_else (eq (match_operator 0 "ix86_comparison_operator"
13315                                       [(reg 17) (const_int 0)])
13316                           (const_int 0))
13317                       (label_ref (match_operand 1 "" ""))
13318                       (pc)))]
13319   ""
13320   [(set (pc)
13321         (if_then_else (match_dup 0)
13322                       (label_ref (match_dup 1))
13323                       (pc)))]
13325   rtx new_op0 = copy_rtx (operands[0]);
13326   operands[0] = new_op0;
13327   PUT_MODE (new_op0, VOIDmode);
13328   PUT_CODE (new_op0, REVERSE_CONDITION (GET_CODE (new_op0),
13329                                         GET_MODE (XEXP (new_op0, 0))));
13331   /* Make sure that (a) the CCmode we have for the flags is strong
13332      enough for the reversed compare or (b) we have a valid FP compare.  */
13333   if (! ix86_comparison_operator (new_op0, VOIDmode))
13334     FAIL;
13337 ;; Define combination compare-and-branch fp compare instructions to use
13338 ;; during early optimization.  Splitting the operation apart early makes
13339 ;; for bad code when we want to reverse the operation.
13341 (define_insn "*fp_jcc_1"
13342   [(set (pc)
13343         (if_then_else (match_operator 0 "comparison_operator"
13344                         [(match_operand 1 "register_operand" "f")
13345                          (match_operand 2 "register_operand" "f")])
13346           (label_ref (match_operand 3 "" ""))
13347           (pc)))
13348    (clobber (reg:CCFP 18))
13349    (clobber (reg:CCFP 17))]
13350   "TARGET_CMOVE && TARGET_80387
13351    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
13352    && FLOAT_MODE_P (GET_MODE (operands[1]))
13353    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13354    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13355   "#")
13357 (define_insn "*fp_jcc_1_sse"
13358   [(set (pc)
13359         (if_then_else (match_operator 0 "comparison_operator"
13360                         [(match_operand 1 "register_operand" "f#x,x#f")
13361                          (match_operand 2 "nonimmediate_operand" "f#x,xm#f")])
13362           (label_ref (match_operand 3 "" ""))
13363           (pc)))
13364    (clobber (reg:CCFP 18))
13365    (clobber (reg:CCFP 17))]
13366   "TARGET_80387
13367    && SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
13368    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13369    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13370   "#")
13372 (define_insn "*fp_jcc_1_sse_only"
13373   [(set (pc)
13374         (if_then_else (match_operator 0 "comparison_operator"
13375                         [(match_operand 1 "register_operand" "x")
13376                          (match_operand 2 "nonimmediate_operand" "xm")])
13377           (label_ref (match_operand 3 "" ""))
13378           (pc)))
13379    (clobber (reg:CCFP 18))
13380    (clobber (reg:CCFP 17))]
13381   "SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
13382    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13383    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13384   "#")
13386 (define_insn "*fp_jcc_2"
13387   [(set (pc)
13388         (if_then_else (match_operator 0 "comparison_operator"
13389                         [(match_operand 1 "register_operand" "f")
13390                          (match_operand 2 "register_operand" "f")])
13391           (pc)
13392           (label_ref (match_operand 3 "" ""))))
13393    (clobber (reg:CCFP 18))
13394    (clobber (reg:CCFP 17))]
13395   "TARGET_CMOVE && TARGET_80387
13396    && !SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
13397    && FLOAT_MODE_P (GET_MODE (operands[1]))
13398    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13399    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13400   "#")
13402 (define_insn "*fp_jcc_2_sse"
13403   [(set (pc)
13404         (if_then_else (match_operator 0 "comparison_operator"
13405                         [(match_operand 1 "register_operand" "f#x,x#f")
13406                          (match_operand 2 "nonimmediate_operand" "f#x,xm#f")])
13407           (pc)
13408           (label_ref (match_operand 3 "" ""))))
13409    (clobber (reg:CCFP 18))
13410    (clobber (reg:CCFP 17))]
13411   "TARGET_80387
13412    && SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
13413    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13414    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13415   "#")
13417 (define_insn "*fp_jcc_2_sse_only"
13418   [(set (pc)
13419         (if_then_else (match_operator 0 "comparison_operator"
13420                         [(match_operand 1 "register_operand" "x")
13421                          (match_operand 2 "nonimmediate_operand" "xm")])
13422           (pc)
13423           (label_ref (match_operand 3 "" ""))))
13424    (clobber (reg:CCFP 18))
13425    (clobber (reg:CCFP 17))]
13426   "SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
13427    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13428    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13429   "#")
13431 (define_insn "*fp_jcc_3"
13432   [(set (pc)
13433         (if_then_else (match_operator 0 "comparison_operator"
13434                         [(match_operand 1 "register_operand" "f")
13435                          (match_operand 2 "nonimmediate_operand" "fm")])
13436           (label_ref (match_operand 3 "" ""))
13437           (pc)))
13438    (clobber (reg:CCFP 18))
13439    (clobber (reg:CCFP 17))
13440    (clobber (match_scratch:HI 4 "=a"))]
13441   "TARGET_80387
13442    && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
13443    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13444    && !ix86_use_fcomi_compare (GET_CODE (operands[0]))
13445    && SELECT_CC_MODE (GET_CODE (operands[0]),
13446                       operands[1], operands[2]) == CCFPmode
13447    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13448   "#")
13450 (define_insn "*fp_jcc_4"
13451   [(set (pc)
13452         (if_then_else (match_operator 0 "comparison_operator"
13453                         [(match_operand 1 "register_operand" "f")
13454                          (match_operand 2 "nonimmediate_operand" "fm")])
13455           (pc)
13456           (label_ref (match_operand 3 "" ""))))
13457    (clobber (reg:CCFP 18))
13458    (clobber (reg:CCFP 17))
13459    (clobber (match_scratch:HI 4 "=a"))]
13460   "TARGET_80387
13461    && (GET_MODE (operands[1]) == SFmode || GET_MODE (operands[1]) == DFmode)
13462    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13463    && !ix86_use_fcomi_compare (GET_CODE (operands[0]))
13464    && SELECT_CC_MODE (GET_CODE (operands[0]),
13465                       operands[1], operands[2]) == CCFPmode
13466    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13467   "#")
13469 (define_insn "*fp_jcc_5"
13470   [(set (pc)
13471         (if_then_else (match_operator 0 "comparison_operator"
13472                         [(match_operand 1 "register_operand" "f")
13473                          (match_operand 2 "register_operand" "f")])
13474           (label_ref (match_operand 3 "" ""))
13475           (pc)))
13476    (clobber (reg:CCFP 18))
13477    (clobber (reg:CCFP 17))
13478    (clobber (match_scratch:HI 4 "=a"))]
13479   "TARGET_80387
13480    && FLOAT_MODE_P (GET_MODE (operands[1]))
13481    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13482    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13483   "#")
13485 (define_insn "*fp_jcc_6"
13486   [(set (pc)
13487         (if_then_else (match_operator 0 "comparison_operator"
13488                         [(match_operand 1 "register_operand" "f")
13489                          (match_operand 2 "register_operand" "f")])
13490           (pc)
13491           (label_ref (match_operand 3 "" ""))))
13492    (clobber (reg:CCFP 18))
13493    (clobber (reg:CCFP 17))
13494    (clobber (match_scratch:HI 4 "=a"))]
13495   "TARGET_80387
13496    && FLOAT_MODE_P (GET_MODE (operands[1]))
13497    && GET_MODE (operands[1]) == GET_MODE (operands[2])
13498    && ix86_fp_jump_nontrivial_p (GET_CODE (operands[0]))"
13499   "#")
13501 (define_split
13502   [(set (pc)
13503         (if_then_else (match_operator 0 "comparison_operator"
13504                         [(match_operand 1 "register_operand" "")
13505                          (match_operand 2 "nonimmediate_operand" "")])
13506           (match_operand 3 "" "")
13507           (match_operand 4 "" "")))
13508    (clobber (reg:CCFP 18))
13509    (clobber (reg:CCFP 17))]
13510   "reload_completed"
13511   [(const_int 0)]
13513   ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
13514                         operands[3], operands[4], NULL_RTX);
13515   DONE;
13518 (define_split
13519   [(set (pc)
13520         (if_then_else (match_operator 0 "comparison_operator"
13521                         [(match_operand 1 "register_operand" "")
13522                          (match_operand 2 "nonimmediate_operand" "")])
13523           (match_operand 3 "" "")
13524           (match_operand 4 "" "")))
13525    (clobber (reg:CCFP 18))
13526    (clobber (reg:CCFP 17))
13527    (clobber (match_scratch:HI 5 "=a"))]
13528   "reload_completed"
13529   [(set (pc)
13530         (if_then_else (match_dup 6)
13531           (match_dup 3)
13532           (match_dup 4)))]
13534   ix86_split_fp_branch (GET_CODE (operands[0]), operands[1], operands[2],
13535                         operands[3], operands[4], operands[5]);
13536   DONE;
13539 ;; Unconditional and other jump instructions
13541 (define_insn "jump"
13542   [(set (pc)
13543         (label_ref (match_operand 0 "" "")))]
13544   ""
13545   "jmp\t%l0"
13546   [(set_attr "type" "ibr")
13547    (set (attr "length")
13548            (if_then_else (and (ge (minus (match_dup 0) (pc))
13549                                   (const_int -128))
13550                               (lt (minus (match_dup 0) (pc))
13551                                   (const_int 124)))
13552              (const_int 2)
13553              (const_int 5)))
13554    (set_attr "modrm" "0")])
13556 (define_expand "indirect_jump"
13557   [(set (pc) (match_operand 0 "nonimmediate_operand" "rm"))]
13558   ""
13559   "")
13561 (define_insn "*indirect_jump"
13562   [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))]
13563   "!TARGET_64BIT"
13564   "jmp\t%A0"
13565   [(set_attr "type" "ibr")
13566    (set_attr "length_immediate" "0")])
13568 (define_insn "*indirect_jump_rtx64"
13569   [(set (pc) (match_operand:DI 0 "nonimmediate_operand" "rm"))]
13570   "TARGET_64BIT"
13571   "jmp\t%A0"
13572   [(set_attr "type" "ibr")
13573    (set_attr "length_immediate" "0")])
13575 (define_expand "tablejump"
13576   [(parallel [(set (pc) (match_operand 0 "nonimmediate_operand" "rm"))
13577               (use (label_ref (match_operand 1 "" "")))])]
13578   ""
13580   /* In PIC mode, the table entries are stored GOT (32-bit) or PC (64-bit)
13581      relative.  Convert the relative address to an absolute address.  */
13582   if (flag_pic)
13583     {
13584       rtx op0, op1;
13585       enum rtx_code code;
13587       if (TARGET_64BIT)
13588         {
13589           code = PLUS;
13590           op0 = operands[0];
13591           op1 = gen_rtx_LABEL_REF (Pmode, operands[1]);
13592         }
13593       else if (TARGET_MACHO || HAVE_AS_GOTOFF_IN_DATA)
13594         {
13595           code = PLUS;
13596           op0 = operands[0];
13597           op1 = pic_offset_table_rtx;
13598         }
13599       else
13600         {
13601           code = MINUS;
13602           op0 = pic_offset_table_rtx;
13603           op1 = operands[0];
13604         }
13606       operands[0] = expand_simple_binop (Pmode, code, op0, op1, NULL_RTX, 0,
13607                                          OPTAB_DIRECT);
13608     }
13611 (define_insn "*tablejump_1"
13612   [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))
13613    (use (label_ref (match_operand 1 "" "")))]
13614   "!TARGET_64BIT"
13615   "jmp\t%A0"
13616   [(set_attr "type" "ibr")
13617    (set_attr "length_immediate" "0")])
13619 (define_insn "*tablejump_1_rtx64"
13620   [(set (pc) (match_operand:DI 0 "nonimmediate_operand" "rm"))
13621    (use (label_ref (match_operand 1 "" "")))]
13622   "TARGET_64BIT"
13623   "jmp\t%A0"
13624   [(set_attr "type" "ibr")
13625    (set_attr "length_immediate" "0")])
13627 ;; Loop instruction
13629 ;; This is all complicated by the fact that since this is a jump insn
13630 ;; we must handle our own reloads.
13632 (define_expand "doloop_end"
13633   [(use (match_operand 0 "" ""))        ; loop pseudo
13634    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
13635    (use (match_operand 2 "" ""))        ; max iterations
13636    (use (match_operand 3 "" ""))        ; loop level 
13637    (use (match_operand 4 "" ""))]       ; label
13638   "!TARGET_64BIT && TARGET_USE_LOOP"
13639   "                                 
13641   /* Only use cloop on innermost loops.  */
13642   if (INTVAL (operands[3]) > 1)
13643     FAIL;
13644   if (GET_MODE (operands[0]) != SImode)
13645     FAIL;
13646   emit_jump_insn (gen_doloop_end_internal (operands[4], operands[0],
13647                                            operands[0]));
13648   DONE;
13651 (define_insn "doloop_end_internal"
13652   [(set (pc)
13653         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,?*r,?*r")
13654                           (const_int 1))
13655                       (label_ref (match_operand 0 "" ""))
13656                       (pc)))
13657    (set (match_operand:SI 2 "register_operand" "=1,1,*m*r")
13658         (plus:SI (match_dup 1)
13659                  (const_int -1)))
13660    (clobber (match_scratch:SI 3 "=X,X,r"))
13661    (clobber (reg:CC 17))]
13662   "!TARGET_64BIT && TARGET_USE_LOOP"
13664   if (which_alternative != 0)
13665     return "#";
13666   if (get_attr_length (insn) == 2)
13667     return "%+loop\t%l0";
13668   else
13669     return "dec{l}\t%1\;%+jne\t%l0";
13671   [(set_attr "ppro_uops" "many")
13672    (set (attr "length")
13673         (if_then_else (and (eq_attr "alternative" "0")
13674                            (and (ge (minus (match_dup 0) (pc))
13675                                     (const_int -128))
13676                                 (lt (minus (match_dup 0) (pc))
13677                                     (const_int 124))))
13678                       (const_int 2)
13679                       (const_int 16)))
13680    ;; We don't know the type before shorten branches.  Optimistically expect
13681    ;; the loop instruction to match.
13682    (set (attr "type") (const_string "ibr"))])
13684 (define_split
13685   [(set (pc)
13686         (if_then_else (ne (match_operand:SI 1 "register_operand" "")
13687                           (const_int 1))
13688                       (match_operand 0 "" "")
13689                       (pc)))
13690    (set (match_dup 1)
13691         (plus:SI (match_dup 1)
13692                  (const_int -1)))
13693    (clobber (match_scratch:SI 2 ""))
13694    (clobber (reg:CC 17))]
13695   "!TARGET_64BIT && TARGET_USE_LOOP
13696    && reload_completed
13697    && REGNO (operands[1]) != 2"
13698   [(parallel [(set (reg:CCZ 17)
13699                    (compare:CCZ (plus:SI (match_dup 1) (const_int -1))
13700                                  (const_int 0)))
13701               (set (match_dup 1) (plus:SI (match_dup 1) (const_int -1)))])
13702    (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0))
13703                            (match_dup 0)
13704                            (pc)))]
13705   "")
13706   
13707 (define_split
13708   [(set (pc)
13709         (if_then_else (ne (match_operand:SI 1 "register_operand" "")
13710                           (const_int 1))
13711                       (match_operand 0 "" "")
13712                       (pc)))
13713    (set (match_operand:SI 2 "nonimmediate_operand" "")
13714         (plus:SI (match_dup 1)
13715                  (const_int -1)))
13716    (clobber (match_scratch:SI 3 ""))
13717    (clobber (reg:CC 17))]
13718   "!TARGET_64BIT && TARGET_USE_LOOP
13719    && reload_completed
13720    && (! REG_P (operands[2])
13721        || ! rtx_equal_p (operands[1], operands[2]))"
13722   [(set (match_dup 3) (match_dup 1))
13723    (parallel [(set (reg:CCZ 17)
13724                    (compare:CCZ (plus:SI (match_dup 3) (const_int -1))
13725                                 (const_int 0)))
13726               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
13727    (set (match_dup 2) (match_dup 3))
13728    (set (pc) (if_then_else (ne (reg:CCZ 17) (const_int 0))
13729                            (match_dup 0)
13730                            (pc)))]
13731   "")
13733 ;; Convert setcc + movzbl to xor + setcc if operands don't overlap.
13735 (define_peephole2
13736   [(set (reg 17) (match_operand 0 "" ""))
13737    (set (match_operand:QI 1 "register_operand" "")
13738         (match_operator:QI 2 "ix86_comparison_operator"
13739           [(reg 17) (const_int 0)]))
13740    (set (match_operand 3 "q_regs_operand" "")
13741         (zero_extend (match_dup 1)))]
13742   "(peep2_reg_dead_p (3, operands[1])
13743     || operands_match_p (operands[1], operands[3]))
13744    && ! reg_overlap_mentioned_p (operands[3], operands[0])"
13745   [(set (match_dup 4) (match_dup 0))
13746    (set (strict_low_part (match_dup 5))
13747         (match_dup 2))]
13749   operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17);
13750   operands[5] = gen_rtx_REG (QImode, REGNO (operands[3]));
13751   ix86_expand_clear (operands[3]);
13754 ;; Similar, but match zero_extendhisi2_and, which adds a clobber.
13756 (define_peephole2
13757   [(set (reg 17) (match_operand 0 "" ""))
13758    (set (match_operand:QI 1 "register_operand" "")
13759         (match_operator:QI 2 "ix86_comparison_operator"
13760           [(reg 17) (const_int 0)]))
13761    (parallel [(set (match_operand 3 "q_regs_operand" "")
13762                    (zero_extend (match_dup 1)))
13763               (clobber (reg:CC 17))])]
13764   "(peep2_reg_dead_p (3, operands[1])
13765     || operands_match_p (operands[1], operands[3]))
13766    && ! reg_overlap_mentioned_p (operands[3], operands[0])"
13767   [(set (match_dup 4) (match_dup 0))
13768    (set (strict_low_part (match_dup 5))
13769         (match_dup 2))]
13771   operands[4] = gen_rtx_REG (GET_MODE (operands[0]), 17);
13772   operands[5] = gen_rtx_REG (QImode, REGNO (operands[3]));
13773   ix86_expand_clear (operands[3]);
13776 ;; Call instructions.
13778 ;; The predicates normally associated with named expanders are not properly
13779 ;; checked for calls.  This is a bug in the generic code, but it isn't that
13780 ;; easy to fix.  Ignore it for now and be prepared to fix things up.
13782 ;; Call subroutine returning no value.
13784 (define_expand "call_pop"
13785   [(parallel [(call (match_operand:QI 0 "" "")
13786                     (match_operand:SI 1 "" ""))
13787               (set (reg:SI 7)
13788                    (plus:SI (reg:SI 7)
13789                             (match_operand:SI 3 "" "")))])]
13790   "!TARGET_64BIT"
13792   ix86_expand_call (NULL, operands[0], operands[1], operands[2], operands[3], 0);
13793   DONE;
13796 (define_insn "*call_pop_0"
13797   [(call (mem:QI (match_operand:SI 0 "constant_call_address_operand" ""))
13798          (match_operand:SI 1 "" ""))
13799    (set (reg:SI 7) (plus:SI (reg:SI 7)
13800                             (match_operand:SI 2 "immediate_operand" "")))]
13801   "!TARGET_64BIT"
13803   if (SIBLING_CALL_P (insn))
13804     return "jmp\t%P0";
13805   else
13806     return "call\t%P0";
13808   [(set_attr "type" "call")])
13809   
13810 (define_insn "*call_pop_1"
13811   [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
13812          (match_operand:SI 1 "" ""))
13813    (set (reg:SI 7) (plus:SI (reg:SI 7)
13814                             (match_operand:SI 2 "immediate_operand" "i")))]
13815   "!TARGET_64BIT"
13817   if (constant_call_address_operand (operands[0], Pmode))
13818     {
13819       if (SIBLING_CALL_P (insn))
13820         return "jmp\t%P0";
13821       else
13822         return "call\t%P0";
13823     }
13824   if (SIBLING_CALL_P (insn))
13825     return "jmp\t%A0";
13826   else
13827     return "call\t%A0";
13829   [(set_attr "type" "call")])
13831 (define_expand "call"
13832   [(call (match_operand:QI 0 "" "")
13833          (match_operand 1 "" ""))
13834    (use (match_operand 2 "" ""))]
13835   ""
13837   ix86_expand_call (NULL, operands[0], operands[1], operands[2], NULL, 0);
13838   DONE;
13841 (define_expand "sibcall"
13842   [(call (match_operand:QI 0 "" "")
13843          (match_operand 1 "" ""))
13844    (use (match_operand 2 "" ""))]
13845   ""
13847   ix86_expand_call (NULL, operands[0], operands[1], operands[2], NULL, 1);
13848   DONE;
13851 (define_insn "*call_0"
13852   [(call (mem:QI (match_operand 0 "constant_call_address_operand" ""))
13853          (match_operand 1 "" ""))]
13854   ""
13856   if (SIBLING_CALL_P (insn))
13857     return "jmp\t%P0";
13858   else
13859     return "call\t%P0";
13861   [(set_attr "type" "call")])
13863 (define_insn "*call_1"
13864   [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "rsm"))
13865          (match_operand 1 "" ""))]
13866   "!SIBLING_CALL_P (insn) && !TARGET_64BIT"
13868   if (constant_call_address_operand (operands[0], QImode))
13869     return "call\t%P0";
13870   return "call\t%A0";
13872   [(set_attr "type" "call")])
13874 (define_insn "*sibcall_1"
13875   [(call (mem:QI (match_operand:SI 0 "sibcall_insn_operand" "s,c,d,a"))
13876          (match_operand 1 "" ""))]
13877   "SIBLING_CALL_P (insn) && !TARGET_64BIT"
13879   if (constant_call_address_operand (operands[0], QImode))
13880     return "jmp\t%P0";
13881   return "jmp\t%A0";
13883   [(set_attr "type" "call")])
13885 (define_insn "*call_1_rex64"
13886   [(call (mem:QI (match_operand:DI 0 "call_insn_operand" "rsm"))
13887          (match_operand 1 "" ""))]
13888   "!SIBLING_CALL_P (insn) && TARGET_64BIT"
13890   if (constant_call_address_operand (operands[0], QImode))
13891     return "call\t%P0";
13892   return "call\t%A0";
13894   [(set_attr "type" "call")])
13896 (define_insn "*sibcall_1_rex64"
13897   [(call (mem:QI (match_operand:DI 0 "constant_call_address_operand" ""))
13898          (match_operand 1 "" ""))]
13899   "SIBLING_CALL_P (insn) && TARGET_64BIT"
13900   "jmp\t%P0"
13901   [(set_attr "type" "call")])
13903 (define_insn "*sibcall_1_rex64_v"
13904   [(call (mem:QI (reg:DI 40))
13905          (match_operand 0 "" ""))]
13906   "SIBLING_CALL_P (insn) && TARGET_64BIT"
13907   "jmp\t*%%r11"
13908   [(set_attr "type" "call")])
13911 ;; Call subroutine, returning value in operand 0
13913 (define_expand "call_value_pop"
13914   [(parallel [(set (match_operand 0 "" "")
13915                    (call (match_operand:QI 1 "" "")
13916                          (match_operand:SI 2 "" "")))
13917               (set (reg:SI 7)
13918                    (plus:SI (reg:SI 7)
13919                             (match_operand:SI 4 "" "")))])]
13920   "!TARGET_64BIT"
13922   ix86_expand_call (operands[0], operands[1], operands[2],
13923                     operands[3], operands[4], 0);
13924   DONE;
13927 (define_expand "call_value"
13928   [(set (match_operand 0 "" "")
13929         (call (match_operand:QI 1 "" "")
13930               (match_operand:SI 2 "" "")))
13931    (use (match_operand:SI 3 "" ""))]
13932   ;; Operand 2 not used on the i386.
13933   ""
13935   ix86_expand_call (operands[0], operands[1], operands[2], operands[3], NULL, 0);
13936   DONE;
13939 (define_expand "sibcall_value"
13940   [(set (match_operand 0 "" "")
13941         (call (match_operand:QI 1 "" "")
13942               (match_operand:SI 2 "" "")))
13943    (use (match_operand:SI 3 "" ""))]
13944   ;; Operand 2 not used on the i386.
13945   ""
13947   ix86_expand_call (operands[0], operands[1], operands[2], operands[3], NULL, 1);
13948   DONE;
13951 ;; Call subroutine returning any type.
13953 (define_expand "untyped_call"
13954   [(parallel [(call (match_operand 0 "" "")
13955                     (const_int 0))
13956               (match_operand 1 "" "")
13957               (match_operand 2 "" "")])]
13958   ""
13960   int i;
13962   /* In order to give reg-stack an easier job in validating two
13963      coprocessor registers as containing a possible return value,
13964      simply pretend the untyped call returns a complex long double
13965      value.  */
13967   ix86_expand_call ((TARGET_FLOAT_RETURNS_IN_80387
13968                      ? gen_rtx_REG (XCmode, FIRST_FLOAT_REG) : NULL),
13969                     operands[0], const0_rtx, GEN_INT (SSE_REGPARM_MAX - 1),
13970                     NULL, 0);
13972   for (i = 0; i < XVECLEN (operands[2], 0); i++)
13973     {
13974       rtx set = XVECEXP (operands[2], 0, i);
13975       emit_move_insn (SET_DEST (set), SET_SRC (set));
13976     }
13978   /* The optimizer does not know that the call sets the function value
13979      registers we stored in the result block.  We avoid problems by
13980      claiming that all hard registers are used and clobbered at this
13981      point.  */
13982   emit_insn (gen_blockage (const0_rtx));
13984   DONE;
13987 ;; Prologue and epilogue instructions
13989 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
13990 ;; all of memory.  This blocks insns from being moved across this point.
13992 (define_insn "blockage"
13993   [(unspec_volatile [(match_operand 0 "" "")] UNSPECV_BLOCKAGE)]
13994   ""
13995   ""
13996   [(set_attr "length" "0")])
13998 ;; Insn emitted into the body of a function to return from a function.
13999 ;; This is only done if the function's epilogue is known to be simple.
14000 ;; See comments for ix86_can_use_return_insn_p in i386.c.
14002 (define_expand "return"
14003   [(return)]
14004   "ix86_can_use_return_insn_p ()"
14006   if (current_function_pops_args)
14007     {
14008       rtx popc = GEN_INT (current_function_pops_args);
14009       emit_jump_insn (gen_return_pop_internal (popc));
14010       DONE;
14011     }
14014 (define_insn "return_internal"
14015   [(return)]
14016   "reload_completed"
14017   "ret"
14018   [(set_attr "length" "1")
14019    (set_attr "length_immediate" "0")
14020    (set_attr "modrm" "0")])
14022 (define_insn "return_pop_internal"
14023   [(return)
14024    (use (match_operand:SI 0 "const_int_operand" ""))]
14025   "reload_completed"
14026   "ret\t%0"
14027   [(set_attr "length" "3")
14028    (set_attr "length_immediate" "2")
14029    (set_attr "modrm" "0")])
14031 (define_insn "return_indirect_internal"
14032   [(return)
14033    (use (match_operand:SI 0 "register_operand" "r"))]
14034   "reload_completed"
14035   "jmp\t%A0"
14036   [(set_attr "type" "ibr")
14037    (set_attr "length_immediate" "0")])
14039 (define_insn "nop"
14040   [(const_int 0)]
14041   ""
14042   "nop"
14043   [(set_attr "length" "1")
14044    (set_attr "length_immediate" "0")
14045    (set_attr "modrm" "0")
14046    (set_attr "ppro_uops" "one")])
14048 (define_expand "prologue"
14049   [(const_int 1)]
14050   ""
14051   "ix86_expand_prologue (); DONE;")
14053 (define_insn "set_got"
14054   [(set (match_operand:SI 0 "register_operand" "=r")
14055         (unspec:SI [(const_int 0)] UNSPEC_SET_GOT))
14056    (clobber (reg:CC 17))]
14057   "!TARGET_64BIT"
14058   { return output_set_got (operands[0]); }
14059   [(set_attr "type" "multi")
14060    (set_attr "length" "12")])
14062 (define_expand "epilogue"
14063   [(const_int 1)]
14064   ""
14065   "ix86_expand_epilogue (1); DONE;")
14067 (define_expand "sibcall_epilogue"
14068   [(const_int 1)]
14069   ""
14070   "ix86_expand_epilogue (0); DONE;")
14072 (define_expand "eh_return"
14073   [(use (match_operand 0 "register_operand" ""))
14074    (use (match_operand 1 "register_operand" ""))]
14075   ""
14077   rtx tmp, sa = operands[0], ra = operands[1];
14079   /* Tricky bit: we write the address of the handler to which we will
14080      be returning into someone else's stack frame, one word below the
14081      stack address we wish to restore.  */
14082   tmp = gen_rtx_PLUS (Pmode, arg_pointer_rtx, sa);
14083   tmp = plus_constant (tmp, -UNITS_PER_WORD);
14084   tmp = gen_rtx_MEM (Pmode, tmp);
14085   emit_move_insn (tmp, ra);
14087   if (Pmode == SImode)
14088     emit_insn (gen_eh_return_si (sa));
14089   else
14090     emit_insn (gen_eh_return_di (sa));
14091   emit_barrier ();
14092   DONE;
14095 (define_insn_and_split "eh_return_si"
14096   [(unspec_volatile [(match_operand:SI 0 "register_operand" "c")]
14097                     UNSPECV_EH_RETURN)]
14098   "!TARGET_64BIT"
14099   "#"
14100   "reload_completed"
14101   [(const_int 1)]
14102   "ix86_expand_epilogue (2); DONE;")
14104 (define_insn_and_split "eh_return_di"
14105   [(unspec_volatile [(match_operand:DI 0 "register_operand" "c")]
14106                     UNSPECV_EH_RETURN)]
14107   "TARGET_64BIT"
14108   "#"
14109   "reload_completed"
14110   [(const_int 1)]
14111   "ix86_expand_epilogue (2); DONE;")
14113 (define_insn "leave"
14114   [(set (reg:SI 7) (plus:SI (reg:SI 6) (const_int 4)))
14115    (set (reg:SI 6) (mem:SI (reg:SI 6)))
14116    (clobber (mem:BLK (scratch)))]
14117   "!TARGET_64BIT"
14118   "leave"
14119   [(set_attr "type" "leave")])
14121 (define_insn "leave_rex64"
14122   [(set (reg:DI 7) (plus:DI (reg:DI 6) (const_int 8)))
14123    (set (reg:DI 6) (mem:DI (reg:DI 6)))
14124    (clobber (mem:BLK (scratch)))]
14125   "TARGET_64BIT"
14126   "leave"
14127   [(set_attr "type" "leave")])
14129 (define_expand "ffssi2"
14130   [(parallel
14131      [(set (match_operand:SI 0 "register_operand" "") 
14132            (ffs:SI (match_operand:SI 1 "nonimmediate_operand" "")))
14133       (clobber (match_scratch:SI 2 ""))
14134       (clobber (reg:CC 17))])]
14135   ""
14136   "")
14138 (define_insn_and_split "*ffs_cmove"
14139   [(set (match_operand:SI 0 "register_operand" "=r") 
14140         (ffs:SI (match_operand:SI 1 "nonimmediate_operand" "rm")))
14141    (clobber (match_scratch:SI 2 "=&r"))
14142    (clobber (reg:CC 17))]
14143   "TARGET_CMOVE"
14144   "#"
14145   "&& reload_completed"
14146   [(set (match_dup 2) (const_int -1))
14147    (parallel [(set (reg:CCZ 17) (compare:CCZ (match_dup 1) (const_int 0)))
14148               (set (match_dup 0) (ctz:SI (match_dup 1)))])
14149    (set (match_dup 0) (if_then_else:SI
14150                         (eq (reg:CCZ 17) (const_int 0))
14151                         (match_dup 2)
14152                         (match_dup 0)))
14153    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
14154               (clobber (reg:CC 17))])]
14155   "")
14157 (define_insn_and_split "*ffs_no_cmove"
14158   [(set (match_operand:SI 0 "nonimmediate_operand" "=r") 
14159         (ffs:SI (match_operand:SI 1 "nonimmediate_operand" "rm")))
14160    (clobber (match_scratch:SI 2 "=&r"))
14161    (clobber (reg:CC 17))]
14162   ""
14163   "#"
14164   "reload_completed"
14165   [(parallel [(set (match_dup 2) (const_int 0))
14166               (clobber (reg:CC 17))])
14167    (parallel [(set (reg:CCZ 17) (compare:CCZ (match_dup 1) (const_int 0)))
14168               (set (match_dup 0) (ctz:SI (match_dup 1)))])
14169    (set (strict_low_part (match_dup 3))
14170         (eq:QI (reg:CCZ 17) (const_int 0)))
14171    (parallel [(set (match_dup 2) (neg:SI (match_dup 2)))
14172               (clobber (reg:CC 17))])
14173    (parallel [(set (match_dup 0) (ior:SI (match_dup 0) (match_dup 2)))
14174               (clobber (reg:CC 17))])
14175    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
14176               (clobber (reg:CC 17))])]
14178   operands[3] = gen_lowpart (QImode, operands[2]);
14181 (define_insn "*ffssi_1"
14182   [(set (reg:CCZ 17)
14183         (compare:CCZ (match_operand:SI 1 "nonimmediate_operand" "rm")
14184                      (const_int 0)))
14185    (set (match_operand:SI 0 "register_operand" "=r")
14186         (ctz:SI (match_dup 1)))]
14187   ""
14188   "bsf{l}\t{%1, %0|%0, %1}"
14189   [(set_attr "prefix_0f" "1")
14190    (set_attr "ppro_uops" "few")])
14192 (define_insn "ctzsi2"
14193   [(set (match_operand:SI 0 "register_operand" "=r")
14194         (ctz:SI (match_operand:SI 1 "nonimmediate_operand" "rm")))
14195    (clobber (reg:CC 17))]
14196   ""
14197   "bsf{l}\t{%1, %0|%0, %1}"
14198   [(set_attr "prefix_0f" "1")
14199    (set_attr "ppro_uops" "few")])
14201 (define_expand "clzsi2"
14202   [(parallel
14203      [(set (match_operand:SI 0 "register_operand" "")
14204            (minus:SI (const_int 31)
14205                      (clz:SI (match_operand:SI 1 "nonimmediate_operand" ""))))
14206       (clobber (reg:CC 17))])
14207    (parallel
14208      [(set (match_dup 0) (xor:SI (match_dup 0) (const_int 31)))
14209       (clobber (reg:CC 17))])]
14210   ""
14211   "")
14213 (define_insn "*bsr"
14214   [(set (match_operand:SI 0 "register_operand" "=r")
14215         (minus:SI (const_int 31)
14216                   (clz:SI (match_operand:SI 1 "nonimmediate_operand" "rm"))))
14217    (clobber (reg:CC 17))]
14218   ""
14219   "bsr{l}\t{%1, %0|%0, %1}"
14220   [(set_attr "prefix_0f" "1")
14221    (set_attr "ppro_uops" "few")])
14223 ;; Thread-local storage patterns for ELF.
14225 ;; Note that these code sequences must appear exactly as shown
14226 ;; in order to allow linker relaxation.
14228 (define_insn "*tls_global_dynamic_32_gnu"
14229   [(set (match_operand:SI 0 "register_operand" "=a")
14230         (unspec:SI [(match_operand:SI 1 "register_operand" "b")
14231                     (match_operand:SI 2 "tls_symbolic_operand" "")
14232                     (match_operand:SI 3 "call_insn_operand" "")]
14233                     UNSPEC_TLS_GD))
14234    (clobber (match_scratch:SI 4 "=d"))
14235    (clobber (match_scratch:SI 5 "=c"))
14236    (clobber (reg:CC 17))]
14237   "!TARGET_64BIT && TARGET_GNU_TLS"
14238   "lea{l}\t{%a2@TLSGD(,%1,1), %0|%0, %a2@TLSGD[%1*1]}\;call\t%P3"
14239   [(set_attr "type" "multi")
14240    (set_attr "length" "12")])
14242 (define_insn "*tls_global_dynamic_32_sun"
14243   [(set (match_operand:SI 0 "register_operand" "=a")
14244         (unspec:SI [(match_operand:SI 1 "register_operand" "b")
14245                     (match_operand:SI 2 "tls_symbolic_operand" "")
14246                     (match_operand:SI 3 "call_insn_operand" "")]
14247                     UNSPEC_TLS_GD))
14248    (clobber (match_scratch:SI 4 "=d"))
14249    (clobber (match_scratch:SI 5 "=c"))
14250    (clobber (reg:CC 17))]
14251   "!TARGET_64BIT && TARGET_SUN_TLS"
14252   "lea{l}\t{%a2@DTLNDX(%1), %4|%4, %a2@DTLNDX[%1]}
14253         push{l}\t%4\;call\t%a2@TLSPLT\;pop{l}\t%4\;nop"
14254   [(set_attr "type" "multi")
14255    (set_attr "length" "14")])
14257 (define_expand "tls_global_dynamic_32"
14258   [(parallel [(set (match_operand:SI 0 "register_operand" "")
14259                    (unspec:SI
14260                     [(match_dup 2)
14261                      (match_operand:SI 1 "tls_symbolic_operand" "")
14262                      (match_dup 3)]
14263                     UNSPEC_TLS_GD))
14264               (clobber (match_scratch:SI 4 ""))
14265               (clobber (match_scratch:SI 5 ""))
14266               (clobber (reg:CC 17))])]
14267   ""
14269   if (flag_pic)
14270     operands[2] = pic_offset_table_rtx;
14271   else
14272     {
14273       operands[2] = gen_reg_rtx (Pmode);
14274       emit_insn (gen_set_got (operands[2]));
14275     }
14276   operands[3] = ix86_tls_get_addr ();
14279 (define_insn "*tls_global_dynamic_64"
14280   [(set (match_operand:DI 0 "register_operand" "=a")
14281         (call (mem:QI (match_operand:DI 2 "call_insn_operand" ""))
14282                       (match_operand:DI 3 "" "")))
14283    (unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")]
14284               UNSPEC_TLS_GD)]
14285   "TARGET_64BIT"
14286   ".byte\t0x66\;lea{q}\t{%a1@TLSGD(%%rip), %%rdi|%%rdi, %a1@TLSGD[%%rip]}\;.word\t0x6666\;rex64\;call\t%P2"
14287   [(set_attr "type" "multi")
14288    (set_attr "length" "16")])
14290 (define_expand "tls_global_dynamic_64"
14291   [(parallel [(set (match_operand:DI 0 "register_operand" "")
14292                    (call (mem:QI (match_dup 2)) (const_int 0)))
14293               (unspec:DI [(match_operand:DI 1 "tls_symbolic_operand" "")]
14294                          UNSPEC_TLS_GD)])]
14295   ""
14297   operands[2] = ix86_tls_get_addr ();
14300 (define_insn "*tls_local_dynamic_base_32_gnu"
14301   [(set (match_operand:SI 0 "register_operand" "=a")
14302         (unspec:SI [(match_operand:SI 1 "register_operand" "b")
14303                     (match_operand:SI 2 "call_insn_operand" "")]
14304                    UNSPEC_TLS_LD_BASE))
14305    (clobber (match_scratch:SI 3 "=d"))
14306    (clobber (match_scratch:SI 4 "=c"))
14307    (clobber (reg:CC 17))]
14308   "!TARGET_64BIT && TARGET_GNU_TLS"
14309   "lea{l}\t{%&@TLSLDM(%1), %0|%0, %&@TLSLDM[%1]}\;call\t%P2"
14310   [(set_attr "type" "multi")
14311    (set_attr "length" "11")])
14313 (define_insn "*tls_local_dynamic_base_32_sun"
14314   [(set (match_operand:SI 0 "register_operand" "=a")
14315         (unspec:SI [(match_operand:SI 1 "register_operand" "b")
14316                     (match_operand:SI 2 "call_insn_operand" "")]
14317                    UNSPEC_TLS_LD_BASE))
14318    (clobber (match_scratch:SI 3 "=d"))
14319    (clobber (match_scratch:SI 4 "=c"))
14320    (clobber (reg:CC 17))]
14321   "!TARGET_64BIT && TARGET_SUN_TLS"
14322   "lea{l}\t{%&@TMDNX(%1), %3|%3, %&@TMDNX[%1]}
14323         push{l}\t%3\;call\t%&@TLSPLT\;pop{l}\t%3"
14324   [(set_attr "type" "multi")
14325    (set_attr "length" "13")])
14327 (define_expand "tls_local_dynamic_base_32"
14328   [(parallel [(set (match_operand:SI 0 "register_operand" "")
14329                    (unspec:SI [(match_dup 1) (match_dup 2)]
14330                               UNSPEC_TLS_LD_BASE))
14331               (clobber (match_scratch:SI 3 ""))
14332               (clobber (match_scratch:SI 4 ""))
14333               (clobber (reg:CC 17))])]
14334   ""
14336   if (flag_pic)
14337     operands[1] = pic_offset_table_rtx;
14338   else
14339     {
14340       operands[1] = gen_reg_rtx (Pmode);
14341       emit_insn (gen_set_got (operands[1]));
14342     }
14343   operands[2] = ix86_tls_get_addr ();
14346 (define_insn "*tls_local_dynamic_base_64"
14347   [(set (match_operand:DI 0 "register_operand" "=a")
14348         (call (mem:QI (match_operand:DI 1 "call_insn_operand" ""))
14349                       (match_operand:DI 2 "" "")))
14350    (unspec:DI [(const_int 0)] UNSPEC_TLS_LD_BASE)]
14351   "TARGET_64BIT"
14352   "lea{q}\t{%&@TLSLD(%%rip), %%rdi|%%rdi, %&@TLSLD[%%rip]}\;call\t%P1"
14353   [(set_attr "type" "multi")
14354    (set_attr "length" "12")])
14356 (define_expand "tls_local_dynamic_base_64"
14357   [(parallel [(set (match_operand:DI 0 "register_operand" "")
14358                    (call (mem:QI (match_dup 1)) (const_int 0)))
14359               (unspec:DI [(const_int 0)] UNSPEC_TLS_LD_BASE)])]
14360   ""
14362   operands[1] = ix86_tls_get_addr ();
14365 ;; Local dynamic of a single variable is a lose.  Show combine how
14366 ;; to convert that back to global dynamic.
14368 (define_insn_and_split "*tls_local_dynamic_32_once"
14369   [(set (match_operand:SI 0 "register_operand" "=a")
14370         (plus:SI (unspec:SI [(match_operand:SI 1 "register_operand" "b")
14371                              (match_operand:SI 2 "call_insn_operand" "")]
14372                             UNSPEC_TLS_LD_BASE)
14373                  (const:SI (unspec:SI
14374                             [(match_operand:SI 3 "tls_symbolic_operand" "")]
14375                             UNSPEC_DTPOFF))))
14376    (clobber (match_scratch:SI 4 "=d"))
14377    (clobber (match_scratch:SI 5 "=c"))
14378    (clobber (reg:CC 17))]
14379   ""
14380   "#"
14381   ""
14382   [(parallel [(set (match_dup 0)
14383                    (unspec:SI [(match_dup 1) (match_dup 3) (match_dup 2)]
14384                               UNSPEC_TLS_GD))
14385               (clobber (match_dup 4))
14386               (clobber (match_dup 5))
14387               (clobber (reg:CC 17))])]
14388   "")
14390 ;; These patterns match the binary 387 instructions for addM3, subM3,
14391 ;; mulM3 and divM3.  There are three patterns for each of DFmode and
14392 ;; SFmode.  The first is the normal insn, the second the same insn but
14393 ;; with one operand a conversion, and the third the same insn but with
14394 ;; the other operand a conversion.  The conversion may be SFmode or
14395 ;; SImode if the target mode DFmode, but only SImode if the target mode
14396 ;; is SFmode.
14398 ;; Gcc is slightly more smart about handling normal two address instructions
14399 ;; so use special patterns for add and mull.
14400 (define_insn "*fop_sf_comm_nosse"
14401   [(set (match_operand:SF 0 "register_operand" "=f")
14402         (match_operator:SF 3 "binary_fp_operator"
14403                         [(match_operand:SF 1 "nonimmediate_operand" "%0")
14404                          (match_operand:SF 2 "nonimmediate_operand" "fm")]))]
14405   "TARGET_80387 && !TARGET_SSE_MATH
14406    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
14407    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14408   "* return output_387_binary_op (insn, operands);"
14409   [(set (attr "type") 
14410         (if_then_else (match_operand:SF 3 "mult_operator" "") 
14411            (const_string "fmul")
14412            (const_string "fop")))
14413    (set_attr "mode" "SF")])
14415 (define_insn "*fop_sf_comm"
14416   [(set (match_operand:SF 0 "register_operand" "=f#x,x#f")
14417         (match_operator:SF 3 "binary_fp_operator"
14418                         [(match_operand:SF 1 "nonimmediate_operand" "%0,0")
14419                          (match_operand:SF 2 "nonimmediate_operand" "fm#x,xm#f")]))]
14420   "TARGET_80387 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387
14421    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
14422    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14423   "* return output_387_binary_op (insn, operands);"
14424   [(set (attr "type") 
14425         (if_then_else (eq_attr "alternative" "1")
14426            (if_then_else (match_operand:SF 3 "mult_operator" "") 
14427               (const_string "ssemul")
14428               (const_string "sseadd"))
14429            (if_then_else (match_operand:SF 3 "mult_operator" "") 
14430               (const_string "fmul")
14431               (const_string "fop"))))
14432    (set_attr "mode" "SF")])
14434 (define_insn "*fop_sf_comm_sse"
14435   [(set (match_operand:SF 0 "register_operand" "=x")
14436         (match_operator:SF 3 "binary_fp_operator"
14437                         [(match_operand:SF 1 "nonimmediate_operand" "%0")
14438                          (match_operand:SF 2 "nonimmediate_operand" "xm")]))]
14439   "TARGET_SSE_MATH && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
14440    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14441   "* return output_387_binary_op (insn, operands);"
14442   [(set (attr "type") 
14443         (if_then_else (match_operand:SF 3 "mult_operator" "") 
14444            (const_string "ssemul")
14445            (const_string "sseadd")))
14446    (set_attr "mode" "SF")])
14448 (define_insn "*fop_df_comm_nosse"
14449   [(set (match_operand:DF 0 "register_operand" "=f")
14450         (match_operator:DF 3 "binary_fp_operator"
14451                         [(match_operand:DF 1 "nonimmediate_operand" "%0")
14452                          (match_operand:DF 2 "nonimmediate_operand" "fm")]))]
14453   "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)
14454    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
14455    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14456   "* return output_387_binary_op (insn, operands);"
14457   [(set (attr "type") 
14458         (if_then_else (match_operand:SF 3 "mult_operator" "") 
14459            (const_string "fmul")
14460            (const_string "fop")))
14461    (set_attr "mode" "DF")])
14463 (define_insn "*fop_df_comm"
14464   [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f")
14465         (match_operator:DF 3 "binary_fp_operator"
14466                         [(match_operand:DF 1 "nonimmediate_operand" "%0,0")
14467                          (match_operand:DF 2 "nonimmediate_operand" "fm#Y,Ym#f")]))]
14468   "TARGET_80387 && TARGET_SSE_MATH && TARGET_SSE2 && TARGET_MIX_SSE_I387
14469    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
14470    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14471   "* return output_387_binary_op (insn, operands);"
14472   [(set (attr "type") 
14473         (if_then_else (eq_attr "alternative" "1")
14474            (if_then_else (match_operand:SF 3 "mult_operator" "") 
14475               (const_string "ssemul")
14476               (const_string "sseadd"))
14477            (if_then_else (match_operand:SF 3 "mult_operator" "") 
14478               (const_string "fmul")
14479               (const_string "fop"))))
14480    (set_attr "mode" "DF")])
14482 (define_insn "*fop_df_comm_sse"
14483   [(set (match_operand:DF 0 "register_operand" "=Y")
14484         (match_operator:DF 3 "binary_fp_operator"
14485                         [(match_operand:DF 1 "nonimmediate_operand" "%0")
14486                          (match_operand:DF 2 "nonimmediate_operand" "Ym")]))]
14487   "TARGET_SSE2 && TARGET_SSE_MATH
14488    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'
14489    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14490   "* return output_387_binary_op (insn, operands);"
14491   [(set (attr "type") 
14492         (if_then_else (match_operand:SF 3 "mult_operator" "") 
14493            (const_string "ssemul")
14494            (const_string "sseadd")))
14495    (set_attr "mode" "DF")])
14497 (define_insn "*fop_xf_comm"
14498   [(set (match_operand:XF 0 "register_operand" "=f")
14499         (match_operator:XF 3 "binary_fp_operator"
14500                         [(match_operand:XF 1 "register_operand" "%0")
14501                          (match_operand:XF 2 "register_operand" "f")]))]
14502   "!TARGET_64BIT && TARGET_80387
14503    && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
14504   "* return output_387_binary_op (insn, operands);"
14505   [(set (attr "type") 
14506         (if_then_else (match_operand:XF 3 "mult_operator" "") 
14507            (const_string "fmul")
14508            (const_string "fop")))
14509    (set_attr "mode" "XF")])
14511 (define_insn "*fop_tf_comm"
14512   [(set (match_operand:TF 0 "register_operand" "=f")
14513         (match_operator:TF 3 "binary_fp_operator"
14514                         [(match_operand:TF 1 "register_operand" "%0")
14515                          (match_operand:TF 2 "register_operand" "f")]))]
14516   "TARGET_80387 && GET_RTX_CLASS (GET_CODE (operands[3])) == 'c'"
14517   "* return output_387_binary_op (insn, operands);"
14518   [(set (attr "type") 
14519         (if_then_else (match_operand:TF 3 "mult_operator" "") 
14520            (const_string "fmul")
14521            (const_string "fop")))
14522    (set_attr "mode" "XF")])
14524 (define_insn "*fop_sf_1_nosse"
14525   [(set (match_operand:SF 0 "register_operand" "=f,f")
14526         (match_operator:SF 3 "binary_fp_operator"
14527                         [(match_operand:SF 1 "nonimmediate_operand" "0,fm")
14528                          (match_operand:SF 2 "nonimmediate_operand" "fm,0")]))]
14529   "TARGET_80387 && !TARGET_SSE_MATH
14530    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14531    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14532   "* return output_387_binary_op (insn, operands);"
14533   [(set (attr "type") 
14534         (cond [(match_operand:SF 3 "mult_operator" "") 
14535                  (const_string "fmul")
14536                (match_operand:SF 3 "div_operator" "") 
14537                  (const_string "fdiv")
14538               ]
14539               (const_string "fop")))
14540    (set_attr "mode" "SF")])
14542 (define_insn "*fop_sf_1"
14543   [(set (match_operand:SF 0 "register_operand" "=f,f,x")
14544         (match_operator:SF 3 "binary_fp_operator"
14545                         [(match_operand:SF 1 "nonimmediate_operand" "0,fm,0")
14546                          (match_operand:SF 2 "nonimmediate_operand" "fm,0,xm#f")]))]
14547   "TARGET_80387 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387
14548    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14549    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14550   "* return output_387_binary_op (insn, operands);"
14551   [(set (attr "type") 
14552         (cond [(and (eq_attr "alternative" "2")
14553                     (match_operand:SF 3 "mult_operator" ""))
14554                  (const_string "ssemul")
14555                (and (eq_attr "alternative" "2")
14556                     (match_operand:SF 3 "div_operator" ""))
14557                  (const_string "ssediv")
14558                (eq_attr "alternative" "2")
14559                  (const_string "sseadd")
14560                (match_operand:SF 3 "mult_operator" "") 
14561                  (const_string "fmul")
14562                (match_operand:SF 3 "div_operator" "") 
14563                  (const_string "fdiv")
14564               ]
14565               (const_string "fop")))
14566    (set_attr "mode" "SF")])
14568 (define_insn "*fop_sf_1_sse"
14569   [(set (match_operand:SF 0 "register_operand" "=x")
14570         (match_operator:SF 3 "binary_fp_operator"
14571                         [(match_operand:SF 1 "register_operand" "0")
14572                          (match_operand:SF 2 "nonimmediate_operand" "xm")]))]
14573   "TARGET_SSE_MATH
14574    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14575   "* return output_387_binary_op (insn, operands);"
14576   [(set (attr "type") 
14577         (cond [(match_operand:SF 3 "mult_operator" "")
14578                  (const_string "ssemul")
14579                (match_operand:SF 3 "div_operator" "")
14580                  (const_string "ssediv")
14581               ]
14582               (const_string "sseadd")))
14583    (set_attr "mode" "SF")])
14585 ;; ??? Add SSE splitters for these!
14586 (define_insn "*fop_sf_2"
14587   [(set (match_operand:SF 0 "register_operand" "=f,f")
14588         (match_operator:SF 3 "binary_fp_operator"
14589           [(float:SF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14590            (match_operand:SF 2 "register_operand" "0,0")]))]
14591   "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH"
14592   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14593   [(set (attr "type") 
14594         (cond [(match_operand:SF 3 "mult_operator" "") 
14595                  (const_string "fmul")
14596                (match_operand:SF 3 "div_operator" "") 
14597                  (const_string "fdiv")
14598               ]
14599               (const_string "fop")))
14600    (set_attr "fp_int_src" "true")
14601    (set_attr "ppro_uops" "many")
14602    (set_attr "mode" "SI")])
14604 (define_insn "*fop_sf_3"
14605   [(set (match_operand:SF 0 "register_operand" "=f,f")
14606         (match_operator:SF 3 "binary_fp_operator"
14607           [(match_operand:SF 1 "register_operand" "0,0")
14608            (float:SF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14609   "TARGET_80387 && TARGET_USE_FIOP && !TARGET_SSE_MATH"
14610   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14611   [(set (attr "type") 
14612         (cond [(match_operand:SF 3 "mult_operator" "") 
14613                  (const_string "fmul")
14614                (match_operand:SF 3 "div_operator" "") 
14615                  (const_string "fdiv")
14616               ]
14617               (const_string "fop")))
14618    (set_attr "fp_int_src" "true")
14619    (set_attr "ppro_uops" "many")
14620    (set_attr "mode" "SI")])
14622 (define_insn "*fop_df_1_nosse"
14623   [(set (match_operand:DF 0 "register_operand" "=f,f")
14624         (match_operator:DF 3 "binary_fp_operator"
14625                         [(match_operand:DF 1 "nonimmediate_operand" "0,fm")
14626                          (match_operand:DF 2 "nonimmediate_operand" "fm,0")]))]
14627   "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)
14628    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14629    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14630   "* return output_387_binary_op (insn, operands);"
14631   [(set (attr "type") 
14632         (cond [(match_operand:DF 3 "mult_operator" "") 
14633                  (const_string "fmul")
14634                (match_operand:DF 3 "div_operator" "")
14635                  (const_string "fdiv")
14636               ]
14637               (const_string "fop")))
14638    (set_attr "mode" "DF")])
14641 (define_insn "*fop_df_1"
14642   [(set (match_operand:DF 0 "register_operand" "=f#Y,f#Y,Y#f")
14643         (match_operator:DF 3 "binary_fp_operator"
14644                         [(match_operand:DF 1 "nonimmediate_operand" "0,fm,0")
14645                          (match_operand:DF 2 "nonimmediate_operand" "fm,0,Ym#f")]))]
14646   "TARGET_80387 && TARGET_SSE2 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387
14647    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'
14648    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14649   "* return output_387_binary_op (insn, operands);"
14650   [(set (attr "type") 
14651         (cond [(and (eq_attr "alternative" "2")
14652                     (match_operand:SF 3 "mult_operator" ""))
14653                  (const_string "ssemul")
14654                (and (eq_attr "alternative" "2")
14655                     (match_operand:SF 3 "div_operator" ""))
14656                  (const_string "ssediv")
14657                (eq_attr "alternative" "2")
14658                  (const_string "sseadd")
14659                (match_operand:DF 3 "mult_operator" "") 
14660                  (const_string "fmul")
14661                (match_operand:DF 3 "div_operator" "") 
14662                  (const_string "fdiv")
14663               ]
14664               (const_string "fop")))
14665    (set_attr "mode" "DF")])
14667 (define_insn "*fop_df_1_sse"
14668   [(set (match_operand:DF 0 "register_operand" "=Y")
14669         (match_operator:DF 3 "binary_fp_operator"
14670                         [(match_operand:DF 1 "register_operand" "0")
14671                          (match_operand:DF 2 "nonimmediate_operand" "Ym")]))]
14672   "TARGET_SSE2 && TARGET_SSE_MATH
14673    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14674   "* return output_387_binary_op (insn, operands);"
14675   [(set_attr "mode" "DF")
14676    (set (attr "type") 
14677         (cond [(match_operand:SF 3 "mult_operator" "")
14678                  (const_string "ssemul")
14679                (match_operand:SF 3 "div_operator" "")
14680                  (const_string "ssediv")
14681               ]
14682               (const_string "sseadd")))])
14684 ;; ??? Add SSE splitters for these!
14685 (define_insn "*fop_df_2"
14686   [(set (match_operand:DF 0 "register_operand" "=f,f")
14687         (match_operator:DF 3 "binary_fp_operator"
14688            [(float:DF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14689             (match_operand:DF 2 "register_operand" "0,0")]))]
14690   "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14691   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14692   [(set (attr "type") 
14693         (cond [(match_operand:DF 3 "mult_operator" "") 
14694                  (const_string "fmul")
14695                (match_operand:DF 3 "div_operator" "") 
14696                  (const_string "fdiv")
14697               ]
14698               (const_string "fop")))
14699    (set_attr "fp_int_src" "true")
14700    (set_attr "ppro_uops" "many")
14701    (set_attr "mode" "SI")])
14703 (define_insn "*fop_df_3"
14704   [(set (match_operand:DF 0 "register_operand" "=f,f")
14705         (match_operator:DF 3 "binary_fp_operator"
14706            [(match_operand:DF 1 "register_operand" "0,0")
14707             (float:DF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14708   "TARGET_80387 && TARGET_USE_FIOP && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14709   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14710   [(set (attr "type") 
14711         (cond [(match_operand:DF 3 "mult_operator" "") 
14712                  (const_string "fmul")
14713                (match_operand:DF 3 "div_operator" "") 
14714                  (const_string "fdiv")
14715               ]
14716               (const_string "fop")))
14717    (set_attr "fp_int_src" "true")
14718    (set_attr "ppro_uops" "many")
14719    (set_attr "mode" "SI")])
14721 (define_insn "*fop_df_4"
14722   [(set (match_operand:DF 0 "register_operand" "=f,f")
14723         (match_operator:DF 3 "binary_fp_operator"
14724            [(float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "fm,0"))
14725             (match_operand:DF 2 "register_operand" "0,f")]))]
14726   "TARGET_80387 && (!TARGET_SSE2 || !TARGET_SSE_MATH)
14727    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
14728   "* return output_387_binary_op (insn, operands);"
14729   [(set (attr "type") 
14730         (cond [(match_operand:DF 3 "mult_operator" "") 
14731                  (const_string "fmul")
14732                (match_operand:DF 3 "div_operator" "") 
14733                  (const_string "fdiv")
14734               ]
14735               (const_string "fop")))
14736    (set_attr "mode" "SF")])
14738 (define_insn "*fop_df_5"
14739   [(set (match_operand:DF 0 "register_operand" "=f,f")
14740         (match_operator:DF 3 "binary_fp_operator"
14741           [(match_operand:DF 1 "register_operand" "0,f")
14742            (float_extend:DF
14743             (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
14744   "TARGET_80387 && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14745   "* return output_387_binary_op (insn, operands);"
14746   [(set (attr "type") 
14747         (cond [(match_operand:DF 3 "mult_operator" "") 
14748                  (const_string "fmul")
14749                (match_operand:DF 3 "div_operator" "") 
14750                  (const_string "fdiv")
14751               ]
14752               (const_string "fop")))
14753    (set_attr "mode" "SF")])
14755 (define_insn "*fop_df_6"
14756   [(set (match_operand:DF 0 "register_operand" "=f,f")
14757         (match_operator:DF 3 "binary_fp_operator"
14758           [(float_extend:DF
14759             (match_operand:SF 1 "register_operand" "0,f"))
14760            (float_extend:DF
14761             (match_operand:SF 2 "nonimmediate_operand" "fm,0"))]))]
14762   "TARGET_80387 && !(TARGET_SSE2 && TARGET_SSE_MATH)"
14763   "* return output_387_binary_op (insn, operands);"
14764   [(set (attr "type") 
14765         (cond [(match_operand:DF 3 "mult_operator" "") 
14766                  (const_string "fmul")
14767                (match_operand:DF 3 "div_operator" "") 
14768                  (const_string "fdiv")
14769               ]
14770               (const_string "fop")))
14771    (set_attr "mode" "SF")])
14773 (define_insn "*fop_xf_1"
14774   [(set (match_operand:XF 0 "register_operand" "=f,f")
14775         (match_operator:XF 3 "binary_fp_operator"
14776                         [(match_operand:XF 1 "register_operand" "0,f")
14777                          (match_operand:XF 2 "register_operand" "f,0")]))]
14778   "!TARGET_64BIT && TARGET_80387
14779    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14780   "* return output_387_binary_op (insn, operands);"
14781   [(set (attr "type") 
14782         (cond [(match_operand:XF 3 "mult_operator" "") 
14783                  (const_string "fmul")
14784                (match_operand:XF 3 "div_operator" "") 
14785                  (const_string "fdiv")
14786               ]
14787               (const_string "fop")))
14788    (set_attr "mode" "XF")])
14790 (define_insn "*fop_tf_1"
14791   [(set (match_operand:TF 0 "register_operand" "=f,f")
14792         (match_operator:TF 3 "binary_fp_operator"
14793                         [(match_operand:TF 1 "register_operand" "0,f")
14794                          (match_operand:TF 2 "register_operand" "f,0")]))]
14795   "TARGET_80387
14796    && GET_RTX_CLASS (GET_CODE (operands[3])) != 'c'"
14797   "* return output_387_binary_op (insn, operands);"
14798   [(set (attr "type") 
14799         (cond [(match_operand:TF 3 "mult_operator" "") 
14800                  (const_string "fmul")
14801                (match_operand:TF 3 "div_operator" "") 
14802                  (const_string "fdiv")
14803               ]
14804               (const_string "fop")))
14805    (set_attr "mode" "XF")])
14807 (define_insn "*fop_xf_2"
14808   [(set (match_operand:XF 0 "register_operand" "=f,f")
14809         (match_operator:XF 3 "binary_fp_operator"
14810            [(float:XF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14811             (match_operand:XF 2 "register_operand" "0,0")]))]
14812   "!TARGET_64BIT && TARGET_80387 && TARGET_USE_FIOP"
14813   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14814   [(set (attr "type") 
14815         (cond [(match_operand:XF 3 "mult_operator" "") 
14816                  (const_string "fmul")
14817                (match_operand:XF 3 "div_operator" "") 
14818                  (const_string "fdiv")
14819               ]
14820               (const_string "fop")))
14821    (set_attr "fp_int_src" "true")
14822    (set_attr "mode" "SI")
14823    (set_attr "ppro_uops" "many")])
14825 (define_insn "*fop_tf_2"
14826   [(set (match_operand:TF 0 "register_operand" "=f,f")
14827         (match_operator:TF 3 "binary_fp_operator"
14828            [(float:TF (match_operand:SI 1 "nonimmediate_operand" "m,?r"))
14829             (match_operand:TF 2 "register_operand" "0,0")]))]
14830   "TARGET_80387 && TARGET_USE_FIOP"
14831   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14832   [(set (attr "type") 
14833         (cond [(match_operand:TF 3 "mult_operator" "") 
14834                  (const_string "fmul")
14835                (match_operand:TF 3 "div_operator" "") 
14836                  (const_string "fdiv")
14837               ]
14838               (const_string "fop")))
14839    (set_attr "fp_int_src" "true")
14840    (set_attr "mode" "SI")
14841    (set_attr "ppro_uops" "many")])
14843 (define_insn "*fop_xf_3"
14844   [(set (match_operand:XF 0 "register_operand" "=f,f")
14845         (match_operator:XF 3 "binary_fp_operator"
14846           [(match_operand:XF 1 "register_operand" "0,0")
14847            (float:XF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14848   "!TARGET_64BIT && TARGET_80387 && TARGET_USE_FIOP"
14849   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14850   [(set (attr "type") 
14851         (cond [(match_operand:XF 3 "mult_operator" "") 
14852                  (const_string "fmul")
14853                (match_operand:XF 3 "div_operator" "") 
14854                  (const_string "fdiv")
14855               ]
14856               (const_string "fop")))
14857    (set_attr "fp_int_src" "true")
14858    (set_attr "mode" "SI")
14859    (set_attr "ppro_uops" "many")])
14861 (define_insn "*fop_tf_3"
14862   [(set (match_operand:TF 0 "register_operand" "=f,f")
14863         (match_operator:TF 3 "binary_fp_operator"
14864           [(match_operand:TF 1 "register_operand" "0,0")
14865            (float:TF (match_operand:SI 2 "nonimmediate_operand" "m,?r"))]))]
14866   "TARGET_80387 && TARGET_USE_FIOP"
14867   "* return which_alternative ? \"#\" : output_387_binary_op (insn, operands);"
14868   [(set (attr "type") 
14869         (cond [(match_operand:TF 3 "mult_operator" "") 
14870                  (const_string "fmul")
14871                (match_operand:TF 3 "div_operator" "") 
14872                  (const_string "fdiv")
14873               ]
14874               (const_string "fop")))
14875    (set_attr "fp_int_src" "true")
14876    (set_attr "mode" "SI")
14877    (set_attr "ppro_uops" "many")])
14879 (define_insn "*fop_xf_4"
14880   [(set (match_operand:XF 0 "register_operand" "=f,f")
14881         (match_operator:XF 3 "binary_fp_operator"
14882            [(float_extend:XF (match_operand 1 "nonimmediate_operand" "fm,0"))
14883             (match_operand:XF 2 "register_operand" "0,f")]))]
14884   "!TARGET_64BIT && TARGET_80387"
14885   "* return output_387_binary_op (insn, operands);"
14886   [(set (attr "type") 
14887         (cond [(match_operand:XF 3 "mult_operator" "") 
14888                  (const_string "fmul")
14889                (match_operand:XF 3 "div_operator" "") 
14890                  (const_string "fdiv")
14891               ]
14892               (const_string "fop")))
14893    (set_attr "mode" "SF")])
14895 (define_insn "*fop_tf_4"
14896   [(set (match_operand:TF 0 "register_operand" "=f,f")
14897         (match_operator:TF 3 "binary_fp_operator"
14898            [(float_extend:TF (match_operand 1 "nonimmediate_operand" "fm,0"))
14899             (match_operand:TF 2 "register_operand" "0,f")]))]
14900   "TARGET_80387"
14901   "* return output_387_binary_op (insn, operands);"
14902   [(set (attr "type") 
14903         (cond [(match_operand:TF 3 "mult_operator" "") 
14904                  (const_string "fmul")
14905                (match_operand:TF 3 "div_operator" "") 
14906                  (const_string "fdiv")
14907               ]
14908               (const_string "fop")))
14909    (set_attr "mode" "SF")])
14911 (define_insn "*fop_xf_5"
14912   [(set (match_operand:XF 0 "register_operand" "=f,f")
14913         (match_operator:XF 3 "binary_fp_operator"
14914           [(match_operand:XF 1 "register_operand" "0,f")
14915            (float_extend:XF
14916             (match_operand 2 "nonimmediate_operand" "fm,0"))]))]
14917   "!TARGET_64BIT && TARGET_80387"
14918   "* return output_387_binary_op (insn, operands);"
14919   [(set (attr "type") 
14920         (cond [(match_operand:XF 3 "mult_operator" "") 
14921                  (const_string "fmul")
14922                (match_operand:XF 3 "div_operator" "") 
14923                  (const_string "fdiv")
14924               ]
14925               (const_string "fop")))
14926    (set_attr "mode" "SF")])
14928 (define_insn "*fop_tf_5"
14929   [(set (match_operand:TF 0 "register_operand" "=f,f")
14930         (match_operator:TF 3 "binary_fp_operator"
14931           [(match_operand:TF 1 "register_operand" "0,f")
14932            (float_extend:TF
14933             (match_operand 2 "nonimmediate_operand" "fm,0"))]))]
14934   "TARGET_80387"
14935   "* return output_387_binary_op (insn, operands);"
14936   [(set (attr "type") 
14937         (cond [(match_operand:TF 3 "mult_operator" "") 
14938                  (const_string "fmul")
14939                (match_operand:TF 3 "div_operator" "") 
14940                  (const_string "fdiv")
14941               ]
14942               (const_string "fop")))
14943    (set_attr "mode" "SF")])
14945 (define_insn "*fop_xf_6"
14946   [(set (match_operand:XF 0 "register_operand" "=f,f")
14947         (match_operator:XF 3 "binary_fp_operator"
14948           [(float_extend:XF
14949             (match_operand 1 "register_operand" "0,f"))
14950            (float_extend:XF
14951             (match_operand 2 "nonimmediate_operand" "fm,0"))]))]
14952   "!TARGET_64BIT && TARGET_80387"
14953   "* return output_387_binary_op (insn, operands);"
14954   [(set (attr "type") 
14955         (cond [(match_operand:XF 3 "mult_operator" "") 
14956                  (const_string "fmul")
14957                (match_operand:XF 3 "div_operator" "") 
14958                  (const_string "fdiv")
14959               ]
14960               (const_string "fop")))
14961    (set_attr "mode" "SF")])
14963 (define_insn "*fop_tf_6"
14964   [(set (match_operand:TF 0 "register_operand" "=f,f")
14965         (match_operator:TF 3 "binary_fp_operator"
14966           [(float_extend:TF
14967             (match_operand 1 "register_operand" "0,f"))
14968            (float_extend:TF
14969             (match_operand 2 "nonimmediate_operand" "fm,0"))]))]
14970   "TARGET_80387"
14971   "* return output_387_binary_op (insn, operands);"
14972   [(set (attr "type") 
14973         (cond [(match_operand:TF 3 "mult_operator" "") 
14974                  (const_string "fmul")
14975                (match_operand:TF 3 "div_operator" "") 
14976                  (const_string "fdiv")
14977               ]
14978               (const_string "fop")))
14979    (set_attr "mode" "SF")])
14981 (define_split
14982   [(set (match_operand 0 "register_operand" "")
14983         (match_operator 3 "binary_fp_operator"
14984            [(float (match_operand:SI 1 "register_operand" ""))
14985             (match_operand 2 "register_operand" "")]))]
14986   "TARGET_80387 && reload_completed
14987    && FLOAT_MODE_P (GET_MODE (operands[0]))"
14988   [(const_int 0)]
14990   operands[4] = ix86_force_to_memory (GET_MODE (operands[1]), operands[1]);
14991   operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
14992   emit_insn (gen_rtx_SET (VOIDmode, operands[0],
14993                           gen_rtx_fmt_ee (GET_CODE (operands[3]),
14994                                           GET_MODE (operands[3]),
14995                                           operands[4],
14996                                           operands[2])));
14997   ix86_free_from_memory (GET_MODE (operands[1]));
14998   DONE;
15001 (define_split
15002   [(set (match_operand 0 "register_operand" "")
15003         (match_operator 3 "binary_fp_operator"
15004            [(match_operand 1 "register_operand" "")
15005             (float (match_operand:SI 2 "register_operand" ""))]))]
15006   "TARGET_80387 && reload_completed
15007    && FLOAT_MODE_P (GET_MODE (operands[0]))"
15008   [(const_int 0)]
15010   operands[4] = ix86_force_to_memory (GET_MODE (operands[2]), operands[2]);
15011   operands[4] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[4]);
15012   emit_insn (gen_rtx_SET (VOIDmode, operands[0],
15013                           gen_rtx_fmt_ee (GET_CODE (operands[3]),
15014                                           GET_MODE (operands[3]),
15015                                           operands[1],
15016                                           operands[4])));
15017   ix86_free_from_memory (GET_MODE (operands[2]));
15018   DONE;
15021 ;; FPU special functions.
15023 (define_expand "sqrtsf2"
15024   [(set (match_operand:SF 0 "register_operand" "")
15025         (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "")))]
15026   "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387) || TARGET_SSE_MATH"
15028   if (!TARGET_SSE_MATH)
15029     operands[1] = force_reg (SFmode, operands[1]);
15032 (define_insn "sqrtsf2_1"
15033   [(set (match_operand:SF 0 "register_operand" "=f#x,x#f")
15034         (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "0#x,xm#f")))]
15035   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15036    && (TARGET_SSE_MATH && TARGET_MIX_SSE_I387)"
15037   "@
15038    fsqrt
15039    sqrtss\t{%1, %0|%0, %1}"
15040   [(set_attr "type" "fpspc,sse")
15041    (set_attr "mode" "SF,SF")
15042    (set_attr "athlon_decode" "direct,*")])
15044 (define_insn "sqrtsf2_1_sse_only"
15045   [(set (match_operand:SF 0 "register_operand" "=x")
15046         (sqrt:SF (match_operand:SF 1 "nonimmediate_operand" "xm")))]
15047   "TARGET_SSE_MATH && (!TARGET_80387 || !TARGET_MIX_SSE_I387)"
15048   "sqrtss\t{%1, %0|%0, %1}"
15049   [(set_attr "type" "sse")
15050    (set_attr "mode" "SF")
15051    (set_attr "athlon_decode" "*")])
15053 (define_insn "sqrtsf2_i387"
15054   [(set (match_operand:SF 0 "register_operand" "=f")
15055         (sqrt:SF (match_operand:SF 1 "register_operand" "0")))]
15056   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15057    && !TARGET_SSE_MATH"
15058   "fsqrt"
15059   [(set_attr "type" "fpspc")
15060    (set_attr "mode" "SF")
15061    (set_attr "athlon_decode" "direct")])
15063 (define_expand "sqrtdf2"
15064   [(set (match_operand:DF 0 "register_operand" "")
15065         (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "")))]
15066   "(! TARGET_NO_FANCY_MATH_387 && TARGET_80387)
15067    || (TARGET_SSE2 && TARGET_SSE_MATH)"
15069   if (!TARGET_SSE2 || !TARGET_SSE_MATH)
15070     operands[1] = force_reg (DFmode, operands[1]);
15073 (define_insn "sqrtdf2_1"
15074   [(set (match_operand:DF 0 "register_operand" "=f#Y,Y#f")
15075         (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "0#Y,Ym#f")))]
15076   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15077    && (TARGET_SSE2 && TARGET_SSE_MATH && TARGET_MIX_SSE_I387)"
15078   "@
15079    fsqrt
15080    sqrtsd\t{%1, %0|%0, %1}"
15081   [(set_attr "type" "fpspc,sse")
15082    (set_attr "mode" "DF,DF")
15083    (set_attr "athlon_decode" "direct,*")])
15085 (define_insn "sqrtdf2_1_sse_only"
15086   [(set (match_operand:DF 0 "register_operand" "=Y")
15087         (sqrt:DF (match_operand:DF 1 "nonimmediate_operand" "Ym")))]
15088   "TARGET_SSE2 && TARGET_SSE_MATH && (!TARGET_80387 || !TARGET_MIX_SSE_I387)"
15089   "sqrtsd\t{%1, %0|%0, %1}"
15090   [(set_attr "type" "sse")
15091    (set_attr "mode" "DF")
15092    (set_attr "athlon_decode" "*")])
15094 (define_insn "sqrtdf2_i387"
15095   [(set (match_operand:DF 0 "register_operand" "=f")
15096         (sqrt:DF (match_operand:DF 1 "register_operand" "0")))]
15097   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15098    && (!TARGET_SSE2 || !TARGET_SSE_MATH)"
15099   "fsqrt"
15100   [(set_attr "type" "fpspc")
15101    (set_attr "mode" "DF")
15102    (set_attr "athlon_decode" "direct")])
15104 (define_insn "*sqrtextendsfdf2"
15105   [(set (match_operand:DF 0 "register_operand" "=f")
15106         (sqrt:DF (float_extend:DF
15107                   (match_operand:SF 1 "register_operand" "0"))))]
15108   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15109    && !(TARGET_SSE2 && TARGET_SSE_MATH)"
15110   "fsqrt"
15111   [(set_attr "type" "fpspc")
15112    (set_attr "mode" "DF")
15113    (set_attr "athlon_decode" "direct")])
15115 (define_insn "sqrtxf2"
15116   [(set (match_operand:XF 0 "register_operand" "=f")
15117         (sqrt:XF (match_operand:XF 1 "register_operand" "0")))]
15118   "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387 
15119    && (TARGET_IEEE_FP || flag_unsafe_math_optimizations) "
15120   "fsqrt"
15121   [(set_attr "type" "fpspc")
15122    (set_attr "mode" "XF")
15123    (set_attr "athlon_decode" "direct")])
15125 (define_insn "sqrttf2"
15126   [(set (match_operand:TF 0 "register_operand" "=f")
15127         (sqrt:TF (match_operand:TF 1 "register_operand" "0")))]
15128   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
15129    && (TARGET_IEEE_FP || flag_unsafe_math_optimizations) "
15130   "fsqrt"
15131   [(set_attr "type" "fpspc")
15132    (set_attr "mode" "XF")
15133    (set_attr "athlon_decode" "direct")])
15135 (define_insn "*sqrtextenddfxf2"
15136   [(set (match_operand:XF 0 "register_operand" "=f")
15137         (sqrt:XF (float_extend:XF
15138                   (match_operand:DF 1 "register_operand" "0"))))]
15139   "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387"
15140   "fsqrt"
15141   [(set_attr "type" "fpspc")
15142    (set_attr "mode" "XF")
15143    (set_attr "athlon_decode" "direct")])
15145 (define_insn "*sqrtextenddftf2"
15146   [(set (match_operand:TF 0 "register_operand" "=f")
15147         (sqrt:TF (float_extend:TF
15148                   (match_operand:DF 1 "register_operand" "0"))))]
15149   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
15150   "fsqrt"
15151   [(set_attr "type" "fpspc")
15152    (set_attr "mode" "XF")
15153    (set_attr "athlon_decode" "direct")])
15155 (define_insn "*sqrtextendsfxf2"
15156   [(set (match_operand:XF 0 "register_operand" "=f")
15157         (sqrt:XF (float_extend:XF
15158                   (match_operand:SF 1 "register_operand" "0"))))]
15159   "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387"
15160   "fsqrt"
15161   [(set_attr "type" "fpspc")
15162    (set_attr "mode" "XF")
15163    (set_attr "athlon_decode" "direct")])
15165 (define_insn "*sqrtextendsftf2"
15166   [(set (match_operand:TF 0 "register_operand" "=f")
15167         (sqrt:TF (float_extend:TF
15168                   (match_operand:SF 1 "register_operand" "0"))))]
15169   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387"
15170   "fsqrt"
15171   [(set_attr "type" "fpspc")
15172    (set_attr "mode" "XF")
15173    (set_attr "athlon_decode" "direct")])
15175 (define_insn "sindf2"
15176   [(set (match_operand:DF 0 "register_operand" "=f")
15177         (unspec:DF [(match_operand:DF 1 "register_operand" "0")] UNSPEC_SIN))]
15178   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
15179    && flag_unsafe_math_optimizations"
15180   "fsin"
15181   [(set_attr "type" "fpspc")
15182    (set_attr "mode" "DF")])
15184 (define_insn "sinsf2"
15185   [(set (match_operand:SF 0 "register_operand" "=f")
15186         (unspec:SF [(match_operand:SF 1 "register_operand" "0")] UNSPEC_SIN))]
15187   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
15188    && flag_unsafe_math_optimizations"
15189   "fsin"
15190   [(set_attr "type" "fpspc")
15191    (set_attr "mode" "SF")])
15193 (define_insn "*sinextendsfdf2"
15194   [(set (match_operand:DF 0 "register_operand" "=f")
15195         (unspec:DF [(float_extend:DF
15196                      (match_operand:SF 1 "register_operand" "0"))]
15197                    UNSPEC_SIN))]
15198   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
15199    && flag_unsafe_math_optimizations"
15200   "fsin"
15201   [(set_attr "type" "fpspc")
15202    (set_attr "mode" "DF")])
15204 (define_insn "sinxf2"
15205   [(set (match_operand:XF 0 "register_operand" "=f")
15206         (unspec:XF [(match_operand:XF 1 "register_operand" "0")] UNSPEC_SIN))]
15207   "!TARGET_64BIT && TARGET_80387 && !TARGET_NO_FANCY_MATH_387
15208    && flag_unsafe_math_optimizations"
15209   "fsin"
15210   [(set_attr "type" "fpspc")
15211    (set_attr "mode" "XF")])
15213 (define_insn "sintf2"
15214   [(set (match_operand:TF 0 "register_operand" "=f")
15215         (unspec:TF [(match_operand:TF 1 "register_operand" "0")] UNSPEC_SIN))]
15216   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
15217    && flag_unsafe_math_optimizations"
15218   "fsin"
15219   [(set_attr "type" "fpspc")
15220    (set_attr "mode" "XF")])
15222 (define_insn "cosdf2"
15223   [(set (match_operand:DF 0 "register_operand" "=f")
15224         (unspec:DF [(match_operand:DF 1 "register_operand" "0")] UNSPEC_COS))]
15225   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
15226    && flag_unsafe_math_optimizations"
15227   "fcos"
15228   [(set_attr "type" "fpspc")
15229    (set_attr "mode" "DF")])
15231 (define_insn "cossf2"
15232   [(set (match_operand:SF 0 "register_operand" "=f")
15233         (unspec:SF [(match_operand:SF 1 "register_operand" "0")] UNSPEC_COS))]
15234   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
15235    && flag_unsafe_math_optimizations"
15236   "fcos"
15237   [(set_attr "type" "fpspc")
15238    (set_attr "mode" "SF")])
15240 (define_insn "*cosextendsfdf2"
15241   [(set (match_operand:DF 0 "register_operand" "=f")
15242         (unspec:DF [(float_extend:DF
15243                      (match_operand:SF 1 "register_operand" "0"))]
15244                    UNSPEC_COS))]
15245   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
15246    && flag_unsafe_math_optimizations"
15247   "fcos"
15248   [(set_attr "type" "fpspc")
15249    (set_attr "mode" "DF")])
15251 (define_insn "cosxf2"
15252   [(set (match_operand:XF 0 "register_operand" "=f")
15253         (unspec:XF [(match_operand:XF 1 "register_operand" "0")] UNSPEC_COS))]
15254   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387
15255    && flag_unsafe_math_optimizations"
15256   "fcos"
15257   [(set_attr "type" "fpspc")
15258    (set_attr "mode" "XF")])
15260 (define_insn "costf2"
15261   [(set (match_operand:TF 0 "register_operand" "=f")
15262         (unspec:TF [(match_operand:TF 1 "register_operand" "0")] UNSPEC_COS))]
15263   "! TARGET_NO_FANCY_MATH_387 && TARGET_80387 
15264    && flag_unsafe_math_optimizations"
15265   "fcos"
15266   [(set_attr "type" "fpspc")
15267    (set_attr "mode" "XF")])
15269 ;; Block operation instructions
15271 (define_insn "cld"
15272  [(set (reg:SI 19) (const_int 0))]
15273  ""
15274  "cld"
15275   [(set_attr "type" "cld")])
15277 (define_expand "movstrsi"
15278   [(use (match_operand:BLK 0 "memory_operand" ""))
15279    (use (match_operand:BLK 1 "memory_operand" ""))
15280    (use (match_operand:SI 2 "nonmemory_operand" ""))
15281    (use (match_operand:SI 3 "const_int_operand" ""))]
15282   ""
15284  if (ix86_expand_movstr (operands[0], operands[1], operands[2], operands[3]))
15285    DONE;
15286  else
15287    FAIL;
15290 (define_expand "movstrdi"
15291   [(use (match_operand:BLK 0 "memory_operand" ""))
15292    (use (match_operand:BLK 1 "memory_operand" ""))
15293    (use (match_operand:DI 2 "nonmemory_operand" ""))
15294    (use (match_operand:DI 3 "const_int_operand" ""))]
15295   "TARGET_64BIT"
15297  if (ix86_expand_movstr (operands[0], operands[1], operands[2], operands[3]))
15298    DONE;
15299  else
15300    FAIL;
15303 ;; Most CPUs don't like single string operations
15304 ;; Handle this case here to simplify previous expander.
15306 (define_expand "strmovdi_rex64"
15307   [(set (match_dup 2)
15308         (mem:DI (match_operand:DI 1 "register_operand" "")))
15309    (set (mem:DI (match_operand:DI 0 "register_operand" ""))
15310         (match_dup 2))
15311    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 8)))
15312               (clobber (reg:CC 17))])
15313    (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 8)))
15314               (clobber (reg:CC 17))])]
15315   "TARGET_64BIT"
15317   if (TARGET_SINGLE_STRINGOP || optimize_size)
15318     {
15319       emit_insn (gen_strmovdi_rex_1 (operands[0], operands[1], operands[0],
15320                                      operands[1]));
15321       DONE;
15322     }
15323   else 
15324     operands[2] = gen_reg_rtx (DImode);
15328 (define_expand "strmovsi"
15329   [(set (match_dup 2)
15330         (mem:SI (match_operand:SI 1 "register_operand" "")))
15331    (set (mem:SI (match_operand:SI 0 "register_operand" ""))
15332         (match_dup 2))
15333    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4)))
15334               (clobber (reg:CC 17))])
15335    (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 4)))
15336               (clobber (reg:CC 17))])]
15337   ""
15339   if (TARGET_64BIT)
15340     {
15341       emit_insn (gen_strmovsi_rex64 (operands[0], operands[1]));
15342       DONE;
15343     }
15344   if (TARGET_SINGLE_STRINGOP || optimize_size)
15345     {
15346       emit_insn (gen_strmovsi_1 (operands[0], operands[1], operands[0],
15347                                 operands[1]));
15348       DONE;
15349     }
15350   else 
15351     operands[2] = gen_reg_rtx (SImode);
15354 (define_expand "strmovsi_rex64"
15355   [(set (match_dup 2)
15356         (mem:SI (match_operand:DI 1 "register_operand" "")))
15357    (set (mem:SI (match_operand:DI 0 "register_operand" ""))
15358         (match_dup 2))
15359    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 4)))
15360               (clobber (reg:CC 17))])
15361    (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 4)))
15362               (clobber (reg:CC 17))])]
15363   "TARGET_64BIT"
15365   if (TARGET_SINGLE_STRINGOP || optimize_size)
15366     {
15367       emit_insn (gen_strmovsi_rex_1 (operands[0], operands[1], operands[0],
15368                                      operands[1]));
15369       DONE;
15370     }
15371   else 
15372     operands[2] = gen_reg_rtx (SImode);
15375 (define_expand "strmovhi"
15376   [(set (match_dup 2)
15377         (mem:HI (match_operand:SI 1 "register_operand" "")))
15378    (set (mem:HI (match_operand:SI 0 "register_operand" ""))
15379         (match_dup 2))
15380    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2)))
15381               (clobber (reg:CC 17))])
15382    (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 2)))
15383               (clobber (reg:CC 17))])]
15384   ""
15386   if (TARGET_64BIT)
15387     {
15388       emit_insn (gen_strmovhi_rex64 (operands[0], operands[1]));
15389       DONE;
15390     }
15391   if (TARGET_SINGLE_STRINGOP || optimize_size)
15392     {
15393       emit_insn (gen_strmovhi_1 (operands[0], operands[1], operands[0],
15394                                 operands[1]));
15395       DONE;
15396     }
15397   else 
15398     operands[2] = gen_reg_rtx (HImode);
15401 (define_expand "strmovhi_rex64"
15402   [(set (match_dup 2)
15403         (mem:HI (match_operand:DI 1 "register_operand" "")))
15404    (set (mem:HI (match_operand:DI 0 "register_operand" ""))
15405         (match_dup 2))
15406    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 2)))
15407               (clobber (reg:CC 17))])
15408    (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 2)))
15409               (clobber (reg:CC 17))])]
15410   "TARGET_64BIT"
15412   if (TARGET_SINGLE_STRINGOP || optimize_size)
15413     {
15414       emit_insn (gen_strmovhi_rex_1 (operands[0], operands[1], operands[0],
15415                                      operands[1]));
15416       DONE;
15417     }
15418   else 
15419     operands[2] = gen_reg_rtx (HImode);
15422 (define_expand "strmovqi"
15423   [(set (match_dup 2)
15424         (mem:QI (match_operand:SI 1 "register_operand" "")))
15425    (set (mem:QI (match_operand:SI 0 "register_operand" ""))
15426         (match_dup 2))
15427    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
15428               (clobber (reg:CC 17))])
15429    (parallel [(set (match_dup 1) (plus:SI (match_dup 1) (const_int 1)))
15430               (clobber (reg:CC 17))])]
15431   ""
15433   if (TARGET_64BIT)
15434     {
15435       emit_insn (gen_strmovqi_rex64 (operands[0], operands[1]));
15436       DONE;
15437     }
15438   if (TARGET_SINGLE_STRINGOP || optimize_size)
15439     {
15440       emit_insn (gen_strmovqi_1 (operands[0], operands[1], operands[0],
15441                                 operands[1]));
15442       DONE;
15443     }
15444   else 
15445     operands[2] = gen_reg_rtx (QImode);
15448 (define_expand "strmovqi_rex64"
15449   [(set (match_dup 2)
15450         (mem:QI (match_operand:DI 1 "register_operand" "")))
15451    (set (mem:QI (match_operand:DI 0 "register_operand" ""))
15452         (match_dup 2))
15453    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 1)))
15454               (clobber (reg:CC 17))])
15455    (parallel [(set (match_dup 1) (plus:DI (match_dup 1) (const_int 1)))
15456               (clobber (reg:CC 17))])]
15457   "TARGET_64BIT"
15459   if (TARGET_SINGLE_STRINGOP || optimize_size)
15460     {
15461       emit_insn (gen_strmovqi_rex_1 (operands[0], operands[1], operands[0],
15462                                      operands[1]));
15463       DONE;
15464     }
15465   else 
15466     operands[2] = gen_reg_rtx (QImode);
15469 (define_insn "strmovdi_rex_1"
15470   [(set (mem:DI (match_operand:DI 2 "register_operand" "0"))
15471         (mem:DI (match_operand:DI 3 "register_operand" "1")))
15472    (set (match_operand:DI 0 "register_operand" "=D")
15473         (plus:DI (match_dup 2)
15474                  (const_int 8)))
15475    (set (match_operand:DI 1 "register_operand" "=S")
15476         (plus:DI (match_dup 3)
15477                  (const_int 8)))
15478    (use (reg:SI 19))]
15479   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15480   "movsq"
15481   [(set_attr "type" "str")
15482    (set_attr "mode" "DI")
15483    (set_attr "memory" "both")])
15485 (define_insn "strmovsi_1"
15486   [(set (mem:SI (match_operand:SI 2 "register_operand" "0"))
15487         (mem:SI (match_operand:SI 3 "register_operand" "1")))
15488    (set (match_operand:SI 0 "register_operand" "=D")
15489         (plus:SI (match_dup 2)
15490                  (const_int 4)))
15491    (set (match_operand:SI 1 "register_operand" "=S")
15492         (plus:SI (match_dup 3)
15493                  (const_int 4)))
15494    (use (reg:SI 19))]
15495   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15496   "{movsl|movsd}"
15497   [(set_attr "type" "str")
15498    (set_attr "mode" "SI")
15499    (set_attr "memory" "both")])
15501 (define_insn "strmovsi_rex_1"
15502   [(set (mem:SI (match_operand:DI 2 "register_operand" "0"))
15503         (mem:SI (match_operand:DI 3 "register_operand" "1")))
15504    (set (match_operand:DI 0 "register_operand" "=D")
15505         (plus:DI (match_dup 2)
15506                  (const_int 4)))
15507    (set (match_operand:DI 1 "register_operand" "=S")
15508         (plus:DI (match_dup 3)
15509                  (const_int 4)))
15510    (use (reg:SI 19))]
15511   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15512   "{movsl|movsd}"
15513   [(set_attr "type" "str")
15514    (set_attr "mode" "SI")
15515    (set_attr "memory" "both")])
15517 (define_insn "strmovhi_1"
15518   [(set (mem:HI (match_operand:SI 2 "register_operand" "0"))
15519         (mem:HI (match_operand:SI 3 "register_operand" "1")))
15520    (set (match_operand:SI 0 "register_operand" "=D")
15521         (plus:SI (match_dup 2)
15522                  (const_int 2)))
15523    (set (match_operand:SI 1 "register_operand" "=S")
15524         (plus:SI (match_dup 3)
15525                  (const_int 2)))
15526    (use (reg:SI 19))]
15527   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15528   "movsw"
15529   [(set_attr "type" "str")
15530    (set_attr "memory" "both")
15531    (set_attr "mode" "HI")])
15533 (define_insn "strmovhi_rex_1"
15534   [(set (mem:HI (match_operand:DI 2 "register_operand" "0"))
15535         (mem:HI (match_operand:DI 3 "register_operand" "1")))
15536    (set (match_operand:DI 0 "register_operand" "=D")
15537         (plus:DI (match_dup 2)
15538                  (const_int 2)))
15539    (set (match_operand:DI 1 "register_operand" "=S")
15540         (plus:DI (match_dup 3)
15541                  (const_int 2)))
15542    (use (reg:SI 19))]
15543   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15544   "movsw"
15545   [(set_attr "type" "str")
15546    (set_attr "memory" "both")
15547    (set_attr "mode" "HI")])
15549 (define_insn "strmovqi_1"
15550   [(set (mem:QI (match_operand:SI 2 "register_operand" "0"))
15551         (mem:QI (match_operand:SI 3 "register_operand" "1")))
15552    (set (match_operand:SI 0 "register_operand" "=D")
15553         (plus:SI (match_dup 2)
15554                  (const_int 1)))
15555    (set (match_operand:SI 1 "register_operand" "=S")
15556         (plus:SI (match_dup 3)
15557                  (const_int 1)))
15558    (use (reg:SI 19))]
15559   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15560   "movsb"
15561   [(set_attr "type" "str")
15562    (set_attr "memory" "both")
15563    (set_attr "mode" "QI")])
15565 (define_insn "strmovqi_rex_1"
15566   [(set (mem:QI (match_operand:DI 2 "register_operand" "0"))
15567         (mem:QI (match_operand:DI 3 "register_operand" "1")))
15568    (set (match_operand:DI 0 "register_operand" "=D")
15569         (plus:DI (match_dup 2)
15570                  (const_int 1)))
15571    (set (match_operand:DI 1 "register_operand" "=S")
15572         (plus:DI (match_dup 3)
15573                  (const_int 1)))
15574    (use (reg:SI 19))]
15575   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15576   "movsb"
15577   [(set_attr "type" "str")
15578    (set_attr "memory" "both")
15579    (set_attr "mode" "QI")])
15581 (define_insn "rep_movdi_rex64"
15582   [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15583    (set (match_operand:DI 0 "register_operand" "=D") 
15584         (plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2")
15585                             (const_int 3))
15586                  (match_operand:DI 3 "register_operand" "0")))
15587    (set (match_operand:DI 1 "register_operand" "=S") 
15588         (plus:DI (ashift:DI (match_dup 5) (const_int 3))
15589                  (match_operand:DI 4 "register_operand" "1")))
15590    (set (mem:BLK (match_dup 3))
15591         (mem:BLK (match_dup 4)))
15592    (use (match_dup 5))
15593    (use (reg:SI 19))]
15594   "TARGET_64BIT"
15595   "{rep\;movsq|rep movsq}"
15596   [(set_attr "type" "str")
15597    (set_attr "prefix_rep" "1")
15598    (set_attr "memory" "both")
15599    (set_attr "mode" "DI")])
15601 (define_insn "rep_movsi"
15602   [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
15603    (set (match_operand:SI 0 "register_operand" "=D") 
15604         (plus:SI (ashift:SI (match_operand:SI 5 "register_operand" "2")
15605                             (const_int 2))
15606                  (match_operand:SI 3 "register_operand" "0")))
15607    (set (match_operand:SI 1 "register_operand" "=S") 
15608         (plus:SI (ashift:SI (match_dup 5) (const_int 2))
15609                  (match_operand:SI 4 "register_operand" "1")))
15610    (set (mem:BLK (match_dup 3))
15611         (mem:BLK (match_dup 4)))
15612    (use (match_dup 5))
15613    (use (reg:SI 19))]
15614   "!TARGET_64BIT"
15615   "{rep\;movsl|rep movsd}"
15616   [(set_attr "type" "str")
15617    (set_attr "prefix_rep" "1")
15618    (set_attr "memory" "both")
15619    (set_attr "mode" "SI")])
15621 (define_insn "rep_movsi_rex64"
15622   [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15623    (set (match_operand:DI 0 "register_operand" "=D") 
15624         (plus:DI (ashift:DI (match_operand:DI 5 "register_operand" "2")
15625                             (const_int 2))
15626                  (match_operand:DI 3 "register_operand" "0")))
15627    (set (match_operand:DI 1 "register_operand" "=S") 
15628         (plus:DI (ashift:DI (match_dup 5) (const_int 2))
15629                  (match_operand:DI 4 "register_operand" "1")))
15630    (set (mem:BLK (match_dup 3))
15631         (mem:BLK (match_dup 4)))
15632    (use (match_dup 5))
15633    (use (reg:SI 19))]
15634   "TARGET_64BIT"
15635   "{rep\;movsl|rep movsd}"
15636   [(set_attr "type" "str")
15637    (set_attr "prefix_rep" "1")
15638    (set_attr "memory" "both")
15639    (set_attr "mode" "SI")])
15641 (define_insn "rep_movqi"
15642   [(set (match_operand:SI 2 "register_operand" "=c") (const_int 0))
15643    (set (match_operand:SI 0 "register_operand" "=D") 
15644         (plus:SI (match_operand:SI 3 "register_operand" "0")
15645                  (match_operand:SI 5 "register_operand" "2")))
15646    (set (match_operand:SI 1 "register_operand" "=S") 
15647         (plus:SI (match_operand:SI 4 "register_operand" "1") (match_dup 5)))
15648    (set (mem:BLK (match_dup 3))
15649         (mem:BLK (match_dup 4)))
15650    (use (match_dup 5))
15651    (use (reg:SI 19))]
15652   "!TARGET_64BIT"
15653   "{rep\;movsb|rep movsb}"
15654   [(set_attr "type" "str")
15655    (set_attr "prefix_rep" "1")
15656    (set_attr "memory" "both")
15657    (set_attr "mode" "SI")])
15659 (define_insn "rep_movqi_rex64"
15660   [(set (match_operand:DI 2 "register_operand" "=c") (const_int 0))
15661    (set (match_operand:DI 0 "register_operand" "=D") 
15662         (plus:DI (match_operand:DI 3 "register_operand" "0")
15663                  (match_operand:DI 5 "register_operand" "2")))
15664    (set (match_operand:DI 1 "register_operand" "=S") 
15665         (plus:DI (match_operand:DI 4 "register_operand" "1") (match_dup 5)))
15666    (set (mem:BLK (match_dup 3))
15667         (mem:BLK (match_dup 4)))
15668    (use (match_dup 5))
15669    (use (reg:SI 19))]
15670   "TARGET_64BIT"
15671   "{rep\;movsb|rep movsb}"
15672   [(set_attr "type" "str")
15673    (set_attr "prefix_rep" "1")
15674    (set_attr "memory" "both")
15675    (set_attr "mode" "SI")])
15677 (define_expand "clrstrsi"
15678    [(use (match_operand:BLK 0 "memory_operand" ""))
15679     (use (match_operand:SI 1 "nonmemory_operand" ""))
15680     (use (match_operand 2 "const_int_operand" ""))]
15681   ""
15683  if (ix86_expand_clrstr (operands[0], operands[1], operands[2]))
15684    DONE;
15685  else
15686    FAIL;
15689 (define_expand "clrstrdi"
15690    [(use (match_operand:BLK 0 "memory_operand" ""))
15691     (use (match_operand:DI 1 "nonmemory_operand" ""))
15692     (use (match_operand 2 "const_int_operand" ""))]
15693   "TARGET_64BIT"
15695  if (ix86_expand_clrstr (operands[0], operands[1], operands[2]))
15696    DONE;
15697  else
15698    FAIL;
15701 ;; Most CPUs don't like single string operations
15702 ;; Handle this case here to simplify previous expander.
15704 (define_expand "strsetdi_rex64"
15705   [(set (mem:DI (match_operand:DI 0 "register_operand" ""))
15706         (match_operand:DI 1 "register_operand" ""))
15707    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 8)))
15708               (clobber (reg:CC 17))])]
15709   "TARGET_64BIT"
15711   if (TARGET_SINGLE_STRINGOP || optimize_size)
15712     {
15713       emit_insn (gen_strsetdi_rex_1 (operands[0], operands[0], operands[1]));
15714       DONE;
15715     }
15718 (define_expand "strsetsi"
15719   [(set (mem:SI (match_operand:SI 0 "register_operand" ""))
15720         (match_operand:SI 1 "register_operand" ""))
15721    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 4)))
15722               (clobber (reg:CC 17))])]
15723   ""
15725   if (TARGET_64BIT)
15726     {
15727       emit_insn (gen_strsetsi_rex64 (operands[0], operands[1]));
15728       DONE;
15729     }
15730   else if (TARGET_SINGLE_STRINGOP || optimize_size)
15731     {
15732       emit_insn (gen_strsetsi_1 (operands[0], operands[0], operands[1]));
15733       DONE;
15734     }
15737 (define_expand "strsetsi_rex64"
15738   [(set (mem:SI (match_operand:DI 0 "register_operand" ""))
15739         (match_operand:SI 1 "register_operand" ""))
15740    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 4)))
15741               (clobber (reg:CC 17))])]
15742   "TARGET_64BIT"
15744   if (TARGET_SINGLE_STRINGOP || optimize_size)
15745     {
15746       emit_insn (gen_strsetsi_rex_1 (operands[0], operands[0], operands[1]));
15747       DONE;
15748     }
15751 (define_expand "strsethi"
15752   [(set (mem:HI (match_operand:SI 0 "register_operand" ""))
15753         (match_operand:HI 1 "register_operand" ""))
15754    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 2)))
15755               (clobber (reg:CC 17))])]
15756   ""
15758   if (TARGET_64BIT)
15759     {
15760       emit_insn (gen_strsethi_rex64 (operands[0], operands[1]));
15761       DONE;
15762     }
15763   else if (TARGET_SINGLE_STRINGOP || optimize_size)
15764     {
15765       emit_insn (gen_strsethi_1 (operands[0], operands[0], operands[1]));
15766       DONE;
15767     }
15770 (define_expand "strsethi_rex64"
15771   [(set (mem:HI (match_operand:DI 0 "register_operand" ""))
15772         (match_operand:HI 1 "register_operand" ""))
15773    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 2)))
15774               (clobber (reg:CC 17))])]
15775   "TARGET_64BIT"
15777   if (TARGET_SINGLE_STRINGOP || optimize_size)
15778     {
15779       emit_insn (gen_strsethi_rex_1 (operands[0], operands[0], operands[1]));
15780       DONE;
15781     }
15784 (define_expand "strsetqi"
15785   [(set (mem:QI (match_operand:SI 0 "register_operand" ""))
15786         (match_operand:QI 1 "register_operand" ""))
15787    (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (const_int 1)))
15788               (clobber (reg:CC 17))])]
15789   ""
15791   if (TARGET_64BIT)
15792     {
15793       emit_insn (gen_strsetqi_rex64 (operands[0], operands[1]));
15794       DONE;
15795     }
15796   else if (TARGET_SINGLE_STRINGOP || optimize_size)
15797     {
15798       emit_insn (gen_strsetqi_1 (operands[0], operands[0], operands[1]));
15799       DONE;
15800     }
15803 (define_expand "strsetqi_rex64"
15804   [(set (mem:QI (match_operand:DI 0 "register_operand" ""))
15805         (match_operand:QI 1 "register_operand" ""))
15806    (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (const_int 1)))
15807               (clobber (reg:CC 17))])]
15808   "TARGET_64BIT"
15810   if (TARGET_SINGLE_STRINGOP || optimize_size)
15811     {
15812       emit_insn (gen_strsetqi_rex_1 (operands[0], operands[0], operands[1]));
15813       DONE;
15814     }
15817 (define_insn "strsetdi_rex_1"
15818   [(set (mem:SI (match_operand:DI 1 "register_operand" "0"))
15819         (match_operand:SI 2 "register_operand" "a"))
15820    (set (match_operand:DI 0 "register_operand" "=D")
15821         (plus:DI (match_dup 1)
15822                  (const_int 8)))
15823    (use (reg:SI 19))]
15824   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15825   "stosq"
15826   [(set_attr "type" "str")
15827    (set_attr "memory" "store")
15828    (set_attr "mode" "DI")])
15830 (define_insn "strsetsi_1"
15831   [(set (mem:SI (match_operand:SI 1 "register_operand" "0"))
15832         (match_operand:SI 2 "register_operand" "a"))
15833    (set (match_operand:SI 0 "register_operand" "=D")
15834         (plus:SI (match_dup 1)
15835                  (const_int 4)))
15836    (use (reg:SI 19))]
15837   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15838   "{stosl|stosd}"
15839   [(set_attr "type" "str")
15840    (set_attr "memory" "store")
15841    (set_attr "mode" "SI")])
15843 (define_insn "strsetsi_rex_1"
15844   [(set (mem:SI (match_operand:DI 1 "register_operand" "0"))
15845         (match_operand:SI 2 "register_operand" "a"))
15846    (set (match_operand:DI 0 "register_operand" "=D")
15847         (plus:DI (match_dup 1)
15848                  (const_int 4)))
15849    (use (reg:SI 19))]
15850   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15851   "{stosl|stosd}"
15852   [(set_attr "type" "str")
15853    (set_attr "memory" "store")
15854    (set_attr "mode" "SI")])
15856 (define_insn "strsethi_1"
15857   [(set (mem:HI (match_operand:SI 1 "register_operand" "0"))
15858         (match_operand:HI 2 "register_operand" "a"))
15859    (set (match_operand:SI 0 "register_operand" "=D")
15860         (plus:SI (match_dup 1)
15861                  (const_int 2)))
15862    (use (reg:SI 19))]
15863   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15864   "stosw"
15865   [(set_attr "type" "str")
15866    (set_attr "memory" "store")
15867    (set_attr "mode" "HI")])
15869 (define_insn "strsethi_rex_1"
15870   [(set (mem:HI (match_operand:DI 1 "register_operand" "0"))
15871         (match_operand:HI 2 "register_operand" "a"))
15872    (set (match_operand:DI 0 "register_operand" "=D")
15873         (plus:DI (match_dup 1)
15874                  (const_int 2)))
15875    (use (reg:SI 19))]
15876   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15877   "stosw"
15878   [(set_attr "type" "str")
15879    (set_attr "memory" "store")
15880    (set_attr "mode" "HI")])
15882 (define_insn "strsetqi_1"
15883   [(set (mem:QI (match_operand:SI 1 "register_operand" "0"))
15884         (match_operand:QI 2 "register_operand" "a"))
15885    (set (match_operand:SI 0 "register_operand" "=D")
15886         (plus:SI (match_dup 1)
15887                  (const_int 1)))
15888    (use (reg:SI 19))]
15889   "!TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15890   "stosb"
15891   [(set_attr "type" "str")
15892    (set_attr "memory" "store")
15893    (set_attr "mode" "QI")])
15895 (define_insn "strsetqi_rex_1"
15896   [(set (mem:QI (match_operand:DI 1 "register_operand" "0"))
15897         (match_operand:QI 2 "register_operand" "a"))
15898    (set (match_operand:DI 0 "register_operand" "=D")
15899         (plus:DI (match_dup 1)
15900                  (const_int 1)))
15901    (use (reg:SI 19))]
15902   "TARGET_64BIT && (TARGET_SINGLE_STRINGOP || optimize_size)"
15903   "stosb"
15904   [(set_attr "type" "str")
15905    (set_attr "memory" "store")
15906    (set_attr "mode" "QI")])
15908 (define_insn "rep_stosdi_rex64"
15909   [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
15910    (set (match_operand:DI 0 "register_operand" "=D") 
15911         (plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1")
15912                             (const_int 3))
15913                  (match_operand:DI 3 "register_operand" "0")))
15914    (set (mem:BLK (match_dup 3))
15915         (const_int 0))
15916    (use (match_operand:DI 2 "register_operand" "a"))
15917    (use (match_dup 4))
15918    (use (reg:SI 19))]
15919   "TARGET_64BIT"
15920   "{rep\;stosq|rep stosq}"
15921   [(set_attr "type" "str")
15922    (set_attr "prefix_rep" "1")
15923    (set_attr "memory" "store")
15924    (set_attr "mode" "DI")])
15926 (define_insn "rep_stossi"
15927   [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
15928    (set (match_operand:SI 0 "register_operand" "=D") 
15929         (plus:SI (ashift:SI (match_operand:SI 4 "register_operand" "1")
15930                             (const_int 2))
15931                  (match_operand:SI 3 "register_operand" "0")))
15932    (set (mem:BLK (match_dup 3))
15933         (const_int 0))
15934    (use (match_operand:SI 2 "register_operand" "a"))
15935    (use (match_dup 4))
15936    (use (reg:SI 19))]
15937   "!TARGET_64BIT"
15938   "{rep\;stosl|rep stosd}"
15939   [(set_attr "type" "str")
15940    (set_attr "prefix_rep" "1")
15941    (set_attr "memory" "store")
15942    (set_attr "mode" "SI")])
15944 (define_insn "rep_stossi_rex64"
15945   [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
15946    (set (match_operand:DI 0 "register_operand" "=D") 
15947         (plus:DI (ashift:DI (match_operand:DI 4 "register_operand" "1")
15948                             (const_int 2))
15949                  (match_operand:DI 3 "register_operand" "0")))
15950    (set (mem:BLK (match_dup 3))
15951         (const_int 0))
15952    (use (match_operand:SI 2 "register_operand" "a"))
15953    (use (match_dup 4))
15954    (use (reg:SI 19))]
15955   "TARGET_64BIT"
15956   "{rep\;stosl|rep stosd}"
15957   [(set_attr "type" "str")
15958    (set_attr "prefix_rep" "1")
15959    (set_attr "memory" "store")
15960    (set_attr "mode" "SI")])
15962 (define_insn "rep_stosqi"
15963   [(set (match_operand:SI 1 "register_operand" "=c") (const_int 0))
15964    (set (match_operand:SI 0 "register_operand" "=D") 
15965         (plus:SI (match_operand:SI 3 "register_operand" "0")
15966                  (match_operand:SI 4 "register_operand" "1")))
15967    (set (mem:BLK (match_dup 3))
15968         (const_int 0))
15969    (use (match_operand:QI 2 "register_operand" "a"))
15970    (use (match_dup 4))
15971    (use (reg:SI 19))]
15972   "!TARGET_64BIT"
15973   "{rep\;stosb|rep stosb}"
15974   [(set_attr "type" "str")
15975    (set_attr "prefix_rep" "1")
15976    (set_attr "memory" "store")
15977    (set_attr "mode" "QI")])
15979 (define_insn "rep_stosqi_rex64"
15980   [(set (match_operand:DI 1 "register_operand" "=c") (const_int 0))
15981    (set (match_operand:DI 0 "register_operand" "=D") 
15982         (plus:DI (match_operand:DI 3 "register_operand" "0")
15983                  (match_operand:DI 4 "register_operand" "1")))
15984    (set (mem:BLK (match_dup 3))
15985         (const_int 0))
15986    (use (match_operand:QI 2 "register_operand" "a"))
15987    (use (match_dup 4))
15988    (use (reg:DI 19))]
15989   "TARGET_64BIT"
15990   "{rep\;stosb|rep stosb}"
15991   [(set_attr "type" "str")
15992    (set_attr "prefix_rep" "1")
15993    (set_attr "memory" "store")
15994    (set_attr "mode" "QI")])
15996 (define_expand "cmpstrsi"
15997   [(set (match_operand:SI 0 "register_operand" "")
15998         (compare:SI (match_operand:BLK 1 "general_operand" "")
15999                     (match_operand:BLK 2 "general_operand" "")))
16000    (use (match_operand 3 "general_operand" ""))
16001    (use (match_operand 4 "immediate_operand" ""))]
16002   ""
16004   rtx addr1, addr2, out, outlow, count, countreg, align;
16006   out = operands[0];
16007   if (GET_CODE (out) != REG)
16008     out = gen_reg_rtx (SImode);
16010   addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
16011   addr2 = copy_to_mode_reg (Pmode, XEXP (operands[2], 0));
16012   
16013   count = operands[3];
16014   countreg = ix86_zero_extend_to_Pmode (count);
16016   /* %%% Iff we are testing strict equality, we can use known alignment
16017      to good advantage.  This may be possible with combine, particularly
16018      once cc0 is dead.  */
16019   align = operands[4];
16021   emit_insn (gen_cld ());
16022   if (GET_CODE (count) == CONST_INT)
16023     {
16024       if (INTVAL (count) == 0)
16025         {
16026           emit_move_insn (operands[0], const0_rtx);
16027           DONE;
16028         }
16029       if (TARGET_64BIT)
16030         emit_insn (gen_cmpstrqi_nz_rex_1 (addr1, addr2, countreg, align,
16031                                           addr1, addr2, countreg));
16032       else
16033         emit_insn (gen_cmpstrqi_nz_1 (addr1, addr2, countreg, align,
16034                                       addr1, addr2, countreg));
16035     }
16036   else
16037     {
16038       if (TARGET_64BIT)
16039         {
16040           emit_insn (gen_cmpdi_1_rex64 (countreg, countreg));
16041           emit_insn (gen_cmpstrqi_rex_1 (addr1, addr2, countreg, align,
16042                                          addr1, addr2, countreg));
16043         }
16044       else
16045         {
16046           emit_insn (gen_cmpsi_1 (countreg, countreg));
16047           emit_insn (gen_cmpstrqi_1 (addr1, addr2, countreg, align,
16048                                      addr1, addr2, countreg));
16049         }
16050     }
16052   outlow = gen_lowpart (QImode, out);
16053   emit_insn (gen_cmpintqi (outlow));
16054   emit_move_insn (out, gen_rtx_SIGN_EXTEND (SImode, outlow));
16056   if (operands[0] != out)
16057     emit_move_insn (operands[0], out);
16059   DONE;
16062 ;; Produce a tri-state integer (-1, 0, 1) from condition codes.
16064 (define_expand "cmpintqi"
16065   [(set (match_dup 1)
16066         (gtu:QI (reg:CC 17) (const_int 0)))
16067    (set (match_dup 2)
16068         (ltu:QI (reg:CC 17) (const_int 0)))
16069    (parallel [(set (match_operand:QI 0 "register_operand" "")
16070                    (minus:QI (match_dup 1)
16071                              (match_dup 2)))
16072               (clobber (reg:CC 17))])]
16073   ""
16074   "operands[1] = gen_reg_rtx (QImode);
16075    operands[2] = gen_reg_rtx (QImode);")
16077 ;; memcmp recognizers.  The `cmpsb' opcode does nothing if the count is
16078 ;; zero.  Emit extra code to make sure that a zero-length compare is EQ.
16080 (define_insn "cmpstrqi_nz_1"
16081   [(set (reg:CC 17)
16082         (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0"))
16083                     (mem:BLK (match_operand:SI 5 "register_operand" "1"))))
16084    (use (match_operand:SI 6 "register_operand" "2"))
16085    (use (match_operand:SI 3 "immediate_operand" "i"))
16086    (use (reg:SI 19))
16087    (clobber (match_operand:SI 0 "register_operand" "=S"))
16088    (clobber (match_operand:SI 1 "register_operand" "=D"))
16089    (clobber (match_operand:SI 2 "register_operand" "=c"))]
16090   "!TARGET_64BIT"
16091   "repz{\;| }cmpsb"
16092   [(set_attr "type" "str")
16093    (set_attr "mode" "QI")
16094    (set_attr "prefix_rep" "1")])
16096 (define_insn "cmpstrqi_nz_rex_1"
16097   [(set (reg:CC 17)
16098         (compare:CC (mem:BLK (match_operand:DI 4 "register_operand" "0"))
16099                     (mem:BLK (match_operand:DI 5 "register_operand" "1"))))
16100    (use (match_operand:DI 6 "register_operand" "2"))
16101    (use (match_operand:SI 3 "immediate_operand" "i"))
16102    (use (reg:SI 19))
16103    (clobber (match_operand:DI 0 "register_operand" "=S"))
16104    (clobber (match_operand:DI 1 "register_operand" "=D"))
16105    (clobber (match_operand:DI 2 "register_operand" "=c"))]
16106   "TARGET_64BIT"
16107   "repz{\;| }cmpsb"
16108   [(set_attr "type" "str")
16109    (set_attr "mode" "QI")
16110    (set_attr "prefix_rep" "1")])
16112 ;; The same, but the count is not known to not be zero.
16114 (define_insn "cmpstrqi_1"
16115   [(set (reg:CC 17)
16116         (if_then_else:CC (ne (match_operand:SI 6 "register_operand" "2")
16117                              (const_int 0))
16118           (compare:CC (mem:BLK (match_operand:SI 4 "register_operand" "0"))
16119                       (mem:BLK (match_operand:SI 5 "register_operand" "1")))
16120           (const_int 0)))
16121    (use (match_operand:SI 3 "immediate_operand" "i"))
16122    (use (reg:CC 17))
16123    (use (reg:SI 19))
16124    (clobber (match_operand:SI 0 "register_operand" "=S"))
16125    (clobber (match_operand:SI 1 "register_operand" "=D"))
16126    (clobber (match_operand:SI 2 "register_operand" "=c"))]
16127   "!TARGET_64BIT"
16128   "repz{\;| }cmpsb"
16129   [(set_attr "type" "str")
16130    (set_attr "mode" "QI")
16131    (set_attr "prefix_rep" "1")])
16133 (define_insn "cmpstrqi_rex_1"
16134   [(set (reg:CC 17)
16135         (if_then_else:CC (ne (match_operand:DI 6 "register_operand" "2")
16136                              (const_int 0))
16137           (compare:CC (mem:BLK (match_operand:DI 4 "register_operand" "0"))
16138                       (mem:BLK (match_operand:DI 5 "register_operand" "1")))
16139           (const_int 0)))
16140    (use (match_operand:SI 3 "immediate_operand" "i"))
16141    (use (reg:CC 17))
16142    (use (reg:SI 19))
16143    (clobber (match_operand:DI 0 "register_operand" "=S"))
16144    (clobber (match_operand:DI 1 "register_operand" "=D"))
16145    (clobber (match_operand:DI 2 "register_operand" "=c"))]
16146   "TARGET_64BIT"
16147   "repz{\;| }cmpsb"
16148   [(set_attr "type" "str")
16149    (set_attr "mode" "QI")
16150    (set_attr "prefix_rep" "1")])
16152 (define_expand "strlensi"
16153   [(set (match_operand:SI 0 "register_operand" "")
16154         (unspec:SI [(match_operand:BLK 1 "general_operand" "")
16155                     (match_operand:QI 2 "immediate_operand" "")
16156                     (match_operand 3 "immediate_operand" "")] UNSPEC_SCAS))]
16157   ""
16159  if (ix86_expand_strlen (operands[0], operands[1], operands[2], operands[3]))
16160    DONE;
16161  else
16162    FAIL;
16165 (define_expand "strlendi"
16166   [(set (match_operand:DI 0 "register_operand" "")
16167         (unspec:DI [(match_operand:BLK 1 "general_operand" "")
16168                     (match_operand:QI 2 "immediate_operand" "")
16169                     (match_operand 3 "immediate_operand" "")] UNSPEC_SCAS))]
16170   ""
16172  if (ix86_expand_strlen (operands[0], operands[1], operands[2], operands[3]))
16173    DONE;
16174  else
16175    FAIL;
16178 (define_insn "strlenqi_1"
16179   [(set (match_operand:SI 0 "register_operand" "=&c")
16180         (unspec:SI [(mem:BLK (match_operand:SI 5 "register_operand" "1"))
16181                     (match_operand:QI 2 "register_operand" "a")
16182                     (match_operand:SI 3 "immediate_operand" "i")
16183                     (match_operand:SI 4 "register_operand" "0")] UNSPEC_SCAS))
16184    (use (reg:SI 19))
16185    (clobber (match_operand:SI 1 "register_operand" "=D"))
16186    (clobber (reg:CC 17))]
16187   "!TARGET_64BIT"
16188   "repnz{\;| }scasb"
16189   [(set_attr "type" "str")
16190    (set_attr "mode" "QI")
16191    (set_attr "prefix_rep" "1")])
16193 (define_insn "strlenqi_rex_1"
16194   [(set (match_operand:DI 0 "register_operand" "=&c")
16195         (unspec:DI [(mem:BLK (match_operand:DI 5 "register_operand" "1"))
16196                     (match_operand:QI 2 "register_operand" "a")
16197                     (match_operand:DI 3 "immediate_operand" "i")
16198                     (match_operand:DI 4 "register_operand" "0")] UNSPEC_SCAS))
16199    (use (reg:SI 19))
16200    (clobber (match_operand:DI 1 "register_operand" "=D"))
16201    (clobber (reg:CC 17))]
16202   "TARGET_64BIT"
16203   "repnz{\;| }scasb"
16204   [(set_attr "type" "str")
16205    (set_attr "mode" "QI")
16206    (set_attr "prefix_rep" "1")])
16208 ;; Peephole optimizations to clean up after cmpstr*.  This should be
16209 ;; handled in combine, but it is not currently up to the task.
16210 ;; When used for their truth value, the cmpstr* expanders generate
16211 ;; code like this:
16213 ;;   repz cmpsb
16214 ;;   seta       %al
16215 ;;   setb       %dl
16216 ;;   cmpb       %al, %dl
16217 ;;   jcc        label
16219 ;; The intermediate three instructions are unnecessary.
16221 ;; This one handles cmpstr*_nz_1...
16222 (define_peephole2
16223   [(parallel[
16224      (set (reg:CC 17)
16225           (compare:CC (mem:BLK (match_operand 4 "register_operand" ""))
16226                       (mem:BLK (match_operand 5 "register_operand" ""))))
16227      (use (match_operand 6 "register_operand" ""))
16228      (use (match_operand:SI 3 "immediate_operand" ""))
16229      (use (reg:SI 19))
16230      (clobber (match_operand 0 "register_operand" ""))
16231      (clobber (match_operand 1 "register_operand" ""))
16232      (clobber (match_operand 2 "register_operand" ""))])
16233    (set (match_operand:QI 7 "register_operand" "")
16234         (gtu:QI (reg:CC 17) (const_int 0)))
16235    (set (match_operand:QI 8 "register_operand" "")
16236         (ltu:QI (reg:CC 17) (const_int 0)))
16237    (set (reg 17)
16238         (compare (match_dup 7) (match_dup 8)))
16239   ]
16240   "peep2_reg_dead_p (4, operands[7]) && peep2_reg_dead_p (4, operands[8])"
16241   [(parallel[
16242      (set (reg:CC 17)
16243           (compare:CC (mem:BLK (match_dup 4))
16244                       (mem:BLK (match_dup 5))))
16245      (use (match_dup 6))
16246      (use (match_dup 3))
16247      (use (reg:SI 19))
16248      (clobber (match_dup 0))
16249      (clobber (match_dup 1))
16250      (clobber (match_dup 2))])]
16251   "")
16253 ;; ...and this one handles cmpstr*_1.
16254 (define_peephole2
16255   [(parallel[
16256      (set (reg:CC 17)
16257           (if_then_else:CC (ne (match_operand 6 "register_operand" "")
16258                                (const_int 0))
16259             (compare:CC (mem:BLK (match_operand 4 "register_operand" ""))
16260                         (mem:BLK (match_operand 5 "register_operand" "")))
16261             (const_int 0)))
16262      (use (match_operand:SI 3 "immediate_operand" ""))
16263      (use (reg:CC 17))
16264      (use (reg:SI 19))
16265      (clobber (match_operand 0 "register_operand" ""))
16266      (clobber (match_operand 1 "register_operand" ""))
16267      (clobber (match_operand 2 "register_operand" ""))])
16268    (set (match_operand:QI 7 "register_operand" "")
16269         (gtu:QI (reg:CC 17) (const_int 0)))
16270    (set (match_operand:QI 8 "register_operand" "")
16271         (ltu:QI (reg:CC 17) (const_int 0)))
16272    (set (reg 17)
16273         (compare (match_dup 7) (match_dup 8)))
16274   ]
16275   "peep2_reg_dead_p (4, operands[7]) && peep2_reg_dead_p (4, operands[8])"
16276   [(parallel[
16277      (set (reg:CC 17)
16278           (if_then_else:CC (ne (match_dup 6)
16279                                (const_int 0))
16280             (compare:CC (mem:BLK (match_dup 4))
16281                         (mem:BLK (match_dup 5)))
16282             (const_int 0)))
16283      (use (match_dup 3))
16284      (use (reg:CC 17))
16285      (use (reg:SI 19))
16286      (clobber (match_dup 0))
16287      (clobber (match_dup 1))
16288      (clobber (match_dup 2))])]
16289   "")
16293 ;; Conditional move instructions.
16295 (define_expand "movdicc"
16296   [(set (match_operand:DI 0 "register_operand" "")
16297         (if_then_else:DI (match_operand 1 "comparison_operator" "")
16298                          (match_operand:DI 2 "general_operand" "")
16299                          (match_operand:DI 3 "general_operand" "")))]
16300   "TARGET_64BIT"
16301   "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
16303 (define_insn "x86_movdicc_0_m1_rex64"
16304   [(set (match_operand:DI 0 "register_operand" "=r")
16305         (if_then_else:DI (match_operand 1 "ix86_carry_flag_operator" "")
16306           (const_int -1)
16307           (const_int 0)))
16308    (clobber (reg:CC 17))]
16309   "TARGET_64BIT"
16310   "sbb{q}\t%0, %0"
16311   ; Since we don't have the proper number of operands for an alu insn,
16312   ; fill in all the blanks.
16313   [(set_attr "type" "alu")
16314    (set_attr "pent_pair" "pu")
16315    (set_attr "memory" "none")
16316    (set_attr "imm_disp" "false")
16317    (set_attr "mode" "DI")
16318    (set_attr "length_immediate" "0")])
16320 (define_insn "movdicc_c_rex64"
16321   [(set (match_operand:DI 0 "register_operand" "=r,r")
16322         (if_then_else:DI (match_operator 1 "ix86_comparison_operator" 
16323                                 [(reg 17) (const_int 0)])
16324                       (match_operand:DI 2 "nonimmediate_operand" "rm,0")
16325                       (match_operand:DI 3 "nonimmediate_operand" "0,rm")))]
16326   "TARGET_64BIT && TARGET_CMOVE
16327    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16328   "@
16329    cmov%O2%C1\t{%2, %0|%0, %2}
16330    cmov%O2%c1\t{%3, %0|%0, %3}"
16331   [(set_attr "type" "icmov")
16332    (set_attr "mode" "DI")])
16334 (define_expand "movsicc"
16335   [(set (match_operand:SI 0 "register_operand" "")
16336         (if_then_else:SI (match_operand 1 "comparison_operator" "")
16337                          (match_operand:SI 2 "general_operand" "")
16338                          (match_operand:SI 3 "general_operand" "")))]
16339   ""
16340   "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
16342 ;; Data flow gets confused by our desire for `sbbl reg,reg', and clearing
16343 ;; the register first winds up with `sbbl $0,reg', which is also weird.
16344 ;; So just document what we're doing explicitly.
16346 (define_insn "x86_movsicc_0_m1"
16347   [(set (match_operand:SI 0 "register_operand" "=r")
16348         (if_then_else:SI (match_operand 1 "ix86_carry_flag_operator" "")
16349           (const_int -1)
16350           (const_int 0)))
16351    (clobber (reg:CC 17))]
16352   ""
16353   "sbb{l}\t%0, %0"
16354   ; Since we don't have the proper number of operands for an alu insn,
16355   ; fill in all the blanks.
16356   [(set_attr "type" "alu")
16357    (set_attr "pent_pair" "pu")
16358    (set_attr "memory" "none")
16359    (set_attr "imm_disp" "false")
16360    (set_attr "mode" "SI")
16361    (set_attr "length_immediate" "0")])
16363 (define_insn "*movsicc_noc"
16364   [(set (match_operand:SI 0 "register_operand" "=r,r")
16365         (if_then_else:SI (match_operator 1 "ix86_comparison_operator" 
16366                                 [(reg 17) (const_int 0)])
16367                       (match_operand:SI 2 "nonimmediate_operand" "rm,0")
16368                       (match_operand:SI 3 "nonimmediate_operand" "0,rm")))]
16369   "TARGET_CMOVE
16370    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16371   "@
16372    cmov%O2%C1\t{%2, %0|%0, %2}
16373    cmov%O2%c1\t{%3, %0|%0, %3}"
16374   [(set_attr "type" "icmov")
16375    (set_attr "mode" "SI")])
16377 (define_expand "movhicc"
16378   [(set (match_operand:HI 0 "register_operand" "")
16379         (if_then_else:HI (match_operand 1 "comparison_operator" "")
16380                          (match_operand:HI 2 "general_operand" "")
16381                          (match_operand:HI 3 "general_operand" "")))]
16382   "TARGET_HIMODE_MATH"
16383   "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
16385 (define_insn "*movhicc_noc"
16386   [(set (match_operand:HI 0 "register_operand" "=r,r")
16387         (if_then_else:HI (match_operator 1 "ix86_comparison_operator" 
16388                                 [(reg 17) (const_int 0)])
16389                       (match_operand:HI 2 "nonimmediate_operand" "rm,0")
16390                       (match_operand:HI 3 "nonimmediate_operand" "0,rm")))]
16391   "TARGET_CMOVE
16392    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16393   "@
16394    cmov%O2%C1\t{%2, %0|%0, %2}
16395    cmov%O2%c1\t{%3, %0|%0, %3}"
16396   [(set_attr "type" "icmov")
16397    (set_attr "mode" "HI")])
16399 (define_expand "movqicc"
16400   [(set (match_operand:QI 0 "register_operand" "")
16401         (if_then_else:QI (match_operand 1 "comparison_operator" "")
16402                          (match_operand:QI 2 "general_operand" "")
16403                          (match_operand:QI 3 "general_operand" "")))]
16404   "TARGET_QIMODE_MATH"
16405   "if (!ix86_expand_int_movcc (operands)) FAIL; DONE;")
16407 (define_insn_and_split "*movqicc_noc"
16408   [(set (match_operand:QI 0 "register_operand" "=r,r")
16409         (if_then_else:QI (match_operator 1 "ix86_comparison_operator" 
16410                                 [(match_operand 4 "flags_reg_operand" "") (const_int 0)])
16411                       (match_operand:QI 2 "register_operand" "r,0")
16412                       (match_operand:QI 3 "register_operand" "0,r")))]
16413   "TARGET_CMOVE && !TARGET_PARTIAL_REG_STALL"
16414   "#"
16415   "&& reload_completed"
16416   [(set (match_dup 0)
16417         (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
16418                       (match_dup 2)
16419                       (match_dup 3)))]
16420   "operands[0] = gen_lowpart (SImode, operands[0]);
16421    operands[2] = gen_lowpart (SImode, operands[2]);
16422    operands[3] = gen_lowpart (SImode, operands[3]);"
16423   [(set_attr "type" "icmov")
16424    (set_attr "mode" "SI")])
16426 (define_expand "movsfcc"
16427   [(set (match_operand:SF 0 "register_operand" "")
16428         (if_then_else:SF (match_operand 1 "comparison_operator" "")
16429                          (match_operand:SF 2 "register_operand" "")
16430                          (match_operand:SF 3 "register_operand" "")))]
16431   "TARGET_CMOVE"
16432   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
16434 (define_insn "*movsfcc_1"
16435   [(set (match_operand:SF 0 "register_operand" "=f,f,r,r")
16436         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator" 
16437                                 [(reg 17) (const_int 0)])
16438                       (match_operand:SF 2 "nonimmediate_operand" "f,0,rm,0")
16439                       (match_operand:SF 3 "nonimmediate_operand" "0,f,0,rm")))]
16440   "TARGET_CMOVE
16441    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16442   "@
16443    fcmov%F1\t{%2, %0|%0, %2}
16444    fcmov%f1\t{%3, %0|%0, %3}
16445    cmov%O2%C1\t{%2, %0|%0, %2}
16446    cmov%O2%c1\t{%3, %0|%0, %3}"
16447   [(set_attr "type" "fcmov,fcmov,icmov,icmov")
16448    (set_attr "mode" "SF,SF,SI,SI")])
16450 (define_expand "movdfcc"
16451   [(set (match_operand:DF 0 "register_operand" "")
16452         (if_then_else:DF (match_operand 1 "comparison_operator" "")
16453                          (match_operand:DF 2 "register_operand" "")
16454                          (match_operand:DF 3 "register_operand" "")))]
16455   "TARGET_CMOVE"
16456   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
16458 (define_insn "*movdfcc_1"
16459   [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r")
16460         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" 
16461                                 [(reg 17) (const_int 0)])
16462                       (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
16463                       (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
16464   "!TARGET_64BIT && TARGET_CMOVE
16465    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16466   "@
16467    fcmov%F1\t{%2, %0|%0, %2}
16468    fcmov%f1\t{%3, %0|%0, %3}
16469    #
16470    #"
16471   [(set_attr "type" "fcmov,fcmov,multi,multi")
16472    (set_attr "mode" "DF")])
16474 (define_insn "*movdfcc_1_rex64"
16475   [(set (match_operand:DF 0 "register_operand" "=f,f,&r,&r")
16476         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" 
16477                                 [(reg 17) (const_int 0)])
16478                       (match_operand:DF 2 "nonimmediate_operand" "f,0,rm,0")
16479                       (match_operand:DF 3 "nonimmediate_operand" "0,f,0,rm")))]
16480   "TARGET_64BIT && TARGET_CMOVE
16481    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
16482   "@
16483    fcmov%F1\t{%2, %0|%0, %2}
16484    fcmov%f1\t{%3, %0|%0, %3}
16485    cmov%O2%C1\t{%2, %0|%0, %2}
16486    cmov%O2%c1\t{%3, %0|%0, %3}"
16487   [(set_attr "type" "fcmov,fcmov,icmov,icmov")
16488    (set_attr "mode" "DF")])
16490 (define_split
16491   [(set (match_operand:DF 0 "register_and_not_any_fp_reg_operand" "")
16492         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator" 
16493                                 [(match_operand 4 "flags_reg_operand" "") (const_int 0)])
16494                       (match_operand:DF 2 "nonimmediate_operand" "")
16495                       (match_operand:DF 3 "nonimmediate_operand" "")))]
16496   "!TARGET_64BIT && reload_completed"
16497   [(set (match_dup 2)
16498         (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
16499                       (match_dup 5)
16500                       (match_dup 7)))
16501    (set (match_dup 3)
16502         (if_then_else:SI (match_op_dup 1 [(match_dup 4) (const_int 0)])
16503                       (match_dup 6)
16504                       (match_dup 8)))]
16505   "split_di (operands+2, 1, operands+5, operands+6);
16506    split_di (operands+3, 1, operands+7, operands+8);
16507    split_di (operands, 1, operands+2, operands+3);")
16509 (define_expand "movxfcc"
16510   [(set (match_operand:XF 0 "register_operand" "")
16511         (if_then_else:XF (match_operand 1 "comparison_operator" "")
16512                          (match_operand:XF 2 "register_operand" "")
16513                          (match_operand:XF 3 "register_operand" "")))]
16514   "!TARGET_64BIT && TARGET_CMOVE"
16515   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
16517 (define_expand "movtfcc"
16518   [(set (match_operand:TF 0 "register_operand" "")
16519         (if_then_else:TF (match_operand 1 "comparison_operator" "")
16520                          (match_operand:TF 2 "register_operand" "")
16521                          (match_operand:TF 3 "register_operand" "")))]
16522   "TARGET_CMOVE"
16523   "if (! ix86_expand_fp_movcc (operands)) FAIL; DONE;")
16525 (define_insn "*movxfcc_1"
16526   [(set (match_operand:XF 0 "register_operand" "=f,f")
16527         (if_then_else:XF (match_operator 1 "fcmov_comparison_operator" 
16528                                 [(reg 17) (const_int 0)])
16529                       (match_operand:XF 2 "register_operand" "f,0")
16530                       (match_operand:XF 3 "register_operand" "0,f")))]
16531   "!TARGET_64BIT && TARGET_CMOVE"
16532   "@
16533    fcmov%F1\t{%2, %0|%0, %2}
16534    fcmov%f1\t{%3, %0|%0, %3}"
16535   [(set_attr "type" "fcmov")
16536    (set_attr "mode" "XF")])
16538 (define_insn "*movtfcc_1"
16539   [(set (match_operand:TF 0 "register_operand" "=f,f")
16540         (if_then_else:TF (match_operator 1 "fcmov_comparison_operator" 
16541                                 [(reg 17) (const_int 0)])
16542                       (match_operand:TF 2 "register_operand" "f,0")
16543                       (match_operand:TF 3 "register_operand" "0,f")))]
16544   "TARGET_CMOVE"
16545   "@
16546    fcmov%F1\t{%2, %0|%0, %2}
16547    fcmov%f1\t{%3, %0|%0, %3}"
16548   [(set_attr "type" "fcmov")
16549    (set_attr "mode" "XF")])
16551 (define_expand "minsf3"
16552   [(parallel [
16553      (set (match_operand:SF 0 "register_operand" "")
16554           (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
16555                                (match_operand:SF 2 "nonimmediate_operand" ""))
16556                            (match_dup 1)
16557                            (match_dup 2)))
16558      (clobber (reg:CC 17))])]
16559   "TARGET_SSE"
16560   "")
16562 (define_insn "*minsf"
16563   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x")
16564         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0,0,f#x")
16565                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x,0"))
16566                          (match_dup 1)
16567                          (match_dup 2)))
16568    (clobber (reg:CC 17))]
16569   "TARGET_SSE && TARGET_IEEE_FP"
16570   "#")
16572 (define_insn "*minsf_nonieee"
16573   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x")
16574         (if_then_else:SF (lt (match_operand:SF 1 "nonimmediate_operand" "%0,0")
16575                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x"))
16576                          (match_dup 1)
16577                          (match_dup 2)))
16578    (clobber (reg:CC 17))]
16579   "TARGET_SSE && !TARGET_IEEE_FP
16580    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
16581   "#")
16583 (define_split
16584   [(set (match_operand:SF 0 "register_operand" "")
16585         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
16586                              (match_operand:SF 2 "nonimmediate_operand" ""))
16587                          (match_operand:SF 3 "register_operand" "")
16588                          (match_operand:SF 4 "nonimmediate_operand" "")))
16589    (clobber (reg:CC 17))]
16590   "SSE_REG_P (operands[0]) && reload_completed
16591    && ((operands_match_p (operands[1], operands[3])
16592         && operands_match_p (operands[2], operands[4]))
16593        || (operands_match_p (operands[1], operands[4])
16594            && operands_match_p (operands[2], operands[3])))"
16595   [(set (match_dup 0)
16596         (if_then_else:SF (lt (match_dup 1)
16597                              (match_dup 2))
16598                          (match_dup 1)
16599                          (match_dup 2)))])
16601 ;; Conditional addition patterns
16602 (define_expand "addqicc"
16603   [(match_operand:QI 0 "register_operand" "")
16604    (match_operand 1 "comparison_operator" "")
16605    (match_operand:QI 2 "register_operand" "")
16606    (match_operand:QI 3 "const_int_operand" "")]
16607   ""
16608   "if (!ix86_expand_int_addcc (operands)) FAIL; DONE;")
16610 (define_expand "addhicc"
16611   [(match_operand:HI 0 "register_operand" "")
16612    (match_operand 1 "comparison_operator" "")
16613    (match_operand:HI 2 "register_operand" "")
16614    (match_operand:HI 3 "const_int_operand" "")]
16615   ""
16616   "if (!ix86_expand_int_addcc (operands)) FAIL; DONE;")
16618 (define_expand "addsicc"
16619   [(match_operand:SI 0 "register_operand" "")
16620    (match_operand 1 "comparison_operator" "")
16621    (match_operand:SI 2 "register_operand" "")
16622    (match_operand:SI 3 "const_int_operand" "")]
16623   ""
16624   "if (!ix86_expand_int_addcc (operands)) FAIL; DONE;")
16626 (define_expand "adddicc"
16627   [(match_operand:DI 0 "register_operand" "")
16628    (match_operand 1 "comparison_operator" "")
16629    (match_operand:DI 2 "register_operand" "")
16630    (match_operand:DI 3 "const_int_operand" "")]
16631   "TARGET_64BIT"
16632   "if (!ix86_expand_int_addcc (operands)) FAIL; DONE;")
16634 ;; We can't represent the LT test directly.  Do this by swapping the operands.
16636 (define_split
16637   [(set (match_operand:SF 0 "fp_register_operand" "")
16638         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "")
16639                              (match_operand:SF 2 "register_operand" ""))
16640                          (match_operand:SF 3 "register_operand" "")
16641                          (match_operand:SF 4 "register_operand" "")))
16642    (clobber (reg:CC 17))]
16643   "reload_completed
16644    && ((operands_match_p (operands[1], operands[3])
16645         && operands_match_p (operands[2], operands[4]))
16646        || (operands_match_p (operands[1], operands[4])
16647            && operands_match_p (operands[2], operands[3])))"
16648   [(set (reg:CCFP 17)
16649         (compare:CCFP (match_dup 2)
16650                       (match_dup 1)))
16651    (set (match_dup 0)
16652         (if_then_else:SF (ge (reg:CCFP 17) (const_int 0))
16653                          (match_dup 1)
16654                          (match_dup 2)))])
16656 (define_insn "*minsf_sse"
16657   [(set (match_operand:SF 0 "register_operand" "=x")
16658         (if_then_else:SF (lt (match_operand:SF 1 "register_operand" "0")
16659                              (match_operand:SF 2 "nonimmediate_operand" "xm"))
16660                          (match_dup 1)
16661                          (match_dup 2)))]
16662   "TARGET_SSE && reload_completed"
16663   "minss\t{%2, %0|%0, %2}"
16664   [(set_attr "type" "sse")
16665    (set_attr "mode" "SF")])
16667 (define_expand "mindf3"
16668   [(parallel [
16669      (set (match_operand:DF 0 "register_operand" "")
16670           (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16671                                (match_operand:DF 2 "nonimmediate_operand" ""))
16672                            (match_dup 1)
16673                            (match_dup 2)))
16674      (clobber (reg:CC 17))])]
16675   "TARGET_SSE2 && TARGET_SSE_MATH"
16676   "#")
16678 (define_insn "*mindf"
16679   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y")
16680         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0,0,f#Y")
16681                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y,0"))
16682                          (match_dup 1)
16683                          (match_dup 2)))
16684    (clobber (reg:CC 17))]
16685   "TARGET_SSE2 && TARGET_IEEE_FP && TARGET_SSE_MATH"
16686   "#")
16688 (define_insn "*mindf_nonieee"
16689   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y")
16690         (if_then_else:DF (lt (match_operand:DF 1 "nonimmediate_operand" "%0,0")
16691                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y"))
16692                          (match_dup 1)
16693                          (match_dup 2)))
16694    (clobber (reg:CC 17))]
16695   "TARGET_SSE2 && TARGET_SSE_MATH && !TARGET_IEEE_FP
16696    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
16697   "#")
16699 (define_split
16700   [(set (match_operand:DF 0 "register_operand" "")
16701         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16702                              (match_operand:DF 2 "nonimmediate_operand" ""))
16703                          (match_operand:DF 3 "register_operand" "")
16704                          (match_operand:DF 4 "nonimmediate_operand" "")))
16705    (clobber (reg:CC 17))]
16706   "SSE_REG_P (operands[0]) && reload_completed
16707    && ((operands_match_p (operands[1], operands[3])
16708         && operands_match_p (operands[2], operands[4]))
16709        || (operands_match_p (operands[1], operands[4])
16710            && operands_match_p (operands[2], operands[3])))"
16711   [(set (match_dup 0)
16712         (if_then_else:DF (lt (match_dup 1)
16713                              (match_dup 2))
16714                          (match_dup 1)
16715                          (match_dup 2)))])
16717 ;; We can't represent the LT test directly.  Do this by swapping the operands.
16718 (define_split
16719   [(set (match_operand:DF 0 "fp_register_operand" "")
16720         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "")
16721                              (match_operand:DF 2 "register_operand" ""))
16722                          (match_operand:DF 3 "register_operand" "")
16723                          (match_operand:DF 4 "register_operand" "")))
16724    (clobber (reg:CC 17))]
16725   "reload_completed
16726    && ((operands_match_p (operands[1], operands[3])
16727         && operands_match_p (operands[2], operands[4]))
16728        || (operands_match_p (operands[1], operands[4])
16729            && operands_match_p (operands[2], operands[3])))"
16730   [(set (reg:CCFP 17)
16731         (compare:CCFP (match_dup 2)
16732                       (match_dup 2)))
16733    (set (match_dup 0)
16734         (if_then_else:DF (ge (reg:CCFP 17) (const_int 0))
16735                          (match_dup 1)
16736                          (match_dup 2)))])
16738 (define_insn "*mindf_sse"
16739   [(set (match_operand:DF 0 "register_operand" "=Y")
16740         (if_then_else:DF (lt (match_operand:DF 1 "register_operand" "0")
16741                              (match_operand:DF 2 "nonimmediate_operand" "Ym"))
16742                          (match_dup 1)
16743                          (match_dup 2)))]
16744   "TARGET_SSE2 && TARGET_SSE_MATH && reload_completed"
16745   "minsd\t{%2, %0|%0, %2}"
16746   [(set_attr "type" "sse")
16747    (set_attr "mode" "DF")])
16749 (define_expand "maxsf3"
16750   [(parallel [
16751      (set (match_operand:SF 0 "register_operand" "")
16752           (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16753                                (match_operand:SF 2 "nonimmediate_operand" ""))
16754                            (match_dup 1)
16755                            (match_dup 2)))
16756      (clobber (reg:CC 17))])]
16757   "TARGET_SSE"
16758   "#")
16760 (define_insn "*maxsf"
16761   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x,f#x")
16762         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0,0,f#x")
16763                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x,0"))
16764                          (match_dup 1)
16765                          (match_dup 2)))
16766    (clobber (reg:CC 17))]
16767   "TARGET_SSE && TARGET_IEEE_FP"
16768   "#")
16770 (define_insn "*maxsf_nonieee"
16771   [(set (match_operand:SF 0 "register_operand" "=x#f,f#x")
16772         (if_then_else:SF (gt (match_operand:SF 1 "nonimmediate_operand" "%0,0")
16773                              (match_operand:SF 2 "nonimmediate_operand" "xm#f,f#x"))
16774                          (match_dup 1)
16775                          (match_dup 2)))
16776    (clobber (reg:CC 17))]
16777   "TARGET_SSE && !TARGET_IEEE_FP
16778    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
16779   "#")
16781 (define_split
16782   [(set (match_operand:SF 0 "register_operand" "")
16783         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16784                              (match_operand:SF 2 "nonimmediate_operand" ""))
16785                          (match_operand:SF 3 "register_operand" "")
16786                          (match_operand:SF 4 "nonimmediate_operand" "")))
16787    (clobber (reg:CC 17))]
16788   "SSE_REG_P (operands[0]) && reload_completed
16789    && ((operands_match_p (operands[1], operands[3])
16790         && operands_match_p (operands[2], operands[4]))
16791        || (operands_match_p (operands[1], operands[4])
16792            && operands_match_p (operands[2], operands[3])))"
16793   [(set (match_dup 0)
16794         (if_then_else:SF (gt (match_dup 1)
16795                              (match_dup 2))
16796                          (match_dup 1)
16797                          (match_dup 2)))])
16799 (define_split
16800   [(set (match_operand:SF 0 "fp_register_operand" "")
16801         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "")
16802                              (match_operand:SF 2 "register_operand" ""))
16803                          (match_operand:SF 3 "register_operand" "")
16804                          (match_operand:SF 4 "register_operand" "")))
16805    (clobber (reg:CC 17))]
16806   "reload_completed
16807    && ((operands_match_p (operands[1], operands[3])
16808         && operands_match_p (operands[2], operands[4]))
16809        || (operands_match_p (operands[1], operands[4])
16810            && operands_match_p (operands[2], operands[3])))"
16811   [(set (reg:CCFP 17)
16812         (compare:CCFP (match_dup 1)
16813                       (match_dup 2)))
16814    (set (match_dup 0)
16815         (if_then_else:SF (gt (reg:CCFP 17) (const_int 0))
16816                          (match_dup 1)
16817                          (match_dup 2)))])
16819 (define_insn "*maxsf_sse"
16820   [(set (match_operand:SF 0 "register_operand" "=x")
16821         (if_then_else:SF (gt (match_operand:SF 1 "register_operand" "0")
16822                              (match_operand:SF 2 "nonimmediate_operand" "xm"))
16823                          (match_dup 1)
16824                          (match_dup 2)))]
16825   "TARGET_SSE && reload_completed"
16826   "maxss\t{%2, %0|%0, %2}"
16827   [(set_attr "type" "sse")
16828    (set_attr "mode" "SF")])
16830 (define_expand "maxdf3"
16831   [(parallel [
16832      (set (match_operand:DF 0 "register_operand" "")
16833           (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
16834                                (match_operand:DF 2 "nonimmediate_operand" ""))
16835                            (match_dup 1)
16836                            (match_dup 2)))
16837      (clobber (reg:CC 17))])]
16838   "TARGET_SSE2 && TARGET_SSE_MATH"
16839   "#")
16841 (define_insn "*maxdf"
16842   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y,f#Y")
16843         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0,0,f#Y")
16844                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y,0"))
16845                          (match_dup 1)
16846                          (match_dup 2)))
16847    (clobber (reg:CC 17))]
16848   "TARGET_SSE2 && TARGET_SSE_MATH && TARGET_IEEE_FP"
16849   "#")
16851 (define_insn "*maxdf_nonieee"
16852   [(set (match_operand:DF 0 "register_operand" "=Y#f,f#Y")
16853         (if_then_else:DF (gt (match_operand:DF 1 "nonimmediate_operand" "%0,0")
16854                              (match_operand:DF 2 "nonimmediate_operand" "Ym#f,f#Y"))
16855                          (match_dup 1)
16856                          (match_dup 2)))
16857    (clobber (reg:CC 17))]
16858   "TARGET_SSE2 && TARGET_SSE_MATH && !TARGET_IEEE_FP
16859    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
16860   "#")
16862 (define_split
16863   [(set (match_operand:DF 0 "register_operand" "")
16864         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
16865                              (match_operand:DF 2 "nonimmediate_operand" ""))
16866                          (match_operand:DF 3 "register_operand" "")
16867                          (match_operand:DF 4 "nonimmediate_operand" "")))
16868    (clobber (reg:CC 17))]
16869   "SSE_REG_P (operands[0]) && reload_completed
16870    && ((operands_match_p (operands[1], operands[3])
16871         && operands_match_p (operands[2], operands[4]))
16872        || (operands_match_p (operands[1], operands[4])
16873            && operands_match_p (operands[2], operands[3])))"
16874   [(set (match_dup 0)
16875         (if_then_else:DF (gt (match_dup 1)
16876                              (match_dup 2))
16877                          (match_dup 1)
16878                          (match_dup 2)))])
16880 (define_split
16881   [(set (match_operand:DF 0 "fp_register_operand" "")
16882         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "")
16883                              (match_operand:DF 2 "register_operand" ""))
16884                          (match_operand:DF 3 "register_operand" "")
16885                          (match_operand:DF 4 "register_operand" "")))
16886    (clobber (reg:CC 17))]
16887   "reload_completed
16888    && ((operands_match_p (operands[1], operands[3])
16889         && operands_match_p (operands[2], operands[4]))
16890        || (operands_match_p (operands[1], operands[4])
16891            && operands_match_p (operands[2], operands[3])))"
16892   [(set (reg:CCFP 17)
16893         (compare:CCFP (match_dup 1)
16894                       (match_dup 2)))
16895    (set (match_dup 0)
16896         (if_then_else:DF (gt (reg:CCFP 17) (const_int 0))
16897                          (match_dup 1)
16898                          (match_dup 2)))])
16900 (define_insn "*maxdf_sse"
16901   [(set (match_operand:DF 0 "register_operand" "=Y")
16902         (if_then_else:DF (gt (match_operand:DF 1 "register_operand" "0")
16903                              (match_operand:DF 2 "nonimmediate_operand" "Ym"))
16904                          (match_dup 1)
16905                          (match_dup 2)))]
16906   "TARGET_SSE2 && TARGET_SSE_MATH && reload_completed"
16907   "maxsd\t{%2, %0|%0, %2}"
16908   [(set_attr "type" "sse")
16909    (set_attr "mode" "DF")])
16911 ;; Misc patterns (?)
16913 ;; This pattern exists to put a dependency on all ebp-based memory accesses.
16914 ;; Otherwise there will be nothing to keep
16915 ;; 
16916 ;; [(set (reg ebp) (reg esp))]
16917 ;; [(set (reg esp) (plus (reg esp) (const_int -160000)))
16918 ;;  (clobber (eflags)]
16919 ;; [(set (mem (plus (reg ebp) (const_int -160000))) (const_int 0))]
16921 ;; in proper program order.
16922 (define_expand "pro_epilogue_adjust_stack"
16923   [(parallel [(set (match_operand:SI 0 "register_operand" "=r,r")
16924                    (plus:SI (match_operand:SI 1 "register_operand" "0,r")
16925                             (match_operand:SI 2 "immediate_operand" "i,i")))
16926               (clobber (reg:CC 17))
16927               (clobber (mem:BLK (scratch)))])]
16928  ""
16930   if (TARGET_64BIT)
16931     {
16932       emit_insn (gen_pro_epilogue_adjust_stack_rex64
16933                  (operands[0], operands[1], operands[2]));
16934       DONE;
16935     }
16938 (define_insn "*pro_epilogue_adjust_stack_1"
16939   [(set (match_operand:SI 0 "register_operand" "=r,r")
16940         (plus:SI (match_operand:SI 1 "register_operand" "0,r")
16941                  (match_operand:SI 2 "immediate_operand" "i,i")))
16942    (clobber (reg:CC 17))
16943    (clobber (mem:BLK (scratch)))]
16944   "!TARGET_64BIT"
16946   switch (get_attr_type (insn))
16947     {
16948     case TYPE_IMOV:
16949       return "mov{l}\t{%1, %0|%0, %1}";
16951     case TYPE_ALU:
16952       if (GET_CODE (operands[2]) == CONST_INT
16953           && (INTVAL (operands[2]) == 128
16954               || (INTVAL (operands[2]) < 0
16955                   && INTVAL (operands[2]) != -128)))
16956         {
16957           operands[2] = GEN_INT (-INTVAL (operands[2]));
16958           return "sub{l}\t{%2, %0|%0, %2}";
16959         }
16960       return "add{l}\t{%2, %0|%0, %2}";
16962     case TYPE_LEA:
16963       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
16964       return "lea{l}\t{%a2, %0|%0, %a2}";
16966     default:
16967       abort ();
16968     }
16970   [(set (attr "type")
16971         (cond [(eq_attr "alternative" "0")
16972                  (const_string "alu")
16973                (match_operand:SI 2 "const0_operand" "")
16974                  (const_string "imov")
16975               ]
16976               (const_string "lea")))
16977    (set_attr "mode" "SI")])
16979 (define_insn "pro_epilogue_adjust_stack_rex64"
16980   [(set (match_operand:DI 0 "register_operand" "=r,r")
16981         (plus:DI (match_operand:DI 1 "register_operand" "0,r")
16982                  (match_operand:DI 2 "x86_64_immediate_operand" "e,e")))
16983    (clobber (reg:CC 17))
16984    (clobber (mem:BLK (scratch)))]
16985   "TARGET_64BIT"
16987   switch (get_attr_type (insn))
16988     {
16989     case TYPE_IMOV:
16990       return "mov{q}\t{%1, %0|%0, %1}";
16992     case TYPE_ALU:
16993       if (GET_CODE (operands[2]) == CONST_INT
16994           && (INTVAL (operands[2]) == 128
16995               || (INTVAL (operands[2]) < 0
16996                   && INTVAL (operands[2]) != -128)))
16997         {
16998           operands[2] = GEN_INT (-INTVAL (operands[2]));
16999           return "sub{q}\t{%2, %0|%0, %2}";
17000         }
17001       return "add{q}\t{%2, %0|%0, %2}";
17003     case TYPE_LEA:
17004       operands[2] = SET_SRC (XVECEXP (PATTERN (insn), 0, 0));
17005       return "lea{q}\t{%a2, %0|%0, %a2}";
17007     default:
17008       abort ();
17009     }
17011   [(set (attr "type")
17012         (cond [(eq_attr "alternative" "0")
17013                  (const_string "alu")
17014                (match_operand:DI 2 "const0_operand" "")
17015                  (const_string "imov")
17016               ]
17017               (const_string "lea")))
17018    (set_attr "mode" "DI")])
17021 ;; Placeholder for the conditional moves.  This one is split either to SSE
17022 ;; based moves emulation or to usual cmove sequence.  Little bit unfortunate
17023 ;; fact is that compares supported by the cmp??ss instructions are exactly
17024 ;; swapped of those supported by cmove sequence.
17025 ;; The EQ/NE comparisons also needs bit care, since they are not directly
17026 ;; supported by i387 comparisons and we do need to emit two conditional moves
17027 ;; in tandem.
17029 (define_insn "sse_movsfcc"
17030   [(set (match_operand:SF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?f#xr,?f#xr,?r#xf,?r#xf,?r#xf,?r#xf")
17031         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
17032                         [(match_operand:SF 4 "nonimmediate_operand" "0#fx,x#fx,f#x,f#x,xm#f,xm#f,f#x,f#x,xm#f,xm#f")
17033                          (match_operand:SF 5 "nonimmediate_operand" "xm#f,xm#f,f#x,f#x,x#f,x#f,f#x,f#x,x#f,x#f")])
17034                       (match_operand:SF 2 "nonimmediate_operand" "x#fr,0#fr,f#fx,0#fx,f#fx,0#fx,rm#rx,0#rx,rm#rx,0#rx")
17035                       (match_operand:SF 3 "nonimmediate_operand" "x#fr,x#fr,0#fx,f#fx,0#fx,f#fx,0#fx,rm#rx,0#rx,rm#rx")))
17036    (clobber (match_scratch:SF 6 "=2,&4,X,X,X,X,X,X,X,X"))
17037    (clobber (reg:CC 17))]
17038   "TARGET_SSE
17039    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)
17040    /* Avoid combine from being smart and converting min/max
17041       instruction patterns into conditional moves.  */
17042    && ((GET_CODE (operands[1]) != LT && GET_CODE (operands[1]) != GT
17043         && GET_CODE (operands[1]) != UNLE && GET_CODE (operands[1]) != UNGE)
17044        || !rtx_equal_p (operands[4], operands[2])
17045        || !rtx_equal_p (operands[5], operands[3]))
17046    && (!TARGET_IEEE_FP
17047        || (GET_CODE (operands[1]) != EQ && GET_CODE (operands[1]) != NE))"
17048   "#")
17050 (define_insn "sse_movsfcc_eq"
17051   [(set (match_operand:SF 0 "register_operand" "=&x#rf,x#rf,?f#xr,?f#xr,?r#xf,?r#xf")
17052         (if_then_else:SF (eq (match_operand:SF 3 "nonimmediate_operand" "%0#fx,x#fx,f#x,xm#f,f#x,xm#f")
17053                              (match_operand:SF 4 "nonimmediate_operand" "xm#f,xm#f,f#x,x#f,f#x,x#f"))
17054                       (match_operand:SF 1 "nonimmediate_operand" "x#fr,0#fr,0#fx,0#fx,0#rx,0#rx")
17055                       (match_operand:SF 2 "nonimmediate_operand" "x#fr,x#fr,f#fx,f#fx,rm#rx,rm#rx")))
17056    (clobber (match_scratch:SF 5 "=1,&3,X,X,X,X"))
17057    (clobber (reg:CC 17))]
17058   "TARGET_SSE
17059    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
17060   "#")
17062 (define_insn "sse_movdfcc"
17063   [(set (match_operand:DF 0 "register_operand" "=&Y#rf,Y#rf,?f#Yr,?f#Yr,?f#Yr,?f#Yr,?r#Yf,?r#Yf,?r#Yf,?r#Yf")
17064         (if_then_else:DF (match_operator 1 "sse_comparison_operator"
17065                         [(match_operand:DF 4 "nonimmediate_operand" "0#fY,Y#fY,f#Y,f#Y,Ym#f,Ym#f,f#Y,f#Y,Ym#f,Ym#f")
17066                          (match_operand:DF 5 "nonimmediate_operand" "Ym#f,Ym#f,f#Y,f#Y,Y#f,Y#f,f#Y,f#Y,Y#f,Y#f")])
17067                       (match_operand:DF 2 "nonimmediate_operand" "Y#fr,0#fr,f#fY,0#fY,f#fY,0#fY,rm#rY,0#rY,rm#rY,0#rY")
17068                       (match_operand:DF 3 "nonimmediate_operand" "Y#fr,Y#fr,0#fY,f#fY,0#fY,f#fY,0#fY,rm#rY,0#rY,rm#rY")))
17069    (clobber (match_scratch:DF 6 "=2,&4,X,X,X,X,X,X,X,X"))
17070    (clobber (reg:CC 17))]
17071   "TARGET_SSE2
17072    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)
17073    /* Avoid combine from being smart and converting min/max
17074       instruction patterns into conditional moves.  */
17075    && ((GET_CODE (operands[1]) != LT && GET_CODE (operands[1]) != GT
17076         && GET_CODE (operands[1]) != UNLE && GET_CODE (operands[1]) != UNGE)
17077        || !rtx_equal_p (operands[4], operands[2])
17078        || !rtx_equal_p (operands[5], operands[3]))
17079    && (!TARGET_IEEE_FP
17080        || (GET_CODE (operands[1]) != EQ && GET_CODE (operands[1]) != NE))"
17081   "#")
17083 (define_insn "sse_movdfcc_eq"
17084   [(set (match_operand:DF 0 "register_operand" "=&Y#rf,Y#rf,?f#Yr,?f#Yr,?r#Yf,?r#Yf")
17085         (if_then_else:DF (eq (match_operand:DF 3 "nonimmediate_operand" "%0#fY,Y#fY,f#Y,Ym#f,f#Y,Ym#f")
17086                              (match_operand:DF 4 "nonimmediate_operand" "Ym#f,Ym#f,f#Y,Y#f,f#Y,Y#f"))
17087                       (match_operand:DF 1 "nonimmediate_operand" "Y#fr,0#fr,0#fY,0#fY,0#rY,0#rY")
17088                       (match_operand:DF 2 "nonimmediate_operand" "Y#fr,Y#fr,f#fY,f#fY,rm#rY,rm#rY")))
17089    (clobber (match_scratch:DF 5 "=1,&3,X,X,X,X"))
17090    (clobber (reg:CC 17))]
17091   "TARGET_SSE
17092    && (GET_CODE (operands[2]) != MEM || GET_CODE (operands[3]) != MEM)"
17093   "#")
17095 ;; For non-sse moves just expand the usual cmove sequence.
17096 (define_split
17097   [(set (match_operand 0 "register_operand" "")
17098         (if_then_else (match_operator 1 "comparison_operator"
17099                         [(match_operand 4 "nonimmediate_operand" "")
17100                          (match_operand 5 "register_operand" "")])
17101                       (match_operand 2 "nonimmediate_operand" "")
17102                       (match_operand 3 "nonimmediate_operand" "")))
17103    (clobber (match_operand 6 "" ""))
17104    (clobber (reg:CC 17))]
17105   "!SSE_REG_P (operands[0]) && reload_completed
17106    && VALID_SSE_REG_MODE (GET_MODE (operands[0]))"
17107   [(const_int 0)]
17109    ix86_compare_op0 = operands[5];
17110    ix86_compare_op1 = operands[4];
17111    operands[1] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands[1])),
17112                                  VOIDmode, operands[5], operands[4]);
17113    ix86_expand_fp_movcc (operands);
17114    DONE;
17117 ;; Split SSE based conditional move into sequence:
17118 ;; cmpCC op0, op4   -  set op0 to 0 or ffffffff depending on the comparison
17119 ;; and   op2, op0   -  zero op2 if comparison was false
17120 ;; nand  op0, op3   -  load op3 to op0 if comparison was false
17121 ;; or    op2, op0   -  get the nonzero one into the result.
17122 (define_split
17123   [(set (match_operand 0 "register_operand" "")
17124         (if_then_else (match_operator 1 "sse_comparison_operator"
17125                         [(match_operand 4 "register_operand" "")
17126                          (match_operand 5 "nonimmediate_operand" "")])
17127                       (match_operand 2 "register_operand" "")
17128                       (match_operand 3 "register_operand" "")))
17129    (clobber (match_operand 6 "" ""))
17130    (clobber (reg:CC 17))]
17131   "SSE_REG_P (operands[0]) && reload_completed"
17132   [(set (match_dup 4) (match_op_dup 1 [(match_dup 4) (match_dup 5)]))
17133    (set (subreg:TI (match_dup 2) 0) (and:TI (subreg:TI (match_dup 2) 0)
17134                                             (subreg:TI (match_dup 4) 0)))
17135    (set (subreg:TI (match_dup 4) 0) (and:TI (not:TI (subreg:TI (match_dup 4) 0))
17136                                             (subreg:TI (match_dup 3) 0)))
17137    (set (subreg:TI (match_dup 0) 0) (ior:TI (subreg:TI (match_dup 6) 0)
17138                                             (subreg:TI (match_dup 7) 0)))]
17140   if (GET_MODE (operands[2]) == DFmode
17141       && TARGET_SSE_PARTIAL_REGS && !optimize_size)
17142     {
17143       rtx op = simplify_gen_subreg (V2DFmode, operands[2], DFmode, 0);
17144       emit_insn (gen_sse2_unpcklpd (op, op, op));
17145       op = simplify_gen_subreg (V2DFmode, operands[3], DFmode, 0);
17146       emit_insn (gen_sse2_unpcklpd (op, op, op));
17147     }
17149   /* If op2 == op3, op3 would be clobbered before it is used.  */
17150   if (operands_match_p (operands[2], operands[3]))
17151     {
17152       emit_move_insn (operands[0], operands[2]);
17153       DONE;
17154     }
17156   PUT_MODE (operands[1], GET_MODE (operands[0]));
17157   if (operands_match_p (operands[0], operands[4]))
17158     operands[6] = operands[4], operands[7] = operands[2];
17159   else
17160     operands[6] = operands[2], operands[7] = operands[4];
17163 ;; Special case of conditional move we can handle effectively.
17164 ;; Do not brother with the integer/floating point case, since these are
17165 ;; bot considerably slower, unlike in the generic case.
17166 (define_insn "*sse_movsfcc_const0_1"
17167   [(set (match_operand:SF 0 "register_operand" "=&x")
17168         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
17169                         [(match_operand:SF 4 "register_operand" "0")
17170                          (match_operand:SF 5 "nonimmediate_operand" "xm")])
17171                       (match_operand:SF 2 "register_operand" "x")
17172                       (match_operand:SF 3 "const0_operand" "X")))]
17173   "TARGET_SSE"
17174   "#")
17176 (define_insn "*sse_movsfcc_const0_2"
17177   [(set (match_operand:SF 0 "register_operand" "=&x")
17178         (if_then_else:SF (match_operator 1 "sse_comparison_operator"
17179                         [(match_operand:SF 4 "register_operand" "0")
17180                          (match_operand:SF 5 "nonimmediate_operand" "xm")])
17181                       (match_operand:SF 2 "const0_operand" "X")
17182                       (match_operand:SF 3 "register_operand" "x")))]
17183   "TARGET_SSE"
17184   "#")
17186 (define_insn "*sse_movsfcc_const0_3"
17187   [(set (match_operand:SF 0 "register_operand" "=&x")
17188         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
17189                         [(match_operand:SF 4 "nonimmediate_operand" "xm")
17190                          (match_operand:SF 5 "register_operand" "0")])
17191                       (match_operand:SF 2 "register_operand" "x")
17192                       (match_operand:SF 3 "const0_operand" "X")))]
17193   "TARGET_SSE"
17194   "#")
17196 (define_insn "*sse_movsfcc_const0_4"
17197   [(set (match_operand:SF 0 "register_operand" "=&x")
17198         (if_then_else:SF (match_operator 1 "fcmov_comparison_operator"
17199                         [(match_operand:SF 4 "nonimmediate_operand" "xm")
17200                          (match_operand:SF 5 "register_operand" "0")])
17201                       (match_operand:SF 2 "const0_operand" "X")
17202                       (match_operand:SF 3 "register_operand" "x")))]
17203   "TARGET_SSE"
17204   "#")
17206 (define_insn "*sse_movdfcc_const0_1"
17207   [(set (match_operand:DF 0 "register_operand" "=&Y")
17208         (if_then_else:DF (match_operator 1 "sse_comparison_operator"
17209                         [(match_operand:DF 4 "register_operand" "0")
17210                          (match_operand:DF 5 "nonimmediate_operand" "Ym")])
17211                       (match_operand:DF 2 "register_operand" "Y")
17212                       (match_operand:DF 3 "const0_operand" "X")))]
17213   "TARGET_SSE2"
17214   "#")
17216 (define_insn "*sse_movdfcc_const0_2"
17217   [(set (match_operand:DF 0 "register_operand" "=&Y")
17218         (if_then_else:DF (match_operator 1 "sse_comparison_operator"
17219                         [(match_operand:DF 4 "register_operand" "0")
17220                          (match_operand:DF 5 "nonimmediate_operand" "Ym")])
17221                       (match_operand:DF 2 "const0_operand" "X")
17222                       (match_operand:DF 3 "register_operand" "Y")))]
17223   "TARGET_SSE2"
17224   "#")
17226 (define_insn "*sse_movdfcc_const0_3"
17227   [(set (match_operand:DF 0 "register_operand" "=&Y")
17228         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
17229                         [(match_operand:DF 4 "nonimmediate_operand" "Ym")
17230                          (match_operand:DF 5 "register_operand" "0")])
17231                       (match_operand:DF 2 "register_operand" "Y")
17232                       (match_operand:DF 3 "const0_operand" "X")))]
17233   "TARGET_SSE2"
17234   "#")
17236 (define_insn "*sse_movdfcc_const0_4"
17237   [(set (match_operand:DF 0 "register_operand" "=&Y")
17238         (if_then_else:DF (match_operator 1 "fcmov_comparison_operator"
17239                         [(match_operand:DF 4 "nonimmediate_operand" "Ym")
17240                          (match_operand:DF 5 "register_operand" "0")])
17241                       (match_operand:DF 2 "const0_operand" "X")
17242                       (match_operand:DF 3 "register_operand" "Y")))]
17243   "TARGET_SSE2"
17244   "#")
17246 (define_split
17247   [(set (match_operand 0 "register_operand" "")
17248         (if_then_else (match_operator 1 "comparison_operator"
17249                         [(match_operand 4 "nonimmediate_operand" "")
17250                          (match_operand 5 "nonimmediate_operand" "")])
17251                       (match_operand 2 "nonmemory_operand" "")
17252                       (match_operand 3 "nonmemory_operand" "")))]
17253   "SSE_REG_P (operands[0]) && reload_completed
17254    && (const0_operand (operands[2], GET_MODE (operands[0]))
17255        || const0_operand (operands[3], GET_MODE (operands[0])))"
17256   [(set (match_dup 0) (match_op_dup 1 [(match_dup 0) (match_dup 5)]))
17257    (set (subreg:TI (match_dup 0) 0) (and:TI (match_dup 6)
17258                                             (match_dup 7)))]
17260   if (TARGET_SSE_PARTIAL_REGS && !optimize_size
17261       && GET_MODE (operands[2]) == DFmode)
17262     {
17263       if (REG_P (operands[2]))
17264         {
17265           rtx op = simplify_gen_subreg (V2DFmode, operands[2], DFmode, 0);
17266           emit_insn (gen_sse2_unpcklpd (op, op, op));
17267         }
17268       if (REG_P (operands[3]))
17269         {
17270           rtx op = simplify_gen_subreg (V2DFmode, operands[3], DFmode, 0);
17271           emit_insn (gen_sse2_unpcklpd (op, op, op));
17272         }
17273     }
17274   PUT_MODE (operands[1], GET_MODE (operands[0]));
17275   if (!sse_comparison_operator (operands[1], VOIDmode)
17276       || !rtx_equal_p (operands[0], operands[4]))
17277     {
17278       rtx tmp = operands[5];
17279       operands[5] = operands[4];
17280       operands[4] = tmp;
17281       PUT_CODE (operands[1], swap_condition (GET_CODE (operands[1])));
17282     }
17283   if (!rtx_equal_p (operands[0], operands[4]))
17284     abort ();
17285   if (const0_operand (operands[2], GET_MODE (operands[0])))
17286     {
17287       operands[7] = operands[3];
17288       operands[6] = gen_rtx_NOT (TImode, gen_rtx_SUBREG (TImode, operands[0],
17289                                                          0));
17290     }
17291   else
17292     {
17293       operands[7] = operands[2];
17294       operands[6] = gen_rtx_SUBREG (TImode, operands[0], 0);
17295     }
17296   operands[7] = simplify_gen_subreg (TImode, operands[7],
17297                                      GET_MODE (operands[7]), 0);
17300 (define_expand "allocate_stack_worker"
17301   [(match_operand:SI 0 "register_operand" "")]
17302   "TARGET_STACK_PROBE"
17304   if (TARGET_64BIT)
17305     emit_insn (gen_allocate_stack_worker_rex64 (operands[0]));
17306   else
17307     emit_insn (gen_allocate_stack_worker_1 (operands[0]));
17308   DONE;
17311 (define_insn "allocate_stack_worker_1"
17312   [(unspec:SI [(match_operand:SI 0 "register_operand" "a")] UNSPEC_STACK_PROBE)
17313    (set (reg:SI 7) (minus:SI (reg:SI 7) (match_dup 0)))
17314    (clobber (match_dup 0))
17315    (clobber (reg:CC 17))]
17316   "!TARGET_64BIT && TARGET_STACK_PROBE"
17317   "call\t__alloca"
17318   [(set_attr "type" "multi")
17319    (set_attr "length" "5")])
17321 (define_insn "allocate_stack_worker_rex64"
17322   [(unspec:DI [(match_operand:DI 0 "register_operand" "a")] UNSPEC_STACK_PROBE)
17323    (set (reg:DI 7) (minus:DI (reg:DI 7) (match_dup 0)))
17324    (clobber (match_dup 0))
17325    (clobber (reg:CC 17))]
17326   "TARGET_64BIT && TARGET_STACK_PROBE"
17327   "call\t__alloca"
17328   [(set_attr "type" "multi")
17329    (set_attr "length" "5")])
17331 (define_expand "allocate_stack"
17332   [(parallel [(set (match_operand:SI 0 "register_operand" "=r")
17333                    (minus:SI (reg:SI 7)
17334                              (match_operand:SI 1 "general_operand" "")))
17335               (clobber (reg:CC 17))])
17336    (parallel [(set (reg:SI 7)
17337                    (minus:SI (reg:SI 7) (match_dup 1)))
17338               (clobber (reg:CC 17))])]
17339   "TARGET_STACK_PROBE"
17341 #ifdef CHECK_STACK_LIMIT
17342   if (GET_CODE (operands[1]) == CONST_INT
17343       && INTVAL (operands[1]) < CHECK_STACK_LIMIT)
17344     emit_insn (gen_subsi3 (stack_pointer_rtx, stack_pointer_rtx,
17345                            operands[1]));
17346   else 
17347 #endif
17348     emit_insn (gen_allocate_stack_worker (copy_to_mode_reg (SImode,
17349                                                             operands[1])));
17351   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
17352   DONE;
17355 (define_expand "builtin_setjmp_receiver"
17356   [(label_ref (match_operand 0 "" ""))]
17357   "!TARGET_64BIT && flag_pic"
17359   emit_insn (gen_set_got (pic_offset_table_rtx));
17360   DONE;
17363 ;; Avoid redundant prefixes by splitting HImode arithmetic to SImode.
17365 (define_split
17366   [(set (match_operand 0 "register_operand" "")
17367         (match_operator 3 "promotable_binary_operator"
17368            [(match_operand 1 "register_operand" "")
17369             (match_operand 2 "aligned_operand" "")]))
17370    (clobber (reg:CC 17))]
17371   "! TARGET_PARTIAL_REG_STALL && reload_completed
17372    && ((GET_MODE (operands[0]) == HImode 
17373         && ((!optimize_size && !TARGET_FAST_PREFIX)
17374             || GET_CODE (operands[2]) != CONST_INT
17375             || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')))
17376        || (GET_MODE (operands[0]) == QImode 
17377            && (TARGET_PROMOTE_QImode || optimize_size)))"
17378   [(parallel [(set (match_dup 0)
17379                    (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
17380               (clobber (reg:CC 17))])]
17381   "operands[0] = gen_lowpart (SImode, operands[0]);
17382    operands[1] = gen_lowpart (SImode, operands[1]);
17383    if (GET_CODE (operands[3]) != ASHIFT)
17384      operands[2] = gen_lowpart (SImode, operands[2]);
17385    PUT_MODE (operands[3], SImode);")
17387 (define_split
17388   [(set (reg 17)
17389         (compare (and (match_operand 1 "aligned_operand" "")
17390                       (match_operand 2 "const_int_operand" ""))
17391                  (const_int 0)))
17392    (set (match_operand 0 "register_operand" "")
17393         (and (match_dup 1) (match_dup 2)))]
17394   "! TARGET_PARTIAL_REG_STALL && reload_completed
17395    && ix86_match_ccmode (insn, CCNOmode)
17396    && (GET_MODE (operands[0]) == HImode
17397        || (GET_MODE (operands[0]) == QImode 
17398            /* Ensure that the operand will remain sign extended immediate.  */
17399            && INTVAL (operands[2]) >= 0
17400            && (TARGET_PROMOTE_QImode || optimize_size)))"
17401   [(parallel [(set (reg:CCNO 17)
17402                    (compare:CCNO (and:SI (match_dup 1) (match_dup 2))
17403                                  (const_int 0)))
17404               (set (match_dup 0)
17405                    (and:SI (match_dup 1) (match_dup 2)))])]
17406   "operands[2]
17407      = gen_int_mode (INTVAL (operands[2])
17408                      & GET_MODE_MASK (GET_MODE (operands[0])),
17409                      SImode);
17410    operands[0] = gen_lowpart (SImode, operands[0]);
17411    operands[1] = gen_lowpart (SImode, operands[1]);")
17413 ; Don't promote the QImode tests, as i386 don't have encoding of
17414 ; the test instruction with 32bit sign extended immediate and thus
17415 ; the code grows.
17416 (define_split
17417   [(set (reg 17)
17418         (compare (and (match_operand:HI 0 "aligned_operand" "")
17419                       (match_operand:HI 1 "const_int_operand" ""))
17420                  (const_int 0)))]
17421   "! TARGET_PARTIAL_REG_STALL && reload_completed
17422    && ix86_match_ccmode (insn, CCNOmode)
17423    && GET_MODE (operands[0]) == HImode"
17424   [(set (reg:CCNO 17)
17425         (compare:CCNO (and:SI (match_dup 0) (match_dup 1))
17426                       (const_int 0)))]
17427   "operands[1]
17428      = gen_int_mode (INTVAL (operands[1])
17429                      & GET_MODE_MASK (GET_MODE (operands[0])),
17430                      SImode);
17431    operands[0] = gen_lowpart (SImode, operands[0]);")
17433 (define_split
17434   [(set (match_operand 0 "register_operand" "")
17435         (neg (match_operand 1 "register_operand" "")))
17436    (clobber (reg:CC 17))]
17437   "! TARGET_PARTIAL_REG_STALL && reload_completed
17438    && (GET_MODE (operands[0]) == HImode
17439        || (GET_MODE (operands[0]) == QImode 
17440            && (TARGET_PROMOTE_QImode || optimize_size)))"
17441   [(parallel [(set (match_dup 0)
17442                    (neg:SI (match_dup 1)))
17443               (clobber (reg:CC 17))])]
17444   "operands[0] = gen_lowpart (SImode, operands[0]);
17445    operands[1] = gen_lowpart (SImode, operands[1]);")
17447 (define_split
17448   [(set (match_operand 0 "register_operand" "")
17449         (not (match_operand 1 "register_operand" "")))]
17450   "! TARGET_PARTIAL_REG_STALL && reload_completed
17451    && (GET_MODE (operands[0]) == HImode
17452        || (GET_MODE (operands[0]) == QImode 
17453            && (TARGET_PROMOTE_QImode || optimize_size)))"
17454   [(set (match_dup 0)
17455         (not:SI (match_dup 1)))]
17456   "operands[0] = gen_lowpart (SImode, operands[0]);
17457    operands[1] = gen_lowpart (SImode, operands[1]);")
17459 (define_split 
17460   [(set (match_operand 0 "register_operand" "")
17461         (if_then_else (match_operator 1 "comparison_operator" 
17462                                 [(reg 17) (const_int 0)])
17463                       (match_operand 2 "register_operand" "")
17464                       (match_operand 3 "register_operand" "")))]
17465   "! TARGET_PARTIAL_REG_STALL && TARGET_CMOVE
17466    && (GET_MODE (operands[0]) == HImode
17467        || (GET_MODE (operands[0]) == QImode 
17468            && (TARGET_PROMOTE_QImode || optimize_size)))"
17469   [(set (match_dup 0)
17470         (if_then_else:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
17471   "operands[0] = gen_lowpart (SImode, operands[0]);
17472    operands[2] = gen_lowpart (SImode, operands[2]);
17473    operands[3] = gen_lowpart (SImode, operands[3]);")
17474                         
17476 ;; RTL Peephole optimizations, run before sched2.  These primarily look to
17477 ;; transform a complex memory operation into two memory to register operations.
17479 ;; Don't push memory operands
17480 (define_peephole2
17481   [(set (match_operand:SI 0 "push_operand" "")
17482         (match_operand:SI 1 "memory_operand" ""))
17483    (match_scratch:SI 2 "r")]
17484   "! optimize_size && ! TARGET_PUSH_MEMORY"
17485   [(set (match_dup 2) (match_dup 1))
17486    (set (match_dup 0) (match_dup 2))]
17487   "")
17489 (define_peephole2
17490   [(set (match_operand:DI 0 "push_operand" "")
17491         (match_operand:DI 1 "memory_operand" ""))
17492    (match_scratch:DI 2 "r")]
17493   "! optimize_size && ! TARGET_PUSH_MEMORY"
17494   [(set (match_dup 2) (match_dup 1))
17495    (set (match_dup 0) (match_dup 2))]
17496   "")
17498 ;; We need to handle SFmode only, because DFmode and XFmode is split to
17499 ;; SImode pushes.
17500 (define_peephole2
17501   [(set (match_operand:SF 0 "push_operand" "")
17502         (match_operand:SF 1 "memory_operand" ""))
17503    (match_scratch:SF 2 "r")]
17504   "! optimize_size && ! TARGET_PUSH_MEMORY"
17505   [(set (match_dup 2) (match_dup 1))
17506    (set (match_dup 0) (match_dup 2))]
17507   "")
17509 (define_peephole2
17510   [(set (match_operand:HI 0 "push_operand" "")
17511         (match_operand:HI 1 "memory_operand" ""))
17512    (match_scratch:HI 2 "r")]
17513   "! optimize_size && ! TARGET_PUSH_MEMORY"
17514   [(set (match_dup 2) (match_dup 1))
17515    (set (match_dup 0) (match_dup 2))]
17516   "")
17518 (define_peephole2
17519   [(set (match_operand:QI 0 "push_operand" "")
17520         (match_operand:QI 1 "memory_operand" ""))
17521    (match_scratch:QI 2 "q")]
17522   "! optimize_size && ! TARGET_PUSH_MEMORY"
17523   [(set (match_dup 2) (match_dup 1))
17524    (set (match_dup 0) (match_dup 2))]
17525   "")
17527 ;; Don't move an immediate directly to memory when the instruction
17528 ;; gets too big.
17529 (define_peephole2
17530   [(match_scratch:SI 1 "r")
17531    (set (match_operand:SI 0 "memory_operand" "")
17532         (const_int 0))]
17533   "! optimize_size
17534    && ! TARGET_USE_MOV0
17535    && TARGET_SPLIT_LONG_MOVES
17536    && get_attr_length (insn) >= ix86_cost->large_insn
17537    && peep2_regno_dead_p (0, FLAGS_REG)"
17538   [(parallel [(set (match_dup 1) (const_int 0))
17539               (clobber (reg:CC 17))])
17540    (set (match_dup 0) (match_dup 1))]
17541   "")
17543 (define_peephole2
17544   [(match_scratch:HI 1 "r")
17545    (set (match_operand:HI 0 "memory_operand" "")
17546         (const_int 0))]
17547   "! optimize_size
17548    && ! TARGET_USE_MOV0
17549    && TARGET_SPLIT_LONG_MOVES
17550    && get_attr_length (insn) >= ix86_cost->large_insn
17551    && peep2_regno_dead_p (0, FLAGS_REG)"
17552   [(parallel [(set (match_dup 2) (const_int 0))
17553               (clobber (reg:CC 17))])
17554    (set (match_dup 0) (match_dup 1))]
17555   "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));")
17557 (define_peephole2
17558   [(match_scratch:QI 1 "q")
17559    (set (match_operand:QI 0 "memory_operand" "")
17560         (const_int 0))]
17561   "! optimize_size
17562    && ! TARGET_USE_MOV0
17563    && TARGET_SPLIT_LONG_MOVES
17564    && get_attr_length (insn) >= ix86_cost->large_insn
17565    && peep2_regno_dead_p (0, FLAGS_REG)"
17566   [(parallel [(set (match_dup 2) (const_int 0))
17567               (clobber (reg:CC 17))])
17568    (set (match_dup 0) (match_dup 1))]
17569   "operands[2] = gen_rtx_REG (SImode, true_regnum (operands[1]));")
17571 (define_peephole2
17572   [(match_scratch:SI 2 "r")
17573    (set (match_operand:SI 0 "memory_operand" "")
17574         (match_operand:SI 1 "immediate_operand" ""))]
17575   "! optimize_size
17576    && get_attr_length (insn) >= ix86_cost->large_insn
17577    && TARGET_SPLIT_LONG_MOVES"
17578   [(set (match_dup 2) (match_dup 1))
17579    (set (match_dup 0) (match_dup 2))]
17580   "")
17582 (define_peephole2
17583   [(match_scratch:HI 2 "r")
17584    (set (match_operand:HI 0 "memory_operand" "")
17585         (match_operand:HI 1 "immediate_operand" ""))]
17586   "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn
17587   && TARGET_SPLIT_LONG_MOVES"
17588   [(set (match_dup 2) (match_dup 1))
17589    (set (match_dup 0) (match_dup 2))]
17590   "")
17592 (define_peephole2
17593   [(match_scratch:QI 2 "q")
17594    (set (match_operand:QI 0 "memory_operand" "")
17595         (match_operand:QI 1 "immediate_operand" ""))]
17596   "! optimize_size && get_attr_length (insn) >= ix86_cost->large_insn
17597   && TARGET_SPLIT_LONG_MOVES"
17598   [(set (match_dup 2) (match_dup 1))
17599    (set (match_dup 0) (match_dup 2))]
17600   "")
17602 ;; Don't compare memory with zero, load and use a test instead.
17603 (define_peephole2
17604   [(set (reg 17)
17605         (compare (match_operand:SI 0 "memory_operand" "")
17606                  (const_int 0)))
17607    (match_scratch:SI 3 "r")]
17608   "ix86_match_ccmode (insn, CCNOmode) && ! optimize_size"
17609   [(set (match_dup 3) (match_dup 0))
17610    (set (reg:CCNO 17) (compare:CCNO (match_dup 3) (const_int 0)))]
17611   "")
17613 ;; NOT is not pairable on Pentium, while XOR is, but one byte longer. 
17614 ;; Don't split NOTs with a displacement operand, because resulting XOR
17615 ;; will not be pairable anyway.
17617 ;; On AMD K6, NOT is vector decoded with memory operand that can not be
17618 ;; represented using a modRM byte.  The XOR replacement is long decoded,
17619 ;; so this split helps here as well.
17621 ;; Note: Can't do this as a regular split because we can't get proper
17622 ;; lifetime information then.
17624 (define_peephole2
17625   [(set (match_operand:SI 0 "nonimmediate_operand" "")
17626         (not:SI (match_operand:SI 1 "nonimmediate_operand" "")))]
17627   "!optimize_size
17628    && peep2_regno_dead_p (0, FLAGS_REG)
17629    && ((TARGET_PENTIUM 
17630         && (GET_CODE (operands[0]) != MEM
17631             || !memory_displacement_operand (operands[0], SImode)))
17632        || (TARGET_K6 && long_memory_operand (operands[0], SImode)))"
17633   [(parallel [(set (match_dup 0)
17634                    (xor:SI (match_dup 1) (const_int -1)))
17635               (clobber (reg:CC 17))])]
17636   "")
17638 (define_peephole2
17639   [(set (match_operand:HI 0 "nonimmediate_operand" "")
17640         (not:HI (match_operand:HI 1 "nonimmediate_operand" "")))]
17641   "!optimize_size
17642    && peep2_regno_dead_p (0, FLAGS_REG)
17643    && ((TARGET_PENTIUM 
17644         && (GET_CODE (operands[0]) != MEM
17645             || !memory_displacement_operand (operands[0], HImode)))
17646        || (TARGET_K6 && long_memory_operand (operands[0], HImode)))"
17647   [(parallel [(set (match_dup 0)
17648                    (xor:HI (match_dup 1) (const_int -1)))
17649               (clobber (reg:CC 17))])]
17650   "")
17652 (define_peephole2
17653   [(set (match_operand:QI 0 "nonimmediate_operand" "")
17654         (not:QI (match_operand:QI 1 "nonimmediate_operand" "")))]
17655   "!optimize_size
17656    && peep2_regno_dead_p (0, FLAGS_REG)
17657    && ((TARGET_PENTIUM 
17658         && (GET_CODE (operands[0]) != MEM
17659             || !memory_displacement_operand (operands[0], QImode)))
17660        || (TARGET_K6 && long_memory_operand (operands[0], QImode)))"
17661   [(parallel [(set (match_dup 0)
17662                    (xor:QI (match_dup 1) (const_int -1)))
17663               (clobber (reg:CC 17))])]
17664   "")
17666 ;; Non pairable "test imm, reg" instructions can be translated to
17667 ;; "and imm, reg" if reg dies.  The "and" form is also shorter (one
17668 ;; byte opcode instead of two, have a short form for byte operands),
17669 ;; so do it for other CPUs as well.  Given that the value was dead,
17670 ;; this should not create any new dependencies.  Pass on the sub-word
17671 ;; versions if we're concerned about partial register stalls.
17673 (define_peephole2
17674   [(set (reg 17)
17675         (compare (and:SI (match_operand:SI 0 "register_operand" "")
17676                          (match_operand:SI 1 "immediate_operand" ""))
17677                  (const_int 0)))]
17678   "ix86_match_ccmode (insn, CCNOmode)
17679    && (true_regnum (operands[0]) != 0
17680        || (GET_CODE (operands[1]) == CONST_INT
17681            && CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'K')))
17682    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17683   [(parallel
17684      [(set (reg:CCNO 17)
17685            (compare:CCNO (and:SI (match_dup 0)
17686                                  (match_dup 1))
17687                          (const_int 0)))
17688       (set (match_dup 0)
17689            (and:SI (match_dup 0) (match_dup 1)))])]
17690   "")
17692 ;; We don't need to handle HImode case, because it will be promoted to SImode
17693 ;; on ! TARGET_PARTIAL_REG_STALL
17695 (define_peephole2
17696   [(set (reg 17)
17697         (compare (and:QI (match_operand:QI 0 "register_operand" "")
17698                          (match_operand:QI 1 "immediate_operand" ""))
17699                  (const_int 0)))]
17700   "! TARGET_PARTIAL_REG_STALL
17701    && ix86_match_ccmode (insn, CCNOmode)
17702    && true_regnum (operands[0]) != 0
17703    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17704   [(parallel
17705      [(set (reg:CCNO 17)
17706            (compare:CCNO (and:QI (match_dup 0)
17707                                  (match_dup 1))
17708                          (const_int 0)))
17709       (set (match_dup 0)
17710            (and:QI (match_dup 0) (match_dup 1)))])]
17711   "")
17713 (define_peephole2
17714   [(set (reg 17)
17715         (compare
17716           (and:SI
17717             (zero_extract:SI
17718               (match_operand 0 "ext_register_operand" "")
17719               (const_int 8)
17720               (const_int 8))
17721             (match_operand 1 "const_int_operand" ""))
17722           (const_int 0)))]
17723   "! TARGET_PARTIAL_REG_STALL
17724    && ix86_match_ccmode (insn, CCNOmode)
17725    && true_regnum (operands[0]) != 0
17726    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
17727   [(parallel [(set (reg:CCNO 17)
17728                    (compare:CCNO
17729                        (and:SI
17730                          (zero_extract:SI
17731                          (match_dup 0)
17732                          (const_int 8)
17733                          (const_int 8))
17734                         (match_dup 1))
17735                    (const_int 0)))
17736               (set (zero_extract:SI (match_dup 0)
17737                                     (const_int 8)
17738                                     (const_int 8))
17739                    (and:SI 
17740                      (zero_extract:SI
17741                        (match_dup 0)
17742                        (const_int 8)
17743                        (const_int 8))
17744                      (match_dup 1)))])]
17745   "")
17747 ;; Don't do logical operations with memory inputs.
17748 (define_peephole2
17749   [(match_scratch:SI 2 "r")
17750    (parallel [(set (match_operand:SI 0 "register_operand" "")
17751                    (match_operator:SI 3 "arith_or_logical_operator"
17752                      [(match_dup 0)
17753                       (match_operand:SI 1 "memory_operand" "")]))
17754               (clobber (reg:CC 17))])]
17755   "! optimize_size && ! TARGET_READ_MODIFY"
17756   [(set (match_dup 2) (match_dup 1))
17757    (parallel [(set (match_dup 0)
17758                    (match_op_dup 3 [(match_dup 0) (match_dup 2)]))
17759               (clobber (reg:CC 17))])]
17760   "")
17762 (define_peephole2
17763   [(match_scratch:SI 2 "r")
17764    (parallel [(set (match_operand:SI 0 "register_operand" "")
17765                    (match_operator:SI 3 "arith_or_logical_operator"
17766                      [(match_operand:SI 1 "memory_operand" "")
17767                       (match_dup 0)]))
17768               (clobber (reg:CC 17))])]
17769   "! optimize_size && ! TARGET_READ_MODIFY"
17770   [(set (match_dup 2) (match_dup 1))
17771    (parallel [(set (match_dup 0)
17772                    (match_op_dup 3 [(match_dup 2) (match_dup 0)]))
17773               (clobber (reg:CC 17))])]
17774   "")
17776 ; Don't do logical operations with memory outputs
17778 ; These two don't make sense for PPro/PII -- we're expanding a 4-uop
17779 ; instruction into two 1-uop insns plus a 2-uop insn.  That last has
17780 ; the same decoder scheduling characteristics as the original.
17782 (define_peephole2
17783   [(match_scratch:SI 2 "r")
17784    (parallel [(set (match_operand:SI 0 "memory_operand" "")
17785                    (match_operator:SI 3 "arith_or_logical_operator"
17786                      [(match_dup 0)
17787                       (match_operand:SI 1 "nonmemory_operand" "")]))
17788               (clobber (reg:CC 17))])]
17789   "! optimize_size && ! TARGET_READ_MODIFY_WRITE"
17790   [(set (match_dup 2) (match_dup 0))
17791    (parallel [(set (match_dup 2)
17792                    (match_op_dup 3 [(match_dup 2) (match_dup 1)]))
17793               (clobber (reg:CC 17))])
17794    (set (match_dup 0) (match_dup 2))]
17795   "")
17797 (define_peephole2
17798   [(match_scratch:SI 2 "r")
17799    (parallel [(set (match_operand:SI 0 "memory_operand" "")
17800                    (match_operator:SI 3 "arith_or_logical_operator"
17801                      [(match_operand:SI 1 "nonmemory_operand" "")
17802                       (match_dup 0)]))
17803               (clobber (reg:CC 17))])]
17804   "! optimize_size && ! TARGET_READ_MODIFY_WRITE"
17805   [(set (match_dup 2) (match_dup 0))
17806    (parallel [(set (match_dup 2)
17807                    (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
17808               (clobber (reg:CC 17))])
17809    (set (match_dup 0) (match_dup 2))]
17810   "")
17812 ;; Attempt to always use XOR for zeroing registers.
17813 (define_peephole2
17814   [(set (match_operand 0 "register_operand" "")
17815         (const_int 0))]
17816   "(GET_MODE (operands[0]) == QImode
17817     || GET_MODE (operands[0]) == HImode
17818     || GET_MODE (operands[0]) == SImode
17819     || (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
17820    && (! TARGET_USE_MOV0 || optimize_size)
17821    && peep2_regno_dead_p (0, FLAGS_REG)"
17822   [(parallel [(set (match_dup 0) (const_int 0))
17823               (clobber (reg:CC 17))])]
17824   "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode,
17825                               true_regnum (operands[0]));")
17827 (define_peephole2
17828   [(set (strict_low_part (match_operand 0 "register_operand" ""))
17829         (const_int 0))]
17830   "(GET_MODE (operands[0]) == QImode
17831     || GET_MODE (operands[0]) == HImode)
17832    && (! TARGET_USE_MOV0 || optimize_size)
17833    && peep2_regno_dead_p (0, FLAGS_REG)"
17834   [(parallel [(set (strict_low_part (match_dup 0)) (const_int 0))
17835               (clobber (reg:CC 17))])])
17837 ;; For HI and SI modes, or $-1,reg is smaller than mov $-1,reg.
17838 (define_peephole2
17839   [(set (match_operand 0 "register_operand" "")
17840         (const_int -1))]
17841   "(GET_MODE (operands[0]) == HImode
17842     || GET_MODE (operands[0]) == SImode 
17843     || (GET_MODE (operands[0]) == DImode && TARGET_64BIT))
17844    && (optimize_size || TARGET_PENTIUM)
17845    && peep2_regno_dead_p (0, FLAGS_REG)"
17846   [(parallel [(set (match_dup 0) (const_int -1))
17847               (clobber (reg:CC 17))])]
17848   "operands[0] = gen_rtx_REG (GET_MODE (operands[0]) == DImode ? DImode : SImode,
17849                               true_regnum (operands[0]));")
17851 ;; Attempt to convert simple leas to adds. These can be created by
17852 ;; move expanders.
17853 (define_peephole2
17854   [(set (match_operand:SI 0 "register_operand" "")
17855         (plus:SI (match_dup 0)
17856                  (match_operand:SI 1 "nonmemory_operand" "")))]
17857   "peep2_regno_dead_p (0, FLAGS_REG)"
17858   [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))
17859               (clobber (reg:CC 17))])]
17860   "")
17862 (define_peephole2
17863   [(set (match_operand:SI 0 "register_operand" "")
17864         (subreg:SI (plus:DI (match_operand:DI 1 "register_operand" "")
17865                             (match_operand:DI 2 "nonmemory_operand" "")) 0))]
17866   "peep2_regno_dead_p (0, FLAGS_REG) && REGNO (operands[0]) == REGNO (operands[1])"
17867   [(parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
17868               (clobber (reg:CC 17))])]
17869   "operands[2] = gen_lowpart (SImode, operands[2]);")
17871 (define_peephole2
17872   [(set (match_operand:DI 0 "register_operand" "")
17873         (plus:DI (match_dup 0)
17874                  (match_operand:DI 1 "x86_64_general_operand" "")))]
17875   "peep2_regno_dead_p (0, FLAGS_REG)"
17876   [(parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 1)))
17877               (clobber (reg:CC 17))])]
17878   "")
17880 (define_peephole2
17881   [(set (match_operand:SI 0 "register_operand" "")
17882         (mult:SI (match_dup 0)
17883                  (match_operand:SI 1 "const_int_operand" "")))]
17884   "exact_log2 (INTVAL (operands[1])) >= 0
17885    && peep2_regno_dead_p (0, FLAGS_REG)"
17886   [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
17887               (clobber (reg:CC 17))])]
17888   "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
17890 (define_peephole2
17891   [(set (match_operand:DI 0 "register_operand" "")
17892         (mult:DI (match_dup 0)
17893                  (match_operand:DI 1 "const_int_operand" "")))]
17894   "exact_log2 (INTVAL (operands[1])) >= 0
17895    && peep2_regno_dead_p (0, FLAGS_REG)"
17896   [(parallel [(set (match_dup 0) (ashift:DI (match_dup 0) (match_dup 2)))
17897               (clobber (reg:CC 17))])]
17898   "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1])));")
17900 (define_peephole2
17901   [(set (match_operand:SI 0 "register_operand" "")
17902         (subreg:SI (mult:DI (match_operand:DI 1 "register_operand" "")
17903                    (match_operand:DI 2 "const_int_operand" "")) 0))]
17904   "exact_log2 (INTVAL (operands[2])) >= 0
17905    && REGNO (operands[0]) == REGNO (operands[1])
17906    && peep2_regno_dead_p (0, FLAGS_REG)"
17907   [(parallel [(set (match_dup 0) (ashift:SI (match_dup 0) (match_dup 2)))
17908               (clobber (reg:CC 17))])]
17909   "operands[2] = GEN_INT (exact_log2 (INTVAL (operands[2])));")
17911 ;; The ESP adjustments can be done by the push and pop instructions.  Resulting
17912 ;; code is shorter, since push is only 1 byte, while add imm, %esp 3 bytes.  On
17913 ;; many CPUs it is also faster, since special hardware to avoid esp
17914 ;; dependencies is present.
17916 ;; While some of these conversions may be done using splitters, we use peepholes
17917 ;; in order to allow combine_stack_adjustments pass to see nonobfuscated RTL.
17919 ;; Convert prologue esp subtractions to push.
17920 ;; We need register to push.  In order to keep verify_flow_info happy we have
17921 ;; two choices
17922 ;; - use scratch and clobber it in order to avoid dependencies
17923 ;; - use already live register
17924 ;; We can't use the second way right now, since there is no reliable way how to
17925 ;; verify that given register is live.  First choice will also most likely in
17926 ;; fewer dependencies.  On the place of esp adjustments it is very likely that
17927 ;; call clobbered registers are dead.  We may want to use base pointer as an
17928 ;; alternative when no register is available later.
17930 (define_peephole2
17931   [(match_scratch:SI 0 "r")
17932    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
17933               (clobber (reg:CC 17))
17934               (clobber (mem:BLK (scratch)))])]
17935   "optimize_size || !TARGET_SUB_ESP_4"
17936   [(clobber (match_dup 0))
17937    (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17938               (clobber (mem:BLK (scratch)))])])
17940 (define_peephole2
17941   [(match_scratch:SI 0 "r")
17942    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17943               (clobber (reg:CC 17))
17944               (clobber (mem:BLK (scratch)))])]
17945   "optimize_size || !TARGET_SUB_ESP_8"
17946   [(clobber (match_dup 0))
17947    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17948    (parallel [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17949               (clobber (mem:BLK (scratch)))])])
17951 ;; Convert esp subtractions to push.
17952 (define_peephole2
17953   [(match_scratch:SI 0 "r")
17954    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
17955               (clobber (reg:CC 17))])]
17956   "optimize_size || !TARGET_SUB_ESP_4"
17957   [(clobber (match_dup 0))
17958    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))])
17960 (define_peephole2
17961   [(match_scratch:SI 0 "r")
17962    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
17963               (clobber (reg:CC 17))])]
17964   "optimize_size || !TARGET_SUB_ESP_8"
17965   [(clobber (match_dup 0))
17966    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))
17967    (set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 0))])
17969 ;; Convert epilogue deallocator to pop.
17970 (define_peephole2
17971   [(match_scratch:SI 0 "r")
17972    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17973               (clobber (reg:CC 17))
17974               (clobber (mem:BLK (scratch)))])]
17975   "optimize_size || !TARGET_ADD_ESP_4"
17976   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17977               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17978               (clobber (mem:BLK (scratch)))])]
17979   "")
17981 ;; Two pops case is tricky, since pop causes dependency on destination register.
17982 ;; We use two registers if available.
17983 (define_peephole2
17984   [(match_scratch:SI 0 "r")
17985    (match_scratch:SI 1 "r")
17986    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
17987               (clobber (reg:CC 17))
17988               (clobber (mem:BLK (scratch)))])]
17989   "optimize_size || !TARGET_ADD_ESP_8"
17990   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
17991               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
17992               (clobber (mem:BLK (scratch)))])
17993    (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
17994               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
17995   "")
17997 (define_peephole2
17998   [(match_scratch:SI 0 "r")
17999    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
18000               (clobber (reg:CC 17))
18001               (clobber (mem:BLK (scratch)))])]
18002   "optimize_size"
18003   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18004               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
18005               (clobber (mem:BLK (scratch)))])
18006    (parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18007               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
18008   "")
18010 ;; Convert esp additions to pop.
18011 (define_peephole2
18012   [(match_scratch:SI 0 "r")
18013    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))
18014               (clobber (reg:CC 17))])]
18015   ""
18016   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18017               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
18018   "")
18020 ;; Two pops case is tricky, since pop causes dependency on destination register.
18021 ;; We use two registers if available.
18022 (define_peephole2
18023   [(match_scratch:SI 0 "r")
18024    (match_scratch:SI 1 "r")
18025    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
18026               (clobber (reg:CC 17))])]
18027   ""
18028   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18029               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
18030    (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
18031               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
18032   "")
18034 (define_peephole2
18035   [(match_scratch:SI 0 "r")
18036    (parallel [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 8)))
18037               (clobber (reg:CC 17))])]
18038   "optimize_size"
18039   [(parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18040               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])
18041    (parallel [(set (match_dup 0) (mem:SI (reg:SI 7)))
18042               (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
18043   "")
18045 ;; Convert compares with 1 to shorter inc/dec operations when CF is not
18046 ;; required and register dies.
18047 (define_peephole2
18048   [(set (reg 17)
18049         (compare (match_operand:SI 0 "register_operand" "")
18050                  (match_operand:SI 1 "incdec_operand" "")))]
18051   "ix86_match_ccmode (insn, CCGCmode)
18052    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
18053   [(parallel [(set (reg:CCGC 17)
18054                    (compare:CCGC (match_dup 0)
18055                                  (match_dup 1)))
18056               (clobber (match_dup 0))])]
18057   "")
18059 (define_peephole2
18060   [(set (reg 17)
18061         (compare (match_operand:HI 0 "register_operand" "")
18062                  (match_operand:HI 1 "incdec_operand" "")))]
18063   "ix86_match_ccmode (insn, CCGCmode)
18064    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
18065   [(parallel [(set (reg:CCGC 17)
18066                    (compare:CCGC (match_dup 0)
18067                                  (match_dup 1)))
18068               (clobber (match_dup 0))])]
18069   "")
18071 (define_peephole2
18072   [(set (reg 17)
18073         (compare (match_operand:QI 0 "register_operand" "")
18074                  (match_operand:QI 1 "incdec_operand" "")))]
18075   "ix86_match_ccmode (insn, CCGCmode)
18076    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
18077   [(parallel [(set (reg:CCGC 17)
18078                    (compare:CCGC (match_dup 0)
18079                                  (match_dup 1)))
18080               (clobber (match_dup 0))])]
18081   "")
18083 ;; Convert compares with 128 to shorter add -128
18084 (define_peephole2
18085   [(set (reg 17)
18086         (compare (match_operand:SI 0 "register_operand" "")
18087                  (const_int 128)))]
18088   "ix86_match_ccmode (insn, CCGCmode)
18089    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
18090   [(parallel [(set (reg:CCGC 17)
18091                    (compare:CCGC (match_dup 0)
18092                                  (const_int 128)))
18093               (clobber (match_dup 0))])]
18094   "")
18096 (define_peephole2
18097   [(set (reg 17)
18098         (compare (match_operand:HI 0 "register_operand" "")
18099                  (const_int 128)))]
18100   "ix86_match_ccmode (insn, CCGCmode)
18101    && find_regno_note (insn, REG_DEAD, true_regnum (operands[0]))"
18102   [(parallel [(set (reg:CCGC 17)
18103                    (compare:CCGC (match_dup 0)
18104                                  (const_int 128)))
18105               (clobber (match_dup 0))])]
18106   "")
18108 (define_peephole2
18109   [(match_scratch:DI 0 "r")
18110    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
18111               (clobber (reg:CC 17))
18112               (clobber (mem:BLK (scratch)))])]
18113   "optimize_size || !TARGET_SUB_ESP_4"
18114   [(clobber (match_dup 0))
18115    (parallel [(set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
18116               (clobber (mem:BLK (scratch)))])])
18118 (define_peephole2
18119   [(match_scratch:DI 0 "r")
18120    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
18121               (clobber (reg:CC 17))
18122               (clobber (mem:BLK (scratch)))])]
18123   "optimize_size || !TARGET_SUB_ESP_8"
18124   [(clobber (match_dup 0))
18125    (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
18126    (parallel [(set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
18127               (clobber (mem:BLK (scratch)))])])
18129 ;; Convert esp subtractions to push.
18130 (define_peephole2
18131   [(match_scratch:DI 0 "r")
18132    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
18133               (clobber (reg:CC 17))])]
18134   "optimize_size || !TARGET_SUB_ESP_4"
18135   [(clobber (match_dup 0))
18136    (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))])
18138 (define_peephole2
18139   [(match_scratch:DI 0 "r")
18140    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
18141               (clobber (reg:CC 17))])]
18142   "optimize_size || !TARGET_SUB_ESP_8"
18143   [(clobber (match_dup 0))
18144    (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))
18145    (set (mem:DI (pre_dec:DI (reg:DI 7))) (match_dup 0))])
18147 ;; Convert epilogue deallocator to pop.
18148 (define_peephole2
18149   [(match_scratch:DI 0 "r")
18150    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
18151               (clobber (reg:CC 17))
18152               (clobber (mem:BLK (scratch)))])]
18153   "optimize_size || !TARGET_ADD_ESP_4"
18154   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18155               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
18156               (clobber (mem:BLK (scratch)))])]
18157   "")
18159 ;; Two pops case is tricky, since pop causes dependency on destination register.
18160 ;; We use two registers if available.
18161 (define_peephole2
18162   [(match_scratch:DI 0 "r")
18163    (match_scratch:DI 1 "r")
18164    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
18165               (clobber (reg:CC 17))
18166               (clobber (mem:BLK (scratch)))])]
18167   "optimize_size || !TARGET_ADD_ESP_8"
18168   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18169               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
18170               (clobber (mem:BLK (scratch)))])
18171    (parallel [(set (match_dup 1) (mem:DI (reg:DI 7)))
18172               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
18173   "")
18175 (define_peephole2
18176   [(match_scratch:DI 0 "r")
18177    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
18178               (clobber (reg:CC 17))
18179               (clobber (mem:BLK (scratch)))])]
18180   "optimize_size"
18181   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18182               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
18183               (clobber (mem:BLK (scratch)))])
18184    (parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18185               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
18186   "")
18188 ;; Convert esp additions to pop.
18189 (define_peephole2
18190   [(match_scratch:DI 0 "r")
18191    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))
18192               (clobber (reg:CC 17))])]
18193   ""
18194   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18195               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
18196   "")
18198 ;; Two pops case is tricky, since pop causes dependency on destination register.
18199 ;; We use two registers if available.
18200 (define_peephole2
18201   [(match_scratch:DI 0 "r")
18202    (match_scratch:DI 1 "r")
18203    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
18204               (clobber (reg:CC 17))])]
18205   ""
18206   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18207               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])
18208    (parallel [(set (match_dup 1) (mem:DI (reg:DI 7)))
18209               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
18210   "")
18212 (define_peephole2
18213   [(match_scratch:DI 0 "r")
18214    (parallel [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 16)))
18215               (clobber (reg:CC 17))])]
18216   "optimize_size"
18217   [(parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18218               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])
18219    (parallel [(set (match_dup 0) (mem:DI (reg:DI 7)))
18220               (set (reg:DI 7) (plus:DI (reg:DI 7) (const_int 8)))])]
18221   "")
18223 ;; Imul $32bit_imm, mem, reg is vector decoded, while
18224 ;; imul $32bit_imm, reg, reg is direct decoded.
18225 (define_peephole2
18226   [(match_scratch:DI 3 "r")
18227    (parallel [(set (match_operand:DI 0 "register_operand" "")
18228                    (mult:DI (match_operand:DI 1 "memory_operand" "")
18229                             (match_operand:DI 2 "immediate_operand" "")))
18230               (clobber (reg:CC 17))])]
18231   "TARGET_K8 && !optimize_size
18232    && (GET_CODE (operands[2]) != CONST_INT
18233        || !CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K'))"
18234   [(set (match_dup 3) (match_dup 1))
18235    (parallel [(set (match_dup 0) (mult:DI (match_dup 3) (match_dup 2)))
18236               (clobber (reg:CC 17))])]
18239 (define_peephole2
18240   [(match_scratch:SI 3 "r")
18241    (parallel [(set (match_operand:SI 0 "register_operand" "")
18242                    (mult:SI (match_operand:SI 1 "memory_operand" "")
18243                             (match_operand:SI 2 "immediate_operand" "")))
18244               (clobber (reg:CC 17))])]
18245   "TARGET_K8 && !optimize_size
18246    && (GET_CODE (operands[2]) != CONST_INT
18247        || !CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K'))"
18248   [(set (match_dup 3) (match_dup 1))
18249    (parallel [(set (match_dup 0) (mult:SI (match_dup 3) (match_dup 2)))
18250               (clobber (reg:CC 17))])]
18253 (define_peephole2
18254   [(match_scratch:SI 3 "r")
18255    (parallel [(set (match_operand:DI 0 "register_operand" "")
18256                    (zero_extend:DI
18257                      (mult:SI (match_operand:SI 1 "memory_operand" "")
18258                               (match_operand:SI 2 "immediate_operand" ""))))
18259               (clobber (reg:CC 17))])]
18260   "TARGET_K8 && !optimize_size
18261    && (GET_CODE (operands[2]) != CONST_INT
18262        || !CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K'))"
18263   [(set (match_dup 3) (match_dup 1))
18264    (parallel [(set (match_dup 0) (zero_extend:DI (mult:SI (match_dup 3) (match_dup 2))))
18265               (clobber (reg:CC 17))])]
18268 ;; imul $8/16bit_imm, regmem, reg is vector decoded.
18269 ;; Convert it into imul reg, reg
18270 ;; It would be better to force assembler to encode instruction using long
18271 ;; immediate, but there is apparently no way to do so.
18272 (define_peephole2
18273   [(parallel [(set (match_operand:DI 0 "register_operand" "")
18274                    (mult:DI (match_operand:DI 1 "nonimmediate_operand" "")
18275                             (match_operand:DI 2 "const_int_operand" "")))
18276               (clobber (reg:CC 17))])
18277    (match_scratch:DI 3 "r")]
18278   "TARGET_K8 && !optimize_size
18279    && CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')"
18280   [(set (match_dup 3) (match_dup 2))
18281    (parallel [(set (match_dup 0) (mult:DI (match_dup 0) (match_dup 3)))
18282               (clobber (reg:CC 17))])]
18284   if (!rtx_equal_p (operands[0], operands[1]))
18285     emit_move_insn (operands[0], operands[1]);
18288 (define_peephole2
18289   [(parallel [(set (match_operand:SI 0 "register_operand" "")
18290                    (mult:SI (match_operand:SI 1 "nonimmediate_operand" "")
18291                             (match_operand:SI 2 "const_int_operand" "")))
18292               (clobber (reg:CC 17))])
18293    (match_scratch:SI 3 "r")]
18294   "TARGET_K8 && !optimize_size
18295    && CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')"
18296   [(set (match_dup 3) (match_dup 2))
18297    (parallel [(set (match_dup 0) (mult:SI (match_dup 0) (match_dup 3)))
18298               (clobber (reg:CC 17))])]
18300   if (!rtx_equal_p (operands[0], operands[1]))
18301     emit_move_insn (operands[0], operands[1]);
18304 (define_peephole2
18305   [(parallel [(set (match_operand:HI 0 "register_operand" "")
18306                    (mult:HI (match_operand:HI 1 "nonimmediate_operand" "")
18307                             (match_operand:HI 2 "immediate_operand" "")))
18308               (clobber (reg:CC 17))])
18309    (match_scratch:HI 3 "r")]
18310   "TARGET_K8 && !optimize_size"
18311   [(set (match_dup 3) (match_dup 2))
18312    (parallel [(set (match_dup 0) (mult:HI (match_dup 0) (match_dup 3)))
18313               (clobber (reg:CC 17))])]
18315   if (!rtx_equal_p (operands[0], operands[1]))
18316     emit_move_insn (operands[0], operands[1]);
18319 ;; Call-value patterns last so that the wildcard operand does not
18320 ;; disrupt insn-recog's switch tables.
18322 (define_insn "*call_value_pop_0"
18323   [(set (match_operand 0 "" "")
18324         (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
18325               (match_operand:SI 2 "" "")))
18326    (set (reg:SI 7) (plus:SI (reg:SI 7)
18327                             (match_operand:SI 3 "immediate_operand" "")))]
18328   "!TARGET_64BIT"
18330   if (SIBLING_CALL_P (insn))
18331     return "jmp\t%P1";
18332   else
18333     return "call\t%P1";
18335   [(set_attr "type" "callv")])
18337 (define_insn "*call_value_pop_1"
18338   [(set (match_operand 0 "" "")
18339         (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
18340               (match_operand:SI 2 "" "")))
18341    (set (reg:SI 7) (plus:SI (reg:SI 7)
18342                             (match_operand:SI 3 "immediate_operand" "i")))]
18343   "!TARGET_64BIT"
18345   if (constant_call_address_operand (operands[1], QImode))
18346     {
18347       if (SIBLING_CALL_P (insn))
18348         return "jmp\t%P1";
18349       else
18350         return "call\t%P1";
18351     }
18352   if (SIBLING_CALL_P (insn))
18353     return "jmp\t%A1";
18354   else
18355     return "call\t%A1";
18357   [(set_attr "type" "callv")])
18359 (define_insn "*call_value_0"
18360   [(set (match_operand 0 "" "")
18361         (call (mem:QI (match_operand:SI 1 "constant_call_address_operand" ""))
18362               (match_operand:SI 2 "" "")))]
18363   "!TARGET_64BIT"
18365   if (SIBLING_CALL_P (insn))
18366     return "jmp\t%P1";
18367   else
18368     return "call\t%P1";
18370   [(set_attr "type" "callv")])
18372 (define_insn "*call_value_0_rex64"
18373   [(set (match_operand 0 "" "")
18374         (call (mem:QI (match_operand:DI 1 "constant_call_address_operand" ""))
18375               (match_operand:DI 2 "const_int_operand" "")))]
18376   "TARGET_64BIT"
18378   if (SIBLING_CALL_P (insn))
18379     return "jmp\t%P1";
18380   else
18381     return "call\t%P1";
18383   [(set_attr "type" "callv")])
18385 (define_insn "*call_value_1"
18386   [(set (match_operand 0 "" "")
18387         (call (mem:QI (match_operand:SI 1 "call_insn_operand" "rsm"))
18388               (match_operand:SI 2 "" "")))]
18389   "!SIBLING_CALL_P (insn) && !TARGET_64BIT"
18391   if (constant_call_address_operand (operands[1], QImode))
18392     return "call\t%P1";
18393   return "call\t%*%1";
18395   [(set_attr "type" "callv")])
18397 (define_insn "*sibcall_value_1"
18398   [(set (match_operand 0 "" "")
18399         (call (mem:QI (match_operand:SI 1 "sibcall_insn_operand" "s,c,d,a"))
18400               (match_operand:SI 2 "" "")))]
18401   "SIBLING_CALL_P (insn) && !TARGET_64BIT"
18403   if (constant_call_address_operand (operands[1], QImode))
18404     return "jmp\t%P1";
18405   return "jmp\t%*%1";
18407   [(set_attr "type" "callv")])
18409 (define_insn "*call_value_1_rex64"
18410   [(set (match_operand 0 "" "")
18411         (call (mem:QI (match_operand:DI 1 "call_insn_operand" "rsm"))
18412               (match_operand:DI 2 "" "")))]
18413   "!SIBLING_CALL_P (insn) && TARGET_64BIT"
18415   if (constant_call_address_operand (operands[1], QImode))
18416     return "call\t%P1";
18417   return "call\t%A1";
18419   [(set_attr "type" "callv")])
18421 (define_insn "*sibcall_value_1_rex64"
18422   [(set (match_operand 0 "" "")
18423         (call (mem:QI (match_operand:DI 1 "constant_call_address_operand" ""))
18424               (match_operand:DI 2 "" "")))]
18425   "SIBLING_CALL_P (insn) && TARGET_64BIT"
18426   "jmp\t%P1"
18427   [(set_attr "type" "callv")])
18429 (define_insn "*sibcall_value_1_rex64_v"
18430   [(set (match_operand 0 "" "")
18431         (call (mem:QI (reg:DI 40))
18432               (match_operand:DI 1 "" "")))]
18433   "SIBLING_CALL_P (insn) && TARGET_64BIT"
18434   "jmp\t*%%r11"
18435   [(set_attr "type" "callv")])
18437 (define_insn "trap"
18438   [(trap_if (const_int 1) (const_int 5))]
18439   ""
18440   "int\t$5")
18442 ;;; ix86 doesn't have conditional trap instructions, but we fake them
18443 ;;; for the sake of bounds checking.  By emitting bounds checks as
18444 ;;; conditional traps rather than as conditional jumps around
18445 ;;; unconditional traps we avoid introducing spurious basic-block
18446 ;;; boundaries and facilitate elimination of redundant checks.  In
18447 ;;; honor of the too-inflexible-for-BPs `bound' instruction, we use
18448 ;;; interrupt 5.
18449 ;;; 
18450 ;;; FIXME: Static branch prediction rules for ix86 are such that
18451 ;;; forward conditional branches predict as untaken.  As implemented
18452 ;;; below, pseudo conditional traps violate that rule.  We should use
18453 ;;; .pushsection/.popsection to place all of the `int 5's in a special
18454 ;;; section loaded at the end of the text segment and branch forward
18455 ;;; there on bounds-failure, and then jump back immediately (in case
18456 ;;; the system chooses to ignore bounds violations, or to report
18457 ;;; violations and continue execution).
18459 (define_expand "conditional_trap"
18460   [(trap_if (match_operator 0 "comparison_operator"
18461              [(match_dup 2) (const_int 0)])
18462             (match_operand 1 "const_int_operand" ""))]
18463   ""
18465   emit_insn (gen_rtx_TRAP_IF (VOIDmode,
18466                               ix86_expand_compare (GET_CODE (operands[0]),
18467                                                    NULL, NULL),
18468                               operands[1]));
18469   DONE;
18472 (define_insn "*conditional_trap_1"
18473   [(trap_if (match_operator 0 "comparison_operator"
18474              [(reg 17) (const_int 0)])
18475             (match_operand 1 "const_int_operand" ""))]
18476   ""
18478   operands[2] = gen_label_rtx ();
18479   output_asm_insn ("j%c0\t%l2\; int\t%1", operands);
18480   (*targetm.asm_out.internal_label) (asm_out_file, "L",
18481                              CODE_LABEL_NUMBER (operands[2]));
18482   RET;
18485         ;; Pentium III SIMD instructions.
18487 ;; Moves for SSE/MMX regs.
18489 (define_insn "movv4sf_internal"
18490   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
18491         (match_operand:V4SF 1 "nonimmediate_operand" "xm,x"))]
18492   "TARGET_SSE"
18493   "movaps\t{%1, %0|%0, %1}"
18494   [(set_attr "type" "ssemov")
18495    (set_attr "mode" "V4SF")])
18497 (define_split
18498   [(set (match_operand:V4SF 0 "register_operand" "")
18499         (match_operand:V4SF 1 "zero_extended_scalar_load_operand" ""))]
18500   "TARGET_SSE"
18501   [(set (match_dup 0)
18502         (vec_merge:V4SF
18503          (vec_duplicate:V4SF (match_dup 1))
18504          (match_dup 2)
18505          (const_int 1)))]
18507   operands[1] = simplify_gen_subreg (SFmode, operands[1], V4SFmode, 0);
18508   operands[2] = CONST0_RTX (V4SFmode);
18511 (define_insn "movv4si_internal"
18512   [(set (match_operand:V4SI 0 "nonimmediate_operand" "=x,m")
18513         (match_operand:V4SI 1 "nonimmediate_operand" "xm,x"))]
18514   "TARGET_SSE"
18516   if (get_attr_mode (insn) == MODE_V4SF)
18517     return "movaps\t{%1, %0|%0, %1}";
18518   else
18519     return "movdqa\t{%1, %0|%0, %1}";
18521   [(set_attr "type" "ssemov")
18522    (set (attr "mode")
18523         (cond [(eq_attr "alternative" "0")
18524                  (if_then_else
18525                    (ne (symbol_ref "optimize_size")
18526                        (const_int 0))
18527                    (const_string "V4SF")
18528                    (const_string "TI"))
18529                (eq_attr "alternative" "1")
18530                  (if_then_else
18531                    (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
18532                             (const_int 0))
18533                         (ne (symbol_ref "optimize_size")
18534                             (const_int 0)))
18535                    (const_string "V4SF")
18536                    (const_string "TI"))]
18537                (const_string "TI")))])
18539 (define_insn "movv2di_internal"
18540   [(set (match_operand:V2DI 0 "nonimmediate_operand" "=x,m")
18541         (match_operand:V2DI 1 "nonimmediate_operand" "xm,x"))]
18542   "TARGET_SSE2"
18544   if (get_attr_mode (insn) == MODE_V4SF)
18545     return "movaps\t{%1, %0|%0, %1}";
18546   else
18547     return "movdqa\t{%1, %0|%0, %1}";
18549   [(set_attr "type" "ssemov")
18550    (set (attr "mode")
18551         (cond [(eq_attr "alternative" "0")
18552                  (if_then_else
18553                    (ne (symbol_ref "optimize_size")
18554                        (const_int 0))
18555                    (const_string "V4SF")
18556                    (const_string "TI"))
18557                (eq_attr "alternative" "1")
18558                  (if_then_else
18559                    (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
18560                             (const_int 0))
18561                         (ne (symbol_ref "optimize_size")
18562                             (const_int 0)))
18563                    (const_string "V4SF")
18564                    (const_string "TI"))]
18565                (const_string "TI")))])
18567 (define_split
18568   [(set (match_operand:V2DF 0 "register_operand" "")
18569         (match_operand:V2DF 1 "zero_extended_scalar_load_operand" ""))]
18570   "TARGET_SSE2"
18571   [(set (match_dup 0)
18572         (vec_merge:V2DF
18573          (vec_duplicate:V2DF (match_dup 1))
18574          (match_dup 2)
18575          (const_int 1)))]
18577   operands[1] = simplify_gen_subreg (DFmode, operands[1], V2DFmode, 0);
18578   operands[2] = CONST0_RTX (V2DFmode);
18581 (define_insn "movv8qi_internal"
18582   [(set (match_operand:V8QI 0 "nonimmediate_operand" "=y,m")
18583         (match_operand:V8QI 1 "nonimmediate_operand" "ym,y"))]
18584   "TARGET_MMX
18585    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
18586   "movq\t{%1, %0|%0, %1}"
18587   [(set_attr "type" "mmxmov")
18588    (set_attr "mode" "DI")])
18590 (define_insn "movv4hi_internal"
18591   [(set (match_operand:V4HI 0 "nonimmediate_operand" "=y,m")
18592         (match_operand:V4HI 1 "nonimmediate_operand" "ym,y"))]
18593   "TARGET_MMX
18594    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
18595   "movq\t{%1, %0|%0, %1}"
18596   [(set_attr "type" "mmxmov")
18597    (set_attr "mode" "DI")])
18599 (define_insn "movv2si_internal"
18600   [(set (match_operand:V2SI 0 "nonimmediate_operand" "=y,m")
18601         (match_operand:V2SI 1 "nonimmediate_operand" "ym,y"))]
18602   "TARGET_MMX
18603    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
18604   "movq\t{%1, %0|%0, %1}"
18605   [(set_attr "type" "mmxcvt")
18606    (set_attr "mode" "DI")])
18608 (define_insn "movv2sf_internal"
18609   [(set (match_operand:V2SF 0 "nonimmediate_operand" "=y,m")
18610         (match_operand:V2SF 1 "nonimmediate_operand" "ym,y"))]
18611   "TARGET_3DNOW
18612    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
18613   "movq\\t{%1, %0|%0, %1}"
18614   [(set_attr "type" "mmxcvt")
18615    (set_attr "mode" "DI")])
18617 (define_expand "movti"
18618   [(set (match_operand:TI 0 "nonimmediate_operand" "")
18619         (match_operand:TI 1 "nonimmediate_operand" ""))]
18620   "TARGET_SSE || TARGET_64BIT"
18622   if (TARGET_64BIT)
18623     ix86_expand_move (TImode, operands);
18624   else
18625     ix86_expand_vector_move (TImode, operands);
18626   DONE;
18629 (define_insn "movv2df_internal"
18630   [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
18631         (match_operand:V2DF 1 "nonimmediate_operand" "xm,x"))]
18632   "TARGET_SSE2
18633    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
18635   if (get_attr_mode (insn) == MODE_V4SF)
18636     return "movaps\t{%1, %0|%0, %1}";
18637   else
18638     return "movapd\t{%1, %0|%0, %1}";
18640   [(set_attr "type" "ssemov")
18641    (set (attr "mode")
18642         (cond [(eq_attr "alternative" "0")
18643                  (if_then_else
18644                    (ne (symbol_ref "optimize_size")
18645                        (const_int 0))
18646                    (const_string "V4SF")
18647                    (const_string "V2DF"))
18648                (eq_attr "alternative" "1")
18649                  (if_then_else
18650                    (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
18651                             (const_int 0))
18652                         (ne (symbol_ref "optimize_size")
18653                             (const_int 0)))
18654                    (const_string "V4SF")
18655                    (const_string "V2DF"))]
18656                (const_string "V2DF")))])
18658 (define_insn "movv8hi_internal"
18659   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=x,m")
18660         (match_operand:V8HI 1 "nonimmediate_operand" "xm,x"))]
18661   "TARGET_SSE2
18662    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
18664   if (get_attr_mode (insn) == MODE_V4SF)
18665     return "movaps\t{%1, %0|%0, %1}";
18666   else
18667     return "movdqa\t{%1, %0|%0, %1}";
18669   [(set_attr "type" "ssemov")
18670    (set (attr "mode")
18671         (cond [(eq_attr "alternative" "0")
18672                  (if_then_else
18673                    (ne (symbol_ref "optimize_size")
18674                        (const_int 0))
18675                    (const_string "V4SF")
18676                    (const_string "TI"))
18677                (eq_attr "alternative" "1")
18678                  (if_then_else
18679                    (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
18680                             (const_int 0))
18681                         (ne (symbol_ref "optimize_size")
18682                             (const_int 0)))
18683                    (const_string "V4SF")
18684                    (const_string "TI"))]
18685                (const_string "TI")))])
18687 (define_insn "movv16qi_internal"
18688   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=x,m")
18689         (match_operand:V16QI 1 "nonimmediate_operand" "xm,x"))]
18690   "TARGET_SSE2
18691    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
18693   if (get_attr_mode (insn) == MODE_V4SF)
18694     return "movaps\t{%1, %0|%0, %1}";
18695   else
18696     return "movdqa\t{%1, %0|%0, %1}";
18698   [(set_attr "type" "ssemov")
18699    (set (attr "mode")
18700         (cond [(eq_attr "alternative" "0")
18701                  (if_then_else
18702                    (ne (symbol_ref "optimize_size")
18703                        (const_int 0))
18704                    (const_string "V4SF")
18705                    (const_string "TI"))
18706                (eq_attr "alternative" "1")
18707                  (if_then_else
18708                    (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
18709                             (const_int 0))
18710                         (ne (symbol_ref "optimize_size")
18711                             (const_int 0)))
18712                    (const_string "V4SF")
18713                    (const_string "TI"))]
18714                (const_string "TI")))])
18716 (define_expand "movv2df"
18717   [(set (match_operand:V2DF 0 "nonimmediate_operand" "")
18718         (match_operand:V2DF 1 "nonimmediate_operand" ""))]
18719   "TARGET_SSE2"
18721   ix86_expand_vector_move (V2DFmode, operands);
18722   DONE;
18725 (define_expand "movv8hi"
18726   [(set (match_operand:V8HI 0 "nonimmediate_operand" "")
18727         (match_operand:V8HI 1 "nonimmediate_operand" ""))]
18728   "TARGET_SSE2"
18730   ix86_expand_vector_move (V8HImode, operands);
18731   DONE;
18734 (define_expand "movv16qi"
18735   [(set (match_operand:V16QI 0 "nonimmediate_operand" "")
18736         (match_operand:V16QI 1 "nonimmediate_operand" ""))]
18737   "TARGET_SSE2"
18739   ix86_expand_vector_move (V16QImode, operands);
18740   DONE;
18743 (define_expand "movv4sf"
18744   [(set (match_operand:V4SF 0 "nonimmediate_operand" "")
18745         (match_operand:V4SF 1 "nonimmediate_operand" ""))]
18746   "TARGET_SSE"
18748   ix86_expand_vector_move (V4SFmode, operands);
18749   DONE;
18752 (define_expand "movv4si"
18753   [(set (match_operand:V4SI 0 "nonimmediate_operand" "")
18754         (match_operand:V4SI 1 "nonimmediate_operand" ""))]
18755   "TARGET_SSE"
18757   ix86_expand_vector_move (V4SImode, operands);
18758   DONE;
18761 (define_expand "movv2di"
18762   [(set (match_operand:V2DI 0 "nonimmediate_operand" "")
18763         (match_operand:V2DI 1 "nonimmediate_operand" ""))]
18764   "TARGET_SSE"
18766   ix86_expand_vector_move (V2DImode, operands);
18767   DONE;
18770 (define_expand "movv2si"
18771   [(set (match_operand:V2SI 0 "nonimmediate_operand" "")
18772         (match_operand:V2SI 1 "nonimmediate_operand" ""))]
18773   "TARGET_MMX"
18775   ix86_expand_vector_move (V2SImode, operands);
18776   DONE;
18779 (define_expand "movv4hi"
18780   [(set (match_operand:V4HI 0 "nonimmediate_operand" "")
18781         (match_operand:V4HI 1 "nonimmediate_operand" ""))]
18782   "TARGET_MMX"
18784   ix86_expand_vector_move (V4HImode, operands);
18785   DONE;
18788 (define_expand "movv8qi"
18789   [(set (match_operand:V8QI 0 "nonimmediate_operand" "")
18790         (match_operand:V8QI 1 "nonimmediate_operand" ""))]
18791   "TARGET_MMX"
18793   ix86_expand_vector_move (V8QImode, operands);
18794   DONE;
18797 (define_expand "movv2sf"
18798   [(set (match_operand:V2SF 0 "nonimmediate_operand" "")
18799         (match_operand:V2SF 1 "nonimmediate_operand" ""))]
18800    "TARGET_3DNOW"
18802   ix86_expand_vector_move (V2SFmode, operands);
18803   DONE;
18806 (define_insn "*pushti"
18807   [(set (match_operand:TI 0 "push_operand" "=<")
18808         (match_operand:TI 1 "register_operand" "x"))]
18809   "TARGET_SSE"
18810   "#")
18812 (define_insn "*pushv2df"
18813   [(set (match_operand:V2DF 0 "push_operand" "=<")
18814         (match_operand:V2DF 1 "register_operand" "x"))]
18815   "TARGET_SSE"
18816   "#")
18818 (define_insn "*pushv2di"
18819   [(set (match_operand:V2DI 0 "push_operand" "=<")
18820         (match_operand:V2DI 1 "register_operand" "x"))]
18821   "TARGET_SSE2"
18822   "#")
18824 (define_insn "*pushv8hi"
18825   [(set (match_operand:V8HI 0 "push_operand" "=<")
18826         (match_operand:V8HI 1 "register_operand" "x"))]
18827   "TARGET_SSE2"
18828   "#")
18830 (define_insn "*pushv16qi"
18831   [(set (match_operand:V16QI 0 "push_operand" "=<")
18832         (match_operand:V16QI 1 "register_operand" "x"))]
18833   "TARGET_SSE2"
18834   "#")
18836 (define_insn "*pushv4sf"
18837   [(set (match_operand:V4SF 0 "push_operand" "=<")
18838         (match_operand:V4SF 1 "register_operand" "x"))]
18839   "TARGET_SSE"
18840   "#")
18842 (define_insn "*pushv4si"
18843   [(set (match_operand:V4SI 0 "push_operand" "=<")
18844         (match_operand:V4SI 1 "register_operand" "x"))]
18845   "TARGET_SSE2"
18846   "#")
18848 (define_insn "*pushv2si"
18849   [(set (match_operand:V2SI 0 "push_operand" "=<")
18850         (match_operand:V2SI 1 "register_operand" "y"))]
18851   "TARGET_MMX"
18852   "#")
18854 (define_insn "*pushv4hi"
18855   [(set (match_operand:V4HI 0 "push_operand" "=<")
18856         (match_operand:V4HI 1 "register_operand" "y"))]
18857   "TARGET_MMX"
18858   "#")
18860 (define_insn "*pushv8qi"
18861   [(set (match_operand:V8QI 0 "push_operand" "=<")
18862         (match_operand:V8QI 1 "register_operand" "y"))]
18863   "TARGET_MMX"
18864   "#")
18866 (define_insn "*pushv2sf"
18867   [(set (match_operand:V2SF 0 "push_operand" "=<")
18868         (match_operand:V2SF 1 "register_operand" "y"))]
18869   "TARGET_3DNOW"
18870   "#")
18872 (define_split
18873   [(set (match_operand 0 "push_operand" "")
18874         (match_operand 1 "register_operand" ""))]
18875   "!TARGET_64BIT && reload_completed
18876    && (SSE_REG_P (operands[1]) || MMX_REG_P (operands[1]))"
18877   [(set (reg:SI 7) (plus:SI (reg:SI 7) (match_dup 3)))
18878    (set (match_dup 2) (match_dup 1))]
18879   "operands[2] = change_address (operands[0], GET_MODE (operands[0]),
18880                                  stack_pointer_rtx);
18881    operands[3] = GEN_INT (-GET_MODE_SIZE (GET_MODE (operands[0])));")
18883 (define_split
18884   [(set (match_operand 0 "push_operand" "")
18885         (match_operand 1 "register_operand" ""))]
18886   "TARGET_64BIT && reload_completed
18887    && (SSE_REG_P (operands[1]) || MMX_REG_P (operands[1]))"
18888   [(set (reg:DI 7) (plus:DI (reg:DI 7) (match_dup 3)))
18889    (set (match_dup 2) (match_dup 1))]
18890   "operands[2] = change_address (operands[0], GET_MODE (operands[0]),
18891                                  stack_pointer_rtx);
18892    operands[3] = GEN_INT (-GET_MODE_SIZE (GET_MODE (operands[0])));")
18895 (define_insn "movti_internal"
18896   [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
18897         (match_operand:TI 1 "general_operand" "C,xm,x"))]
18898   "TARGET_SSE && !TARGET_64BIT
18899    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
18901   switch (which_alternative)
18902     {
18903     case 0:
18904       if (get_attr_mode (insn) == MODE_V4SF)
18905         return "xorps\t%0, %0";
18906       else
18907         return "pxor\t%0, %0";
18908     case 1:
18909     case 2:
18910       if (get_attr_mode (insn) == MODE_V4SF)
18911         return "movaps\t{%1, %0|%0, %1}";
18912       else
18913         return "movdqa\t{%1, %0|%0, %1}";
18914     default:
18915       abort ();
18916     }
18918   [(set_attr "type" "ssemov,ssemov,ssemov")
18919    (set (attr "mode")
18920         (cond [(eq_attr "alternative" "0,1")
18921                  (if_then_else
18922                    (ne (symbol_ref "optimize_size")
18923                        (const_int 0))
18924                    (const_string "V4SF")
18925                    (const_string "TI"))
18926                (eq_attr "alternative" "2")
18927                  (if_then_else
18928                    (ne (symbol_ref "optimize_size")
18929                        (const_int 0))
18930                    (const_string "V4SF")
18931                    (const_string "TI"))]
18932                (const_string "TI")))])
18934 (define_insn "*movti_rex64"
18935   [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o,x,x,xm")
18936         (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
18937   "TARGET_64BIT
18938    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
18940   switch (which_alternative)
18941     {
18942     case 0:
18943     case 1:
18944       return "#";
18945     case 2:
18946       if (get_attr_mode (insn) == MODE_V4SF)
18947         return "xorps\t%0, %0";
18948       else
18949         return "pxor\t%0, %0";
18950     case 3:
18951     case 4:
18952       if (get_attr_mode (insn) == MODE_V4SF)
18953         return "movaps\t{%1, %0|%0, %1}";
18954       else
18955         return "movdqa\t{%1, %0|%0, %1}";
18956     default:
18957       abort ();
18958     }
18960   [(set_attr "type" "*,*,ssemov,ssemov,ssemov")
18961    (set (attr "mode")
18962         (cond [(eq_attr "alternative" "2,3")
18963                  (if_then_else
18964                    (ne (symbol_ref "optimize_size")
18965                        (const_int 0))
18966                    (const_string "V4SF")
18967                    (const_string "TI"))
18968                (eq_attr "alternative" "4")
18969                  (if_then_else
18970                    (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
18971                             (const_int 0))
18972                         (ne (symbol_ref "optimize_size")
18973                             (const_int 0)))
18974                    (const_string "V4SF")
18975                    (const_string "TI"))]
18976                (const_string "DI")))])
18978 (define_split
18979   [(set (match_operand:TI 0 "nonimmediate_operand" "")
18980         (match_operand:TI 1 "general_operand" ""))]
18981   "reload_completed && !SSE_REG_P (operands[0])
18982    && !SSE_REG_P (operands[1])"
18983   [(const_int 0)]
18984   "ix86_split_long_move (operands); DONE;")
18986 ;; These two patterns are useful for specifying exactly whether to use
18987 ;; movaps or movups
18988 (define_insn "sse_movaps"
18989   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
18990         (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,x")]
18991                      UNSPEC_MOVA))]
18992   "TARGET_SSE
18993    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
18994   "movaps\t{%1, %0|%0, %1}"
18995   [(set_attr "type" "ssemov,ssemov")
18996    (set_attr "mode" "V4SF")])
18998 (define_insn "sse_movups"
18999   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
19000         (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm,x")]
19001                      UNSPEC_MOVU))]
19002   "TARGET_SSE
19003    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
19004   "movups\t{%1, %0|%0, %1}"
19005   [(set_attr "type" "ssecvt,ssecvt")
19006    (set_attr "mode" "V4SF")])
19009 ;; SSE Strange Moves.
19011 (define_insn "sse_movmskps"
19012   [(set (match_operand:SI 0 "register_operand" "=r")
19013         (unspec:SI [(match_operand:V4SF 1 "register_operand" "x")]
19014                    UNSPEC_MOVMSK))]
19015   "TARGET_SSE"
19016   "movmskps\t{%1, %0|%0, %1}"
19017   [(set_attr "type" "ssecvt")
19018    (set_attr "mode" "V4SF")])
19020 (define_insn "mmx_pmovmskb"
19021   [(set (match_operand:SI 0 "register_operand" "=r")
19022         (unspec:SI [(match_operand:V8QI 1 "register_operand" "y")]
19023                    UNSPEC_MOVMSK))]
19024   "TARGET_SSE || TARGET_3DNOW_A"
19025   "pmovmskb\t{%1, %0|%0, %1}"
19026   [(set_attr "type" "ssecvt")
19027    (set_attr "mode" "V4SF")])
19030 (define_insn "mmx_maskmovq"
19031   [(set (mem:V8QI (match_operand:SI 0 "register_operand" "D"))
19032         (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "y")
19033                       (match_operand:V8QI 2 "register_operand" "y")]
19034                      UNSPEC_MASKMOV))]
19035   "(TARGET_SSE || TARGET_3DNOW_A) && !TARGET_64BIT"
19036   ;; @@@ check ordering of operands in intel/nonintel syntax
19037   "maskmovq\t{%2, %1|%1, %2}"
19038   [(set_attr "type" "mmxcvt")
19039    (set_attr "mode" "DI")])
19041 (define_insn "mmx_maskmovq_rex"
19042   [(set (mem:V8QI (match_operand:DI 0 "register_operand" "D"))
19043         (unspec:V8QI [(match_operand:V8QI 1 "register_operand" "y")
19044                       (match_operand:V8QI 2 "register_operand" "y")]
19045                      UNSPEC_MASKMOV))]
19046   "(TARGET_SSE || TARGET_3DNOW_A) && TARGET_64BIT"
19047   ;; @@@ check ordering of operands in intel/nonintel syntax
19048   "maskmovq\t{%2, %1|%1, %2}"
19049   [(set_attr "type" "mmxcvt")
19050    (set_attr "mode" "DI")])
19052 (define_insn "sse_movntv4sf"
19053   [(set (match_operand:V4SF 0 "memory_operand" "=m")
19054         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "x")]
19055                      UNSPEC_MOVNT))]
19056   "TARGET_SSE"
19057   "movntps\t{%1, %0|%0, %1}"
19058   [(set_attr "type" "ssemov")
19059    (set_attr "mode" "V4SF")])
19061 (define_insn "sse_movntdi"
19062   [(set (match_operand:DI 0 "memory_operand" "=m")
19063         (unspec:DI [(match_operand:DI 1 "register_operand" "y")]
19064                    UNSPEC_MOVNT))]
19065   "TARGET_SSE || TARGET_3DNOW_A"
19066   "movntq\t{%1, %0|%0, %1}"
19067   [(set_attr "type" "mmxmov")
19068    (set_attr "mode" "DI")])
19070 (define_insn "sse_movhlps"
19071   [(set (match_operand:V4SF 0 "register_operand" "=x")
19072         (vec_merge:V4SF
19073          (match_operand:V4SF 1 "register_operand" "0")
19074          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
19075                           (parallel [(const_int 2)
19076                                      (const_int 3)
19077                                      (const_int 0)
19078                                      (const_int 1)]))
19079          (const_int 3)))]
19080   "TARGET_SSE"
19081   "movhlps\t{%2, %0|%0, %2}"
19082   [(set_attr "type" "ssecvt")
19083    (set_attr "mode" "V4SF")])
19085 (define_insn "sse_movlhps"
19086   [(set (match_operand:V4SF 0 "register_operand" "=x")
19087         (vec_merge:V4SF
19088          (match_operand:V4SF 1 "register_operand" "0")
19089          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
19090                           (parallel [(const_int 2)
19091                                      (const_int 3)
19092                                      (const_int 0)
19093                                      (const_int 1)]))
19094          (const_int 12)))]
19095   "TARGET_SSE"
19096   "movlhps\t{%2, %0|%0, %2}"
19097   [(set_attr "type" "ssecvt")
19098    (set_attr "mode" "V4SF")])
19100 (define_insn "sse_movhps"
19101   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
19102         (vec_merge:V4SF
19103          (match_operand:V4SF 1 "nonimmediate_operand" "0,0")
19104          (match_operand:V4SF 2 "nonimmediate_operand" "m,x")
19105          (const_int 12)))]
19106   "TARGET_SSE
19107    && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
19108   "movhps\t{%2, %0|%0, %2}"
19109   [(set_attr "type" "ssecvt")
19110    (set_attr "mode" "V4SF")])
19112 (define_insn "sse_movlps"
19113   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=x,m")
19114         (vec_merge:V4SF
19115          (match_operand:V4SF 1 "nonimmediate_operand" "0,0")
19116          (match_operand:V4SF 2 "nonimmediate_operand" "m,x")
19117          (const_int 3)))]
19118   "TARGET_SSE
19119    && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
19120   "movlps\t{%2, %0|%0, %2}"
19121   [(set_attr "type" "ssecvt")
19122    (set_attr "mode" "V4SF")])
19124 (define_expand "sse_loadss"
19125   [(match_operand:V4SF 0 "register_operand" "")
19126    (match_operand:SF 1 "memory_operand" "")]
19127   "TARGET_SSE"
19129   emit_insn (gen_sse_loadss_1 (operands[0], operands[1],
19130                                CONST0_RTX (V4SFmode)));
19131   DONE;
19134 (define_insn "sse_loadss_1"
19135   [(set (match_operand:V4SF 0 "register_operand" "=x")
19136         (vec_merge:V4SF
19137          (vec_duplicate:V4SF (match_operand:SF 1 "memory_operand" "m"))
19138          (match_operand:V4SF 2 "const0_operand" "X")
19139          (const_int 1)))]
19140   "TARGET_SSE"
19141   "movss\t{%1, %0|%0, %1}"
19142   [(set_attr "type" "ssemov")
19143    (set_attr "mode" "SF")])
19145 (define_insn "sse_movss"
19146   [(set (match_operand:V4SF 0 "register_operand" "=x")
19147         (vec_merge:V4SF
19148          (match_operand:V4SF 1 "register_operand" "0")
19149          (match_operand:V4SF 2 "register_operand" "x")
19150          (const_int 1)))]
19151   "TARGET_SSE"
19152   "movss\t{%2, %0|%0, %2}"
19153   [(set_attr "type" "ssemov")
19154    (set_attr "mode" "SF")])
19156 (define_insn "sse_storess"
19157   [(set (match_operand:SF 0 "memory_operand" "=m")
19158         (vec_select:SF
19159          (match_operand:V4SF 1 "register_operand" "x")
19160          (parallel [(const_int 0)])))]
19161   "TARGET_SSE"
19162   "movss\t{%1, %0|%0, %1}"
19163   [(set_attr "type" "ssemov")
19164    (set_attr "mode" "SF")])
19166 (define_insn "sse_shufps"
19167   [(set (match_operand:V4SF 0 "register_operand" "=x")
19168         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "0")
19169                       (match_operand:V4SF 2 "nonimmediate_operand" "xm")
19170                       (match_operand:SI 3 "immediate_operand" "i")]
19171                      UNSPEC_SHUFFLE))]
19172   "TARGET_SSE"
19173   ;; @@@ check operand order for intel/nonintel syntax
19174   "shufps\t{%3, %2, %0|%0, %2, %3}"
19175   [(set_attr "type" "ssecvt")
19176    (set_attr "mode" "V4SF")])
19179 ;; SSE arithmetic
19181 (define_insn "addv4sf3"
19182   [(set (match_operand:V4SF 0 "register_operand" "=x")
19183         (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
19184                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
19185   "TARGET_SSE"
19186   "addps\t{%2, %0|%0, %2}"
19187   [(set_attr "type" "sseadd")
19188    (set_attr "mode" "V4SF")])
19190 (define_insn "vmaddv4sf3"
19191   [(set (match_operand:V4SF 0 "register_operand" "=x")
19192         (vec_merge:V4SF
19193          (plus:V4SF (match_operand:V4SF 1 "register_operand" "0")
19194                     (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
19195          (match_dup 1)
19196          (const_int 1)))]
19197   "TARGET_SSE"
19198   "addss\t{%2, %0|%0, %2}"
19199   [(set_attr "type" "sseadd")
19200    (set_attr "mode" "SF")])
19202 (define_insn "subv4sf3"
19203   [(set (match_operand:V4SF 0 "register_operand" "=x")
19204         (minus:V4SF (match_operand:V4SF 1 "register_operand" "0")
19205                     (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
19206   "TARGET_SSE"
19207   "subps\t{%2, %0|%0, %2}"
19208   [(set_attr "type" "sseadd")
19209    (set_attr "mode" "V4SF")])
19211 (define_insn "vmsubv4sf3"
19212   [(set (match_operand:V4SF 0 "register_operand" "=x")
19213         (vec_merge:V4SF
19214          (minus:V4SF (match_operand:V4SF 1 "register_operand" "0")
19215                      (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
19216          (match_dup 1)
19217          (const_int 1)))]
19218   "TARGET_SSE"
19219   "subss\t{%2, %0|%0, %2}"
19220   [(set_attr "type" "sseadd")
19221    (set_attr "mode" "SF")])
19223 (define_insn "mulv4sf3"
19224   [(set (match_operand:V4SF 0 "register_operand" "=x")
19225         (mult:V4SF (match_operand:V4SF 1 "register_operand" "0")
19226                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
19227   "TARGET_SSE"
19228   "mulps\t{%2, %0|%0, %2}"
19229   [(set_attr "type" "ssemul")
19230    (set_attr "mode" "V4SF")])
19232 (define_insn "vmmulv4sf3"
19233   [(set (match_operand:V4SF 0 "register_operand" "=x")
19234         (vec_merge:V4SF
19235          (mult:V4SF (match_operand:V4SF 1 "register_operand" "0")
19236                     (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
19237          (match_dup 1)
19238          (const_int 1)))]
19239   "TARGET_SSE"
19240   "mulss\t{%2, %0|%0, %2}"
19241   [(set_attr "type" "ssemul")
19242    (set_attr "mode" "SF")])
19244 (define_insn "divv4sf3"
19245   [(set (match_operand:V4SF 0 "register_operand" "=x")
19246         (div:V4SF (match_operand:V4SF 1 "register_operand" "0")
19247                   (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
19248   "TARGET_SSE"
19249   "divps\t{%2, %0|%0, %2}"
19250   [(set_attr "type" "ssediv")
19251    (set_attr "mode" "V4SF")])
19253 (define_insn "vmdivv4sf3"
19254   [(set (match_operand:V4SF 0 "register_operand" "=x")
19255         (vec_merge:V4SF
19256          (div:V4SF (match_operand:V4SF 1 "register_operand" "0")
19257                    (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
19258          (match_dup 1)
19259          (const_int 1)))]
19260   "TARGET_SSE"
19261   "divss\t{%2, %0|%0, %2}"
19262   [(set_attr "type" "ssediv")
19263    (set_attr "mode" "SF")])
19266 ;; SSE square root/reciprocal
19268 (define_insn "rcpv4sf2"
19269   [(set (match_operand:V4SF 0 "register_operand" "=x")
19270         (unspec:V4SF
19271          [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] UNSPEC_RCP))]
19272   "TARGET_SSE"
19273   "rcpps\t{%1, %0|%0, %1}"
19274   [(set_attr "type" "sse")
19275    (set_attr "mode" "V4SF")])
19277 (define_insn "vmrcpv4sf2"
19278   [(set (match_operand:V4SF 0 "register_operand" "=x")
19279         (vec_merge:V4SF
19280          (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
19281                       UNSPEC_RCP)
19282          (match_operand:V4SF 2 "register_operand" "0")
19283          (const_int 1)))]
19284   "TARGET_SSE"
19285   "rcpss\t{%1, %0|%0, %1}"
19286   [(set_attr "type" "sse")
19287    (set_attr "mode" "SF")])
19289 (define_insn "rsqrtv4sf2"
19290   [(set (match_operand:V4SF 0 "register_operand" "=x")
19291         (unspec:V4SF
19292          [(match_operand:V4SF 1 "nonimmediate_operand" "xm")] UNSPEC_RSQRT))]
19293   "TARGET_SSE"
19294   "rsqrtps\t{%1, %0|%0, %1}"
19295   [(set_attr "type" "sse")
19296    (set_attr "mode" "V4SF")])
19298 (define_insn "vmrsqrtv4sf2"
19299   [(set (match_operand:V4SF 0 "register_operand" "=x")
19300         (vec_merge:V4SF
19301          (unspec:V4SF [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
19302                       UNSPEC_RSQRT)
19303          (match_operand:V4SF 2 "register_operand" "0")
19304          (const_int 1)))]
19305   "TARGET_SSE"
19306   "rsqrtss\t{%1, %0|%0, %1}"
19307   [(set_attr "type" "sse")
19308    (set_attr "mode" "SF")])
19310 (define_insn "sqrtv4sf2"
19311   [(set (match_operand:V4SF 0 "register_operand" "=x")
19312         (sqrt:V4SF (match_operand:V4SF 1 "nonimmediate_operand" "xm")))]
19313   "TARGET_SSE"
19314   "sqrtps\t{%1, %0|%0, %1}"
19315   [(set_attr "type" "sse")
19316    (set_attr "mode" "V4SF")])
19318 (define_insn "vmsqrtv4sf2"
19319   [(set (match_operand:V4SF 0 "register_operand" "=x")
19320         (vec_merge:V4SF
19321          (sqrt:V4SF (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
19322          (match_operand:V4SF 2 "register_operand" "0")
19323          (const_int 1)))]
19324   "TARGET_SSE"
19325   "sqrtss\t{%1, %0|%0, %1}"
19326   [(set_attr "type" "sse")
19327    (set_attr "mode" "SF")])
19329 ;; SSE logical operations.
19331 ;; SSE defines logical operations on floating point values.  This brings
19332 ;; interesting challenge to RTL representation where logicals are only valid
19333 ;; on integral types.  We deal with this by representing the floating point
19334 ;; logical as logical on arguments casted to TImode as this is what hardware
19335 ;; really does.  Unfortunately hardware requires the type information to be
19336 ;; present and thus we must avoid subregs from being simplified and eliminated
19337 ;; in later compilation phases.
19339 ;; We have following variants from each instruction:
19340 ;; sse_andsf3 - the operation taking V4SF vector operands
19341 ;;              and doing TImode cast on them
19342 ;; *sse_andsf3_memory - the operation taking one memory operand casted to
19343 ;;                      TImode, since backend insist on eliminating casts
19344 ;;                      on memory operands
19345 ;; sse_andti3_sf_1 - the operation taking SF scalar operands.
19346 ;;                   We can not accept memory operand here as instruction reads
19347 ;;                   whole scalar.  This is generated only post reload by GCC
19348 ;;                   scalar float operations that expands to logicals (fabs)
19349 ;; sse_andti3_sf_2 - the operation taking SF scalar input and TImode
19350 ;;                   memory operand.  Eventually combine can be able
19351 ;;                   to synthesize these using splitter.
19352 ;; sse2_anddf3, *sse2_anddf3_memory
19353 ;;              
19354 ;; 
19355 ;; These are not called andti3 etc. because we really really don't want
19356 ;; the compiler to widen DImode ands to TImode ands and then try to move
19357 ;; into DImode subregs of SSE registers, and them together, and move out
19358 ;; of DImode subregs again!
19359 ;; SSE1 single precision floating point logical operation
19360 (define_expand "sse_andv4sf3"
19361   [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "") 0)
19362         (and:TI (subreg:TI (match_operand:V4SF 1 "register_operand" "") 0)
19363                 (subreg:TI (match_operand:V4SF 2 "nonimmediate_operand" "") 0)))]
19364   "TARGET_SSE"
19365   "")
19367 (define_insn "*sse_andv4sf3"
19368   [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "=x") 0)
19369         (and:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19370                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19371   "TARGET_SSE
19372    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19373   "andps\t{%2, %0|%0, %2}"
19374   [(set_attr "type" "sselog")
19375    (set_attr "mode" "V4SF")])
19377 (define_insn "*sse_andsf3"
19378   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
19379         (and:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19380                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19381   "TARGET_SSE
19382    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19383   "andps\t{%2, %0|%0, %2}"
19384   [(set_attr "type" "sselog")
19385    (set_attr "mode" "V4SF")])
19387 (define_expand "sse_nandv4sf3"
19388   [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "") 0)
19389         (and:TI (not:TI (subreg:TI (match_operand:V4SF 1 "register_operand" "") 0))
19390                 (subreg:TI (match_operand:V4SF 2 "nonimmediate_operand" "") 0)))]
19391   "TARGET_SSE"
19392   "")
19394 (define_insn "*sse_nandv4sf3"
19395   [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "=x") 0)
19396         (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
19397                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19398   "TARGET_SSE"
19399   "andnps\t{%2, %0|%0, %2}"
19400   [(set_attr "type" "sselog")
19401    (set_attr "mode" "V4SF")])
19403 (define_insn "*sse_nandsf3"
19404   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
19405         (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
19406                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19407   "TARGET_SSE"
19408   "andnps\t{%2, %0|%0, %2}"
19409   [(set_attr "type" "sselog")
19410    (set_attr "mode" "V4SF")])
19412 (define_expand "sse_iorv4sf3"
19413   [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "") 0)
19414         (ior:TI (subreg:TI (match_operand:V4SF 1 "register_operand" "") 0)
19415                 (subreg:TI (match_operand:V4SF 2 "nonimmediate_operand" "") 0)))]
19416   "TARGET_SSE"
19417   "")
19419 (define_insn "*sse_iorv4sf3"
19420   [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "=x") 0)
19421         (ior:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19422                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19423   "TARGET_SSE
19424    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19425   "orps\t{%2, %0|%0, %2}"
19426   [(set_attr "type" "sselog")
19427    (set_attr "mode" "V4SF")])
19429 (define_insn "*sse_iorsf3"
19430   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
19431         (ior:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19432                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19433   "TARGET_SSE
19434    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19435   "orps\t{%2, %0|%0, %2}"
19436   [(set_attr "type" "sselog")
19437    (set_attr "mode" "V4SF")])
19439 (define_expand "sse_xorv4sf3"
19440   [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "") 0)
19441         (xor:TI (subreg:TI (match_operand:V4SF 1 "register_operand" "") 0)
19442                 (subreg:TI (match_operand:V4SF 2 "nonimmediate_operand" "") 0)))]
19443   "TARGET_SSE
19444    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19445   "")
19447 (define_insn "*sse_xorv4sf3"
19448   [(set (subreg:TI (match_operand:V4SF 0 "register_operand" "=x") 0)
19449         (xor:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19450                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19451   "TARGET_SSE
19452    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19453   "xorps\t{%2, %0|%0, %2}"
19454   [(set_attr "type" "sselog")
19455    (set_attr "mode" "V4SF")])
19457 (define_insn "*sse_xorsf3"
19458   [(set (subreg:TI (match_operand:SF 0 "register_operand" "=x") 0)
19459         (xor:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19460                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19461   "TARGET_SSE
19462    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19463   "xorps\t{%2, %0|%0, %2}"
19464   [(set_attr "type" "sselog")
19465    (set_attr "mode" "V4SF")])
19467 ;; SSE2 double precision floating point logical operation
19469 (define_expand "sse2_andv2df3"
19470   [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "") 0)
19471         (and:TI (subreg:TI (match_operand:V2DF 1 "register_operand" "") 0)
19472                 (subreg:TI (match_operand:V2DF 2 "nonimmediate_operand" "") 0)))]
19473   "TARGET_SSE2"
19474   "")
19476 (define_insn "*sse2_andv2df3"
19477   [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "=x") 0)
19478         (and:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19479                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19480   "TARGET_SSE2
19481    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19482   "andpd\t{%2, %0|%0, %2}"
19483   [(set_attr "type" "sselog")
19484    (set_attr "mode" "V2DF")])
19486 (define_insn "*sse2_andv2df3"
19487   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=x") 0)
19488         (and:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19489                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19490   "TARGET_SSE2
19491    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19492   "andpd\t{%2, %0|%0, %2}"
19493   [(set_attr "type" "sselog")
19494    (set_attr "mode" "V2DF")])
19496 (define_expand "sse2_nandv2df3"
19497   [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "") 0)
19498         (and:TI (not:TI (subreg:TI (match_operand:V2DF 1 "register_operand" "") 0))
19499                 (subreg:TI (match_operand:V2DF 2 "nonimmediate_operand" "") 0)))]
19500   "TARGET_SSE2"
19501   "")
19503 (define_insn "*sse2_nandv2df3"
19504   [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "=x") 0)
19505         (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
19506                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19507   "TARGET_SSE2"
19508   "andnpd\t{%2, %0|%0, %2}"
19509   [(set_attr "type" "sselog")
19510    (set_attr "mode" "V2DF")])
19512 (define_insn "*sse_nandti3_df"
19513   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=Y") 0)
19514         (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
19515                 (match_operand:TI 2 "nonimmediate_operand" "Ym")))]
19516   "TARGET_SSE2"
19517   "andnpd\t{%2, %0|%0, %2}"
19518   [(set_attr "type" "sselog")
19519    (set_attr "mode" "V2DF")])
19521 (define_expand "sse2_iorv2df3"
19522   [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "") 0)
19523         (ior:TI (subreg:TI (match_operand:V2DF 1 "register_operand" "") 0)
19524                 (subreg:TI (match_operand:V2DF 2 "nonimmediate_operand" "") 0)))]
19525   "TARGET_SSE2"
19526   "")
19528 (define_insn "*sse2_iorv2df3"
19529   [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "=x") 0)
19530         (ior:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19531                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19532   "TARGET_SSE2
19533    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19534   "orpd\t{%2, %0|%0, %2}"
19535   [(set_attr "type" "sselog")
19536    (set_attr "mode" "V2DF")])
19538 (define_insn "*sse2_iordf3"
19539   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=x") 0)
19540         (ior:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19541                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19542   "TARGET_SSE2
19543    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19544   "orpd\t{%2, %0|%0, %2}"
19545   [(set_attr "type" "sselog")
19546    (set_attr "mode" "V2DF")])
19548 (define_expand "sse2_xorv2df3"
19549   [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "") 0)
19550         (xor:TI (subreg:TI (match_operand:V2DF 1 "nonimmediate_operand" "") 0)
19551                 (subreg:TI (match_operand:V2DF 2 "nonimmediate_operand" "") 0)))]
19552   "TARGET_SSE2"
19553   "")
19555 (define_insn "*sse2_xorv2df3"
19556   [(set (subreg:TI (match_operand:V2DF 0 "register_operand" "=x") 0)
19557         (xor:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19558                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19559   "TARGET_SSE2
19560    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19561   "xorpd\t{%2, %0|%0, %2}"
19562   [(set_attr "type" "sselog")
19563    (set_attr "mode" "V2DF")])
19565 (define_insn "*sse2_xordf3"
19566   [(set (subreg:TI (match_operand:DF 0 "register_operand" "=x") 0)
19567         (xor:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19568                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19569   "TARGET_SSE2
19570    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19571   "xorpd\t{%2, %0|%0, %2}"
19572   [(set_attr "type" "sselog")
19573    (set_attr "mode" "V2DF")])
19575 ;; SSE2 integral logicals.  These patterns must always come after floating
19576 ;; point ones since we don't want compiler to use integer opcodes on floating
19577 ;; point SSE values to avoid matching of subregs in the match_operand.
19578 (define_insn "*sse2_andti3"
19579   [(set (match_operand:TI 0 "register_operand" "=x")
19580         (and:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19581                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19582   "TARGET_SSE2
19583    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19584   "pand\t{%2, %0|%0, %2}"
19585   [(set_attr "type" "sselog")
19586    (set_attr "mode" "TI")])
19588 (define_insn "sse2_andv2di3"
19589   [(set (match_operand:V2DI 0 "register_operand" "=x")
19590         (and:V2DI (match_operand:V2DI 1 "nonimmediate_operand" "%0")
19591                   (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
19592   "TARGET_SSE2
19593    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19594   "pand\t{%2, %0|%0, %2}"
19595   [(set_attr "type" "sselog")
19596    (set_attr "mode" "TI")])
19598 (define_insn "*sse2_nandti3"
19599   [(set (match_operand:TI 0 "register_operand" "=x")
19600         (and:TI (not:TI (match_operand:TI 1 "register_operand" "0"))
19601                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19602   "TARGET_SSE2"
19603   "pandn\t{%2, %0|%0, %2}"
19604   [(set_attr "type" "sselog")
19605    (set_attr "mode" "TI")])
19607 (define_insn "sse2_nandv2di3"
19608   [(set (match_operand:V2DI 0 "register_operand" "=x")
19609         (and:V2DI (not:V2DI (match_operand:V2DI 1 "nonimmediate_operand" "%0"))
19610                   (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
19611   "TARGET_SSE2
19612    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19613   "pandn\t{%2, %0|%0, %2}"
19614   [(set_attr "type" "sselog")
19615    (set_attr "mode" "TI")])
19617 (define_insn "*sse2_iorti3"
19618   [(set (match_operand:TI 0 "register_operand" "=x")
19619         (ior:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19620                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19621   "TARGET_SSE2
19622    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19623   "por\t{%2, %0|%0, %2}"
19624   [(set_attr "type" "sselog")
19625    (set_attr "mode" "TI")])
19627 (define_insn "sse2_iorv2di3"
19628   [(set (match_operand:V2DI 0 "register_operand" "=x")
19629         (ior:V2DI (match_operand:V2DI 1 "nonimmediate_operand" "%0")
19630                   (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
19631   "TARGET_SSE2
19632    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19633   "por\t{%2, %0|%0, %2}"
19634   [(set_attr "type" "sselog")
19635    (set_attr "mode" "TI")])
19637 (define_insn "*sse2_xorti3"
19638   [(set (match_operand:TI 0 "register_operand" "=x")
19639         (xor:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
19640                 (match_operand:TI 2 "nonimmediate_operand" "xm")))]
19641   "TARGET_SSE2
19642    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19643   "pxor\t{%2, %0|%0, %2}"
19644   [(set_attr "type" "sselog")
19645    (set_attr "mode" "TI")])
19647 (define_insn "sse2_xorv2di3"
19648   [(set (match_operand:V2DI 0 "register_operand" "=x")
19649         (xor:V2DI (match_operand:V2DI 1 "nonimmediate_operand" "%0")
19650                   (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
19651   "TARGET_SSE2
19652    && (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != MEM)"
19653   "pxor\t{%2, %0|%0, %2}"
19654   [(set_attr "type" "sselog")
19655    (set_attr "mode" "TI")])
19657 ;; Use xor, but don't show input operands so they aren't live before
19658 ;; this insn.
19659 (define_insn "sse_clrv4sf"
19660   [(set (match_operand:V4SF 0 "register_operand" "=x")
19661         (match_operand:V4SF 1 "const0_operand" "X"))]
19662   "TARGET_SSE"
19664   if (get_attr_mode (insn) == MODE_TI)
19665     return "pxor\t{%0, %0|%0, %0}";
19666   else
19667     return "xorps\t{%0, %0|%0, %0}";
19669   [(set_attr "type" "sselog")
19670    (set_attr "memory" "none")
19671    (set (attr "mode")
19672         (if_then_else
19673            (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
19674                          (const_int 0))
19675                      (ne (symbol_ref "TARGET_SSE2")
19676                          (const_int 0)))
19677                 (eq (symbol_ref "optimize_size")
19678                     (const_int 0)))
19679          (const_string "TI")
19680          (const_string "V4SF")))])
19682 ;; Use xor, but don't show input operands so they aren't live before
19683 ;; this insn.
19684 (define_insn "sse_clrv2df"
19685   [(set (match_operand:V2DF 0 "register_operand" "=x")
19686         (unspec:V2DF [(const_int 0)] UNSPEC_NOP))]
19687   "TARGET_SSE2"
19688   "xorpd\t{%0, %0|%0, %0}"
19689   [(set_attr "type" "sselog")
19690    (set_attr "memory" "none")
19691    (set_attr "mode" "V4SF")])
19693 ;; SSE mask-generating compares
19695 (define_insn "maskcmpv4sf3"
19696   [(set (match_operand:V4SI 0 "register_operand" "=x")
19697         (match_operator:V4SI 3 "sse_comparison_operator"
19698                 [(match_operand:V4SF 1 "register_operand" "0")
19699                  (match_operand:V4SF 2 "register_operand" "x")]))]
19700   "TARGET_SSE"
19701   "cmp%D3ps\t{%2, %0|%0, %2}"
19702   [(set_attr "type" "ssecmp")
19703    (set_attr "mode" "V4SF")])
19705 (define_insn "maskncmpv4sf3"
19706   [(set (match_operand:V4SI 0 "register_operand" "=x")
19707         (not:V4SI
19708          (match_operator:V4SI 3 "sse_comparison_operator"
19709                 [(match_operand:V4SF 1 "register_operand" "0")
19710                  (match_operand:V4SF 2 "register_operand" "x")])))]
19711   "TARGET_SSE"
19713   if (GET_CODE (operands[3]) == UNORDERED)
19714     return "cmpordps\t{%2, %0|%0, %2}";
19715   else
19716     return "cmpn%D3ps\t{%2, %0|%0, %2}";
19718   [(set_attr "type" "ssecmp")
19719    (set_attr "mode" "V4SF")])
19721 (define_insn "vmmaskcmpv4sf3"
19722   [(set (match_operand:V4SI 0 "register_operand" "=x")
19723         (vec_merge:V4SI
19724          (match_operator:V4SI 3 "sse_comparison_operator"
19725                 [(match_operand:V4SF 1 "register_operand" "0")
19726                  (match_operand:V4SF 2 "register_operand" "x")])
19727          (match_dup 1)
19728          (const_int 1)))]
19729   "TARGET_SSE"
19730   "cmp%D3ss\t{%2, %0|%0, %2}"
19731   [(set_attr "type" "ssecmp")
19732    (set_attr "mode" "SF")])
19734 (define_insn "vmmaskncmpv4sf3"
19735   [(set (match_operand:V4SI 0 "register_operand" "=x")
19736         (vec_merge:V4SI
19737          (not:V4SI
19738           (match_operator:V4SI 3 "sse_comparison_operator"
19739                 [(match_operand:V4SF 1 "register_operand" "0")
19740                  (match_operand:V4SF 2 "register_operand" "x")]))
19741          (subreg:V4SI (match_dup 1) 0)
19742          (const_int 1)))]
19743   "TARGET_SSE"
19745   if (GET_CODE (operands[3]) == UNORDERED)
19746     return "cmpordss\t{%2, %0|%0, %2}";
19747   else
19748     return "cmpn%D3ss\t{%2, %0|%0, %2}";
19750   [(set_attr "type" "ssecmp")
19751    (set_attr "mode" "SF")])
19753 (define_insn "sse_comi"
19754   [(set (reg:CCFP 17)
19755         (compare:CCFP (vec_select:SF
19756                        (match_operand:V4SF 0 "register_operand" "x")
19757                        (parallel [(const_int 0)]))
19758                       (vec_select:SF
19759                        (match_operand:V4SF 1 "register_operand" "x")
19760                        (parallel [(const_int 0)]))))]
19761   "TARGET_SSE"
19762   "comiss\t{%1, %0|%0, %1}"
19763   [(set_attr "type" "ssecomi")
19764    (set_attr "mode" "SF")])
19766 (define_insn "sse_ucomi"
19767   [(set (reg:CCFPU 17)
19768         (compare:CCFPU (vec_select:SF
19769                         (match_operand:V4SF 0 "register_operand" "x")
19770                         (parallel [(const_int 0)]))
19771                        (vec_select:SF
19772                         (match_operand:V4SF 1 "register_operand" "x")
19773                         (parallel [(const_int 0)]))))]
19774   "TARGET_SSE"
19775   "ucomiss\t{%1, %0|%0, %1}"
19776   [(set_attr "type" "ssecomi")
19777    (set_attr "mode" "SF")])
19780 ;; SSE unpack
19782 (define_insn "sse_unpckhps"
19783   [(set (match_operand:V4SF 0 "register_operand" "=x")
19784         (vec_merge:V4SF
19785          (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0")
19786                           (parallel [(const_int 2)
19787                                      (const_int 0)
19788                                      (const_int 3)
19789                                      (const_int 1)]))
19790          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
19791                           (parallel [(const_int 0)
19792                                      (const_int 2)
19793                                      (const_int 1)
19794                                      (const_int 3)]))
19795          (const_int 5)))]
19796   "TARGET_SSE"
19797   "unpckhps\t{%2, %0|%0, %2}"
19798   [(set_attr "type" "ssecvt")
19799    (set_attr "mode" "V4SF")])
19801 (define_insn "sse_unpcklps"
19802   [(set (match_operand:V4SF 0 "register_operand" "=x")
19803         (vec_merge:V4SF
19804          (vec_select:V4SF (match_operand:V4SF 1 "register_operand" "0")
19805                           (parallel [(const_int 0)
19806                                      (const_int 2)
19807                                      (const_int 1)
19808                                      (const_int 3)]))
19809          (vec_select:V4SF (match_operand:V4SF 2 "register_operand" "x")
19810                           (parallel [(const_int 2)
19811                                      (const_int 0)
19812                                      (const_int 3)
19813                                      (const_int 1)]))
19814          (const_int 5)))]
19815   "TARGET_SSE"
19816   "unpcklps\t{%2, %0|%0, %2}"
19817   [(set_attr "type" "ssecvt")
19818    (set_attr "mode" "V4SF")])
19821 ;; SSE min/max
19823 (define_insn "smaxv4sf3"
19824   [(set (match_operand:V4SF 0 "register_operand" "=x")
19825         (smax:V4SF (match_operand:V4SF 1 "register_operand" "0")
19826                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
19827   "TARGET_SSE"
19828   "maxps\t{%2, %0|%0, %2}"
19829   [(set_attr "type" "sse")
19830    (set_attr "mode" "V4SF")])
19832 (define_insn "vmsmaxv4sf3"
19833   [(set (match_operand:V4SF 0 "register_operand" "=x")
19834         (vec_merge:V4SF
19835          (smax:V4SF (match_operand:V4SF 1 "register_operand" "0")
19836                     (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
19837          (match_dup 1)
19838          (const_int 1)))]
19839   "TARGET_SSE"
19840   "maxss\t{%2, %0|%0, %2}"
19841   [(set_attr "type" "sse")
19842    (set_attr "mode" "SF")])
19844 (define_insn "sminv4sf3"
19845   [(set (match_operand:V4SF 0 "register_operand" "=x")
19846         (smin:V4SF (match_operand:V4SF 1 "register_operand" "0")
19847                    (match_operand:V4SF 2 "nonimmediate_operand" "xm")))]
19848   "TARGET_SSE"
19849   "minps\t{%2, %0|%0, %2}"
19850   [(set_attr "type" "sse")
19851    (set_attr "mode" "V4SF")])
19853 (define_insn "vmsminv4sf3"
19854   [(set (match_operand:V4SF 0 "register_operand" "=x")
19855         (vec_merge:V4SF
19856          (smin:V4SF (match_operand:V4SF 1 "register_operand" "0")
19857                     (match_operand:V4SF 2 "nonimmediate_operand" "xm"))
19858          (match_dup 1)
19859          (const_int 1)))]
19860   "TARGET_SSE"
19861   "minss\t{%2, %0|%0, %2}"
19862   [(set_attr "type" "sse")
19863    (set_attr "mode" "SF")])
19865 ;; SSE <-> integer/MMX conversions
19867 (define_insn "cvtpi2ps"
19868   [(set (match_operand:V4SF 0 "register_operand" "=x")
19869         (vec_merge:V4SF
19870          (match_operand:V4SF 1 "register_operand" "0")
19871          (vec_duplicate:V4SF
19872           (float:V2SF (match_operand:V2SI 2 "nonimmediate_operand" "ym")))
19873          (const_int 12)))]
19874   "TARGET_SSE"
19875   "cvtpi2ps\t{%2, %0|%0, %2}"
19876   [(set_attr "type" "ssecvt")
19877    (set_attr "mode" "V4SF")])
19879 (define_insn "cvtps2pi"
19880   [(set (match_operand:V2SI 0 "register_operand" "=y")
19881         (vec_select:V2SI
19882          (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm"))
19883          (parallel [(const_int 0) (const_int 1)])))]
19884   "TARGET_SSE"
19885   "cvtps2pi\t{%1, %0|%0, %1}"
19886   [(set_attr "type" "ssecvt")
19887    (set_attr "mode" "V4SF")])
19889 (define_insn "cvttps2pi"
19890   [(set (match_operand:V2SI 0 "register_operand" "=y")
19891         (vec_select:V2SI
19892          (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
19893                       UNSPEC_FIX)
19894          (parallel [(const_int 0) (const_int 1)])))]
19895   "TARGET_SSE"
19896   "cvttps2pi\t{%1, %0|%0, %1}"
19897   [(set_attr "type" "ssecvt")
19898    (set_attr "mode" "SF")])
19900 (define_insn "cvtsi2ss"
19901   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
19902         (vec_merge:V4SF
19903          (match_operand:V4SF 1 "register_operand" "0,0")
19904          (vec_duplicate:V4SF
19905           (float:SF (match_operand:SI 2 "nonimmediate_operand" "r,rm")))
19906          (const_int 14)))]
19907   "TARGET_SSE"
19908   "cvtsi2ss\t{%2, %0|%0, %2}"
19909   [(set_attr "type" "sseicvt")
19910    (set_attr "athlon_decode" "vector,double")
19911    (set_attr "mode" "SF")])
19913 (define_insn "cvtsi2ssq"
19914   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
19915         (vec_merge:V4SF
19916          (match_operand:V4SF 1 "register_operand" "0,0")
19917          (vec_duplicate:V4SF
19918           (float:SF (match_operand:DI 2 "nonimmediate_operand" "r,rm")))
19919          (const_int 14)))]
19920   "TARGET_SSE && TARGET_64BIT"
19921   "cvtsi2ssq\t{%2, %0|%0, %2}"
19922   [(set_attr "type" "sseicvt")
19923    (set_attr "athlon_decode" "vector,double")
19924    (set_attr "mode" "SF")])
19926 (define_insn "cvtss2si"
19927   [(set (match_operand:SI 0 "register_operand" "=r,r")
19928         (vec_select:SI
19929          (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "x,m"))
19930          (parallel [(const_int 0)])))]
19931   "TARGET_SSE"
19932   "cvtss2si\t{%1, %0|%0, %1}"
19933   [(set_attr "type" "sseicvt")
19934    (set_attr "athlon_decode" "double,vector")
19935    (set_attr "mode" "SF")])
19937 (define_insn "cvttss2si"
19938   [(set (match_operand:SI 0 "register_operand" "=r,r")
19939         (vec_select:SI
19940          (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "x,xm")]
19941                       UNSPEC_FIX)
19942          (parallel [(const_int 0)])))]
19943   "TARGET_SSE"
19944   "cvttss2si\t{%1, %0|%0, %1}"
19945   [(set_attr "type" "sseicvt")
19946    (set_attr "mode" "SF")
19947    (set_attr "athlon_decode" "double,vector")])
19950 ;; MMX insns
19952 ;; MMX arithmetic
19954 (define_insn "addv8qi3"
19955   [(set (match_operand:V8QI 0 "register_operand" "=y")
19956         (plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
19957                    (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19958   "TARGET_MMX"
19959   "paddb\t{%2, %0|%0, %2}"
19960   [(set_attr "type" "mmxadd")
19961    (set_attr "mode" "DI")])
19963 (define_insn "addv4hi3"
19964   [(set (match_operand:V4HI 0 "register_operand" "=y")
19965         (plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
19966                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19967   "TARGET_MMX"
19968   "paddw\t{%2, %0|%0, %2}"
19969   [(set_attr "type" "mmxadd")
19970    (set_attr "mode" "DI")])
19972 (define_insn "addv2si3"
19973   [(set (match_operand:V2SI 0 "register_operand" "=y")
19974         (plus:V2SI (match_operand:V2SI 1 "register_operand" "0")
19975                    (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
19976   "TARGET_MMX"
19977   "paddd\t{%2, %0|%0, %2}"
19978   [(set_attr "type" "mmxadd")
19979    (set_attr "mode" "DI")])
19981 (define_insn "ssaddv8qi3"
19982   [(set (match_operand:V8QI 0 "register_operand" "=y")
19983         (ss_plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
19984                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
19985   "TARGET_MMX"
19986   "paddsb\t{%2, %0|%0, %2}"
19987   [(set_attr "type" "mmxadd")
19988    (set_attr "mode" "DI")])
19990 (define_insn "ssaddv4hi3"
19991   [(set (match_operand:V4HI 0 "register_operand" "=y")
19992         (ss_plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
19993                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
19994   "TARGET_MMX"
19995   "paddsw\t{%2, %0|%0, %2}"
19996   [(set_attr "type" "mmxadd")
19997    (set_attr "mode" "DI")])
19999 (define_insn "usaddv8qi3"
20000   [(set (match_operand:V8QI 0 "register_operand" "=y")
20001         (us_plus:V8QI (match_operand:V8QI 1 "register_operand" "0")
20002                       (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20003   "TARGET_MMX"
20004   "paddusb\t{%2, %0|%0, %2}"
20005   [(set_attr "type" "mmxadd")
20006    (set_attr "mode" "DI")])
20008 (define_insn "usaddv4hi3"
20009   [(set (match_operand:V4HI 0 "register_operand" "=y")
20010         (us_plus:V4HI (match_operand:V4HI 1 "register_operand" "0")
20011                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20012   "TARGET_MMX"
20013   "paddusw\t{%2, %0|%0, %2}"
20014   [(set_attr "type" "mmxadd")
20015    (set_attr "mode" "DI")])
20017 (define_insn "subv8qi3"
20018   [(set (match_operand:V8QI 0 "register_operand" "=y")
20019         (minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
20020                     (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20021   "TARGET_MMX"
20022   "psubb\t{%2, %0|%0, %2}"
20023   [(set_attr "type" "mmxadd")
20024    (set_attr "mode" "DI")])
20026 (define_insn "subv4hi3"
20027   [(set (match_operand:V4HI 0 "register_operand" "=y")
20028         (minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
20029                     (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20030   "TARGET_MMX"
20031   "psubw\t{%2, %0|%0, %2}"
20032   [(set_attr "type" "mmxadd")
20033    (set_attr "mode" "DI")])
20035 (define_insn "subv2si3"
20036   [(set (match_operand:V2SI 0 "register_operand" "=y")
20037         (minus:V2SI (match_operand:V2SI 1 "register_operand" "0")
20038                     (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
20039   "TARGET_MMX"
20040   "psubd\t{%2, %0|%0, %2}"
20041   [(set_attr "type" "mmxadd")
20042    (set_attr "mode" "DI")])
20044 (define_insn "sssubv8qi3"
20045   [(set (match_operand:V8QI 0 "register_operand" "=y")
20046         (ss_minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
20047                        (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20048   "TARGET_MMX"
20049   "psubsb\t{%2, %0|%0, %2}"
20050   [(set_attr "type" "mmxadd")
20051    (set_attr "mode" "DI")])
20053 (define_insn "sssubv4hi3"
20054   [(set (match_operand:V4HI 0 "register_operand" "=y")
20055         (ss_minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
20056                        (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20057   "TARGET_MMX"
20058   "psubsw\t{%2, %0|%0, %2}"
20059   [(set_attr "type" "mmxadd")
20060    (set_attr "mode" "DI")])
20062 (define_insn "ussubv8qi3"
20063   [(set (match_operand:V8QI 0 "register_operand" "=y")
20064         (us_minus:V8QI (match_operand:V8QI 1 "register_operand" "0")
20065                        (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20066   "TARGET_MMX"
20067   "psubusb\t{%2, %0|%0, %2}"
20068   [(set_attr "type" "mmxadd")
20069    (set_attr "mode" "DI")])
20071 (define_insn "ussubv4hi3"
20072   [(set (match_operand:V4HI 0 "register_operand" "=y")
20073         (us_minus:V4HI (match_operand:V4HI 1 "register_operand" "0")
20074                        (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20075   "TARGET_MMX"
20076   "psubusw\t{%2, %0|%0, %2}"
20077   [(set_attr "type" "mmxadd")
20078    (set_attr "mode" "DI")])
20080 (define_insn "mulv4hi3"
20081   [(set (match_operand:V4HI 0 "register_operand" "=y")
20082         (mult:V4HI (match_operand:V4HI 1 "register_operand" "0")
20083                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20084   "TARGET_MMX"
20085   "pmullw\t{%2, %0|%0, %2}"
20086   [(set_attr "type" "mmxmul")
20087    (set_attr "mode" "DI")])
20089 (define_insn "smulv4hi3_highpart"
20090   [(set (match_operand:V4HI 0 "register_operand" "=y")
20091         (truncate:V4HI
20092          (lshiftrt:V4SI
20093           (mult:V4SI (sign_extend:V4SI
20094                       (match_operand:V4HI 1 "register_operand" "0"))
20095                      (sign_extend:V4SI
20096                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
20097           (const_int 16))))]
20098   "TARGET_MMX"
20099   "pmulhw\t{%2, %0|%0, %2}"
20100   [(set_attr "type" "mmxmul")
20101    (set_attr "mode" "DI")])
20103 (define_insn "umulv4hi3_highpart"
20104   [(set (match_operand:V4HI 0 "register_operand" "=y")
20105         (truncate:V4HI
20106          (lshiftrt:V4SI
20107           (mult:V4SI (zero_extend:V4SI
20108                       (match_operand:V4HI 1 "register_operand" "0"))
20109                      (zero_extend:V4SI
20110                       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
20111           (const_int 16))))]
20112   "TARGET_SSE || TARGET_3DNOW_A"
20113   "pmulhuw\t{%2, %0|%0, %2}"
20114   [(set_attr "type" "mmxmul")
20115    (set_attr "mode" "DI")])
20117 (define_insn "mmx_pmaddwd"
20118   [(set (match_operand:V2SI 0 "register_operand" "=y")
20119         (plus:V2SI
20120          (mult:V2SI
20121           (sign_extend:V2SI
20122            (vec_select:V2HI (match_operand:V4HI 1 "register_operand" "0")
20123                             (parallel [(const_int 0) (const_int 2)])))
20124           (sign_extend:V2SI
20125            (vec_select:V2HI (match_operand:V4HI 2 "nonimmediate_operand" "ym")
20126                             (parallel [(const_int 0) (const_int 2)]))))
20127          (mult:V2SI
20128           (sign_extend:V2SI (vec_select:V2HI (match_dup 1)
20129                                              (parallel [(const_int 1)
20130                                                         (const_int 3)])))
20131           (sign_extend:V2SI (vec_select:V2HI (match_dup 2)
20132                                              (parallel [(const_int 1)
20133                                                         (const_int 3)]))))))]
20134   "TARGET_MMX"
20135   "pmaddwd\t{%2, %0|%0, %2}"
20136   [(set_attr "type" "mmxmul")
20137    (set_attr "mode" "DI")])
20140 ;; MMX logical operations
20141 ;; Note we don't want to declare these as regular iordi3 insns to prevent
20142 ;; normal code that also wants to use the FPU from getting broken.
20143 ;; The UNSPECs are there to prevent the combiner from getting overly clever.
20144 (define_insn "mmx_iordi3"
20145   [(set (match_operand:DI 0 "register_operand" "=y")
20146         (unspec:DI
20147          [(ior:DI (match_operand:DI 1 "register_operand" "0")
20148                   (match_operand:DI 2 "nonimmediate_operand" "ym"))]
20149          UNSPEC_NOP))]
20150   "TARGET_MMX"
20151   "por\t{%2, %0|%0, %2}"
20152   [(set_attr "type" "mmxadd")
20153    (set_attr "mode" "DI")])
20155 (define_insn "mmx_xordi3"
20156   [(set (match_operand:DI 0 "register_operand" "=y")
20157         (unspec:DI
20158          [(xor:DI (match_operand:DI 1 "register_operand" "0")
20159                   (match_operand:DI 2 "nonimmediate_operand" "ym"))]
20160          UNSPEC_NOP))]
20161   "TARGET_MMX"
20162   "pxor\t{%2, %0|%0, %2}"
20163   [(set_attr "type" "mmxadd")
20164    (set_attr "mode" "DI")
20165    (set_attr "memory" "none")])
20167 ;; Same as pxor, but don't show input operands so that we don't think
20168 ;; they are live.
20169 (define_insn "mmx_clrdi"
20170   [(set (match_operand:DI 0 "register_operand" "=y")
20171         (unspec:DI [(const_int 0)] UNSPEC_NOP))]
20172   "TARGET_MMX"
20173   "pxor\t{%0, %0|%0, %0}"
20174   [(set_attr "type" "mmxadd")
20175    (set_attr "mode" "DI")
20176    (set_attr "memory" "none")])
20178 (define_insn "mmx_anddi3"
20179   [(set (match_operand:DI 0 "register_operand" "=y")
20180         (unspec:DI
20181          [(and:DI (match_operand:DI 1 "register_operand" "0")
20182                   (match_operand:DI 2 "nonimmediate_operand" "ym"))]
20183          UNSPEC_NOP))]
20184   "TARGET_MMX"
20185   "pand\t{%2, %0|%0, %2}"
20186   [(set_attr "type" "mmxadd")
20187    (set_attr "mode" "DI")])
20189 (define_insn "mmx_nanddi3"
20190   [(set (match_operand:DI 0 "register_operand" "=y")
20191         (unspec:DI
20192          [(and:DI (not:DI (match_operand:DI 1 "register_operand" "0"))
20193                           (match_operand:DI 2 "nonimmediate_operand" "ym"))]
20194          UNSPEC_NOP))]
20195   "TARGET_MMX"
20196   "pandn\t{%2, %0|%0, %2}"
20197   [(set_attr "type" "mmxadd")
20198    (set_attr "mode" "DI")])
20201 ;; MMX unsigned averages/sum of absolute differences
20203 (define_insn "mmx_uavgv8qi3"
20204   [(set (match_operand:V8QI 0 "register_operand" "=y")
20205         (ashiftrt:V8QI
20206          (plus:V8QI (plus:V8QI
20207                      (match_operand:V8QI 1 "register_operand" "0")
20208                      (match_operand:V8QI 2 "nonimmediate_operand" "ym"))
20209                     (const_vector:V8QI [(const_int 1)
20210                                         (const_int 1)
20211                                         (const_int 1)
20212                                         (const_int 1)
20213                                         (const_int 1)
20214                                         (const_int 1)
20215                                         (const_int 1)
20216                                         (const_int 1)]))
20217          (const_int 1)))]
20218   "TARGET_SSE || TARGET_3DNOW_A"
20219   "pavgb\t{%2, %0|%0, %2}"
20220   [(set_attr "type" "mmxshft")
20221    (set_attr "mode" "DI")])
20223 (define_insn "mmx_uavgv4hi3"
20224   [(set (match_operand:V4HI 0 "register_operand" "=y")
20225         (ashiftrt:V4HI
20226          (plus:V4HI (plus:V4HI
20227                      (match_operand:V4HI 1 "register_operand" "0")
20228                      (match_operand:V4HI 2 "nonimmediate_operand" "ym"))
20229                     (const_vector:V4HI [(const_int 1)
20230                                         (const_int 1)
20231                                         (const_int 1)
20232                                         (const_int 1)]))
20233          (const_int 1)))]
20234   "TARGET_SSE || TARGET_3DNOW_A"
20235   "pavgw\t{%2, %0|%0, %2}"
20236   [(set_attr "type" "mmxshft")
20237    (set_attr "mode" "DI")])
20239 (define_insn "mmx_psadbw"
20240   [(set (match_operand:DI 0 "register_operand" "=y")
20241         (unspec:DI [(match_operand:V8QI 1 "register_operand" "0")
20242                     (match_operand:V8QI 2 "nonimmediate_operand" "ym")]
20243                    UNSPEC_PSADBW))]
20244   "TARGET_SSE || TARGET_3DNOW_A"
20245   "psadbw\t{%2, %0|%0, %2}"
20246   [(set_attr "type" "mmxshft")
20247    (set_attr "mode" "DI")])
20250 ;; MMX insert/extract/shuffle
20252 (define_insn "mmx_pinsrw"
20253   [(set (match_operand:V4HI 0 "register_operand" "=y")
20254         (vec_merge:V4HI (match_operand:V4HI 1 "register_operand" "0")
20255                         (vec_duplicate:V4HI
20256                          (truncate:HI (match_operand:SI 2 "nonimmediate_operand" "rm")))
20257                         (match_operand:SI 3 "immediate_operand" "i")))]
20258   "TARGET_SSE || TARGET_3DNOW_A"
20259   "pinsrw\t{%3, %2, %0|%0, %2, %3}"
20260   [(set_attr "type" "mmxcvt")
20261    (set_attr "mode" "DI")])
20263 (define_insn "mmx_pextrw"
20264   [(set (match_operand:SI 0 "register_operand" "=r")
20265         (zero_extend:SI (vec_select:HI (match_operand:V4HI 1 "register_operand" "y")
20266                                        (parallel
20267                                         [(match_operand:SI 2 "immediate_operand" "i")]))))]
20268   "TARGET_SSE || TARGET_3DNOW_A"
20269   "pextrw\t{%2, %1, %0|%0, %1, %2}"
20270   [(set_attr "type" "mmxcvt")
20271    (set_attr "mode" "DI")])
20273 (define_insn "mmx_pshufw"
20274   [(set (match_operand:V4HI 0 "register_operand" "=y")
20275         (unspec:V4HI [(match_operand:V4HI 1 "register_operand" "0")
20276                       (match_operand:SI 2 "immediate_operand" "i")]
20277                      UNSPEC_SHUFFLE))]
20278   "TARGET_SSE || TARGET_3DNOW_A"
20279   "pshufw\t{%2, %1, %0|%0, %1, %2}"
20280   [(set_attr "type" "mmxcvt")
20281    (set_attr "mode" "DI")])
20284 ;; MMX mask-generating comparisons
20286 (define_insn "eqv8qi3"
20287   [(set (match_operand:V8QI 0 "register_operand" "=y")
20288         (eq:V8QI (match_operand:V8QI 1 "register_operand" "0")
20289                  (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20290   "TARGET_MMX"
20291   "pcmpeqb\t{%2, %0|%0, %2}"
20292   [(set_attr "type" "mmxcmp")
20293    (set_attr "mode" "DI")])
20295 (define_insn "eqv4hi3"
20296   [(set (match_operand:V4HI 0 "register_operand" "=y")
20297         (eq:V4HI (match_operand:V4HI 1 "register_operand" "0")
20298                  (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20299   "TARGET_MMX"
20300   "pcmpeqw\t{%2, %0|%0, %2}"
20301   [(set_attr "type" "mmxcmp")
20302    (set_attr "mode" "DI")])
20304 (define_insn "eqv2si3"
20305   [(set (match_operand:V2SI 0 "register_operand" "=y")
20306         (eq:V2SI (match_operand:V2SI 1 "register_operand" "0")
20307                  (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
20308   "TARGET_MMX"
20309   "pcmpeqd\t{%2, %0|%0, %2}"
20310   [(set_attr "type" "mmxcmp")
20311    (set_attr "mode" "DI")])
20313 (define_insn "gtv8qi3"
20314   [(set (match_operand:V8QI 0 "register_operand" "=y")
20315         (gt:V8QI (match_operand:V8QI 1 "register_operand" "0")
20316                  (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20317   "TARGET_MMX"
20318   "pcmpgtb\t{%2, %0|%0, %2}"
20319   [(set_attr "type" "mmxcmp")
20320    (set_attr "mode" "DI")])
20322 (define_insn "gtv4hi3"
20323   [(set (match_operand:V4HI 0 "register_operand" "=y")
20324         (gt:V4HI (match_operand:V4HI 1 "register_operand" "0")
20325                  (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20326   "TARGET_MMX"
20327   "pcmpgtw\t{%2, %0|%0, %2}"
20328   [(set_attr "type" "mmxcmp")
20329    (set_attr "mode" "DI")])
20331 (define_insn "gtv2si3"
20332   [(set (match_operand:V2SI 0 "register_operand" "=y")
20333         (gt:V2SI (match_operand:V2SI 1 "register_operand" "0")
20334                  (match_operand:V2SI 2 "nonimmediate_operand" "ym")))]
20335   "TARGET_MMX"
20336   "pcmpgtd\t{%2, %0|%0, %2}"
20337   [(set_attr "type" "mmxcmp")
20338    (set_attr "mode" "DI")])
20341 ;; MMX max/min insns
20343 (define_insn "umaxv8qi3"
20344   [(set (match_operand:V8QI 0 "register_operand" "=y")
20345         (umax:V8QI (match_operand:V8QI 1 "register_operand" "0")
20346                    (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20347   "TARGET_SSE || TARGET_3DNOW_A"
20348   "pmaxub\t{%2, %0|%0, %2}"
20349   [(set_attr "type" "mmxadd")
20350    (set_attr "mode" "DI")])
20352 (define_insn "smaxv4hi3"
20353   [(set (match_operand:V4HI 0 "register_operand" "=y")
20354         (smax:V4HI (match_operand:V4HI 1 "register_operand" "0")
20355                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20356   "TARGET_SSE || TARGET_3DNOW_A"
20357   "pmaxsw\t{%2, %0|%0, %2}"
20358   [(set_attr "type" "mmxadd")
20359    (set_attr "mode" "DI")])
20361 (define_insn "uminv8qi3"
20362   [(set (match_operand:V8QI 0 "register_operand" "=y")
20363         (umin:V8QI (match_operand:V8QI 1 "register_operand" "0")
20364                    (match_operand:V8QI 2 "nonimmediate_operand" "ym")))]
20365   "TARGET_SSE || TARGET_3DNOW_A"
20366   "pminub\t{%2, %0|%0, %2}"
20367   [(set_attr "type" "mmxadd")
20368    (set_attr "mode" "DI")])
20370 (define_insn "sminv4hi3"
20371   [(set (match_operand:V4HI 0 "register_operand" "=y")
20372         (smin:V4HI (match_operand:V4HI 1 "register_operand" "0")
20373                    (match_operand:V4HI 2 "nonimmediate_operand" "ym")))]
20374   "TARGET_SSE || TARGET_3DNOW_A"
20375   "pminsw\t{%2, %0|%0, %2}"
20376   [(set_attr "type" "mmxadd")
20377    (set_attr "mode" "DI")])
20380 ;; MMX shifts
20382 (define_insn "ashrv4hi3"
20383   [(set (match_operand:V4HI 0 "register_operand" "=y")
20384         (ashiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0")
20385                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
20386   "TARGET_MMX"
20387   "psraw\t{%2, %0|%0, %2}"
20388   [(set_attr "type" "mmxshft")
20389    (set_attr "mode" "DI")])
20391 (define_insn "ashrv2si3"
20392   [(set (match_operand:V2SI 0 "register_operand" "=y")
20393         (ashiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0")
20394                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
20395   "TARGET_MMX"
20396   "psrad\t{%2, %0|%0, %2}"
20397   [(set_attr "type" "mmxshft")
20398    (set_attr "mode" "DI")])
20400 (define_insn "lshrv4hi3"
20401   [(set (match_operand:V4HI 0 "register_operand" "=y")
20402         (lshiftrt:V4HI (match_operand:V4HI 1 "register_operand" "0")
20403                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
20404   "TARGET_MMX"
20405   "psrlw\t{%2, %0|%0, %2}"
20406   [(set_attr "type" "mmxshft")
20407    (set_attr "mode" "DI")])
20409 (define_insn "lshrv2si3"
20410   [(set (match_operand:V2SI 0 "register_operand" "=y")
20411         (lshiftrt:V2SI (match_operand:V2SI 1 "register_operand" "0")
20412                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
20413   "TARGET_MMX"
20414   "psrld\t{%2, %0|%0, %2}"
20415   [(set_attr "type" "mmxshft")
20416    (set_attr "mode" "DI")])
20418 ;; See logical MMX insns.
20419 (define_insn "mmx_lshrdi3"
20420   [(set (match_operand:DI 0 "register_operand" "=y")
20421         (unspec:DI
20422           [(lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
20423                        (match_operand:DI 2 "nonmemory_operand" "yi"))]
20424           UNSPEC_NOP))]
20425   "TARGET_MMX"
20426   "psrlq\t{%2, %0|%0, %2}"
20427   [(set_attr "type" "mmxshft")
20428    (set_attr "mode" "DI")])
20430 (define_insn "ashlv4hi3"
20431   [(set (match_operand:V4HI 0 "register_operand" "=y")
20432         (ashift:V4HI (match_operand:V4HI 1 "register_operand" "0")
20433                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
20434   "TARGET_MMX"
20435   "psllw\t{%2, %0|%0, %2}"
20436   [(set_attr "type" "mmxshft")
20437    (set_attr "mode" "DI")])
20439 (define_insn "ashlv2si3"
20440   [(set (match_operand:V2SI 0 "register_operand" "=y")
20441         (ashift:V2SI (match_operand:V2SI 1 "register_operand" "0")
20442                        (match_operand:DI 2 "nonmemory_operand" "yi")))]
20443   "TARGET_MMX"
20444   "pslld\t{%2, %0|%0, %2}"
20445   [(set_attr "type" "mmxshft")
20446    (set_attr "mode" "DI")])
20448 ;; See logical MMX insns.
20449 (define_insn "mmx_ashldi3"
20450   [(set (match_operand:DI 0 "register_operand" "=y")
20451         (unspec:DI
20452          [(ashift:DI (match_operand:DI 1 "register_operand" "0")
20453                      (match_operand:DI 2 "nonmemory_operand" "yi"))]
20454          UNSPEC_NOP))]
20455   "TARGET_MMX"
20456   "psllq\t{%2, %0|%0, %2}"
20457   [(set_attr "type" "mmxshft")
20458    (set_attr "mode" "DI")])
20461 ;; MMX pack/unpack insns.
20463 (define_insn "mmx_packsswb"
20464   [(set (match_operand:V8QI 0 "register_operand" "=y")
20465         (vec_concat:V8QI
20466          (ss_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0"))
20467          (ss_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))]
20468   "TARGET_MMX"
20469   "packsswb\t{%2, %0|%0, %2}"
20470   [(set_attr "type" "mmxshft")
20471    (set_attr "mode" "DI")])
20473 (define_insn "mmx_packssdw"
20474   [(set (match_operand:V4HI 0 "register_operand" "=y")
20475         (vec_concat:V4HI
20476          (ss_truncate:V2HI (match_operand:V2SI 1 "register_operand" "0"))
20477          (ss_truncate:V2HI (match_operand:V2SI 2 "register_operand" "y"))))]
20478   "TARGET_MMX"
20479   "packssdw\t{%2, %0|%0, %2}"
20480   [(set_attr "type" "mmxshft")
20481    (set_attr "mode" "DI")])
20483 (define_insn "mmx_packuswb"
20484   [(set (match_operand:V8QI 0 "register_operand" "=y")
20485         (vec_concat:V8QI
20486          (us_truncate:V4QI (match_operand:V4HI 1 "register_operand" "0"))
20487          (us_truncate:V4QI (match_operand:V4HI 2 "register_operand" "y"))))]
20488   "TARGET_MMX"
20489   "packuswb\t{%2, %0|%0, %2}"
20490   [(set_attr "type" "mmxshft")
20491    (set_attr "mode" "DI")])
20493 (define_insn "mmx_punpckhbw"
20494   [(set (match_operand:V8QI 0 "register_operand" "=y")
20495         (vec_merge:V8QI
20496          (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0")
20497                           (parallel [(const_int 4)
20498                                      (const_int 0)
20499                                      (const_int 5)
20500                                      (const_int 1)
20501                                      (const_int 6)
20502                                      (const_int 2)
20503                                      (const_int 7)
20504                                      (const_int 3)]))
20505          (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y")
20506                           (parallel [(const_int 0)
20507                                      (const_int 4)
20508                                      (const_int 1)
20509                                      (const_int 5)
20510                                      (const_int 2)
20511                                      (const_int 6)
20512                                      (const_int 3)
20513                                      (const_int 7)]))
20514          (const_int 85)))]
20515   "TARGET_MMX"
20516   "punpckhbw\t{%2, %0|%0, %2}"
20517   [(set_attr "type" "mmxcvt")
20518    (set_attr "mode" "DI")])
20520 (define_insn "mmx_punpckhwd"
20521   [(set (match_operand:V4HI 0 "register_operand" "=y")
20522         (vec_merge:V4HI
20523          (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0")
20524                           (parallel [(const_int 0)
20525                                      (const_int 2)
20526                                      (const_int 1)
20527                                      (const_int 3)]))
20528          (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y")
20529                           (parallel [(const_int 2)
20530                                      (const_int 0)
20531                                      (const_int 3)
20532                                      (const_int 1)]))
20533          (const_int 5)))]
20534   "TARGET_MMX"
20535   "punpckhwd\t{%2, %0|%0, %2}"
20536   [(set_attr "type" "mmxcvt")
20537    (set_attr "mode" "DI")])
20539 (define_insn "mmx_punpckhdq"
20540   [(set (match_operand:V2SI 0 "register_operand" "=y")
20541         (vec_merge:V2SI
20542          (match_operand:V2SI 1 "register_operand" "0")
20543          (vec_select:V2SI (match_operand:V2SI 2 "register_operand" "y")
20544                           (parallel [(const_int 1)
20545                                      (const_int 0)]))
20546          (const_int 1)))]
20547   "TARGET_MMX"
20548   "punpckhdq\t{%2, %0|%0, %2}"
20549   [(set_attr "type" "mmxcvt")
20550    (set_attr "mode" "DI")])
20552 (define_insn "mmx_punpcklbw"
20553   [(set (match_operand:V8QI 0 "register_operand" "=y")
20554         (vec_merge:V8QI
20555          (vec_select:V8QI (match_operand:V8QI 1 "register_operand" "0")
20556                           (parallel [(const_int 0)
20557                                      (const_int 4)
20558                                      (const_int 1)
20559                                      (const_int 5)
20560                                      (const_int 2)
20561                                      (const_int 6)
20562                                      (const_int 3)
20563                                      (const_int 7)]))
20564          (vec_select:V8QI (match_operand:V8QI 2 "register_operand" "y")
20565                           (parallel [(const_int 4)
20566                                      (const_int 0)
20567                                      (const_int 5)
20568                                      (const_int 1)
20569                                      (const_int 6)
20570                                      (const_int 2)
20571                                      (const_int 7)
20572                                      (const_int 3)]))
20573          (const_int 85)))]
20574   "TARGET_MMX"
20575   "punpcklbw\t{%2, %0|%0, %2}"
20576   [(set_attr "type" "mmxcvt")
20577    (set_attr "mode" "DI")])
20579 (define_insn "mmx_punpcklwd"
20580   [(set (match_operand:V4HI 0 "register_operand" "=y")
20581         (vec_merge:V4HI
20582          (vec_select:V4HI (match_operand:V4HI 1 "register_operand" "0")
20583                           (parallel [(const_int 2)
20584                                      (const_int 0)
20585                                      (const_int 3)
20586                                      (const_int 1)]))
20587          (vec_select:V4HI (match_operand:V4HI 2 "register_operand" "y")
20588                           (parallel [(const_int 0)
20589                                      (const_int 2)
20590                                      (const_int 1)
20591                                      (const_int 3)]))
20592          (const_int 5)))]
20593   "TARGET_MMX"
20594   "punpcklwd\t{%2, %0|%0, %2}"
20595   [(set_attr "type" "mmxcvt")
20596    (set_attr "mode" "DI")])
20598 (define_insn "mmx_punpckldq"
20599   [(set (match_operand:V2SI 0 "register_operand" "=y")
20600         (vec_merge:V2SI
20601          (vec_select:V2SI (match_operand:V2SI 1 "register_operand" "0")
20602                            (parallel [(const_int 1)
20603                                       (const_int 0)]))
20604          (match_operand:V2SI 2 "register_operand" "y")
20605          (const_int 1)))]
20606   "TARGET_MMX"
20607   "punpckldq\t{%2, %0|%0, %2}"
20608   [(set_attr "type" "mmxcvt")
20609    (set_attr "mode" "DI")])
20612 ;; Miscellaneous stuff
20614 (define_insn "emms"
20615   [(unspec_volatile [(const_int 0)] UNSPECV_EMMS)
20616    (clobber (reg:XF 8))
20617    (clobber (reg:XF 9))
20618    (clobber (reg:XF 10))
20619    (clobber (reg:XF 11))
20620    (clobber (reg:XF 12))
20621    (clobber (reg:XF 13))
20622    (clobber (reg:XF 14))
20623    (clobber (reg:XF 15))
20624    (clobber (reg:DI 29))
20625    (clobber (reg:DI 30))
20626    (clobber (reg:DI 31))
20627    (clobber (reg:DI 32))
20628    (clobber (reg:DI 33))
20629    (clobber (reg:DI 34))
20630    (clobber (reg:DI 35))
20631    (clobber (reg:DI 36))]
20632   "TARGET_MMX"
20633   "emms"
20634   [(set_attr "type" "mmx")
20635    (set_attr "memory" "unknown")])
20637 (define_insn "ldmxcsr"
20638   [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")]
20639                     UNSPECV_LDMXCSR)]
20640   "TARGET_SSE"
20641   "ldmxcsr\t%0"
20642   [(set_attr "type" "sse")
20643    (set_attr "memory" "load")])
20645 (define_insn "stmxcsr"
20646   [(set (match_operand:SI 0 "memory_operand" "=m")
20647         (unspec_volatile:SI [(const_int 0)] UNSPECV_STMXCSR))]
20648   "TARGET_SSE"
20649   "stmxcsr\t%0"
20650   [(set_attr "type" "sse")
20651    (set_attr "memory" "store")])
20653 (define_expand "sfence"
20654   [(set (match_dup 0)
20655         (unspec:BLK [(match_dup 0)] UNSPEC_SFENCE))]
20656   "TARGET_SSE || TARGET_3DNOW_A"
20658   operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
20659   MEM_VOLATILE_P (operands[0]) = 1;
20662 (define_insn "*sfence_insn"
20663   [(set (match_operand:BLK 0 "" "")
20664         (unspec:BLK [(match_dup 0)] UNSPEC_SFENCE))]
20665   "TARGET_SSE || TARGET_3DNOW_A"
20666   "sfence"
20667   [(set_attr "type" "sse")
20668    (set_attr "memory" "unknown")])
20670 (define_expand "sse_prologue_save"
20671   [(parallel [(set (match_operand:BLK 0 "" "")
20672                    (unspec:BLK [(reg:DI 21)
20673                                 (reg:DI 22)
20674                                 (reg:DI 23)
20675                                 (reg:DI 24)
20676                                 (reg:DI 25)
20677                                 (reg:DI 26)
20678                                 (reg:DI 27)
20679                                 (reg:DI 28)] UNSPEC_SSE_PROLOGUE_SAVE))
20680               (use (match_operand:DI 1 "register_operand" ""))
20681               (use (match_operand:DI 2 "immediate_operand" ""))
20682               (use (label_ref:DI (match_operand 3 "" "")))])]
20683   "TARGET_64BIT"
20684   "")
20686 (define_insn "*sse_prologue_save_insn"
20687   [(set (mem:BLK (plus:DI (match_operand:DI 0 "register_operand" "R")
20688                           (match_operand:DI 4 "const_int_operand" "n")))
20689         (unspec:BLK [(reg:DI 21)
20690                      (reg:DI 22)
20691                      (reg:DI 23)
20692                      (reg:DI 24)
20693                      (reg:DI 25)
20694                      (reg:DI 26)
20695                      (reg:DI 27)
20696                      (reg:DI 28)] UNSPEC_SSE_PROLOGUE_SAVE))
20697    (use (match_operand:DI 1 "register_operand" "r"))
20698    (use (match_operand:DI 2 "const_int_operand" "i"))
20699    (use (label_ref:DI (match_operand 3 "" "X")))]
20700   "TARGET_64BIT
20701    && INTVAL (operands[4]) + SSE_REGPARM_MAX * 16 - 16 < 128
20702    && INTVAL (operands[4]) + INTVAL (operands[2]) * 16 >= -128"
20703   "*
20705   int i;
20706   operands[0] = gen_rtx_MEM (Pmode,
20707                              gen_rtx_PLUS (Pmode, operands[0], operands[4]));
20708   output_asm_insn (\"jmp\\t%A1\", operands);
20709   for (i = SSE_REGPARM_MAX - 1; i >= INTVAL (operands[2]); i--)
20710     {
20711       operands[4] = adjust_address (operands[0], DImode, i*16);
20712       operands[5] = gen_rtx_REG (TImode, SSE_REGNO (i));
20713       PUT_MODE (operands[4], TImode);
20714       if (GET_CODE (XEXP (operands[0], 0)) != PLUS)
20715         output_asm_insn (\"rex\", operands);
20716       output_asm_insn (\"movaps\\t{%5, %4|%4, %5}\", operands);
20717     }
20718   (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
20719                              CODE_LABEL_NUMBER (operands[3]));
20720   RET;
20722   "
20723   [(set_attr "type" "other")
20724    (set_attr "length_immediate" "0")
20725    (set_attr "length_address" "0")
20726    (set_attr "length" "135")
20727    (set_attr "memory" "store")
20728    (set_attr "modrm" "0")
20729    (set_attr "mode" "DI")])
20731 ;; 3Dnow! instructions
20733 (define_insn "addv2sf3"
20734   [(set (match_operand:V2SF 0 "register_operand" "=y")
20735         (plus:V2SF (match_operand:V2SF 1 "register_operand" "0")
20736                    (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
20737   "TARGET_3DNOW"
20738   "pfadd\\t{%2, %0|%0, %2}"
20739   [(set_attr "type" "mmxadd")
20740    (set_attr "mode" "V2SF")])
20742 (define_insn "subv2sf3"
20743   [(set (match_operand:V2SF 0 "register_operand" "=y")
20744         (minus:V2SF (match_operand:V2SF 1 "register_operand" "0")
20745                     (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
20746   "TARGET_3DNOW"
20747   "pfsub\\t{%2, %0|%0, %2}"
20748   [(set_attr "type" "mmxadd")
20749    (set_attr "mode" "V2SF")])
20751 (define_insn "subrv2sf3"
20752   [(set (match_operand:V2SF 0 "register_operand" "=y")
20753         (minus:V2SF (match_operand:V2SF 2 "nonimmediate_operand" "ym")
20754                     (match_operand:V2SF 1 "register_operand" "0")))]
20755   "TARGET_3DNOW"
20756   "pfsubr\\t{%2, %0|%0, %2}"
20757   [(set_attr "type" "mmxadd")
20758    (set_attr "mode" "V2SF")])
20760 (define_insn "gtv2sf3"
20761   [(set (match_operand:V2SI 0 "register_operand" "=y")
20762         (gt:V2SI (match_operand:V2SF 1 "register_operand" "0")
20763                  (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
20764  "TARGET_3DNOW"
20765   "pfcmpgt\\t{%2, %0|%0, %2}"
20766   [(set_attr "type" "mmxcmp")
20767    (set_attr "mode" "V2SF")])
20769 (define_insn "gev2sf3"
20770   [(set (match_operand:V2SI 0 "register_operand" "=y")
20771         (ge:V2SI (match_operand:V2SF 1 "register_operand" "0")
20772                  (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
20773   "TARGET_3DNOW"
20774   "pfcmpge\\t{%2, %0|%0, %2}"
20775   [(set_attr "type" "mmxcmp")
20776    (set_attr "mode" "V2SF")])
20778 (define_insn "eqv2sf3"
20779   [(set (match_operand:V2SI 0 "register_operand" "=y")
20780         (eq:V2SI (match_operand:V2SF 1 "register_operand" "0")
20781                  (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
20782   "TARGET_3DNOW"
20783   "pfcmpeq\\t{%2, %0|%0, %2}"
20784   [(set_attr "type" "mmxcmp")
20785    (set_attr "mode" "V2SF")])
20787 (define_insn "pfmaxv2sf3"
20788   [(set (match_operand:V2SF 0 "register_operand" "=y")
20789         (smax:V2SF (match_operand:V2SF 1 "register_operand" "0")
20790                    (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
20791   "TARGET_3DNOW"
20792   "pfmax\\t{%2, %0|%0, %2}"
20793   [(set_attr "type" "mmxadd")
20794    (set_attr "mode" "V2SF")])
20796 (define_insn "pfminv2sf3"
20797   [(set (match_operand:V2SF 0 "register_operand" "=y")
20798         (smin:V2SF (match_operand:V2SF 1 "register_operand" "0")
20799                    (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
20800   "TARGET_3DNOW"
20801   "pfmin\\t{%2, %0|%0, %2}"
20802   [(set_attr "type" "mmxadd")
20803    (set_attr "mode" "V2SF")])
20805 (define_insn "mulv2sf3"
20806   [(set (match_operand:V2SF 0 "register_operand" "=y")
20807         (mult:V2SF (match_operand:V2SF 1 "register_operand" "0")
20808                    (match_operand:V2SF 2 "nonimmediate_operand" "ym")))]
20809   "TARGET_3DNOW"
20810   "pfmul\\t{%2, %0|%0, %2}"
20811   [(set_attr "type" "mmxmul")
20812    (set_attr "mode" "V2SF")])
20814 (define_insn "femms"
20815   [(unspec_volatile [(const_int 0)] UNSPECV_FEMMS)
20816    (clobber (reg:XF 8))
20817    (clobber (reg:XF 9))
20818    (clobber (reg:XF 10))
20819    (clobber (reg:XF 11))
20820    (clobber (reg:XF 12))
20821    (clobber (reg:XF 13))
20822    (clobber (reg:XF 14))
20823    (clobber (reg:XF 15))
20824    (clobber (reg:DI 29))
20825    (clobber (reg:DI 30))
20826    (clobber (reg:DI 31))
20827    (clobber (reg:DI 32))
20828    (clobber (reg:DI 33))
20829    (clobber (reg:DI 34))
20830    (clobber (reg:DI 35))
20831    (clobber (reg:DI 36))]
20832   "TARGET_3DNOW"
20833   "femms"
20834   [(set_attr "type" "mmx")
20835    (set_attr "memory" "none")]) 
20837 (define_insn "pf2id"
20838   [(set (match_operand:V2SI 0 "register_operand" "=y")
20839         (fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))]
20840   "TARGET_3DNOW"
20841   "pf2id\\t{%1, %0|%0, %1}"
20842   [(set_attr "type" "mmxcvt")
20843    (set_attr "mode" "V2SF")])
20845 (define_insn "pf2iw"
20846   [(set (match_operand:V2SI 0 "register_operand" "=y")
20847         (sign_extend:V2SI
20848            (ss_truncate:V2HI
20849               (fix:V2SI (match_operand:V2SF 1 "nonimmediate_operand" "ym")))))]
20850   "TARGET_3DNOW_A"
20851   "pf2iw\\t{%1, %0|%0, %1}"
20852   [(set_attr "type" "mmxcvt")
20853    (set_attr "mode" "V2SF")])
20855 (define_insn "pfacc"
20856   [(set (match_operand:V2SF 0 "register_operand" "=y")
20857         (vec_concat:V2SF
20858            (plus:SF
20859               (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
20860                              (parallel [(const_int  0)]))
20861               (vec_select:SF (match_dup 1)
20862                              (parallel [(const_int 1)])))
20863            (plus:SF
20864               (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
20865                              (parallel [(const_int  0)]))
20866               (vec_select:SF (match_dup 2)
20867                              (parallel [(const_int 1)])))))]
20868   "TARGET_3DNOW"
20869   "pfacc\\t{%2, %0|%0, %2}"
20870   [(set_attr "type" "mmxadd")
20871    (set_attr "mode" "V2SF")])
20873 (define_insn "pfnacc"
20874   [(set (match_operand:V2SF 0 "register_operand" "=y")
20875         (vec_concat:V2SF
20876            (minus:SF
20877               (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
20878                              (parallel [(const_int 0)]))
20879               (vec_select:SF (match_dup 1)
20880                              (parallel [(const_int 1)])))
20881            (minus:SF
20882               (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
20883                              (parallel [(const_int  0)]))
20884               (vec_select:SF (match_dup 2)
20885                              (parallel [(const_int 1)])))))]
20886   "TARGET_3DNOW_A"
20887   "pfnacc\\t{%2, %0|%0, %2}"
20888   [(set_attr "type" "mmxadd")
20889    (set_attr "mode" "V2SF")])
20891 (define_insn "pfpnacc"
20892   [(set (match_operand:V2SF 0 "register_operand" "=y")
20893         (vec_concat:V2SF
20894            (minus:SF
20895               (vec_select:SF (match_operand:V2SF 1 "register_operand" "0")
20896                              (parallel [(const_int 0)]))
20897               (vec_select:SF (match_dup 1)
20898                              (parallel [(const_int 1)])))
20899            (plus:SF
20900               (vec_select:SF (match_operand:V2SF 2 "nonimmediate_operand" "y")
20901                              (parallel [(const_int 0)]))
20902               (vec_select:SF (match_dup 2)
20903                              (parallel [(const_int 1)])))))]
20904   "TARGET_3DNOW_A"
20905   "pfpnacc\\t{%2, %0|%0, %2}"
20906   [(set_attr "type" "mmxadd")
20907    (set_attr "mode" "V2SF")])
20909 (define_insn "pi2fw"
20910   [(set (match_operand:V2SF 0 "register_operand" "=y")
20911         (float:V2SF
20912            (vec_concat:V2SI
20913               (sign_extend:SI
20914                  (truncate:HI
20915                     (vec_select:SI (match_operand:V2SI 1 "nonimmediate_operand" "ym")
20916                                    (parallel [(const_int 0)]))))
20917               (sign_extend:SI
20918                  (truncate:HI
20919                     (vec_select:SI (match_dup 1)
20920                                    (parallel [(const_int  1)])))))))]
20921   "TARGET_3DNOW_A"
20922   "pi2fw\\t{%1, %0|%0, %1}"
20923   [(set_attr "type" "mmxcvt")
20924    (set_attr "mode" "V2SF")])
20926 (define_insn "floatv2si2"
20927   [(set (match_operand:V2SF 0 "register_operand" "=y")
20928         (float:V2SF (match_operand:V2SI 1 "nonimmediate_operand" "ym")))]
20929   "TARGET_3DNOW"
20930   "pi2fd\\t{%1, %0|%0, %1}"
20931   [(set_attr "type" "mmxcvt")
20932    (set_attr "mode" "V2SF")])
20934 ;; This insn is identical to pavgb in operation, but the opcode is
20935 ;; different.  To avoid accidentally matching pavgb, use an unspec.
20937 (define_insn "pavgusb"
20938  [(set (match_operand:V8QI 0 "register_operand" "=y")
20939        (unspec:V8QI
20940           [(match_operand:V8QI 1 "register_operand" "0")
20941            (match_operand:V8QI 2 "nonimmediate_operand" "ym")]
20942           UNSPEC_PAVGUSB))]
20943   "TARGET_3DNOW"
20944   "pavgusb\\t{%2, %0|%0, %2}"
20945   [(set_attr "type" "mmxshft")
20946    (set_attr "mode" "TI")])
20948 ;; 3DNow reciprocal and sqrt
20950 (define_insn "pfrcpv2sf2"
20951   [(set (match_operand:V2SF 0 "register_operand" "=y")
20952         (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")]
20953         UNSPEC_PFRCP))]
20954   "TARGET_3DNOW"
20955   "pfrcp\\t{%1, %0|%0, %1}"
20956   [(set_attr "type" "mmx")
20957    (set_attr "mode" "TI")])
20959 (define_insn "pfrcpit1v2sf3"
20960   [(set (match_operand:V2SF 0 "register_operand" "=y")
20961         (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
20962                       (match_operand:V2SF 2 "nonimmediate_operand" "ym")]
20963                      UNSPEC_PFRCPIT1))]
20964   "TARGET_3DNOW"
20965   "pfrcpit1\\t{%2, %0|%0, %2}"
20966   [(set_attr "type" "mmx")
20967    (set_attr "mode" "TI")])
20969 (define_insn "pfrcpit2v2sf3"
20970   [(set (match_operand:V2SF 0 "register_operand" "=y")
20971         (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
20972                       (match_operand:V2SF 2 "nonimmediate_operand" "ym")]
20973                      UNSPEC_PFRCPIT2))]
20974   "TARGET_3DNOW"
20975   "pfrcpit2\\t{%2, %0|%0, %2}"
20976   [(set_attr "type" "mmx")
20977    (set_attr "mode" "TI")])
20979 (define_insn "pfrsqrtv2sf2"
20980   [(set (match_operand:V2SF 0 "register_operand" "=y")
20981         (unspec:V2SF [(match_operand:V2SF 1 "nonimmediate_operand" "ym")]
20982                      UNSPEC_PFRSQRT))]
20983   "TARGET_3DNOW"
20984   "pfrsqrt\\t{%1, %0|%0, %1}"
20985   [(set_attr "type" "mmx")
20986    (set_attr "mode" "TI")])
20987                 
20988 (define_insn "pfrsqit1v2sf3"
20989   [(set (match_operand:V2SF 0 "register_operand" "=y")
20990         (unspec:V2SF [(match_operand:V2SF 1 "register_operand" "0")
20991                       (match_operand:V2SF 2 "nonimmediate_operand" "ym")]
20992                      UNSPEC_PFRSQIT1))]
20993   "TARGET_3DNOW"
20994   "pfrsqit1\\t{%2, %0|%0, %2}"
20995   [(set_attr "type" "mmx")
20996    (set_attr "mode" "TI")])
20998 (define_insn "pmulhrwv4hi3"
20999   [(set (match_operand:V4HI 0 "register_operand" "=y")
21000         (truncate:V4HI
21001            (lshiftrt:V4SI
21002               (plus:V4SI
21003                  (mult:V4SI
21004                     (sign_extend:V4SI
21005                        (match_operand:V4HI 1 "register_operand" "0"))
21006                     (sign_extend:V4SI
21007                        (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
21008                  (const_vector:V4SI [(const_int 32768)
21009                                      (const_int 32768)
21010                                      (const_int 32768)
21011                                      (const_int 32768)]))
21012               (const_int 16))))]
21013   "TARGET_3DNOW"
21014   "pmulhrw\\t{%2, %0|%0, %2}"
21015   [(set_attr "type" "mmxmul")
21016    (set_attr "mode" "TI")])
21018 (define_insn "pswapdv2si2"
21019   [(set (match_operand:V2SI 0 "register_operand" "=y")
21020         (vec_select:V2SI (match_operand:V2SI 1 "nonimmediate_operand" "ym")
21021                          (parallel [(const_int 1) (const_int 0)])))]
21022   "TARGET_3DNOW_A"
21023   "pswapd\\t{%1, %0|%0, %1}"
21024   [(set_attr "type" "mmxcvt")
21025    (set_attr "mode" "TI")])
21027 (define_insn "pswapdv2sf2"
21028   [(set (match_operand:V2SF 0 "register_operand" "=y")
21029         (vec_select:V2SF (match_operand:V2SF 1 "nonimmediate_operand" "ym")
21030                          (parallel [(const_int 1) (const_int 0)])))]
21031   "TARGET_3DNOW_A"
21032   "pswapd\\t{%1, %0|%0, %1}"
21033   [(set_attr "type" "mmxcvt")
21034    (set_attr "mode" "TI")])
21036 (define_expand "prefetch"
21037   [(prefetch (match_operand 0 "address_operand" "")
21038              (match_operand:SI 1 "const_int_operand" "")
21039              (match_operand:SI 2 "const_int_operand" ""))]
21040   "TARGET_PREFETCH_SSE || TARGET_3DNOW"
21042   int rw = INTVAL (operands[1]);
21043   int locality = INTVAL (operands[2]);
21045   if (rw != 0 && rw != 1)
21046     abort ();
21047   if (locality < 0 || locality > 3)
21048     abort ();
21049   if (GET_MODE (operands[0]) != Pmode && GET_MODE (operands[0]) != VOIDmode)
21050     abort ();
21052   /* Use 3dNOW prefetch in case we are asking for write prefetch not
21053      suported by SSE counterpart or the SSE prefetch is not available
21054      (K6 machines).  Otherwise use SSE prefetch as it allows specifying
21055      of locality.  */
21056   if (TARGET_3DNOW && (!TARGET_PREFETCH_SSE || rw))
21057     operands[2] = GEN_INT (3);
21058   else
21059     operands[1] = const0_rtx;
21062 (define_insn "*prefetch_sse"
21063   [(prefetch (match_operand:SI 0 "address_operand" "p")
21064              (const_int 0)
21065              (match_operand:SI 1 "const_int_operand" ""))]
21066   "TARGET_PREFETCH_SSE && !TARGET_64BIT"
21068   static const char * const patterns[4] = {
21069    "prefetchnta\t%a0", "prefetcht2\t%a0", "prefetcht1\t%a0", "prefetcht0\t%a0"
21070   };
21072   int locality = INTVAL (operands[1]);
21073   if (locality < 0 || locality > 3)
21074     abort ();
21076   return patterns[locality];  
21078   [(set_attr "type" "sse")
21079    (set_attr "memory" "none")])
21081 (define_insn "*prefetch_sse_rex"
21082   [(prefetch (match_operand:DI 0 "address_operand" "p")
21083              (const_int 0)
21084              (match_operand:SI 1 "const_int_operand" ""))]
21085   "TARGET_PREFETCH_SSE && TARGET_64BIT"
21087   static const char * const patterns[4] = {
21088    "prefetchnta\t%a0", "prefetcht2\t%a0", "prefetcht1\t%a0", "prefetcht0\t%a0"
21089   };
21091   int locality = INTVAL (operands[1]);
21092   if (locality < 0 || locality > 3)
21093     abort ();
21095   return patterns[locality];  
21097   [(set_attr "type" "sse")
21098    (set_attr "memory" "none")])
21100 (define_insn "*prefetch_3dnow"
21101   [(prefetch (match_operand:SI 0 "address_operand" "p")
21102              (match_operand:SI 1 "const_int_operand" "n")
21103              (const_int 3))]
21104   "TARGET_3DNOW && !TARGET_64BIT"
21106   if (INTVAL (operands[1]) == 0)
21107     return "prefetch\t%a0";
21108   else
21109     return "prefetchw\t%a0";
21111   [(set_attr "type" "mmx")
21112    (set_attr "memory" "none")])
21114 (define_insn "*prefetch_3dnow_rex"
21115   [(prefetch (match_operand:DI 0 "address_operand" "p")
21116              (match_operand:SI 1 "const_int_operand" "n")
21117              (const_int 3))]
21118   "TARGET_3DNOW && TARGET_64BIT"
21120   if (INTVAL (operands[1]) == 0)
21121     return "prefetch\t%a0";
21122   else
21123     return "prefetchw\t%a0";
21125   [(set_attr "type" "mmx")
21126    (set_attr "memory" "none")])
21128 ;; SSE2 support
21130 (define_insn "addv2df3"
21131   [(set (match_operand:V2DF 0 "register_operand" "=x")
21132         (plus:V2DF (match_operand:V2DF 1 "register_operand" "0")
21133                    (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
21134   "TARGET_SSE2"
21135   "addpd\t{%2, %0|%0, %2}"
21136   [(set_attr "type" "sseadd")
21137    (set_attr "mode" "V2DF")])
21139 (define_insn "vmaddv2df3"
21140   [(set (match_operand:V2DF 0 "register_operand" "=x")
21141         (vec_merge:V2DF (plus:V2DF (match_operand:V2DF 1 "register_operand" "0")
21142                                    (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
21143                         (match_dup 1)
21144                         (const_int 1)))]
21145   "TARGET_SSE2"
21146   "addsd\t{%2, %0|%0, %2}"
21147   [(set_attr "type" "sseadd")
21148    (set_attr "mode" "DF")])
21150 (define_insn "subv2df3"
21151   [(set (match_operand:V2DF 0 "register_operand" "=x")
21152         (minus:V2DF (match_operand:V2DF 1 "register_operand" "0")
21153                    (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
21154   "TARGET_SSE2"
21155   "subpd\t{%2, %0|%0, %2}"
21156   [(set_attr "type" "sseadd")
21157    (set_attr "mode" "V2DF")])
21159 (define_insn "vmsubv2df3"
21160   [(set (match_operand:V2DF 0 "register_operand" "=x")
21161         (vec_merge:V2DF (minus:V2DF (match_operand:V2DF 1 "register_operand" "0")
21162                                    (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
21163                         (match_dup 1)
21164                         (const_int 1)))]
21165   "TARGET_SSE2"
21166   "subsd\t{%2, %0|%0, %2}"
21167   [(set_attr "type" "sseadd")
21168    (set_attr "mode" "DF")])
21170 (define_insn "mulv2df3"
21171   [(set (match_operand:V2DF 0 "register_operand" "=x")
21172         (mult:V2DF (match_operand:V2DF 1 "register_operand" "0")
21173                    (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
21174   "TARGET_SSE2"
21175   "mulpd\t{%2, %0|%0, %2}"
21176   [(set_attr "type" "ssemul")
21177    (set_attr "mode" "V2DF")])
21179 (define_insn "vmmulv2df3"
21180   [(set (match_operand:V2DF 0 "register_operand" "=x")
21181         (vec_merge:V2DF (mult:V2DF (match_operand:V2DF 1 "register_operand" "0")
21182                                    (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
21183                         (match_dup 1)
21184                         (const_int 1)))]
21185   "TARGET_SSE2"
21186   "mulsd\t{%2, %0|%0, %2}"
21187   [(set_attr "type" "ssemul")
21188    (set_attr "mode" "DF")])
21190 (define_insn "divv2df3"
21191   [(set (match_operand:V2DF 0 "register_operand" "=x")
21192         (div:V2DF (match_operand:V2DF 1 "register_operand" "0")
21193                   (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
21194   "TARGET_SSE2"
21195   "divpd\t{%2, %0|%0, %2}"
21196   [(set_attr "type" "ssediv")
21197    (set_attr "mode" "V2DF")])
21199 (define_insn "vmdivv2df3"
21200   [(set (match_operand:V2DF 0 "register_operand" "=x")
21201         (vec_merge:V2DF (div:V2DF (match_operand:V2DF 1 "register_operand" "0")
21202                                   (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
21203                         (match_dup 1)
21204                         (const_int 1)))]
21205   "TARGET_SSE2"
21206   "divsd\t{%2, %0|%0, %2}"
21207   [(set_attr "type" "ssediv")
21208    (set_attr "mode" "DF")])
21210 ;; SSE min/max
21212 (define_insn "smaxv2df3"
21213   [(set (match_operand:V2DF 0 "register_operand" "=x")
21214         (smax:V2DF (match_operand:V2DF 1 "register_operand" "0")
21215                    (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
21216   "TARGET_SSE2"
21217   "maxpd\t{%2, %0|%0, %2}"
21218   [(set_attr "type" "sseadd")
21219    (set_attr "mode" "V2DF")])
21221 (define_insn "vmsmaxv2df3"
21222   [(set (match_operand:V2DF 0 "register_operand" "=x")
21223         (vec_merge:V2DF (smax:V2DF (match_operand:V2DF 1 "register_operand" "0")
21224                                    (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
21225                         (match_dup 1)
21226                         (const_int 1)))]
21227   "TARGET_SSE2"
21228   "maxsd\t{%2, %0|%0, %2}"
21229   [(set_attr "type" "sseadd")
21230    (set_attr "mode" "DF")])
21232 (define_insn "sminv2df3"
21233   [(set (match_operand:V2DF 0 "register_operand" "=x")
21234         (smin:V2DF (match_operand:V2DF 1 "register_operand" "0")
21235                    (match_operand:V2DF 2 "nonimmediate_operand" "xm")))]
21236   "TARGET_SSE2"
21237   "minpd\t{%2, %0|%0, %2}"
21238   [(set_attr "type" "sseadd")
21239    (set_attr "mode" "V2DF")])
21241 (define_insn "vmsminv2df3"
21242   [(set (match_operand:V2DF 0 "register_operand" "=x")
21243         (vec_merge:V2DF (smin:V2DF (match_operand:V2DF 1 "register_operand" "0")
21244                                    (match_operand:V2DF 2 "nonimmediate_operand" "xm"))
21245                         (match_dup 1)
21246                         (const_int 1)))]
21247   "TARGET_SSE2"
21248   "minsd\t{%2, %0|%0, %2}"
21249   [(set_attr "type" "sseadd")
21250    (set_attr "mode" "DF")])
21251 ;; SSE2 square root.  There doesn't appear to be an extension for the
21252 ;; reciprocal/rsqrt instructions if the Intel manual is to be believed.
21254 (define_insn "sqrtv2df2"
21255   [(set (match_operand:V2DF 0 "register_operand" "=x")
21256         (sqrt:V2DF (match_operand:V2DF 1 "register_operand" "xm")))]
21257   "TARGET_SSE2"
21258   "sqrtpd\t{%1, %0|%0, %1}"
21259   [(set_attr "type" "sse")
21260    (set_attr "mode" "V2DF")])
21262 (define_insn "vmsqrtv2df2"
21263   [(set (match_operand:V2DF 0 "register_operand" "=x")
21264         (vec_merge:V2DF (sqrt:V2DF (match_operand:V2DF 1 "register_operand" "xm"))
21265                         (match_operand:V2DF 2 "register_operand" "0")
21266                         (const_int 1)))]
21267   "TARGET_SSE2"
21268   "sqrtsd\t{%1, %0|%0, %1}"
21269   [(set_attr "type" "sse")
21270    (set_attr "mode" "SF")])
21272 ;; SSE mask-generating compares
21274 (define_insn "maskcmpv2df3"
21275   [(set (match_operand:V2DI 0 "register_operand" "=x")
21276         (match_operator:V2DI 3 "sse_comparison_operator"
21277                              [(match_operand:V2DF 1 "register_operand" "0")
21278                               (match_operand:V2DF 2 "nonimmediate_operand" "x")]))]
21279   "TARGET_SSE2"
21280   "cmp%D3pd\t{%2, %0|%0, %2}"
21281   [(set_attr "type" "ssecmp")
21282    (set_attr "mode" "V2DF")])
21284 (define_insn "maskncmpv2df3"
21285   [(set (match_operand:V2DI 0 "register_operand" "=x")
21286         (not:V2DI
21287          (match_operator:V2DI 3 "sse_comparison_operator"
21288                               [(match_operand:V2DF 1 "register_operand" "0")
21289                                (match_operand:V2DF 2 "nonimmediate_operand" "x")])))]
21290   "TARGET_SSE2"
21292   if (GET_CODE (operands[3]) == UNORDERED)
21293     return "cmpordps\t{%2, %0|%0, %2}";
21294   else
21295     return "cmpn%D3pd\t{%2, %0|%0, %2}";
21297   [(set_attr "type" "ssecmp")
21298    (set_attr "mode" "V2DF")])
21300 (define_insn "vmmaskcmpv2df3"
21301   [(set (match_operand:V2DI 0 "register_operand" "=x")
21302         (vec_merge:V2DI
21303          (match_operator:V2DI 3 "sse_comparison_operator"
21304                               [(match_operand:V2DF 1 "register_operand" "0")
21305                                (match_operand:V2DF 2 "nonimmediate_operand" "x")])
21306          (match_dup 1)
21307          (const_int 1)))]
21308   "TARGET_SSE2"
21309   "cmp%D3sd\t{%2, %0|%0, %2}"
21310   [(set_attr "type" "ssecmp")
21311    (set_attr "mode" "DF")])
21313 (define_insn "vmmaskncmpv2df3"
21314   [(set (match_operand:V2DI 0 "register_operand" "=x")
21315         (vec_merge:V2DI
21316          (not:V2DI
21317           (match_operator:V2DI 3 "sse_comparison_operator"
21318                                [(match_operand:V2DF 1 "register_operand" "0")
21319                                 (match_operand:V2DF 2 "nonimmediate_operand" "x")]))
21320          (subreg:V2DI (match_dup 1) 0)
21321          (const_int 1)))]
21322   "TARGET_SSE2"
21324   if (GET_CODE (operands[3]) == UNORDERED)
21325     return "cmpordsd\t{%2, %0|%0, %2}";
21326   else
21327     return "cmpn%D3sd\t{%2, %0|%0, %2}";
21329   [(set_attr "type" "ssecmp")
21330    (set_attr "mode" "DF")])
21332 (define_insn "sse2_comi"
21333   [(set (reg:CCFP 17)
21334         (compare:CCFP (vec_select:DF
21335                        (match_operand:V2DF 0 "register_operand" "x")
21336                        (parallel [(const_int 0)]))
21337                       (vec_select:DF
21338                        (match_operand:V2DF 1 "register_operand" "x")
21339                        (parallel [(const_int 0)]))))]
21340   "TARGET_SSE2"
21341   "comisd\t{%1, %0|%0, %1}"
21342   [(set_attr "type" "ssecomi")
21343    (set_attr "mode" "DF")])
21345 (define_insn "sse2_ucomi"
21346   [(set (reg:CCFPU 17)
21347         (compare:CCFPU (vec_select:DF
21348                          (match_operand:V2DF 0 "register_operand" "x")
21349                          (parallel [(const_int 0)]))
21350                         (vec_select:DF
21351                          (match_operand:V2DF 1 "register_operand" "x")
21352                          (parallel [(const_int 0)]))))]
21353   "TARGET_SSE2"
21354   "ucomisd\t{%1, %0|%0, %1}"
21355   [(set_attr "type" "ssecomi")
21356    (set_attr "mode" "DF")])
21358 ;; SSE Strange Moves.
21360 (define_insn "sse2_movmskpd"
21361   [(set (match_operand:SI 0 "register_operand" "=r")
21362         (unspec:SI [(match_operand:V2DF 1 "register_operand" "x")]
21363                    UNSPEC_MOVMSK))]
21364   "TARGET_SSE2"
21365   "movmskpd\t{%1, %0|%0, %1}"
21366   [(set_attr "type" "ssecvt")
21367    (set_attr "mode" "V2DF")])
21369 (define_insn "sse2_pmovmskb"
21370   [(set (match_operand:SI 0 "register_operand" "=r")
21371         (unspec:SI [(match_operand:V16QI 1 "register_operand" "x")]
21372                    UNSPEC_MOVMSK))]
21373   "TARGET_SSE2"
21374   "pmovmskb\t{%1, %0|%0, %1}"
21375   [(set_attr "type" "ssecvt")
21376    (set_attr "mode" "V2DF")])
21378 (define_insn "sse2_maskmovdqu"
21379   [(set (mem:V16QI (match_operand:SI 0 "register_operand" "D"))
21380         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "x")
21381                        (match_operand:V16QI 2 "register_operand" "x")]
21382                       UNSPEC_MASKMOV))]
21383   "TARGET_SSE2"
21384   ;; @@@ check ordering of operands in intel/nonintel syntax
21385   "maskmovdqu\t{%2, %1|%1, %2}"
21386   [(set_attr "type" "ssecvt")
21387    (set_attr "mode" "TI")])
21389 (define_insn "sse2_maskmovdqu_rex64"
21390   [(set (mem:V16QI (match_operand:DI 0 "register_operand" "D"))
21391         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "x")
21392                        (match_operand:V16QI 2 "register_operand" "x")]
21393                       UNSPEC_MASKMOV))]
21394   "TARGET_SSE2"
21395   ;; @@@ check ordering of operands in intel/nonintel syntax
21396   "maskmovdqu\t{%2, %1|%1, %2}"
21397   [(set_attr "type" "ssecvt")
21398    (set_attr "mode" "TI")])
21400 (define_insn "sse2_movntv2df"
21401   [(set (match_operand:V2DF 0 "memory_operand" "=m")
21402         (unspec:V2DF [(match_operand:V2DF 1 "register_operand" "x")]
21403                      UNSPEC_MOVNT))]
21404   "TARGET_SSE2"
21405   "movntpd\t{%1, %0|%0, %1}"
21406   [(set_attr "type" "ssecvt")
21407    (set_attr "mode" "V2DF")])
21409 (define_insn "sse2_movntv2di"
21410   [(set (match_operand:V2DI 0 "memory_operand" "=m")
21411         (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "x")]
21412                      UNSPEC_MOVNT))]
21413   "TARGET_SSE2"
21414   "movntdq\t{%1, %0|%0, %1}"
21415   [(set_attr "type" "ssecvt")
21416    (set_attr "mode" "TI")])
21418 (define_insn "sse2_movntsi"
21419   [(set (match_operand:SI 0 "memory_operand" "=m")
21420         (unspec:SI [(match_operand:SI 1 "register_operand" "r")]
21421                    UNSPEC_MOVNT))]
21422   "TARGET_SSE2"
21423   "movnti\t{%1, %0|%0, %1}"
21424   [(set_attr "type" "ssecvt")
21425    (set_attr "mode" "V2DF")])
21427 ;; SSE <-> integer/MMX conversions
21429 ;; Conversions between SI and SF
21431 (define_insn "cvtdq2ps"
21432   [(set (match_operand:V4SF 0 "register_operand" "=x")
21433         (float:V4SF (match_operand:V4SI 1 "nonimmediate_operand" "xm")))]
21434   "TARGET_SSE2"
21435   "cvtdq2ps\t{%1, %0|%0, %1}"
21436   [(set_attr "type" "ssecvt")
21437    (set_attr "mode" "V2DF")])
21439 (define_insn "cvtps2dq"
21440   [(set (match_operand:V4SI 0 "register_operand" "=x")
21441         (fix:V4SI (match_operand:V4SF 1 "nonimmediate_operand" "xm")))]
21442   "TARGET_SSE2"
21443   "cvtps2dq\t{%1, %0|%0, %1}"
21444   [(set_attr "type" "ssecvt")
21445    (set_attr "mode" "TI")])
21447 (define_insn "cvttps2dq"
21448   [(set (match_operand:V4SI 0 "register_operand" "=x")
21449         (unspec:V4SI [(match_operand:V4SF 1 "nonimmediate_operand" "xm")]
21450                      UNSPEC_FIX))]
21451   "TARGET_SSE2"
21452   "cvttps2dq\t{%1, %0|%0, %1}"
21453   [(set_attr "type" "ssecvt")
21454    (set_attr "mode" "TI")])
21456 ;; Conversions between SI and DF
21458 (define_insn "cvtdq2pd"
21459   [(set (match_operand:V2DF 0 "register_operand" "=x")
21460         (float:V2DF (vec_select:V2SI
21461                      (match_operand:V4SI 1 "nonimmediate_operand" "xm")
21462                      (parallel
21463                       [(const_int 0)
21464                        (const_int 1)]))))]
21465   "TARGET_SSE2"
21466   "cvtdq2pd\t{%1, %0|%0, %1}"
21467   [(set_attr "type" "ssecvt")
21468    (set_attr "mode" "V2DF")])
21470 (define_insn "cvtpd2dq"
21471   [(set (match_operand:V4SI 0 "register_operand" "=x")
21472         (vec_concat:V4SI
21473          (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "xm"))
21474          (const_vector:V2SI [(const_int 0) (const_int 0)])))]
21475   "TARGET_SSE2"
21476   "cvtpd2dq\t{%1, %0|%0, %1}"
21477   [(set_attr "type" "ssecvt")
21478    (set_attr "mode" "TI")])
21480 (define_insn "cvttpd2dq"
21481   [(set (match_operand:V4SI 0 "register_operand" "=x")
21482         (vec_concat:V4SI
21483          (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "xm")]
21484                       UNSPEC_FIX)
21485          (const_vector:V2SI [(const_int 0) (const_int 0)])))]
21486   "TARGET_SSE2"
21487   "cvttpd2dq\t{%1, %0|%0, %1}"
21488   [(set_attr "type" "ssecvt")
21489    (set_attr "mode" "TI")])
21491 (define_insn "cvtpd2pi"
21492   [(set (match_operand:V2SI 0 "register_operand" "=y")
21493         (fix:V2SI (match_operand:V2DF 1 "nonimmediate_operand" "xm")))]
21494   "TARGET_SSE2"
21495   "cvtpd2pi\t{%1, %0|%0, %1}"
21496   [(set_attr "type" "ssecvt")
21497    (set_attr "mode" "TI")])
21499 (define_insn "cvttpd2pi"
21500   [(set (match_operand:V2SI 0 "register_operand" "=y")
21501         (unspec:V2SI [(match_operand:V2DF 1 "nonimmediate_operand" "xm")]
21502                      UNSPEC_FIX))]
21503   "TARGET_SSE2"
21504   "cvttpd2pi\t{%1, %0|%0, %1}"
21505   [(set_attr "type" "ssecvt")
21506    (set_attr "mode" "TI")])
21508 (define_insn "cvtpi2pd"
21509   [(set (match_operand:V2DF 0 "register_operand" "=x")
21510         (float:V2DF (match_operand:V2SI 1 "nonimmediate_operand" "ym")))]
21511   "TARGET_SSE2"
21512   "cvtpi2pd\t{%1, %0|%0, %1}"
21513   [(set_attr "type" "ssecvt")
21514    (set_attr "mode" "TI")])
21516 ;; Conversions between SI and DF
21518 (define_insn "cvtsd2si"
21519   [(set (match_operand:SI 0 "register_operand" "=r")
21520         (fix:SI (vec_select:DF (match_operand:V2DF 1 "register_operand" "xm")
21521                                (parallel [(const_int 0)]))))]
21522   "TARGET_SSE2"
21523   "cvtsd2si\t{%1, %0|%0, %1}"
21524   [(set_attr "type" "sseicvt")
21525    (set_attr "mode" "SI")])
21527 (define_insn "cvttsd2si"
21528   [(set (match_operand:SI 0 "register_operand" "=r,r")
21529         (unspec:SI [(vec_select:DF (match_operand:V2DF 1 "register_operand" "x,xm")
21530                                    (parallel [(const_int 0)]))] UNSPEC_FIX))]
21531   "TARGET_SSE2"
21532   "cvttsd2si\t{%1, %0|%0, %1}"
21533   [(set_attr "type" "sseicvt")
21534    (set_attr "mode" "SI")
21535    (set_attr "athlon_decode" "double,vector")])
21537 (define_insn "cvtsi2sd"
21538   [(set (match_operand:V2DF 0 "register_operand" "=x,x")
21539         (vec_merge:V2DF (match_operand:V2DF 1 "register_operand" "0,0")
21540                         (vec_duplicate:V2DF
21541                           (float:DF
21542                             (match_operand:SI 2 "nonimmediate_operand" "r,rm")))
21543                         (const_int 2)))]
21544   "TARGET_SSE2"
21545   "cvtsi2sd\t{%2, %0|%0, %2}"
21546   [(set_attr "type" "sseicvt")
21547    (set_attr "mode" "DF")
21548    (set_attr "athlon_decode" "double,direct")])
21550 ;; Conversions between SF and DF
21552 (define_insn "cvtsd2ss"
21553   [(set (match_operand:V4SF 0 "register_operand" "=x,x")
21554         (vec_merge:V4SF (match_operand:V4SF 1 "register_operand" "0,0")
21555                         (vec_duplicate:V4SF
21556                           (float_truncate:V2SF
21557                             (match_operand:V2DF 2 "nonimmediate_operand" "x,xm")))
21558                         (const_int 14)))]
21559   "TARGET_SSE2"
21560   "cvtsd2ss\t{%2, %0|%0, %2}"
21561   [(set_attr "type" "ssecvt")
21562    (set_attr "athlon_decode" "vector,double")
21563    (set_attr "mode" "SF")])
21565 (define_insn "cvtss2sd"
21566   [(set (match_operand:V2DF 0 "register_operand" "=x")
21567         (vec_merge:V2DF (match_operand:V2DF 1 "register_operand" "0")
21568                         (float_extend:V2DF
21569                           (vec_select:V2SF
21570                             (match_operand:V4SF 2 "nonimmediate_operand" "xm")
21571                             (parallel [(const_int 0)
21572                                        (const_int 1)])))
21573                         (const_int 2)))]
21574   "TARGET_SSE2"
21575   "cvtss2sd\t{%2, %0|%0, %2}"
21576   [(set_attr "type" "ssecvt")
21577    (set_attr "mode" "DF")])
21579 (define_insn "cvtpd2ps"
21580   [(set (match_operand:V4SF 0 "register_operand" "=x")
21581         (subreg:V4SF
21582           (vec_concat:V4SI
21583             (subreg:V2SI (float_truncate:V2SF
21584                            (match_operand:V2DF 1 "nonimmediate_operand" "xm")) 0)
21585             (const_vector:V2SI [(const_int 0) (const_int 0)])) 0))]
21586   "TARGET_SSE2"
21587   "cvtpd2ps\t{%1, %0|%0, %1}"
21588   [(set_attr "type" "ssecvt")
21589    (set_attr "mode" "V4SF")])
21591 (define_insn "cvtps2pd"
21592   [(set (match_operand:V2DF 0 "register_operand" "=x")
21593         (float_extend:V2DF
21594           (vec_select:V2SF (match_operand:V4SF 1 "nonimmediate_operand" "xm")
21595                            (parallel [(const_int 0)
21596                                       (const_int 1)]))))]
21597   "TARGET_SSE2"
21598   "cvtps2pd\t{%1, %0|%0, %1}"
21599   [(set_attr "type" "ssecvt")
21600    (set_attr "mode" "V2DF")])
21602 ;; SSE2 variants of MMX insns
21604 ;; MMX arithmetic
21606 (define_insn "addv16qi3"
21607   [(set (match_operand:V16QI 0 "register_operand" "=x")
21608         (plus:V16QI (match_operand:V16QI 1 "register_operand" "0")
21609                     (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21610   "TARGET_SSE2"
21611   "paddb\t{%2, %0|%0, %2}"
21612   [(set_attr "type" "sseiadd")
21613    (set_attr "mode" "TI")])
21615 (define_insn "addv8hi3"
21616   [(set (match_operand:V8HI 0 "register_operand" "=x")
21617         (plus:V8HI (match_operand:V8HI 1 "register_operand" "0")
21618                    (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21619   "TARGET_SSE2"
21620   "paddw\t{%2, %0|%0, %2}"
21621   [(set_attr "type" "sseiadd")
21622    (set_attr "mode" "TI")])
21624 (define_insn "addv4si3"
21625   [(set (match_operand:V4SI 0 "register_operand" "=x")
21626         (plus:V4SI (match_operand:V4SI 1 "register_operand" "0")
21627                    (match_operand:V4SI 2 "nonimmediate_operand" "xm")))]
21628   "TARGET_SSE2"
21629   "paddd\t{%2, %0|%0, %2}"
21630   [(set_attr "type" "sseiadd")
21631    (set_attr "mode" "TI")])
21633 (define_insn "addv2di3"
21634   [(set (match_operand:V2DI 0 "register_operand" "=x")
21635         (plus:V2DI (match_operand:V2DI 1 "register_operand" "0")
21636                    (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
21637   "TARGET_SSE2"
21638   "paddq\t{%2, %0|%0, %2}"
21639   [(set_attr "type" "sseiadd")
21640    (set_attr "mode" "TI")])
21642 (define_insn "ssaddv16qi3"
21643   [(set (match_operand:V16QI 0 "register_operand" "=x")
21644         (ss_plus:V16QI (match_operand:V16QI 1 "register_operand" "0")
21645                        (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21646   "TARGET_SSE2"
21647   "paddsb\t{%2, %0|%0, %2}"
21648   [(set_attr "type" "sseiadd")
21649    (set_attr "mode" "TI")])
21651 (define_insn "ssaddv8hi3"
21652   [(set (match_operand:V8HI 0 "register_operand" "=x")
21653         (ss_plus:V8HI (match_operand:V8HI 1 "register_operand" "0")
21654                       (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21655   "TARGET_SSE2"
21656   "paddsw\t{%2, %0|%0, %2}"
21657   [(set_attr "type" "sseiadd")
21658    (set_attr "mode" "TI")])
21660 (define_insn "usaddv16qi3"
21661   [(set (match_operand:V16QI 0 "register_operand" "=x")
21662         (us_plus:V16QI (match_operand:V16QI 1 "register_operand" "0")
21663                        (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21664   "TARGET_SSE2"
21665   "paddusb\t{%2, %0|%0, %2}"
21666   [(set_attr "type" "sseiadd")
21667    (set_attr "mode" "TI")])
21669 (define_insn "usaddv8hi3"
21670   [(set (match_operand:V8HI 0 "register_operand" "=x")
21671         (us_plus:V8HI (match_operand:V8HI 1 "register_operand" "0")
21672                       (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21673   "TARGET_SSE2"
21674   "paddusw\t{%2, %0|%0, %2}"
21675   [(set_attr "type" "sseiadd")
21676    (set_attr "mode" "TI")])
21678 (define_insn "subv16qi3"
21679   [(set (match_operand:V16QI 0 "register_operand" "=x")
21680         (minus:V16QI (match_operand:V16QI 1 "register_operand" "0")
21681                      (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21682   "TARGET_SSE2"
21683   "psubb\t{%2, %0|%0, %2}"
21684   [(set_attr "type" "sseiadd")
21685    (set_attr "mode" "TI")])
21687 (define_insn "subv8hi3"
21688   [(set (match_operand:V8HI 0 "register_operand" "=x")
21689         (minus:V8HI (match_operand:V8HI 1 "register_operand" "0")
21690                     (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21691   "TARGET_SSE2"
21692   "psubw\t{%2, %0|%0, %2}"
21693   [(set_attr "type" "sseiadd")
21694    (set_attr "mode" "TI")])
21696 (define_insn "subv4si3"
21697   [(set (match_operand:V4SI 0 "register_operand" "=x")
21698         (minus:V4SI (match_operand:V4SI 1 "register_operand" "0")
21699                     (match_operand:V4SI 2 "nonimmediate_operand" "xm")))]
21700   "TARGET_SSE2"
21701   "psubd\t{%2, %0|%0, %2}"
21702   [(set_attr "type" "sseiadd")
21703    (set_attr "mode" "TI")])
21705 (define_insn "subv2di3"
21706   [(set (match_operand:V2DI 0 "register_operand" "=x")
21707         (minus:V2DI (match_operand:V2DI 1 "register_operand" "0")
21708                     (match_operand:V2DI 2 "nonimmediate_operand" "xm")))]
21709   "TARGET_SSE2"
21710   "psubq\t{%2, %0|%0, %2}"
21711   [(set_attr "type" "sseiadd")
21712    (set_attr "mode" "TI")])
21714 (define_insn "sssubv16qi3"
21715   [(set (match_operand:V16QI 0 "register_operand" "=x")
21716         (ss_minus:V16QI (match_operand:V16QI 1 "register_operand" "0")
21717                         (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21718   "TARGET_SSE2"
21719   "psubsb\t{%2, %0|%0, %2}"
21720   [(set_attr "type" "sseiadd")
21721    (set_attr "mode" "TI")])
21723 (define_insn "sssubv8hi3"
21724   [(set (match_operand:V8HI 0 "register_operand" "=x")
21725         (ss_minus:V8HI (match_operand:V8HI 1 "register_operand" "0")
21726                        (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21727   "TARGET_SSE2"
21728   "psubsw\t{%2, %0|%0, %2}"
21729   [(set_attr "type" "sseiadd")
21730    (set_attr "mode" "TI")])
21732 (define_insn "ussubv16qi3"
21733   [(set (match_operand:V16QI 0 "register_operand" "=x")
21734         (us_minus:V16QI (match_operand:V16QI 1 "register_operand" "0")
21735                         (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21736   "TARGET_SSE2"
21737   "psubusb\t{%2, %0|%0, %2}"
21738   [(set_attr "type" "sseiadd")
21739    (set_attr "mode" "TI")])
21741 (define_insn "ussubv8hi3"
21742   [(set (match_operand:V8HI 0 "register_operand" "=x")
21743         (us_minus:V8HI (match_operand:V8HI 1 "register_operand" "0")
21744                        (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21745   "TARGET_SSE2"
21746   "psubusw\t{%2, %0|%0, %2}"
21747   [(set_attr "type" "sseiadd")
21748    (set_attr "mode" "TI")])
21750 (define_insn "mulv8hi3"
21751   [(set (match_operand:V8HI 0 "register_operand" "=x")
21752         (mult:V8HI (match_operand:V8HI 1 "register_operand" "0")
21753                    (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21754   "TARGET_SSE2"
21755   "pmullw\t{%2, %0|%0, %2}"
21756   [(set_attr "type" "sseimul")
21757    (set_attr "mode" "TI")])
21759 (define_insn "smulv8hi3_highpart"
21760   [(set (match_operand:V8HI 0 "register_operand" "=x")
21761         (truncate:V8HI
21762          (lshiftrt:V8SI
21763           (mult:V8SI (sign_extend:V8SI (match_operand:V8HI 1 "register_operand" "0"))
21764                      (sign_extend:V8SI (match_operand:V8HI 2 "nonimmediate_operand" "xm")))
21765           (const_int 16))))]
21766   "TARGET_SSE2"
21767   "pmulhw\t{%2, %0|%0, %2}"
21768   [(set_attr "type" "sseimul")
21769    (set_attr "mode" "TI")])
21771 (define_insn "umulv8hi3_highpart"
21772   [(set (match_operand:V8HI 0 "register_operand" "=x")
21773         (truncate:V8HI
21774          (lshiftrt:V8SI
21775           (mult:V8SI (zero_extend:V8SI (match_operand:V8HI 1 "register_operand" "0"))
21776                      (zero_extend:V8SI (match_operand:V8HI 2 "nonimmediate_operand" "xm")))
21777           (const_int 16))))]
21778   "TARGET_SSE2"
21779   "pmulhuw\t{%2, %0|%0, %2}"
21780   [(set_attr "type" "sseimul")
21781    (set_attr "mode" "TI")])
21783 (define_insn "sse2_umulsidi3"
21784   [(set (match_operand:DI 0 "register_operand" "=y")
21785         (mult:DI (zero_extend:DI (vec_select:SI
21786                                   (match_operand:V2SI 1 "register_operand" "0")
21787                                   (parallel [(const_int 0)])))
21788                  (zero_extend:DI (vec_select:SI
21789                                   (match_operand:V2SI 2 "nonimmediate_operand" "ym")
21790                                   (parallel [(const_int 0)])))))]
21791   "TARGET_SSE2"
21792   "pmuludq\t{%2, %0|%0, %2}"
21793   [(set_attr "type" "sseimul")
21794    (set_attr "mode" "TI")])
21796 (define_insn "sse2_umulv2siv2di3"
21797   [(set (match_operand:V2DI 0 "register_operand" "=x")
21798         (mult:V2DI (zero_extend:V2DI
21799                      (vec_select:V2SI
21800                        (match_operand:V4SI 1 "register_operand" "0")
21801                        (parallel [(const_int 0) (const_int 2)])))
21802                    (zero_extend:V2DI
21803                      (vec_select:V2SI
21804                        (match_operand:V4SI 2 "nonimmediate_operand" "xm")
21805                        (parallel [(const_int 0) (const_int 2)])))))]
21806   "TARGET_SSE2"
21807   "pmuludq\t{%2, %0|%0, %2}"
21808   [(set_attr "type" "sseimul")
21809    (set_attr "mode" "TI")])
21811 (define_insn "sse2_pmaddwd"
21812   [(set (match_operand:V4SI 0 "register_operand" "=x")
21813         (plus:V4SI
21814          (mult:V4SI
21815           (sign_extend:V4SI (vec_select:V4HI (match_operand:V8HI 1 "register_operand" "0")
21816                                              (parallel [(const_int 0)
21817                                                         (const_int 2)
21818                                                         (const_int 4)
21819                                                         (const_int 6)])))
21820           (sign_extend:V4SI (vec_select:V4HI (match_operand:V8HI 2 "nonimmediate_operand" "xm")
21821                                              (parallel [(const_int 0)
21822                                                         (const_int 2)
21823                                                         (const_int 4)
21824                                                         (const_int 6)]))))
21825          (mult:V4SI
21826           (sign_extend:V4SI (vec_select:V4HI (match_dup 1)
21827                                              (parallel [(const_int 1)
21828                                                         (const_int 3)
21829                                                         (const_int 5)
21830                                                         (const_int 7)])))
21831           (sign_extend:V4SI (vec_select:V4HI (match_dup 2)
21832                                              (parallel [(const_int 1)
21833                                                         (const_int 3)
21834                                                         (const_int 5)
21835                                                         (const_int 7)]))))))]
21836   "TARGET_SSE2"
21837   "pmaddwd\t{%2, %0|%0, %2}"
21838   [(set_attr "type" "sseiadd")
21839    (set_attr "mode" "TI")])
21841 ;; Same as pxor, but don't show input operands so that we don't think
21842 ;; they are live.
21843 (define_insn "sse2_clrti"
21844   [(set (match_operand:TI 0 "register_operand" "=x") (const_int 0))]
21845   "TARGET_SSE2"
21847   if (get_attr_mode (insn) == MODE_TI)
21848     return "pxor\t%0, %0";
21849   else
21850     return "xorps\t%0, %0";
21852   [(set_attr "type" "ssemov")
21853    (set_attr "memory" "none")
21854    (set (attr "mode")
21855               (if_then_else
21856                 (ne (symbol_ref "optimize_size")
21857                     (const_int 0))
21858                 (const_string "V4SF")
21859                 (const_string "TI")))])
21861 ;; MMX unsigned averages/sum of absolute differences
21863 (define_insn "sse2_uavgv16qi3"
21864   [(set (match_operand:V16QI 0 "register_operand" "=x")
21865         (ashiftrt:V16QI
21866          (plus:V16QI (plus:V16QI
21867                      (match_operand:V16QI 1 "register_operand" "0")
21868                      (match_operand:V16QI 2 "nonimmediate_operand" "xm"))
21869                      (const_vector:V16QI [(const_int 1) (const_int 1)
21870                                           (const_int 1) (const_int 1)
21871                                           (const_int 1) (const_int 1)
21872                                           (const_int 1) (const_int 1)
21873                                           (const_int 1) (const_int 1)
21874                                           (const_int 1) (const_int 1)
21875                                           (const_int 1) (const_int 1)
21876                                           (const_int 1) (const_int 1)]))
21877          (const_int 1)))]
21878   "TARGET_SSE2"
21879   "pavgb\t{%2, %0|%0, %2}"
21880   [(set_attr "type" "sseiadd")
21881    (set_attr "mode" "TI")])
21883 (define_insn "sse2_uavgv8hi3"
21884   [(set (match_operand:V8HI 0 "register_operand" "=x")
21885         (ashiftrt:V8HI
21886          (plus:V8HI (plus:V8HI
21887                      (match_operand:V8HI 1 "register_operand" "0")
21888                      (match_operand:V8HI 2 "nonimmediate_operand" "xm"))
21889                     (const_vector:V8HI [(const_int 1) (const_int 1)
21890                                         (const_int 1) (const_int 1)
21891                                         (const_int 1) (const_int 1)
21892                                         (const_int 1) (const_int 1)]))
21893          (const_int 1)))]
21894   "TARGET_SSE2"
21895   "pavgw\t{%2, %0|%0, %2}"
21896   [(set_attr "type" "sseiadd")
21897    (set_attr "mode" "TI")])
21899 ;; @@@ this isn't the right representation.
21900 (define_insn "sse2_psadbw"
21901   [(set (match_operand:V2DI 0 "register_operand" "=x")
21902         (unspec:V2DI [(match_operand:V16QI 1 "register_operand" "0")
21903                       (match_operand:V16QI 2 "nonimmediate_operand" "xm")]
21904                      UNSPEC_PSADBW))]
21905   "TARGET_SSE2"
21906   "psadbw\t{%2, %0|%0, %2}"
21907   [(set_attr "type" "sseiadd")
21908    (set_attr "mode" "TI")])
21911 ;; MMX insert/extract/shuffle
21913 (define_insn "sse2_pinsrw"
21914   [(set (match_operand:V8HI 0 "register_operand" "=x")
21915         (vec_merge:V8HI (match_operand:V8HI 1 "register_operand" "0")
21916                         (vec_duplicate:V8HI
21917                          (match_operand:SI 2 "nonimmediate_operand" "rm"))
21918                         (match_operand:SI 3 "immediate_operand" "i")))]
21919   "TARGET_SSE2"
21920   "pinsrw\t{%3, %2, %0|%0, %2, %3}"
21921   [(set_attr "type" "ssecvt")
21922    (set_attr "mode" "TI")])
21924 (define_insn "sse2_pextrw"
21925   [(set (match_operand:SI 0 "register_operand" "=r")
21926         (zero_extend:SI
21927           (vec_select:HI (match_operand:V8HI 1 "register_operand" "x")
21928                          (parallel
21929                           [(match_operand:SI 2 "immediate_operand" "i")]))))]
21930   "TARGET_SSE2"
21931   "pextrw\t{%2, %1, %0|%0, %1, %2}"
21932   [(set_attr "type" "ssecvt")
21933    (set_attr "mode" "TI")])
21935 (define_insn "sse2_pshufd"
21936   [(set (match_operand:V4SI 0 "register_operand" "=x")
21937         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "0")
21938                       (match_operand:SI 2 "immediate_operand" "i")]
21939                      UNSPEC_SHUFFLE))]
21940   "TARGET_SSE2"
21941   "pshufd\t{%2, %1, %0|%0, %1, %2}"
21942   [(set_attr "type" "ssecvt")
21943    (set_attr "mode" "TI")])
21945 (define_insn "sse2_pshuflw"
21946   [(set (match_operand:V8HI 0 "register_operand" "=x")
21947         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "0")
21948                       (match_operand:SI 2 "immediate_operand" "i")]
21949                      UNSPEC_PSHUFLW))]
21950   "TARGET_SSE2"
21951   "pshuflw\t{%2, %1, %0|%0, %1, %2}"
21952   [(set_attr "type" "ssecvt")
21953    (set_attr "mode" "TI")])
21955 (define_insn "sse2_pshufhw"
21956   [(set (match_operand:V8HI 0 "register_operand" "=x")
21957         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "0")
21958                       (match_operand:SI 2 "immediate_operand" "i")]
21959                      UNSPEC_PSHUFHW))]
21960   "TARGET_SSE2"
21961   "pshufhw\t{%2, %1, %0|%0, %1, %2}"
21962   [(set_attr "type" "ssecvt")
21963    (set_attr "mode" "TI")])
21965 ;; MMX mask-generating comparisons
21967 (define_insn "eqv16qi3"
21968   [(set (match_operand:V16QI 0 "register_operand" "=x")
21969         (eq:V16QI (match_operand:V16QI 1 "register_operand" "0")
21970                  (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21971   "TARGET_SSE2"
21972   "pcmpeqb\t{%2, %0|%0, %2}"
21973   [(set_attr "type" "ssecmp")
21974    (set_attr "mode" "TI")])
21976 (define_insn "eqv8hi3"
21977   [(set (match_operand:V8HI 0 "register_operand" "=x")
21978         (eq:V8HI (match_operand:V8HI 1 "register_operand" "0")
21979                  (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
21980   "TARGET_SSE2"
21981   "pcmpeqw\t{%2, %0|%0, %2}"
21982   [(set_attr "type" "ssecmp")
21983    (set_attr "mode" "TI")])
21985 (define_insn "eqv4si3"
21986   [(set (match_operand:V4SI 0 "register_operand" "=x")
21987         (eq:V4SI (match_operand:V4SI 1 "register_operand" "0")
21988                  (match_operand:V4SI 2 "nonimmediate_operand" "xm")))]
21989   "TARGET_SSE2"
21990   "pcmpeqd\t{%2, %0|%0, %2}"
21991   [(set_attr "type" "ssecmp")
21992    (set_attr "mode" "TI")])
21994 (define_insn "gtv16qi3"
21995   [(set (match_operand:V16QI 0 "register_operand" "=x")
21996         (gt:V16QI (match_operand:V16QI 1 "register_operand" "0")
21997                  (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
21998   "TARGET_SSE2"
21999   "pcmpgtb\t{%2, %0|%0, %2}"
22000   [(set_attr "type" "ssecmp")
22001    (set_attr "mode" "TI")])
22003 (define_insn "gtv8hi3"
22004   [(set (match_operand:V8HI 0 "register_operand" "=x")
22005         (gt:V8HI (match_operand:V8HI 1 "register_operand" "0")
22006                  (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
22007   "TARGET_SSE2"
22008   "pcmpgtw\t{%2, %0|%0, %2}"
22009   [(set_attr "type" "ssecmp")
22010    (set_attr "mode" "TI")])
22012 (define_insn "gtv4si3"
22013   [(set (match_operand:V4SI 0 "register_operand" "=x")
22014         (gt:V4SI (match_operand:V4SI 1 "register_operand" "0")
22015                  (match_operand:V4SI 2 "nonimmediate_operand" "xm")))]
22016   "TARGET_SSE2"
22017   "pcmpgtd\t{%2, %0|%0, %2}"
22018   [(set_attr "type" "ssecmp")
22019    (set_attr "mode" "TI")])
22022 ;; MMX max/min insns
22024 (define_insn "umaxv16qi3"
22025   [(set (match_operand:V16QI 0 "register_operand" "=x")
22026         (umax:V16QI (match_operand:V16QI 1 "register_operand" "0")
22027                    (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
22028   "TARGET_SSE2"
22029   "pmaxub\t{%2, %0|%0, %2}"
22030   [(set_attr "type" "sseiadd")
22031    (set_attr "mode" "TI")])
22033 (define_insn "smaxv8hi3"
22034   [(set (match_operand:V8HI 0 "register_operand" "=x")
22035         (smax:V8HI (match_operand:V8HI 1 "register_operand" "0")
22036                    (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
22037   "TARGET_SSE2"
22038   "pmaxsw\t{%2, %0|%0, %2}"
22039   [(set_attr "type" "sseiadd")
22040    (set_attr "mode" "TI")])
22042 (define_insn "uminv16qi3"
22043   [(set (match_operand:V16QI 0 "register_operand" "=x")
22044         (umin:V16QI (match_operand:V16QI 1 "register_operand" "0")
22045                    (match_operand:V16QI 2 "nonimmediate_operand" "xm")))]
22046   "TARGET_SSE2"
22047   "pminub\t{%2, %0|%0, %2}"
22048   [(set_attr "type" "sseiadd")
22049    (set_attr "mode" "TI")])
22051 (define_insn "sminv8hi3"
22052   [(set (match_operand:V8HI 0 "register_operand" "=x")
22053         (smin:V8HI (match_operand:V8HI 1 "register_operand" "0")
22054                    (match_operand:V8HI 2 "nonimmediate_operand" "xm")))]
22055   "TARGET_SSE2"
22056   "pminsw\t{%2, %0|%0, %2}"
22057   [(set_attr "type" "sseiadd")
22058    (set_attr "mode" "TI")])
22061 ;; MMX shifts
22063 (define_insn "ashrv8hi3"
22064   [(set (match_operand:V8HI 0 "register_operand" "=x")
22065         (ashiftrt:V8HI (match_operand:V8HI 1 "register_operand" "0")
22066                        (match_operand:SI 2 "nonmemory_operand" "xi")))]
22067   "TARGET_SSE2"
22068   "psraw\t{%2, %0|%0, %2}"
22069   [(set_attr "type" "sseishft")
22070    (set_attr "mode" "TI")])
22072 (define_insn "ashrv4si3"
22073   [(set (match_operand:V4SI 0 "register_operand" "=x")
22074         (ashiftrt:V4SI (match_operand:V4SI 1 "register_operand" "0")
22075                        (match_operand:SI 2 "nonmemory_operand" "xi")))]
22076   "TARGET_SSE2"
22077   "psrad\t{%2, %0|%0, %2}"
22078   [(set_attr "type" "sseishft")
22079    (set_attr "mode" "TI")])
22081 (define_insn "lshrv8hi3"
22082   [(set (match_operand:V8HI 0 "register_operand" "=x")
22083         (lshiftrt:V8HI (match_operand:V8HI 1 "register_operand" "0")
22084                        (match_operand:SI 2 "nonmemory_operand" "xi")))]
22085   "TARGET_SSE2"
22086   "psrlw\t{%2, %0|%0, %2}"
22087   [(set_attr "type" "sseishft")
22088    (set_attr "mode" "TI")])
22090 (define_insn "lshrv4si3"
22091   [(set (match_operand:V4SI 0 "register_operand" "=x")
22092         (lshiftrt:V4SI (match_operand:V4SI 1 "register_operand" "0")
22093                        (match_operand:SI 2 "nonmemory_operand" "xi")))]
22094   "TARGET_SSE2"
22095   "psrld\t{%2, %0|%0, %2}"
22096   [(set_attr "type" "sseishft")
22097    (set_attr "mode" "TI")])
22099 (define_insn "lshrv2di3"
22100   [(set (match_operand:V2DI 0 "register_operand" "=x")
22101         (lshiftrt:V2DI (match_operand:V2DI 1 "register_operand" "0")
22102                        (match_operand:SI 2 "nonmemory_operand" "xi")))]
22103   "TARGET_SSE2"
22104   "psrlq\t{%2, %0|%0, %2}"
22105   [(set_attr "type" "sseishft")
22106    (set_attr "mode" "TI")])
22108 (define_insn "ashlv8hi3"
22109   [(set (match_operand:V8HI 0 "register_operand" "=x")
22110         (ashift:V8HI (match_operand:V8HI 1 "register_operand" "0")
22111                      (match_operand:SI 2 "nonmemory_operand" "xi")))]
22112   "TARGET_SSE2"
22113   "psllw\t{%2, %0|%0, %2}"
22114   [(set_attr "type" "sseishft")
22115    (set_attr "mode" "TI")])
22117 (define_insn "ashlv4si3"
22118   [(set (match_operand:V4SI 0 "register_operand" "=x")
22119         (ashift:V4SI (match_operand:V4SI 1 "register_operand" "0")
22120                      (match_operand:SI 2 "nonmemory_operand" "xi")))]
22121   "TARGET_SSE2"
22122   "pslld\t{%2, %0|%0, %2}"
22123   [(set_attr "type" "sseishft")
22124    (set_attr "mode" "TI")])
22126 (define_insn "ashlv2di3"
22127   [(set (match_operand:V2DI 0 "register_operand" "=x")
22128         (ashift:V2DI (match_operand:V2DI 1 "register_operand" "0")
22129                      (match_operand:SI 2 "nonmemory_operand" "xi")))]
22130   "TARGET_SSE2"
22131   "psllq\t{%2, %0|%0, %2}"
22132   [(set_attr "type" "sseishft")
22133    (set_attr "mode" "TI")])
22135 (define_insn "ashrv8hi3_ti"
22136   [(set (match_operand:V8HI 0 "register_operand" "=x")
22137         (ashiftrt:V8HI (match_operand:V8HI 1 "register_operand" "0")
22138                        (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22139   "TARGET_SSE2"
22140   "psraw\t{%2, %0|%0, %2}"
22141   [(set_attr "type" "sseishft")
22142    (set_attr "mode" "TI")])
22144 (define_insn "ashrv4si3_ti"
22145   [(set (match_operand:V4SI 0 "register_operand" "=x")
22146         (ashiftrt:V4SI (match_operand:V4SI 1 "register_operand" "0")
22147                        (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22148   "TARGET_SSE2"
22149   "psrad\t{%2, %0|%0, %2}"
22150   [(set_attr "type" "sseishft")
22151    (set_attr "mode" "TI")])
22153 (define_insn "lshrv8hi3_ti"
22154   [(set (match_operand:V8HI 0 "register_operand" "=x")
22155         (lshiftrt:V8HI (match_operand:V8HI 1 "register_operand" "0")
22156                        (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22157   "TARGET_SSE2"
22158   "psrlw\t{%2, %0|%0, %2}"
22159   [(set_attr "type" "sseishft")
22160    (set_attr "mode" "TI")])
22162 (define_insn "lshrv4si3_ti"
22163   [(set (match_operand:V4SI 0 "register_operand" "=x")
22164         (lshiftrt:V4SI (match_operand:V4SI 1 "register_operand" "0")
22165                        (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22166   "TARGET_SSE2"
22167   "psrld\t{%2, %0|%0, %2}"
22168   [(set_attr "type" "sseishft")
22169    (set_attr "mode" "TI")])
22171 (define_insn "lshrv2di3_ti"
22172   [(set (match_operand:V2DI 0 "register_operand" "=x")
22173         (lshiftrt:V2DI (match_operand:V2DI 1 "register_operand" "0")
22174                        (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22175   "TARGET_SSE2"
22176   "psrlq\t{%2, %0|%0, %2}"
22177   [(set_attr "type" "sseishft")
22178    (set_attr "mode" "TI")])
22180 (define_insn "ashlv8hi3_ti"
22181   [(set (match_operand:V8HI 0 "register_operand" "=x")
22182         (ashift:V8HI (match_operand:V8HI 1 "register_operand" "0")
22183                      (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22184   "TARGET_SSE2"
22185   "psllw\t{%2, %0|%0, %2}"
22186   [(set_attr "type" "sseishft")
22187    (set_attr "mode" "TI")])
22189 (define_insn "ashlv4si3_ti"
22190   [(set (match_operand:V4SI 0 "register_operand" "=x")
22191         (ashift:V4SI (match_operand:V4SI 1 "register_operand" "0")
22192                      (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22193   "TARGET_SSE2"
22194   "pslld\t{%2, %0|%0, %2}"
22195   [(set_attr "type" "sseishft")
22196    (set_attr "mode" "TI")])
22198 (define_insn "ashlv2di3_ti"
22199   [(set (match_operand:V2DI 0 "register_operand" "=x")
22200         (ashift:V2DI (match_operand:V2DI 1 "register_operand" "0")
22201                      (subreg:TI (match_operand:V2DI 2 "nonmemory_operand" "xi") 0)))]
22202   "TARGET_SSE2"
22203   "psllq\t{%2, %0|%0, %2}"
22204   [(set_attr "type" "sseishft")
22205    (set_attr "mode" "TI")])
22207 ;; See logical MMX insns for the reason for the unspec.  Strictly speaking
22208 ;; we wouldn't need here it since we never generate TImode arithmetic.
22210 ;; There has to be some kind of prize for the weirdest new instruction...
22211 (define_insn "sse2_ashlti3"
22212   [(set (match_operand:TI 0 "register_operand" "=x")
22213         (unspec:TI
22214          [(ashift:TI (match_operand:TI 1 "register_operand" "0")
22215                      (mult:SI (match_operand:SI 2 "immediate_operand" "i")
22216                                (const_int 8)))] UNSPEC_NOP))]
22217   "TARGET_SSE2"
22218   "pslldq\t{%2, %0|%0, %2}"
22219   [(set_attr "type" "sseishft")
22220    (set_attr "mode" "TI")])
22222 (define_insn "sse2_lshrti3"
22223   [(set (match_operand:TI 0 "register_operand" "=x")
22224         (unspec:TI
22225          [(lshiftrt:TI (match_operand:TI 1 "register_operand" "0")
22226                        (mult:SI (match_operand:SI 2 "immediate_operand" "i")
22227                                 (const_int 8)))] UNSPEC_NOP))]
22228   "TARGET_SSE2"
22229   "psrldq\t{%2, %0|%0, %2}"
22230   [(set_attr "type" "sseishft")
22231    (set_attr "mode" "TI")])
22233 ;; SSE unpack
22235 (define_insn "sse2_unpckhpd"
22236   [(set (match_operand:V2DF 0 "register_operand" "=x")
22237         (vec_concat:V2DF
22238          (vec_select:DF (match_operand:V2DF 1 "register_operand" "0")
22239                         (parallel [(const_int 1)]))
22240          (vec_select:DF (match_operand:V2DF 2 "register_operand" "x")
22241                         (parallel [(const_int 0)]))))]
22242   "TARGET_SSE2"
22243   "unpckhpd\t{%2, %0|%0, %2}"
22244   [(set_attr "type" "ssecvt")
22245    (set_attr "mode" "TI")])
22247 (define_insn "sse2_unpcklpd"
22248   [(set (match_operand:V2DF 0 "register_operand" "=x")
22249         (vec_concat:V2DF
22250          (vec_select:DF (match_operand:V2DF 1 "register_operand" "0")
22251                         (parallel [(const_int 0)]))
22252          (vec_select:DF (match_operand:V2DF 2 "register_operand" "x")
22253                         (parallel [(const_int 1)]))))]
22254   "TARGET_SSE2"
22255   "unpcklpd\t{%2, %0|%0, %2}"
22256   [(set_attr "type" "ssecvt")
22257    (set_attr "mode" "TI")])
22259 ;; MMX pack/unpack insns.
22261 (define_insn "sse2_packsswb"
22262   [(set (match_operand:V16QI 0 "register_operand" "=x")
22263         (vec_concat:V16QI
22264          (ss_truncate:V8QI (match_operand:V8HI 1 "register_operand" "0"))
22265          (ss_truncate:V8QI (match_operand:V8HI 2 "register_operand" "x"))))]
22266   "TARGET_SSE2"
22267   "packsswb\t{%2, %0|%0, %2}"
22268   [(set_attr "type" "ssecvt")
22269    (set_attr "mode" "TI")])
22271 (define_insn "sse2_packssdw"
22272   [(set (match_operand:V8HI 0 "register_operand" "=x")
22273         (vec_concat:V8HI
22274          (ss_truncate:V4HI (match_operand:V4SI 1 "register_operand" "0"))
22275          (ss_truncate:V4HI (match_operand:V4SI 2 "register_operand" "x"))))]
22276   "TARGET_SSE2"
22277   "packssdw\t{%2, %0|%0, %2}"
22278   [(set_attr "type" "ssecvt")
22279    (set_attr "mode" "TI")])
22281 (define_insn "sse2_packuswb"
22282   [(set (match_operand:V16QI 0 "register_operand" "=x")
22283         (vec_concat:V16QI
22284          (us_truncate:V8QI (match_operand:V8HI 1 "register_operand" "0"))
22285          (us_truncate:V8QI (match_operand:V8HI 2 "register_operand" "x"))))]
22286   "TARGET_SSE2"
22287   "packuswb\t{%2, %0|%0, %2}"
22288   [(set_attr "type" "ssecvt")
22289    (set_attr "mode" "TI")])
22291 (define_insn "sse2_punpckhbw"
22292   [(set (match_operand:V16QI 0 "register_operand" "=x")
22293         (vec_merge:V16QI
22294          (vec_select:V16QI (match_operand:V16QI 1 "register_operand" "0")
22295                            (parallel [(const_int 8) (const_int 0)
22296                                       (const_int 9) (const_int 1)
22297                                       (const_int 10) (const_int 2)
22298                                       (const_int 11) (const_int 3)
22299                                       (const_int 12) (const_int 4)
22300                                       (const_int 13) (const_int 5)
22301                                       (const_int 14) (const_int 6)
22302                                       (const_int 15) (const_int 7)]))
22303          (vec_select:V16QI (match_operand:V16QI 2 "register_operand" "x")
22304                            (parallel [(const_int 0) (const_int 8)
22305                                       (const_int 1) (const_int 9)
22306                                       (const_int 2) (const_int 10)
22307                                       (const_int 3) (const_int 11)
22308                                       (const_int 4) (const_int 12)
22309                                       (const_int 5) (const_int 13)
22310                                       (const_int 6) (const_int 14)
22311                                       (const_int 7) (const_int 15)]))
22312          (const_int 21845)))]
22313   "TARGET_SSE2"
22314   "punpckhbw\t{%2, %0|%0, %2}"
22315   [(set_attr "type" "ssecvt")
22316    (set_attr "mode" "TI")])
22318 (define_insn "sse2_punpckhwd"
22319   [(set (match_operand:V8HI 0 "register_operand" "=x")
22320         (vec_merge:V8HI
22321          (vec_select:V8HI (match_operand:V8HI 1 "register_operand" "0")
22322                           (parallel [(const_int 4) (const_int 0)
22323                                      (const_int 5) (const_int 1)
22324                                      (const_int 6) (const_int 2)
22325                                      (const_int 7) (const_int 3)]))
22326          (vec_select:V8HI (match_operand:V8HI 2 "register_operand" "x")
22327                           (parallel [(const_int 0) (const_int 4)
22328                                      (const_int 1) (const_int 5)
22329                                      (const_int 2) (const_int 6)
22330                                      (const_int 3) (const_int 7)]))
22331          (const_int 85)))]
22332   "TARGET_SSE2"
22333   "punpckhwd\t{%2, %0|%0, %2}"
22334   [(set_attr "type" "ssecvt")
22335    (set_attr "mode" "TI")])
22337 (define_insn "sse2_punpckhdq"
22338   [(set (match_operand:V4SI 0 "register_operand" "=x")
22339         (vec_merge:V4SI
22340          (vec_select:V4SI (match_operand:V4SI 1 "register_operand" "0")
22341                           (parallel [(const_int 2) (const_int 0)
22342                                      (const_int 3) (const_int 1)]))
22343          (vec_select:V4SI (match_operand:V4SI 2 "register_operand" "x")
22344                           (parallel [(const_int 0) (const_int 2)
22345                                      (const_int 1) (const_int 3)]))
22346          (const_int 5)))]
22347   "TARGET_SSE2"
22348   "punpckhdq\t{%2, %0|%0, %2}"
22349   [(set_attr "type" "ssecvt")
22350    (set_attr "mode" "TI")])
22352 (define_insn "sse2_punpcklbw"
22353   [(set (match_operand:V16QI 0 "register_operand" "=x")
22354         (vec_merge:V16QI
22355          (vec_select:V16QI (match_operand:V16QI 1 "register_operand" "0")
22356                            (parallel [(const_int 0) (const_int 8)
22357                                       (const_int 1) (const_int 9)
22358                                       (const_int 2) (const_int 10)
22359                                       (const_int 3) (const_int 11)
22360                                       (const_int 4) (const_int 12)
22361                                       (const_int 5) (const_int 13)
22362                                       (const_int 6) (const_int 14)
22363                                       (const_int 7) (const_int 15)]))
22364          (vec_select:V16QI (match_operand:V16QI 2 "register_operand" "x")
22365                            (parallel [(const_int 8) (const_int 0)
22366                                       (const_int 9) (const_int 1)
22367                                       (const_int 10) (const_int 2)
22368                                       (const_int 11) (const_int 3)
22369                                       (const_int 12) (const_int 4)
22370                                       (const_int 13) (const_int 5)
22371                                       (const_int 14) (const_int 6)
22372                                       (const_int 15) (const_int 7)]))
22373          (const_int 21845)))]
22374   "TARGET_SSE2"
22375   "punpcklbw\t{%2, %0|%0, %2}"
22376   [(set_attr "type" "ssecvt")
22377    (set_attr "mode" "TI")])
22379 (define_insn "sse2_punpcklwd"
22380   [(set (match_operand:V8HI 0 "register_operand" "=x")
22381         (vec_merge:V8HI
22382          (vec_select:V8HI (match_operand:V8HI 1 "register_operand" "0")
22383                           (parallel [(const_int 0) (const_int 4)
22384                                      (const_int 1) (const_int 5)
22385                                      (const_int 2) (const_int 6)
22386                                      (const_int 3) (const_int 7)]))
22387          (vec_select:V8HI (match_operand:V8HI 2 "register_operand" "x")
22388                           (parallel [(const_int 4) (const_int 0)
22389                                      (const_int 5) (const_int 1)
22390                                      (const_int 6) (const_int 2)
22391                                      (const_int 7) (const_int 3)]))
22392          (const_int 85)))]
22393   "TARGET_SSE2"
22394   "punpcklwd\t{%2, %0|%0, %2}"
22395   [(set_attr "type" "ssecvt")
22396    (set_attr "mode" "TI")])
22398 (define_insn "sse2_punpckldq"
22399   [(set (match_operand:V4SI 0 "register_operand" "=x")
22400         (vec_merge:V4SI
22401          (vec_select:V4SI (match_operand:V4SI 1 "register_operand" "0")
22402                           (parallel [(const_int 0) (const_int 2)
22403                                      (const_int 1) (const_int 3)]))
22404          (vec_select:V4SI (match_operand:V4SI 2 "register_operand" "x")
22405                           (parallel [(const_int 2) (const_int 0)
22406                                      (const_int 3) (const_int 1)]))
22407          (const_int 5)))]
22408   "TARGET_SSE2"
22409   "punpckldq\t{%2, %0|%0, %2}"
22410   [(set_attr "type" "ssecvt")
22411    (set_attr "mode" "TI")])
22413 (define_insn "sse2_punpcklqdq"
22414   [(set (match_operand:V2DI 0 "register_operand" "=x")
22415         (vec_merge:V2DI
22416          (vec_select:V2DI (match_operand:V2DI 2 "register_operand" "x")
22417                           (parallel [(const_int 1)
22418                                      (const_int 0)]))
22419          (match_operand:V2DI 1 "register_operand" "0")
22420          (const_int 1)))]
22421   "TARGET_SSE2"
22422   "punpcklqdq\t{%2, %0|%0, %2}"
22423   [(set_attr "type" "ssecvt")
22424    (set_attr "mode" "TI")])
22426 (define_insn "sse2_punpckhqdq"
22427   [(set (match_operand:V2DI 0 "register_operand" "=x")
22428         (vec_merge:V2DI
22429          (match_operand:V2DI 1 "register_operand" "0")
22430          (vec_select:V2DI (match_operand:V2DI 2 "register_operand" "x")
22431                           (parallel [(const_int 1)
22432                                      (const_int 0)]))
22433          (const_int 1)))]
22434   "TARGET_SSE2"
22435   "punpckhqdq\t{%2, %0|%0, %2}"
22436   [(set_attr "type" "ssecvt")
22437    (set_attr "mode" "TI")])
22439 ;; SSE2 moves
22441 (define_insn "sse2_movapd"
22442   [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
22443         (unspec:V2DF [(match_operand:V2DF 1 "nonimmediate_operand" "xm,x")]
22444                      UNSPEC_MOVA))]
22445   "TARGET_SSE2
22446    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
22447   "movapd\t{%1, %0|%0, %1}"
22448   [(set_attr "type" "ssemov")
22449    (set_attr "mode" "V2DF")])
22451 (define_insn "sse2_movupd"
22452   [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
22453         (unspec:V2DF [(match_operand:V2DF 1 "nonimmediate_operand" "xm,x")]
22454                      UNSPEC_MOVU))]
22455   "TARGET_SSE2
22456    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
22457   "movupd\t{%1, %0|%0, %1}"
22458   [(set_attr "type" "ssecvt")
22459    (set_attr "mode" "V2DF")])
22461 (define_insn "sse2_movdqa"
22462   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=x,m")
22463         (unspec:V16QI [(match_operand:V16QI 1 "nonimmediate_operand" "xm,x")]
22464                        UNSPEC_MOVA))]
22465   "TARGET_SSE2
22466    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
22467   "movdqa\t{%1, %0|%0, %1}"
22468   [(set_attr "type" "ssemov")
22469    (set_attr "mode" "TI")])
22471 (define_insn "sse2_movdqu"
22472   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=x,m")
22473         (unspec:V16QI [(match_operand:V16QI 1 "nonimmediate_operand" "xm,x")]
22474                        UNSPEC_MOVU))]
22475   "TARGET_SSE2
22476    && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
22477   "movdqu\t{%1, %0|%0, %1}"
22478   [(set_attr "type" "ssecvt")
22479    (set_attr "mode" "TI")])
22481 (define_insn "sse2_movdq2q"
22482   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,y")
22483         (vec_select:DI (match_operand:V2DI 1 "register_operand" "x,x")
22484                        (parallel [(const_int 0)])))]
22485   "TARGET_SSE2"
22486   "@
22487    movq\t{%1, %0|%0, %1}
22488    movdq2q\t{%1, %0|%0, %1}"
22489   [(set_attr "type" "ssecvt")
22490    (set_attr "mode" "TI")])
22492 (define_insn "sse2_movq2dq"
22493   [(set (match_operand:V2DI 0 "register_operand" "=x,?x")
22494         (vec_concat:V2DI (match_operand:DI 1 "nonimmediate_operand" "m,y")
22495                          (const_int 0)))]
22496   "TARGET_SSE2"
22497   "@
22498    movq\t{%1, %0|%0, %1}
22499    movq2dq\t{%1, %0|%0, %1}"
22500   [(set_attr "type" "ssecvt,ssemov")
22501    (set_attr "mode" "TI")])
22503 (define_insn "sse2_movq"
22504   [(set (match_operand:V2DI 0 "register_operand" "=x")
22505         (vec_concat:V2DI (vec_select:DI
22506                           (match_operand:V2DI 1 "nonimmediate_operand" "xm")
22507                           (parallel [(const_int 0)]))
22508                          (const_int 0)))]
22509   "TARGET_SSE2"
22510   "movq\t{%1, %0|%0, %1}"
22511   [(set_attr "type" "ssemov")
22512    (set_attr "mode" "TI")])
22514 (define_insn "sse2_loadd"
22515   [(set (match_operand:V4SI 0 "register_operand" "=x")
22516         (vec_merge:V4SI
22517          (vec_duplicate:V4HI (match_operand:SI 1 "nonimmediate_operand" "mr"))
22518          (const_vector:V4SI [(const_int 0)
22519                              (const_int 0)
22520                              (const_int 0)
22521                              (const_int 0)])
22522          (const_int 1)))]
22523   "TARGET_SSE2"
22524   "movd\t{%1, %0|%0, %1}"
22525   [(set_attr "type" "ssemov")
22526    (set_attr "mode" "TI")])
22528 (define_insn "sse2_stored"
22529   [(set (match_operand:SI 0 "nonimmediate_operand" "=mr")
22530         (vec_select:SI
22531          (match_operand:V4SI 1 "register_operand" "x")
22532          (parallel [(const_int 0)])))]
22533   "TARGET_SSE2"
22534   "movd\t{%1, %0|%0, %1}"
22535   [(set_attr "type" "ssemov")
22536    (set_attr "mode" "TI")])
22538 (define_insn "sse2_movhpd"
22539   [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
22540         (vec_merge:V2DF
22541          (match_operand:V2DF 1 "nonimmediate_operand" "0,0")
22542          (match_operand:V2DF 2 "nonimmediate_operand" "m,x")
22543          (const_int 2)))]
22544   "TARGET_SSE2 && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
22545   "movhpd\t{%2, %0|%0, %2}"
22546   [(set_attr "type" "ssecvt")
22547    (set_attr "mode" "V2DF")])
22549 (define_insn "sse2_movlpd"
22550   [(set (match_operand:V2DF 0 "nonimmediate_operand" "=x,m")
22551         (vec_merge:V2DF
22552          (match_operand:V2DF 1 "nonimmediate_operand" "0,0")
22553          (match_operand:V2DF 2 "nonimmediate_operand" "m,x")
22554          (const_int 1)))]
22555   "TARGET_SSE2 && (GET_CODE (operands[1]) == MEM || GET_CODE (operands[2]) == MEM)"
22556   "movlpd\t{%2, %0|%0, %2}"
22557   [(set_attr "type" "ssecvt")
22558    (set_attr "mode" "V2DF")])
22560 (define_expand "sse2_loadsd"
22561   [(match_operand:V2DF 0 "register_operand" "")
22562    (match_operand:DF 1 "memory_operand" "")]
22563   "TARGET_SSE2"
22565   emit_insn (gen_sse2_loadsd_1 (operands[0], operands[1],
22566                                 CONST0_RTX (V2DFmode)));
22567   DONE;
22570 (define_insn "sse2_loadsd_1"
22571   [(set (match_operand:V2DF 0 "register_operand" "=x")
22572         (vec_merge:V2DF
22573          (vec_duplicate:V2DF (match_operand:DF 1 "memory_operand" "m"))
22574          (match_operand:V2DF 2 "const0_operand" "X")
22575          (const_int 1)))]
22576   "TARGET_SSE2"
22577   "movsd\t{%1, %0|%0, %1}"
22578   [(set_attr "type" "ssecvt")
22579    (set_attr "mode" "DF")])
22581 (define_insn "sse2_movsd"
22582   [(set (match_operand:V2DF 0 "register_operand" "=x")
22583         (vec_merge:V2DF
22584          (match_operand:V2DF 1 "register_operand" "0")
22585          (match_operand:V2DF 2 "register_operand" "x")
22586          (const_int 1)))]
22587   "TARGET_SSE2"
22588   "movsd\t{%2, %0|%0, %2}"
22589   [(set_attr "type" "ssecvt")
22590    (set_attr "mode" "DF")])
22592 (define_insn "sse2_storesd"
22593   [(set (match_operand:DF 0 "memory_operand" "=m")
22594         (vec_select:DF
22595          (match_operand:V2DF 1 "register_operand" "x")
22596          (parallel [(const_int 0)])))]
22597   "TARGET_SSE2"
22598   "movsd\t{%1, %0|%0, %1}"
22599   [(set_attr "type" "ssecvt")
22600    (set_attr "mode" "DF")])
22602 (define_insn "sse2_shufpd"
22603   [(set (match_operand:V2DF 0 "register_operand" "=x")
22604         (unspec:V2DF [(match_operand:V2DF 1 "register_operand" "0")
22605                       (match_operand:V2DF 2 "nonimmediate_operand" "xm")
22606                       (match_operand:SI 3 "immediate_operand" "i")]
22607                      UNSPEC_SHUFFLE))]
22608   "TARGET_SSE2"
22609   ;; @@@ check operand order for intel/nonintel syntax
22610   "shufpd\t{%3, %2, %0|%0, %2, %3}"
22611   [(set_attr "type" "ssecvt")
22612    (set_attr "mode" "V2DF")])
22614 (define_insn "sse2_clflush"
22615   [(unspec_volatile [(match_operand 0 "address_operand" "p")]
22616                     UNSPECV_CLFLUSH)]
22617   "TARGET_SSE2"
22618   "clflush %0"
22619   [(set_attr "type" "sse")
22620    (set_attr "memory" "unknown")])
22622 (define_expand "sse2_mfence"
22623   [(set (match_dup 0)
22624         (unspec:BLK [(match_dup 0)] UNSPEC_MFENCE))]
22625   "TARGET_SSE2"
22627   operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
22628   MEM_VOLATILE_P (operands[0]) = 1;
22631 (define_insn "*mfence_insn"
22632   [(set (match_operand:BLK 0 "" "")
22633         (unspec:BLK [(match_dup 0)] UNSPEC_MFENCE))]
22634   "TARGET_SSE2"
22635   "mfence"
22636   [(set_attr "type" "sse")
22637    (set_attr "memory" "unknown")])
22639 (define_expand "sse2_lfence"
22640   [(set (match_dup 0)
22641         (unspec:BLK [(match_dup 0)] UNSPEC_LFENCE))]
22642   "TARGET_SSE2"
22644   operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
22645   MEM_VOLATILE_P (operands[0]) = 1;
22648 (define_insn "*lfence_insn"
22649   [(set (match_operand:BLK 0 "" "")
22650         (unspec:BLK [(match_dup 0)] UNSPEC_LFENCE))]
22651   "TARGET_SSE2"
22652   "lfence"
22653   [(set_attr "type" "sse")
22654    (set_attr "memory" "unknown")])